JAL-2480 always include all non-positional features in getAllFeatures()
[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 features stored, whose type either matches one of the
50    * given ontology terms, or is a specialisation of a term in the Sequence
51    * Ontology. Results are returned in no particular guaranteed order.
52    * 
53    * @param ontologyTerm
54    * @return
55    */
56   List<SequenceFeature> getFeaturesByOntology(String... ontologyTerm);
57
58   /**
59    * Answers the number of (positional or non-positional) features, optionally
60    * restricted to specified feature types. Contact features are counted as 1.
61    * 
62    * @param positional
63    * @param type
64    * @return
65    */
66   int getFeatureCount(boolean positional, String... type);
67
68   /**
69    * Answers the total length of positional features, optionally restricted to
70    * specified feature types. Contact features are counted as length 1.
71    * 
72    * @param type
73    * @return
74    */
75   int getTotalFeatureLength(String... type);
76
77   /**
78    * Answers a list of all positional features, optionally restricted to
79    * specified types, in no particular guaranteed order
80    * 
81    * @param type
82    * @return
83    */
84   List<SequenceFeature> getPositionalFeatures(
85           String... type);
86
87   /**
88    * Answers a list of all contact features, optionally restricted to specified
89    * types, in no particular guaranteed order
90    * 
91    * @return
92    */
93   List<SequenceFeature> getContactFeatures(String... type);
94
95   /**
96    * Answers a list of all non-positional features, optionally restricted to
97    * specified types, in no particular guaranteed order
98    * 
99    * @param type
100    *          if no type is specified, all are returned
101    * @return
102    */
103   List<SequenceFeature> getNonPositionalFeatures(
104           String... type);
105
106   /**
107    * Deletes the given feature from the store, returning true if it was found
108    * (and deleted), else false. This method makes no assumption that the feature
109    * is in the 'expected' place in the store, in case it has been modified since
110    * it was added.
111    * 
112    * @param sf
113    */
114   boolean delete(SequenceFeature sf);
115
116   /**
117    * Answers true if this store contains at least one feature, else false
118    * 
119    * @return
120    */
121   boolean hasFeatures();
122
123   /**
124    * Returns a set of the distinct feature groups present in the collection. The
125    * set may include null. The boolean parameter determines whether the groups
126    * for positional or for non-positional features are returned. The optional
127    * type parameter may be used to restrict to groups for specified feature
128    * types.
129    * 
130    * @param positionalFeatures
131    * @param type
132    * @return
133    */
134   Set<String> getFeatureGroups(boolean positionalFeatures,
135           String... type);
136
137   /**
138    * Answers the set of distinct feature types for which there is at least one
139    * feature with one of the given feature group(s). The boolean parameter
140    * determines whether the groups for positional or for non-positional features
141    * are returned.
142    * 
143    * @param positionalFeatures
144    * @param groups
145    * @return
146    */
147   Set<String> getFeatureTypesForGroups(
148           boolean positionalFeatures, String... groups);
149
150   /**
151    * Answers a set of the distinct feature types for which a feature is stored.
152    * The types may optionally be restricted to those which match, or are a
153    * subtype of, given sequence ontology terms
154    * 
155    * @return
156    */
157   Set<String> getFeatureTypes(String... soTerm);
158
159   /**
160    * Answers the minimum score held for positional or non-positional features
161    * for the specified type. This may be Float.NaN if there are no features, or
162    * none has a non-NaN score.
163    * 
164    * @param type
165    * @param positional
166    * @return
167    */
168   float getMinimumScore(String type, boolean positional);
169
170   /**
171    * Answers the maximum score held for positional or non-positional features
172    * for the specified type. This may be Float.NaN if there are no features, or
173    * none has a non-NaN score.
174    * 
175    * @param type
176    * @param positional
177    * @return
178    */
179   float getMaximumScore(String type, boolean positional);
180 }