Program: 39451
Project: 39451
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.err.println("String_Node_Str" + inputHandler.getQueryName() + "String_Node_Str");
    return;
  }
  flag=ConnectivityChecker.isConnected(target);
  if (!flag) {
    System.err.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) {
    String fileName=target.getProperty(CDKConstants.TITLE) == null ? "String_Node_Str" : (String)target.getProperty(CDKConstants.TITLE);
    target.setID(fileName);
    argumentHandler.setTargetMolOutName(target.getID());
  }
  if (query.getProperty(CDKConstants.TITLE) != null) {
    String fileName=query.getProperty(CDKConstants.TITLE) == null ? "String_Node_Str" : (String)query.getProperty(CDKConstants.TITLE);
    query.setID(fileName);
    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;
  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);
    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();
    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.err.println("String_Node_Str" + inputHandler.getQueryName() + "String_Node_Str");
    return;
  }
  flag=ConnectivityChecker.isConnected(target);
  if (!flag) {
    System.err.println("String_Node_Str" + inputHandler.getTargetName() + "String_Node_Str");
    return;
  }
  String fileNameQ="String_Node_Str";
  String fileNameT="String_Node_Str";
  if (target.getProperty(CDKConstants.TITLE) != null) {
    fileNameQ=target.getProperty(CDKConstants.TITLE) == null ? fileNameT : (String)target.getProperty(CDKConstants.TITLE);
    target.setID(fileNameQ);
    argumentHandler.setTargetMolOutName(target.getID());
  }
  if (query.getProperty(CDKConstants.TITLE) != null) {
    fileNameT=query.getProperty(CDKConstants.TITLE) == null ? fileNameQ : (String)query.getProperty(CDKConstants.TITLE);
    query.setID(fileNameT);
    argumentHandler.setQueryMolOutName(query.getID());
  }
  if (removeHydrogens) {
    query=new AtomContainer(AtomContainerManipulator.removeHydrogens(query));
    query.setID(fileNameQ);
    target=new AtomContainer(AtomContainerManipulator.removeHydrogens(target));
    target.setID(fileNameT);
  }
  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;
  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);
    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();
    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();
}