def test_excel(self): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: cli.residue_neighborhoods("395", [self.traj, self.traj_reverse], self.geom, table_ext=".xlsx", output_dir=tmpdir)
def test_AAs(self): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: cli.residue_neighborhoods("395", [self.traj, self.traj_reverse], self.geom, short_AA_names=True, output_dir=tmpdir, no_disk=self.no_disk)
def test_no_top(self): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: input_values = (val for val in ["1.0"]) with mock.patch('builtins.input', lambda *x: next(input_values)): cli.residue_neighborhoods("200,395", self.geom, output_dir=tmpdir, no_disk=self.no_disk)
def test_no_bonds_fail(self): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: top = self.geom[0] top.top._bonds = [] with pytest.raises(ValueError): cli.residue_neighborhoods("R131", [self.traj, self.traj_reverse], top, output_dir=tmpdir)
def test_wrong_input_resSeq_idxs(self): with pytest.raises(ValueError): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: cli.residue_neighborhoods("AX*", [self.traj, self.traj_reverse], self.geom, distro=True, output_dir=tmpdir, no_disk=self.no_disk)
def test_precomputed_raises(self): with pytest.raises(ValueError): cli.residue_neighborhoods([1043], [self.traj, self.traj_reverse], self.geom, res_idxs=True, no_disk=False, figures=False, pre_computed_contact_matrix=_np.zeros((self.geom.n_residues, self.geom.n_residues + 1)))
def test_some_CG_have_no_contacts(self): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: cli.residue_neighborhoods("0-3", [self.traj, self.traj_reverse], self.geom, ctc_cutoff_Ang=3.2, res_idxs=True, output_dir=tmpdir, no_disk=self.no_disk )
def test_nomenclature_BW(self): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: cli.residue_neighborhoods("R131", [self.traj, self.traj_reverse], self.geom, BW_uniprot=test_filenames.adrb2_human_xlsx, output_dir=tmpdir, accept_guess=True, no_disk=self.no_disk )
def test_res_idxs(self): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: cli.residue_neighborhoods("1043", [self.traj, self.traj_reverse], self.geom, fragment_colors=True, allow_same_fragment_ctcs=False, short_AA_names=True, res_idxs=True, output_dir=tmpdir, no_disk=self.no_disk)
def test_neighborhoods_no_disk_works(self): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: with remember_cwd(): os.chdir(tmpdir) input_values = (val for val in ["1.0"]) with mock.patch('builtins.input', lambda *x: next(input_values)): cli.residue_neighborhoods("200,395", self.traj, self.geom, no_disk=True ) assert len(os.listdir(".")) == 0
def test_nomenclature_CGN(self): with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: shutil.copy(test_filenames.CGN_3SN6, tmpdir) shutil.copy(test_filenames.pdb_3SN6, tmpdir) with remember_cwd(): os.chdir(tmpdir) cli.residue_neighborhoods("R131", [self.traj, self.traj_reverse], self.geom, CGN_PDB="3SN6", output_dir=tmpdir, accept_guess=True, no_disk=self.no_disk )
def test_precomputed(self): CG1 = list(cli.residue_neighborhoods([1043], [self.traj, self.traj_reverse], self.geom, res_idxs=True, no_disk=True, figures=False)["neighborhoods"].values())[0] CG2 = list(cli.residue_neighborhoods([1043], [self.traj, self.traj_reverse], self.geom, res_idxs=True, no_disk=True, figures=False, pre_computed_contact_matrix=_np.zeros((self.geom.n_residues, self.geom.n_residues)))[ "neighborhoods"].values())[0] _np.testing.assert_array_equal(CG1.frequency_per_contact(3.5), CG2.frequency_per_contact(3.5))
def test_no_residues_returns_None(self): # This is more of an argparse fail # TODO consider throwing exception with TemporaryDirectory(suffix='_test_mdciao') as tmpdir: assert None == cli.residue_neighborhoods(None, [self.traj, self.traj_reverse], self.geom, None, distro=True, output_dir=tmpdir, no_disk=self.no_disk)
# (at your option) any later version. # # mdciao is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with mdciao. If not, see <https://www.gnu.org/licenses/>. ############################################################################## from mdciao.parsers import parser_for_rn, _inform_of_parser from mdciao.cli import residue_neighborhoods # Get and instantiate parser parser = parser_for_rn() a = parser.parse_args() if not a.fragmentify: a.fragments=["None"] a.fragment_names="None" # Make a dictionary out ot of it and pop the positional keywords b = {key:getattr(a,key) for key in dir(a) if not key.startswith("_")} for key in ["trajectories","residues", "fragmentify"]: b.pop(key) # Call the method out_dict = residue_neighborhoods(a.residues, a.trajectories, **b)
def test_no_contacts_at_allp(self): cli.residue_neighborhoods("R131", [self.traj, self.traj_reverse], self.geom, ctc_cutoff_Ang=.1, )