* @author gmcarstairs
*
*/
-public class SequenceFeatures
+public class SequenceFeatures implements SequenceFeaturesI
{
/*
}
/**
- * Adds one sequence feature to the store, and returns true, unless the
- * feature is already contained in the store, in which case this method
- * returns false. Containment is determined by SequenceFeature.equals()
- * comparison.
- *
- * @param sf
+ * {@inheritDoc}
*/
+ @Override
public boolean add(SequenceFeature sf)
{
String type = sf.getType();
}
/**
- * Returns a (possibly empty) list of features, optionally restricted to
- * specified types, which overlap the given (inclusive) sequence position
- * range
- *
- * @param from
- * @param to
- * @param type
- * @return
+ * {@inheritDoc}
*/
+ @Override
public List<SequenceFeature> findFeatures(int from, int to,
String... type)
{
}
/**
- * Answers a list of all features stored, optionally restricted to specified
- * types, in no particular guaranteed order
- *
- * @param type
- * @return
+ * {@inheritDoc}
*/
+ @Override
public List<SequenceFeature> getAllFeatures(String... type)
{
List<SequenceFeature> result = new ArrayList<SequenceFeature>();
}
/**
- * Answers a list of all positional features, optionally restricted to
- * specified types, in no particular guaranteed order
- *
- * @param type
- * @return
+ * {@inheritDoc}
+ */
+ @Override
+ public int getFeatureCount(boolean positional, String... type)
+ {
+ int result = 0;
+
+ for (String featureType : varargToTypes(type))
+ {
+ FeatureStore featureSet = featureStore.get(featureType);
+ if (featureSet != null)
+ {
+ result += featureSet.getFeatureCount(positional);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getTotalFeatureLength(String... type)
+ {
+ int result = 0;
+
+ for (String featureType : varargToTypes(type))
+ {
+ FeatureStore featureSet = featureStore.get(featureType);
+ if (featureSet != null)
+ {
+ result += featureSet.getTotalFeatureLength();
+ }
+ }
+ return result;
+
+ }
+
+ /**
+ * {@inheritDoc}
*/
+ @Override
public List<SequenceFeature> getPositionalFeatures(String... type)
{
List<SequenceFeature> result = new ArrayList<SequenceFeature>();
}
/**
- * Answers a list of all contact features, optionally restricted to specified
- * types, in no particular guaranteed order
- *
- * @return
+ * {@inheritDoc}
*/
+ @Override
public List<SequenceFeature> getContactFeatures(String... type)
{
List<SequenceFeature> result = new ArrayList<SequenceFeature>();
}
/**
- * Answers a list of all non-positional features, optionally restricted to
- * specified types, in no particular guaranteed order
- *
- * @param type
- * if no type is specified, all are returned
- * @return
+ * {@inheritDoc}
*/
+ @Override
public List<SequenceFeature> getNonPositionalFeatures(String... type)
{
List<SequenceFeature> result = new ArrayList<SequenceFeature>();
}
/**
- * Deletes the given feature from the store, returning true if it was found
- * (and deleted), else false. This method makes no assumption that the feature
- * is in the 'expected' place in the store, in case it has been modified since
- * it was added.
- *
- * @param sf
+ * {@inheritDoc}
*/
+ @Override
public boolean delete(SequenceFeature sf)
{
for (FeatureStore featureSet : featureStore.values())
}
/**
- * Answers true if this store contains at least one feature, else false
- *
- * @return
+ * {@inheritDoc}
*/
+ @Override
public boolean hasFeatures()
{
for (FeatureStore featureSet : featureStore.values())
}
/**
- * Returns a set of the distinct feature groups present in the collection. The
- * set may include null. The boolean parameter determines whether the groups
- * for positional or for non-positional features are returned. The optional
- * type parameter may be used to restrict to groups for specified feature
- * types.
- *
- * @param positionalFeatures
- * @param type
- * @return
+ * {@inheritDoc}
*/
+ @Override
public Set<String> getFeatureGroups(boolean positionalFeatures,
String... type)
{
}
/**
- * Answers the set of distinct feature types for which there is at least one
- * feature with one of the given feature group(s). The parameter determines
- * whether the groups for positional or for non-positional features are
- * returned.
- *
- * @param positionalFeatures
- * @param groups
- * @return
+ * {@inheritDoc}
*/
+ @Override
public Set<String> getFeatureTypesForGroups(boolean positionalFeatures,
String... groups)
{
return result;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Set<String> getFeatureTypes()
+ {
+ Set<String> types = new HashSet<String>();
+ for (Entry<String, FeatureStore> entry : featureStore.entrySet())
+ {
+ if (!entry.getValue().isEmpty())
+ {
+ types.add(entry.getKey());
+ }
+ }
+ return types;
+ }
+
+ /**
+ * Answers the minimum score held for positional or non-positional features
+ * for the specified type. This may be Float.NaN if there are no features, or
+ * none has a non-NaN score.
+ *
+ * @param type
+ * @param positional
+ * @return
+ */
+ public float getMinimumScore(String type, boolean positional)
+ {
+ return featureStore.containsKey(type) ? featureStore.get(type)
+ .getMinimumScore(positional) : Float.NaN;
+ }
+
+ /**
+ * Answers the maximum score held for positional or non-positional features
+ * for the specified type. This may be Float.NaN if there are no features, or
+ * none has a non-NaN score.
+ *
+ * @param type
+ * @param positional
+ * @return
+ */
+ public float getMaximumScore(String type, boolean positional)
+ {
+ return featureStore.containsKey(type) ? featureStore.get(type)
+ .getMaximumScore(positional) : Float.NaN;
+ }
}