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