package jalview.datamodel.features; import jalview.datamodel.SequenceFeature; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; public class SequenceFeatures { /* * map from feature type to structured store of features for that type */ private Map featureStore; /** * Constructor */ public SequenceFeatures() { featureStore = new HashMap(); } /** * Add one sequence feature to the store * * @param sf */ public void add(SequenceFeature sf) { String type = sf.getType(); if (featureStore.get(type) == null) { featureStore.put(type, new FeatureStore()); } featureStore.get(type).addFeature(sf); } /** * Returns a (possibly empty) list of features of the given type which overlap * the (inclusive) sequence position range * * @param type * @param from * @param to * @return */ public List findFeatures(String type, int from, int to) { FeatureStore features = featureStore.get(type); if (features == null) { return Collections.emptyList(); } return features.findOverlappingFeatures(from, to); } }