Commits

Daniel Lowe  committed f11be4e

Added support for both variants of the nitrolic acid suffix

  • Participants
  • Parent commits 2bd01f8

Comments (0)

Files changed (6)

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

 					}
 				}
 			}
+			else if (suffixValue.equals("nitrolic acid") || suffixValue.equals("nitrolicacid")) {
+				Element precedingGroup = OpsinTools.getPreviousSibling(suffix, GROUP_EL);
+				if (precedingGroup == null){
+					if (subOrRoot.getChildCount() != 1) {
+						throw new RuntimeException("OPSIN Bug: nitrolic acid not expected to have sibilings");
+					}
+					Element precedingSubstituent = OpsinTools.getPreviousSibling(subOrRoot);
+					if(precedingSubstituent == null || !precedingSubstituent.getName().equals(SUBSTITUENT_EL)){
+						throw new ComponentGenerationException("Expected substituent before nitrolic acid");
+					}
+
+					List<Element> existingSuffixes = precedingSubstituent.getChildElements(SUFFIX_EL);
+					if (existingSuffixes.size() == 1) {
+						if (!existingSuffixes.get(0).getValue().equals("yl")){
+							throw new ComponentGenerationException("Unexpected suffix found before nitrolic acid");
+						}
+						existingSuffixes.get(0).detach();
+						for (Element child : precedingSubstituent.getChildElements()) {
+							child.detach();
+							OpsinTools.insertBefore(suffix, child);
+						}
+						precedingSubstituent.detach();
+					}
+					else{
+						throw new ComponentGenerationException("Only the nitrolic acid case where it is preceded by an yl suffix is supported");
+					}
+				}
+			}
 		}
 	}
 

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

 		<token value="[SH3+]=O" labels="none">sulfoxonium</token>
 		<token value="[SH4]" labels="none">sulfurane</token>
 	</tokenList>
+
+  <tokenList tagname="suffix" type="root" subType="terminal" symbol="Ø"><!--Fudged by handleSuffixIrregularities such that the preceding subsituent is merged in front of this-->
+    <token value="nitrolic acid">nitrolic acid</token>
+    <token value="nitrolic acid">nitrolicacid</token>
+	</tokenList>
 </tokenLists>

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

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!DOCTYPE suffixApplicability SYSTEM "suffixApplicability.dtd">
 <!-- This file dictates what suffixes are applicabily to the group types that OPSIN recognises.
-There are currently 3 main types: acidStem, substituent, standardGroup.
-Other types are used under specific conditions e.g. chalcogenAcidStem, aminoAcid, mononuclearNonCarbonOxoAcid
+The two most important/common types are: acidStem and standardGroup.
+Other types are used under specific conditions e.g. chalcogenAcidStem, aminoAcid, carbohydrate, nonCarboxylicAcid, substituent
 If a type in OPSIN corresponds to a group type then it is used:
 Hence acidStem is OPSIN type acidStem
 All other groups are classified as standardGroup
     <suffix value="lactone">lactone</suffix>
     <suffix value="nitrile">nitrile</suffix>
     <suffix value="nitrilium">nitrilium</suffix>
+    <suffix value="nitrolic acid">nitrolic acid</suffix>
     <suffix value="onaphthone">onaphthone</suffix>
     <!-- one is handled by hard coding common examples of its use -->
     <suffix value="ophenone">ophenone</suffix>
     <suffix value="lactone">lactone</suffix>
     <suffix value="nitrile">nitrile</suffix>
     <suffix value="nitrilium">nitrilium</suffix>
+    <suffix value="nitrolic acid">nitrolic acid</suffix>
     <suffix value="ol">ol</suffix>
     <suffix value="olate">olate</suffix>
     <suffix value="olide">lactone</suffix>

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

     <addSuffixPrefixIfNonePresentAndCyclic SMILES="C"/>
     <addgroup SMILES="[*]#[NH+]"/>
   </rule>
+  <rule value="nitrolic acid">
+    <addSuffixPrefixIfNonePresentAndCyclic SMILES="C"/>
+    <addgroup SMILES="[*](=NO)[N+](=O)[O-]"/>
+  </rule>
   <rule value="ol">
     <addgroup SMILES="[*]O" />
   </rule>

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

     <token value="ic" additionalValue="anilide">anilic acid</token>
     <token value="ite">ite</token>
     <token value="ite">it</token>
+    <token value="nitrolic acid">nitrolic acid</token>
+    <token value="nitrolic acid">nitrolicacid</token>
     <token value="onaphthone">onaphthone</token>
     <token value="onaphthone">onaphthon</token>
     <token value="onaphthone">naphthone</token>

File opsin-inchi/src/test/resources/uk/ac/cam/ch/wwmm/opsin/miscellany.txt

 Hexafluorosilicic acid	InChI=1S/F6Si/c1-7(2,3,4,5)6/q-2/p+2
 Hexafluorophosphoric acid	InChI=1S/F6P/c1-7(2,3,4,5)6/q-1/p+1
 Hexafluorophosphoric acid triamide	InChI=1S/F6N3OP/c1-7(2)11(10,8(3)4)9(5)6
-phenyltrifluoroborate	InChI=1S/C6H5BF3/c8-7(9,10)6-4-2-1-3-5-6/h1-5H/q-1
+phenyltrifluoroborate	InChI=1S/C6H5BF3/c8-7(9,10)6-4-2-1-3-5-6/h1-5H/q-1
+ethylnitrolic acid	InChI=1S/C2H4N2O3/c1-2(3-5)4(6)7/h5H,1H3