Beispiel #1
0
def info(cs, list_sequences, argument):
    print_colored("INFO", "green")
    seq = Seq(list_sequences[int(argument)])
    print(seq)
    number_dict = seq.count()
    len1 = len(str(seq))
    percentage_dict = seq.percentage(seq.count_bases(), len1)
    response = "Sequence: " + list_sequences[int(
        argument)] + "\nTotal length: " + str(len1) + "\n"
    for key in number_dict:
        response += (str(key) + ": " + str(number_dict[key]) + " (" +
                     str(percentage_dict[key], ) + "%)\n")
    print(response)
    cs.send(response.encode())
Beispiel #2
0
    "FGFR3": "ENSG00000068078",
    "KDR": "ENSG00000128052",
    "ANK2": "ENSG00000145362"
}

SERVER = "rest.ensembl.org"
ENDPOINT = "/sequence/id/"
PARAMETERS = "?content-type=application/json"

connection = http.client.HTTPConnection(SERVER)
try:
    for key, ID in genes_dict.items():
        connection.request("GET", ENDPOINT + ID + PARAMETERS)
        response = connection.getresponse()
        if response.status == 200:
            response_dict = json.loads(response.read().decode())
            #response = json.dumps(response_dict, indent=4, sort_keys=True
            sequence = Seq(response_dict["seq"])
            s_length = sequence.len()
            percentages = sequence.percentage()
            most_frequent_base = sequence.frequent_base(sequence.count())
            print_colored("Gene: ", key, "yellow")
            print_colored("Description: ", response_dict['desc'], "yellow")
            print_colored("Total length: ", s_length, "yellow")
            for key, value in percentages.items():
                print_colored(key, value, "blue")
            print_colored("Most frequent base: ", most_frequent_base, "yellow")
except KeyError:
    print(
        "The gene is not inside our dictionary. Choose one of the following: ",
        list(genes_dict.keys()))
Beispiel #3
0
from Seq02 import Seq
print('-----| Practice 1, Exercise 10 |------')
bases = ["A", "C", "T", "G"]
list_of_genes = ["U5", "ADA", "FRAT1", "FXN", "RNU6_269P" ]
txt = ".txt"
FOLDER = "../SEQUENCES/"


for e in list_of_genes:
    s0 = Seq('')
    val = 0
    base = ''
    s0 = s0.read_fasta(FOLDER+e+txt)
    dict1 = s0.count()
    for i, t in dict1.items():
        while t > val:
            val = t
            base = i
    print("Gene ", e, " : Most frequent base: ", base)
Beispiel #4
0
from Seq02 import Seq

print("-----| Practice 1, Exercise 6 |------")

s1 = Seq()
s2 = Seq("ACTGA")
s3 = Seq("Invalid sequence")

print("Sequence 1: (Length : ", s1.len(), ")", s1)
print("Bases:", s1.count())

print("Sequence 2: (Length : ", s2.len(), ")", s2)
print("Bases:", s2.count())

print("Sequence 3: (Length : ", s3.len(), ")", s3)
print("Bases:", s3.count())