Exemplo n.º 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())
Exemplo n.º 2
0
def percentageSeq(gene, genes_dict):
    SERVER = "rest.ensembl.org"
    ENDPOINT = "/sequence/id/"
    PARAMS = "?content-type=application/json"

    ID = genes_dict[gene]
    connection = http.client.HTTPConnection(SERVER)
    connection.request("GET", ENDPOINT + ID + PARAMS)

    response = connection.getresponse()
    print(response.status, response.reason)

    answer_decoded = response.read().decode()
    dict_response = json.loads(answer_decoded)
    sequence = Seq(dict_response["seq"])
    lenght = sequence.len()
    a, c, g, t = sequence.percentage(sequence.count_bases(), lenght)

    context = {"A": a, "C": c, "G": g, "T": t, "gene": gene}
    content = su.read_template_html_file("HTML/percentageCalc.html").render(
        context=context)
    return content
Exemplo n.º 3
0
}

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

connection = http.client.HTTPConnection(SERVER)
try:
    user_gene = input("Enter the gene you want to analise: ")
    ID = genes_dict[user_gene]
    connection.request("GET", ENDPOINT + ID + PARAMETERS)
    response = connection.getresponse()
    if response.status == 200:
        response_dict = json.loads(response.read().decode())
        #print(json.dumps(response_dict, indent=4, sort_keys=True))
        sequence = Seq(response_dict["seq"])
        s_length = sequence.len()
        a, c, g, t = sequence.percentage(sequence.count_bases(), s_length)
        most_frequent_base = sequence.frequent_base(sequence.count())
        print_colored("Gene: ", user_gene, "yellow")
        print_colored("Total length: ", s_length, "yellow")
        print(a)
        print(c)
        print(t)
        print(g)
        print(most_frequent_base)
except KeyError:
    print("The gene is not inside our dictionary. Choose one of the following: ", list(genes_dict.keys()))