Example #1
0
  private void loadVCF(ResourceLocator locator, List<Track> newTracks, Genome genome)
      throws IOException, TribbleIndexNotFoundException {

    TribbleFeatureSource src = TribbleFeatureSource.getFeatureSource(locator, genome);

    VCFHeader header = (VCFHeader) src.getHeader();

    // Test if the input VCF file contains methylation rate data:

    // This is determined by testing for the presence of two sample format fields: MR and GB, used
    // in the
    // rendering of methylation rate.
    // MR is the methylation rate on a scale of 0 to 100% and GB is the number of bases that pass
    // filter for the position. GB is needed to avoid displaying positions for which limited
    // coverage
    // prevents reliable estimation of methylation rate.
    boolean enableMethylationRateSupport =
        (header.getFormatHeaderLine("MR") != null && header.getFormatHeaderLine("GB") != null);

    List<String> allSamples = new ArrayList(header.getGenotypeSamples());

    VariantTrack t = new VariantTrack(locator, src, allSamples, enableMethylationRateSupport);

    // VCF tracks handle their own margin
    t.setMargin(0);
    newTracks.add(t);
  }
Example #2
0
  /**
   * Load the input file as a feature, mutation, or maf (multiple alignment) file.
   *
   * @param locator
   * @param newTracks
   */
  private void loadTribbleFile(ResourceLocator locator, List<Track> newTracks, Genome genome)
      throws IOException, TribbleIndexNotFoundException {

    String typeString = locator.getTypeString();

    // Mutation (mut, maf, vcf) files are handled special.  Check here, rather than depend on order
    // in giant case statement.
    if (MutationTrackLoader.isMutationAnnotationFile(locator)) {
      loadMutFile(locator, newTracks, genome); // Must be tried before generic "loadIndexed" below
    } else if (VariantTrack.isVCF(typeString)) {
      loadVCF(locator, newTracks, genome);
    } else {

      TribbleFeatureSource tribbleFeatureSource =
          TribbleFeatureSource.getFeatureSource(locator, genome);
      FeatureSource src =
          GFFFeatureSource.isGFF(locator.getPath())
              ? new GFFFeatureSource(tribbleFeatureSource)
              : tribbleFeatureSource;

      // Create feature source and track
      FeatureTrack t = new FeatureTrack(locator, src);
      t.setName(locator.getTrackName());
      // t.setRendererClass(BasicTribbleRenderer.class);

      // Set track properties from header
      Object header = tribbleFeatureSource.getHeader();
      if (header != null && header instanceof FeatureFileHeader) {
        FeatureFileHeader ffh = (FeatureFileHeader) header;
        if (ffh.getTrackType() != null) {
          t.setTrackType(ffh.getTrackType());
        }
        if (ffh.getTrackProperties() != null) {
          t.setProperties(ffh.getTrackProperties());
        }

        if (ffh.getTrackType() == TrackType.REPMASK) {
          t.setHeight(15);
        }
      }
      if (locator.getPath().contains(".narrowPeak")
          || locator.getPath().contains(".broadPeak")
          || locator.getPath().contains(".gappedPeak")) {
        t.setUseScore(true);
      }
      newTracks.add(t);
    }
  }
Example #3
0
    synchronized Iterator<Mutation> getFeatures(String trackKey, String chr, int start, int end)
        throws IOException {
      if (currentRange == null || !currentRange.contains(chr, start, end)) {
        Iterator<Feature> features = tribbleFeatureSource.getFeatures(chr, start, end);

        while (features.hasNext()) {
          Mutation feat = (Mutation) features.next();
          String thisKey = feat.getSampleId();
          List<Mutation> keyFeatures = featureMap.get(thisKey);
          if (keyFeatures == null) {
            keyFeatures = new ArrayList<Mutation>();
            featureMap.put(thisKey, keyFeatures);
          }
          keyFeatures.add(feat);
          currentRange = new Range(chr, start, end);
        }
      }
      List<Mutation> featureList = featureMap.get(trackKey);
      return featureList == null ? Collections.EMPTY_LIST.iterator() : featureList.iterator();
    }
Example #4
0
 public MutationDataManager(ResourceLocator locator, Genome genome)
     throws IOException, TribbleIndexNotFoundException {
   this.tribbleFeatureSource = TribbleFeatureSource.getFeatureSource(locator, genome);
   this.locator = locator;
 }