[BioPython] Logo and More Code
Jeffrey Chang
jchang@SMI.Stanford.EDU
Fri, 10 Sep 1999 17:11:02 -0700 (PDT)
On Fri, 10 Sep 1999, Bradley Marshall wrote:
> I'm going to repost my code for a seq object at :
>
> www.bradmarshall.com/pyDNA1
I haven't looked at the LSR BSA RFC, so I can't give specific answers
to some of your questions.
> I'm looking for any comments on:
>
> 1) am I doing inheritance right? ie when SeqRegion inherits from
> Interval, should I call interval's constructor or ovverride it?
Both.
class Interval:
def __init__(self, start, length):
self.start = start - 1
self.end = self.start + length
class SeqRegion(Interval):
def __init__(self, start, length, StrandType = 'PLUS_STRAND',
start_relative_to_seq_end = 0):
self.start = start - 1
self.end = self.start + length
self.strandtype = StrandType
self.relative = start_relative_to_seq_end
Here, the code to initialize the self.start and self.end attributes
are duplicated across two classes. SeqRegion should allow Interval to
initialize them.
class SeqRegion(Interval):
def __init__(self, start, length, StrandType = 'PLUS_STRAND',
start_relative_to_seq_end = 0):
Interval.__init__(self, start, length)
self.strandtype = StrandType
self.relative = start_relative_to_seq_end
> 2) Where should SeqAnnotationIterator go? Right now it's a function
> of seq (well, I called it pyDNA1, but you know...)
Iterators are usually their own class. Does the BSA give an interface
for it?
> 4) Am I remotely on the right track? I mean it works, but am I
> following the idl well? (other than having a lot of things misnamed)
> Specifically, the idl doesn't really say where the
> SEqANnotationIterator would go. It doesn't say where the annotation
> list would go. I guess that's because these things wouldn't be in
> the interfaces?
That depends on what you're trying to do! If you're after compliance
with the IDL, the you will need to compare your implementation with
the specs to see how you're doing. However, if you're aiming for a
useful object with general applicability, then that's a much harder
question, and that's what we're here to find out!
Jeff