Skip to content

Commit

Permalink
added time remaining estimate for addProperty to sdf
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalv committed Aug 28, 2012
1 parent a7620dd commit 0be211c
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -37,6 +37,7 @@
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.domain.IMolecule.Property;
import net.bioclipse.core.util.LogUtils;
import net.bioclipse.core.util.TimeCalculator;
import net.bioclipse.jobs.IReturner;
import net.bioclipse.managers.business.IBioclipseManager;

Expand Down Expand Up @@ -506,9 +507,11 @@ public void calculatePropertiesFor( IFile file,

IFile target = null;
SubMonitor loopProgress = progress.newChild( 8000 );
loopProgress.setWorkRemaining( model.getNumberOfMolecules()*20 );
int numberOfMolecules = model.getNumberOfMolecules();
loopProgress.setWorkRemaining( numberOfMolecules*20 );
loopProgress.subTask( "Writing to file" );
for(int i = 0;i<model.getNumberOfMolecules();i++ ) {
long startTime = System.currentTimeMillis();
for(int i = 0;i<numberOfMolecules;i++ ) {
//loopProgress.setWorkRemaining( (model.getNumberOfMolecules()-i) );
StringWriter writer = new StringWriter();
IChemObjectWriter chemWriter = new SDFWriter(writer);
Expand All @@ -526,6 +529,11 @@ public void calculatePropertiesFor( IFile file,
mol.setProperties( ac.getProperties() );
}
loopProgress.worked( 5 );
loopProgress.setTaskName(
"Done " + i + "/" + numberOfMolecules
+ " (" + TimeCalculator.generateTimeRemainEst(
startTime, i+1, numberOfMolecules )
+ ")" );
calculateProperties( molecule, calculators, new IReturner<Void>() {
public void completeReturn( Void object ) {
}
Expand Down Expand Up @@ -585,7 +593,7 @@ public void partialReturn( Void object ) {
e.getMessage()!=null?e.getMessage():"");
}
loopProgress.subTask( String.format( "%d/%d", i,
model.getNumberOfMolecules() ) );
numberOfMolecules ) );
}
progress.setWorkRemaining( 1000 );

Expand Down

0 comments on commit 0be211c

Please sign in to comment.