@@ -91,6 +91,7 @@ private static Map<String, StringBuilder> buildStringBuilderMap(
91
91
int counter , firstOfEquivalenceIndexPyLSD ;
92
92
Set <Integer > groupMembers ; // use as a Set to remove the actual value and not at a list index
93
93
MolecularConnectivity molecularConnectivityGroupMember , molecularConnectivityHeavyAtom ;
94
+ final Map <Integer , Set <Integer >> addedBONDPairs = new HashMap <>();
94
95
final Set <Integer > addedKeysSHIH = new HashSet <>();
95
96
for (final int correlationIndex : molecularConnectivityMap .keySet ()) {
96
97
firstOfEquivalenceIndexPyLSD = -1 ;
@@ -234,18 +235,29 @@ private static Map<String, StringBuilder> buildStringBuilderMap(
234
235
!= null ) {
235
236
stringList = stringListMap .get ("BOND" );
236
237
for (final int bondedIndexInPyLSD : molecularConnectivity .getFixedNeighbors ()) {
237
- stringBuilder = new StringBuilder ();
238
- stringBuilder .append ("BOND " )
239
- .append (molecularConnectivity .getIndex ())
240
- .append (" " )
241
- .append (bondedIndexInPyLSD )
242
- .append (buildShiftsComment (molecularConnectivityMap , molecularConnectivity ,
243
- casekit .nmr .elucidation .Utilities .findMolecularConnectivityByIndex (
244
- molecularConnectivityMap , "H" , true ,
245
- bondedIndexInPyLSD )))
246
- .append ("\n " );
247
- if (!stringList .contains (stringBuilder .toString ())) {
248
- stringList .add (stringBuilder .toString ());
238
+ if (!addedBONDPairs .containsKey (molecularConnectivity .getIndex ())
239
+ || (addedBONDPairs .containsKey (molecularConnectivity .getIndex ())
240
+ && !addedBONDPairs .get (molecularConnectivity .getIndex ())
241
+ .contains (bondedIndexInPyLSD ))) {
242
+ stringBuilder = new StringBuilder ();
243
+ stringBuilder .append ("BOND " )
244
+ .append (molecularConnectivity .getIndex ())
245
+ .append (" " )
246
+ .append (bondedIndexInPyLSD )
247
+ .append (buildShiftsComment (molecularConnectivityMap , molecularConnectivity ,
248
+ casekit .nmr .elucidation .Utilities .findMolecularConnectivityByIndex (
249
+ molecularConnectivityMap , "H" , true ,
250
+ bondedIndexInPyLSD )))
251
+ .append ("\n " );
252
+ if (!stringList .contains (stringBuilder .toString ())) {
253
+ stringList .add (stringBuilder .toString ());
254
+ }
255
+ addedBONDPairs .putIfAbsent (molecularConnectivity .getIndex (), new HashSet <>());
256
+ addedBONDPairs .get (molecularConnectivity .getIndex ())
257
+ .add (bondedIndexInPyLSD );
258
+ addedBONDPairs .putIfAbsent (bondedIndexInPyLSD , new HashSet <>());
259
+ addedBONDPairs .get (bondedIndexInPyLSD )
260
+ .add (molecularConnectivity .getIndex ());
249
261
}
250
262
}
251
263
}
0 commit comments