/**
   * Runs the variant program inside the Broad's OxoG container to produce a mini-BAM for a given
   * BAM.
   *
   * @param parent
   * @param bamType - The type of BAM file to use. Determines the name of the output file.
   * @param bamPath - The path to the input BAM file.
   * @param tumourBAMFileName - Name of the BAM file. Only used if bamType == BAMType.tumour.
   * @param aliquotID
   * @return
   */
  private Job doVariantBam(
      BAMType bamType, String bamPath, String tumourBAMFileName, String aliquotID, Job... parents) {
    Job runVariantbam;
    if (!this.skipVariantBam) {
      VariantBamJobGenerator variantBamJobGenerator =
          new VariantBamJobGenerator(
              this.JSONlocation, this.JSONrepoName, this.JSONfolderName, this.JSONfileName);
      variantBamJobGenerator.setGitMoveTestMode(this.gitMoveTestMode);
      variantBamJobGenerator.setIndelPadding(String.valueOf(this.indelPadding));
      variantBamJobGenerator.setSnvPadding(String.valueOf(this.snvPadding));
      variantBamJobGenerator.setSvPadding(String.valueOf(this.svPadding));
      variantBamJobGenerator.setGitMoveTestMode(this.gitMoveTestMode);

      variantBamJobGenerator.setAliquotID(aliquotID);
      variantBamJobGenerator.setSnvVcf(
          mergedVcfs.stream().filter(isSnv).findFirst().get().getFileName());
      variantBamJobGenerator.setSvVcf(
          mergedVcfs.stream().filter(isSv).findFirst().get().getFileName());
      variantBamJobGenerator.setIndelVcf(
          mergedVcfs.stream().filter(isIndel).findFirst().get().getFileName());

      UpdateBamForUpload<String, String, Boolean> updateFilesForUpload =
          (path, id, isLink) -> {
            if (id == null || id.trim().equals("")) {
              // only update the normalMinibamPath with the path to the actual BAM.
              // If you get a .bai file here, add it to filesForUpload,
              // but don't do anything else.
              // Also, if what was passed in has been indicated as a symlink, just add
              // to filesForUpload but do nothing else.
              if (path.endsWith(".bam") && !isLink) {
                this.normalMinibamPath = path;
              }
              this.filesForUpload.add(path);
            } else {
              for (TumourInfo tInfo : this.tumours) {
                if (tInfo.getAliquotID().equals(id)) {
                  // Set the tumour minibam path only to the BAM file.
                  // If you get a .bai file here, add it to filesForUpload,
                  // but don't do anything else.
                  // Also, if what was passed in has been indicated as a symlink, just add
                  // to filesForUpload but do nothing else.
                  if (path.endsWith(".bam") && !isLink) {
                    tInfo.setTumourMinibamPath(path);
                  }
                  filesForUpload.add(path);
                }
              }
            }
          };

      String bamName = (bamType == BAMType.normal ? this.normalBAMFileName : tumourBAMFileName);
      runVariantbam =
          variantBamJobGenerator.doVariantBam(
              this, bamType, bamName, bamPath, tumourBAMFileName, updateFilesForUpload, parents);
    } else {
      runVariantbam =
          this.getWorkflow()
              .createBashJob(
                  "run "
                      + bamType
                      + (bamType == BAMType.tumour ? "_" + aliquotID + "_" : "")
                      + " variantbam");
      Arrays.stream(parents).forEach(parent -> runVariantbam.addParent(parent));
    }
    return runVariantbam;
  }