Python Help!!!
kyosohma at gmail.com
kyosohma at gmail.com
Mon Jun 11 10:04:27 EDT 2007
On Jun 11, 3:39 am, Elfine Peterson Tjio <elf... at gwu.edu> wrote:
> I'm trying to make a program that reads Fasta file and print it out. I used the SeqIO module and the results is:
>
> 'ATGGTCAT....SingleAlphabet()'
>
> For this purpose, should I use SeqIO or Fasta?
>
> for example:
>
> from Bio import SeqIO
>
> or
>
> from Bio import Fasta
>
> I want it to print every letter. Can anyone point me to the right direction. The newest biopython tutorial or book recommendation will be appreciated, too.
As I understand it, a "Fasta" file is a text file, correct? If so,
this should be trivial with Python.
I created a file with the following data from http://en.wikipedia.org/wiki/Fasta_format:
>gi|5524211|gb|AAD44166.1| cytochrome b [Elephas maximus maximus]
LCLYTHIGRNIYYGSYLYSETWNTGIMLLLITMATAFMGYVLPWGQMSFWGATVITNLFSAIPYIGTNLV
EWIWGGFSVDKATLNRFFAFHFILPFTMVALAGVHLTFLHETGSNNPLGLTSDSDKIPFHPYYTIKDFLG
LLILILLLLLLALLSPDMLGDPDNHMPADPLNTPLHIKPEWYFLFAYAILRSVPNKLGGVLALFLSIVIL
GLMPFLHTSKHRSMMLRPLSQALFWTLTMDLLTLTWIGSQPVEYPYTIIGQMASILYFSIILAFLPIAGX
IENY
Then I did the following to read it:
>>> fil = open(r'c:\test\fasta.txt')
>>> for f in fil.readlines():
if '>' in f:
print f
else:
for letter in f:
print letter
That seemed to work for me. You probably don't want to print the first
line, but that's easily fixed.
Hope that helps.
Mike
More information about the Python-list
mailing list