Skip to content

Commit

Permalink
adjusted calculation of def hash based on stereochemistry: include
Browse files Browse the repository at this point in the history
optical activity when stereochemistry is 'UNKNOWN' based on request from
colleague
  • Loading branch information
ChemMitch committed Oct 29, 2024
1 parent 251f201 commit 808d623
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,43 @@ public void testOpticalInDefinitionalHashCalcNeg() throws Exception {
List<DefinitionalElement> definitionalElements = new ArrayList<>();
defHashCalculator.computeDefinitionalElements(chem, definitionalElements::add);
definitionalElements.forEach(de-> System.out.printf("key: %s = %s\n", de.getKey(), de.getValue()));
Assertions.assertTrue(definitionalElements.stream().noneMatch(de->de.getKey().equals(opticalActivityKey)));
}

@Test
public void testOpticalInDefinitionalHashCalcNeg2() throws Exception {
String opticalActivityKey="structure.properties.opticalActivity";
String structureJson = "{\n" +
" \"opticalActivity\": \"UNSPECIFIED\",\n" +
" \"molfile\": \"\\n ACCLDraw07282209012D\\n\\n 5 4 0 0 0 0 0 0 0 0999 V2000\\n 10.5000 -8.5938 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\\n 11.5229 -8.0032 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0\\n 11.5229 -6.8217 0.0000 Cl 0 0 0 0 0 0 0 0 0 0 0 0\\n 12.5460 -8.5939 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\\n 13.5692 -8.0032 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\\n 1 2 1 0 0 0 0\\n 2 3 1 0 0 0 0\\n 2 4 1 0 0 0 0\\n 4 5 1 0 0 0 0\\nM END\",\n" +
" \"stereoCenters\": 1,\n" +
" \"definedStereo\": 0,\n" +
" \"ezCenters\": 0,\n" +
" \"charge\": 0,\n" +
" \"mwt\": 92.56726,\n" +
" \"count\": 1,\n" +
" \"stereochemistry\": \"UNKNOWN\"\n" +
"}\n" +
"";
ObjectMapper om = new ObjectMapper();
Structure rawStructure = om.readValue(structureJson, Structure.class);
Structure instrumentedStructure =structureProcessor.instrument(rawStructure.toChemical(), true);
GinasChemicalStructure ginasChemicalStructure = new GinasChemicalStructure(instrumentedStructure);
ginasChemicalStructure.setStereoChemistry(Structure.Stereo.UNKNOWN);

ChemicalSubstanceBuilder builder = new ChemicalSubstanceBuilder();
ChemicalSubstance chem =builder
.setStructure(ginasChemicalStructure)
.addName("2-chlorobutane")
.build();
ChemicalSubstanceDefinitionalElementImpl defHashCalculator = new ChemicalSubstanceDefinitionalElementImpl();
List<DefinitionalElement> definitionalElements = new ArrayList<>();
defHashCalculator.computeDefinitionalElements(chem, definitionalElements::add);
definitionalElements.forEach(de-> System.out.printf("key: %s = %s\n", de.getKey(), de.getValue()));
Assertions.assertTrue(definitionalElements.stream().anyMatch(de->de.getKey().equals(opticalActivityKey)));
}


@Test
public void testOpticalInDefinitionalHashCalcPos() throws Exception {
String opticalActivityKey="structure.properties.opticalActivity";
Expand Down Expand Up @@ -96,7 +130,7 @@ public void testOpticalInDefinitionalHashCalcPos() throws Exception {
List<DefinitionalElement> definitionalElements = new ArrayList<>();
defHashCalculator.computeDefinitionalElements(chem, definitionalElements::add);
definitionalElements.forEach(de-> System.out.printf("key: %s = %s\n", de.getKey(), de.getValue()));
Assertions.assertTrue(definitionalElements.stream().anyMatch(de->de.getKey().equals(opticalActivityKey)));
Assertions.assertTrue(definitionalElements.stream().noneMatch(de->de.getKey().equals(opticalActivityKey)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
@Slf4j
Expand All @@ -18,7 +19,8 @@ public class ChemicalSubstanceDefinitionalElementImpl implements DefinitionalEle
@Autowired
private StructureProcessor structureProcessor;

private List<String> stereoUsingOpticalActivities = Arrays.asList( "UNKNOWN", "MIXED", "EPIMERIC", "RACEMIC");
private List<String> stereoUsingOpticalActivities = Collections.singletonList("UNKNOWN");
//changed to UNKNOWN based on Slack conversation on 29 Oct 2024 Arrays.asList( "UNKNOWN", "MIXED", "EPIMERIC", "RACEMIC");

@Override
public boolean supports(Object s) {
Expand Down

0 comments on commit 808d623

Please sign in to comment.