{
return positional ? positionalMaxScore : nonPositionalMaxScore;
}
+
+ /**
+ * Answers a list of all either positional or non-positional features whose
+ * feature group matches the given group (which may be null)
+ *
+ * @param positional
+ * @param group
+ * @return
+ */
+ public List<SequenceFeature> getFeaturesForGroup(boolean positional,
+ String group)
+ {
+ List<SequenceFeature> result = new ArrayList<SequenceFeature>();
+
+ /*
+ * if we know features don't include the target group, no need
+ * to inspect them for matches
+ */
+ if (positional && !positionalFeatureGroups.contains(group)
+ || !positional && !nonPositionalFeatureGroups.contains(group))
+ {
+ return result;
+ }
+
+ List<SequenceFeature> sfs = positional ? getPositionalFeatures()
+ : getNonPositionalFeatures();
+ for (SequenceFeature sf : sfs)
+ {
+ String featureGroup = sf.getFeatureGroup();
+ if (group == null && featureGroup == null || group != null
+ && group.equals(featureGroup))
+ {
+ result.add(sf);
+ }
+ }
+ return result;
+ }
}
Collections.sort(features, forwardStrand ? FORWARD_STRAND
: REVERSE_STRAND);
}
+
+ /**
+ * {@inheritDoc} This method is 'semi-optimised': it only inspects features
+ * for types that include the specified group, but has to inspect every
+ * feature of those types for matching feature group. This is efficient unless
+ * a sequence has features that share the same type but are in different
+ * groups - an unlikely case.
+ * <p>
+ * For example, if RESNUM feature is created with group = PDBID, then features
+ * would only be retrieved for those sequences associated with the target
+ * PDBID (group).
+ */
+ @Override
+ public List<SequenceFeature> getFeaturesForGroup(boolean positional,
+ String group, String... type)
+ {
+ List<SequenceFeature> result = new ArrayList<SequenceFeature>();
+ Iterable<String> types = varargToTypes(type);
+
+ for (String featureType : types)
+ {
+ /*
+ * check whether the feature type is present, and also
+ * whether it has features for the specified group
+ */
+ FeatureStore features = featureStore.get(featureType);
+ if (features != null
+ && features.getFeatureGroups(positional).contains(group))
+ {
+ result.addAll(features.getFeaturesForGroup(positional, group));
+ }
+ }
+ return result;
+ }
}
\ No newline at end of file
List<SequenceFeature> getAllFeatures(String... type);
/**
+ * Answers a list of all positional (or non-positional) features which are in
+ * the specified feature group, optionally restricted to features of specified
+ * types.
+ *
+ * @param positional
+ * if true returns positional features, else non-positional features
+ * @param group
+ * the feature group to be matched (which may be null)
+ * @param type
+ * optional feature types to filter by
+ * @return
+ */
+ List<SequenceFeature> getFeaturesForGroup(boolean positional,
+ String group, String... type);
+
+ /**
* Answers a list of all features stored, whose type either matches one of the
* given ontology terms, or is a specialisation of a term in the Sequence
* Ontology. Results are returned in no particular guaranteed order.