2 * BioJava development code
4 * This code may be freely distributed and modified under the
5 * terms of the GNU Lesser General Public Licence. This should
6 * be distributed with the code. If you do not have a copy,
9 * http://www.gnu.org/copyleft/lesser.html
11 * Copyright for this code is held jointly by the individual
12 * authors. These should be listed in @author doc comments.
14 * For more information on the BioJava project and its aims,
15 * or to join the biojava-l mailing list, visit the home page
18 * http://www.biojava.org/
20 * Created on Feb 9, 2005
23 package org.biojava.dasobert.feature;
25 import java.util.ArrayList;
26 import java.util.Iterator;
27 import java.util.List;
29 /** An Abstract class representing a Feature as being diplayed in the SeqFeaturePanel
30 * A feature corresponds to everything that is visible in a "line" and can contain one or multiple Segments.
33 * @author Andreas Prlic
36 public abstract class AbstractFeatureTrack implements FeatureTrack,Cloneable {
50 public AbstractFeatureTrack() {
58 segments = new ArrayList();
62 public abstract Object clone();
65 public String toString() {
66 String str = "Feature: method: " + method +" type: " + type ;
68 str += " name: " + name;
70 if (( note != null) && (! note.equals("null")))
72 if (note.length() > 40)
73 str += "note: " +note.substring(0,39) + "...";
75 str += " note: "+note;
77 str += " # segments: " + segments.size() ;
82 /** returns true if the specified sequence position is within the range of this Feature
84 * @param seqPosition the position to check
85 * @return true if the position is within the ranges of the segments of this feature
87 public boolean overlaps(int seqPosition){
88 List segments = getSegments();
89 Iterator iter =segments.iterator();
91 while (iter.hasNext()){
93 Segment seg = (Segment) iter.next();
94 if ( seg.overlaps(seqPosition) )
101 public void setSource(String s) { source = s;}
102 public String getSource() { return source; };
105 public void setName(String nam) { name = nam; }
106 public String getName() { return name; }
108 public void setMethod(String methd) { method = methd ; }
109 public String getMethod() { return method ; }
111 public void setType(String typ) { type = typ ; }
112 public String getType() { return type ; }
114 public void setNote(String nte) {
118 public String getNote() { return note ; }
120 public void setLink(String lnk) { link = lnk;}
121 public String getLink() { return link;}
123 public void setScore(String s){ score = s;}
124 public String getScore() { return score;}
126 /** add a segment to this feature */
127 public void addSegment(int start, int end, String name) {
128 Segment s = new SegmentImpl() ;
136 public void addSegment( Segment s ){
141 public List getSegments() {
146 public String getOrientation() {
150 public void setOrientation(String orientation) {
151 this.orientation = orientation;
154 /** test if two features are equivalent
155 * important: only comares type,method and source.
156 * The individual segments are not compared!
159 public boolean equals(FeatureTrack feat) {
160 // if ( note == null) {
161 // if (( feat.getNote() == null ) ||
162 // ( feat.getNote().equals(""))) {
163 //} else if ( this.note.equals(feat.getNote())){
166 if ( this.type.equals(feat.getType())){
167 if ( this.method.equals(feat.getMethod())){
168 if ( this.source.equals(feat.getSource())){
169 if (this.note.equals(feat.getNote())){
178 public String getTypeCategory() {
179 // TODO Auto-generated method stub
183 public String getTypeID() {
184 // TODO Auto-generated method stub
188 public void setTypeCategory(String typeCategory) {
189 this.typeCategory = typeCategory;
193 public void setTypeID(String typeID) {
194 this.typeID = typeID;