package com.github.sparkcaller.preprocessing;

import com.github.sparkcaller.BaseGATKProgram;
import com.github.sparkcaller.Utils;
import org.apache.spark.api.java.function.Function;
import scala.Tuple2;

import java.io.File;
import java.util.ArrayList;

/*
 * Minimize the amount of mismatching bases across all reads.
 *
 * See:
 * https://www.broadinstitute.org/gatk/gatkdocs/org_broadinstitute_gatk_tools_walkers_indels_RealignerTargetCreator.php
 *
 * For more information.
 *
 */
public class IndelTargetCreator extends BaseGATKProgram implements Function<File, Tuple2<File, File>> {
    public IndelTargetCreator(String pathToReference, String extraArgsString, String coresPerNode) {
        super("RealignerTargetCreator", extraArgsString);
        setReference(pathToReference);
        addArgument("-nt", coresPerNode); // The target creator is better optimized for multiple data threads.
    }

    public Tuple2<File, File> call(File file) throws Exception {
        setInputFile(file.getPath());

        final String outputIntervalsFilename = Utils.removeExtenstion(file.getPath(), "bam") + "-target.intervals";
        File outputIntervalsFile = new File(outputIntervalsFilename);
        setOutputFile(outputIntervalsFile.getPath());

        executeProgram();
        return new Tuple2<File, File>(file, outputIntervalsFile);
   }
}

@@ -538,57 +538,11 @@
 gram
- implements Function%3CFile, Tuple2%3CFile, File%3E%3E
  %7B%0A
+
     
@@ -868,31 +868,26 @@
 lic 
-Tuple2%3CFile, File%3E call
+File createTargets
 (Fil
@@ -1237,37 +1237,8 @@
 turn
- new Tuple2%3CFile, File%3E(file,
  out
@@ -1253,17 +1253,16 @@
 valsFile
-)
 ;%0A   %7D%0A%7D

Make it easier to run the RealignerTargetCreator on a single file.