This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Read Dna Sequences From More Than One Fasta File From A Directory?
import os
from Bio import SeqIO
import glob
list_of_files = glob.glob( "directory path/./*.fasta")
for file_name in list_of_files:
       R = SeqIO.parse(file_name)
       for records in R:
                     print records

from this i can parse over all the files in directory but i am not able to print Sequence records in it .

biopython python

What i've written above gives me DNA/protein sequence from more than one fasta file which are read from a directory. .

Please don't edit your code to include the solution, it renders this whole post very confusing as the question itself becomes the answer... I've edited back to your original code and deleted your comment so that this post can help future users having the same problem :-)

Is that pseudo code? The SeqIO parse function requires a format argument as well, e.g. "fasta" or "gb".

1 answer

SeqIO.parse() returns a SeqRecord object, and the __str__() method for this object (method implicitely called whenever you run a 'print x') will return a bunch of information and not just the sequence:

ID: Z78439.1
Name: Z78439
Description: P.barbatum 5.8S rRNA gene and ITS1 and ITS2 DNA.
Number of features: 5
/source=Paphiopedilum barbatum
/taxonomy=['Eukaryota', 'Viridiplantae', 'Streptophyta', 'Embryophyta', ..., 'Paphiopedilum']
/keywords=['5.8S ribosomal RNA', '5.8S rRNA gene', 'internal transcribed spacer', 'ITS1', 'ITS2']
/references=[<Bio.SeqFeature.Reference ...>, <Bio.SeqFeature.Reference ...>]
/data_file_division=PLN
/date=30-NOV-2006
/organism=Paphiopedilum barbatum
/gi=2765564
Seq('CATTGTTGAGATCACATAATAATTGATCGAGTTAATCTGGAGGATCTGTTTACTTTGGTC ...', IUPACAmbiguousDNA())

Have you tried rather a

print records.seq

or a

print records.format("fasta")

This is possibly what you are looking for.

Log in to answer this question.