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;
30 * An Abstract class representing a Feature as being diplayed in the
31 * SeqFeaturePanel A feature corresponds to everything that is visible in a
32 * "line" and can contain one or multiple Segments.
35 * @author Andreas Prlic
38 public abstract class AbstractFeatureTrack implements FeatureTrack,
64 public AbstractFeatureTrack()
73 segments = new ArrayList();
77 public abstract Object clone();
79 public String toString()
81 String str = "Feature: method: " + method + " type: " + type;
83 str += " name: " + name;
85 if ((note != null) && (!note.equals("null")))
87 if (note.length() > 40)
88 str += "note: " + note.substring(0, 39) + "...";
90 str += " note: " + note;
92 str += " # segments: " + segments.size();
97 * returns true if the specified sequence position is within the range of this
101 * the position to check
102 * @return true if the position is within the ranges of the segments of this
105 public boolean overlaps(int seqPosition)
107 List segments = getSegments();
108 Iterator iter = segments.iterator();
110 while (iter.hasNext())
113 Segment seg = (Segment) iter.next();
114 if (seg.overlaps(seqPosition))
121 public void setSource(String s)
126 public String getSource()
131 public void setName(String nam)
136 public String getName()
141 public void setMethod(String methd)
146 public String getMethod()
151 public void setType(String typ)
156 public String getType()
161 public void setNote(String nte)
167 public String getNote()
172 public void setLink(String lnk)
177 public String getLink()
182 public void setScore(String s)
187 public String getScore()
192 /** add a segment to this feature */
193 public void addSegment(int start, int end, String name)
195 Segment s = new SegmentImpl();
203 public void addSegment(Segment s)
209 public List getSegments()
214 public String getOrientation()
219 public void setOrientation(String orientation)
221 this.orientation = orientation;
225 * test if two features are equivalent important: only comares type,method and
226 * source. The individual segments are not compared!
229 public boolean equals(FeatureTrack feat)
231 // if ( note == null) {
232 // if (( feat.getNote() == null ) ||
233 // ( feat.getNote().equals(""))) {
234 // } else if ( this.note.equals(feat.getNote())){
237 if (this.type.equals(feat.getType()))
239 if (this.method.equals(feat.getMethod()))
241 if (this.source.equals(feat.getSource()))
243 if (this.note.equals(feat.getNote()))
254 public String getTypeCategory()
256 // TODO Auto-generated method stub
260 public String getTypeID()
262 // TODO Auto-generated method stub
266 public void setTypeCategory(String typeCategory)
268 this.typeCategory = typeCategory;
272 public void setTypeID(String typeID)
274 this.typeID = typeID;