예제 #1
0
  @Override
  public void performOperation() throws OperationFailedException {

    BEDFile intervals = (BEDFile) this.getInputBufferForClass(BEDFile.class);
    BAMFile bam = (BAMFile) this.getInputBufferForClass(BAMFile.class);
    DOCMetrics metrics = (DOCMetrics) getOutputBufferForClass(DOCMetrics.class);

    try {
      intervals.buildIntervalsMap();

      CoverageCalculator covCalc = new CoverageCalculator(bam.getFile(), intervals, false);
      covCalc.setThreadCount(getPipelineOwner().getThreadCount());

      int[] depthHistogram = covCalc.computeOverallCoverage();

      // The depth histogram is an un-normalized raw counts of the number of bases with a certain
      // read depth
      // for instance, the 10th position in the list of the number of bases found with read depths =
      // 10
      double mean = CoverageCalculator.getMean(depthHistogram);
      double[] covs = CoverageCalculator.convertCountsToProportions(depthHistogram);

      int[] cutoffs = new int[] {1, 10, 15, 20, 25, 50, 100};
      double[] covAboveCutoffs = new double[cutoffs.length];
      for (int i = 0; i < covAboveCutoffs.length; i++) {
        covAboveCutoffs[i] = covs[cutoffs[i]];
      }

      metrics.setMeanCoverage(mean);
      metrics.setCoverageProportions(covs);
      metrics.setCutoffs(cutoffs);
      metrics.setFractionAboveCutoff(covAboveCutoffs);

      Logger.getLogger(Pipeline.primaryLoggerName)
          .info(getObjectLabel() + " Found mean depth : " + mean);

    } catch (IOException e) {
      e.printStackTrace();
      Logger.getLogger(Pipeline.primaryLoggerName)
          .warning(getObjectLabel() + " encountered IO Error : " + e.getLocalizedMessage());
      throw new OperationFailedException(
          "IO Error calculating coverages : " + e.getLocalizedMessage(), this);
    } catch (InterruptedException e) {
      e.printStackTrace();
      Logger.getLogger(Pipeline.primaryLoggerName)
          .warning(getObjectLabel() + " was interrupted: " + e.getLocalizedMessage());
      throw new OperationFailedException(
          "Interrupted calculating coverages : " + e.getLocalizedMessage(), this);
    }
  }
예제 #2
0
  protected void parseOptions() {
    FileBuffer inputBEDfb = this.getInputBufferForClass(BEDFile.class);
    if (inputBEDfb != null) {
      inputBED = (BEDFile) inputBEDfb;
      bedFileOpt = " -t " + inputBED.getAbsolutePath();
    } else {
      bedFileOpt = "";
    }

    List<FileBuffer> inputBAMBuffers = this.getAllInputBuffersForClass(BAMFile.class);
    for (FileBuffer bamBuffer : inputBAMBuffers) {
      inputBAMs = inputBAMs + " -b " + bamBuffer.getAbsolutePath();
    }

    if (extraOptions == null || extraOptions.equals("null")) {
      extraOptions = "";
    }
    inputBuffers = this.getAllInputBuffersForClass(BAMFile.class);
    refBuf = (ReferenceFile) this.getInputBufferForClass(ReferenceFile.class);
    outputVCF = (VCFFile) this.getOutputBufferForClass(VCFFile.class);
  }