[Biojava-l] Remove features from a sequence

Keith James kdj at sanger.ac.uk
Thu Jun 19 10:33:22 EDT 2003


>>>>> "Zhen" == Ren, Zhen <zren at amylin.com> writes:

    Zhen> Hi, folks, How do I remove features from a sequence?  The
    Zhen> interface FeatureHolder has a public method - public void
    Zhen> removeFeature(Feature f) throws ChangeVetoException.  It is
    Zhen> also the superinterface for Sequence.  However, I can not
    Zhen> use the method (compile error) as shown in the following
    Zhen> snippet.  Please help.  Thanks.


[...]

Hi,

This will not compile because you have a typo at line 23: the method
should be (as seq is a Sequence)

 seq.removeFeature(feature)

and not

 seq.remove(feature)

Note that when the typo is corrected the program will throw a
java.util.ConcurrentModificationException as written because you are
violating the Java Iterator contract. See the archive for messages
from Mark and myself (in reply to Robert Stones) describing how to
avoid this.

hth, Keith

-- 

- Keith James <kdj at sanger.ac.uk> bioinformatics programming support -
- Pathogen Sequencing Unit, The Wellcome Trust Sanger Institute, UK -



More information about the Biojava-l mailing list