[Biopython-dev] [Biopython] Subclassing Seq and SeqRecord
Jose Blanca
jblanca at btc.upv.es
Tue Nov 24 16:06:32 UTC 2009
> What does your Seq subclass aim to do? Add one or two general
> methods to enhance the Seq object - or model something a little
> different?
Basically I want to use just a Seq and a SeqRecord almost as the Biopython
ones.
For the SeqRecord I'm adding a qual property, but I can change my code to deal
with that. Also I've added an __add__ (that I will remove as soon as the
biopython one is stable) and complement method to SeqRecord and __eq__ to
Seq.
Regards,
Jose Blanca
> If anyone else has written Seq (or SeqRecord) subclasses, it
> would be very helpful to hear about them. After all, the change
> Jose is proposing may break your code ;)
>
> >> > def __add__(self, seq2):
> >> > '''It returns a new object with both seq and qual joined '''
> >> > #per letter annotations
> >> > new_seq = self.__class__(name = self.name + '+' + seq2.name,
> >> > id = self.id + '+' + seq2.id,
> >> > seq = self.seq + seq2.seq)
> >> > #the letter annotations, including quality
> >> > for name, annot in self.letter_annotations.items():
> >> > if name in seq2.letter_annotations:
> >> > new_seq.letter_annotations[name] = annot + \
> >> > seq2.letter_annotations[name]
> >> > return new_seq
> >>
> >> This bit is much less clear to me - you completely ignore any
> >> features. Was it written before I added the __add__ method
> >> to the original SeqRecord (expected to be in Biopython 1.53)?
> >
> > Yes, it was added much earliear. I'll remove it as soon as the
> > Biopython SeqRecord has one.
>
> OK - your code makes more sense now. The Biopython trunk
> does now have an __add__ method (which I expect to be in
> Biopython 1.53).
>
> Peter
--
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-dev
mailing list