[Biopython] SeqIO.dict
Peter
biopython at maubp.freeserve.co.uk
Thu Jun 10 19:33:32 EDT 2010
On Thu, Jun 10, 2010 at 11:47 PM, Willis, Jordan R wrote:
> Hello Community.
>
> I was wonderig if you could convert a dictionary object back into a fasta file.
>
>
> Dictionary = SeqIO.to_dict(SeqIO.parse('my.file', "fasta")
>
> Removed some objects from dictionary....
>
> SeqIO.write(Dictionary, 'my.file', "fasta")
>
>
> This is how I have removed items from my.file but I
> need to convert it back into a fasta file so it can be
> read by blast.
Doing Dictionary.values() will give a list of SeqRecord
objects, which you can give to the SeqIO.write(...)
function to save to a FASTA file. i.e.
Dictionary = SeqIO.to_dict(SeqIO.parse('my.file', "fasta")
#edit dictionary... then:
SeqIO.write(Dictionary.values(), "new.fas", "fasta")
If you care about the order then it is a little more
complicated.
Peter
More information about the Biopython
mailing list