Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding stereochemistryComments/'additional stereochemistry' to the def #367

Merged
merged 4 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import ix.core.chem.StructureProcessor;
import ix.core.models.Structure;
import ix.ginas.modelBuilders.ChemicalSubstanceBuilder;
import ix.ginas.modelBuilders.SubstanceBuilder;
import ix.ginas.models.v1.ChemicalSubstance;
import ix.ginas.models.v1.GinasChemicalStructure;
import ix.ginas.modelBuilders.MixtureSubstanceBuilder;
import ix.ginas.modelBuilders.StructurallyDiverseSubstanceBuilder;
import ix.ginas.modelBuilders.SubstanceBuilder;
import ix.ginas.models.v1.*;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -63,6 +65,40 @@ public void testOpticalInDefinitionalHashCalcNeg() throws Exception {
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 @@ -94,7 +130,56 @@ 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
public void testStereoCommentsInDefinitionalHashCalcPos() throws Exception {
String additionalStereochemistryKey="structure.properties.stereoComments";
String dataFileName ="R0NL28355M.json";
File proteinFile = new ClassPathResource("testJSON/" + dataFileName).getFile();
ChemicalSubstanceBuilder builder = SubstanceBuilder.from(proteinFile);

ChemicalSubstance chem =builder.build();
System.out.printf("atropisomerism: %s\n", chem.getStructure().atropisomerism);
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(additionalStereochemistryKey)));
}

@Test
public void testStereoCommentsInDefinitionalHashCalcNeg() throws Exception {
String additionalStereochemistryKey="structure.properties.stereoComments";
String dataFileName ="R0NL28355M.json";
File proteinFile = new ClassPathResource("testJSON/" + dataFileName).getFile();
ChemicalSubstanceBuilder builder = SubstanceBuilder.from(proteinFile);

ChemicalSubstance chem =builder.build();
chem.getStructure().atropisomerism= Structure.NYU.No;
System.out.printf("atropisomerism: %s\n", chem.getStructure().atropisomerism);
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.assertFalse(definitionalElements.stream().anyMatch(de->de.getKey().equals(additionalStereochemistryKey)));
}

@Test
public void testStereoCommentsInDefinitionalHashCalcNeg2() throws Exception {
String additionalStereochemistryKey="structure.properties.stereoComments";
String dataFileName ="R0NL28355M.json";
File proteinFile = new ClassPathResource("testJSON/" + dataFileName).getFile();
ChemicalSubstanceBuilder builder = SubstanceBuilder.from(proteinFile);

ChemicalSubstance chem =builder.build();
chem.getStructure().stereoComments = null;
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.assertFalse(definitionalElements.stream().anyMatch(de->de.getKey().equals(additionalStereochemistryKey)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

Marvin 01132111322D

9 9 0 0 0 0 999 V2000
7.3523 -4.5535 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
7.6081 -3.7619 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
6.9404 -3.2827 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.2700 -3.7619 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.5257 -4.5535 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
6.0411 -5.2212 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.3916 -3.5035 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.8370 -5.2212 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
7.5031 -5.9750 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 3 1 0 0 0 0
3 4 1 0 0 0 0
1 5 1 0 0 0 0
4 5 1 0 0 0 0
5 6 1 6 0 0 0
2 7 1 1 0 0 0
1 8 1 0 0 0 0
8 9 2 0 0 0 0
M END
Loading