def test_answer_letters(self): residues = ["GLU30", "TRP32"] input_values = (val for val in ["0.0", "4.0"]) with mock.patch('builtins.input', lambda *x: next(input_values)): residue_and_atom.residues_from_descriptors(residues, self.by_bonds_geom2frags, self.geom2frags.top, )
def test_extra_dicts(self): residues = ["GLU30", "TRP32"] consensus_dicts = {"BW": {0: "3.50"}, "CGN": {2: "CGNt"}} residue_and_atom.residues_from_descriptors(residues, self.by_bonds_geom2frags, self.geom2frags.top, additional_resnaming_dicts=consensus_dicts, pick_this_fragment_by_default=0 )
def test_default_fragment_idx_is_none_ans_should_be_in_list(self): input_values = (val for val in ["123"]) with mock.patch('builtins.input', lambda *x: next(input_values)): with pytest.raises((ValueError, AssertionError)): residue_and_atom.residues_from_descriptors("GLU30", self.by_bonds_geom2frags, self.geom2frags.top) input_values = (val for val in ["123"]) with mock.patch('builtins.input', lambda *x: next(input_values)): with pytest.raises((ValueError, AssertionError)): residue_and_atom.residues_from_descriptors("30", self.by_bonds_geom2frags, self.geom2frags.top)
def test_default_fragment_idx_is_passed_special_case(self): with pytest.raises((ValueError, AssertionError)): residue_and_atom.residues_from_descriptors("GLU30", self.by_bonds_geom2frags, self.geom2frags.top, pick_this_fragment_by_default=99) with pytest.raises((ValueError, AssertionError)): residue_and_atom.residues_from_descriptors(30, self.by_bonds_geom2frags, self.geom2frags.top, pick_this_fragment_by_default=99)
def test_ambiguous_just_inform(self): residues = ["GLU30", 30] residxs, fragidx = residue_and_atom.residues_from_descriptors(residues, self.by_bonds_geom2frags, self.geom2frags.top, just_inform=True) self.assertListEqual(residxs,[0,8]) self.assertListEqual(fragidx,[0,4])
def test_no_ambiguous(self): residues = ["GLU30", "GDP382", 30, 382] residxs, fragidxs = residue_and_atom.residues_from_descriptors(residues, self.by_bonds_geom, self.geom.top) self.assertSequenceEqual([0,7,0,7], residxs) # GLU30 is the 1st residue # GDP382 is the 8th residue self.assertSequenceEqual([0,3,0,3], fragidxs)
def test_ambiguous(self): input_values = (val for val in ["4", "4"]) with mock.patch('builtins.input', lambda *x: next(input_values)): residues = ["GLU30", 30] residxs, fragidx = residue_and_atom.residues_from_descriptors(residues, self.by_bonds_geom2frags, self.geom2frags.top) self.assertSequenceEqual([8, 8], residxs) self.assertSequenceEqual([4, 4], fragidx) input_values = (val for val in ["3", "3"]) with mock.patch('builtins.input', lambda *x: next(input_values)): residues = ["GDP382", 382] residxs, fragidx = residue_and_atom.residues_from_descriptors(residues, self.by_bonds_geom2frags, self.geom2frags.top) self.assertSequenceEqual([7, 7], residxs) self.assertSequenceEqual([3, 3], fragidx)
def test_default_fragment_idx_is_passed(self): residues = ["GLU30", 30] residxs, fragidx = residue_and_atom.residues_from_descriptors(residues, self.by_bonds_geom2frags, self.geom2frags.top, pick_this_fragment_by_default=4) # Checking if residue names gives the correct corresponding residue id # NOTE:Enter 4 for GLU30 when asked "input one fragment idx" self.assertSequenceEqual([8, 8], residxs) self.assertSequenceEqual([4, 4], fragidx)
def test_fragment_idx_is_none_last_answer(self): residues = ["GLU30", 30] input_values = (val for val in ["", ""]) with mock.patch('builtins.input', lambda *x: next(input_values)): residxs, fragidxs = residue_and_atom.residues_from_descriptors(residues, self.by_bonds_geom2frags, self.geom2frags.top) # NOTE:Accepted default "" for GLU30 when asked "input one fragment idx" self.assertSequenceEqual(residxs, [0, 0]) self.assertSequenceEqual(fragidxs, [0, 0])
def test_fragment_name(self): residues = ["GLU30", 30] input_values = (val for val in ["0", "0"]) with mock.patch('builtins.input', lambda *x: next(input_values)): residxs, fragidx = residue_and_atom.residues_from_descriptors(residues, self.by_bonds_geom2frags, self.geom2frags.top, fragment_names=["A", "B", "C", "D", "E", "F", "G", "H"]) # Checking if residue names gives the correct corresponding residue id # NOTE:Enter 0 for GLU30 when asked "input one fragment idx" self.assertSequenceEqual([0, 0], residxs) self.assertSequenceEqual([0, 0], fragidx)
def test_idx_not_present(self): residxs, fragidx = residue_and_atom.residues_from_descriptors(["GLU99", 99], self.by_bonds_geom2frags, self.geom2frags.top, pick_this_fragment_by_default=99) self.assertSequenceEqual([None, None], residxs) self.assertSequenceEqual([None, None], fragidx)
def test_not_in_fragment(self): residues = ["GLU30"] with pytest.raises(ValueError): residue_and_atom.residues_from_descriptors(residues, [np.arange(3,5)], self.geom.top)
def test_overlaping_frags(self): residues = ["GLU30"] with pytest.raises(ValueError): residue_and_atom.residues_from_descriptors(residues, [np.arange(self.geom.n_residues), [np.arange(self.geom.n_residues)]], self.geom.top)