From d22606a18d25a85e697638f019cfa9b95b4ab207 Mon Sep 17 00:00:00 2001 From: Richard Gowers Date: Fri, 22 Jan 2016 14:18:06 +0000 Subject: [PATCH 1/2] Added extra resnames to 'nucleic' selection Closes issue #461 --- package/CHANGELOG | 2 + package/MDAnalysis/core/Selection.py | 6 ++- testsuite/MDAnalysisTests/data/nucl_res.pdb | 37 +++++++++++++++++++ testsuite/MDAnalysisTests/datafiles.py | 4 ++ .../MDAnalysisTests/test_atomselections.py | 9 ++++- 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 testsuite/MDAnalysisTests/data/nucl_res.pdb diff --git a/package/CHANGELOG b/package/CHANGELOG index ed7665c1b68..ebeae4f1b5f 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -37,6 +37,8 @@ Fixes (Issue #639) * The 'atom' selection keyword returns an empty selection rather than an error when no atoms are are found. (Issue #644) + * nucleic selection will now detect nucleic residue names suffixed with 3 or 5 + (Issue #461) 01/16/16 tyler.je.reddy, kain88-de, richardjgowers, manuel.nuno.melo, diff --git a/package/MDAnalysis/core/Selection.py b/package/MDAnalysis/core/Selection.py index 823313ea04c..fe74df3f229 100644 --- a/package/MDAnalysis/core/Selection.py +++ b/package/MDAnalysis/core/Selection.py @@ -735,7 +735,11 @@ class NucleicSelection(Selection): nucl_res = np.array([ 'ADE', 'URA', 'CYT', 'GUA', 'THY', 'DA', 'DC', 'DG', 'DT', 'RA', - 'RU', 'RG', 'RC', 'A', 'T', 'U', 'C', 'G' + 'RU', 'RG', 'RC', 'A', 'T', 'U', 'C', 'G', + 'DA5', 'DC5', 'DG5', 'DT5', + 'DA3', 'DC3', 'DG3', 'DT3', + 'RA5', 'RU5', 'RG5', 'RC5', + 'RA3', 'RU3', 'RG3', 'RC3' ]) def __init__(self, parser, tokens): diff --git a/testsuite/MDAnalysisTests/data/nucl_res.pdb b/testsuite/MDAnalysisTests/data/nucl_res.pdb new file mode 100644 index 00000000000..b5742578c27 --- /dev/null +++ b/testsuite/MDAnalysisTests/data/nucl_res.pdb @@ -0,0 +1,37 @@ +MODEL +CRYST1 80.000 80.000 80.000 60.00 60.00 90.00 +ATOM 1 CA ADE 1 00.000 00.000 00.000 1.00 84.71 +ATOM 2 CA URA 2 01.000 01.000 01.000 1.00 68.59 +ATOM 3 CA CYT 3 02.000 02.000 02.000 1.00 48.30 +ATOM 4 CA GUA 4 03.000 03.000 03.000 1.00 49.38 +ATOM 5 CA THY 5 04.000 04.000 04.000 1.00 42.10 +ATOM 6 CA DA 6 04.000 04.000 04.000 1.00 42.10 +ATOM 7 CA DC 7 04.000 04.000 04.000 1.00 42.10 +ATOM 8 CA DG 8 04.000 04.000 04.000 1.00 42.10 +ATOM 9 CA DT 9 04.000 04.000 04.000 1.00 42.10 +ATOM 10 CA RA 10 04.000 04.000 04.000 1.00 42.10 +ATOM 11 CA RU 11 04.000 04.000 04.000 1.00 42.10 +ATOM 12 CA RG 12 04.000 04.000 04.000 1.00 42.10 +ATOM 13 CA RC 13 04.000 04.000 04.000 1.00 42.10 +ATOM 14 CA A 14 04.000 04.000 04.000 1.00 42.10 +ATOM 15 CA T 15 04.000 04.000 04.000 1.00 42.10 +ATOM 16 CA U 16 04.000 04.000 04.000 1.00 42.10 +ATOM 17 CA C 17 04.000 04.000 04.000 1.00 42.10 +ATOM 18 CA G 18 04.000 04.000 04.000 1.00 42.10 +ATOM 19 CA DA5 19 04.000 04.000 04.000 1.00 42.10 +ATOM 20 CA DC5 20 04.000 04.000 04.000 1.00 42.10 +ATOM 21 CA DG5 21 04.000 04.000 04.000 1.00 42.10 +ATOM 22 CA DT5 22 04.000 04.000 04.000 1.00 42.10 +ATOM 23 CA DA3 23 04.000 04.000 04.000 1.00 42.10 +ATOM 24 CA DC3 24 04.000 04.000 04.000 1.00 42.10 +ATOM 25 CA DG3 25 04.000 04.000 04.000 1.00 42.10 +ATOM 26 CA DT3 26 04.000 04.000 04.000 1.00 42.10 +ATOM 27 CA RA5 27 04.000 04.000 04.000 1.00 42.10 +ATOM 28 CA RU5 28 04.000 04.000 04.000 1.00 42.10 +ATOM 29 CA RG5 29 04.000 04.000 04.000 1.00 42.10 +ATOM 30 CA RC5 30 04.000 04.000 04.000 1.00 42.10 +ATOM 31 CA RA3 31 04.000 04.000 04.000 1.00 42.10 +ATOM 32 CA RU3 32 04.000 04.000 04.000 1.00 42.10 +ATOM 33 CA RG3 33 04.000 04.000 04.000 1.00 42.10 +ATOM 34 CA RC3 34 04.000 04.000 04.000 1.00 42.10 +END diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index acd5a8fc9dc..63be4804615 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -105,6 +105,7 @@ "COORDINATES_XTC", "COORDINATES_TRR", "COORDINATES_TOPOLOGY", + "NUCLsel", ] from pkg_resources import resource_filename @@ -294,3 +295,6 @@ Plength = resource_filename(__name__, 'data/plength.gro') Martini_membrane_gro = resource_filename(__name__, 'data/martini_dppc_chol_bilayer.gro') + +# Contains one of each residue in 'nucleic' selections +NUCLsel = resource_filename(__name__, 'data/nucl_res.pdb') diff --git a/testsuite/MDAnalysisTests/test_atomselections.py b/testsuite/MDAnalysisTests/test_atomselections.py index 7fdf629b349..fac2b6cde17 100644 --- a/testsuite/MDAnalysisTests/test_atomselections.py +++ b/testsuite/MDAnalysisTests/test_atomselections.py @@ -42,7 +42,7 @@ PSF, DCD, PRMpbc, TRJpbc_bz2, PSF_NAMD, PDB_NAMD, - GRO, NUCL, TPR, XTC, + GRO, NUCL, NUCLsel, TPR, XTC, TRZ_psf, TRZ, PDB_full, ) @@ -464,6 +464,13 @@ def test_nucleic(self): assert_equal(rna.n_atoms, 739) assert_equal(rna.n_residues, 23) + def test_nucleic_all(self): + u = mda.Universe(NUCLsel) + + sel = u.select_atoms('nucleic') + + assert_(len(sel) == len(u.atoms)) + def test_nucleicbackbone(self): rna = self.universe.select_atoms("nucleicbackbone") assert_equal(rna.n_residues, 23) From 8bb8d38468e60d6521e56ad5df95bf67118657c2 Mon Sep 17 00:00:00 2001 From: Richard Gowers Date: Fri, 22 Jan 2016 14:54:30 +0000 Subject: [PATCH 2/2] Updated nuclres tests to include non selected atoms --- testsuite/MDAnalysisTests/data/nucl_res.pdb | 5 +++++ testsuite/MDAnalysisTests/test_atomselections.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/data/nucl_res.pdb b/testsuite/MDAnalysisTests/data/nucl_res.pdb index b5742578c27..3594c788a92 100644 --- a/testsuite/MDAnalysisTests/data/nucl_res.pdb +++ b/testsuite/MDAnalysisTests/data/nucl_res.pdb @@ -34,4 +34,9 @@ ATOM 31 CA RA3 31 04.000 04.000 04.000 1.00 42.10 ATOM 32 CA RU3 32 04.000 04.000 04.000 1.00 42.10 ATOM 33 CA RG3 33 04.000 04.000 04.000 1.00 42.10 ATOM 34 CA RC3 34 04.000 04.000 04.000 1.00 42.10 +ATOM 35 CA TAF 35 04.000 04.000 04.000 1.00 42.10 +ATOM 36 CA ERU 36 04.000 04.000 04.000 1.00 42.10 +ATOM 37 CA SEN 37 04.000 04.000 04.000 1.00 42.10 +ATOM 38 CA T__ 38 04.000 04.000 04.000 1.00 42.10 +ATOM 39 CA S__ 39 04.000 04.000 04.000 1.00 42.10 END diff --git a/testsuite/MDAnalysisTests/test_atomselections.py b/testsuite/MDAnalysisTests/test_atomselections.py index fac2b6cde17..b657592e7c9 100644 --- a/testsuite/MDAnalysisTests/test_atomselections.py +++ b/testsuite/MDAnalysisTests/test_atomselections.py @@ -469,7 +469,7 @@ def test_nucleic_all(self): sel = u.select_atoms('nucleic') - assert_(len(sel) == len(u.atoms)) + assert_(len(sel) == 34) def test_nucleicbackbone(self): rna = self.universe.select_atoms("nucleicbackbone")