def test_wrong_length(multi_mol_system_irregular, sequence): """ Many molecule and a sequence that has the wrong length raises an error. """ processor = dssp.AnnotateResidues('test', sequence) with pytest.raises(ValueError): processor.run_system(multi_mol_system_irregular)
def test_empty_system_error(): """ There are no molecules, but there is a sequence. Should raise an error. """ system = vermouth.system.System() sequence = 'not empty' processor = dssp.AnnotateResidues('test', sequence) with pytest.raises(ValueError): processor.run_system(system)
def test_multi_molecules_cycle_one(self, multi_mol_system_irregular): """ Many molecules and a one element sequence to repeat. """ sequence = 'A' expected = [sequence] * (15 * 3) processor = dssp.AnnotateResidues('test', sequence) processor.run_system(multi_mol_system_irregular) found = self.sequence_from_system(multi_mol_system_irregular, 'test') assert found == expected
def test_run_molecule(self, single_mol_system): """ The `run_molecule` method works. """ sequence = 'ABCDE' expected = list( itertools.chain(*([element] * 3 for element in sequence))) processor = dssp.AnnotateResidues('test', sequence) processor.run_molecule(single_mol_system.molecules[0]) found = self.sequence_from_system(single_mol_system, 'test') assert found == expected
def test_empty_with_filter(multi_mol_system_irregular): """ There is a sequence, but no molecule are accepted by the molecule selector. Should raise an error. """ sequence = 'not empty' processor = dssp.AnnotateResidues('test', sequence, molecule_selector=lambda mol: False) with pytest.raises(ValueError): processor.run_system(multi_mol_system_irregular)
def test_empty_system_empty_sequence(): """ There are no molecules, but the sequence is empty. """ system = vermouth.system.System() sequence = '' processor = dssp.AnnotateResidues('test', sequence) try: processor.run_system(system) except ValueError: pytest.fail('Should not have raised a ValueError.')
def test_single_molecules_cycle_one(self, single_mol_system): """ One molecule and a one element sequence to repeat over all residues of the molecule. """ sequence = 'A' expected = [sequence] * (5 * 3) processor = dssp.AnnotateResidues('test', sequence) processor.run_system(single_mol_system) found = self.sequence_from_system(single_mol_system, 'test') assert found == expected
def test_single_molecule(self, single_mol_system, sequence): """ The simple case with a single molecule and a sequence of the right size works as expected. """ expected = list( itertools.chain(*([element] * 3 for element in sequence))) processor = dssp.AnnotateResidues('test', sequence) processor.run_system(single_mol_system) found = self.sequence_from_system(single_mol_system, 'test') assert found == expected
def test_run_molecule_not_selected(self, single_mol_system): """ The molecule selector works with `run_molecule`. """ sequence = 'ABCDE' processor = dssp.AnnotateResidues('test', sequence, molecule_selector=lambda mol: False) processor.run_molecule(single_mol_system.molecules[0]) found = self.sequence_from_system(single_mol_system, 'test') assert vermouth.utils.are_all_equal(found) assert found[0] is None
def test_multi_molecules_cycle(self, multi_mol_system_regular, sequence): """ The case with multiple molecules with all the same size and one sequence to repeat for each molecule works as expected. """ expected = list( itertools.chain(*([element] * 3 for element in sequence))) expected = expected * 3 processor = dssp.AnnotateResidues('test', sequence) processor.run_system(multi_mol_system_regular) found = self.sequence_from_system(multi_mol_system_regular, 'test') assert found == expected
def test_multi_molecules_diff_sizes(self, multi_mol_system_irregular, sequence): """ The case of many protein of various sizes and a sequence of the right size works as expected. """ expected = list( itertools.chain(*([element] * 3 for element in sequence))) processor = dssp.AnnotateResidues('test', sequence) processor.run_system(multi_mol_system_irregular) found = self.sequence_from_system(multi_mol_system_irregular, 'test') assert found == expected
def test_wrong_length_with_filter(multi_mol_system_irregular, sequence): """ Many molecules and a sequence that has the wrong length because of a molecule selector. """ # We exclude the second molecule. The filter excludes it based on the # number of nodes, which is 15 because it has 5 residues with 3 nodes # each. processor = dssp.AnnotateResidues( 'test', sequence, molecule_selector=lambda mol: len(mol.nodes) != (5 * 3), ) with pytest.raises(ValueError): processor.run_system(multi_mol_system_irregular)