visualise progress of loop.

Somedays ago, I read a blog post about useful python library and I found cool library.
The name of library was ‘tqdm’.
The library can visualise progress bar very easily.
For example, if I want to visualise progress of loops, I could do it only call tqdm.
That’s all. ๐Ÿ˜‰
Then I could get following progress bar.
Hmm That’s cool.

In [1]: from rdkit import Chem
In [2]: from tqdm import tqdm
In [3]: sdf = Chem.SDMolSupplier( 'cdk2.sdf' )
In [4]: mols = [ mol for mol in tqdm( sdf ) ]
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 47/47 [00:00<00:00, 1081.43it/s]
In [8]: for mol in tqdm( mols ):
   ...:     print( Chem.MolToSmiles( mol ) )
  0%|                                                    | 0/47 [00:00<?, ?it/s]CC(C)C(=O)COc1nc(N)nc2[nH]cnc12
100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 47/47 [00:00<00:00, 3283.24it/s]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s