23.2 OEDots

This is a utility class to provide a dot-based (on the console) progress bar display to show status of scripts that iterate over large input files. The constructor takes 3 arguments, with the third optional.

dots = OEDots(1000, 50, "molecules")

The first argument is how many count events happen on each line of dots, the second is how many counts each dot equals. The last argument is simply a text label such that at the end of each line, the text says what is being counted. The example above will print a dot (to stderr) every 50 events. After 1000 event, it will end the line of dots with "1000 molecules processed, 2000 molecules processed", etc. If either of the numeric arguments are set to zero (0), there will be no output but the internal counter will still count. This is useful if you want to count number of times through a loop, but don't care about a status update.

In order up increment the counter, call the Update() method each time through the loop. If you loop in groups of more than one, you can call Update(n), where n is a positive integer.

After the end of the loop, call the Total() member function to get output to stderr of the total number of items counted. The following example shows how to use OEDots:

from openeye.oechem import *
import os, sys

ifs = oemolistream()
ifs.open("nci.smi")

# create a dots instance
dots = OEDots(10000,500,"SMILES")

# loop over the input file, call update for each molecule
for mol in ifs.GetOEGraphMols():
    DoSomething(mol)
    dots.Update()

# output a summary
dots.Total()