Hi everybody :)
i opened a freshly new blog about python and simulation in bioinformatics and i started by programming a DNA Replication,Transcription andTranslation simulator with very simple python commands so is there any improvement to the code source?
the Vpython is needed for graphs

the blog:http://bioticcomputer.blogspot.com/
the code source:http://www.slingfile.com/file/ENAI9lK4FM


Thanks

Recommended Answers

All 2 Replies

Nice blog, its worth a glance. I have never been into Bioinformatics though I may give it a look now because your code struck some interest with me.

I suggest the following replacement for Starter_AA:

from pprint import pprint

mapping  = """
Phe: UUU, UUC;
Leu: UUA, UUG, CUU, CUC, CUA, CUG;
Iso: AUU, AUC, AUA;
Met: AUG;
Val: GUU, GUC, GUA, GUG;
Ser: UCU, UCC, UCA, UCG, AGU, AGC;
Pro: CCU, CCC, CCA, CCG;
Thr: ACU, ACC, ACA, ACG;
Ala: GCU, GCC, GCA, GCG;
Tyr: UAU, UAC;
His: CAU, CAC;
Gln: CAA, CAG;
Asn: AAU, AAC;
Lys: AAA, AAG;
Asp: GAU, GAC;
Glu: GAA, GAG;
Sys: UGU, UGC;
Trp: UGG;
Arg: CGU, CGC, CGA, CGG, AGA, AGG;
Gly: GGU, GGC, GGA, GGG;
STOP: UGA, UAG, UAA;
"""

def parse(mapping):
    """Create a dictionary UUU -> Phe, etc"""
    checklist = []
    L = mapping.strip().split(";")[:-1]
    D = dict()
    for i, line in enumerate(L):
        key, value = line.split(":")
        key = key.strip()
        value = [x.strip() for x in value.split(",")]
        checklist.extend(value)
        for v in value:
            D[v] = key
    assert len(checklist) == len(set(checklist))
    return D

mapping = parse(mapping)
# pprint(mapping)

def Starter_AA():    
    for i in range(len(Codons)):
        if Codons[i]=="AUG":
            for j in range(i,len(Codons)): # don't use the same variable i for the inner loop
                display (Codons[j])
                pro = mapping[Codons[j]]
                display("----------->%s" % pro if pro != "STOP" else "Traduction Stopped")
                Protide.append(pro)
            return

The idea is to avoid repetitions in the code (a winning rule).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.