@@ -450,6 +450,14 @@ private void resetFLAGS(Holder mh) throws Exception {
450450 }
451451 }
452452
453+ protected final String canonicalMatchedSmiles (
454+ ICanonicalMoleculeLabeller canonLabeler ,
455+ IAtomContainer matchedPart ) throws Exception {
456+ IAtomContainer canonical = canonLabeler .getCanonicalMolecule (matchedPart );
457+ CDKSMILES cdkSmiles = new CDKSMILES (canonical , true , false );
458+ return cdkSmiles .getCanonicalSMILES ();
459+ }
460+
453461 private void refillMatrixWithOldData (Holder holder , int substrateIndex , int productIndex ) {
454462 LOGGER .debug ("**********REFILL MCS And Calculate Similarity**************" );
455463 try {
@@ -722,19 +730,11 @@ private void UpdateMapping() throws Exception {
722730 delta += GM .removeMatchedAtomsAndUpdateAAM (reaction );
723731 List <MolMapping > rMap = getReactionMolMapping ().
724732 getMapping (rid , this .eductList .get (substrateIndex ), this .productList .get (productIndex ));
725- rMap .stream ().map ((map ) -> {
733+ String matchedSmiles = canonicalMatchedSmiles (canonLabeler , GM .getMatchedPart ());
734+ for (MolMapping map : rMap ) {
726735 map .setReactionMapping (true );
727- return map ;
728- }).forEach ((map ) -> {
729- try {
730- IAtomContainer mol = GM .getMatchedPart ();
731- mol = canonLabeler .getCanonicalMolecule (mol );
732- CDKSMILES cdkSmiles = new CDKSMILES (mol , true , false );
733- map .setMatchedSMILES (cdkSmiles .getCanonicalSMILES (), ++stepIndex );
734- } catch (CloneNotSupportedException e ) {
735- LOGGER .error ("Error in cloning molecule: " , e .getMessage ());
736- }
737- });
736+ map .setMatchedSMILES (matchedSmiles , ++stepIndex );
737+ }
738738 }
739739 IAtomContainer remainingEduct = GM .getRemainingEduct ();
740740 IAtomContainer remainingProduct = GM .getRemainingProduct ();
@@ -885,12 +885,10 @@ private void UpdateMapping() throws Exception {
885885 delta += graphMatching .removeMatchedAtomsAndUpdateAAM (reaction );
886886 List <MolMapping > rMap = getReactionMolMapping ().
887887 getMapping (reactionName , this .eductList .get (substrateIndex ), this .productList .get (productIndex ));
888+ String matchedSmiles = canonicalMatchedSmiles (canonLabeler , graphMatching .getMatchedPart ());
888889 for (MolMapping map : rMap ) {
889890 map .setReactionMapping (true );
890- IAtomContainer mol = graphMatching .getMatchedPart ();
891- mol = canonLabeler .getCanonicalMolecule (mol );
892- CDKSMILES cdkSmiles = new CDKSMILES (mol , true , false );
893- map .setMatchedSMILES (cdkSmiles .getCanonicalSMILES (), ++stepIndex );
891+ map .setMatchedSMILES (matchedSmiles , ++stepIndex );
894892 }
895893 }
896894 IAtomContainer remainingEduct = graphMatching .getRemainingEduct ();
@@ -1032,12 +1030,10 @@ private void UpdateMapping() throws Exception {
10321030 delta += GM .removeMatchedAtomsAndUpdateAAM (reaction );
10331031 List <MolMapping > rMap = getReactionMolMapping ().
10341032 getMapping (RID , this .eductList .get (substrateIndex ), this .productList .get (productIndex ));
1033+ String matchedSmiles = canonicalMatchedSmiles (canonLabeler , GM .getMatchedPart ());
10351034 for (MolMapping map : rMap ) {
10361035 map .setReactionMapping (true );
1037- IAtomContainer mol = GM .getMatchedPart ();
1038- mol = canonLabeler .getCanonicalMolecule (mol );
1039- CDKSMILES cdkSmiles = new CDKSMILES (mol , true , false );
1040- map .setMatchedSMILES (cdkSmiles .getCanonicalSMILES (), ++stepIndex );
1036+ map .setMatchedSMILES (matchedSmiles , ++stepIndex );
10411037 }
10421038 }
10431039 IAtomContainer RemainingEduct = GM .getRemainingEduct ();
@@ -1178,12 +1174,10 @@ private void UpdateMapping() throws Exception {
11781174 delta += GM .removeMatchedAtomsAndUpdateAAM (reaction );
11791175 List <MolMapping > rMap = getReactionMolMapping ().
11801176 getMapping (RID , this .eductList .get (substrateIndex ), this .productList .get (productIndex ));
1177+ String matchedSmiles = canonicalMatchedSmiles (canonLabeler , GM .getMatchedPart ());
11811178 for (MolMapping map : rMap ) {
11821179 map .setReactionMapping (true );
1183- IAtomContainer mol = GM .getMatchedPart ();
1184- mol = canonLabeler .getCanonicalMolecule (mol );
1185- CDKSMILES cdkSmiles = new CDKSMILES (mol , true , false );
1186- map .setMatchedSMILES (cdkSmiles .getCanonicalSMILES (), ++stepIndex );
1180+ map .setMatchedSMILES (matchedSmiles , ++stepIndex );
11871181 }
11881182 }
11891183 IAtomContainer remainingEduct = GM .getRemainingEduct ();
0 commit comments