Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/Featureize-Nitrosamines.iml
/target/
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<groupId>gov.fda.gsrs</groupId>
<artifactId>Featureize-Nitrosamines</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.4-SNAPSHOT</version>

<name>Featurize-Nitrosamines</name>

Expand Down
71 changes: 69 additions & 2 deletions src/main/java/gov/fda/gsrs/ndsri/FeaturizeNitrosamine.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,24 @@ public FeatureJob(String name, Chemical c,int forceC, boolean useMap, boolean ad
}
}

public static FeatureJob forOneNitrosamine(Chemical c){
c.atoms().forEach(a->a.setAtomToAtomMap(0));
List<Integer> sites = markAllNitrosamines(c);

List<Chemical> chems = new ArrayList<>();
for(int m:sites){
chems.add(removeNitrosamine(c.copy(), m));
}
if(chems.size()!=1){
System.out.println(chems.size());
throw new IllegalArgumentException("Wrong number of nitrosamines for this method. Expected 1.");
}
FeatureJob fj = new FeatureJob(chems.get(0));
fj.addNitrosamine=true;
fj.useMap=true;

return fj;
}
}


Expand Down Expand Up @@ -521,8 +539,7 @@ public static List<FeatureResponse> fingerprintNitrosamine(FeatureJob fj) throws
}
}
}


System.out.printf("computed type: %s\n", type);

if(atList.size()>0 || !got){
int i=1;
Expand Down Expand Up @@ -1750,4 +1767,54 @@ public static void run(Stream<String> inputStream, ParsedOptions parsedOptions)

}
}

public static Optional<FeatureResponse> forMostPotentNitrosamine(Chemical c){
c.atoms().forEach(a->a.setAtomToAtomMap(0));
List<Integer> sites = markAllNitrosamines(c);
if(sites.isEmpty()){
throw new IllegalArgumentException("Wrong number of nitrosamines for this method. Expected 1 or more.");
}

List<Chemical> chems = new ArrayList<>();
for(int m:sites){
chems.add(removeNitrosamine(c.copy(), m));
}

return chems.stream()
.map(cc->new FeatureJob(cc))
.peek(fj->fj.addNitrosamine=false)
.peek(fj->fj.useMap=true)
.map(fj->{

try{
return FeaturizeNitrosamine.fingerprintNitrosamine(fj);
}catch(Exception e){
return new ArrayList<FeatureResponse>();
}
})
.flatMap(r->r.stream())
.filter(r->!(r.getType().startsWith("B") || r.getType().startsWith("C"))) //eliminate amides and amide-like items
.sorted(Comparator.comparing(fr->fr.getCategoryScore()))
.findFirst()
.map(fr->{
if(fr.getCategoryScore()==1){
fr.addFeature("AI Limit (US)", "26.5 ng/day");
}else if(fr.getCategoryScore()==2){
fr.addFeature("AI Limit (US)", "100 ng/day");
}else if(fr.getCategoryScore()==3){
fr.addFeature("AI Limit (US)", "400 ng/day");
}else if(fr.getCategoryScore()==4){
fr.addFeature("AI Limit (US)", "1500 ng/day");
}else if(fr.getCategoryScore()==5){
fr.addFeature("AI Limit (US)", "1500 ng/day");
}
if(chems.size()==1){
fr.setType("Single N-nitroso group");
}else{
fr.setType("Most potent of multiple N-nitroso groups");
}
return fr;
});
}

}
127 changes: 117 additions & 10 deletions src/test/java/gov/nih/ncats/molwitch/renderer/FeatureParsingTests.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package gov.nih.ncats.molwitch.renderer;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import org.apache.commons.io.IOUtils;
import org.junit.Ignore;
import org.junit.Test;

Expand All @@ -18,8 +20,48 @@
import gov.fda.gsrs.ndsri.FeaturizeNitrosamine.FeatureResponse;
import gov.nih.ncats.molwitch.Chemical;

import static org.junit.Assert.*;

public class FeatureParsingTests {


private static class TestMol {
private String molFileName;
private boolean expectData;
private String description;

public TestMol(String molFileName, boolean expectData, String description) {
this.molFileName = molFileName;
this.expectData = expectData;
this.description = description;
}

public String getMolFileName() {
return molFileName;
}

public void setMolFileName(String molFileName) {
this.molFileName = molFileName;
}

public boolean isExpectData() {
return expectData;
}

public void setExpectData(boolean expectData) {
this.expectData = expectData;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

}

@Test
@Ignore
public void testExportAtomMaps() throws IOException {
Expand Down Expand Up @@ -55,8 +97,7 @@ public void testIVACAFTORType() throws Exception {

FeatureResponse resp1= resp.get(0);
resp1.getChemical();
// for()


assertEquals(1,resp.size());
assertEquals("A. Secondary Amine" ,resp1.getType());
assertEquals("0,1" ,resp1.getFeature(FeaturizeNitrosamine.FeaturePairRegistry.ALPHA_HYDROGENS.getFeatureName()).orElse(null));
Expand All @@ -75,8 +116,9 @@ public void testFostamatibib() throws Exception {
assertEquals("A. Multiple Secondary Amine" ,resp1.getType());
assertEquals("0,0" ,resp1.getFeature(FeaturizeNitrosamine.FeaturePairRegistry.ALPHA_HYDROGENS.getFeatureName()).orElse(null));
}

@Test


@Test
public void testSP3CarbonOnSmallRing() throws Exception {
Chemical c1= Chemical.parse("C1CCCCC1");

Expand All @@ -93,7 +135,7 @@ public void testSP3CarbonOnSmallHeteroRing() throws Exception {
}

@Test
public void testisPiperazine() throws Exception {
public void testIsPiperazine() throws Exception {
FeaturizeNitrosamine.GLOBAL_SETTINGS.DO_EXTENDED_FEATURES_TOO=true;

Chemical c1= Chemical.parse("N1CCNCC1");
Expand All @@ -116,8 +158,6 @@ public void testisPiperazine() throws Exception {
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");

//TODO: This should really work even without this part
// c1.generateCoordinates();
FeatureJob fj = new FeatureJob(c1);

List<FeatureResponse> resp = FeaturizeNitrosamine.fingerprintNitrosamine(fj);
Expand Down Expand Up @@ -316,4 +356,71 @@ public void testAbacavirSulfateSecondaryAmine() throws Exception {
assertEquals("0,1" ,resp1.getFeature(FeaturizeNitrosamine.FeaturePairRegistry.ALPHA_HYDROGENS.getFeatureName()).orElse(null));
}
//NC1=NC2=C(N=CN2[C@@H]3C[C@H](CO)C=C3)C(NC4CC4)=N1

@Test
public void testTartaricAcid() throws Exception {
//we expect this molecule not to have any nitrosamine potential whatsoever
Chemical c1= Chemical.parse("[C@@H]([C@H](C(=O)O)O)(C(=O)O)O");

FeatureJob fj = new FeatureJob(c1);

List<FeatureResponse> resp = FeaturizeNitrosamine.fingerprintNitrosamine(fj);

assertNotNull(resp);
System.out.println("got output");
assertTrue( resp.isEmpty());
}

@Test
public void testAmide() throws Exception {
//we expect this molecule not to have any nitrosamine potential whatsoever
Chemical c1= Chemical.parse("C(C)CCN(C(N)=N)N=O");

FeatureJob fj = new FeatureJob(c1);

List<FeatureResponse> resp = FeaturizeNitrosamine.fingerprintNitrosamine(fj);

assertNotNull(resp);
System.out.println("got output");
assertTrue( resp.isEmpty());
}

@Test
public void testNitrosamine() throws Exception {
Chemical testChemical = Chemical.parse("CCN(CC)N=O");
FeatureJob job = new FeatureJob(testChemical);
List<FeatureResponse> responses = FeaturizeNitrosamine.fingerprintNitrosamine(job);
assertNotNull(responses);
for(FeatureResponse resp: responses) {
System.out.printf("type: %s\n", resp.getType());
}
}

@Test
public void testNitrosamideSetFromMolfile() throws Exception {
List<TestMol> testData = Arrays.asList(new TestMol("nitrosamiide-like", false,
"nitrosamide-like with S expects no output"),
new TestMol("nitrosamiide-like2", false,
"nitrosamide-like with N expects no output"),
new TestMol("nitrosamine_amide", false, "amides are currently not supported by model"),
new TestMol("nitrosamine1", true, "nitrosamine produces output"));
testData.forEach(m->{
try {
InputStream stream = getClass().getResourceAsStream("/molfiles/" + m.molFileName + ".mol");
String molfileText = IOUtils.toString(stream, "UTF-8");
Chemical testChemical = Chemical.parse(molfileText);
Optional<FeatureResponse> response = FeaturizeNitrosamine.forMostPotentNitrosamine(testChemical);
assertEquals(m.expectData, response.isPresent());
} catch (Exception ex){
Logger.getLogger(this.getClass().getName()).warning(String.format("failure for %s", m.description));
fail();
}
});
/*InputStream stream =getClass().getResourceAsStream("/molfiles/nitrosamiide-like.mol");
String molfileText = IOUtils.toString(stream, "UTF-8");
Chemical testChemical = Chemical.parse(molfileText);
Optional<FeatureResponse> response = FeaturizeNitrosamine.forMostPotentNitrosamine(testChemical);
assertFalse(response.isPresent());*/
}

}
24 changes: 24 additions & 0 deletions src/test/resources/molfiles/nitrosamiide.mol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

ACCLDraw10032421372D

10 9 0 0 0 0 0 0 0 0999 V2000
11.1697 -12.9221 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
10.3721 -13.3822 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
11.9677 -13.3824 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.7657 -12.9221 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.5637 -13.3824 0.0000 N 0 0 3 0 0 0 0 0 0 0 0 0
13.5637 -14.3037 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.7690 -14.7655 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
14.3618 -12.9221 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
15.1592 -13.3822 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
14.3634 -14.7643 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 3 1 0 0 0 0
3 4 1 0 0 0 0
4 5 1 0 0 0 0
5 6 1 0 0 0 0
6 7 1 0 0 0 0
5 8 1 0 0 0 0
8 9 2 0 0 0 0
6 10 2 0 0 0 0
M END
24 changes: 24 additions & 0 deletions src/test/resources/molfiles/nitrosamine1.mol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

ACCLDraw10032414512D

10 9 0 0 0 0 0 0 0 0999 V2000
10.4139 -10.4343 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
9.6163 -10.8944 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
11.2119 -10.8946 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.0099 -10.4343 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.8079 -10.8946 0.0000 N 0 0 3 0 0 0 0 0 0 0 0 0
12.8098 -11.8159 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
12.0132 -12.2777 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
13.6060 -10.4343 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
14.4034 -10.8944 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
13.6076 -12.2765 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 3 1 0 0 0 0
3 4 1 0 0 0 0
4 5 1 0 0 0 0
5 6 1 0 0 0 0
6 7 1 0 0 0 0
5 8 1 0 0 0 0
8 9 2 0 0 0 0
6 10 1 0 0 0 0
M END
24 changes: 24 additions & 0 deletions src/test/resources/molfiles/nitrosamine_amide.mol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

ACCLDraw10032421262D

10 9 0 0 0 0 0 0 0 0999 V2000
11.1697 -12.9221 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
10.3721 -13.3822 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
11.9677 -13.3824 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.7657 -12.9221 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
13.5637 -13.3824 0.0000 N 0 0 3 0 0 0 0 0 0 0 0 0
13.5637 -14.3037 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
12.7690 -14.7655 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
14.3618 -12.9221 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
15.1592 -13.3822 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
14.3634 -14.7643 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 3 1 0 0 0 0
3 4 1 0 0 0 0
4 5 1 0 0 0 0
5 6 1 0 0 0 0
6 7 1 0 0 0 0
5 8 1 0 0 0 0
8 9 2 0 0 0 0
6 10 2 0 0 0 0
M END