AminoAcidFunctions { @NotNull public static List<String> allTrinucleotidesForSameAminoAcid(@NotNull String trinucleotideToFind, @NotNull Strand strand) { if (trinucleotideToFind.length() != 3) { LOGGER.warn("Cannot look up amino acids for non-trinucleotides: {}", trinucleotideToFind); return Lists.newArrayList(); } String aminoAcid = findAminoAcidForCodon(strand == Strand.FORWARD ? trinucleotideToFind : reverseAndFlip(trinucleotideToFind)); List<String> allTrinucleotides = Lists.newArrayList(); Set<String> trinucleotides = AMINO_ACID_TO_TRINUCLEOTIDES_MAP.get(aminoAcid); if (trinucleotides != null) { for (String trinucleotide : trinucleotides) { allTrinucleotides.add(strand == Strand.FORWARD ? trinucleotide : reverseAndFlip(trinucleotide)); } } else { LOGGER.warn("Could not find amino acid for trinucleotide '{}' on {} strand", trinucleotideToFind, strand); } return allTrinucleotides; }  @Nullable static String findAminoAcidForCodon(@NotNull String codon); @NotNull static List<String> allTrinucleotidesForSameAminoAcid(@NotNull String trinucleotideToFind, @NotNull Strand strand); @NotNull static String forceSingleLetterProteinAnnotation(@NotNull String proteinAnnotation); @NotNull static String reverseAndFlip(@NotNull String string);  }
@Test public void canLookupTrinucleotides() { assertEquals(6, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("TCT", Strand.FORWARD).size()); assertEquals(6, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("AGA", Strand.REVERSE).size()); assertEquals(4, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("GTC", Strand.FORWARD).size()); assertEquals(4, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("GAC", Strand.REVERSE).size()); assertEquals(2, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("TAC", Strand.FORWARD).size()); assertEquals(2, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("GTA", Strand.REVERSE).size()); assertEquals(0, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("???", Strand.FORWARD).size()); assertEquals(0, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("???", Strand.REVERSE).size()); assertEquals(0, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("TCTC", Strand.FORWARD).size()); assertEquals(0, AminoAcidFunctions.allTrinucleotidesForSameAminoAcid("GAGA", Strand.REVERSE).size()); }