import org.biojava.bio.*;
import org.biojava.bio.seq.*;
import org.biojava.bio.symbol.*;
import org.biojava.util.*;
public class MakeFeature {
public static void main(String[] args){
// 从链状特征中得到一个特征模版
strandedFeature.Template templ = new StrandedFeature.Template();
// 填充模版
templ.annotation = Annotation.EMPTY_ANNOTATION;
templ.location = new RangeLocation(3,6);
templ.strand = StrandedFeature.POSITIVE;
templ.type = "interesting motif";
try {
// 拥有这个特征的序列
Sequence seq = DNATools.createDNASequence("atgcgcttaag","seq1");
System.out.println(seq.getName()+" contains "+seq.countFeatures()+" features");
System.out.println("adding new feature...");
// 创建一个序列特征
Feature f = seq.createFeature(templ);
System.out.println(seq.getName()+" contains "+seq.countFeatures()+" features");
// 创建一个和序列特征的模版一致的模版
templ =(StrandedFeature.Template)f.makeTemplate();
// 重新设置特征位置和类型
templ.location = new PointLocation(4);
templ.type = "point mutation";
System.out.println("adding nested feature...");
// 将新特征变成旧特征的嵌套特征
f.createFeature(templ);
// 注意countFeature()方法如何仅仅计算顶级(top level)特征
System.out.println(seq.getName()+" contains "+seq.countFeatures()+" features ");
System.out.println(f.getSource()+" contains "+seq.countFeatures()+" features ");
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}