nus-yam/ex-repair huggingface dataset:
Program: 30621
Project: 30621
Buggy source:
/** 
 * Sets the state of this tile's processing.
 */
public void setState(final TileProcessingState state){
  this.state=state;
}

Fixed version (ground truth):
/** 
 * Sets the state of this tile's processing.
 */
public synchronized void setState(final TileProcessingState state){
  this.state=state;
}
Program: 30622
Project: 30622
Buggy source:
/** 
 * Returns true if this aggregator has not completed its work.  Specifically, returns false iff any tile's barcode data yas not yet been written.
 * @return True if more work remains to be done, false otherwise
 */
public boolean isWorkCompleted(){
  for (  final Map.Entry<Tile,TileProcessingRecord> entry : this.tileRecords.entrySet()) {
    final TileProcessingRecord tileProcessingRecord=entry.getValue();
    if (tileProcessingRecord.getState() != TileProcessingState.DONE_READING) {
      return false;
    }
 else {
      for (      final TileBarcodeProcessingState barcodeProcessingState : tileProcessingRecord.barcodeToProcessingState.values()) {
        if (barcodeProcessingState != TileBarcodeProcessingState.WRITTEN) {
          return false;
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns true if this aggregator has not completed its work.  Specifically, returns false iff any tile's barcode data yas not yet been written.
 * @return True if more work remains to be done, false otherwise
 */
public boolean isWorkCompleted(){
  for (  final Map.Entry<Tile,TileProcessingRecord> entry : this.tileRecords.entrySet()) {
    final TileProcessingRecord tileProcessingRecord=entry.getValue();
    if (tileProcessingRecord.getState() != TileProcessingState.DONE_READING) {
      log.debug(String.format("String_Node_Str",entry.getKey().getNumber()));
      return false;
    }
 else {
      for (      final Map.Entry<String,TileBarcodeProcessingState> barcodeStateEntry : tileProcessingRecord.getBarcodeProcessingStates().entrySet()) {
        TileBarcodeProcessingState barcodeProcessingState=barcodeStateEntry.getValue();
        if (barcodeProcessingState != TileBarcodeProcessingState.WRITTEN) {
          log.debug(String.format("String_Node_Str",entry.getKey().getNumber(),barcodeStateEntry.getKey(),barcodeProcessingState));
          return false;
        }
      }
    }
  }
  log.info("String_Node_Str");
  return true;
}
Program: 30624
Project: 30624
Buggy source:
/** 
 * Parses a String into a double. 
 */
public double parseDouble(String value){
  if ("String_Node_Str".equals(value))   return Double.NaN;
 else   return Double.parseDouble(value);
}

Fixed version (ground truth):
/** 
 * Parses a String into a double. 
 */
public double parseDouble(String value){
  if ("String_Node_Str".equals(value) || "String_Node_Str".equals(value))   return Double.NaN;
 else   return Double.parseDouble(value);
}
Program: 30625
Project: 30625
Buggy source:
/** 
 * Parses a String into a float. 
 */
public float parseFloat(String value){
  if ("String_Node_Str".equals(value))   return Float.NaN;
 else   return Float.parseFloat(value);
}

Fixed version (ground truth):
/** 
 * Parses a String into a float. 
 */
public float parseFloat(String value){
  if ("String_Node_Str".equals(value) || "String_Node_Str".equals(value))   return Float.NaN;
 else   return Float.parseFloat(value);
}
Program: 30626
Project: 30626
Buggy source:
private void doTileProcessing(){
  FileChannelJDKBugWorkAround.doBugWorkAround();
  final List<Tile> tiles=new ArrayList<Tile>();
  for (  final Integer tileNumber : this.tiles) {
    tiles.add(new Tile(tileNumber));
  }
  final TileReadAggregator tileReadAggregator=new TileReadAggregator(tiles);
  tileReadAggregator.submit();
  try {
    tileReadAggregator.awaitWorkComplete();
  }
 catch (  InterruptedException e) {
    log.error(e,"String_Node_Str");
    tileReadAggregator.shutdown();
  }
}

Fixed version (ground truth):
private void doTileProcessing(){
  FileChannelJDKBugWorkAround.doBugWorkAround();
  final List<Tile> tiles=new ArrayList<Tile>();
  for (  final Integer tileNumber : this.tiles) {
    tiles.add(new Tile(tileNumber));
  }
  final TileReadAggregator tileReadAggregator=new TileReadAggregator(tiles);
  tileReadAggregator.submit();
  try {
    tileReadAggregator.awaitWorkComplete();
  }
 catch (  InterruptedException e) {
    log.error(e,"String_Node_Str");
    tileReadAggregator.shutdown();
    throw new PicardException("String_Node_Str");
  }
}
Program: 30627
Project: 30627
Buggy source:
/** 
 * Execute the tile aggregator's work.  Creates a thread pool to read data from tiles and write them to file. Invoke this method only once.
 * @throws IllegalStateException If submit was called more than once.
 */
public void submit(){
  if (!this.submitted.compareAndSet(false,true)) {
    throw new IllegalStateException("String_Node_Str");
  }
  this.parentThread=Thread.currentThread();
  int priority=0;
  for (  final Tile tile : this.tileRecords.keySet()) {
    final TileReader reader=new TileReader(tile,this,this.tileRecords.get(tile));
    this.prioritizingThreadPool.execute(new PriorityRunnable(--priority){
      @Override public void run(){
        reader.process();
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * Execute the tile aggregator's work.  Creates a thread pool to read data from tiles and write them to file. Invoke this method only once.
 * @throws IllegalStateException If submit was called more than once.
 */
public void submit(){
  if (!this.submitted.compareAndSet(false,true)) {
    throw new IllegalStateException("String_Node_Str");
  }
  this.parentThread=Thread.currentThread();
  int priority=0;
  for (  final Tile tile : this.tileRecords.keySet()) {
    final TileReader reader=new TileReader(tile,this,this.tileRecords.get(tile));
    this.prioritizingThreadPool.execute(new PriorityRunnable(--priority){
      @Override public void run(){
        try {
          reader.process();
        }
 catch (        RuntimeException e) {
          parentThread.interrupt();
          throw e;
        }
catch (        Error e) {
          parentThread.interrupt();
          throw e;
        }
      }
    }
);
  }
}
Program: 30628
Project: 30628
Buggy source:
private void doTileProcessing(){
  FileChannelJDKBugWorkAround.doBugWorkAround();
  final List<Tile> tiles=new ArrayList<Tile>();
  for (  final Integer tileNumber : this.tiles) {
    tiles.add(new Tile(tileNumber));
  }
  final TileReadAggregator tileReadAggregator=new TileReadAggregator(tiles);
  tileReadAggregator.submit();
  try {
    tileReadAggregator.awaitWorkComplete();
  }
 catch (  InterruptedException e) {
    log.error(e,"String_Node_Str");
    tileReadAggregator.shutdown();
    throw new PicardException(String.format("String_Node_Str",e.getMessage()));
  }
}

Fixed version (ground truth):
private void doTileProcessing(){
  FileChannelJDKBugWorkAround.doBugWorkAround();
  final List<Tile> tiles=new ArrayList<Tile>();
  for (  final Integer tileNumber : this.tiles) {
    tiles.add(new Tile(tileNumber));
  }
  final TileReadAggregator tileReadAggregator=new TileReadAggregator(tiles);
  tileReadAggregator.submit();
  try {
    tileReadAggregator.awaitWorkComplete();
  }
 catch (  InterruptedException e) {
    log.error(e,"String_Node_Str");
    tileReadAggregator.shutdown();
  }
}
Program: 30632
Project: 30632
Buggy source:
@Override protected void setup(final SAMFileHeader header,final File samFile){
  if (CHART_OUTPUT != null)   IoUtil.assertFileIsWritable(CHART_OUTPUT);
  final OverlapDetector<Gene> geneOverlapDetector=GeneAnnotationReader.loadRefFlat(REF_FLAT,header.getSequenceDictionary());
  LOG.info("String_Node_Str" + geneOverlapDetector.getAll().size() + "String_Node_Str");
  final Long ribosomalBasesInitialValue=RIBOSOMAL_INTERVALS != null ? 0L : null;
  final OverlapDetector<Interval> ribosomalSequenceOverlapDetector=MultiLevelRnaSeqMetricsCollector.makeOverlapDetector(samFile,header,RIBOSOMAL_INTERVALS);
  final HashSet<Integer> ignoredSequenceIndices=MultiLevelRnaSeqMetricsCollector.makeIgnoredSequenceIndicesSet(header,IGNORE_SEQUENCE);
  collector=new MultiLevelRnaSeqMetricsCollector(METRIC_ACCUMULATION_LEVEL,header.getReadGroups(),ribosomalBasesInitialValue,geneOverlapDetector,ribosomalSequenceOverlapDetector,ignoredSequenceIndices,MINIMUM_LENGTH,STRAND_SPECIFICITY,RRNA_FRAGMENT_PERCENTAGE);
}

Fixed version (ground truth):
@Override protected void setup(final SAMFileHeader header,final File samFile){
  if (CHART_OUTPUT != null)   IoUtil.assertFileIsWritable(CHART_OUTPUT);
  final OverlapDetector<Gene> geneOverlapDetector=GeneAnnotationReader.loadRefFlat(REF_FLAT,header.getSequenceDictionary());
  LOG.info("String_Node_Str" + geneOverlapDetector.getAll().size() + "String_Node_Str");
  final Long ribosomalBasesInitialValue=RIBOSOMAL_INTERVALS != null ? 0L : null;
  final OverlapDetector<Interval> ribosomalSequenceOverlapDetector=RnaSeqMetricsCollector.makeOverlapDetector(samFile,header,RIBOSOMAL_INTERVALS);
  final HashSet<Integer> ignoredSequenceIndices=RnaSeqMetricsCollector.makeIgnoredSequenceIndicesSet(header,IGNORE_SEQUENCE);
  collector=new RnaSeqMetricsCollector(METRIC_ACCUMULATION_LEVEL,header.getReadGroups(),ribosomalBasesInitialValue,geneOverlapDetector,ribosomalSequenceOverlapDetector,ignoredSequenceIndices,MINIMUM_LENGTH,STRAND_SPECIFICITY,RRNA_FRAGMENT_PERCENTAGE);
}
Program: 30633
Project: 30633
Buggy source:
private int[] removeNonexistantCycles(final int[] cycles){
  if (lazyDetectedCyclesSet == null) {
    lazyDetectedCyclesSet=new TreeSet<Integer>();
    for (    final Integer cycle : detectedCycles) {
      lazyDetectedCyclesSet.add(cycle);
    }
  }
  final TreeSet<Integer> inputCyclesSet=new TreeSet<Integer>();
  for (  final Integer inputCycle : cycles) {
    inputCyclesSet.add(inputCycle);
  }
  final int[] outputCycles;
  inputCyclesSet.retainAll(lazyDetectedCyclesSet);
  outputCycles=new int[inputCyclesSet.size()];
  int i=0;
  for (  final Integer element : inputCyclesSet) {
    outputCycles[i++]=element;
  }
  return outputCycles;
}

Fixed version (ground truth):
private int[] removeNonexistantCycles(final int[] cycles){
  final TreeSet<Integer> detectedCyclesSet=new TreeSet<Integer>();
  for (  final Integer cycle : detectedCycles) {
    detectedCyclesSet.add(cycle);
  }
  final TreeSet<Integer> inputCyclesSet=new TreeSet<Integer>();
  for (  final Integer inputCycle : cycles) {
    inputCyclesSet.add(inputCycle);
  }
  final int[] outputCycles;
  inputCyclesSet.retainAll(detectedCyclesSet);
  outputCycles=new int[inputCyclesSet.size()];
  int i=0;
  for (  final Integer element : inputCyclesSet) {
    outputCycles[i++]=element;
  }
  return outputCycles;
}
Program: 30634
Project: 30634
Buggy source:
/** 
 * Compute SAMRecord insert size
 * @param firstEnd
 * @param secondEnd
 * @return note that when storing insert size on the secondEnd, the return value must be negated.
 */
public static int computeInsertSize(final SAMRecord firstEnd,final SAMRecord secondEnd){
  if (firstEnd.getReadUnmappedFlag() || secondEnd.getReadUnmappedFlag()) {
    return 0;
  }
  if (!firstEnd.getReferenceName().equals(secondEnd.getReferenceName())) {
    return 0;
  }
  int firstEnd5PrimePosition=firstEnd.getReadNegativeStrandFlag() ? firstEnd.getAlignmentEnd() : firstEnd.getAlignmentStart();
  int secondEnd5PrimePosition=secondEnd.getReadNegativeStrandFlag() ? secondEnd.getAlignmentEnd() : secondEnd.getAlignmentStart();
  return CoordMath.getLength(firstEnd5PrimePosition,secondEnd5PrimePosition);
}

Fixed version (ground truth):
/** 
 * Compute SAMRecord insert size
 * @param firstEnd
 * @param secondEnd
 * @return note that when storing insert size on the secondEnd, the return value must be negated.
 */
public static int computeInsertSize(final SAMRecord firstEnd,final SAMRecord secondEnd){
  if (firstEnd.getReadUnmappedFlag() || secondEnd.getReadUnmappedFlag()) {
    return 0;
  }
  if (!firstEnd.getReferenceName().equals(secondEnd.getReferenceName())) {
    return 0;
  }
  final int firstEnd5PrimePosition=firstEnd.getReadNegativeStrandFlag() ? firstEnd.getAlignmentEnd() : firstEnd.getAlignmentStart();
  final int secondEnd5PrimePosition=secondEnd.getReadNegativeStrandFlag() ? secondEnd.getAlignmentEnd() : secondEnd.getAlignmentStart();
  final int adjustment=(secondEnd5PrimePosition >= firstEnd5PrimePosition) ? +1 : -1;
  return secondEnd5PrimePosition - firstEnd5PrimePosition + adjustment;
}
Program: 30636
Project: 30636
Buggy source:
private void collectReadData(final SAMRecord record,final ReferenceSequence ref){
  metrics.TOTAL_READS++;
  readLengthHistogram.increment(record.getReadBases().length);
  if (!record.getReadFailsVendorQualityCheckFlag()) {
    metrics.PF_READS++;
    if (isNoiseRead(record)) {
      metrics.PF_NOISE_READS++;
    }
 else     if (record.getReadUnmappedFlag()) {
      final byte[] readBases=record.getReadBases();
      if (!(record instanceof BAMRecord))       StringUtil.toUpperCase(readBases);
      if (isAdapterSequence(readBases)) {
        this.adapterReads++;
      }
    }
 else {
      if (doRefMetrics) {
        metrics.PF_READS_ALIGNED++;
        if (!record.getReadNegativeStrandFlag()) {
          numPositiveStrand++;
        }
        if (record.getReadPairedFlag() && !record.getMateUnmappedFlag()) {
          metrics.READS_ALIGNED_IN_PAIRS++;
          final Integer mateMq=record.getIntegerAttribute("String_Node_Str");
          if (mateMq == null || mateMq >= MAPPING_QUALITY_THRESHOLD && record.getMappingQuality() >= MAPPING_QUALITY_THRESHOLD) {
            ++this.chimerasDenominator;
            if (Math.abs(record.getInferredInsertSize()) > MAX_INSERT_SIZE || !record.getReferenceIndex().equals(record.getMateReferenceIndex())) {
              ++this.chimeras;
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void collectReadData(final SAMRecord record,final ReferenceSequence ref){
  metrics.TOTAL_READS++;
  readLengthHistogram.increment(record.getReadBases().length);
  if (!record.getReadFailsVendorQualityCheckFlag()) {
    metrics.PF_READS++;
    if (isNoiseRead(record))     metrics.PF_NOISE_READS++;
    if (record.getReadUnmappedFlag()) {
      final byte[] readBases=record.getReadBases();
      if (!(record instanceof BAMRecord))       StringUtil.toUpperCase(readBases);
      if (isAdapterSequence(readBases)) {
        this.adapterReads++;
      }
    }
 else     if (doRefMetrics) {
      metrics.PF_READS_ALIGNED++;
      if (!record.getReadNegativeStrandFlag())       numPositiveStrand++;
      if (record.getReadPairedFlag() && !record.getMateUnmappedFlag()) {
        metrics.READS_ALIGNED_IN_PAIRS++;
        final Integer mateMq=record.getIntegerAttribute("String_Node_Str");
        if (mateMq == null || mateMq >= MAPPING_QUALITY_THRESHOLD && record.getMappingQuality() >= MAPPING_QUALITY_THRESHOLD) {
          ++this.chimerasDenominator;
          if (Math.abs(record.getInferredInsertSize()) > MAX_INSERT_SIZE || !record.getReferenceIndex().equals(record.getMateReferenceIndex())) {
            ++this.chimeras;
          }
        }
      }
    }
  }
}
Program: 30637
Project: 30637
Buggy source:
/** 
 * Gets the pair of writers for a given read group or, if we are not sorting by read group, just returns the single pair of writers.
 */
private Map<SAMReadGroupRecord,List<FastqWriter>> getWriters(final List<SAMReadGroupRecord> samReadGroupRecords,final FastqWriterFactory factory){
  final Map<SAMReadGroupRecord,List<FastqWriter>> writerMap=new HashMap<SAMReadGroupRecord,List<FastqWriter>>(0);
  for (  final SAMReadGroupRecord rg : samReadGroupRecords) {
    final List<FastqWriter> fqw=new ArrayList<FastqWriter>();
    if (!OUTPUT_PER_RG) {
      if (writerMap.isEmpty()) {
        IoUtil.assertFileIsWritable(FASTQ);
        IoUtil.openFileForWriting(FASTQ);
        fqw.add(factory.newWriter(FASTQ));
        if (SECOND_END_FASTQ != null) {
          IoUtil.assertFileIsWritable(SECOND_END_FASTQ);
          IoUtil.openFileForWriting(SECOND_END_FASTQ);
          fqw.add(factory.newWriter(SECOND_END_FASTQ));
        }
        writerMap.put(rg,fqw);
      }
 else {
        writerMap.put(rg,writerMap.values().iterator().next());
      }
    }
 else {
      fqw.add(factory.newWriter(makeReadGroupFile(rg,"String_Node_Str")));
      writerMap.put(rg,fqw);
    }
  }
  return writerMap;
}

Fixed version (ground truth):
/** 
 * Gets the pair of writers for a given read group or, if we are not sorting by read group, just returns the single pair of writers.
 */
private Map<SAMReadGroupRecord,List<FastqWriter>> getWriters(final List<SAMReadGroupRecord> samReadGroupRecords,final FastqWriterFactory factory){
  final Map<SAMReadGroupRecord,List<FastqWriter>> writerMap=new HashMap<SAMReadGroupRecord,List<FastqWriter>>();
  for (  final SAMReadGroupRecord rg : samReadGroupRecords) {
    final List<FastqWriter> fqw=new ArrayList<FastqWriter>();
    if (!OUTPUT_PER_RG) {
      if (writerMap.isEmpty()) {
        IoUtil.assertFileIsWritable(FASTQ);
        IoUtil.openFileForWriting(FASTQ);
        fqw.add(factory.newWriter(FASTQ));
        if (SECOND_END_FASTQ != null) {
          IoUtil.assertFileIsWritable(SECOND_END_FASTQ);
          IoUtil.openFileForWriting(SECOND_END_FASTQ);
          fqw.add(factory.newWriter(SECOND_END_FASTQ));
        }
        writerMap.put(rg,fqw);
      }
 else {
        writerMap.put(rg,writerMap.values().iterator().next());
      }
    }
 else {
      fqw.add(factory.newWriter(makeReadGroupFile(rg,"String_Node_Str")));
      writerMap.put(rg,fqw);
    }
  }
  return writerMap;
}
Program: 30639
Project: 30639
Buggy source:
/** 
 * Compute SAMRecord insert size
 * @param firstEnd
 * @param secondEnd
 * @return note that when storing insert size on the secondEnd, the return value must be negated.
 */
public static int computeInsertSize(final SAMRecord firstEnd,final SAMRecord secondEnd){
  if (firstEnd.getReadUnmappedFlag() || secondEnd.getReadUnmappedFlag()) {
    return 0;
  }
  if (!firstEnd.getReferenceName().equals(secondEnd.getReferenceName())) {
    return 0;
  }
  int firstEnd5PrimePosition=firstEnd.getReadNegativeStrandFlag() ? firstEnd.getAlignmentEnd() : firstEnd.getAlignmentStart();
  int secondEnd5PrimePosition=secondEnd.getReadNegativeStrandFlag() ? secondEnd.getAlignmentEnd() : secondEnd.getAlignmentStart();
  return secondEnd5PrimePosition - firstEnd5PrimePosition;
}

Fixed version (ground truth):
/** 
 * Compute SAMRecord insert size
 * @param firstEnd
 * @param secondEnd
 * @return note that when storing insert size on the secondEnd, the return value must be negated.
 */
public static int computeInsertSize(final SAMRecord firstEnd,final SAMRecord secondEnd){
  if (firstEnd.getReadUnmappedFlag() || secondEnd.getReadUnmappedFlag()) {
    return 0;
  }
  if (!firstEnd.getReferenceName().equals(secondEnd.getReferenceName())) {
    return 0;
  }
  int firstEnd5PrimePosition=firstEnd.getReadNegativeStrandFlag() ? firstEnd.getAlignmentEnd() : firstEnd.getAlignmentStart();
  int secondEnd5PrimePosition=secondEnd.getReadNegativeStrandFlag() ? secondEnd.getAlignmentEnd() : secondEnd.getAlignmentStart();
  return CoordMath.getLength(firstEnd5PrimePosition,secondEnd5PrimePosition);
}
Program: 30643
Project: 30643
Buggy source:
public void run(){
  try {
    long i=0;
    SAMRecord rec=null;
    while ((rec=queue.poll(15,TimeUnit.SECONDS)) != null) {
      out.addAlignment(rec);
      if (++i % PROGRESS_INTERVAL == 0)       log.info(i + "String_Node_Str");
    }
    consumerSuccceeded.set(true);
  }
 catch (  InterruptedException ie) {
    throw new PicardException("String_Node_Str",ie);
  }
}

Fixed version (ground truth):
public void run(){
  try {
    long i=0;
    while (!producerSuccceeded.get()) {
      SAMRecord rec=queue.poll(15,TimeUnit.SECONDS);
      if (rec != null) {
        out.addAlignment(rec);
        if (++i % PROGRESS_INTERVAL == 0)         log.info(i + "String_Node_Str");
      }
    }
    consumerSuccceeded.set(true);
  }
 catch (  InterruptedException ie) {
    throw new PicardException("String_Node_Str",ie);
  }
}
Program: 30645
Project: 30645
Buggy source:
/** 
 * Reads a whole line. A line is considered to be terminated by a line feed ('\n')
 * @return  A String containing the contents of the line, excluding the line terminatingcharacter, or null if the end of the stream has been reached
 * @exception IOException  If an I/O error occurs
 */
public String readLine() throws IOException {
  int available=available();
  if (available == 0) {
    return null;
  }
  buf.setLength(0);
  boolean done=false;
  while (!done) {
    int linetmpPos=mCurrentOffset;
    int bCnt=0;
    while ((available-- > 0)) {
      final byte c=mCurrentBlock[linetmpPos++];
      if (c == eol) {
        done=true;
        break;
      }
      ++bCnt;
    }
    if (mCurrentOffset < linetmpPos) {
      buf.append(new String(mCurrentBlock,mCurrentOffset,bCnt));
      mCurrentOffset=linetmpPos;
    }
    available=available();
    if (available == 0) {
      done=true;
    }
  }
  return buf.toString();
}

Fixed version (ground truth):
/** 
 * Reads a whole line. A line is considered to be terminated by either a line feed ('\n'),  carriage return ('\r') or carriage return followed by a line feed ("\r\n").
 * @return  A String containing the contents of the line, excluding the line terminatingcharacter, or null if the end of the stream has been reached
 * @exception IOException  If an I/O error occurs
 * @
 */
public String readLine() throws IOException {
  int available=available();
  if (available == 0) {
    return null;
  }
  buf.reset();
  boolean done=false;
  boolean foundCr=false;
  while (!done) {
    int linetmpPos=mCurrentOffset;
    int bCnt=0;
    while ((available-- > 0)) {
      final byte c=mCurrentBlock[linetmpPos++];
      if (c == eol) {
        done=true;
        break;
      }
 else       if (foundCr) {
        --linetmpPos;
        done=true;
        break;
      }
 else       if (c == eolCr) {
        foundCr=true;
        continue;
      }
      ++bCnt;
    }
    if (mCurrentOffset < linetmpPos) {
      buf.write(mCurrentBlock,mCurrentOffset,bCnt);
      mCurrentOffset=linetmpPos;
    }
    available=available();
    if (available == 0) {
      done=true;
    }
  }
  return buf.toString();
}
Program: 30647
Project: 30647
Buggy source:
public SnappyLoader(final boolean verbose){
  Constructor<InputStream> inputStreamCtor=null;
  Constructor<OutputStream> outputStreamCtor=null;
  if (java.lang.Boolean.valueOf(System.getProperty("String_Node_Str","String_Node_Str"))) {
    System.err.println("String_Node_Str");
  }
 else {
    try {
      final Class<InputStream> snappyInputStreamClass=(Class<InputStream>)Class.forName("String_Node_Str");
      final Class<OutputStream> snappyOutputStreamClass=(Class<OutputStream>)Class.forName("String_Node_Str");
      inputStreamCtor=snappyInputStreamClass.getConstructor(InputStream.class);
      outputStreamCtor=snappyOutputStreamClass.getConstructor(OutputStream.class);
    }
 catch (    NoSuchMethodException e) {
    }
catch (    ClassNotFoundException e) {
    }
  }
  SnappyInputStreamCtor=inputStreamCtor;
  SnappyOutputStreamCtor=outputStreamCtor;
  if (SnappyInputStreamCtor != null && SnappyOutputStreamCtor != null) {
    if (!LoadSnappy.load()) {
      if (verbose)       System.err.println("String_Node_Str");
      SnappyAvailable=false;
    }
 else {
      SnappyAvailable=true;
      if (verbose)       System.err.println("String_Node_Str");
    }
  }
 else {
    SnappyAvailable=false;
    if (verbose)     System.err.println("String_Node_Str");
  }
}

Fixed version (ground truth):
public SnappyLoader(final boolean verbose){
  Constructor<InputStream> inputStreamCtor=null;
  Constructor<OutputStream> outputStreamCtor=null;
  if (true || java.lang.Boolean.valueOf(System.getProperty("String_Node_Str","String_Node_Str"))) {
    System.err.println("String_Node_Str");
  }
 else {
    try {
      final Class<InputStream> snappyInputStreamClass=(Class<InputStream>)Class.forName("String_Node_Str");
      final Class<OutputStream> snappyOutputStreamClass=(Class<OutputStream>)Class.forName("String_Node_Str");
      inputStreamCtor=snappyInputStreamClass.getConstructor(InputStream.class);
      outputStreamCtor=snappyOutputStreamClass.getConstructor(OutputStream.class);
    }
 catch (    NoSuchMethodException e) {
    }
catch (    ClassNotFoundException e) {
    }
  }
  SnappyInputStreamCtor=inputStreamCtor;
  SnappyOutputStreamCtor=outputStreamCtor;
  if (SnappyInputStreamCtor != null && SnappyOutputStreamCtor != null) {
    if (!LoadSnappy.load()) {
      if (verbose)       System.err.println("String_Node_Str");
      SnappyAvailable=false;
    }
 else {
      SnappyAvailable=true;
      if (verbose)       System.err.println("String_Node_Str");
    }
  }
 else {
    SnappyAvailable=false;
    if (verbose)     System.err.println("String_Node_Str");
  }
}
Program: 30649
Project: 30649
Buggy source:
/** 
 * Read the next record from the list of input files, and load into data argument.
 * @param data Has already been set up appropriately for paired or single end read, barcoded or not.
 */
@Override public void next(final IlluminaReadData data){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  final int lineNumber=parser.getCurrentLineNumber();
  final String line=parser.getCurrentLine();
  try {
    final String[] fields=parser.next();
    processLine(data,fields);
  }
 catch (  RuntimeException re) {
    log.error(re,"String_Node_Str" + parser.getFileName() + "String_Node_Str"+ lineNumber+ "String_Node_Str"+ line);
    throw re;
  }
}

Fixed version (ground truth):
/** 
 * Read the next record from the list of input files, and load into data argument.
 * @param data Has already been set up appropriately for paired or single end read, barcoded or not.
 */
@Override public void next(final IlluminaReadData data){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  try {
    final String[] fields=parser.next();
    processLine(data,fields);
  }
 catch (  RuntimeException re) {
    log.error(re,"String_Node_Str" + parser.getFileName() + "String_Node_Str"+ parser.getCurrentLineNumber()+ "String_Node_Str"+ parser.getCurrentLine());
    throw re;
  }
}
Program: 30650
Project: 30650
Buggy source:
/** 
 * Workhorse method that reads the next line from the underlying reader
 * @return  String or null if there is no next line
 */
protected byte[] readNextLine(){
  try {
    final String line=reader.readLine();
    if (line != null) {
      currentLineNumber++;
      currentLine=line;
      return line.getBytes();
    }
    if (inputs.size() > 0) {
      currentFileName=fileNames.size() > 0 ? fileNames.remove(0) : null;
      currentLineNumber=0;
      reader=new AsciiLineReader(inputs.remove(0));
      return readNextLine();
    }
    return null;
  }
 catch (  RuntimeIOException ioe) {
    throw new PicardException("String_Node_Str" + currentFileName,ioe);
  }
}

Fixed version (ground truth):
/** 
 * Workhorse method that reads the next line from the underlying reader
 * @return  String or null if there is no next line
 */
protected byte[] readNextLine(){
  try {
    final String line=reader.readLine();
    if (nextLine != null && !isComment(nextLine.getBytes())) {
      currentLineNumber=nextLineNumber;
      currentLine=nextLine;
    }
    if (line != null) {
      nextLineNumber++;
      nextLine=line;
      return line.getBytes();
    }
    if (inputs.size() > 0) {
      currentFileName=fileNames.size() > 0 ? fileNames.remove(0) : null;
      nextLineNumber=0;
      nextLine=null;
      reader=new AsciiLineReader(inputs.remove(0));
      return readNextLine();
    }
    return null;
  }
 catch (  RuntimeIOException ioe) {
    throw new PicardException("String_Node_Str" + currentFileName,ioe);
  }
}
Program: 30651
Project: 30651
Buggy source:
@Override public Row next(){
  final String source=parser.getCurrentLine();
  final String[] fields=parser.next();
  return new Row(fields,source);
}

Fixed version (ground truth):
@Override public Row next(){
  final String[] fields=parser.next();
  final String source=parser.getCurrentLine();
  return new Row(fields,source);
}
Program: 30652
Project: 30652
Buggy source:
@Test(dataProvider="String_Node_Str") public void testTextFileParser(Object fileOrStream){
  FormatUtil format=new FormatUtil();
  BasicInputParser parser=fileOrStream instanceof File ? new BasicInputParser(true,(File)fileOrStream) : new BasicInputParser(true,(InputStream)fileOrStream);
  int index=0;
  while (parser.hasNext()) {
    String parts[]=parser.next();
    Assert.assertEquals(parts.length,4);
    if (index < 4) {
      for (int i=0; i < parts.length; i++) {
        Assert.assertEquals(parts,testFile1Data[index]);
      }
    }
 else {
      Assert.assertEquals(testFile1Data[index][0],format.parseDouble(parts[0]));
      Assert.assertEquals(testFile1Data[index][1],format.parseInt(parts[1]));
      Assert.assertEquals(testFile1Data[index][2],format.parseInt(parts[2]));
      Assert.assertEquals(testFile1Data[index][3],format.parseDouble(parts[3]));
    }
    index++;
  }
}

Fixed version (ground truth):
@Test(dataProvider="String_Node_Str") public void testTextFileParser(Object fileOrStream) throws IOException {
  FormatUtil format=new FormatUtil();
  List<String> expected=new ArrayList<String>();
  if (fileOrStream instanceof File) {
    BufferedReader reader=new BufferedReader(new FileReader((File)fileOrStream));
    String line=null;
    while ((line=reader.readLine()) != null) {
      if (!line.startsWith("String_Node_Str"))       expected.add(line);
    }
    reader.close();
  }
  BasicInputParser parser=fileOrStream instanceof File ? new BasicInputParser(true,(File)fileOrStream) : new BasicInputParser(true,(InputStream)fileOrStream);
  int index=0;
  while (parser.hasNext()) {
    String parts[]=parser.next();
    if (fileOrStream instanceof File) {
      Assert.assertEquals(parser.getCurrentLine(),expected.get(index));
    }
    Assert.assertEquals(parser.getCurrentLineNumber(),index <= 2 ? index + 1 : index + 2);
    Assert.assertEquals(parts.length,4);
    if (index < 4) {
      for (int i=0; i < parts.length; i++) {
        Assert.assertEquals(parts,testFile1Data[index]);
      }
    }
 else {
      Assert.assertEquals(testFile1Data[index][0],format.parseDouble(parts[0]));
      Assert.assertEquals(testFile1Data[index][1],format.parseInt(parts[1]));
      Assert.assertEquals(testFile1Data[index][2],format.parseInt(parts[2]));
      Assert.assertEquals(testFile1Data[index][3],format.parseDouble(parts[3]));
    }
    index++;
  }
}
Program: 30653
Project: 30653
Buggy source:
/** 
 * Checks that the average quality over the entire read is >= min, and that the first N bases do not contain any no-calls.
 */
boolean passesQualityCheck(final byte[] bases,final byte[] quals,final int seedLength,final int minQuality){
  for (int i=0; i < seedLength; ++i) {
    if (SequenceUtil.isNoCall(bases[i]))     return false;
  }
  int total=0;
  for (  final byte b : quals)   total+=b;
  return total / quals.length >= minQuality;
}

Fixed version (ground truth):
/** 
 * Checks that the average quality over the entire read is >= min, and that the first N bases do not contain any no-calls.
 */
boolean passesQualityCheck(final byte[] bases,final byte[] quals,final int seedLength,final int minQuality){
  if (bases.length < seedLength)   return false;
  for (int i=0; i < seedLength; ++i) {
    if (SequenceUtil.isNoCall(bases[i]))     return false;
  }
  int total=0;
  for (  final byte b : quals)   total+=b;
  return total / quals.length >= minQuality;
}
Program: 30656
Project: 30656
Buggy source:
@Override public Row next(){
  final Row row=new Row(parser.next());
  row.setCurrentLine(parser.getCurrentLine());
  return row;
}

Fixed version (ground truth):
@Override public Row next(){
  final String source=parser.getCurrentLine();
  final String[] fields=parser.next();
  return new Row(fields,source);
}
Program: 30657
Project: 30657
Buggy source:
Row(final String[] fields){
  this.fields=fields;
}

Fixed version (ground truth):
Row(final String[] fields,final String source){
  this.fields=fields;
  this.currentLine=source;
}
Program: 30662
Project: 30662
Buggy source:
/** 
 * Merges the alignment from the map file with the non-aligned records from the source BAM file.
 */
public void mergeAlignment(){
  try {
    super.mergeAlignment();
  }
 catch (  Exception e) {
    forceSort=true;
    super.mergeAlignment();
  }
}

Fixed version (ground truth):
/** 
 * Merges the alignment from the map file with the non-aligned records from the source BAM file.
 */
public void mergeAlignment(){
  try {
    super.mergeAlignment();
  }
 catch (  Exception e) {
    forceSort=true;
    setRefSeqFileWalker();
    super.mergeAlignment();
  }
}
Program: 30663
Project: 30663
Buggy source:
public int compare(final SAMRecord samRecord1,final SAMRecord samRecord2){
  final int cmp=fileOrderCompare(samRecord1,samRecord2);
  if (cmp != 0) {
    return cmp;
  }
  if (samRecord1.getReadPairedFlag()) {
    if (samRecord1.getFirstOfPairFlag() && samRecord2.getSecondOfPairFlag()) {
      return -1;
    }
 else     if (samRecord2.getFirstOfPairFlag() && samRecord1.getSecondOfPairFlag()) {
      return 1;
    }
  }
  if (samRecord1.getReadNegativeStrandFlag() == samRecord2.getReadNegativeStrandFlag()) {
    return 0;
  }
  return (samRecord1.getReadNegativeStrandFlag() ? 1 : -1);
}

Fixed version (ground truth):
public int compare(final SAMRecord samRecord1,final SAMRecord samRecord2){
  final int cmp=fileOrderCompare(samRecord1,samRecord2);
  if (cmp != 0) {
    return cmp;
  }
  final boolean r1Paired=samRecord1.getReadPairedFlag();
  final boolean r2Paired=samRecord2.getReadPairedFlag();
  if (r1Paired || r2Paired) {
    if (!r1Paired)     return 1;
 else     if (!r2Paired)     return -1;
 else     if (samRecord1.getFirstOfPairFlag() && samRecord2.getSecondOfPairFlag())     return -1;
 else     if (samRecord1.getSecondOfPairFlag() && samRecord2.getFirstOfPairFlag())     return 1;
  }
  if (samRecord1.getReadNegativeStrandFlag() == samRecord2.getReadNegativeStrandFlag())   return 0;
 else   return (samRecord1.getReadNegativeStrandFlag() ? 1 : -1);
}
Program: 30664
Project: 30664
Buggy source:
protected List<Chunk> optimizeChunkList(final List<Chunk> chunks,final long minimumOffset){
  Chunk lastChunk=null;
  Collections.sort(chunks);
  final List<Chunk> result=new ArrayList<Chunk>();
  for (  final Chunk chunk : chunks) {
    if (chunk.getChunkEnd() <= minimumOffset) {
      continue;
    }
    if (result.isEmpty()) {
      result.add(chunk);
      lastChunk=chunk;
      continue;
    }
    if (!BlockCompressedFilePointerUtil.areInSameOrAdjacentBlocks(lastChunk.getChunkEnd(),chunk.getChunkStart())) {
      result.add(chunk);
      lastChunk=chunk;
    }
 else {
      if (chunk.getChunkEnd() > lastChunk.getChunkEnd()) {
        lastChunk.setChunkEnd(chunk.getChunkEnd());
      }
    }
  }
  return result;
}

Fixed version (ground truth):
protected List<Chunk> optimizeChunkList(final List<Chunk> chunks,final long minimumOffset){
  Chunk lastChunk=null;
  Collections.sort(chunks);
  final List<Chunk> result=new ArrayList<Chunk>();
  for (  final Chunk chunk : chunks) {
    if (chunk.getChunkEnd() <= minimumOffset) {
      continue;
    }
    if (result.isEmpty()) {
      result.add(chunk);
      lastChunk=chunk;
      continue;
    }
    if (!lastChunk.overlaps(chunk) && !lastChunk.isAdjacentTo(chunk)) {
      result.add(chunk);
      lastChunk=chunk;
    }
 else {
      if (chunk.getChunkEnd() > lastChunk.getChunkEnd()) {
        lastChunk.setChunkEnd(chunk.getChunkEnd());
      }
    }
  }
  return result;
}
Program: 30666
Project: 30666
Buggy source:
/** 
 * @return  the chunks associated with this bin
 */
public List<Chunk> getChunkList(){
  return chunkList;
}

Fixed version (ground truth):
/** 
 * Gets the list of chunks associated with this bin.
 * @return the chunks in this bin.  If no chunks are associated, an empty list will be returned.
 */
public List<Chunk> getChunkList(){
  if (chunkList == null)   return Collections.<Chunk>emptyList();
  return chunkList;
}
Program: 30667
Project: 30667
Buggy source:
/** 
 * Perform an overlapping query of all bins bounding the given location.
 * @param bin The bin over which to perform an overlapping query.
 * @return The file pointers
 */
public BAMFileSpan getSpanOverlapping(final Bin bin){
  if (bin == null)   return null;
  final int referenceSequence=bin.getReferenceSequence();
  BAMIndexContent indexQuery=getQueryResults(referenceSequence);
  if (indexQuery == null)   return null;
  final int binLevel=getLevelForBin(bin);
  final int firstLocusInBin=getFirstLocusInBin(bin);
  List<Bin> binTree=new ArrayList<Bin>();
  if (indexQuery.containsBin(bin))   binTree.add(bin);
  int currentBinLevel=binLevel;
  while (--currentBinLevel >= 0) {
    final int binStart=getFirstBinInLevel(currentBinLevel);
    final int binWidth=getMaxAddressibleGenomicLocation() / getLevelSize(currentBinLevel);
    final int binNumber=firstLocusInBin / binWidth + binStart;
    Bin parentBin=new Bin(bin.getReferenceSequence(),binNumber);
    if (indexQuery.containsBin(parentBin))     binTree.add(parentBin);
  }
  List<Chunk> chunkList=new ArrayList<Chunk>();
  for (  Bin coveringBin : binTree) {
    for (    Chunk chunk : coveringBin.getChunkList())     chunkList.add(chunk.clone());
  }
  final int start=getFirstLocusInBin(bin);
  chunkList=optimizeChunkList(chunkList,indexQuery.getLinearIndex().getMinimumOffset(start));
  return new BAMFileSpan(chunkList);
}

Fixed version (ground truth):
/** 
 * Perform an overlapping query of all bins bounding the given location.
 * @param bin The bin over which to perform an overlapping query.
 * @return The file pointers
 */
public BAMFileSpan getSpanOverlapping(final Bin bin){
  if (bin == null)   return null;
  final int referenceSequence=bin.getReferenceSequence();
  BAMIndexContent indexQuery=getQueryResults(referenceSequence);
  if (indexQuery == null)   return null;
  final int binLevel=getLevelForBin(bin);
  final int firstLocusInBin=getFirstLocusInBin(bin);
  List<Bin> binTree=new ArrayList<Bin>();
  if (indexQuery.containsBin(bin))   binTree.add(indexQuery.getBins().getBin(bin.getBinNumber()));
  int currentBinLevel=binLevel;
  while (--currentBinLevel >= 0) {
    final int binStart=getFirstBinInLevel(currentBinLevel);
    final int binWidth=getMaxAddressibleGenomicLocation() / getLevelSize(currentBinLevel);
    final int binNumber=firstLocusInBin / binWidth + binStart;
    Bin parentBin=indexQuery.getBins().getBin(binNumber);
    if (parentBin != null && indexQuery.containsBin(parentBin))     binTree.add(parentBin);
  }
  List<Chunk> chunkList=new ArrayList<Chunk>();
  for (  Bin coveringBin : binTree) {
    for (    Chunk chunk : coveringBin.getChunkList())     chunkList.add(chunk.clone());
  }
  final int start=getFirstLocusInBin(bin);
  chunkList=optimizeChunkList(chunkList,indexQuery.getLinearIndex().getMinimumOffset(start));
  return new BAMFileSpan(chunkList);
}
Program: 30671
Project: 30671
Buggy source:
public void add(final SAMRecord record){
  if (!record.getReadPairedFlag()) {
    collection.add(record);
  }
 else   if (pending == null) {
    pending=record;
  }
 else {
    if (!record.getReadName().equals(pending.getReadName())) {
      throw new PicardException("String_Node_Str" + record.getReadName() + "String_Node_Str"+ pending.getReadName());
    }
    if (!(record.getReadUnmappedFlag() || pending.getReadUnmappedFlag())) {
      if (record.getReadNegativeStrandFlag() != pending.getReadNegativeStrandFlag()) {
        final SAMRecord pos=(record.getReadNegativeStrandFlag()) ? pending : record;
        final SAMRecord neg=(record.getReadNegativeStrandFlag()) ? record : pending;
        if (pos.getAlignmentStart() < neg.getAlignmentEnd()) {
          final int posDiff=pos.getAlignmentEnd() - neg.getAlignmentEnd();
          final int negDiff=pos.getAlignmentStart() - neg.getAlignmentStart();
          if (posDiff > 0) {
            CigarUtil.softClip3PrimeEndOfRead(pos,Math.min(pos.getReadLength(),pos.getReadLength() - posDiff + 1));
          }
          if (negDiff > 0) {
            CigarUtil.softClip3PrimeEndOfRead(neg,Math.min(neg.getReadLength(),neg.getReadLength() - negDiff + 1));
          }
        }
      }
 else {
      }
    }
    SamPairUtil.setMateInfo(record,pending,header);
    collection.add(pending);
    collection.add(record);
    pending=null;
  }
}

Fixed version (ground truth):
public void add(final SAMRecord record){
  if (!record.getReadPairedFlag()) {
    collection.add(record);
  }
 else   if (pending == null) {
    pending=record;
  }
 else   if (alignedOnly && !pending.getReadName().equals(record.getReadName())) {
    collection.add(pending);
    pending=record;
  }
 else {
    if (!record.getReadName().equals(pending.getReadName())) {
      throw new PicardException("String_Node_Str" + record.getReadName() + "String_Node_Str"+ pending.getReadName());
    }
    if (!(record.getReadUnmappedFlag() || pending.getReadUnmappedFlag())) {
      if (record.getReadNegativeStrandFlag() != pending.getReadNegativeStrandFlag()) {
        final SAMRecord pos=(record.getReadNegativeStrandFlag()) ? pending : record;
        final SAMRecord neg=(record.getReadNegativeStrandFlag()) ? record : pending;
        if (pos.getAlignmentStart() < neg.getAlignmentEnd()) {
          final int posDiff=pos.getAlignmentEnd() - neg.getAlignmentEnd();
          final int negDiff=pos.getAlignmentStart() - neg.getAlignmentStart();
          if (posDiff > 0) {
            CigarUtil.softClip3PrimeEndOfRead(pos,Math.min(pos.getReadLength(),pos.getReadLength() - posDiff + 1));
          }
          if (negDiff > 0) {
            CigarUtil.softClip3PrimeEndOfRead(neg,Math.min(neg.getReadLength(),neg.getReadLength() - negDiff + 1));
          }
        }
      }
 else {
      }
    }
    SamPairUtil.setMateInfo(record,pending,header);
    collection.add(pending);
    collection.add(record);
    pending=null;
  }
}
Program: 30672
Project: 30672
Buggy source:
public ClippedPairFixer(final SortingCollection<SAMRecord> collection,final SAMFileHeader header){
  this.collection=collection;
  this.header=header;
}

Fixed version (ground truth):
public ClippedPairFixer(final SortingCollection<SAMRecord> collection,final SAMFileHeader header,boolean alignedReadsOnly){
  this.collection=collection;
  this.header=header;
  this.alignedOnly=alignedReadsOnly;
}
Program: 30673
Project: 30673
Buggy source:
/** 
 * Prints the histogram if one is present. 
 */
private void printHistogram(BufferedWriter out,FormatUtil formatter) throws IOException {
  if (this.histograms.isEmpty()) {
    return;
  }
  java.util.Set<HKEY> keys=new TreeSet<HKEY>();
  for (  Histogram<HKEY> histo : histograms) {
    if (histo != null)     keys.addAll(histo.keySet());
  }
  out.append(HISTO_HEADER + this.histograms.get(0).keySet().iterator().next().getClass().getName());
  out.newLine();
  out.append(StringUtil.assertCharactersNotInString(this.histograms.get(0).getBinLabel(),'\t','\n'));
  for (  Histogram<HKEY> histo : this.histograms) {
    out.append(SEPARATOR);
    out.append(StringUtil.assertCharactersNotInString(histo.getValueLabel(),'\t','\n'));
  }
  out.newLine();
  for (  HKEY key : keys) {
    out.append(key.toString());
    for (    Histogram<HKEY> histo : this.histograms) {
      Histogram<HKEY>.Bin bin=histo.get(key);
      final double value=(bin == null ? 0 : bin.getValue());
      out.append(SEPARATOR);
      out.append(formatter.format(value));
    }
    out.newLine();
  }
}

Fixed version (ground truth):
/** 
 * Prints the histogram if one is present. 
 */
private void printHistogram(BufferedWriter out,FormatUtil formatter) throws IOException {
  if (this.histograms.isEmpty()) {
    return;
  }
  java.util.Set<HKEY> keys=new TreeSet<HKEY>(histograms.get(0).comparator());
  for (  Histogram<HKEY> histo : histograms) {
    if (histo != null)     keys.addAll(histo.keySet());
  }
  out.append(HISTO_HEADER + this.histograms.get(0).keySet().iterator().next().getClass().getName());
  out.newLine();
  out.append(StringUtil.assertCharactersNotInString(this.histograms.get(0).getBinLabel(),'\t','\n'));
  for (  Histogram<HKEY> histo : this.histograms) {
    out.append(SEPARATOR);
    out.append(StringUtil.assertCharactersNotInString(histo.getValueLabel(),'\t','\n'));
  }
  out.newLine();
  for (  HKEY key : keys) {
    out.append(key.toString());
    for (    Histogram<HKEY> histo : this.histograms) {
      Histogram<HKEY>.Bin bin=histo.get(key);
      final double value=(bin == null ? 0 : bin.getValue());
      out.append(SEPARATOR);
      out.append(formatter.format(value));
    }
    out.newLine();
  }
}
Program: 30675
Project: 30675
Buggy source:
/** 
 * Checks to see if there are clashes where different readers are using the same read group IDs. If they are then a new set of unique read group IDs are generated (across all read groups) otherwise the original read group headers are returned.
 * @param readers readers to combine
 * @return new list of readgroups constructed from all the readers
 */
private List<SAMReadGroupRecord> mergeReadGroups(final Collection<SAMFileReader> readers){
  final Map<String,SAMReadGroupRecord> seenGroupIds=new TreeMap<String,SAMReadGroupRecord>();
  int idx=0;
  for (  final SAMFileReader reader : readers) {
    final Map<String,String> groupIdTranslation=new HashMap<String,String>();
    samReadGroupIdTranslation.put(reader,groupIdTranslation);
    for (    final SAMReadGroupRecord group : reader.getFileHeader().getReadGroups()) {
      final String groupId=group.getReadGroupId();
      final SAMReadGroupRecord seenGroup=seenGroupIds.get(groupId);
      if (seenGroup == null) {
        seenGroupIds.put(groupId,group);
        groupIdTranslation.put(groupId,groupId);
      }
 else       if (!group.equivalent(seenGroup)) {
        hasReadGroupCollisions=true;
        String newGroupId;
        while (seenGroupIds.containsKey(newGroupId=Integer.toString(idx++)))         ;
        seenGroupIds.put(newGroupId,new SAMReadGroupRecord(newGroupId,group));
        groupIdTranslation.put(groupId,newGroupId);
      }
    }
  }
  return new ArrayList<SAMReadGroupRecord>(seenGroupIds.values());
}

Fixed version (ground truth):
/** 
 * Checks to see if there are clashes where different readers are using the same read group IDs. If yes, then those IDs that collided are remapped.
 * @param readers readers to combine
 * @return new list of read groups constructed from all the readers
 */
private List<SAMReadGroupRecord> mergeReadGroups(final Collection<SAMFileReader> readers){
  final HashSet<String> idsThatAreAlreadyTaken=new HashSet<String>();
  final List<HeaderRecordAndFileReader<SAMReadGroupRecord>> readGroupsToProcess=new LinkedList<HeaderRecordAndFileReader<SAMReadGroupRecord>>();
  for (  final SAMFileReader reader : readers) {
    for (    final SAMReadGroupRecord readGroup : reader.getFileHeader().getReadGroups()) {
      if (!idsThatAreAlreadyTaken.add(readGroup.getId()))       throw new PicardException("String_Node_Str" + reader + "String_Node_Str"+ readGroup.getId()+ "String_Node_Str");
      readGroupsToProcess.add(new HeaderRecordAndFileReader<SAMReadGroupRecord>(readGroup,reader));
    }
    idsThatAreAlreadyTaken.clear();
  }
  final List<SAMReadGroupRecord> result=new LinkedList<SAMReadGroupRecord>();
  hasReadGroupCollisions=mergeHeaderRecords(readGroupsToProcess,READ_GROUP_RECORD_FACTORY,idsThatAreAlreadyTaken,samReadGroupIdTranslation,result);
  Collections.sort(result,RECORD_ID_COMPARATOR);
  return result;
}
Program: 30677
Project: 30677
Buggy source:
public Set<Map.Entry<String,Object>> getAttributes(){
  return mAttributes.entrySet();
}

Fixed version (ground truth):
/** 
 * Returns the Set of attributes.
 */
public Set<Map.Entry<String,Object>> getAttributes(){
  return mAttributes.entrySet();
}
Program: 30678
Project: 30678
Buggy source:
public String getLibrary(){
  return (String)getAttribute("String_Node_Str");
}

Fixed version (ground truth):
public String getLibrary(){
  return (String)getAttribute(LIBRARY_TAG);
}
Program: 30679
Project: 30679
Buggy source:
public String getSample(){
  return (String)getAttribute("String_Node_Str");
}

Fixed version (ground truth):
public String getSample(){
  return (String)getAttribute(READ_GROUP_SAMPLE_TAG);
}
Program: 30680
Project: 30680
Buggy source:
public void setSample(final String value){
  setAttribute("String_Node_Str",value);
}

Fixed version (ground truth):
public void setSample(final String value){
  setAttribute(READ_GROUP_SAMPLE_TAG,value);
}