Skip to content

Commit

Permalink
Removed duplicated cloning, now only down in DSMAnager.runTest(..)
Browse files Browse the repository at this point in the history
  • Loading branch information
olas committed Sep 7, 2012
1 parent ec3c2e3 commit 83fdd99
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 34 deletions.
Expand Up @@ -826,25 +826,26 @@ private void doRunAllTests() {

//Start by cloning the molecule. This is to avoid threading
//issues in CDK.
try {
IAtomContainer clonedAC=(IAtomContainer) mol
.getAtomContainer().clone();

ICDKMolecule clonedMol=new CDKMolecule(clonedAC);

preprocessClonedMol(clonedMol);
// try {
// IAtomContainer clonedAC=(IAtomContainer) mol
// .getAtomContainer().clone();
//
// ICDKMolecule clonedMol=new CDKMolecule(clonedAC);
//
// preprocessClonedMol(clonedMol);

logger.debug( "== Testrun: " + tr.getTest().getName() + " started" );
tr.setStatus( TestRun.RUNNING );
tr.setMolecule( clonedMol );
tr.setMolecule( mol );
viewer.refresh(tr);
viewer.setExpandedState( tr, true );

runTestAsJobs( clonedMol, ds, tr , mol);
runTestAsJobs( mol, ds, tr , mol);

} catch ( CloneNotSupportedException e ) {
LogUtils.handleException( e, logger, Activator.PLUGIN_ID);
}
// }
// catch ( CloneNotSupportedException e ) {
// LogUtils.handleException( e, logger, Activator.PLUGIN_ID);
// }

}
}
Expand Down
Expand Up @@ -165,10 +165,28 @@ public void runTest( String testID, IMolecule mol,
IProgressMonitor monitor)
throws BioclipseException{

ICDKManager cdk = net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();


IDSTest test = getTest( testID );
List<? extends ITestResult> ret=null;
try{
ret = test.runWarningTest( mol, monitor);

//Preprocess the molecule
ICDKMolecule cdkmol = cdk.asCDKMolecule(mol);

//Clone the mol
IAtomContainer clonedAC=null;
try {
clonedAC = (IAtomContainer) cdkmol.getAtomContainer().clone();
} catch (CloneNotSupportedException e) {
logger.error("Could not clone mol: " + cdkmol);
return;
}

ICDKMolecule clonedMol=new CDKMolecule(clonedAC);
ret = test.runWarningTest( clonedMol, monitor);

}catch (Exception e){
//in case of error...
LogUtils.debugTrace(logger, e);
Expand Down Expand Up @@ -211,38 +229,41 @@ public void runEndpoint( String endpointID, IMolecule mol,
//Get manager interface, we want to use the AOP
IDSManager ds = Activator.getDefault().getJavaManager();
Map<String,BioclipseJob<List<ITestResult>>> jobs = new HashMap<String, BioclipseJob<List<ITestResult>>>();
ICDKManager cdk = net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();

//Preprocess the molecule
ICDKMolecule cdkmol = cdk.asCDKMolecule(mol);

try {
cdkmol = cdk.removeExplicitHydrogens(cdkmol);
cdkmol=cdk.perceiveAromaticity(cdkmol);
cdkmol=cdk.addImplicitHydrogens(cdkmol);
} catch (InvocationTargetException e1) {
throw new BioclipseException("Could not preprocess molecule: " + e1.getMessage());
}
//This is done in abstractDSTest + ds.runTest

// ICDKManager cdk = net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();
// //Preprocess the molecule
// ICDKMolecule cdkmol = cdk.asCDKMolecule(mol);
//
// try {
// cdkmol = cdk.removeExplicitHydrogens(cdkmol);
// cdkmol=cdk.perceiveAromaticity(cdkmol);
// cdkmol=cdk.addImplicitHydrogens(cdkmol);
// } catch (InvocationTargetException e1) {
// throw new BioclipseException("Could not preprocess molecule: " + e1.getMessage());
// }


//Loop over all tests in this endpoint and run them
for (IDSTest test : getEndpoint( endpointID ).getTests()){

//Clone the mol
IAtomContainer clonedAC=null;
try {
clonedAC = (IAtomContainer) cdkmol.getAtomContainer().clone();
} catch (CloneNotSupportedException e) {
//Should not happen
logger.error("Could not clone mol: " + cdkmol);
continue;
}
ICDKMolecule clonedMol=new CDKMolecule(clonedAC);
// //Clone the mol
// IAtomContainer clonedAC=null;
// try {
// clonedAC = (IAtomContainer) cdkmol.getAtomContainer().clone();
// } catch (CloneNotSupportedException e) {
// //Should not happen
// logger.error("Could not clone mol: " + cdkmol);
// continue;
// }
// ICDKMolecule clonedMol=new CDKMolecule(clonedAC);


//Start up a job with the test
BioclipseJob<List<ITestResult>> job =
ds.runTest( test.getId(), clonedMol,
ds.runTest( test.getId(), mol,
new BioclipseJobUpdateHook<List<ITestResult>>(test.getName()));
jobs.put(test.getId(),job);
job.schedule();
Expand Down

0 comments on commit 83fdd99

Please sign in to comment.