From 71ac64a5518fad0311fc1ac3035bfb7721e05111 Mon Sep 17 00:00:00 2001 From: Sam Ireland Date: Fri, 11 Aug 2017 12:38:07 +0100 Subject: [PATCH] Final 0.3 changes --- README.rst | 10 ++++++++ atomium/structures/chains.py | 23 ++++++++++--------- atomium/structures/models.py | 4 +++- docs/source/changelog.rst | 10 ++++++++ .../structure_tests/test_residue_sequences.py | 5 ++++ 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 050a5952..5fd69f60 100644 --- a/README.rst +++ b/README.rst @@ -164,6 +164,16 @@ The ``Xyz`` object itself can also be saved: Changelog --------- +Release 0.3.0 +~~~~~~~~~~~~~ + +`11 August 2017` + +* Added classes for Molecules, Chains, Residues, and their interfaces. +* Added charges to atoms and structures. +* Add ability to create AtomicStructures from AtomicStructures. + + Release 0.2.0 ~~~~~~~~~~~~~ diff --git a/atomium/structures/chains.py b/atomium/structures/chains.py index 791b1e0b..3b12ee4a 100644 --- a/atomium/structures/chains.py +++ b/atomium/structures/chains.py @@ -92,17 +92,18 @@ def verify(sequence): residues = set() for atom in sequence.atoms(): residues.add(atom.residue()) - seq = [list(residues)[0]] - while seq[-1].next() is not None and seq[-1].next() in residues: - seq.append(seq[-1].next()) - while seq[-1].previous() is not None and seq[-1].previous() in residues: - seq.append(seq[-1].previous()) - if set(seq) != residues: - raise SequenceConnectivityError( - "{} missing from sequence {} - check connections".format( - residues, residues - set(seq) - ) - ) + if residues: + seq = [list(residues)[0]] + while seq[-1].next() is not None and seq[-1].next() in residues: + seq.append(seq[-1].next()) + while seq[-1].previous() is not None and seq[-1].previous() in residues: + seq.append(seq[-1].previous()) + if set(seq) != residues: + raise SequenceConnectivityError( + "{} missing from sequence {} - check connections".format( + residues, residues - set(seq) + ) + ) return True diff --git a/atomium/structures/models.py b/atomium/structures/models.py index aa58ecea..62b8a6f6 100644 --- a/atomium/structures/models.py +++ b/atomium/structures/models.py @@ -94,7 +94,9 @@ def molecules(self, molecule_id=None, name=None, generic=False): lambda m: not isinstance(m, (Residue, Chain)), molecules )) if molecule_id: - molecules = set(filter(lambda m: m.molecule_id() == molecule_id, molecules)) + molecules = set(filter( + lambda m: m.molecule_id() == molecule_id, molecules + )) if name: molecules = set(filter(lambda m: m.name() == name, molecules)) return molecules diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 8c0bd9d4..cae4454b 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,6 +1,16 @@ Changelog --------- +Release 0.3.0 +~~~~~~~~~~~~~ + +`11 August 2017` + +* Added classes for Molecules, Chains, Residues, and their interfaces. +* Added charges to atoms and structures. +* Add ability to create AtomicStructures from AtomicStructures. + + Release 0.2.0 ~~~~~~~~~~~~~ diff --git a/tests/structure_tests/test_residue_sequences.py b/tests/structure_tests/test_residue_sequences.py index d03f119e..e35ba1e1 100644 --- a/tests/structure_tests/test_residue_sequences.py +++ b/tests/structure_tests/test_residue_sequences.py @@ -137,6 +137,11 @@ def test_can_reject_unconnected_residues(self): ResidueSequence.verify(self.sequence) + def test_empty_sequences_pass(self): + self.sequence.atoms = lambda: set() + self.assertTrue(ResidueSequence.verify(self.sequence)) + + class ResidueSequenceLengthTests(ResidueSequenceTest):