Program: 38640
Project: 38640
Buggy source:
public static void runSingleQueryMultipleTarget(InputHandler inputHandler,OutputHandler outputHandler,ArgumentHandler argumentHandler) throws IOException, CDKException, CloneNotSupportedException {
  IAtomContainer query=inputHandler.getQuery();
  boolean removeHydrogens=argumentHandler.isApplyHRemoval();
  boolean flag=ConnectivityChecker.isConnected(query);
  if (!flag) {
    System.err.println("String_Node_Str" + inputHandler.getQueryName() + "String_Node_Str");
    return;
  }
  if (removeHydrogens) {
    query=new AtomContainer(AtomContainerManipulator.removeHydrogens(query));
  }
  outputHandler.writeQueryMol(query);
  String out="String_Node_Str";
  outputHandler.startAppending(out);
  long startTime=System.currentTimeMillis();
  BaseMapping smsd=null;
  boolean matchBonds=argumentHandler.isMatchBondType();
  boolean matchRings=argumentHandler.isMatchRingType();
  int targetNumber=0;
  IIteratingChemObjectReader reader=inputHandler.getAllTargets();
  String targetType=argumentHandler.getTargetType();
  if (reader == null) {
    throw new IOException("String_Node_Str" + targetType);
  }
  while (reader.hasNext()) {
    IAtomContainer target=(IAtomContainer)reader.next();
    flag=ConnectivityChecker.isConnected(target);
    if (!flag) {
      System.err.println("String_Node_Str" + target.getProperty(CDKConstants.TITLE) + "String_Node_Str");
      continue;
    }
    if (removeHydrogens) {
      target=new AtomContainer(AtomContainerManipulator.removeHydrogens(target));
    }
    if (target.getProperty(CDKConstants.TITLE) != null) {
      target.setID((String)target.getProperty(CDKConstants.TITLE));
      argumentHandler.setTargetMolOutName(target.getID() == null ? "String_Node_Str" : target.getID());
    }
    inputHandler.configure(target,targetType);
    if (argumentHandler.isSubstructureMode()) {
      smsd=runSubstructure(query,target,argumentHandler.getChemFilter(),matchBonds,matchRings);
    }
 else {
      smsd=run(query,target,argumentHandler.getChemFilter(),matchBonds,matchRings);
    }
    long endTime=System.currentTimeMillis();
    long executionTime=endTime - startTime;
    outputHandler.writeTargetMol(smsd.getTargetContainer());
    String queryPath=argumentHandler.getQueryFilepath();
    String targetPath=argumentHandler.getTargetFilepath();
    query=query.getBuilder().newInstance(IAtomContainer.class,smsd.getFirstAtomMapping().getQuery());
    target=target.getBuilder().newInstance(IAtomContainer.class,smsd.getFirstAtomMapping().getTarget());
    Map<IAtom,IAtom> mcs=smsd.getFirstAtomMapping().getMappings();
    int nAtomsMatched=(mcs == null) ? 0 : mcs.size();
    double tanimotoSimilarity=smsd.getTanimotoSimilarity();
    if (mcs != null && argumentHandler.isAllMapping()) {
      outputHandler.printHeader(queryPath,targetPath,nAtomsMatched);
      int counter=0;
      for (Iterator<AtomAtomMapping> it=smsd.getAllAtomMapping().iterator(); it.hasNext(); ) {
        AtomAtomMapping aam=it.next();
        Map<Integer,Integer> mapping=aam.getMappingsIndex();
        if (argumentHandler.isImage()) {
          double stereoScore=smsd.getStereoScore(counter);
          String label=outputHandler.makeLabel(tanimotoSimilarity,stereoScore);
          outputHandler.addImage(query,target,label,mapping);
        }
        outputHandler.printMapping((counter + 1),mapping);
        counter+=1;
      }
    }
 else     if (mcs != null && !argumentHandler.isAllMapping()) {
      Map<Integer,Integer> mcsNumber=smsd.getFirstAtomMapping().getMappingsIndex();
      double stereoScore=smsd.getStereoScore(0);
      outputHandler.printHeader(queryPath,targetPath,nAtomsMatched);
      String qrefName=inputHandler.getQRefName();
      String trefName=inputHandler.getTRefName();
      outputHandler.printTopMapping(nAtomsMatched,mcs,mcsNumber,qrefName,trefName);
      if (argumentHandler.isImage()) {
        String label=outputHandler.makeLabel(tanimotoSimilarity,stereoScore);
        outputHandler.makeImage(query,target,label,mcsNumber);
      }
    }
    double tanimotoGraph=smsd.getTanimotoSimilarity();
    double euclidianGraph=smsd.getEuclideanDistance();
    outputHandler.writeResults(query,target,tanimotoGraph,euclidianGraph,nAtomsMatched,executionTime);
    if (mcs != null && argumentHandler.isImage()) {
      String qName=inputHandler.getQueryName();
      String tName=inputHandler.getTargetName() + "String_Node_Str" + targetNumber;
      outputHandler.writeImage(qName,tName);
    }
    targetNumber++;
  }
  outputHandler.closeFiles();
}

Fixed version (ground truth):
public static void runSingleQueryMultipleTarget(InputHandler inputHandler,OutputHandler outputHandler,ArgumentHandler argumentHandler) throws IOException, CDKException, CloneNotSupportedException {
  IAtomContainer query=inputHandler.getQuery();
  String name=(String)query.getProperty(CDKConstants.TITLE);
  boolean removeHydrogens=argumentHandler.isApplyHRemoval();
  boolean flag=ConnectivityChecker.isConnected(query);
  if (!flag) {
    System.err.println("String_Node_Str" + inputHandler.getQueryName() + "String_Node_Str");
    return;
  }
  if (removeHydrogens) {
    query=new AtomContainer(AtomContainerManipulator.removeHydrogens(query));
    query.setProperty(CDKConstants.TITLE,name);
    query.setID(name);
  }
  outputHandler.writeQueryMol(query);
  String out="String_Node_Str";
  outputHandler.startAppending(out);
  long startTime=System.currentTimeMillis();
  BaseMapping smsd=null;
  boolean matchBonds=argumentHandler.isMatchBondType();
  boolean matchRings=argumentHandler.isMatchRingType();
  int targetNumber=0;
  IIteratingChemObjectReader reader=inputHandler.getAllTargets();
  String targetType=argumentHandler.getTargetType();
  if (reader == null) {
    throw new IOException("String_Node_Str" + targetType);
  }
  while (reader.hasNext()) {
    IAtomContainer target=(IAtomContainer)reader.next();
    flag=ConnectivityChecker.isConnected(target);
    if (!flag) {
      System.err.println("String_Node_Str" + target.getProperty(CDKConstants.TITLE) + "String_Node_Str");
      continue;
    }
    if (removeHydrogens) {
      target=new AtomContainer(AtomContainerManipulator.removeHydrogens(target));
    }
    if (target.getProperty(CDKConstants.TITLE) != null) {
      target.setID((String)target.getProperty(CDKConstants.TITLE));
      argumentHandler.setTargetMolOutName(target.getID() == null ? "String_Node_Str" : target.getID());
    }
    inputHandler.configure(target,targetType);
    if (argumentHandler.isSubstructureMode()) {
      smsd=runSubstructure(query,target,argumentHandler.getChemFilter(),matchBonds,matchRings);
    }
 else {
      smsd=run(query,target,argumentHandler.getChemFilter(),matchBonds,matchRings);
    }
    long endTime=System.currentTimeMillis();
    long executionTime=endTime - startTime;
    outputHandler.writeTargetMol(smsd.getTargetContainer());
    String queryPath=argumentHandler.getQueryFilepath();
    String targetPath=argumentHandler.getTargetFilepath();
    query=query.getBuilder().newInstance(IAtomContainer.class,smsd.getFirstAtomMapping().getQuery());
    target=target.getBuilder().newInstance(IAtomContainer.class,smsd.getFirstAtomMapping().getTarget());
    Map<IAtom,IAtom> mcs=smsd.getFirstAtomMapping().getMappings();
    int nAtomsMatched=(mcs == null) ? 0 : mcs.size();
    double tanimotoSimilarity=smsd.getTanimotoSimilarity();
    if (mcs != null && argumentHandler.isAllMapping()) {
      outputHandler.printHeader(queryPath,targetPath,nAtomsMatched);
      int counter=0;
      for (Iterator<AtomAtomMapping> it=smsd.getAllAtomMapping().iterator(); it.hasNext(); ) {
        AtomAtomMapping aam=it.next();
        Map<Integer,Integer> mapping=aam.getMappingsIndex();
        if (argumentHandler.isImage()) {
          double stereoScore=smsd.getStereoScore(counter);
          String label=outputHandler.makeLabel(tanimotoSimilarity,stereoScore);
          outputHandler.addImage(query,target,label,mapping);
        }
        outputHandler.printMapping((counter + 1),mapping);
        counter+=1;
      }
    }
 else     if (mcs != null && !argumentHandler.isAllMapping()) {
      Map<Integer,Integer> mcsNumber=smsd.getFirstAtomMapping().getMappingsIndex();
      double stereoScore=smsd.getStereoScore(0);
      outputHandler.printHeader(queryPath,targetPath,nAtomsMatched);
      String qrefName=inputHandler.getQRefName();
      String trefName=inputHandler.getTRefName();
      outputHandler.printTopMapping(nAtomsMatched,mcs,mcsNumber,qrefName,trefName);
      if (argumentHandler.isImage()) {
        String label=outputHandler.makeLabel(tanimotoSimilarity,stereoScore);
        outputHandler.makeImage(query,target,label,mcsNumber);
      }
    }
    double tanimotoGraph=smsd.getTanimotoSimilarity();
    double euclidianGraph=smsd.getEuclideanDistance();
    outputHandler.writeResults(query,target,tanimotoGraph,euclidianGraph,nAtomsMatched,executionTime);
    if (mcs != null && argumentHandler.isImage()) {
      String qName=inputHandler.getQueryName();
      String tName=inputHandler.getTargetName() + "String_Node_Str" + targetNumber;
      outputHandler.writeImage(qName,tName);
    }
    targetNumber++;
  }
  outputHandler.closeFiles();
}