[Biojava-l] Introducing a mutation in a DNA sequence

Ben Stöver benstoever at uni-muenster.de
Wed Apr 8 16:18:52 UTC 2015


Hi Andreas, Paolo and all,

> I was asking this question since in a previous message you said the
> following and I was not sure what you meant with this:

> > A different EditableSequence interface and a tool class that can
> > converts
> > between Sequence and EditableSequence (without inheriting
> > EditableSequence
> > from Sequence as I initially proposed) might be one option

> I agree that stacking of views is not desirable.

I was writing this only to provide an alternative if EditableSequence really
should not be inherited from Sequence because no class implementing Sequence
(which would be the case for each class implementing EditableSequence, if it
inherits from Sequence) should be mutable. I personally would not prefer that
solution, but it would be necessary to keep all Sequence implementations
unmodifiable.

I think it could be a compromise to inherit EditableSequence from Sequence and
leave it to the application developer to make sure not to pass implementations
of EditableSequence to e.g. SequenceViews that expect an unmodifiable object.
What do you and others think about this?

To demonstrate this idea a made a fork and committed two stubs:

An example how EditableSequence could look like:
https://github.com/BenStoever/biojava/blob/master/biojava-core/src/main/java/org/biojava/nbio/core/sequence/template/EditableSequence.java

An example for a method that makes sure that only unmodifiable objects are
provided as parameters:
https://github.com/BenStoever/biojava/blob/master/biojava-core/src/test/java/org/biojava/nbio/core/sequence/test/TestSequenceView.java


@Paolo:

> I don't see completely necessary to use a stack of views if mutation
> objects (let's say to define Mutation: an Interface to describe a mutation)
> are stored in a Sequence object by means of a collection. So every
> subsequent edit could be added to the others in the same Sequence object.

That would be possible, but it does not make an real difference to having an
EditableSequence interface, because SequenceView extends Sequence and
therefore having such a view would again be a modifiable implementation of
Sequence.

Best
Ben


More information about the Biojava-l mailing list