public void calculateOverlapsAndReduce ( IAtomContainer molecule1 , IAtomContainer molecule2 , boolean shouldMatchBonds ) throws CDKException { setSource ( molecule1 ) ; setTarget ( molecule2 ) ; setMappings ( new ArrayList < Map < Integer , Integer > > ( ) ) ; if ( ( getSource ( ) . getAtomCount ( ) == 1 ) || ( getTarget ( ) . getAtomCount ( ) == 1 ) ) { List < CDKRMap > overlaps = CDKMCS . checkSingleAtomCases ( getSource ( ) , getTarget ( ) ) ; int nAtomsMatched = overlaps . size ( ) ; nAtomsMatched = ( nAtomsMatched > 0 ) ? 1 : 0 ; if ( nAtomsMatched > 0 ) { /* UnComment this to get one Unique Mapping */ //List reducedList = removeRedundantMappingsForSingleAtomCase(overlaps); //int counter = 0; identifySingleAtomsMatchedParts ( overlaps , getSource ( ) , getTarget ( ) ) ; } } else { List < List < CDKRMap >> overlaps = CDKMCS . search ( getSource ( ) , getTarget ( ) , new BitSet ( ) , new BitSet ( ) , true , true , shouldMatchBonds ) ; List < List < CDKRMap > > reducedList = removeSubGraph ( overlaps ) ; Stack < List < CDKRMap > > allMaxOverlaps = getAllMaximum ( reducedList ) ; while ( ! allMaxOverlaps . empty ( ) ) { // System.out.println("source: " + source.getAtomCount() + ", target: " + target.getAtomCount() + ", overl: " + allMaxOverlaps.peek().size()); List < List < CDKRMap >> maxOverlapsAtoms = makeAtomsMapOfBondsMap ( allMaxOverlaps . peek ( ) , getSource ( ) , getTarget ( ) ) ; // System.out.println("size of maxOverlaps: " + maxOverlapsAtoms.size()); identifyMatchedParts ( maxOverlapsAtoms , getSource ( ) , getTarget ( ) ) ; // identifyMatchedParts(allMaxOverlaps.peek(), source, target); allMaxOverlaps . pop ( ) ; } } FinalMappings . getInstance ( ) . set ( getMappings ( ) ) ; }
This function calculates all the possible combinations of MCS