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

changed call to featurize-nitrosamines #363

Merged
merged 2 commits into from
Aug 27, 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
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ void testOneMol() throws Exception{
structure.molfile = molfileText;
List<Map<String, String>> 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<Map<String, String>> properties = FeatureUtils.calculateFeatures( c1);
assertEquals(1, properties.size());
List<Map<String, String>> 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
Expand All @@ -45,9 +46,9 @@ void testFostamatibib() throws Exception {

List<Map<String, String>> 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
Expand All @@ -57,27 +58,41 @@ public void testIsPiperazine() throws Exception {
Chemical c1= Chemical.parse("N1CCNCC1");
List<Map<String, String>> 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<Map<String, String>> 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<Map<String, String>> 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<Map<String, String>> 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"));
}

}
2 changes: 1 addition & 1 deletion gsrs-module-substances-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
<dependency>
<groupId>gov.fda.gsrs</groupId>
<artifactId>Featureize-Nitrosamines</artifactId>
<version>0.0.2-SNAPSHOT</version>
<version>0.0.3-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,28 +12,22 @@
@Slf4j
public class FeatureUtils {
public static List<Map<String, String>> 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<FeatureResponse> response = FeaturizeNitrosamine.forMostPotentNitrosamine(chemical);
List<Map<String,String>> maps = new ArrayList<>();
if( response.isPresent()){
FeatureResponse r = response.get();
Map<String, String> 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<FeatureResponse> resp = FeaturizeNitrosamine.fingerprintNitrosamine(fj);

List<Map<String,String>> maps = new ArrayList<>();
resp.forEach(r->{
Map<String, String> 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;
}
}
2 changes: 1 addition & 1 deletion installExtraJars.cmd
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion installExtraJars.sh
Original file line number Diff line number Diff line change
@@ -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