Program: 141331
Project: 141331
Buggy source:
private void scanWorkflow() throws EoulsanException {
  final Context context=this.context;
  final Set<DataFile> checkedDatafile=newHashSet();
  final Map<DataFormat,Checker> checkers=newHashMap();
  final DataFormatRegistry dfRegistry=DataFormatRegistry.getInstance();
  dfRegistry.register(DataFormats.READS_FASTQ);
  dfRegistry.register(DataFormats.READS_TFQ);
  dfRegistry.register(DataFormats.GENOME_FASTA);
  dfRegistry.register(DataFormats.ANNOTATION_GFF);
  boolean firstSample=true;
  for (  Sample s : this.design.getSamples()) {
    final Set<DataFormat> cart=newHashSet();
    final Set<DataFormat> cartUsed=newHashSet();
    final Set<DataFormat> cartReUsed=newHashSet();
    final Set<DataFormat> cartGenerated=newHashSet();
    final Set<DataFormat> cartNotGenerated=newHashSet();
    final Set<DataFormat> cartOnlyGenerated=newHashSet();
    cart.add(getReadsDataFormat(s));
    final DataFormat genomeFormat=getGenomeDataFormat(s);
    if (genomeFormat != null) {
      cart.add(genomeFormat);
    }
    final DataFormat annotationFormat=getAnnotationDataFormat(s);
    if (annotationFormat != null) {
      cart.add(annotationFormat);
    }
    for (    Step step : this.steps) {
      if (firstSample)       checkStepInOutFormat(step);
      final Map<DataType,Set<DataFormat>> map=getDataFormatByDataType(step.getInputFormats());
      if (map != null && map.size() > 0)       for (      Map.Entry<DataType,Set<DataFormat>> e : map.entrySet()) {
        int found=0;
        boolean canBeGenerated=false;
        for (        DataFormat df : e.getValue()) {
          if (df.isGenerator())           canBeGenerated=true;
          if (cart.contains(df)) {
            cartUsed.add(df);
            if (df.isChecker())             checkers.put(df,df.getChecker());
            if (cartGenerated.contains(df))             cartReUsed.add(df);
            found++;
          }
        }
        if (found == 0) {
          if (canBeGenerated) {
            cartUsed.add(e.getValue().iterator().next());
          }
 else           throw new EoulsanException("String_Node_Str" + s.getId() + "String_Node_Str"+ step.getName()+ "String_Node_Str");
        }
        if (found > 1)         throw new EoulsanException("String_Node_Str" + s.getId() + "String_Node_Str"+ step.getName()+ "String_Node_Str");
      }
      if (step.getOutputFormats() != null)       for (      DataFormat df : step.getOutputFormats()) {
        cartGenerated.add(df);
        cart.add(df);
      }
    }
    cartNotGenerated.addAll(cartUsed);
    cartNotGenerated.removeAll(cartGenerated);
    for (    DataFormat df : cartNotGenerated) {
      final DataFile file=context.getDataFile(df,s);
      if (!checkedDatafile.contains(file)) {
        if (!context.getDataFile(df,s).exists()) {
          if (df.isGenerator()) {
            this.steps.add(0,df.getGenerator());
            scanWorkflow();
            return;
          }
          throw new EoulsanException("String_Node_Str" + s.getId() + "String_Node_Str"+ df.getFormatName()+ "String_Node_Str");
        }
        checkedDatafile.add(file);
      }
    }
    for (    DataFormat df : cartGenerated) {
      final DataFile file=context.getDataFile(df,s);
      if (!checkedDatafile.contains(file)) {
        if (context.getDataFile(df,s).exists())         throw new EoulsanException("String_Node_Str" + s.getId() + "String_Node_Str"+ df.getFormatName()+ "String_Node_Str");
        checkedDatafile.add(file);
      }
    }
    cartOnlyGenerated.addAll(cartGenerated);
    cartOnlyGenerated.removeAll(cartReUsed);
    globalInputDataFormats.put(s.getId(),Collections.unmodifiableSet(cartNotGenerated));
    globalOutputDataFormats.put(s.getId(),Collections.unmodifiableSet(cartGenerated));
    if (firstSample)     firstSample=false;
  }
  runChecker(checkers);
}

Fixed version (ground truth):
private void scanWorkflow() throws EoulsanException {
  final Context context=this.context;
  final Set<DataFile> checkedDatafile=newHashSet();
  final Map<DataFormat,Checker> checkers=newHashMap();
  final DataFormatRegistry dfRegistry=DataFormatRegistry.getInstance();
  dfRegistry.register(DataFormats.READS_FASTQ);
  dfRegistry.register(DataFormats.READS_TFQ);
  dfRegistry.register(DataFormats.GENOME_FASTA);
  dfRegistry.register(DataFormats.ANNOTATION_GFF);
  boolean firstSample=true;
  for (  Sample s : this.design.getSamples()) {
    final Set<DataFormat> cart=newHashSet();
    final Set<DataFormat> cartUsed=newHashSet();
    final Set<DataFormat> cartReUsed=newHashSet();
    final Set<DataFormat> cartGenerated=newHashSet();
    final Set<DataFormat> cartNotGenerated=newHashSet();
    final Set<DataFormat> cartOnlyGenerated=newHashSet();
    cart.add(getReadsDataFormat(s));
    final DataFormat genomeFormat=getGenomeDataFormat(s);
    if (genomeFormat != null) {
      cart.add(genomeFormat);
    }
    final DataFormat annotationFormat=getAnnotationDataFormat(s);
    if (annotationFormat != null) {
      cart.add(annotationFormat);
    }
    for (    Step step : this.steps) {
      if (firstSample)       checkStepInOutFormat(step);
      final Map<DataType,Set<DataFormat>> map=getDataFormatByDataType(step.getInputFormats());
      if (map != null && map.size() > 0)       for (      Map.Entry<DataType,Set<DataFormat>> e : map.entrySet()) {
        int found=0;
        boolean canBeGenerated=false;
        for (        DataFormat df : e.getValue()) {
          if (df.isGenerator())           canBeGenerated=true;
          if (cart.contains(df)) {
            cartUsed.add(df);
            if (df.isChecker())             checkers.put(df,df.getChecker());
            if (cartGenerated.contains(df))             cartReUsed.add(df);
            found++;
          }
 else {
            if (context.getDataFile(df,s).exists()) {
              cart.add(df);
              cartNotGenerated.add(df);
              cartUsed.add(df);
              found++;
            }
          }
        }
        if (found == 0) {
          if (canBeGenerated) {
            cartUsed.add(e.getValue().iterator().next());
          }
 else           throw new EoulsanException("String_Node_Str" + s.getId() + "String_Node_Str"+ step.getName()+ "String_Node_Str");
        }
        if (found > 1)         throw new EoulsanException("String_Node_Str" + s.getId() + "String_Node_Str"+ step.getName()+ "String_Node_Str");
      }
      if (step.getOutputFormats() != null)       for (      DataFormat df : step.getOutputFormats()) {
        cartGenerated.add(df);
        cart.add(df);
      }
    }
    cartNotGenerated.addAll(cartUsed);
    cartNotGenerated.removeAll(cartGenerated);
    for (    DataFormat df : cartNotGenerated) {
      final DataFile file=context.getDataFile(df,s);
      if (!checkedDatafile.contains(file)) {
        if (!context.getDataFile(df,s).exists()) {
          if (df.isGenerator()) {
            this.steps.add(0,df.getGenerator());
            scanWorkflow();
            return;
          }
          throw new EoulsanException("String_Node_Str" + s.getId() + "String_Node_Str"+ df.getFormatName()+ "String_Node_Str");
        }
        checkedDatafile.add(file);
      }
    }
    for (    DataFormat df : cartGenerated) {
      final DataFile file=context.getDataFile(df,s);
      if (!checkedDatafile.contains(file)) {
        if (context.getDataFile(df,s).exists())         throw new EoulsanException("String_Node_Str" + s.getId() + "String_Node_Str"+ df.getFormatName()+ "String_Node_Str");
        checkedDatafile.add(file);
      }
    }
    cartOnlyGenerated.addAll(cartGenerated);
    cartOnlyGenerated.removeAll(cartReUsed);
    globalInputDataFormats.put(s.getId(),Collections.unmodifiableSet(cartNotGenerated));
    globalOutputDataFormats.put(s.getId(),Collections.unmodifiableSet(cartGenerated));
    if (firstSample)     firstSample=false;
  }
  runChecker(checkers);
}