Exemplo n.º 1
0
  /**
   * Load a rnai gene score file and create a datasource and track.
   *
   * <p>
   *
   * @param locator
   * @param newTracks
   */
  private void loadRNAiGeneScoreFile(
      ResourceLocator locator,
      List<Track> newTracks,
      RNAIGeneScoreParser.Type type,
      Genome genome) {

    RNAIGeneScoreParser parser = new RNAIGeneScoreParser(locator.getPath(), type, genome);

    Collection<RNAIDataSource> dataSources = parser.parse();
    String path = locator.getPath();
    for (RNAIDataSource ds : dataSources) {
      String name = ds.getName();
      String trackId = path + "_" + name;
      DataSourceTrack track = new DataSourceTrack(locator, trackId, name, ds);

      // Set attributes.  This "hack" is neccessary to register these attributes with the
      // attribute manager to get displayed.
      track.setAttributeValue("SCREEN", ds.getScreen());
      if ((ds.getCondition() != null) && (ds.getCondition().length() > 0)) {
        track.setAttributeValue("CONDITION", ds.getCondition());
      }
      track.setHeight(80);
      // track.setDataRange(new DataRange(-3, 0, 3));
      newTracks.add(track);
    }
  }
Exemplo n.º 2
0
  @Test
  public void testWigAndBigWig() throws Exception {
    String wigPath = TestUtils.DATA_DIR + "wig/test_fixedStep.wig";
    String bigWigPath = TestUtils.DATA_DIR + "wig/test_fixedStep.bigwig";
    List<Track> wigtracks = tstLoadFi(wigPath, 1, false);
    List<Track> bigWigtracks = tstLoadFi(bigWigPath, 1, false);

    String chr = "chr19";
    int start = 5930725;
    int end = 5930764;
    int zoom = 21;

    DataSourceTrack wigTrack = (DataSourceTrack) wigtracks.get(0);
    DataSourceTrack bigWigTrack = (DataSourceTrack) bigWigtracks.get(0);

    int trials = 10;

    for (int ii = 0; ii < trials; ii++) {
      int strt = start + ii;
      List<LocusScore> wigScores = wigTrack.getSummaryScores(chr, strt, end, zoom);
      List<LocusScore> bigWigScores = bigWigTrack.getSummaryScores(chr, strt, end, zoom);
      assertEquals(wigScores.size(), bigWigScores.size());
      int ind = 0;
      for (LocusScore ws : wigScores) {
        LocusScore bws = bigWigScores.get(ind);
        assertEquals(ws.getScore(), bws.getScore());
        ind++;
      }
    }
  }
Exemplo n.º 3
0
  private void loadIGVFile(ResourceLocator locator, List<Track> newTracks, Genome genome) {

    if (locator.isLocal()) {
      if (!checkSize(locator)) {
        return;
      }
    }

    String dsName = locator.getTrackName();
    IGVDataset ds = new IGVDataset(locator, genome);
    ds.setName(dsName);

    TrackProperties trackProperties = ds.getTrackProperties();
    String path = locator.getPath();
    TrackType type = ds.getType();
    for (String trackName : ds.getTrackNames()) {

      DatasetDataSource dataSource = new DatasetDataSource(trackName, ds, genome);
      String trackId = path + "_" + trackName;
      DataSourceTrack track = new DataSourceTrack(locator, trackId, trackName, dataSource);

      // track.setRendererClass(HeatmapRenderer.class);
      track.setTrackType(ds.getType());
      track.setProperties(trackProperties);

      if (type == TrackType.ALLELE_FREQUENCY) {
        track.setRendererClass(PointsRenderer.class);
        track.setHeight(40);
      }
      newTracks.add(track);
    }
  }
Exemplo n.º 4
0
  /**
   * Add the provided SegmentedDataSet to the list of tracks, set other relevant properties
   *
   * @param locator
   * @param newTracks
   * @param genome
   * @param ds
   */
  private void loadSegTrack(
      ResourceLocator locator, List<Track> newTracks, Genome genome, SegmentedDataSet ds) {
    String path = locator.getPath();

    TrackProperties props = null;
    if (ds instanceof SegmentedAsciiDataSet) {
      props = ((SegmentedAsciiDataSet) ds).getTrackProperties();
    }

    // The "freq" track.  TODO - make this optional
    if ((ds.getType() == TrackType.COPY_NUMBER || ds.getType() == TrackType.CNV)
        && ds.getSampleNames().size() > 1) {
      FreqData fd = new FreqData(ds, genome);
      String freqTrackId = path;
      String freqTrackName = "CNV Summary";
      CNFreqTrack freqTrack = new CNFreqTrack(locator, freqTrackId, freqTrackName, fd);
      newTracks.add(freqTrack);
    }

    for (String trackName : ds.getSampleNames()) {
      String trackId = path + "_" + trackName;
      SegmentedDataSource dataSource = new SegmentedDataSource(trackName, ds);
      DataSourceTrack track = new DataSourceTrack(locator, trackId, trackName, dataSource);
      track.setRendererClass(HeatmapRenderer.class);
      track.setTrackType(ds.getType());

      if (props != null) {
        track.setProperties(props);
      }

      newTracks.add(track);
    }
  }
  @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());
  }
Exemplo n.º 6
0
  public void loadTDFFile(ResourceLocator locator, List<Track> newTracks, Genome genome) {

    log.debug("Loading TDF file " + locator.getPath());
    TDFReader reader = TDFReader.getReader(locator);
    TrackType type = reader.getTrackType();

    TrackProperties props = null;
    String trackLine = reader.getTrackLine();
    if (trackLine != null && trackLine.length() > 0) {
      props = new TrackProperties();
      ParsingUtils.parseTrackLine(trackLine, props);
    }

    // In case of conflict between the resource locator display name and the track properties name,
    // use the resource locator
    String name = locator.getName();
    if (name != null && props != null) {
      props.setName(name);
    }

    if (name == null) {
      name = props == null ? locator.getTrackName() : props.getName();
    }

    int trackNumber = 0;
    String path = locator.getPath();
    boolean multiTrack = reader.getTrackNames().length > 1;

    for (String heading : reader.getTrackNames()) {

      String trackId = multiTrack ? path + "_" + heading : path;
      String trackName = multiTrack ? heading : name;
      final DataSource dataSource =
          locator.getPath().endsWith(".counts")
              ? new GobyCountArchiveDataSource(locator)
              : new TDFDataSource(reader, trackNumber, heading, genome);
      DataSourceTrack track = new DataSourceTrack(locator, trackId, trackName, dataSource);

      String displayName = (name == null || multiTrack) ? heading : name;
      track.setName(displayName);
      track.setTrackType(type);
      if (props != null) {
        track.setProperties(props);
      }
      newTracks.add(track);
      trackNumber++;
    }
  }
Exemplo n.º 7
0
  private void loadWigFile(ResourceLocator locator, List<Track> newTracks, Genome genome) {

    if (locator.isLocal()) {
      if (!checkSize(locator)) {
        return;
      }
    }

    WiggleDataset ds = (new WiggleParser(locator, genome)).parse();
    TrackProperties props = ds.getTrackProperties();

    // In case of conflict between the resource locator display name and the track properties name,
    // use the resource locator
    String name = props == null ? null : props.getName();
    String label = locator.getName();
    if (name == null) {
      name = locator.getFileName();
    } else if (label != null) {
      props.setName(label); // erase name rom track properties
    }

    String path = locator.getPath();
    boolean multiTrack = ds.getTrackNames().length > 1;

    for (String heading : ds.getTrackNames()) {

      String trackId = multiTrack ? path + "_" + heading : path;
      String trackName = multiTrack ? heading : name;

      DatasetDataSource dataSource = new DatasetDataSource(trackId, ds, genome);

      DataSourceTrack track = new DataSourceTrack(locator, trackId, trackName, dataSource);

      String displayName = (label == null || multiTrack) ? heading : label;
      track.setName(displayName);
      track.setProperties(props);

      track.setTrackType(ds.getType());

      if (ds.getType() == TrackType.EXPR) {
        track.setWindowFunction(WindowFunction.none);
      }

      newTracks.add(track);
    }
  }
Exemplo n.º 8
0
  private void loadRnaiGctFile(ResourceLocator locator, List<Track> newTracks, Genome genome) {

    RNAIGCTDatasetParser parser = new RNAIGCTDatasetParser(locator, genome);

    Collection<RNAIDataSource> dataSources = parser.parse();
    if (dataSources != null) {
      String path = locator.getPath();
      for (RNAIDataSource ds : dataSources) {
        String trackId = path + "_" + ds.getName();
        DataSourceTrack track = new DataSourceTrack(locator, trackId, ds.getName(), ds);

        // Set attributes.
        track.setAttributeValue("SCREEN", ds.getScreen());
        track.setHeight(80);
        newTracks.add(track);
      }
    }
  }
  @Test
  public void testLoadCombinedDataSourceSession() throws Exception {
    String sessionpath = TestUtils.DATA_DIR + "sessions/subtypes_wdiff.xml";
    rewriteRestoreSession(sessionpath);

    String combPart0 = "TRIBE_p_TCGAaffx_B1_2_GBM_Nsp_GenomeWideSNP_6_E11_155884";
    String combPart1 = "TRIGS_p_TCGAaffxB5_sty_GenomeWideSNP_6_D05_223156";

    DataTrack track0 =
        Iterables.find(IGV.getInstance().getDataTracks(), new ContIdPredicate(combPart0));
    DataTrack track1 =
        Iterables.find(IGV.getInstance().getDataTracks(), new ContIdPredicate(combPart1));

    DataSourceTrack combTrack =
        (DataSourceTrack)
            Iterables.find(
                IGV.getInstance().getDataTracks(),
                new ContIdPredicate(new String[] {combPart0, combPart1}));

    assertTrue(combTrack.getRenderer() instanceof BarChartRenderer);
    assertEquals("Difference", combTrack.getName());

    String chr = "chr1";
    int start = 0;
    int end = 1000;

    LocusScore sumScore0 = track0.getSummaryScores(chr, start, end, 0).get(0);
    LocusScore sumScore1 = track1.getSummaryScores(chr, start, end, 0).get(0);
    LocusScore sumScoreComb = combTrack.getSummaryScores(chr, start, end, 0).get(0);

    assertEquals(sumScore0.getStart(), sumScore1.getStart());
    assertEquals(sumScore0.getStart(), sumScoreComb.getStart());
    assertEquals(sumScore1.getEnd(), sumScoreComb.getEnd());

    assertEquals(sumScore0.getScore() - sumScore1.getScore(), sumScoreComb.getScore(), 1e-10);
  }