Program: 141376
Project: 141376
Buggy source:
private Map<DataFile,DataFile> reWriteDesign(final Design design,final Set<DataFile> filesToCopy) throws IOException {
  final Map<DataFile,DataFile> result=new HashMap<DataFile,DataFile>();
  final Map<String,String> genomesMap=new HashMap<String,String>();
  final Map<String,String> annotationsMap=new HashMap<String,String>();
  int genomesCount=0;
  int annotationsCount=0;
  for (  Sample s : design.getSamples()) {
    DataFile sampleOldFile=new DataFile(s.getSource());
    DataFile sampleNewFile=getUploadedDataFile(sampleOldFile,s.getId());
    if (filesToCopy.contains(sampleOldFile)) {
      filesToCopy.remove(sampleOldFile);
      result.put(sampleOldFile,sampleNewFile);
    }
    s.setSource(sampleNewFile.getSource());
    final String genome=s.getMetadata().getGenome();
    if (!genomesMap.containsKey(genome)) {
      genomesCount++;
      DataFile genomeOldFile=new DataFile(genome);
      DataFile genomeNewFile=getUploadedDataFile(genomeOldFile,genomesCount);
      if (filesToCopy.contains(genomeOldFile)) {
        filesToCopy.remove(genomeOldFile);
        result.put(genomeOldFile,genomeNewFile);
      }
      genomesMap.put(genome,genomeNewFile.getSource());
    }
    s.getMetadata().setGenome(genomesMap.get(genome));
    final String annotation=s.getMetadata().getAnnotation();
    if (!annotationsMap.containsKey(annotation)) {
      annotationsCount++;
      DataFile annotationOldFile=new DataFile(annotation);
      DataFile annotationNewFile=getUploadedDataFile(annotationOldFile,annotationsCount);
      if (filesToCopy.contains(annotationOldFile)) {
        filesToCopy.remove(annotationOldFile);
        result.put(annotationOldFile,annotationNewFile);
      }
      annotationsMap.put(annotation,annotationNewFile.getSource());
    }
    s.getMetadata().setAnnotation(annotationsMap.get(annotation));
  }
  for (  DataFile file : filesToCopy)   result.put(file,getUploadedDataFile(file));
  return result;
}

Fixed version (ground truth):
private Map<DataFile,DataFile> reWriteDesign(final Design design,final Set<DataFile> filesToCopy) throws IOException {
  final Map<DataFile,DataFile> result=new HashMap<DataFile,DataFile>();
  final Map<String,String> genomesMap=new HashMap<String,String>();
  final Map<String,String> annotationsMap=new HashMap<String,String>();
  int genomesCount=0;
  int annotationsCount=0;
  for (  Sample s : design.getSamples()) {
    DataFile sampleOldFile=new DataFile(s.getSource());
    DataFile sampleNewFile=getUploadedDataFile(sampleOldFile,s.getId());
    if (filesToCopy.contains(sampleOldFile)) {
      filesToCopy.remove(sampleOldFile);
      result.put(sampleOldFile,sampleNewFile);
    }
    s.setSource(sampleNewFile.getSource());
    final String genome=s.getMetadata().getGenome();
    if (!genomesMap.containsKey(genome)) {
      genomesCount++;
      final DataFile genomeOldFile=new DataFile(genome);
      final DataFile genomeNewFile=getUploadedDataFile(genomeOldFile,genomesCount);
      if (filesToCopy.contains(genomeOldFile)) {
        filesToCopy.remove(genomeOldFile);
        result.put(genomeOldFile,genomeNewFile);
      }
      genomesMap.put(genome,genomeNewFile == null ? "String_Node_Str" : genomeNewFile.getSource());
    }
    s.getMetadata().setGenome(genomesMap.get(genome));
    final String annotation=s.getMetadata().getAnnotation();
    if (!annotationsMap.containsKey(annotation)) {
      annotationsCount++;
      final DataFile annotationOldFile=new DataFile(annotation);
      final DataFile annotationNewFile=getUploadedDataFile(annotationOldFile,annotationsCount);
      if (filesToCopy.contains(annotationOldFile)) {
        filesToCopy.remove(annotationOldFile);
        result.put(annotationOldFile,annotationNewFile);
      }
      annotationsMap.put(annotation,annotationNewFile == null ? "String_Node_Str" : annotationNewFile.getSource());
    }
    s.getMetadata().setAnnotation(annotationsMap.get(annotation));
  }
  for (  DataFile file : filesToCopy)   result.put(file,getUploadedDataFile(file));
  return result;
}