[BioPython] Alignment add_sequence
Jose Blanca
jblanca at btc.upv.es
Wed Feb 6 16:06:08 UTC 2008
Hello,
I'm building an alignment object from a set of seqRecords using the following
code:
from Bio.Align.Generic import Alignment
from Bio.Alphabet import IUPAC
my_alpha = IUPAC.IUPACAmbiguousDNA()
ali = Alignment(my_alpha)
for seqName in sequences.keys():
seq = sequences[seqName].seq.tostring()
start = mesh[seqName]['location_begin']
id = sequences[seqName].id
ali.add_sequence(id, seq, start)
Is this the best way to do it? Everything is working as expected, but I have a
problem with this implementation. My seqRecords have additional annotations
and I'm loosing them. Maybe this could be solved with a new function like:
def add_sequence(self, seqRecord, start = None, end = None,
weight = 1.0):
Also in this way the we woudn't need to create a new SeqRecord for every
sequence and it should be quicker. The result could be something like:
from Bio.Align.Generic import Alignment
from Bio.Alphabet import IUPAC
my_alpha = IUPAC.IUPACAmbiguousDNA()
ali = Alignment(my_alpha)
for seqName in sequences.keys():
start = mesh[seqName]['location_begin']
ali.add_sequence(sequences[seqName], start)
With such a function a problem could appear if an annotation named 'start'
or 'end' is already in the annotation dict. But this could be solved raising
an expection in that case. What do you think?
Thanks for your help.
--
Jose M. Blanca Postigo
Instituto Universitario de Conservacion y
Mejora de la Agrodiversidad Valenciana (COMAV)
Universidad Politecnica de Valencia (UPV)
Edificio CPI (Ciudad Politecnica de la Innovacion), 8E
46022 Valencia (SPAIN)
Tlf.:+34-96-3877000 (ext 88473)
More information about the Biopython
mailing list