diff --git a/pycgtool/frame.py b/pycgtool/frame.py index a7f7c97ed543438f06e97f82f610d7d80eb67eab..dc4907a7adbba6003e3f5e858bd40f76fd3b6d77 100644 --- a/pycgtool/frame.py +++ b/pycgtool/frame.py @@ -124,7 +124,6 @@ class Frame: """ Hold Atom data separated into Residues """ - def __init__(self, gro=None, xtc=None, itp=None, frame_start=0, xtc_reader="simpletraj"): """ Return Frame instance having read Residues and Atoms from GRO if provided diff --git a/pycgtool/interface.py b/pycgtool/interface.py index e878d02c052b003776bee8fafd671234a721d2bb..210a4868e719ce8f0ec7f00db349a5d8a541cf6a 100644 --- a/pycgtool/interface.py +++ b/pycgtool/interface.py @@ -6,6 +6,11 @@ import curses import curses.textpad import time +try: + from tqdm import tqdm +except ImportError: + pass + class Options: """ @@ -267,8 +272,19 @@ class Progress: def run(self): """ Iterate through self until stopped by maximum iterations or False condition. + + Use the tqdm library if it is present. """ - collections.deque(self, maxlen=0) + if self._quiet: + collections.deque(self, maxlen=0) + else: + try: + self._quiet = True + collections.deque(tqdm(self, total=len(self)-1), maxlen=0) + except NameError: + self._quiet = False + collections.deque(self, maxlen=0) + return self._its @property diff --git a/pycgtool/pycgtool.py b/pycgtool/pycgtool.py index 4696f6b2c07f90562e6a9689f406a062fa80c081..2660c1d8becb0fd7921fed01194aa1bc3e6441b7 100755 --- a/pycgtool/pycgtool.py +++ b/pycgtool/pycgtool.py @@ -18,7 +18,7 @@ def main(args, config): :param args: Arguments from argparse :param config: Configuration dictionary """ - frame = Frame(gro=args.gro, xtc=args.xtc, itp=args.itp, frame_start=args.begin, xtc_reader="mdtraj") + frame = Frame(gro=args.gro, xtc=args.xtc, itp=args.itp, frame_start=args.begin) if args.bnd: bonds = BondSet(args.bnd, config) diff --git a/test/test_frame.py b/test/test_frame.py index 59942f1323465667b56aa187aad4ee48bbf20f55..848e299ce91aa865fea4a13961be0282bc289e53 100644 --- a/test/test_frame.py +++ b/test/test_frame.py @@ -72,11 +72,13 @@ class FrameTest(unittest.TestCase): os.remove("water-out.gro") def test_frame_read_xtc_simpletraj_numframes(self): - frame = Frame(gro="test/data/water.gro", xtc="test/data/water.xtc") + frame = Frame(gro="test/data/water.gro", xtc="test/data/water.xtc", + xtc_reader="simpletraj") self.assertEqual(12, frame.numframes) - def test_frame_read_xtc(self): - frame = Frame(gro="test/data/water.gro", xtc="test/data/water.xtc") + def test_frame_read_xtc_simpletraj(self): + frame = Frame(gro="test/data/water.gro", xtc="test/data/water.xtc", + xtc_reader="simpletraj") self.assertEqual(663, frame.natoms) # These are the coordinates from the gro file np.testing.assert_allclose(np.array([0.696, 1.33, 1.211]),