[Biopython-dev] [Biopython] Subclassing Seq and SeqRecord
Jose Blanca
jblanca at btc.upv.es
Tue Nov 24 14:58:39 UTC 2009
What I mean is this:
http://github.com/JoseBlanca/biopython/commit/d4c87365f614de2d69d800dc63d0cc25087d96dc
I would like to change the Seq() and SeqRecord() for self.__class__
There are places already in Seq in which self.__class__ is used. But this is
not the case in all instances. I think that this would be a reasonable
change.
> >
> > def _set_qual(self, qual):
> > '''It stores the quality in the
> > letter_annotations['phred_quality']'''
> > self.letter_annotations["phred_quality"] = qual
> > def _get_qual(self):
> > '''It gets the quality from letter_annotations['phred_quality']'''
> > return self.letter_annotations["phred_quality"]
> > qual = property(_get_qual, _set_qual)
>
> I can see how adding a property makes accessing the PHRED
> qualities much easier.
Yes, that's just a convenience method. I used to have my own class with this
property and now I'm trying to use SeqRecord instead but adding this method
to ease the change.
> > 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.
--
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