[BioPython] question regarding writing SeqRecord objects in Fasta format

Iddo Friedberg idoerg at burnham.org
Fri Jul 15 13:30:18 EDT 2005


Hi Ann,

How did you create the SeqRecord instances in the first place? Did you 
read in using SeqIO.Fasta.FastaReader, or something else?

Your SeqRecord instance lacks an id attribute, which should have been 
read in, or inserted some other way.

Let me know.

Cheers,

Iddo





Ann Loraine wrote:

> Hi,
>
> I'm trying to create a new fasta file from a larger one by selecting 
> out records that contain specific ids.
>
> Reading the records worked fine - I just followed the directions in 
> the tutorial.
>
> But now I want to write them out in fasta format to a file handle.
>
> I tried using the SeqIO.FASTA.FastaWriter class to do this, but got 
> this error:
>
> >>> writer = Bio.SeqIO.FASTA.FastaWriter('test.fa')
> >>> writer.write(cur_record)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/local/lib/python2.4/site-packages/Bio/SeqIO/FASTA.py", 
> line 67, in write
>     id = record.id
> AttributeError: Record instance has no attribute 'id'
>
> Looks like FastaWriter expects a different type of object.
>
> Printing the record works fine, however:
>
> >>> print cur_record
> >consensus:Rat230_2:1367552_at; gb|M25590; gb:M25590.1 
> /DB_XREF=gi:202756 /FEA=FLmRNA /CNT=455 /TID=Rn.9942.1 /TIER=FL+Stack 
> /STK=452 /UG=Rn.9942 /LL=24802 /UG_GENE=Svp4 /UG_TITLE=Seminal vesicle 
> protein 4 /DEF=Rat androgen-dependent protein mRNA, complete cds. 
> /FL=gb:NM_012662.1 gb:M25590.1
> atataaactaagaactcagctcagccttcagtcaagagcttttctggcaagatgaagtct
> accagcttgttcctctgttctctgctcctccttctagtgacaggagccattgggagaaaa
> acnaaggaaaaatactcacagtcggaagaagttgtcagtgagagctttgcctcgggccct
> tcctcgggttcttctgatgatgaattagtgagagacaagccatatggccccaaagtctcg
> ggcggctcctttggtgaggaagcttctgaggagataagtagcagaaggagcaagcacatc
> tctaggagttccggtggctccaacatggaaggtgagagctcgtatgccaagaaaaagagg
> agccggtttgcccaagacgtactcaactgatagtgcatcgggcagctgaacatcttggac
> caatatgccggagccacattgcctggatgaagcctgtgatgtcttcagcatgcagctccc
> natgtggtctcagaggcagtccctggatggcatttccttctcatgcttgtttgtcttgag
> gttcttaaacctaacattcaggaactttctgtccaataaagagataacaatctgcatcnt
> taaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnn
>
>
> But I don't want to print the record to stdout -- I want to write it 
> to a filehandle.  I'd like the record to be formatted nicely -  same 
> number of characters per line in the sequence part - but I can't 
> figure out how to do it.
>
> Is there another 'writer' type object I could use that would accept a 
> SeqRecord?
>
> -Ann
>
>
> _______________________________________________
> BioPython mailing list  -  BioPython at biopython.org
> http://biopython.org/mailman/listinfo/biopython
>
>


-- 
Iddo Friedberg, Ph.D.
The Burnham Institute
10901 N. Torrey Pines Rd.
La Jolla, CA 92037 USA
Tel: +1 (858) 646 3100 x3516
Fax: +1 (858) 713 9949
http://ffas.ljcrf.edu/~iddo



More information about the BioPython mailing list