@Override public Set<AminoAcidCompound> getEquivalentCompounds(AminoAcidCompound compound) { if (equivalentsCache.isEmpty()) { // most compounds are equivalent to themselves alone for (AminoAcidCompound c : aminoAcidCompoundCache.values()) { equivalentsCache.put(c, Collections.singleton(c)); } // ambiguous Asparagine or Aspartic acid addAmbiguousEquivalents("N", "D", "B"); // ambiguous Glutamine or Glutamic acid addAmbiguousEquivalents("E", "Q", "Z"); // ambiguous Leucine or Isoleucine addAmbiguousEquivalents("I", "L", "J"); // ambiguous gaps AminoAcidCompound gap1, gap2, gap3; Set<AminoAcidCompound> gaps = new HashSet<AminoAcidCompound>(); gaps.add(gap1 = aminoAcidCompoundCache.get("-")); gaps.add(gap2 = aminoAcidCompoundCache.get(".")); gaps.add(gap3 = aminoAcidCompoundCache.get("_")); equivalentsCache.put(gap1, gaps); equivalentsCache.put(gap2, gaps); equivalentsCache.put(gap3, gaps); // X is never equivalent, even to itself equivalentsCache.put(aminoAcidCompoundCache.get("X"), new HashSet<AminoAcidCompound>()); } return equivalentsCache.get(compound); }
@Override public Set<AminoAcidCompound> getEquivalentCompounds(AminoAcidCompound compound) { if (equivalentsCache.isEmpty()) { // most compounds are equivalent to themselves alone for (AminoAcidCompound c : aminoAcidCompoundCache.values()) { equivalentsCache.put(c, Collections.singleton(c)); } // ambiguous Asparagine or Aspartic acid addAmbiguousEquivalents("N", "D", "B"); // ambiguous Glutamine or Glutamic acid addAmbiguousEquivalents("E", "Q", "Z"); // ambiguous Leucine or Isoleucine addAmbiguousEquivalents("I", "L", "J"); // ambiguous gaps AminoAcidCompound gap1, gap2, gap3; Set<AminoAcidCompound> gaps = new HashSet<AminoAcidCompound>(); gaps.add(gap1 = aminoAcidCompoundCache.get("-")); gaps.add(gap2 = aminoAcidCompoundCache.get(".")); gaps.add(gap3 = aminoAcidCompoundCache.get("_")); equivalentsCache.put(gap1, gaps); equivalentsCache.put(gap2, gaps); equivalentsCache.put(gap3, gaps); // X is never equivalent, even to itself equivalentsCache.put(aminoAcidCompoundCache.get("X"), new HashSet<AminoAcidCompound>()); } return equivalentsCache.get(compound); }