Commits

Daniel Lowe committed 14fb128

Allowed carbohydrate "biochemical esters"
replaceAtomWithAnotherAtomPreservingConnectivity now updates stereochemistry involving the replaced atom

Comments (0)

Files changed (2)

opsin-core/src/main/java/uk/ac/cam/ch/wwmm/opsin/FragmentManager.java

 		}
 		List<Bond> bonds = atomToBeReplaced.getBonds();
 		for (Bond bond : bonds) {
+			Atom connectedAtom = bond.getOtherAtom(atomToBeReplaced);
+			if (connectedAtom.getAtomParity() != null){
+				Atom[] atomRefs4 = connectedAtom.getAtomParity().getAtomRefs4();
+				for (int i = 0 ; i < 4; i++) {
+					if (atomRefs4[i] == atomToBeReplaced){
+						atomRefs4[i] = replacementAtom;
+						break;
+					}
+				}
+			}
+			if (bond.getBondStereo() != null){
+				Atom[] atomRefs4 = bond.getBondStereo().getAtomRefs4();
+				for (int i = 0 ; i < 4; i++) {
+					if (atomRefs4[i] == atomToBeReplaced){
+						atomRefs4[i] = replacementAtom;
+						break;
+					}
+				}
+			}
 			createBond(replacementAtom, bond.getOtherAtom(atomToBeReplaced), bond.getOrder());
 		}
 		removeAtomAndAssociatedBonds(atomToBeReplaced);

opsin-core/src/main/resources/uk/ac/cam/ch/wwmm/opsin/resources/wordRules.xml

 
   <wordRule name="biochemicalEster" type="full">
     <word type="full" endsWithGroupSubType="biochemical"/>
-    <word type="full" endsWithRegex="\S((?&lt;!hydr)at[e]?|amid[e]?|it[e]?)[\]\)\}]*"/>
+    <word type="full" endsWithRegex="\S((?&lt;!hydr)at[e]?|amid[e]?|it[e]?|os[e]?id[e?])[\]\)\}]*"/>
   </wordRule>
 
   <wordRule name="biochemicalEster" type="full">
     <word type="full" endsWithGroupType="aminoAcid"/>
-    <word type="full" endsWithRegex="\S((?&lt;!hydr)at[e]?|amid[e]?|it[e]?)[\]\)\}]*"/>
+    <word type="full" endsWithRegex="\S((?&lt;!hydr)at[e]?|amid[e]?|it[e]?|os[e]?id[e?])[\]\)\}]*"/>
   </wordRule>
 
   <wordRule name="biochemicalEster" type="full">
     <word type="full" endsWithGroupSubType="carbohydrate"/>
-    <word type="full" endsWithRegex="\S((?&lt;!hydr)at[e]?|amid[e]?|it[e]?)[\]\)\}]*"/>
+    <word type="full" endsWithRegex="\S((?&lt;!hydr)at[e]?|amid[e]?|it[e]?|os[e]?id[e?])[\]\)\}]*"/>
   </wordRule>
 
   <wordRule name="polymer" type="polymer">