def testSubmitMultIni(self):
     # Create and submit more than one ini
     temp_file_list = [
         'ethylrad.com', 'ircr.tpl', 'ircf.tpl', 'opt.tpl', 'ethylrad.chk'
     ]
     for fname in temp_file_list:
         with open(fname, 'w') as f:
             f.write("# for test only\n")
     test_input = ['ethylrad', "-c", SETUP_IRCS_INI, "-s", "-n"]
     try:
         main(test_input)
         self.assertFalse(
             diff_lines(SETUP_IRCR_INI_OUT, GOOD_SETUP_IRCR_INI_OUT))
         self.assertFalse(
             diff_lines(SETUP_IRCR_SLM_OUT, GOOD_SETUP_IRCR_SLM_OUT))
         self.assertFalse(
             diff_lines(SETUP_IRCF_INI_OUT, GOOD_SETUP_IRCF_INI_OUT))
         self.assertFalse(
             diff_lines(SETUP_IRCF_SLM_OUT, GOOD_SETUP_IRCF_SLM_OUT))
     finally:
         for fname in temp_file_list + [
                 SETUP_IRCR_INI_OUT, SETUP_IRCR_SLM_OUT, SETUP_IRCF_INI_OUT,
                 SETUP_IRCF_SLM_OUT
         ]:
             silent_remove(fname, disable=DISABLE_REMOVE)
         pass
 def testFirstOnly(self):
     test_input = ["-c", MULTI_FIRST_ONLY_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(REMOVE_H_OUT1, GOOD_KEEP_H_OUT1))
         self.assertFalse(diff_lines(GAU_OUT1, GOOD_GAU_OUT1))
     finally:
         silent_remove(REMOVE_H_OUT1, disable=DISABLE_REMOVE)
         silent_remove(GAU_OUT1, disable=DISABLE_REMOVE)
 def testSetupSubmit(self):
     test_input = [ETHYLRAD, "-s", "-c", SETUP_SUBMIT_INI, "-n"]
     try:
         main(test_input)
         self.assertFalse(diff_lines(SPAWN0_INI, GOOD_SETUP_INI_OUT))
         self.assertFalse(diff_lines(SPAWN0_SLURM, GOOD_SETUP_SLURM_OUT))
     finally:
         for fname in [SPAWN0_INI, SPAWN0_SLURM]:
             silent_remove(fname, disable=DISABLE_REMOVE)
         pass
 def testSetupOneJobIni(self):
     test_input = [ETHYLRAD, "-c", ONE_JOB_INI, "-t", "-s"]
     try:
         main(test_input)
         self.assertFalse(diff_lines(ONE_INI_OUT, GOOD_ONE_INI_OUT))
         self.assertFalse(diff_lines(ONE_SLM_OUT, GOOD_ONE_SLM_OUT))
     finally:
         silent_remove(ONE_INI_OUT, disable=DISABLE_REMOVE)
         silent_remove(ONE_SLM_OUT, disable=DISABLE_REMOVE)
         pass
 def testFromListCase(self):
     test_input = ["-t", TPL_FILE, "-l", LIST_FILE, "-c"]
     try:
         main(test_input)
         self.assertFalse(diff_lines(COM_OUT_FILE, GOOD_COM_OUT_FILE))
         self.assertFalse(diff_lines(COM_OUT_FILE2, GOOD_COM_OUT_FILE2))
     finally:
         silent_remove(COM_OUT_FILE, disable=DISABLE_REMOVE)
         silent_remove(COM_OUT_FILE2, disable=DISABLE_REMOVE)
         pass
 def testMultIni(self):
     test_input = ["-c", MULT_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(PDB_OUT, GOOD_PDB_LAST_OUT))
         self.assertFalse(diff_lines(PDB2_OUT, GOOD_PDB2_LAST_OUT))
     finally:
         silent_remove(PDB_OUT, disable=DISABLE_REMOVE)
         silent_remove(PDB2_OUT, disable=DISABLE_REMOVE)
         pass
예제 #7
0
 def testNTripleBond(self):
     test_input = ["-c", N_TRIPLE_BOND_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(CP_N_OUT, GOOD_CP_N_OUT))
         self.assertFalse(diff_lines(F2_N_OUT, GOOD_F2_N_OUT))
     finally:
         silent_remove(CP_N_OUT, disable=DISABLE_REMOVE)
         silent_remove(F2_N_OUT, disable=DISABLE_REMOVE)
         pass
예제 #8
0
 def testCPTpl(self):
     test_input = ["-t", CP_COM_TPL, "-l", LOG_LIST, "-c"]
     try:
         main(test_input)
         self.assertFalse(diff_lines(COM1_OUT, GOOD_COM1_OUT))
         self.assertFalse(diff_lines(COM2_OUT, GOOD_COM2_OUT))
     finally:
         silent_remove(COM1_OUT, disable=DISABLE_REMOVE)
         silent_remove(COM2_OUT, disable=DISABLE_REMOVE)
         pass
 def testDefIni(self):
     test_input = ["-c", DEF_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(GAU_OUT1, GOOD_GAU_OUT1))
         self.assertFalse(diff_lines(GAU_OUT2, GOOD_GAU_OUT2))
         self.assertFalse(diff_lines(GAU_OUT3, GOOD_GAU_OUT3))
     finally:
         silent_remove(GAU_OUT1, disable=DISABLE_REMOVE)
         silent_remove(GAU_OUT2, disable=DISABLE_REMOVE)
         silent_remove(GAU_OUT3, disable=DISABLE_REMOVE)
 def testRemoveH(self):
     test_input = ["-c", REMOVE_H_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(REMOVE_H_OUT1, GOOD_REMOVE_H_OUT1))
         self.assertFalse(diff_lines(REMOVE_H_OUT2, GOOD_REMOVE_H_OUT2))
         self.assertFalse(diff_lines(REMOVE_H_OUT3, GOOD_REMOVE_H_OUT3))
     finally:
         silent_remove(REMOVE_H_OUT1, disable=DISABLE_REMOVE)
         silent_remove(REMOVE_H_OUT2, disable=DISABLE_REMOVE)
         silent_remove(REMOVE_H_OUT3, disable=DISABLE_REMOVE)
예제 #11
0
 def testSepMolecules(self):
     # to help when there is a reactant or product complex that is two different molecules; ignores the
     #   larger distance between the atoms belonging to two different molecules
     test_input = ["-c", IGNORE_MAX_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(CP_TPA_OUT, GOOD_CP_TPA_OUT))
         self.assertFalse(diff_lines(F2_TPA_OUT, GOOD_F2_TPA_OUT))
     finally:
         silent_remove(CP_TPA_OUT, disable=DISABLE_REMOVE)
         silent_remove(F2_TPA_OUT, disable=DISABLE_REMOVE)
         pass
 def testCommandLineOptions(self):
     test_input = ["-t", "tests/test_data/pdbs2gausscoms/gau.tpl",
                   "-l", "tests/test_data/pdbs2gausscoms/pdb_list.txt"]
     try:
         main(test_input)
         self.assertFalse(diff_lines(GAU_OUT1, GOOD_GAU_OUT1))
         self.assertFalse(diff_lines(GAU_OUT2, GOOD_GAU_OUT2))
         self.assertFalse(diff_lines(GAU_OUT3, GOOD_GAU_OUT3))
     finally:
         silent_remove(GAU_OUT1, disable=DISABLE_REMOVE)
         silent_remove(GAU_OUT2, disable=DISABLE_REMOVE)
         silent_remove(GAU_OUT3, disable=DISABLE_REMOVE)
예제 #13
0
 def testMetalBond(self):
     # Uses a longer bond cut-off when one of the atoms is a metal
     test_input = ["-c", METAL_BOND_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(CP_METAL_OUT, GOOD_CP_METAL_OUT))
         self.assertFalse(diff_lines(F1_METAL_OUT, GOOD_F1_METAL_OUT))
         self.assertFalse(diff_lines(F2_METAL_OUT, GOOD_F2_METAL_OUT))
     finally:
         silent_remove(CP_METAL_OUT, disable=DISABLE_REMOVE)
         silent_remove(F1_METAL_OUT, disable=DISABLE_REMOVE)
         silent_remove(F2_METAL_OUT, disable=DISABLE_REMOVE)
         pass
예제 #14
0
 def testNTripleBondSubDir(self):
     # Test that output files were created in subdir
     test_input = ["-c", N_TRIPLE_BOND_SUB_DIR_INI]
     try:
         silent_remove(TEMP_DIR, dir_with_files=True)
         main(test_input)
         self.assertFalse(diff_lines(CP_N_OUT_SUB_DIR, GOOD_CP_N_OUT))
         self.assertFalse(diff_lines(F2_N_OUT_SUB_DIR, GOOD_F2_N_OUT))
     finally:
         silent_remove(TEMP_DIR,
                       disable=DISABLE_REMOVE,
                       dir_with_files=True)
         pass
예제 #15
0
 def testDefIni(self):
     test_input = [ETHYLRAD, "-c", DEF_INI, "-t"]
     try:
         main(test_input)
         self.assertFalse(diff_lines(DEF_SH_OUT, GOOD_SH_OUT))
         self.assertFalse(diff_lines(OPT_SH_OUT, GOOD_OPT_SH_OUT))
         self.assertFalse(
             diff_lines(OPT_STABLE_SH_OUT, GOOD_OPT_STABLE_SH_OUT))
     finally:
         for file in [
                 DEF_SH_OUT, DEF_LOG_OUT, OPT_SH_OUT, OPT_STABLE_SH_OUT
         ]:
             silent_remove(file, disable=DISABLE_REMOVE)
         pass
예제 #16
0
 def testDubO(self):
     test_input = ["-c", DIMER_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(CP_DI_18_24_OUT, GOOD_CP_DI_18_24_OUT))
         self.assertFalse(diff_lines(F2_DI_18_24_OUT, GOOD_F2_DI_18_24_OUT))
         self.assertFalse(diff_lines(CP_DI_18_16_OUT, GOOD_CP_DI_18_16_OUT))
         self.assertFalse(diff_lines(F1_DI_18_16_OUT, GOOD_F1_DI_18_16_OUT))
         self.assertFalse(diff_lines(F2_DI_18_16_OUT, GOOD_F2_DI_18_16_OUT))
     finally:
         silent_remove(CP_DI_18_24_OUT, disable=DISABLE_REMOVE)
         silent_remove(F2_DI_18_24_OUT, disable=DISABLE_REMOVE)
         silent_remove(CP_DI_18_16_OUT, disable=DISABLE_REMOVE)
         silent_remove(F1_DI_18_16_OUT, disable=DISABLE_REMOVE)
         silent_remove(F2_DI_18_16_OUT, disable=DISABLE_REMOVE)
         pass
 def testNoTplIni(self):
     test_input = ["-c", NO_TPL_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(PDB_OUT, GOOD_NO_TPL_OUT))
     finally:
         silent_remove(PDB_OUT, disable=DISABLE_REMOVE)
 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
 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 testNoGrowth(self):
     # Here, all the monomers are available at the beginning of the simulation
     try:
         # minimize random calls by providing set list of monomer types
         mono_type_list = [
             S, S, S, S, G, S, S, S, S, S, S, G, S, S, S, S, S, S, S, S, S,
             S, S, S
         ]
         random_num = 24
         initial_monomers = [
             Monomer(mono_type, i)
             for i, mono_type in enumerate(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=0.0001,
                          random_seed=random_num)
         gen_tcl(result[ADJ_MATRIX],
                 result[MONO_LIST],
                 tcl_fname=TCL_FNAME,
                 chain_id="L",
                 out_dir=SUB_DATA_DIR)
         self.assertFalse(diff_lines(TCL_FILE_LOC, GOOD_TCL_NO_GROW_OUT))
     finally:
         silent_remove(TCL_FILE_LOC, disable=DISABLE_REMOVE)
         pass
예제 #21
0
 def testFindNodeProc(self):
     test_input = [ETHYLRAD, "-c", SETUP_GET_PROCS_INI, "-t"]
     try:
         # main(test_input)
         with capture_stdout(main, test_input) as output:
             # each assert from a different print command
             self.assertTrue("the whole node will" in output)
             self.assertFalse("Will allocate up to 63124196 kB" in output)
             self.assertTrue("0-35" in output)
             self.assertTrue("user may override these" in output)
         self.assertFalse(diff_lines(DEF_SH_OUT, GOOD_PROC_SH_OUT))
         self.assertFalse(diff_lines(OPT_SH_OUT, GOOD_PROC_OPT_SH_OUT))
     finally:
         for fname in [DEF_SH_OUT, OPT_SH_OUT]:
             silent_remove(fname, disable=DISABLE_REMOVE)
         pass
 def testFromPinnedAtomFileCase(self):
     test_input = ["-t", TPL_FILE, "-f", PINNED_ATOM_IN]
     try:
         main(test_input)
         self.assertFalse(diff_lines(PINNED_ATOM_OUT, GOOD_COM_OUT_FILE))
     finally:
         silent_remove(PINNED_ATOM_OUT, disable=DISABLE_REMOVE)
         pass
 def testMultipleHeaderLinesIni(self):
     test_input = ["-c", MORE_HEADER_LINES_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(PDB_MULT_HEADER_OUT, GOOD_PDB_OUT))
     finally:
         silent_remove(PDB_MULT_HEADER_OUT, disable=DISABLE_REMOVE)
         pass
 def testAltIni(self):
     test_input = ["-c", ALT_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(ALT_OUT, GOOD_ALT_OUT))
     finally:
         silent_remove(ALT_OUT, disable=DISABLE_REMOVE)
         pass
    def testSpecify2SetsCommandLine(self):
        # As ALT_INI, but command-line only
        # make sure old files are cleaned up before starting
        for fname in [REMOVE_H_OUT1, REMOVE_H_OUT2, REMOVE_H_OUT3]:
            silent_remove(fname)

        test_input = ["-t", 'tests/test_data/pdbs2gausscoms/gau.tpl',
                      '-f', 'tests/test_data/pdbs2gausscoms/pet_mono_f1hs.pdb', "-r", "-n", "2"]
        try:
            main(test_input)
            self.assertFalse(diff_lines(REMOVE_H_OUT1, GOOD_REMOVE_H_OUT1))
            self.assertFalse(diff_lines(REMOVE_H_OUT2, GOOD_REMOVE_H_OUT2))
            self.assertFalse(os.path.isfile(REMOVE_H_OUT3))
        finally:
            silent_remove(REMOVE_H_OUT1, disable=DISABLE_REMOVE)
            silent_remove(REMOVE_H_OUT2, disable=DISABLE_REMOVE)
            pass
 def testRouteNoChargeTpl(self):
     test_input = ["-t", ROUTE_NO_CHARGE_TPL, "-f", CP_COM_IN, "-c"]
     try:
         main(test_input)
         self.assertFalse(diff_lines(CP_COM_OUT, GOOD_ROUTE_ONLY_COM_OUT))
     finally:
         silent_remove(CP_COM_OUT, disable=DISABLE_REMOVE)
         pass
 def testLink0Ini(self):
     test_input = ["-c", LINK0_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(PDB_LINK0_OUT, GOOD_PDB_OUT))
     finally:
         silent_remove(PDB_LINK0_OUT, disable=DISABLE_REMOVE)
         pass
 def testFileCPTpl(self):
     test_input = ["-t", CP_COM_TPL, "-f", CP_COM_IN]
     try:
         main(test_input)
         self.assertFalse(diff_lines(CP_COM_OUT, GOOD_CP_COM_OUT))
     finally:
         silent_remove(CP_COM_OUT, disable=DISABLE_REMOVE)
         pass
예제 #29
0
 def testSaveSmi(self):
     try:
         test_input = ["-r", "10", "-o", TEST_SMI_BASENAME, "-d", SUB_DATA_DIR, "-a", "1.0"]
         main(test_input)
         self.assertFalse(diff_lines(TEST_SMI_OUT, GOOD_TEST_SMI_OUT))
     finally:
         silent_remove(TEST_SMI_OUT, disable=DISABLE_REMOVE)
         pass
 def testFromFileCase(self):
     test_input = ["-t", TPL_FILE, "-f", COM_IN_NO_CHARGE_FILE]
     try:
         main(test_input)
         self.assertFalse(diff_lines(MISSING_MULT_COM_OUT_FILE, GOOD_COM_OUT_FILE))
     finally:
         silent_remove(MISSING_MULT_COM_OUT_FILE, disable=DISABLE_REMOVE)
         pass