Skip to content

Commit

Permalink
fix bug 3073, HandlerTest method -> manager test
Browse files Browse the repository at this point in the history
Moved the HandlerTest method in the manager test cause it actually only tested if the SMILES file was loaded with properties and it's better to do that in CDKManager test.
  • Loading branch information
jonalv committed Sep 1, 2011
1 parent f336398 commit 9a4fa83
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 43 deletions.
Expand Up @@ -62,6 +62,7 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
Expand Down Expand Up @@ -267,6 +268,37 @@ public void testBug3055_SmilesProperties() throws Exception {
List<ICDKMolecule> mols = cdk.loadSMILESFile(path);
assertNotNull( mols.get( 0 ).getProperty("name",
Property.USE_CACHED) );

String csvfile = "/testFiles/testsmi2sdf.smi";
InputStream stream = getClass().getResourceAsStream(csvfile);
MockIFile ifile=new MockIFile(stream).extension("smi");

mols = cdk.loadSMILESFile( ifile, new NullProgressMonitor() );

//Confirm all molecules are read
assertEquals(8, mols.size());

//Confirm properties are stored on first mol
assertEquals("842267", mols.get(0).getAtomContainer()
.getProperty("PUBCHEM_SID"));
assertEquals("", mols.get(0).getAtomContainer()
.getProperty("PUBCHEM_EXT_DATASOURCE_REGID"));
assertEquals("644526", mols.get(0).getAtomContainer()
.getProperty("PUBCHEM_CID"));
assertEquals("2", mols.get(0).getAtomContainer()
.getProperty("PUBCHEM_ACTIVITY_OUTCOME"));
assertEquals("26", mols.get(0).getAtomContainer()
.getProperty("PUBCHEM_ACTIVITY_SCORE"));
assertEquals("\"\"", mols.get(0).getAtomContainer()
.getProperty("PUBCHEM_ACTIVITY_URL"));
assertEquals("20100519", mols.get(0).getAtomContainer()
.getProperty("PUBCHEM_ASSAYDATA_COMMENT"));
assertEquals("\"\"", mols.get(0).getAtomContainer()
.getProperty("PUBCHEM_ASSAYDATA_REVOKE"));
assertEquals("123.22", mols.get(0).getAtomContainer()
.getProperty("1"));
assertEquals("10.2743", mols.get(0).getAtomContainer()
.getProperty("2"));
}

@Test
Expand Down
@@ -0,0 +1,9 @@
SMILES,"PUBCHEM_SID","PUBCHEM_EXT_DATASOURCE_REGID","PUBCHEM_CID","PUBCHEM_ACTIVITY_OUTCOME","PUBCHEM_ACTIVITY_SCORE","PUBCHEM_ACTIVITY_URL","PUBCHEM_ASSAYDATA_COMMENT","PUBCHEM_ASSAYDATA_REVOKE",1,2
C1=CC=C(C=C1)OCCN2C3=CC=CC=C3SC2=O,842267,,644526,2,26,"",20100519,"",123.22,10.2743
CN\1C2=CC=CC=C2S/C1=C\C(=O)C3CCC3,842317,,5409720,2,30,"",20100519,"",137.55,10.0768
C1OC2=C(O1)C=C(C=C2)NC(=O)CSC3=NN=NN3CC4=CC=CC=C4,842386,,644654,2,18,"",20100519,"",84.67,3.7112
C1=CC=C(C=C1)NC(=O)C2=CC3=C(C=C2)N=C(S3)N,842516,,644786,2,29,"",20100519,"",137.13,5.14689
C1=CC=C(C=C1)OCC2=NN=C3N2N=C(S3)C4=CC=CS4,842734,,645009,2,17,"",20100519,"",80.71,14.5673
C1=CC=C(C=C1)C2=NC3=CC=CC=C3C4=NN=CN24,843032,,645307,2,26,"",20100519,"",123.13,7.53848
CC(=O)NC1=NC2=C(S1)C=C(C=C2)C(=O)NC,843041,,645316,1,4,"",20100519,"",22.68,0.948018
CC1=NN=C(C2=CC=CC=C12)NC3=CC=CC=N3,843042,,645317,2,31,"",20100519,"",142.71,3.81868
Expand Up @@ -44,40 +44,6 @@
*/
public class HandlerTests {

/**
* Test converting a comma-separated SMIELS file into an SDF.
* @throws CoreException
* @throws IOException
* @throws URISyntaxException
* @throws BioclipseException
* @throws InvocationTargetException
* @throws InterruptedException
*/
@Test
public void testConvertSMILEStoSDF() throws CoreException, IOException, URISyntaxException, BioclipseException, InvocationTargetException, InterruptedException {
String csvfile = "/testFiles/testsmi2sdf.smi";
InputStream stream = getClass().getResourceAsStream(csvfile);
MockIFile ifile=new MockIFile(stream);

List<ICDKMolecule> mols = ConvertSMILEStoSDF.readFileIntoMoleculeList(ifile, new NullProgressMonitor());

//Confirm all molecules are read
assertEquals(8, mols.size());

//Confirm properties are stored on first mol
assertEquals("842267", mols.get(0).getAtomContainer().getProperty("PUBCHEM_SID"));
assertEquals("", mols.get(0).getAtomContainer().getProperty("PUBCHEM_EXT_DATASOURCE_REGID"));
assertEquals("644526", mols.get(0).getAtomContainer().getProperty("PUBCHEM_CID"));
assertEquals("2", mols.get(0).getAtomContainer().getProperty("PUBCHEM_ACTIVITY_OUTCOME"));
assertEquals("26", mols.get(0).getAtomContainer().getProperty("PUBCHEM_ACTIVITY_SCORE"));
assertEquals("\"\"", mols.get(0).getAtomContainer().getProperty("PUBCHEM_ACTIVITY_URL"));
assertEquals("20100519", mols.get(0).getAtomContainer().getProperty("PUBCHEM_ASSAYDATA_COMMENT"));
assertEquals("\"\"", mols.get(0).getAtomContainer().getProperty("PUBCHEM_ASSAYDATA_REVOKE"));
assertEquals("123.22", mols.get(0).getAtomContainer().getProperty("1"));
assertEquals("10.2743", mols.get(0).getAtomContainer().getProperty("2"));

}

@Test
public void testFilterOutSalts() throws MalformedURLException, IOException, BioclipseException, CoreException, URISyntaxException{

Expand All @@ -104,13 +70,4 @@ public void testFilterOutSalts() throws MalformedURLException, IOException, Bioc
}

}


private String sourcePathtoAbsolutePath(String sourcepath)
throws URISyntaxException, MalformedURLException, IOException{
URI uri = getClass().getResource(sourcepath).toURI();
URL url = FileLocator.toFileURL(uri.toURL());
return url.getFile();
}

}

0 comments on commit 9a4fa83

Please sign in to comment.