def testTCLTruncateSegname(self):
     # Tests providing a chain_id that is longer than one character
     try:
         # easier to run_kmc to create monomer_list than recreate it here (adj easier) so doing so
         # minimize random calls by providing set list of monomer types
         initial_mono_type_list = [S, S, G, S, S, S, G, S]
         num_monos = len(initial_mono_type_list)
         initial_monomers = [
             Monomer(mono_type, i)
             for i, mono_type in enumerate(initial_mono_type_list)
         ]
         initial_events = create_initial_events(initial_monomers,
                                                DEF_RXN_RATES)
         initial_state = create_initial_state(initial_events,
                                              initial_monomers)
         # since GROW is not added to event_dict, no additional monomers will be added
         result = run_kmc(DEF_RXN_RATES,
                          initial_state,
                          sorted(initial_events),
                          t_max=2,
                          random_seed=8)
         # quick tests to make sure run_kmc gives expected results (not what we want to test here)
         # self.assertAlmostEqual(result[TIME][-1], 0.000766574526703574)
         self.assertTrue(len(result[MONO_LIST]) == num_monos)
         # the function we want to test here is below
         with capture_stderr(gen_tcl,
                             result[ADJ_MATRIX],
                             result[MONO_LIST],
                             chain_id="lignin",
                             out_dir=SUB_DATA_DIR) as output:
             self.assertTrue("should be one character" in output)
         self.assertFalse(diff_lines(TCL_FILE_LOC, GOOD_TCL_SHORT))
     finally:
         silent_remove(TCL_FILE_LOC, disable=DISABLE_REMOVE)
         pass
    def testB1BondGenMol(self):
        ini_mono_type_list = [S, S, S, G, S]
        sg_ratio = 1.0
        max_monos = 12
        random_num = 55
        initial_monomers = [
            Monomer(mono_type, i)
            for i, mono_type in enumerate(ini_mono_type_list)
        ]
        initial_events = create_initial_events(initial_monomers, DEF_RXN_RATES)
        initial_events.append(Event(GROW, [], rate=1e4))
        initial_state = create_initial_state(initial_events, initial_monomers)
        result = run_kmc(DEF_RXN_RATES,
                         initial_state,
                         initial_events,
                         n_max=max_monos,
                         t_max=2,
                         random_seed=random_num,
                         sg_ratio=sg_ratio)
        nodes = result[MONO_LIST]
        adj = result[ADJ_MATRIX]
        # generate_mol(adj, nodes)
        with capture_stderr(generate_mol, adj, nodes) as output:
            self.assertFalse(output)

        mol = MolFromMolBlock(generate_mol(adj, nodes))
        mols = GetMolFrags(mol)

        analysis = analyze_adj_matrix(adj)
        frag_sizes = analysis[CHAIN_LEN]

        # Make sure there are the same number of separate fragments calculated by RDKIT
        # as we get from just separating the alternate B1
        self.assertEqual(np.sum(list(frag_sizes.values())), len(mols))
Exemplo n.º 3
0
 def testMissingTpl(self):
     test_input = ["-f", LOG_FILE, "-c"]
     # main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("No template file" in output)
 def testMissingJobTpl(self):
     test_input = [ETHYLRAD, "-c", MISSING_JOB_TPL_INI]
     # main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue(
             "For job 'stable', could not find a template file 'stable.tpl"
             in output)
Exemplo n.º 5
0
 def testWrongDir(self):
     test_input = ["-d", "ghost"]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Could not find" in output)
     silent_remove(FOR_HARTREE_DIR, disable=DISABLE_REMOVE)
Exemplo n.º 6
0
 def testSortByEnthalpy(self):
     test_input = ["-l", LOG_LIST, '-n']
     good_output = ''.join([HEADER, LME2_TS3, LME2_25_T]) + '\n'
     with capture_stdout(main, test_input) as output:
         self.assertTrue(good_output in output)
     with capture_stderr(main, test_input) as output:
         self.assertTrue('Check convergence' in output)
 def testTCLGenEmptySegname(self):
     # tcl_fname="psfgen.tcl", psf_fname='lignin', chain_id="L", toppar_dir="toppar/"
     # Here, all the monomers are available at the beginning of the simulation
     # Increases coverage of gen_tcl
     try:
         # easier to run_kmc to create monomer_list than recreate it here (adj easier) so doing so
         # minimize random calls by providing set list of monomer types
         initial_mono_type_list = [S, S, G, S, S, S, G, S]
         num_monos = len(initial_mono_type_list)
         initial_monomers = [Monomer(mono_type, i) for i, mono_type in enumerate(initial_mono_type_list)]
         initial_events = create_initial_events(initial_monomers, DEF_RXN_RATES)
         initial_state = create_initial_state(initial_events, initial_monomers)
         # since GROW is not added to event_dict, no additional monomers will be added
         result = run_kmc(DEF_RXN_RATES, initial_state, sorted(initial_events), t_max=2, random_seed=8)
         # quick tests to make sure run_kmc gives expected results (not what we want to test here)
         self.assertAlmostEqual(result[TIME][-1], 0.00015059250794459398)
         self.assertTrue(len(result[MONO_LIST]) == num_monos)
         # the function we want to test here is below
         with capture_stderr(gen_tcl, result[ADJ_MATRIX], result[MONO_LIST], chain_id=" ",
                             out_dir=SUB_DATA_DIR) as output:
             self.assertTrue("should be one character" in output)
         self.assertFalse(diff_lines(TCL_FILE_LOC, GOOD_TCL_SHORT))
     finally:
         silent_remove(TCL_FILE_LOC, disable=DISABLE_REMOVE)
         pass
Exemplo n.º 8
0
 def testNoScanInfo(self):
     no_scan_log = os.path.join(SUB_DATA_DIR, 'me2propprpnt_7.log')
     test_input = ["-f", no_scan_log, "--scan", "test.png"]
     # main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue(
             "Did not find expected parameter scan info" in output)
Exemplo n.º 9
0
 def testNonIntLastStepNum(self):
     test_input = ["-t", "ghost"]
     # main(test_input)
     # if logger.isEnabledFor(logging.DEBUG):
     #     main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("integer must be provided" in output)
Exemplo n.º 10
0
 def testNoArgs(self):
     test_input = []
     # main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("required" in output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("optional arguments" in output)
 def testNoSuchFile(self):
     test_input = ["ghost.log"]
     # main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Could not find" in output)
 def testMissingValue(self):
     test_input = [TEST_LOG1, "-c"]
     # main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("expected one argument" in output)
Exemplo n.º 13
0
 def testNoSMI(self):
     test_input = ['-t', GAU_TPL]
     # main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("SMILES " in output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("optional arguments" in output)
Exemplo n.º 14
0
 def testNoLastStepNum(self):
     test_input = ["-t"]
     # main(test_input)
     # if logger.isEnabledFor(logging.DEBUG):
     #     main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("expected one argument" in output)
 def testBadAtomIni(self):
     test_input = ["-c", BAD_ATOM_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Atom types do not match" in output)
     silent_remove(PDB_OUT, disable=DISABLE_REMOVE)
 def testNoArgs(self):
     with capture_stderr(main, []) as output:
         self.assertTrue(
             "WARNING:  Problems reading file: Could not read file" in
             output)
     with capture_stdout(main, []) as output:
         self.assertTrue("optional arguments" in output)
Exemplo n.º 17
0
 def testFewerMaxThanIniMonos(self):
     test_input = ["-r", "10", "-i", "6", "-m", "4"]
     # main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue('is less than' in output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("Lignin KMC created 6 monomers" in output)
 def testCP(self):
     test_input = [TEST_LOG5, "--cpu"]
     # main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Could not find frequency" in output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("0 days  0 hrs 27 mins 11 secs" in output)
Exemplo n.º 19
0
 def testHelp(self):
     test_input = ['-h']
     # main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertFalse(output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("optional arguments" in output)
Exemplo n.º 20
0
 def testMissingListIni(self):
     test_input = [ETHYLRAD, "-c", MISSING_TPL_INI]
     # main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("not find the submit template" in output)
Exemplo n.º 21
0
 def testProduction(self):
     # new_out_dir = os.path.join(DATA_DIR, 'new_plots')
     plot_input = [
         "-x",
         "-p",
         # next line: testing
         "-i",
         "5",
         "-m",
         "100",
         "-a",
         "1",
         "-sg",
         "1, 10",
         "-n",
         "3",
         "-d",
         TEMP_DIR,
         # # alt lines: production
         # "-i", "2", "-m", "500", "-l", "1e5", "-a", "1e8, 1e6, 1e4, 1e2, 1",
         # "-sg", "0.1, 0.2, 0.25, 0.33, 0.5, 1, 2, 3, 4, 5, 10", "-n", "100", "-d", new_out_dir,
     ]
     try:
         with capture_stderr(main, plot_input) as output:
             self.assertFalse(output)
     finally:
         silent_remove(TEMP_DIR,
                       dir_with_files=True,
                       disable=DISABLE_REMOVE)
         pass
 def testMissingFile(self):
     test_input = ["-t", TPL_FILE, "-f", "ghost.txt"]
     # main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Problems reading file" in output)
 def testNoFilesToProcess(self):
     test_input = ["-t", TPL_FILE]
     main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("No files have been specified to be read" in output)
 def testNotIni(self):
     # gracefully fail if give the wrong file to the -c option
     test_input = ["-c", GOOD_PDB_OUT]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue(
             "WARNING:  File contains no section headers" in output)
 def testHelp(self):
     test_input = ['-h']
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertFalse(output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("optional arguments" in output)
 def testUnknownArg(self):
     test_input = ['--ghost']
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("unrecognized arguments" in output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("optional arguments" in output)
Exemplo n.º 27
0
 def testCheckForValenceError(self):
     random_seed = 1
     test_input = ["-i", "5", "-m", "200", "-a", "1", "-sg", "1, 3, 5, 10", "-n", "3", "-r", str(random_seed)]
     # main(test_input)
     with capture_stderr(main, test_input) as output:
         if output:
             print("Encountered error:\n", output)
         self.assertFalse(output)
Exemplo n.º 28
0
 def testConflictingOptions(self):
     test_input = ["-s", "-z"]
     # main(test_input)
     # if logger.isEnabledFor(logging.DEBUG):
     #     main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Choose either" in output)
     silent_remove(FOR_HARTREE_DIR, disable=DISABLE_REMOVE)
Exemplo n.º 29
0
 def testNoneFloatVib(self):
     test_input = ["-l", TPA_LIST, "-d", SUB_DATA_DIR, "-t", "-v", "ghost"]
     # main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("not convert string" in output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("optional arguments" in output)
Exemplo n.º 30
0
 def testBadConfigFile(self):
     test_input = ["-c", "ghost.ini"]
     # main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Could not find specified configuration file" in output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("optional arguments" in output)