Ejemplo n.º 1
0
  @Test
  public void testBedAndBigBed() throws Exception {
    String bedPath = TestUtils.DATA_DIR + "bed/Unigene.sample.nolong.bed";
    String bigBedPath = TestUtils.DATA_DIR + "bed/Unigene.sample.nolong.bigbed";

    File bigBedFile = new File(bigBedPath);

    // Need to index so query of bed file is accurate
    TestUtils.createIndex(bedPath);

    List<Track> bedtracks = tstLoadFi(bedPath, 1, false);
    List<Track> bigBedtracks = tstLoadFi(bigBedPath, 1, false);

    String chr = "chr2";
    int start = 178711404 - 1;
    int end = 179189619 + 1;

    FeatureTrack bedTrack = (FeatureTrack) bedtracks.get(0);
    FeatureTrack bigBedTrack = (FeatureTrack) bigBedtracks.get(0);

    // Multiple trials because we're concerned about file open/close issues
    int trials = 10;

    for (int ii = 0; ii < trials; ii++) {
      int strt = start + ii;
      List<Feature> bedFeatures = bedTrack.getFeatures(chr, strt, end);
      List<Feature> bigBedFeatures = bigBedTrack.getFeatures(chr, strt, end);
      TestUtils.assertFeatureListsEqual(bedFeatures.iterator(), bigBedFeatures.iterator());

      // NOT FOOLPROOF
      assertTrue(bigBedFile.canWrite());
    }
  }
Ejemplo n.º 2
0
  @BeforeClass
  public static void setUpClass() throws Exception {
    assumeNotHeadless();
    TestUtils.setUpTestEnvironment();
    igv = startGUI();

    TestUtils.setAllNames(igv, true);
  }
Ejemplo n.º 3
0
  @Before
  public void setUp() throws Exception {
    igv.newSession();
    IGV.getMainFrame().requestFocus();

    TestUtils.resetPrefsFile();
    TestUtils.resetTestUserDefinedGenomes();
    IGV.getInstance().getContentPane().getCommandBar().refreshGenomeListComboBox();
  }
Ejemplo n.º 4
0
  static List<Track> tstLoadFi(
      TrackLoader trackLoader,
      String filepath,
      Integer expected_tracks,
      Genome genome,
      boolean makeIndex)
      throws Exception {
    ResourceLocator locator = new ResourceLocator(filepath);

    // Try creating an index
    // UI would ask for confirmation
    if (makeIndex) {
      try {
        TestUtils.createIndex(filepath);
      } catch (Exception e) {

      }
    }
    List<Track> tracks = trackLoader.load(locator, genome);
    if (expected_tracks != null) {
      assertEquals(expected_tracks.intValue(), tracks.size());
      if (expected_tracks == 0) {
        return tracks;
      }
    }

    Track track = tracks.get(0);
    assertEquals(locator, track.getResourceLocator());

    return tracks;
  }
Ejemplo n.º 5
0
  @Test
  public void testEncodeDecode() throws Exception {
    String testFile = TestUtils.DATA_DIR + "sam/NA12878.muc1.test.sam";
    SAMReader reader = new SAMReader(testFile);

    Iterator<PicardAlignment> inputAlignmentIterator = reader.iterator();
    ArrayList<PicardAlignment> inputAlignmentList = new ArrayList<PicardAlignment>();

    while (inputAlignmentIterator.hasNext()) {
      PicardAlignment al = inputAlignmentIterator.next();
      inputAlignmentList.add(al);
    }
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    FeatureEncoder<PicardAlignment> alignmentEncoder = new SamAlignmentEncoder();
    alignmentEncoder.encodeAll(bos, reader.iterator());

    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());

    FeatureDecoder<PicardAlignment> alignmentDecoder = new AlignmentDecoder();
    Iterator<PicardAlignment> decodedAlignments = alignmentDecoder.decodeAll(bis, false);

    int ind = 0;
    while (decodedAlignments.hasNext()) {

      Alignment act = decodedAlignments.next();
      Alignment exp = inputAlignmentList.get(ind++);
      TestUtils.assertFeaturesEqual(exp, act);
      assertEquals(exp.getCigarString(), act.getCigarString());
    }

    assertEquals("Different number of alignments read in as out", inputAlignmentList.size(), ind);
  }
Ejemplo n.º 6
0
  @Test
  public void testLoadDataSourceTrack() throws Exception {
    String path = TestUtils.DATA_DIR + "sessions/tdf_session.xml";
    rewriteRestoreSession(path);

    DataSourceTrack track = (DataSourceTrack) IGV.getInstance().getAllTracks().get(0);
    assertEquals(true, TestUtils.runMethod(track, "getNormalize"));
    assertEquals("NA12878.SLX.egfr.sam.tdf", track.getName());
  }
Ejemplo n.º 7
0
  /**
   * Test that we properly load a vcf file, even though the extension is upper-case. IGV-2012
   *
   * @throws Exception
   */
  @Test
  public void testLoadVCFUpperCase() throws Exception {
    String filepath = TestUtils.DATA_DIR + "vcf/HC_MOD_CAPS.VCF";
    ResourceLocator locator = new ResourceLocator(filepath);
    TestUtils.createIndex(filepath);

    List<Track> tracks = trackLoader.load(locator, genome);
    assertEquals(1, tracks.size());
    assertTrue("VCF file loaded incorrect track type", tracks.get(0) instanceof VariantTrack);
  }
Ejemplo n.º 8
0
 @Test
 public void testLoadBEDtxt() throws Exception {
   String filepath = TestUtils.DATA_DIR + "bed/intervalTest.bed.txt";
   TestUtils.createIndex(filepath);
   tstLoadFi(filepath, 1, true);
 }
Ejemplo n.º 9
0
 public void tstFilesHeadless(String[] filenames, boolean tryIndex) throws Exception {
   Genome genome = TestUtils.loadGenome();
   for (String finame : filenames) {
     tstLoadFi(TestUtils.DATA_DIR + finame, null, genome, tryIndex);
   }
 }
Ejemplo n.º 10
0
 private List<Track> tstLoadFi(String filepath, Integer expected_tracks, boolean makeIndex)
     throws Exception {
   Genome genome = TestUtils.loadGenome();
   return tstLoadFi(filepath, expected_tracks, genome, makeIndex);
 }
Ejemplo n.º 11
0
 @After
 public void tearDown() throws Exception {
   TestUtils.resetPrefsFile();
   TestUtils.resetTestUserDefinedGenomes();
 }
Ejemplo n.º 12
0
 @AfterClass
 public static void tearDownClass() throws Exception {
   TestUtils.clearOutputDir();
   stopGUI();
   igv = null;
 }
Ejemplo n.º 13
0
 protected static String rewriteRestoreSession(String sessionPath) throws Exception {
   sessionPath = (TestUtils.replaceTestPaths(new File(sessionPath))).getAbsolutePath();
   IGV.getInstance().doRestoreSession(sessionPath, null, false);
   return sessionPath;
 }
Ejemplo n.º 14
0
 /**
  * Get render options of the track, reflectively so we don't need to alter access controls
  *
  * @param track
  * @return
  * @throws Exception
  */
 private AlignmentTrack.RenderOptions getRenderOptions(Track track) throws Exception {
   Object result = TestUtils.getField(track, "renderOptions");
   return (AlignmentTrack.RenderOptions) result;
 }