-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.py
26 lines (22 loc) · 2.38 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from fna2faa_gmsc import translate
from flask import jsonify
sequences = [
("GMSC10.100AA.000_000_000", "GTGGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCAGCGGCAGGTGGGGCAAGAGGAGAGAATTTTGACGAGAATAAAATAGACGCAGAAAGAGAAGCAGGAGTAGACGTACAAGTCGATCGCGGGGTGCTGCTGCTGTTGCTGTTGATCCTACTGCTGCTATTGCTGCTGCTGCTGCTGCTGTTGGTGCTGGTGACGCTGGCCGCCGTGCTCCCTTGTCGGGATAAGGGCGGGGATTGA", "water associated", ""),
("GMSC10.100AA.000_000_001", "ATGGCTGCTGCAGCAGCAGCTGCTGCTGCTGCTGCCGCCGCCTTTGTAGTTTTCGTAGGTTTTCCATCGTCATCTTTCTTGTCTGATGATTTTCTAACATTCTTGTCAGAATCCGGAAAGGATGGCAGGGCGGGTTTCCGGCTCCGAGGAAATCGAGGTGGCGGAGCTCTAGTTTCTTGGTATCCTGCCAATATCTGTTGGGCATCAATAGCAGCATCTACTAGATTGGAAATGTACCGGGCTGTCAATTCTGAGAGGAGTTGA", "marine", ""),
("GMSC10.100AA.000_000_002", "GTGGCTGCTGCTGCTGCTGCTGCTGCTGCTGCTGCTGCCAAAGGGAGTGCTGTGCGCAATATATTTTCGACGGGCATGCTTGAGACACTGCGAGCACTGGCTGACGGTGTTGCAGCATCTGATATACTTCCAAGAGTACTGGCAGTACGTCATCGTTCAATACTGCCCATACCGCGAGTGAGTATACTCGCAGTATTTCGGATTATGTATGTCTGTACTGCCTGA", "marine", ""),
("GMSC10.100AA.000_000_003", "ATGGCCGCCGCCGCAGCCGCCGCCGCCGCCGCCGCCGCCGTCGGAACCTCCTTGGACACCGGGCCGGACCCGCTGATGGCGATGCTCGCCGGCGATTTCCAGCCCGCGGCGGGGTTCAAGTCGAGCGACTCGGCGCCGGAGCTCGTCGAGGTTGTCAAGATTCACTCTCCGGTTGTCGCGACGGGGGAGAACGGCGCCGCGAGCGCGATGGATGTCCTGACGGAGCCGGCTTGA", "marine", ""),
("GMSC10.100AA.000_000_004", "ATGGCCGCCGCCGCCGCCGCCGCCGCCGCAGCCGCCGCCGTCGGAACCTCCGTGGACACCGGGCCGGACCCGCTGATGGCGATGCTCGCCGGCGATTTCCAGCCCGCTGCGGGGTTCAAGTCGAGCGACTCGGCGCCGGAGCTCGTCGAGGTTGTCAAGATTCACTCGCCGGTTGTCGCGACGGGGGAGAACGGCGCCGCGAGCGCGATGGATGTCCTGACGGAGCCGGCTTGA", "soil", "d__Bacteria;p__Actinobacteriota;c__Actinomycetia;o__Streptosporangiales;f__Streptosporangiaceae"),
("GMSC10.100AA.000_000_005", "GTGGCGGCTGCGGCCGCAGCTGCCGCAGCGGCGGCCTGGACCTGGGCTTTTTCCTTCAGGTCGGCCATCTTGTTGTTCATGTCCTGCAGTTTTTCATCGGCGGCCTGGCGAATGCTGTCCAGATCGACCTTTTCAGAAAACTCGCACCAGGTGAGCACACCCACCATCAGCGGCAGCAAGAAGACGAAAGCCGAGGCCAGCGCAAACACCAGGCTGAAGCCCACGCCTGCCCCCATCATGTGGCCCGAGGCGCCGCCCATCATGATGGCCATGGGGTTAAAGCCACCCATTCCATAA", "soil", "d__Bacteria;p__Actinobacteriota;c__Actinomycetia"),
]
def get_demo_seqinfo(seq_ix):
if seq_ix >= len(sequences):
return {"error": "Invalid sequence ID (too large)"}, 400
(seq_id, nuc, habitat, taxonomy) = sequences[seq_ix]
aa = translate(nuc)
return jsonify({
"seq_id": seq_id,
"nucleotide": nuc,
"aminoacid": aa,
"habitat": habitat,
"taxonomy": taxonomy,
})