public
Description: repository for the code featured in the blog
Homepage: http://python.genedrift.org
Clone URL: git://github.com/nuin/beginning-python-for-bioinformatics.git
100755 18 lines (14 sloc) 0.451 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/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)