-
- @Test(groups = "Functional")
- public void testGetCdsRanges_badData()
- {
- EmblEntry testee = new EmblEntry();
-
- /*
- * Make a (CDS) Feature with 4 locations
- */
- EmblFeature cds = new EmblFeature();
- Vector<EmblFeatureLocations> locs = new Vector<EmblFeatureLocations>();
- cds.setLocations(locs);
-
- /*
- * single range [10-20]
- */
- EmblFeatureLocations loc = new EmblFeatureLocations();
- loc.setLocationType("single");
- loc.setLocationComplement(false);
- Vector<EmblFeatureLocElement> elements = new Vector<EmblFeatureLocElement>();
- EmblFeatureLocElement locElement = new EmblFeatureLocElement();
- BasePosition b1 = new BasePosition();
- b1.setPos("10");
- BasePosition b2 = new BasePosition();
- b2.setPos("20");
- locElement.setBasePositions(new BasePosition[] { b1, b2 });
- elements.add(locElement);
- loc.setLocElements(elements);
- locs.add(loc);
-
- /*
- * single range with missing end position - should be skipped
- */
- loc = new EmblFeatureLocations();
- loc.setLocationType("single");
- loc.setLocationComplement(false);
- elements = new Vector<EmblFeatureLocElement>();
- locElement = new EmblFeatureLocElement();
- b1 = new BasePosition();
- b1.setPos("30");
- locElement.setBasePositions(new BasePosition[] { b1 });
- elements.add(locElement);
- loc.setLocElements(elements);
- locs.add(loc);
-
- /*
- * single range with extra base position - should be skipped
- */
- loc = new EmblFeatureLocations();
- loc.setLocationType("single");
- loc.setLocationComplement(false);
- elements = new Vector<EmblFeatureLocElement>();
- locElement = new EmblFeatureLocElement();
- b1 = new BasePosition();
- b1.setPos("30");
- locElement.setBasePositions(new BasePosition[] { b1, b1, b1 });
- elements.add(locElement);
- loc.setLocElements(elements);
- locs.add(loc);
-
- /*
- * single valid range [50-60] to finish
- */
- loc = new EmblFeatureLocations();
- loc.setLocationType("single");
- loc.setLocationComplement(false);
- elements = new Vector<EmblFeatureLocElement>();
- locElement = new EmblFeatureLocElement();
- b1 = new BasePosition();
- b1.setPos("50");
- b2 = new BasePosition();
- b2.setPos("60");
- locElement.setBasePositions(new BasePosition[] { b1, b2 });
- elements.add(locElement);
- loc.setLocElements(elements);
- locs.add(loc);
-
- int[] exons = testee.getCdsRanges(cds);
- assertEquals("[10, 20, 50, 60]", Arrays.toString(exons));
- }
-
- /**
- * Test retrieval of exon locations matching an accession id
- */
- @Test(groups = "Functional")
- public void testGetCdsRanges_forAccession()
- {
- EmblEntry testee = new EmblEntry();
- String accession = "A1234";
- testee.setAccession(accession);
- /*
- * Make a (CDS) Feature with 4 locations
- */
- EmblFeature cds = new EmblFeature();
- Vector<EmblFeatureLocations> locs = new Vector<EmblFeatureLocations>();
- cds.setLocations(locs);
-
- /*
- * single range [10-20] for 'this' accession
- */
- EmblFeatureLocations loc = new EmblFeatureLocations();
- loc.setLocationType("single");
- loc.setLocationComplement(false);
- Vector<EmblFeatureLocElement> elements = new Vector<EmblFeatureLocElement>();
- EmblFeatureLocElement locElement = new EmblFeatureLocElement();
- locElement.setAccession(accession);
- BasePosition b1 = new BasePosition();
- b1.setPos("10");
- BasePosition b2 = new BasePosition();
- b2.setPos("20");
- locElement.setBasePositions(new BasePosition[] { b1, b2 });
- elements.add(locElement);
- loc.setLocElements(elements);
- locs.add(loc);
-
- /*
- * complement range [30-40] - no accession
- */
- loc = new EmblFeatureLocations();
- loc.setLocationType("single");
- loc.setLocationComplement(true);
- elements = new Vector<EmblFeatureLocElement>();
- locElement = new EmblFeatureLocElement();
- b1 = new BasePosition();
- b1.setPos("30");
- b2 = new BasePosition();
- b2.setPos("40");
- locElement.setBasePositions(new BasePosition[] { b1, b2 });
- elements.add(locElement);
- loc.setLocElements(elements);
- locs.add(loc);
-
- /*
- * join range [50-60] this accession, [70-80] another
- */
- loc = new EmblFeatureLocations();
- loc.setLocationType("join");
- loc.setLocationComplement(false);
- elements = new Vector<EmblFeatureLocElement>();
- locElement = new EmblFeatureLocElement();
- locElement.setAccession(accession);
- b1 = new BasePosition();
- b1.setPos("50");
- b2 = new BasePosition();
- b2.setPos("60");
- locElement.setBasePositions(new BasePosition[] { b1, b2 });
- elements.add(locElement);
- locElement = new EmblFeatureLocElement();
- locElement.setAccession("notme");
- b1 = new BasePosition();
- b1.setPos("70");
- b2 = new BasePosition();
- b2.setPos("80");
- locElement.setBasePositions(new BasePosition[] { b1, b2 });
- elements.add(locElement);
- loc.setLocElements(elements);
- locs.add(loc);
-
- /*
- * complement range [90-100] wrong accession, [110-120] good
- * this should be the same as complement(join(90..100,110.120))
- * which is "join 90-100 and 110-120, then complement"
- */
- loc = new EmblFeatureLocations();
- loc.setLocationType("join");
- loc.setLocationComplement(true);
- elements = new Vector<EmblFeatureLocElement>();
- locElement = new EmblFeatureLocElement();
- locElement.setAccession("wrong");
- b1 = new BasePosition();
- b1.setPos("90");
- b2 = new BasePosition();
- b2.setPos("100");
- locElement.setBasePositions(new BasePosition[] { b1, b2 });
- elements.add(locElement);
- locElement = new EmblFeatureLocElement();
- locElement.setAccession(accession);
- b1 = new BasePosition();
- b1.setPos("110");
- b2 = new BasePosition();
- b2.setPos("120");
- locElement.setBasePositions(new BasePosition[] { b1, b2 });
- elements.add(locElement);
- loc.setLocElements(elements);
- locs.add(loc);
-
- /*
- * verify we pick out only ranges for A1234
- */
- int[] exons = testee.getCdsRanges(cds);
- assertEquals("[10, 20, 50, 60, 120, 110]",
- Arrays.toString(exons));
- }