Exemple #1
0
    def __init__(self, l=None):
        Seq.__init__(self)

        if l is None:
            self.data = []
        else:
            self.data = l
Exemple #2
0
def gene(seq_name):
    PATH = "./projects/" + seq_name + ".txt"
    s1 = Seq()
    s1.seq_read_fasta(PATH)
    context = {'gene_name': seq_name, 'gene_contents': s1.bases}
    contents = read_html_file('./html/gene.html').render(context=context)
    return contents
    def __init__(self, maf_file, annotations_file, regions_names, coding=True):

        Seq.__init__(self)

        self.coding = coding
        annotations = Importer.get_lines_from_file(annotations_file)
        maf_file = Importer.get_lines_from_file(maf_file)

        for region_name in regions_names:
            print(region_name)
            self.tri_num = 0
            self.mutation_number = 0

            self.trinucleotides_occurences = self.generate_empty_params()
            self.neutral_matrix = self.generate_empty_params()

            print('extracting annotations')
            regions = self.extract_regions_from_annotations(
                annotations, region_name)

            print('analysing sequence')
            self.analyse_maf_file(maf_file, regions)

            self.export_tri_occ_and_mutations(region_name)
            self.normalize_neutral_matrix()
            self.export_results(region_name)
            print()
Exemple #4
0
def info(cs, sequence):
    print_colored("INFO", "green")
    seq = Seq(sequence)
    response = seq.percentage_base(
    )  # -- We have created a new function in Seq1.py to print A: number (percentage)%
    final_response = "Sequence: " + sequence + "\n" + "Total Length: " + str(
        seq.len()) + "\n" + response
    print(final_response)
    cs.send(str(final_response).encode())
Exemple #5
0
def gene(seq_name):
    PATH = "./sequences/" + seq_name
    s1 = Seq()
    s1.read_fasta(PATH)
    context = {
        'gene_name': seq_name,
        'gene_contents': s1.bases
    }
    contents = read_template_html_file('./html/gene.html').render(context=context)
    return contents
Exemple #6
0
def gene_calc(gene):

    good, id = get_id(gene)
    if good:
        endpoint = '/sequence/id/'
        params = f'{id}?content-type=application/json'
        url = endpoint + params

        conn = http.client.HTTPConnection(SERVER)
        conn.request("GET", url)
        response = conn.getresponse()
        status = GOOD_REQUEST
        if response.status == GOOD_REQUEST:
            data = json.loads(response.read().decode("utf-8"))
            try:
                bases = data['seq']
                seq = Seq(bases)
                context = {"gene": gene, "seq": seq}
                contents = read_template_html_file(
                    "html/gene_calc.html").render(context=context)
            except KeyError:
                status = BAD_REQUEST
                contents = Path("./html/error.html").read_text()
        else:
            status = BAD_REQUEST
            contents = Path("./html/error.html").read_text()
    else:
        status = BAD_REQUEST
        contents = Path("./html/error.html").read_text()
    return status, contents
Exemple #7
0
def test():
    size = MPI.COMM_WORLD.Get_size()
    rank = MPI.COMM_WORLD.Get_rank()
    name = MPI.Get_processor_name()
    with Seq(MPI.COMM_WORLD, 1, 10):
        print("Hello, World! I am process %d of %d on %s." %
              (rank, size, name))
Exemple #8
0
def num_to_seq(fn, loader):
    """Given a filename of the form 'directory/start#end' finds all files that match the given form, where # is an arbitrary number. The files are sorted into numerical order, and each is loaded using the provided loader (ReadCV for instance - constructor should take a single filename.), a Seq object is then created. This in effect turns a directory of numbered video files into a single video file."""
    # Break the given filename form into its basic parts...
    path, fn = os.path.split(fn)
    start, end = map(lambda s: s.replace('#', ''), fn.split('#', 1))

    # Get all files from the directory, filter it down to only those that match the form...
    files = os.listdir(path)

    def valid(fn):
        if fn[:len(start)] != start: return False
        if fn[-len(end):] != end: return False
        if not fn[len(start):-len(end)].isdigit(): return False
        return True

    files = filter(valid, files)

    # Get the relevant numbers, sort the files by them...
    files.sort(key=lambda fn: int(fn[len(start):-len(end)]))

    # Put the paths back...
    files = map(lambda f: os.path.join(path, f), files)

    # Loop and load the files...
    seq = map(lambda fn: loader(fn), files)

    # Create and return the sequence object...
    return Seq(seq)
Exemple #9
0
def main(op,
         file_dir,
         target_dir,
         num_channel=1,
         redo=False,
         origin_size=32,
         out_size=32):
    s = Seq()

    if op == 'image':
        s.generate_image(file_dir, target_dir, num_channel, origin_size,
                         out_size, redo)
    elif op == 'clean':
        s.clean_image(file_dir)
    elif op == 'mean':
        s.generate_mean(file_dir, target_dir, num_channel, out_size)
    else:
        raise NameError('The operation type {} is undefined'.format(op))
Exemple #10
0
    "RBMY2YP": "ENSG00000227633",
    "FGFR3": "ENSG00000068078",
    "KDR": "ENSG00000128052",
    "ANK2": "ENSG00000145362"
}

SERVER = "rest.ensembl.org"
ENDPOINT = "/sequence/id/"

PARAMETERS = "?content-type=application/json"

connection = http.client.HTTPConnection(SERVER)
try:
    user_gene = input("Enter the gene that you want to analyze:")
    id = DICT_GENE[user_gene]
    connection.request("GET", ENDPOINT + id + PARAMETERS)
    response = connection.getresponse()
    if response.status == 200:
        response_dict = json.loads(response.read().decode())
        sequence = Seq(response_dict["seq"])
        s_length = sequence.len()
        percentages = sequence.percentage_base(sequence.count_base())
        most_frequent_base = sequence.frequent_base(sequence.count())
        print("Total length:", s_length)
        for value in percentages.values():
            print(value)
        print("Most frequent base:", most_frequent_base)
except KeyError:
    print("The key is not inside our dictionary. Choose one of the following:",
          list(DICT_GENE.keys))
Exemple #11
0
from seq import Seq

print("-------Exercise 1-------")
s = Seq("ACTGA")
print(f"Sequence 1: (length:{s.len()}) {s}")
Exemple #12
0
		return self.ss[strand][chrom][min(up, down):max(up, down)]

	def _linear_search(self, chrom, strand, pos, start = 0):
		for i in xrange(start, len(self.ss[strand][chrom])):
			if self.ss[strand][chrom][i][0] > pos:
				return i
		return len(self.ss[strand][chrom])

MAX_ALLOWED_INSERT = 1000
MAX_FIVE_INSERT = 400
OVERHANG = 10           # Don't extract reads short of an annotated splice site by less than this.
ALLOW_ANNO_AGGT = True  # Allow alignment to anno splice sites with seq AGGT and inside bigger intron.

samfile = pysam.AlignmentFile(sys.argv[1])
jxns    = Junctions(sys.argv[2])
seq = Seq(load_genome(open(sys.argv[3], 'r')))
sample = sys.argv[4]

for read in samfile.fetch():
	if not read.is_read2: continue
	if read.reference_id != read.next_reference_id: continue

	strand = (read.is_read1 == read.is_reverse)
	strand_str = '+' if strand else '-'
	chrom = samfile.getrname(read.reference_id)
	if chrom[:3] == 'chr': chrom = chrom[3:]

	# The following two blocks are identical and handle + and - strands.
	if strand and read.pnext - read.pos > MAX_ALLOWED_INSERT:
		inner_left = read.get_blocks()[-1][1] # End   of mate #1
		inner_right = read.pnext              # Start of mate #2
Exemple #13
0
from Hello.Client0 import Client
from seq import Seq

PRACTICE = 2
EXERCISE = 7

print(f"--------| {PRACTICE}, Exercise {EXERCISE} |-------")

IP = "127.0.0.1"
PORT = 9992
PORT_2 = 9777
c = Client(IP, PORT)
c_2 = Client(IP, PORT_2)

s = Seq()
s.read_fasta_format("../P1/FRAT1.txt")
count = 0
i = 0
while i < len(s.bases) and count < 5:
    fragment = s.bases[i:i + 10]
    count += 1
    i += 10
    print(f"Fragment {count} : {fragment}")
    if count % 2 == 0:
        print(c_2.talk(f"Fragment {count} : {fragment}"))
    else:
        print(c.talk(f"Fragment {count} : {fragment}"))
Exemple #14
0
def comp(cs, argument):
    print_colored("COMP", "green")
    seq = Seq(argument)
    complement = seq.complement()
    print(complement)
    cs.send(complement.encode())
Exemple #15
0
from seq import Seq


print("-----| Exercise 9 |------")
s = Seq()

s.read_fasta("U5.txt")

print(f"Sequence: (Length: {s.len()}) {s}")
print(f"\tBases: {s.count()}")
print(f"\tRev: {s.reverse()}")
print(f"\tComp: {s.complement()}")
Exemple #16
0
from seq import Seq
import operator

print("-------Exercise 10-------")
FASTA_GENE_SEQ = ["U5.txt", "FRAT1.txt", "FXN.txt", "RNU6_269P.txt", "ADA.txt"]
for fasta in FASTA_GENE_SEQ:
    s = Seq()
    s.read_fasta_format(fasta)
    var = s.count()
    max_key = max(var, key=var.get)
    print(max_key)
Exemple #17
0
from seq import Seq

print("-----|  Exercise 9 |------")
s = Seq()
s.read_fasta_format('U5.txt')

print(f"Sequence: (Length: {s.len()}) {s}")
print(f"\tBases: {s.count()}")
print(f"\tRev: {s.reverse_mode()}")
print(f"\tComp: {s.complementary()}")
                try:
                    number = int(parts[1])
                    if 0 <= number <= len(list_sequences):
                        termcolor.cprint("GET", 'green')
                        seq = list_sequences[number]
                        termcolor.cprint(f"{seq}\n", 'white')
                        cs.send(f"{seq}".encode())
                        cs.close()
                except ValueError:
                    pass

        elif msg.startswith("INFO"):
            parts = msg.split(" ")
            if len(parts) == 2 and parts[0] == "INFO":
                termcolor.cprint("INFO", 'green')
                seq = Seq(parts[1])
                info = seq.info()
                termcolor.cprint(f"{info}", 'white')
                cs.send(f"{info}".encode())
                cs.close()

        elif msg.startswith("COMP"):
            parts = msg.split(" ")
            if len(parts) == 2 and parts[0] == "COMP":
                termcolor.cprint("COMP", 'green')
                seq = Seq(parts[1])
                complem = seq.complement()
                termcolor.cprint(f"{complem}\n", 'white')
                cs.send(f"{complem}\n".encode())
                cs.close()
Exemple #19
0
    def do_GET(self):
        """This method is called whenever the client invokes the GET method
        in the HTTP protocol request"""
        json_response = False
        answer_value = 200
        # Print the request line
        termcolor.cprint(self.requestline, 'green')


        # Message to send back to the client

        #The main programming code appears below, and it starts with the index page (principal page)
        if self.path == '/' or self.path == '/index.html':
            json_response = False
            filename = 'index.html'
            with open(filename, 'r') as f:
                contents = f.read()
        #we program now the code for the path list species
        elif '/listSpecies' in self.path:
            try:
                arguments = self.main(self.path)
                if 'limit' in arguments:
                    try:
                        limit = int(arguments['limit'])
                    except Exception:
                        limit = 0
                else:
                    limit = 0


                print(limit)
                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/info/species?content-type=application/json")
                # -- Wait for the server's response
                r1 = conn.getresponse()
                # -- Print the status
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                # -- Read the response's body and close
                # -- the connection
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                species_l = resp['species']
                if type(limit) != int:
                    answer_value = 400
                    filename = 'error.html'
                    with open(filename, 'r') as f:
                        contents = f.read()
                elif limit == 0:
                    limit = len(species_l)
                conn.close()
                #As this is the advance level of the practice the user can choose to select the json option, so if json is in arguments the program give back the contents in json format
                if 'json' in arguments:
                    json_response = True
                    species = []
                    counter = 0
                    for specie in species_l:
                        specie_f = specie['display_name']
                        species.append(specie_f)
                        counter = counter + 1
                        if counter == limit:
                            break

                    contents = json.dumps(species)
                else:
                    json_response = False
                    contents = """
                            <html>
                            <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>List of the chosen limited species </h3></FONT>
                            <ol>"""
                    counter = 0
                    for specie in species_l:
                        contents = contents + "<li>" + specie['display_name'] + "</li>"
                        counter = counter + 1
                        if counter == limit:
                            break
                    contents = contents + """</ol>
                            </body>
                            </html>
                            """
            except ValueError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

            except KeyError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

            except TypeError:
                answer_value = 404
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()


        elif '/karyotype' in self.path:
            try:
                arguments = self.main(self.path)
                if 'specie' in arguments and arguments['specie'] != "":
                    specie = arguments['specie']
                    conn = http.client.HTTPConnection('rest.ensembl.org')
                    conn.request("GET", "/info/assembly/"+specie+"?content-type=application/json")
                    r1 = conn.getresponse()
                    print()
                    print("Response received: ", end='')
                    print(r1.status, r1.reason)
                    text_json = r1.read().decode("utf-8")
                    resp = json.loads(text_json)
                    karyotype_l = resp['karyotype']
                    print(karyotype_l)
                    if 'json' in arguments:
                        json_response = True
                        contents = json.dumps(karyotype_l)
                    else:
                        json_response = False
                        contents = """
                                                                <html>
                                                                <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>Chromosomes of the chosen specie: </h3></FONT>
                                                                <ul>"""

                        for elem in karyotype_l:
                            contents = contents + "<li>" + elem + "</li>"

                        contents = contents + """</ul>
                                                                </body>
                                                                </html>
                                                                  """
                else:
                    answer_value = 404
                    filename = 'error.html'
                    with open(filename, 'r') as f:
                        contents = f.read()
            except KeyError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()



        elif '/chromosomeLength' in self.path:
            try:
                arguments = self.main(self.path)
                if ('specie') in arguments and ('chromo') in arguments:
                    specie = arguments['specie']
                    chromo = arguments['chromo']
                    print("The chromosome number to study its length is: ", chromo)
                    print("The specie to study is: ", specie)
                    conn = http.client.HTTPConnection('rest.ensembl.org')
                    conn.request("GET", "/info/assembly/" + specie + "?content-type=application/json")
                    r1 = conn.getresponse()
                    print()
                    print("Response received: ", end='')
                    print(r1.status, r1.reason)
                    text_json = r1.read().decode("utf-8")
                    resp = json.loads(text_json)
                    if 'top_level_region' in resp:
                        info = resp['top_level_region']
                        length = 0
                        for elem in info:
                            if elem['name'] == chromo:
                                length = str(elem['length'])
                        print(length)
                        if 'json' in arguments:
                            json_response = True
                            resp_ ={'Length' : length}
                            contents = json.dumps(resp_)
                        else:
                            json_response = False
                            contents = """
                                                                                <html>
                                                                                <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The length of the chromosome of the chosen specie is: </h3></FONT>
                                                                                <ul>"""


                            contents = contents + "<li>" + str(length) + "</li>"

                            """</ul>
                                                                                </body>
                                                                                </html>
                                                                                """
                    else:
                        answer_value = 404
                        filename = 'error.html'
                        with open(filename, 'r') as f:
                            contents = f.read()

                else:
                    answer_value = 404
                    filename = 'error.html'
                    with open(filename, 'r') as f:
                        contents = f.read()

            except KeyError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except TypeError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

        elif '/geneSeq' in self.path:
            try:
                arguments = self.main(self.path)
                if 'gene' in arguments:
                    gene = arguments['gene']
                    conn = http.client.HTTPConnection('rest.ensembl.org')
                    conn.request("GET", "/homology/symbol/human/" + gene + "?content-type=application/json")
                    r1 = conn.getresponse()
                    print()
                    print("Response received: ", end='')
                    print(r1.status, r1.reason)
                    text_json = r1.read().decode("utf-8")
                    resp = json.loads(text_json)
                    id = resp['data'][0]['id']
                    print(id)

                    conn.request("GET", "/sequence/id/" + id + "?content-type=application/json")
                    r1 = conn.getresponse()
                    print()
                    print("Response received: ", end='')
                    print(r1.status, r1.reason)
                    text_json = r1.read().decode("utf-8")
                    resp = json.loads(text_json)
                    sequence = resp['seq']
                    print(sequence)
                    if 'json' in arguments:
                        json_response = True
                        resp_ = {'Sequence': sequence}
                        contents = json.dumps(resp_)
                    else:
                        json_response = False
                        contents = """
                                                                            <html>
                                                                            <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The sequence of the given human gene is: </h3></FONT>
                                                                            <ul>"""


                        contents = contents + "<li>" + sequence + "</li>"

                        """</ul>
                                                                            </body>
                                                                            </html>
                                                                  """
                else:
                    answer_value = 400
                    filename = 'error.html'
                    with open(filename, 'r') as f:
                        contents = f.read()
            except KeyError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

            except TypeError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()





        elif '/geneInfo' in self.path:
            try:
                arguments = self.main(self.path)
                gene = arguments['gene']
                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/homology/symbol/human/" + gene + "?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                id = resp['data'][0]['id']
                print(id)

                conn.request("GET", "/overlap/id/" + id + "?feature=gene;content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)

                id = resp[0]['id']
                start = resp[0]['start']
                end = resp[0]['end']
                length = (end-start)+1
                chromo = resp[0]['seq_region_name']
                if 'json' in arguments:
                    json_response = True
                    resp_ = {'Id': id,'Chromo-name': chromo, 'Start': start, 'End': end, 'Length': length }
                    contents = json.dumps(resp_)
                else:
                    json_response = False
                    contents = """
                                                                    <html>
                                                                    <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The information asked of the given human gene is: </h3></FONT>
                                                                    <ul>"""

                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The id of the sequence is: </h5></FONT>""" + str(id) + "</li>"
                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The start of the sequence is: </h5></FONT>""" + str(start) + "</li>"
                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The end of the sequence is: </h5></FONT>""" + str(end) + "</li>"
                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The length of the sequence is: </h5></FONT>""" + str(length) + "</li>"
                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The name of the gene is: </h5></FONT>""" + str(chromo) + "</li>"

                    """</ul>
                                                                        </body>
                                                                        </html>
                                                                        """

            except KeyError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

            except TypeError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

        elif '/geneCalc' in self.path:
            try:
                arguments = self.main(self.path)
                gene = arguments['gene']
                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/homology/symbol/human/" + gene + "?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                id = resp['data'][0]['id']
                print(id)

                conn.request("GET", "/sequence/id/" + id + "?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                # print(resp)
                sequence = resp['seq']
                print(sequence)

                s1 = Seq(sequence)
                total_length = len(sequence)

                pa = s1.perc('A')
                pt = s1.perc('T')
                pc = s1.perc('C')
                pg = s1.perc('G')

                if 'json' in arguments:
                    json_response = True
                    s1 = Seq(sequence)
                    total_length = len(sequence)


                    resp_ = {'Sequence': sequence, 'Length': total_length, 'PercA': pa, 'PercT': pt, 'PercC': pc, 'PercG': pg}
                    print(type(resp_))
                    contents = json.dumps(resp_)

                else:
                    json_response = False
                    contents = """
                                                                    <html>
                                                                    <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The calculations asked of the given sequence is: </h3></FONT>
                                                                    <ul>"""


                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The total lenght of the sequence is: </h5></FONT>""" + str(total_length) + "</li>"
                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The percentage of A's in the sequence is: </h5></FONT>""" + str(pa) + "</li>"
                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The percentage of T's in the sequence is: </h5></FONT>""" + str(pt) + "</li>"
                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The percentage of C's in the sequence is: </h5></FONT>""" + str(pc) + "</li>"
                    contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The percentage of G's in the sequence is: </h5></FONT>""" + str(pg) + "</li>"
                    """</ul>
                                                                        </body>
                                                                        </html>
                                                                        """
            except KeyError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

            except TypeError:
                answer_value = 400
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

        elif '/geneList' in self.path:
            try:
                arguments = self.main(self.path)
                start = arguments['start']
                chromo = arguments['chromo']
                end = arguments['end']
                print('The number of chromosome is: ', chromo)
                print('The start point is: ', start)
                print('The end point is: ', end)
                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/overlap/region/human/" + str(chromo) + ":" + str(start) + "-" + str(end) + "?content-type=application/json;feature=gene;feature=transcript;feature=cds;feature=exon")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)

                if 'json' in arguments:
                    try:
                        json_response = True
                        id_l = []
                        for elem in resp:
                            position1 = elem['feature_type']
                            if position1 == "gene":
                                position2 = elem['id']
                                id_l.append(str(position2))


                        contents = json.dumps(id_l)
                    except TypeError:
                        resp_ = 'None'
                        contents = json.dumps(resp_)
                else:
                    json_response = False
                    contents = """
                                                                    <html>
                                                                    <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The names of the genes located in the chromosome asked from the start to end positions are: </h3></FONT>
                                                                    <ul>"""



                    for elem in resp:
                        #print(elem)
                        position1 = elem['feature_type']

                        if position1 == "gene":
                            position2 = elem['id']
                            print(position2)
                            contents = contents + "<li>" + 'The name of the chromosome is: ' + str(position2) + "</li>"

                        """</ul>
                                                                                </body>
                                                                                </html>
                                                                                """

            except KeyError:
                answer_value = 404
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except TypeError:
                answer_value = 404
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()



        else:
            answer_value = 404
            filename = 'error.html'
            print('prueba')
            with open(filename, 'r') as f:
                contents = f.read()



        # Generating the response message
        self.send_response(answer_value)  # -- Status line: OK!

        if (json_response == True) :
            self.send_header('Content-Type', 'application/json')
        else:
            self.send_header('Content-Type', 'text/html')

        # Define the content-type header:

        self.send_header('Content-Length', len(str.encode(contents)))

        # The header is finished
        self.end_headers()

        # Send the response message
        self.wfile.write(str.encode(contents))

        return
Exemple #20
0
import socket
import termcolor
from seq import Seq

PORT = 8080
IP = "127.0.0.1"

SEQUENCES_LISTS = [
    Seq("ATTATATTA"),
    Seq("CATCATGAT"),
    Seq("TTTTTTT"),
    Seq("CCC"),
    Seq("TGGGTGGG")
]

ls = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ls.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
ls.bind((IP, PORT))
ls.listen()
termcolor.cprint("The server is configured!", "white")
while True:
    termcolor.cprint("Waiting for Clients to connect", "white")
    try:
        (cs, client_ip_port) = ls.accept()
    except KeyboardInterrupt:
        termcolor.cprint("Server stopped by the user", "white")
        ls.close()
        exit()
    else:
        msg_raw = cs.recv(2048)
        msg = msg_raw.decode()
Exemple #21
0
def showOpCodes():
    print('{:<10}\t{:>10}\t{:>20}'.format('OpCode', 'Hex', 'Bin'))
    for name, member in OpCode.__members__.items():
        print('{:<10}\t{:>10}\t{:>20}'.format(name, hex(member.value), bin(member.value)))


if __name__ == '__main__':
    #showOpCodes()
    #showExampleEncodings()
    #print()
    #asm = Assembler('examples/factorial.asm')
    #asm = Assembler('examples/misc.asm')
    #asm = Assembler('examples/mul.asm')
    #asm = Assembler('examples/int.asm')
    asm = Assembler('examples/mov.asm')
    #asm = Assembler('examples/br.asm')
    #print('generated code:')

    program_memory = asm.parse()
    #for i in program_memory:
    #    print('0x{0:04X}\t0b{0:016b}'.format(i))

    cpu = Cpu(program_memory)
    seq = Seq(MPM, cpu)
#TODO: intreruperi
    dbg = Debugger(seq)
    dbg.attach()

    # print(cpu.__dict__)
    # print(seq.__dict__)
Exemple #22
0
    def do_GET(self):
        """This method is called whenever the client invokes the GET method
        in the HTTP protocol request"""

        # Print the request line
        termcolor.cprint(self.requestline, 'green')



        # Message to send back to the client
        #We start here to program the code of the medium level starting with the code that will give back the index, which is our main page
        if self.path == '/' or self.path == '/index.html':
            filename = 'index.html'
            with open(filename, 'r') as f:
                contents = f.read()
        elif '/listSpecies' in self.path:
            try:
                if 'limit=' in self.path:
                    limit = self.path.split('limit=')[1]
                    print(limit)
                    conn = http.client.HTTPConnection('rest.ensembl.org')
                    conn.request("GET", "/info/species?content-type=application/json")
                    # -- Wait for the server's response
                    r1 = conn.getresponse()
                    # -- Print the status
                    print()
                    print("Response received: ", end='')
                    print(r1.status, r1.reason)
                    # -- Read the response's body and close
                    # -- the connection
                    text_json = r1.read().decode("utf-8")
                    resp = json.loads(text_json)
                    species_l = resp['species']
                    conn.close()
                    contents = """
                            <html>
                            <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>List of the chosen limited species </h3></FONT>
                            <ol>"""
                    limit = int(limit)
                    counter = 0
                    for specie in species_l:
                        contents = contents + "<li>" + specie['display_name'] + "</li>"
                        counter = counter + 1
                        if counter == limit:
                            break
                    contents = contents + """</ol>
                            </body>
                            </html>
                            """
                else:
                    conn = http.client.HTTPConnection('rest.ensembl.org')
                    conn.request("GET", "/info/species?content-type=application/json")
                    # -- Wait for the server's response
                    r1 = conn.getresponse()
                    # -- Print the status
                    print()
                    print("Response received: ", end='')
                    print(r1.status, r1.reason)
                    # -- Read the response's body and close
                    # -- the connection
                    text_json = r1.read().decode("utf-8")
                    resp = json.loads(text_json)
                    species_l = resp['species']
                    contents = """
                                            <html>
                                            <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>List of all the species </h3></FONT>
                                            <ol>"""

                    for specie in species_l:
                        contents = contents + "<li>" + specie['display_name'] + "</li>"

                    contents = contents + """</ol>
                                            </body>
                                            </html>
                                            """
            except IndexError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except ValueError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except KeyError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except TypeError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

        elif '/karyotype' in self.path:
            try:
                specie = self.path.split('=')[1]
                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/info/assembly/"+specie+"?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                karyotype_l = resp['karyotype']
                print(karyotype_l)
                contents = """
                                                        <html>
                                                        <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>Chromosomes of the chosen specie: </h3></FONT>
                                                        <ul>"""

                for elem in karyotype_l:
                    contents = contents + "<li>" + elem + "</li>"

                contents = contents + """</ul>
                                                        </body>
                                                        </html>
                                                        """
            except IndexError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except TypeError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except ValueError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except KeyError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()


        elif '/chromosomeLength' in self.path:
            try:
                slice = self.path.split('&')[1]
                chromo = slice.split('=')[1]
                slice2 = self.path.split('&')[0]
                specie = slice2.split('=')[1]
                print("The chromosome number to study its length is: ", chromo)
                print("The specie to study is: ", specie)
                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/info/assembly/" + specie + "?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                info = resp['top_level_region']
                length = 0
                for elem in info:
                    if elem['name'] == chromo:
                        length = str(elem['length'])
                print(length)
                contents = """
                                                                    <html>
                                                                    <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The length of the chromosome of the chosen specie is: </h3></FONT>
                                                                    <ul>"""


                contents = contents + "<li>" + length + "</li>"

                """</ul>
                                                                    </body>
                                                                    </html>
                                                                    """
            except IndexError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except ValueError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except KeyError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except TypeError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()



        elif '/geneSeq' in self.path:
            try:
                gene = self.path.split('=')[1]

                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/homology/symbol/human/" + gene + "?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                id = resp['data'][0]['id']
                print(id)

                conn.request("GET", "/sequence/id/" + id + "?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                #print(resp)
                sequence = resp['seq']
                print(sequence)

                contents = """
                                                                    <html>
                                                                    <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The sequence of the given human gene is: </h3></FONT>
                                                                    <ul>"""


                contents = contents + "<li>" + sequence + "</li>"

                """</ul>
                                                                    </body>
                                                                    </html>
                                                                    """
            except IndexError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except ValueError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except KeyError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except TypeError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

        elif '/geneInfo' in self.path:
            try:
                gene = self.path.split('=')[1]
                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/homology/symbol/human/" + gene + "?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                id = resp['data'][0]['id']
                print(id)

                conn.request("GET", "/overlap/id/" + id + "?feature=gene;content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)

                start = resp[0]['start']
                end = resp[0]['end']
                length = end-start
                chromo_name = resp[0]['assembly_name']

                contents = """
                                                                    <html>
                                                                    <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The information asked of the given human gene is: </h3></FONT>
                                                                    <ul>"""


                contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The start of the sequence is: </h5></FONT>""" + str(start) + "</li>"
                contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The end of the sequence is: </h5></FONT>""" + str(end) + "</li>"
                contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The length of the sequence is: </h5></FONT>""" + str(length) + "</li>"
                contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The name of the gene is: </h5></FONT>""" + str(chromo_name) + "</li>"

                """</ul>
                                                                    </body>
                                                                    </html>
                                                                    """
            except IndexError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except ValueError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except KeyError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except TypeError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

        elif '/geneCalc' in self.path:
            try:
                gene = self.path.split('=')[1]
                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/homology/symbol/human/" + gene + "?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                id = resp['data'][0]['id']
                print(id)

                conn.request("GET", "/sequence/id/" + id + "?content-type=application/json")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                # print(resp)
                sequence = resp['seq']
                print(sequence)

                s1 = Seq(sequence)
                total_length = len(sequence)

                pa = s1.perc('A')
                pt = s1.perc('T')
                pc = s1.perc('C')
                pg = s1.perc('G')

                contents = """
                                                                    <html>
                                                                    <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The calculations asked of the given sequence is: </h3></FONT>
                                                                    <ul>"""


                contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The total lenght of the sequence is: </h5></FONT>""" + str(total_length) + "</li>"
                contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The percentage of A's in the sequence is: </h5></FONT>""" + str(pa) + "</li>"
                contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The percentage of T's in the sequence is: </h5></FONT>""" + str(pt) + "</li>"
                contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The percentage of C's in the sequence is: </h5></FONT>""" + str(pc) + "</li>"
                contents = contents + "<li>" + """<FONT FACE="monospace" SIZE = 5 COLOR = 'darkslategray'><h5>The percentage of G's in the sequence is: </h5></FONT>""" + str(pg) + "</li>"
                """</ul>
                                                                    </body>
                                                                    </html>
                                                                    """
            except IndexError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except ValueError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except KeyError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except TypeError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()

        elif '/geneList' in self.path:
            try:
                slice = self.path.split('&')[1]
                start = slice.split('=')[1]
                slice2 = self.path.split('&')[0]
                chromo = slice2.split('=')[1]
                slice3 = self.path.split('&')[2]
                end = slice3.split('=')[1]
                print('The number of chromosome is: ', chromo)
                print('The start point is: ', start)
                print('The end point is: ', end)
                conn = http.client.HTTPConnection('rest.ensembl.org')
                conn.request("GET", "/overlap/region/human/" + str(chromo) + ":" + str(start) + "-" + str(end) + "?content-type=application/json;feature=gene;feature=transcript;feature=cds;feature=exon")
                r1 = conn.getresponse()
                print()
                print("Response received: ", end='')
                print(r1.status, r1.reason)
                text_json = r1.read().decode("utf-8")
                resp = json.loads(text_json)
                contents = """
                                                                    <html>
                                                                    <body style="background-color: D7B7BC;"><FONT FACE="monospace" SIZE = 5 COLOR = 'white'><h3>The names of the genes located in the chromosome asked from the start to end positions are: </h3></FONT>
                                                                    <ul>"""
                for elem in resp:
                    position1 = elem['feature_type']

                    if position1 == "gene":
                        position2 = elem['id']
                        print(position2)
                        contents = contents + "<li>" + 'The name of the chromosome is: ' + str(position2) + "</li>"

                    """</ul>
                                                                            </body>
                                                                            </html>
                                                                            """
            except IndexError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except ValueError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except KeyError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()
            except TypeError:
                filename = 'error.html'
                with open(filename, 'r') as f:
                    contents = f.read()



        else:
            filename = 'error.html'
            with open(filename, 'r') as f:
                contents = f.read()



        # Generating the response message
        self.send_response(200)  # -- Status line: OK!

        # Define the content-type header:
        self.send_header('Content-Type', 'text/html')
        self.send_header('Content-Length', len(str.encode(contents)))

        # The header is finished
        self.end_headers()

        # Send the response message
        self.wfile.write(str.encode(contents))

        return
Exemple #23
0
from seq import Seq
import socket

try:
    while True:
        s1 = Seq(input("Please introduce a sequence: "))
        s2 = Seq(s1.reverse())
        s3 = Seq(s2.complement())

        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        PORT = 8080
        IP = "212.128.253.68"

        # Connect to the server
        s.connect((IP, PORT))

        # Send a message
        s.send(str.encode("Reverse/complement:{}".format(s3.strbases)))


        msg = s.recv(2048).decode("utf-8")
        print("Mesaage from server: ")
        print(msg)

        s.close()
except KeyboardInterrupt:
    print("Execution interrupted by user")

Exemple #24
0
            if abs(five - three) < MIN_INTRON_SIZE: continue

            key = (chrom, strand, five)
            out[key] = compare(out[key], three) if key in out else three
    return out


###############################################################

MIN_RECURSIVE_INTRON_SIZE = 35
MIN_INTRON_SIZE = 1000

samfile = pysam.AlignmentFile(sys.argv[1], 'rb')
ss = get_jxns(sys.argv[2])
seq = Seq(load_genome(open(sys.argv[3], 'r')))

for read in samfile.fetch():
    blocks = merge_blocks(read.get_blocks())
    strand = (read.is_read1 == read.is_reverse)
    if len(blocks) > 1:
        for i in xrange(len(blocks) - 1):
            if strand:
                five, three = blocks[i][1], blocks[i + 1][0]
            else:
                three, five = blocks[i][1], blocks[i + 1][0]

            # Some insertion events align to 5'ss and cause false positives
            # ... easily fixed by asserting a minimum recursive intron length.
            if abs(five - three) < MIN_RECURSIVE_INTRON_SIZE: continue
Exemple #25
0
def rev(cs, argument):
    print_colored("REV", "green")
    seq = Seq(argument)
    reverse = seq.reverse()
    print(reverse)
    cs.send(reverse.encode())
Exemple #26
0
import http.server
import socketserver
from urllib.parse import parse_qs, urlparse
import server_utils as su
from seq import Seq

IP = "127.0.0.1"
PORT = 8080
SEQUENCES_LISTS = [
    Seq("ATTATATTA"),
    Seq("CATCATGAT"),
    Seq("TTTTTTT"),
    Seq("CCC"),
    Seq("TGGGTGGG")
]
LIST_GENES = ["ADA.txt", "FRAT1.txt", "FNX.txt", "RNU6_269P.txt"]


class MyWebServerRequestHandler(http.server.BaseHTTPRequestHandler):
    def do_GET(self):
        print(self.requestline, "green")
        print((self.path, "blue"))

        o = urlparse(self.path)
        path_name = o.path
        arguments = parse_qs(o.query)
        print("Resource requested:", path_name)
        print("Parameters:", arguments)

        context = {}
        if path_name == "/":
Exemple #27
0
from seq import Seq

print("-------Exercise 3-------")
s1 = Seq()
s3 = Seq("Invalid sequence DETECTED")
s2 = Seq("ACTGA")
print(f"Sequence 1: {s1}")
print(f"Sequence 2: {s2}")
print(f"Sequence 3: {s3}")
Exemple #28
0
    def _linear_search(self, chrom, strand, pos, start=0):
        for i in xrange(start, len(self.ss[strand][chrom])):
            if self.ss[strand][chrom][i][0] > pos:
                return i
        return len(self.ss[strand][chrom])


MAX_ALLOWED_INSERT = 1000
MAX_FIVE_INSERT = 400
OVERHANG = 10  # Don't extract reads short of an annotated splice site by less than this.
ALLOW_ANNO_AGGT = True  # Allow alignment to anno splice sites with seq AGGT and inside bigger intron.

samfile = pysam.AlignmentFile(sys.argv[1])
jxns = Junctions(sys.argv[2])
seq = Seq(load_genome(open(sys.argv[3], 'r')))
sample = sys.argv[4]

for read in samfile.fetch():
    if not read.is_read2: continue
    if read.reference_id != read.next_reference_id: continue

    strand = (read.is_read1 == read.is_reverse)
    strand_str = '+' if strand else '-'
    chrom = samfile.getrname(read.reference_id)
    if chrom[:3] == 'chr': chrom = chrom[3:]

    # The following two blocks are identical and handle + and - strands.
    if strand and read.pnext - read.pos > MAX_ALLOWED_INSERT:
        inner_left = read.get_blocks()[-1][1]  # End   of mate #1
        inner_right = read.pnext  # Start of mate #2
Exemple #29
0
from seq import Seq

print("-------Exercise 7-------")
s1 = Seq()
s2 = Seq("ACTGA")
s3 = Seq("Invalid sequence")
sequences = [s1, s2, s3]
for i, sequence in enumerate(sequences):
    print(f"Sequence {i}: (Length: {sequence.len()}) {sequence}")
    print(f"Bases:{sequence.count()}")
    print(f"Rev:{sequence.reverse_mode()}")
Exemple #30
0
from seq import Seq

print("-------Exercise 2-------")
s1 = Seq()
s2 = Seq("ACTGA")
print(f"Sequence 1: {s1}")
print(f"Sequence 2: {s2}")
				three, five, compare = int(start), int(end), min

			if abs(five-three) < MIN_INTRON_SIZE: continue

			key = (chrom, strand, five)
			out[key] = compare(out[key], three) if key in out else three
	return out

###############################################################

MIN_RECURSIVE_INTRON_SIZE = 35
MIN_INTRON_SIZE = 1000

samfile = pysam.AlignmentFile(sys.argv[1], 'rb')
ss = get_jxns(sys.argv[2])
seq = Seq(load_genome(open(sys.argv[3], 'r')))

for read in samfile.fetch():
	blocks = merge_blocks(read.get_blocks())
	strand = (read.is_read1 == read.is_reverse)
	if len(blocks) > 1:
		for i in xrange(len(blocks) - 1):
			if strand:
				five, three = blocks[i][1], blocks[i+1][0]
			else:
				three, five = blocks[i][1], blocks[i+1][0]

			# Some insertion events align to 5'ss and cause false positives
			# ... easily fixed by asserting a minimum recursive intron length.
			if abs(five - three) < MIN_RECURSIVE_INTRON_SIZE: continue
Exemple #32
0
def rev(argument):
    seq = Seq(argument)
    reverse = seq.reverse()
    return reverse