#!/usr/bin/env python

'''
translating DNA into proteins
'''

#import our homemade module that has the DNA
#translating function
import dnatranslate

#OK, we are using the same DNA file
dnafile = open("AY162388.seq", 'r').readlines()

#opening the file and stripping and joining the lines
sequence = ''
for line in dnafile:
    sequence += line.strip()

#call the function in our module and translating the sequence
protein = dnatranslate.translate_dna(sequence)

#output, simple, we could make it better
print sequence, len(sequence)
print
print protein, len(protein)

#!/usr/bin/env python

#import two modules
import dnatranslate
import fasta
import sys


#read the fasta file in one line: open the file, read the contents
#and send it to the fasta reading function
dna = fasta.read_fasta(open(sys.argv[1], 'r').readlines())

for item in dna:
    #translate the DNA
    protein = dnatranslate.translate_dna(item.sequence)
    print item.name
    #format and print the protein
    print fasta.format_output(protein, 60)
示例#3
0
#!/usr/bin/env python
'''
simple to translate dna into proteins
'''

#importing the dnatranslate module
import dnatranslate
import sys
import fasta

#opening and reading the file in one take
dna = fasta.read_fasta(open(sys.argv[1], 'r').readlines())

#iterate over the sequences and translate them
for item in dna:
    protein = dnatranslate.translate_dna(item.sequence)
    print item.name
    print protein
示例#4
0
#!/usr/bin/env python
'''
translating DNA into proteins
'''

#import our homemade module that has the DNA
#translating function
import dnatranslate

#OK, we are using the same DNA file
dnafile = open("AY162388.seq", 'r').readlines()

#opening the file and stripping and joining the lines
sequence = ''
for line in dnafile:
    sequence += line.strip()

#call the function in our module and translating the sequence
protein = dnatranslate.translate_dna(sequence)

#output, simple, we could make it better
print sequence, len(sequence)
print
print protein, len(protein)