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