Last change
on this file since 47 was 41, checked in by Rick van der Zwet, 15 years ago |
Some futging around with FASTA files
|
-
Property svn:executable
set to
*
|
File size:
787 bytes
|
Rev | Line | |
---|
[41] | 1 | #!/usr/bin/env python
|
---|
| 2 | from Bio import SeqIO,Seq
|
---|
| 3 | from Bio import Alphabet
|
---|
| 4 | from Bio.Alphabet.IUPAC import ambiguous_dna,unambiguous_dna
|
---|
| 5 | import Bio.Data.CodonTable
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | handle = open("data/AE005174v2-1.fas", "rU")
|
---|
| 9 | for seq_record in SeqIO.parse(handle, "fasta",ambiguous_dna):
|
---|
| 10 | print seq_record.id
|
---|
| 11 | print repr(seq_record.seq)
|
---|
| 12 | print seq_record.seq.alphabet
|
---|
| 13 | print seq_record.letter_annotations
|
---|
| 14 |
|
---|
| 15 | # How to translate damm thing into plain nucleic acid codes
|
---|
| 16 | # http://en.wikipedia.org/wiki/FASTA_format
|
---|
| 17 | stupid = seq_record.seq.to_str().translate({'W' : 'G'})
|
---|
| 18 |
|
---|
| 19 | pdict = {}
|
---|
| 20 | for n in range(1, len(stupid)):
|
---|
| 21 | protein = stupid[n]
|
---|
| 22 | if not pdict.has_key(protein):
|
---|
| 23 | pdict[protein] = 1
|
---|
| 24 | else:
|
---|
| 25 | pdict[protein] += 1
|
---|
| 26 |
|
---|
| 27 | print pdict
|
---|
| 28 |
|
---|
| 29 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.