Esempio n. 1
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;
  }
Esempio n. 2
0
 @Test
 public void testLoadBEDNotIndexed() throws Exception {
   String filepath = TestUtils.DATA_DIR + "bed/intervalTest.bed";
   if (TrackLoader.isIndexed(new ResourceLocator(filepath), null)) {
     File f = new File(filepath + ".idx");
     f.delete();
   }
   tstLoadFi(filepath, 1, false);
 }
Esempio n. 3
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);
  }
Esempio n. 4
0
  /**
   * Test loading segmented data file from a sql database, using a profile
   *
   * @throws Exception
   */
  @Test
  public void testLoadSegProfile() throws Exception {
    String path = TestUtils.DATA_DIR + "sql/seg_canFam2_profile.dbxml";

    int expectedTracks = 6;
    List<Track> tracks = trackLoader.load(new ResourceLocator(path), genome);
    assertEquals(expectedTracks, tracks.size());
    Set<String> expSampleIds =
        new HashSet<String>(
            Arrays.asList("0123-A", "0123-B-1", "0123-C-1", "0123-C-2", "0123-C-3"));
    Set<String> actSampleIds = new HashSet<String>(5);
    for (Track track : tracks) {
      if (track instanceof DataSourceTrack) {
        actSampleIds.add(track.getName());
      }
    }
    assertEquals(expSampleIds, actSampleIds);
  }
Esempio n. 5
0
  @Test
  public void testLoadGFF() throws Exception {
    String filepath = TestUtils.DATA_DIR + "gff/simfeatures.gff3";
    List<Track> tracks = trackLoader.load(new ResourceLocator(filepath), genome);
    assertEquals(1, tracks.size());
    FeatureTrack track = (FeatureTrack) tracks.get(0);

    assertEquals("notmeaningful", track.getName());

    List<Feature> features = track.getFeatures("chr1", 0, Integer.MAX_VALUE);
    assertEquals(2, features.size());

    IGVFeature feat0 = (IGVFeature) features.get(0);
    IGVFeature feat1 = (IGVFeature) features.get(1);

    assertEquals(707 - 1, feat0.getStart());
    assertEquals(943, feat0.getEnd());
    assertEquals(7563 - 1, feat1.getStart());
    assertEquals(7938, feat1.getEnd());
  }
Esempio n. 6
0
  @Test
  public void testLoadGFFAliasedChrs() throws Exception {
    String filepath = TestUtils.DATA_DIR + "gff/aliased.unsorted.gff";
    Genome genome =
        IgvTools.loadGenome(TestUtils.DATA_DIR + "genomes/hg18_truncated_aliased.genome");
    List<Track> tracks = trackLoader.load(new ResourceLocator(filepath), genome);
    assertEquals(1, tracks.size());
    FeatureTrack track = (FeatureTrack) tracks.get(0);

    assertEquals("aliased.unsorted.gff", track.getName());

    List<Feature> features = track.getFeatures("chr1", 0, Integer.MAX_VALUE);
    assertEquals(56, features.size());

    features = track.getFeatures("chr5", 0, Integer.MAX_VALUE);
    assertEquals(16, features.size());

    // Non-aliased
    features = track.getFeatures("NC_007072.3", 0, Integer.MAX_VALUE);
    assertEquals(30, features.size());
  }
Esempio n. 7
0
  /**
   * Test loading sample information file from a sql database, using a profile
   *
   * @throws Exception
   */
  @Test
  public void testLoadSampleInfoProfile() throws Exception {

    AttributeManager.getInstance().clearAllAttributes();
    String path = TestUtils.DATA_DIR + "sql/sampleinfo_brca_sif_profile.dbxml";

    int expectedTracks = 0;
    List<Track> tracks = trackLoader.load(new ResourceLocator(path), genome);
    assertEquals(expectedTracks, tracks.size());

    String[] attrNames =
        "TCGA_EXPERIMENT	TCGA_BATCH	TUMOR_NORMAL	BIRDSEED_GENDER	LEVEL2_NOISE	LEVEL3_SEGMENT_COUNT	PURITY	PLOIDY	DELTA	CANCER_DNA_FRACTION	SUBCLONAL_GENOME_FRACTION"
            .split("\\s+");
    Set<String> expAttrNames = new HashSet<String>(Arrays.asList(attrNames));
    List<String> actAttrNames = AttributeManager.getInstance().getAttributeNames();
    actAttrNames.remove("NAME");
    actAttrNames.remove("DATA TYPE");
    actAttrNames.remove("DATA FILE");
    assertEquals(actAttrNames.size(), expAttrNames.size());
    for (String attrName : actAttrNames) {
      assertTrue(expAttrNames.contains(attrName));
    }
  }