2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel.features;
23 import jalview.datamodel.SequenceFeature;
25 import java.util.List;
28 public interface SequenceFeaturesI
32 * Adds one sequence feature to the store, and returns true, unless the
33 * feature is already contained in the store, in which case this method
34 * returns false. Containment is determined by SequenceFeature.equals()
35 * comparison. Answers false, and does not add the feature, if feature type is
40 boolean add(SequenceFeature sf);
43 * Returns a (possibly empty) list of features, optionally restricted to
44 * specified types, which overlap the given (inclusive) sequence position
45 * range. If types are specified, features are returned in the order of the
53 List<SequenceFeature> findFeatures(int from, int to,
57 * Answers a list of all features stored, in no particular guaranteed order.
58 * Positional features may optionally be restricted to specified types, but
59 * all non-positional features (if any) are always returned.
61 * To filter non-positional features by type, use
62 * getNonPositionalFeatures(type).
67 List<SequenceFeature> getAllFeatures(String... type);
70 * Answers a list of all positional (or non-positional) features which are in
71 * the specified feature group, optionally restricted to features of specified
75 * if true returns positional features, else non-positional features
77 * the feature group to be matched (which may be null)
79 * optional feature types to filter by
82 List<SequenceFeature> getFeaturesForGroup(boolean positional,
83 String group, String... type);
86 * Answers a list of all features stored, whose type either matches, or is a
87 * specialisation (in the Sequence Ontology) of, one of the given terms.
88 * Results are returned in no particular order.
93 List<SequenceFeature> getFeaturesByOntology(String... ontologyTerm);
96 * Answers the number of (positional or non-positional) features, optionally
97 * restricted to specified feature types. Contact features are counted as 1.
103 int getFeatureCount(boolean positional, String... type);
106 * Answers the total length of positional features, optionally restricted to
107 * specified feature types. Contact features are counted as length 1.
112 int getTotalFeatureLength(String... type);
115 * Answers a list of all positional features, optionally restricted to
116 * specified types, in no particular guaranteed order
121 List<SequenceFeature> getPositionalFeatures(
125 * Answers a list of all contact features, optionally restricted to specified
126 * types, in no particular guaranteed order
130 List<SequenceFeature> getContactFeatures(String... type);
133 * Answers a list of all non-positional features, optionally restricted to
134 * specified types, in no particular guaranteed order
137 * if no type is specified, all are returned
140 List<SequenceFeature> getNonPositionalFeatures(
144 * Deletes the given feature from the store, returning true if it was found
145 * (and deleted), else false. This method makes no assumption that the feature
146 * is in the 'expected' place in the store, in case it has been modified since
151 boolean delete(SequenceFeature sf);
154 * Answers true if this store contains at least one feature, else false
158 boolean hasFeatures();
161 * Returns a set of the distinct feature groups present in the collection. The
162 * set may include null. The boolean parameter determines whether the groups
163 * for positional or for non-positional features are returned. The optional
164 * type parameter may be used to restrict to groups for specified feature
167 * @param positionalFeatures
171 Set<String> getFeatureGroups(boolean positionalFeatures,
175 * Answers the set of distinct feature types for which there is at least one
176 * feature with one of the given feature group(s). The boolean parameter
177 * determines whether the groups for positional or for non-positional features
180 * @param positionalFeatures
184 Set<String> getFeatureTypesForGroups(
185 boolean positionalFeatures, String... groups);
188 * Answers a set of the distinct feature types for which a feature is stored.
189 * The types may optionally be restricted to those which match, or are a
190 * subtype of, given sequence ontology terms
194 Set<String> getFeatureTypes(String... soTerm);
197 * Answers the minimum score held for positional or non-positional features
198 * for the specified type. This may be Float.NaN if there are no features, or
199 * none has a non-NaN score.
205 float getMinimumScore(String type, boolean positional);
208 * Answers the maximum score held for positional or non-positional features
209 * for the specified type. This may be Float.NaN if there are no features, or
210 * none has a non-NaN score.
216 float getMaximumScore(String type, boolean positional);
219 * Adds the shift amount to the start and end of all positional features whose
220 * start position is at or after fromPosition. Returns true if at least one
221 * feature was shifted, else false.
223 * @param fromPosition
226 boolean shiftFeatures(int fromPosition, int shiftBy);
229 * Deletes all positional and non-positional features