Ich bin ein Python Neuling und versuche mir den Großteil mit Tutorials etc.beizubringen momentan sitze ich an diesem Task und komme irgendwie nicht weiter. Habe das Forum durchsucht aber nichts gefunden also hoffe ich das mir hier jemand helfen kann. ich poste euch einmal den task und was ich bisher so habe.
Write a python script that
– Reads a DNA sequence from a file. The name of the input file should be passed as a command-line parameter
– Translates the sequence to the corresponding amino acid sequence. Look up the “genetic code” in the Internet!
– Writes the resulting AA sequence to a new file (whose name should also be read from a command-line parameter)
Extend your flowchart and script so that one can pass a file (as 3rd parameter) with mutations to your script
– This mutationfile contains simply a position information and the new base character, e.g., the file :
1 A
5 C
means that the first character of the DNA sequence should be replaced by an A, the 5th should be replaced by a C.
– Position and base character should be separated by a TAB character (“\t”) in this file
– Make sure that yours olution is case-insensitive(so,uppercaseand lowercase base characters should have the same effect)
Your script should now create an output file that looks like this:
“> original AAs”
<ORIGINAL AA SEQUENCE>
“> mutated AAs”
<MUTATED AA SEQUENCE>
Ich weiß nicht genau wie ich das mit der Bibliothek so mache dass jemand das Programm generell verwenden kann. Bisher hatte ich eine Library gencode die eben am PC gespeichert ist und die ich aufgemacht hab. Auch ist mir nicht ganz klar wie ich das Programm so schreibe dass es generell für jede beliebige DNA sequenz funktioniert und egal wer es wo verwendet!???
Das habe ich bisher:
python myscript.py dna.fa aa.txt mut.txt
Code: Alles auswählen
import.sys
dna.fa=sys.argv[1]
aa.txt=sys.argv[2]
mut.txt=sys.argv[3]
gencode={""} #do i need to upload a library so the user can get the seq.translated??
f=open(“dna.fa”)
l=f.readlines()[:-1]
“”.join(l)
for base in range(len((l)-2):
codon=seq[base:base+3]
as=gencode.get(a)
print as > aa.txt
g=open(“mut.txt”, “w”)
print >> g, “1”,(“t”), “A”, #now i'm stuck!