+
+ dbRefEntry = dbrefs[3];
+ assertEquals("EMBLCDSPROTEIN", dbRefEntry.getSource());
+ assertEquals("CAA12345.6", dbRefEntry.getAccessionId());
+ assertSame(peptides.get(5), dbRefEntry.getMap().getTo());
+ fromRanges = dbRefEntry.getMap().getMap().getFromRanges();
+ assertEquals(2, fromRanges.size());
+ assertEquals(4, fromRanges.get(0)[0]);
+ assertEquals(6, fromRanges.get(0)[1]);
+ assertEquals(10, fromRanges.get(1)[0]);
+ assertEquals(15, fromRanges.get(1)[1]);
+ toRanges = dbRefEntry.getMap().getMap().getToRanges();
+ assertEquals(1, toRanges.size());
+ assertEquals(1, toRanges.get(0)[0]);
+ assertEquals(3, toRanges.get(0)[1]);
+ }
+
+ @Test(groups = "Functional")
+ public void testAdjustForProteinLength()
+ {
+ int[] exons = new int[] { 11, 15, 21, 25, 31, 38 }; // 18 bp
+
+ // exact length match:
+ assertSame(exons, EmblEntry.adjustForProteinLength(6, exons));
+
+ // match if we assume exons include stop codon not in protein:
+ assertSame(exons, EmblEntry.adjustForProteinLength(5, exons));
+
+ // truncate last exon by 6bp
+ int[] truncated = EmblEntry.adjustForProteinLength(4, exons);
+ assertEquals("[11, 15, 21, 25, 31, 32]",
+ Arrays.toString(truncated));
+
+ // remove last exon and truncate preceding by 1bp
+ truncated = EmblEntry.adjustForProteinLength(3, exons);
+ assertEquals("[11, 15, 21, 24]", Arrays.toString(truncated));
+
+ // exact removal of exon case:
+ exons = new int[] { 11, 15, 21, 27, 33, 38 }; // 18 bp
+ truncated = EmblEntry.adjustForProteinLength(4, exons);
+ assertEquals("[11, 15, 21, 27]", Arrays.toString(truncated));
+
+ // what if exons are too short for protein?
+ truncated = EmblEntry.adjustForProteinLength(7, exons);
+ assertSame(exons, truncated);
+ // assertEquals("[11, 15, 21, 27]", Arrays.toString(truncated));