Exemplo n.º 1
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.º 2
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);
    }
  }