[BioPython] question regarding writing Seq objects in Fasta format

Ann Loraine aloraine at gmail.com
Tue Mar 27 05:31:05 UTC 2007


Hello,

I have a question about how to write out Bio.Seq.Seq objects to a
fasta format file.

I've generated a lot of these by translating segments of genomic
sequence -- see below.

What objects or code should I use?

It looks like Bio.SeqIO.FASTA.FastaWriter might be the right thing,
but it doesn't appear to accept Bio.Seq.Seq objects. Do I need to
create a new type of Seq-like object before I can use
Bio.SeqIO.FASTA.FastaWriter?

Thank you for your time!

Yours,

Ann

xxx my code for generating the Seq objects I want to write

def feat2aaseq(feat,seq):
    """
    Function: translate the given feature
    Returns : a Bio.Seq.Seq [biopython]
    Args    : feat - feature.DNASeqFeature [not biopython]
                seq - a Bio.Seq.Seq, e.g., a chromosome
    """
    start = feat.start()
    end = feat.start()+feat.length()
    fullseq = seq.sequence
    subseq_ob = Seq(fullseq[start:end],IUPAC.unambiguous_dna)
    if feat.strand() == -1:
        subseq_ob = subseq_ob.reverse_complement()
    translator = Translate.unambiguous_dna_by_id[4]
    aaseq = translator.translate(subseq_ob)
    return aaseq

-- 
Ann Loraine, Assistant Professor
Departments of Genetics, Biostatistics,
Computer and Information Sciences
Associate Scientist, Comprehensive Cancer Center
University of Alabama at Birmingham
http://www.transvar.org
205-996-4155



More information about the Biopython mailing list