diff --git a/extraJars/Featureize-Nitrosamines-0.0.2-SNAPSHOT.jar b/extraJars/Featureize-Nitrosamines-0.0.3-SNAPSHOT.jar similarity index 94% rename from extraJars/Featureize-Nitrosamines-0.0.2-SNAPSHOT.jar rename to extraJars/Featureize-Nitrosamines-0.0.3-SNAPSHOT.jar index eed7d149..f72cbb73 100644 Binary files a/extraJars/Featureize-Nitrosamines-0.0.2-SNAPSHOT.jar and b/extraJars/Featureize-Nitrosamines-0.0.3-SNAPSHOT.jar differ diff --git a/gsrs-module-substance-example/src/test/java/example/chem/FeatureGenerationTest.java b/gsrs-module-substance-example/src/test/java/example/chem/FeatureGenerationTest.java index 4ee34606..8f5202dd 100644 --- a/gsrs-module-substance-example/src/test/java/example/chem/FeatureGenerationTest.java +++ b/gsrs-module-substance-example/src/test/java/example/chem/FeatureGenerationTest.java @@ -26,17 +26,18 @@ void testOneMol() throws Exception{ structure.molfile = molfileText; List> properties = FeatureUtils.calculateFeatures( structure.toChemical()); //properties.get(0).entrySet().forEach(e-> System.out.printf("key: %s = value: %s\n", e.getKey(), e.getValue())); - Assertions.assertEquals("5", properties.get(0).get("categoryScore")); + //Assertions.assertEquals("5", properties.get(0).get("categoryScore")); + Assertions.assertTrue(properties.isEmpty()); } @Test void testIVACAFTORType() throws Exception { Chemical c1= Chemical.parse("c1ccc2c(c1)c(=O)cc[nH]2"); - - List> properties = FeatureUtils.calculateFeatures( c1); - assertEquals(1, properties.size()); + List> properties = FeatureUtils.calculateFeatures( c1); + Assertions.assertTrue(properties.isEmpty()); + /*assertEquals(1, properties.size()); assertEquals("A. Secondary Amine" ,properties.get(0).get("type")); - assertEquals("0,1", properties.get(0).get("Alpha-Hydrogens")); + assertEquals("0,1", properties.get(0).get("Alpha-Hydrogens"));*/ } @Test @@ -45,9 +46,9 @@ void testFostamatibib() throws Exception { List> properties = FeatureUtils.calculateFeatures( c1); - assertEquals(2,properties.size()); - assertEquals("A. Multiple Secondary Amine", properties.get(0).get("type")); - assertEquals("0,0", properties.get(0).get("Alpha-Hydrogens")); + assertEquals(0, properties.size()); + /*assertEquals("A. Multiple Secondary Amine", properties.get(0).get("type")); + assertEquals("0,0", properties.get(0).get("Alpha-Hydrogens"));*/ } @Test @@ -57,27 +58,41 @@ public void testIsPiperazine() throws Exception { Chemical c1= Chemical.parse("N1CCNCC1"); List> properties = FeatureUtils.calculateFeatures( c1); - assertEquals(2,properties.size()); - assertEquals("A. Multiple Secondary Amine", properties.get(0).get("type")); + assertEquals(0, properties.size()); + /*assertEquals("A. Multiple Secondary Amine", properties.get(0).get("type")); assertEquals("2,2", properties.get(0).get("Alpha-Hydrogens")); - assertEquals("YES", properties.get(0).get( FeaturizeNitrosamine.FeaturePairRegistry.PIPERAZINE.getFeatureName())); + assertEquals("YES", properties.get(0).get( FeaturizeNitrosamine.FeaturePairRegistry.PIPERAZINE.getFeatureName()));*/ } @Test public void testCarboxylicAcidOnSaltDoesNotCount() throws Exception { Chemical c1= Chemical.parse("O[C@H]([C@@H](O)C(O)=O)C(O)=O.COC1=CC=C(C[C@@H](C)[NH:20]C[C@H](O)C2=CC=C(O)C(NC=O)=C2)C=C1"); List> properties = FeatureUtils.calculateFeatures( c1); - assertEquals(1, properties.size()); - assertEquals("A. Secondary Amine", properties.get(0).get("type")); - assertEquals("NO" ,properties.get(0).get(FeaturizeNitrosamine.FeaturePairRegistry.COOH.getFeatureName())); + assertEquals(0, properties.size()); + /*assertEquals("A. Secondary Amine", properties.get(0).get("type")); + assertEquals("NO" ,properties.get(0).get(FeaturizeNitrosamine.FeaturePairRegistry.COOH.getFeatureName()));*/ } @Test public void testBenzylLikeFeatureShouldNotFindPsuedoAromaticity() throws Exception { Chemical c1= Chemical.parse("C[C@H]([NH:3]C1=C2N=CNC2=NC=N1)C3=CC4=C(C(Cl)=CC=C4)C(=O)N3C5=CC=CC=C5"); List> properties = FeatureUtils.calculateFeatures( c1); - assertEquals(1, properties.size()); - assertEquals("A. Secondary Amine", properties.get(0).get("type")); - assertEquals("NO", properties.get(0).get(FeaturizeNitrosamine.FeaturePairRegistry.ARYL_ALPHA.getFeatureName())); + assertEquals(0, properties.size()); + /*assertEquals("A. Secondary Amine", properties.get(0).get("type")); + assertEquals("NO", properties.get(0).get(FeaturizeNitrosamine.FeaturePairRegistry.ARYL_ALPHA.getFeatureName()));*/ } + + @Test + void testOneRealNitrosamine() throws Exception{ + String molfileText = IOUtils.toString( + this.getClass().getResourceAsStream("/molfiles/M8LE2AF05P.mol"), + "UTF-8" + ); + GinasChemicalStructure structure = new GinasChemicalStructure(); + structure.molfile = molfileText; + List> properties = FeatureUtils.calculateFeatures( structure.toChemical()); + //properties.get(0).entrySet().forEach(e-> System.out.printf("key: %s = value: %s\n", e.getKey(), e.getValue())); + Assertions.assertEquals("5", properties.get(0).get("categoryScore")); + } + } diff --git a/gsrs-module-substances-core/pom.xml b/gsrs-module-substances-core/pom.xml index 378d787f..04d3a5a6 100644 --- a/gsrs-module-substances-core/pom.xml +++ b/gsrs-module-substances-core/pom.xml @@ -332,7 +332,7 @@ gov.fda.gsrs Featureize-Nitrosamines - 0.0.2-SNAPSHOT + 0.0.3-SNAPSHOT diff --git a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/utils/FeatureUtils.java b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/utils/FeatureUtils.java index 039155ac..d28a299a 100644 --- a/gsrs-module-substances-core/src/main/java/gsrs/module/substance/utils/FeatureUtils.java +++ b/gsrs-module-substances-core/src/main/java/gsrs/module/substance/utils/FeatureUtils.java @@ -2,10 +2,8 @@ import gov.nih.ncats.molwitch.Chemical; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; + import gov.fda.gsrs.ndsri.FeaturizeNitrosamine; import gov.fda.gsrs.ndsri.FeaturizeNitrosamine.FeatureJob; import gov.fda.gsrs.ndsri.FeaturizeNitrosamine.FeatureResponse; @@ -14,28 +12,22 @@ @Slf4j public class FeatureUtils { public static List> calculateFeatures(Chemical chemical) throws Exception{ - FeatureJob fj; - try{ - fj = FeatureJob.forOneNitrosamine(chemical); - } catch (Exception ex) { - //log.info("forOneNitrosamine failed; using regular constructor"); - //fj = new FeatureJob(chemical); - //For now, don't generate properties unless it's a legitimate NNO + try { + Optional response = FeaturizeNitrosamine.forMostPotentNitrosamine(chemical); + List> maps = new ArrayList<>(); + if( response.isPresent()){ + FeatureResponse r = response.get(); + Map ret = new HashMap<>(); + r.getFeatureSet().entrySet().forEach(e-> ret.put(e.getKey(), e.getValue())); + ret.put("categoryScore", Integer.toString( r.getCategoryScore())); + ret.put("sumOfScores", Integer.toString(r.getSumOfScores())); + ret.put("type", r.getType()); + maps.add(ret); + } + return maps; + } catch (IllegalArgumentException ex) { return new ArrayList<>(); } - - List resp = FeaturizeNitrosamine.fingerprintNitrosamine(fj); - - List> maps = new ArrayList<>(); - resp.forEach(r->{ - Map ret = new HashMap<>(); - r.getFeatureSet().entrySet().forEach(e-> ret.put(e.getKey(), e.getValue())); - ret.put("categoryScore", Integer.toString( r.getCategoryScore())); - ret.put("sumOfScores", Integer.toString(r.getSumOfScores())); - ret.put("type", r.getType()); - maps.add(ret); - }); - return maps; } } diff --git a/installExtraJars.cmd b/installExtraJars.cmd index cdc9524e..eb1a7292 100755 --- a/installExtraJars.cmd +++ b/installExtraJars.cmd @@ -1,4 +1,4 @@ mvnw.cmd install:install-file -Dfile=extraJars/applications-api-3.1-SNAPSHOT.jar mvnw.cmd install:install-file -Dfile=extraJars/products-api-3.1.1-SNAPSHOT.jar mvnw.cmd install:install-file -Dfile=extraJars/clinical-trials-api-3.1.1-SNAPSHOT.jar -mvnw.cmd install:install-file -Dfile=extraJars/Featureize-Nitrosamines-0.0.2-SNAPSHOT.jar +mvnw.cmd install:install-file -Dfile=extraJars/Featureize-Nitrosamines-0.0.3-SNAPSHOT.jar diff --git a/installExtraJars.sh b/installExtraJars.sh index 7e95c4d9..1aa35dfc 100755 --- a/installExtraJars.sh +++ b/installExtraJars.sh @@ -1,4 +1,4 @@ ./mvnw install:install-file -Dfile=extraJars/applications-api-3.1-SNAPSHOT.jar ./mvnw install:install-file -Dfile=extraJars/products-api-3.1.1-SNAPSHOT.jar ./mvnw install:install-file -Dfile=extraJars/clinical-trials-api-3.1.1-SNAPSHOT.jar -./mvnw install:install-file -Dfile=extraJars/Featureize-Nitrosamines-0.0.2-SNAPSHOT.jar +./mvnw install:install-file -Dfile=extraJars/Featureize-Nitrosamines-0.0.3-SNAPSHOT.jar