JAL-2483 use SequenceFeatures to look up groups, types, feature lengths
[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.
16    * 
17    * @param sf
18    */
19   abstract boolean add(SequenceFeature sf);
20
21   /**
22    * Returns a (possibly empty) list of features, optionally restricted to
23    * specified types, which overlap the given (inclusive) sequence position
24    * range
25    * 
26    * @param from
27    * @param to
28    * @param type
29    * @return
30    */
31   abstract List<SequenceFeature> findFeatures(int from, int to,
32           String... type);
33
34   /**
35    * Answers a list of all features stored, optionally restricted to specified
36    * types, in no particular guaranteed order
37    * 
38    * @param type
39    * @return
40    */
41   abstract List<SequenceFeature> getAllFeatures(String... type);
42
43   /**
44    * Answers the number of (positional or non-positional) features, optionally
45    * restricted to specified feature types. Contact features are counted as 1.
46    * 
47    * @param positional
48    * @param type
49    * @return
50    */
51   abstract int getFeatureCount(boolean positional, String... type);
52
53   /**
54    * Answers the total length of positional features, optionally restricted to
55    * specified feature types. Contact features are counted as length 1.
56    * 
57    * @param type
58    * @return
59    */
60   abstract int getTotalFeatureLength(String... type);
61
62   /**
63    * Answers a list of all positional features, optionally restricted to
64    * specified types, in no particular guaranteed order
65    * 
66    * @param type
67    * @return
68    */
69   abstract List<SequenceFeature> getPositionalFeatures(
70           String... type);
71
72   /**
73    * Answers a list of all contact features, optionally restricted to specified
74    * types, in no particular guaranteed order
75    * 
76    * @return
77    */
78   abstract List<SequenceFeature> getContactFeatures(String... type);
79
80   /**
81    * Answers a list of all non-positional features, optionally restricted to
82    * specified types, in no particular guaranteed order
83    * 
84    * @param type
85    *          if no type is specified, all are returned
86    * @return
87    */
88   abstract List<SequenceFeature> getNonPositionalFeatures(
89           String... type);
90
91   /**
92    * Deletes the given feature from the store, returning true if it was found
93    * (and deleted), else false. This method makes no assumption that the feature
94    * is in the 'expected' place in the store, in case it has been modified since
95    * it was added.
96    * 
97    * @param sf
98    */
99   abstract boolean delete(SequenceFeature sf);
100
101   /**
102    * Answers true if this store contains at least one feature, else false
103    * 
104    * @return
105    */
106   abstract boolean hasFeatures();
107
108   /**
109    * Returns a set of the distinct feature groups present in the collection. The
110    * set may include null. The boolean parameter determines whether the groups
111    * for positional or for non-positional features are returned. The optional
112    * type parameter may be used to restrict to groups for specified feature
113    * types.
114    * 
115    * @param positionalFeatures
116    * @param type
117    * @return
118    */
119   abstract Set<String> getFeatureGroups(boolean positionalFeatures,
120           String... type);
121
122   /**
123    * Answers the set of distinct feature types for which there is at least one
124    * feature with one of the given feature group(s). The boolean parameter
125    * determines whether the groups for positional or for non-positional features
126    * are returned.
127    * 
128    * @param positionalFeatures
129    * @param groups
130    * @return
131    */
132   abstract Set<String> getFeatureTypesForGroups(
133           boolean positionalFeatures, String... groups);
134
135   /**
136    * Answers a set of the distinct feature types for which a feature is stored
137    * 
138    * @return
139    */
140   abstract Set<String> getFeatureTypes();
141
142 }