JAL-2446 merged to spike branch
[jalview.git] / src / jalview / datamodel / features / SequenceFeaturesI.java
1 package jalview.datamodel.features;
2
3 import jalview.datamodel.SequenceFeature;
4
5 import java.util.List;
6 import java.util.Set;
7
8 public interface SequenceFeaturesI
9 {
10
11   /**
12    * Adds one sequence feature to the store, and returns true, unless the
13    * feature is already contained in the store, in which case this method
14    * returns false. Containment is determined by SequenceFeature.equals()
15    * comparison. Answers false, and does not add the feature, if feature type is
16    * null.
17    * 
18    * @param sf
19    */
20   boolean add(SequenceFeature sf);
21
22   /**
23    * Returns a (possibly empty) list of features, optionally restricted to
24    * specified types, which overlap the given (inclusive) sequence position
25    * range
26    * 
27    * @param from
28    * @param to
29    * @param type
30    * @return
31    */
32   List<SequenceFeature> findFeatures(int from, int to,
33           String... type);
34
35   /**
36    * Answers a list of all features stored, in no particular guaranteed order.
37    * Positional features may optionally be restricted to specified types, but
38    * all non-positional features (if any) are always returned.
39    * <p>
40    * To filter non-positional features by type, use
41    * getNonPositionalFeatures(type).
42    * 
43    * @param type
44    * @return
45    */
46   List<SequenceFeature> getAllFeatures(String... type);
47
48   /**
49    * Answers a list of all positional (or non-positional) features which are in
50    * the specified feature group, optionally restricted to features of specified
51    * types.
52    * 
53    * @param positional
54    *          if true returns positional features, else non-positional features
55    * @param group
56    *          the feature group to be matched (which may be null)
57    * @param type
58    *          optional feature types to filter by
59    * @return
60    */
61   List<SequenceFeature> getFeaturesForGroup(boolean positional,
62           String group, String... type);
63
64   /**
65    * Answers a list of all features stored, whose type either matches one of the
66    * given ontology terms, or is a specialisation of a term in the Sequence
67    * Ontology. Results are returned in no particular guaranteed order.
68    * 
69    * @param ontologyTerm
70    * @return
71    */
72   List<SequenceFeature> getFeaturesByOntology(String... ontologyTerm);
73
74   /**
75    * Answers the number of (positional or non-positional) features, optionally
76    * restricted to specified feature types. Contact features are counted as 1.
77    * 
78    * @param positional
79    * @param type
80    * @return
81    */
82   int getFeatureCount(boolean positional, String... type);
83
84   /**
85    * Answers the total length of positional features, optionally restricted to
86    * specified feature types. Contact features are counted as length 1.
87    * 
88    * @param type
89    * @return
90    */
91   int getTotalFeatureLength(String... type);
92
93   /**
94    * Answers a list of all positional features, optionally restricted to
95    * specified types, in no particular guaranteed order
96    * 
97    * @param type
98    * @return
99    */
100   List<SequenceFeature> getPositionalFeatures(
101           String... type);
102
103   /**
104    * Answers a list of all contact features, optionally restricted to specified
105    * types, in no particular guaranteed order
106    * 
107    * @return
108    */
109   List<SequenceFeature> getContactFeatures(String... type);
110
111   /**
112    * Answers a list of all non-positional features, optionally restricted to
113    * specified types, in no particular guaranteed order
114    * 
115    * @param type
116    *          if no type is specified, all are returned
117    * @return
118    */
119   List<SequenceFeature> getNonPositionalFeatures(
120           String... type);
121
122   /**
123    * Deletes the given feature from the store, returning true if it was found
124    * (and deleted), else false. This method makes no assumption that the feature
125    * is in the 'expected' place in the store, in case it has been modified since
126    * it was added.
127    * 
128    * @param sf
129    */
130   boolean delete(SequenceFeature sf);
131
132   /**
133    * Answers true if this store contains at least one feature, else false
134    * 
135    * @return
136    */
137   boolean hasFeatures();
138
139   /**
140    * Returns a set of the distinct feature groups present in the collection. The
141    * set may include null. The boolean parameter determines whether the groups
142    * for positional or for non-positional features are returned. The optional
143    * type parameter may be used to restrict to groups for specified feature
144    * types.
145    * 
146    * @param positionalFeatures
147    * @param type
148    * @return
149    */
150   Set<String> getFeatureGroups(boolean positionalFeatures,
151           String... type);
152
153   /**
154    * Answers the set of distinct feature types for which there is at least one
155    * feature with one of the given feature group(s). The boolean parameter
156    * determines whether the groups for positional or for non-positional features
157    * are returned.
158    * 
159    * @param positionalFeatures
160    * @param groups
161    * @return
162    */
163   Set<String> getFeatureTypesForGroups(
164           boolean positionalFeatures, String... groups);
165
166   /**
167    * Answers a set of the distinct feature types for which a feature is stored.
168    * The types may optionally be restricted to those which match, or are a
169    * subtype of, given sequence ontology terms
170    * 
171    * @return
172    */
173   Set<String> getFeatureTypes(String... soTerm);
174
175   /**
176    * Answers the minimum score held for positional or non-positional features
177    * for the specified type. This may be Float.NaN if there are no features, or
178    * none has a non-NaN score.
179    * 
180    * @param type
181    * @param positional
182    * @return
183    */
184   float getMinimumScore(String type, boolean positional);
185
186   /**
187    * Answers the maximum score held for positional or non-positional features
188    * for the specified type. This may be Float.NaN if there are no features, or
189    * none has a non-NaN score.
190    * 
191    * @param type
192    * @param positional
193    * @return
194    */
195   float getMaximumScore(String type, boolean positional);
196
197   /**
198    * Adds the shift amount to the start and end of all positional features,
199    * returning true if at least one feature was shifted, else false
200    * 
201    * @param shift
202    */
203   abstract boolean shiftFeatures(int shift);
204 }