Program: 38639
Project: 38639
Buggy source:
public static void runSingleQuerySingleTarget(InputHandler inputHandler,OutputHandler outputHandler,ArgumentHandler argumentHandler) throws IOException, CDKException, CloneNotSupportedException {
  IAtomContainer query=inputHandler.getQuery();
  IAtomContainer target=inputHandler.getTarget();
  boolean removeHydrogens=argumentHandler.isApplyHRemoval();
  boolean flag=ConnectivityChecker.isConnected(query);
  if (!flag) {
    System.out.println("String_Node_Str" + inputHandler.getQueryName() + "String_Node_Str");
    return;
  }
  flag=ConnectivityChecker.isConnected(target);
  if (!flag) {
    System.out.println("String_Node_Str" + inputHandler.getTargetName() + "String_Node_Str");
    return;
  }
  if (removeHydrogens) {
    query=new AtomContainer(AtomContainerManipulator.removeHydrogens(query));
    target=new AtomContainer(AtomContainerManipulator.removeHydrogens(target));
  }
  if (target.getProperty(CDKConstants.TITLE) != null) {
    target.setID((String)target.getProperty(CDKConstants.TITLE));
    argumentHandler.setTargetMolOutName(target.getID());
  }
  if (query.getProperty(CDKConstants.TITLE) != null) {
    query.setID((String)target.getProperty(CDKConstants.TITLE));
    argumentHandler.setQueryMolOutName(query.getID());
  }
  String out="String_Node_Str";
  if (!argumentHandler.isAppendMode()) {
    outputHandler.startAppending(out);
  }
 else {
    outputHandler.startNew(out);
  }
  CDKHueckelAromaticityDetector.detectAromaticity(query);
  CDKHueckelAromaticityDetector.detectAromaticity(target);
  AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(query);
  AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(target);
  if (argumentHandler.isApplyHAdding()) {
    AtomContainerManipulator.convertImplicitToExplicitHydrogens(query);
    AtomContainerManipulator.convertImplicitToExplicitHydrogens(target);
  }
  long startTime=System.currentTimeMillis();
  BaseMapping smsd=null;
  boolean matchBonds=argumentHandler.isMatchBondType();
  boolean matchRings=argumentHandler.isMatchRingType();
  if (argumentHandler.isSubstructureMode()) {
    smsd=runSubstructure(query,target,argumentHandler.getChemFilter(),matchBonds,matchRings);
  }
 else {
    smsd=run(query,target,argumentHandler.getChemFilter(),matchBonds,matchRings);
  }
  query=query.getBuilder().newInstance(IAtomContainer.class,smsd.getFirstAtomMapping().getQuery());
  target=target.getBuilder().newInstance(IAtomContainer.class,smsd.getFirstAtomMapping().getTarget());
  long endTime=System.currentTimeMillis();
  long executionTime=endTime - startTime;
  outputHandler.writeQueryMol(smsd.getFirstAtomMapping().getQuery());
  outputHandler.writeTargetMol(smsd.getFirstAtomMapping().getTarget());
  String queryPath=argumentHandler.getQueryFilepath();
  String targetPath=argumentHandler.getTargetFilepath();
  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);
    for (    AtomAtomMapping aam : smsd.getAllAtomMapping()) {
      Map<Integer,Integer> mapping=getIndexMapping(aam);
      int counter=0;
      if (argumentHandler.isImage()) {
        double stereoScore=smsd.getStereoScore(counter);
        String label=outputHandler.makeLabel(tanimotoSimilarity,stereoScore);
        outputHandler.addImage(query,target,label,mapping);
      }
      outputHandler.printMapping(counter++,mcs);
    }
  }
 else   if (mcs != null && !argumentHandler.isAllMapping()) {
    Map<Integer,Integer> mcsNumber=getIndexMapping(smsd.getFirstAtomMapping());
    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();
    outputHandler.writeImage(qName,tName);
  }
  if (argumentHandler.shouldOutputSubgraph()) {
    Map<Integer,Integer> mapping=getIndexMapping(smsd.getFirstAtomMapping());
    IAtomContainer subgraph=getSubgraph(target,mapping);
    String outpath=argumentHandler.getOutputFilepath();
    String outtype=argumentHandler.getOutputFiletype();
    outputHandler.writeMol(outtype,subgraph,outpath);
  }
  outputHandler.closeFiles();
}

Fixed version (ground truth):
public static void runSingleQuerySingleTarget(InputHandler inputHandler,OutputHandler outputHandler,ArgumentHandler argumentHandler) throws IOException, CDKException, CloneNotSupportedException {
  IAtomContainer query=inputHandler.getQuery();
  IAtomContainer target=inputHandler.getTarget();
  boolean removeHydrogens=argumentHandler.isApplyHRemoval();
  boolean flag=ConnectivityChecker.isConnected(query);
  if (!flag) {
    System.out.println("String_Node_Str" + inputHandler.getQueryName() + "String_Node_Str");
    return;
  }
  flag=ConnectivityChecker.isConnected(target);
  if (!flag) {
    System.out.println("String_Node_Str" + inputHandler.getTargetName() + "String_Node_Str");
    return;
  }
  if (removeHydrogens) {
    query=new AtomContainer(AtomContainerManipulator.removeHydrogens(query));
    target=new AtomContainer(AtomContainerManipulator.removeHydrogens(target));
  }
  if (target.getProperty(CDKConstants.TITLE) != null) {
    target.setID((String)target.getProperty(CDKConstants.TITLE));
    argumentHandler.setTargetMolOutName(target.getID());
  }
  if (query.getProperty(CDKConstants.TITLE) != null) {
    query.setID((String)query.getProperty(CDKConstants.TITLE));
    argumentHandler.setQueryMolOutName(query.getID());
  }
  String out="String_Node_Str";
  if (!argumentHandler.isAppendMode()) {
    outputHandler.startAppending(out);
  }
 else {
    outputHandler.startNew(out);
  }
  CDKHueckelAromaticityDetector.detectAromaticity(query);
  CDKHueckelAromaticityDetector.detectAromaticity(target);
  AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(query);
  AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(target);
  if (argumentHandler.isApplyHAdding()) {
    AtomContainerManipulator.convertImplicitToExplicitHydrogens(query);
    AtomContainerManipulator.convertImplicitToExplicitHydrogens(target);
  }
  long startTime=System.currentTimeMillis();
  BaseMapping smsd=null;
  boolean matchBonds=argumentHandler.isMatchBondType();
  boolean matchRings=argumentHandler.isMatchRingType();
  if (argumentHandler.isSubstructureMode()) {
    smsd=runSubstructure(query,target,argumentHandler.getChemFilter(),matchBonds,matchRings);
  }
 else {
    smsd=run(query,target,argumentHandler.getChemFilter(),matchBonds,matchRings);
  }
  query=query.getBuilder().newInstance(IAtomContainer.class,smsd.getFirstAtomMapping().getQuery());
  target=target.getBuilder().newInstance(IAtomContainer.class,smsd.getFirstAtomMapping().getTarget());
  long endTime=System.currentTimeMillis();
  long executionTime=endTime - startTime;
  outputHandler.writeQueryMol(smsd.getFirstAtomMapping().getQuery());
  outputHandler.writeTargetMol(smsd.getFirstAtomMapping().getTarget());
  String queryPath=argumentHandler.getQueryFilepath();
  String targetPath=argumentHandler.getTargetFilepath();
  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);
    for (    AtomAtomMapping aam : smsd.getAllAtomMapping()) {
      Map<Integer,Integer> mapping=getIndexMapping(aam);
      int counter=0;
      if (argumentHandler.isImage()) {
        double stereoScore=smsd.getStereoScore(counter);
        String label=outputHandler.makeLabel(tanimotoSimilarity,stereoScore);
        outputHandler.addImage(query,target,label,mapping);
      }
      outputHandler.printMapping(counter++,mcs);
    }
  }
 else   if (mcs != null && !argumentHandler.isAllMapping()) {
    Map<Integer,Integer> mcsNumber=getIndexMapping(smsd.getFirstAtomMapping());
    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();
    outputHandler.writeImage(qName,tName);
  }
  if (argumentHandler.shouldOutputSubgraph()) {
    Map<Integer,Integer> mapping=getIndexMapping(smsd.getFirstAtomMapping());
    IAtomContainer subgraph=getSubgraph(target,mapping);
    String outpath=argumentHandler.getOutputFilepath();
    String outtype=argumentHandler.getOutputFiletype();
    outputHandler.writeMol(outtype,subgraph,outpath);
  }
  outputHandler.closeFiles();
}