예제 #1
0
  protected void baseQualityScoreRecalibration(
      Context context,
      String region,
      ChromosomeRange r,
      PreprocessingTools tools,
      GATKTools gatk,
      String input,
      String output)
      throws InterruptedException, IOException, URISyntaxException {
    String table = tmpFileBase + ".table";

    // get snp database(s)
    String[] snpslocal = HalvadeFileUtils.downloadSites(context, taskId);
    String[] newKnownSites = new String[snpslocal.length];
    for (int i = 0; i < snpslocal.length; i++) {
      if (filterDBsnp) {
        newKnownSites[i] =
            tools.filterDBSnps(
                ref.replaceAll("fasta", "dict"), snpslocal[i], r, tmpFileBase, threads);
      } else {
        newKnownSites[i] = snpslocal[i];
      }
      if (newKnownSites[i].endsWith(".gz")) {
        newKnownSites[i] = HalvadeFileUtils.Unzip(newKnownSites[i]);
      }
    }

    // should be created automatically by GATK v3.0 or higher
    //        Logger.DEBUG("build bam index");
    //        context.setStatus("build bam index");
    //        tools.runBuildBamIndex(tmpFile1);
    Logger.DEBUG("run baseRecalibrator");
    context.setStatus("run baseRecalibrator");
    context.getCounter(HalvadeCounters.TOOLS_GATK).increment(1);
    gatk.runBaseRecalibrator(input, table, ref, newKnownSites, region);

    Logger.DEBUG("run printReads");
    context.setStatus("run printReads");
    context.getCounter(HalvadeCounters.TOOLS_GATK).increment(1);
    gatk.runPrintReads(input, output, ref, table, region);

    HalvadeFileUtils.removeLocalFile(keep, input, context, HalvadeCounters.FOUT_GATK_TMP);
    HalvadeFileUtils.removeLocalFile(keep, input.replaceAll(".bam", ".bai"));
    HalvadeFileUtils.removeLocalFile(keep, table, context, HalvadeCounters.FOUT_GATK_TMP);
    for (int i = 0; i < newKnownSites.length; i++) {
      if (filterDBsnp) {
        HalvadeFileUtils.removeLocalFile(
            keep, newKnownSites[i], context, HalvadeCounters.FOUT_GATK_TMP);
      }
    }
  }