1 package jalview.datamodel;
3 import java.util.ArrayList;
4 import java.util.Collections;
5 import java.util.HashMap;
10 * A singleton object that holds all mappings between sequences
15 public class SequenceMappings
17 private static SequenceMappings instance;
19 private Map<SequenceI, List<SequenceMapping>> mappingsFrom;
21 private Map<SequenceI, List<SequenceMapping>> mappingsTo;
24 * Non-instantiable class
26 private SequenceMappings()
28 mappingsFrom = new HashMap<>();
29 mappingsTo = new HashMap<>();
33 * Answers the singleton instance of this class
37 public SequenceMappings getInstance()
43 * Answers a (possibly empty) unmodifiable list of mappings from the given
49 public List<SequenceMapping> getMappingsFromSequence(SequenceI seq)
51 List<SequenceMapping> from = mappingsFrom.get(seq);
52 return from == null ? Collections.emptyList()
53 : Collections.unmodifiableList(from);
57 * Answers a (possibly empty) unmodifiable list of mappings to the given
63 public List<SequenceMapping> getMappingsToSequence(SequenceI seq)
65 List<SequenceMapping> from = mappingsTo.get(seq);
66 return from == null ? Collections.emptyList()
67 : Collections.unmodifiableList(from);
71 * Answers a (possibly empty) list of mappings from the given sequence to its
72 * complement(s), defined as mappings that are either CdsToPeptide or
78 public List<SequenceMapping> getMappingsToComplement(SequenceI seq)
80 List<SequenceMapping> from = mappingsTo.get(seq);
81 List<SequenceMapping> result = new ArrayList<>();
82 for (SequenceMapping mapping : from)
84 MappingType type = mapping.getType();