geored's picture
Upload folder using huggingface_hub
fe41391 verified
raw
history blame
1.91 kB
"""
This module contains methods for the RUST tool
These are general purpose functions that are used in the RUST tool
"""
import sys
def stop_err(msg):
sys.stderr.write("%s\n" % msg)
sys.exit()
def mean_value(input_list):
if len(input_list) == 0:
return 0
else:
return sum(map(float, input_list)) / len(input_list)
def translate_dna(sequence):
codontable = {
"ATA": "I",
"ATC": "I",
"ATT": "I",
"ATG": "M",
"ACA": "T",
"ACC": "T",
"ACG": "T",
"ACT": "T",
"AAC": "N",
"AAT": "N",
"AAA": "K",
"AAG": "K",
"AGC": "S",
"AGT": "S",
"AGA": "R",
"AGG": "R",
"CTA": "L",
"CTC": "L",
"CTG": "L",
"CTT": "L",
"CCA": "P",
"CCC": "P",
"CCG": "P",
"CCT": "P",
"CAC": "H",
"CAT": "H",
"CAA": "Q",
"CAG": "Q",
"CGA": "R",
"CGC": "R",
"CGG": "R",
"CGT": "R",
"GTA": "V",
"GTC": "V",
"GTG": "V",
"GTT": "V",
"GCA": "A",
"GCC": "A",
"GCG": "A",
"GCT": "A",
"GAC": "D",
"GAT": "D",
"GAA": "E",
"GAG": "E",
"GGA": "G",
"GGC": "G",
"GGG": "G",
"GGT": "G",
"TCA": "S",
"TCC": "S",
"TCG": "S",
"TCT": "S",
"TTC": "F",
"TTT": "F",
"TTA": "L",
"TTG": "L",
"TAC": "Y",
"TAT": "Y",
"TAA": "*",
"TAG": "*",
"TGC": "C",
"TGT": "C",
"TGA": "*",
"TGG": "W",
}
proteinsequence = ""
for n in range(0, len(sequence), 3):
try:
proteinsequence += codontable[sequence[n : n + 3]]
except:
proteinsequence += "X"
return proteinsequence