class tester(): def setup(self): self.p = ArgumentParser() def cmd(self, value): sys.argv = [os.path.abspath(__file__)] for e in value.split(): sys.argv.append(e) @property def v(self): return self.p.parse_args(print_banner=False) def add(self, *args, **kwargs): self.p.add_argument(*args, **kwargs) def test_0(self): self.add('a', nargs='+') self.cmd('-a 1 2') eq_(self.v.a, ['1', '2']) def test_1(self): self.add('a', nargs='+', type=int) self.cmd('-a 1 2') eq_(self.v.a, [1, 2]) def test_2(self): self.add('a', type=int) self.cmd('-a 4') eq_(self.v.a, 4) def test_3(self): self.add('a', type=float) self.cmd('-a 5') eq_(self.v.a, 5.0) @raises(SystemExit) def test_4(self): sys.stderr = open('/dev/null', 'w') self.add('a', choices=[1, 2], type=float) self.cmd('-a 5') eq_(self.v.a, 5.0) sys.stderr = sys.__stderr__ def test_5(self): self.add('a', choices=['1', '2'], type=int) self.cmd('-a 1') eq_(self.v.a, 1.0) # @expected_failure def test_6(self): self.add('a', choices=[1, 2], type=int) self.cmd('-a 1') eq_(self.v.a, 1) def test_7(self): self.add('a', action='store_true', type=bool) self.cmd('-a') eq_(self.v.a, True) def test_71(self): self.add('a', action='store_false', type=bool) self.cmd('-a') eq_(self.v.a, False) def test_8(self): self.add('a', action='store_true') self.cmd('-a') eq_(self.v.a, True) def test_81(self): self.add('b', action='store_false') self.cmd('-b') eq_(self.v.b, False) def test_9(self): self.add('a', default=False, action='store_true', type=bool) self.cmd('') eq_(self.v.a, False) def test_10(self): self.add('a', action='store_true', type=bool) self.cmd('') eq_(self.v.a, False)
together. The glob pattern used would be XTC/*/*.xtc'. If 'fah', then standard folding@home-style directory architecture is required.''', default='file', choices=['fah', 'file', 'file_dcd']) parser.add_argument('min_length', help='''Minimum number of frames per trajectory required to include data in Project. Used to discard extremely short trajectories.''', default=0, type=int) parser.add_argument('stride', help='''Integer number to subsample by. Every "u-th" frame will be taken from the data and converted to msmbuilder format''', default=1, type=int) parser.add_argument('rmsd_cutoff', help='''A safe-guard that discards any structure with and RMSD higher than the specified value (in nanometers, with respect to the input PDB file). Pass -1 to disable this feature''', default=-1, type=float) #parser.add_argument('parallel', help='''Run the conversion in parallel. # multiprocessing launches multiple python interpreters to use all of your cores. # dtm uses mpi, and requires python's "deap" module to be installed. To execute the # code over mpi using dtm, you need to start the command with mpirun -np <num_procs>. # Note that in many circumstates, the conversion done by this script is IO bound, # not CPU bound, so parallelism can actually be detrememtal.''', default='None', # choices=['None', 'multiprocessing', 'dtm']) args = parser.parse_args() rmsd_cutoff = args.rmsd_cutoff if rmsd_cutoff <= 0.0: rmsd_cutoff = None else: logger.warning("Will discard any frame that is %f nm from the PDB conformation...", rmsd_cutoff) run(args.project, args.pdb, args.input_dir, args.source, args.min_length, args.stride, rmsd_cutoff)
help='''Integer number to subsample by. Every "u-th" frame will be taken from the data and converted to msmbuilder format''', default=1, type=int) parser.add_argument('rmsd_cutoff', help='''A safe-guard that discards any structure with and RMSD higher than the specified value (in nanometers, with respect to the input PDB file). Pass -1 to disable this feature''', default=-1, type=float) #parser.add_argument('parallel', help='''Run the conversion in parallel. # multiprocessing launches multiple python interpreters to use all of your cores. # dtm uses mpi, and requires python's "deap" module to be installed. To execute the # code over mpi using dtm, you need to start the command with mpirun -np <num_procs>. # Note that in many circumstates, the conversion done by this script is IO bound, # not CPU bound, so parallelism can actually be detrememtal.''', default='None', # choices=['None', 'multiprocessing', 'dtm']) args = parser.parse_args() rmsd_cutoff = args.rmsd_cutoff if rmsd_cutoff <= 0.0: rmsd_cutoff = None else: logger.warning( "Will discard any frame that is %f nm from the PDB conformation...", rmsd_cutoff) run(args.project, args.pdb, args.input_dir, args.source, args.min_length, args.stride, rmsd_cutoff)
class tester(): def setup(self): self.p = ArgumentParser() def cmd(self, value): sys.argv = [os.path.abspath(__file__)] for e in value.split(): sys.argv.append(e) @property def v(self): return self.p.parse_args(print_banner=False) def add(self, *args, **kwargs): self.p.add_argument(*args, **kwargs) def test_0(self): self.add('a', nargs='+') self.cmd('-a 1 2') eq_(self.v.a, ['1', '2']) def test_1(self): self.add('a', nargs='+', type=int) self.cmd('-a 1 2') eq_(self.v.a, [1, 2]) def test_2(self): self.add('a', type=int) self.cmd('-a 4') eq_(self.v.a, 4) def test_3(self): self.add('a', type=float) self.cmd('-a 5') eq_(self.v.a, 5.0) @raises(SystemExit) def test_4(self): sys.stderr = open('/dev/null', 'w') self.add('a', choices=[1,2], type=float) self.cmd('-a 5') eq_(self.v.a, 5.0) sys.stderr = sys.__stderr__ def test_5(self): self.add('a', choices=['1', '2'], type=int) self.cmd('-a 1') eq_(self.v.a, 1.0) def test_6(self): self.add('a', choices=[1, 2], type=int) self.cmd('-a 1') eq_(self.v.a, 1) def test_7(self): self.add('a', action='store_true', type=bool) self.cmd('-a') eq_(self.v.a, True) def test_71(self): self.add('a', action='store_false', type=bool) self.cmd('-a') eq_(self.v.a, False) def test_8(self): self.add('a', action='store_true') self.cmd('-a') eq_(self.v.a, True) def test_81(self): self.add('b', action='store_false') self.cmd('-b') eq_(self.v.b, False) def test_9(self): self.add('a', default=False, action='store_true', type=bool) self.cmd('') eq_(self.v.a, False) def test_10(self): self.add('a', action='store_true', type=bool) self.cmd('') eq_(self.v.a, False)