[Biojava-l] Remove features from a sequence

Ren, Zhen zren at amylin.com
Wed Jun 18 17:33:32 EDT 2003


Hi, folks,

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

Zhen

import org.biojava.bio.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.symbol.*;
import org.biojava.utils.*;
import java.util.*;

public class MakeAFeature {
    public static void main(String[] args) {
        StrandedFeature.Template templ = new StrandedFeature.Template();

        templ.annotation = Annotation.EMPTY_ANNOTATION;
        templ.location = new RangeLocation(3,6);
        templ.source = "my feature";
        templ.strand = StrandedFeature.POSITIVE;
        templ.type = "interesting motif";

        try {
            Sequence seq = DNATools.createDNASequence("atgcgcttaag", "seq1");
            Feature f = seq.createFeature(templ);
            Iterator i = seq.features();
            while(i.hasNext()) {
                Feature feature = (Feature)i.next();
                seq.remove(feature);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}



More information about the Biojava-l mailing list