Program: 13766
Project: 13766
Buggy source:
protected void PicardPreprocess(Context context,PreprocessingTools tools,SAMRecordIterator input,String output) throws InterruptedException, QualityException, IOException, URISyntaxException {
  outHeader=header.clone();
  outHeader.setSortOrder(SAMFileHeader.SortOrder.coordinate);
  String tmpOut1=tmpFileBase + "String_Node_Str";
  String tmpOut2=tmpFileBase + "String_Node_Str";
  String tmpOut3=tmpFileBase + "String_Node_Str";
  String fCounts=tmpFileBase + "String_Node_Str";
  String tmpMetrics=tmpFileBase + "String_Node_Str";
  SAMFileWriterFactory factory=new SAMFileWriterFactory();
  if (!inputIsBam)   outHeader.addReadGroup(bamrg);
  SAMFileWriter writer=factory.makeBAMWriter(outHeader,true,new File(tmpOut1));
  long startTime=System.currentTimeMillis();
  int count=0;
  SAMRecord sam;
  while (input.hasNext()) {
    sam=input.next();
    writer.addAlignment(sam);
    count++;
  }
  int reads=input.getCount();
  writer.close();
  context.getCounter(HalvadeCounters.IN_PREP_READS).increment(reads);
  long estimatedTime=System.currentTimeMillis() - startTime;
  context.getCounter(HalvadeCounters.TIME_HADOOP_SAMTOBAM).increment(estimatedTime);
  Logger.DEBUG("String_Node_Str" + count + "String_Node_Str"+ estimatedTime / 1000);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runCleanSam(tmpOut1,tmpOut2);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runMarkDuplicates(tmpOut2,tmpOut3,tmpMetrics);
  if (gff != null) {
    Logger.DEBUG("String_Node_Str");
    context.setStatus("String_Node_Str");
    tools.runFeatureCounts(gff,tmpOut3,fCounts);
    HalvadeFileUtils.uploadFileToHDFS(context,FileSystem.get(new URI(outputdir),context.getConfiguration()),fCounts,outputdir + context.getTaskAttemptID().toString() + "String_Node_Str");
    HalvadeFileUtils.uploadFileToHDFS(context,null,ref,tmp);
  }
  if (!inputIsBam) {
    Logger.DEBUG("String_Node_Str");
    context.setStatus("String_Node_Str");
    tools.runAddOrReplaceReadGroups(tmpOut3,output,RGID,RGLB,RGPL,RGPU,RGSM);
  }
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runBuildBamIndex(output);
  estimatedTime=System.currentTimeMillis() - startTime;
  Logger.DEBUG("String_Node_Str" + estimatedTime / 1000);
  HalvadeFileUtils.removeLocalFile(keep,tmpMetrics,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut1,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut2,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut3,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,htseq);
}

Fixed version (ground truth):
protected void PicardPreprocess(Context context,PreprocessingTools tools,SAMRecordIterator input,String output) throws InterruptedException, QualityException, IOException, URISyntaxException {
  outHeader=header.clone();
  outHeader.setSortOrder(SAMFileHeader.SortOrder.coordinate);
  String tmpOut1=tmpFileBase + "String_Node_Str";
  String tmpOut2=tmpFileBase + "String_Node_Str";
  String tmpOut3=tmpFileBase + "String_Node_Str";
  String fCounts=tmpFileBase + "String_Node_Str";
  String tmpMetrics=tmpFileBase + "String_Node_Str";
  SAMFileWriterFactory factory=new SAMFileWriterFactory();
  if (!inputIsBam)   outHeader.addReadGroup(bamrg);
  SAMFileWriter writer=factory.makeBAMWriter(outHeader,true,new File(tmpOut1));
  long startTime=System.currentTimeMillis();
  int count=0;
  SAMRecord sam;
  while (input.hasNext()) {
    sam=input.next();
    writer.addAlignment(sam);
    count++;
  }
  int reads=input.getCount();
  writer.close();
  context.getCounter(HalvadeCounters.IN_PREP_READS).increment(reads);
  long estimatedTime=System.currentTimeMillis() - startTime;
  context.getCounter(HalvadeCounters.TIME_HADOOP_SAMTOBAM).increment(estimatedTime);
  Logger.DEBUG("String_Node_Str" + count + "String_Node_Str"+ estimatedTime / 1000);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runCleanSam(tmpOut1,tmpOut2);
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runMarkDuplicates(tmpOut2,tmpOut3,tmpMetrics);
  if (gff != null) {
    Logger.DEBUG("String_Node_Str");
    context.setStatus("String_Node_Str");
    tools.runFeatureCounts(gff,tmpOut3,fCounts);
    HalvadeFileUtils.uploadFileToHDFS(context,FileSystem.get(new URI(outputdir),context.getConfiguration()),fCounts,outputdir + context.getTaskAttemptID().toString() + "String_Node_Str");
    HalvadeFileUtils.uploadFileToHDFS(context,null,ref,tmp);
  }
  if (!inputIsBam) {
    Logger.DEBUG("String_Node_Str");
    context.setStatus("String_Node_Str");
    tools.runAddOrReplaceReadGroups(tmpOut3,output,RGID,RGLB,RGPL,RGPU,RGSM);
  }
  Logger.DEBUG("String_Node_Str");
  context.setStatus("String_Node_Str");
  tools.runBuildBamIndex(output);
  estimatedTime=System.currentTimeMillis() - startTime;
  Logger.DEBUG("String_Node_Str" + estimatedTime / 1000);
  HalvadeFileUtils.removeLocalFile(keep,tmpMetrics,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut1,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut2,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,tmpOut3,context,HalvadeCounters.FOUT_GATK_TMP);
  HalvadeFileUtils.removeLocalFile(keep,fCounts);
}