mailr27289 - /trunk/lib/structure/internal/object.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on January 23, 2015 - 11:06:
Author: bugman
Date: Fri Jan 23 11:06:53 2015
New Revision: 27289

URL: http://svn.gna.org/viewcvs/relax?rev=27289&view=rev
Log:
Implemented the internal structural object one_letter_codes() method.

This will create a string of one letter residue codes for the given molecule. 
 Only proteins are
currently supported.  This method uses the new 
lib.sequence.aa_codes_three_to_one() relax library
function.


Modified:
    trunk/lib/structure/internal/object.py

Modified: trunk/lib/structure/internal/object.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/structure/internal/object.py?rev=27289&r1=27288&r2=27289&view=diff
==============================================================================
--- trunk/lib/structure/internal/object.py      (original)
+++ trunk/lib/structure/internal/object.py      Fri Jan 23 11:06:53 2015
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2003-2014 Edward d'Auvergne                                  
 #
+# Copyright (C) 2003-2015 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -39,6 +39,7 @@
 from lib.errors import RelaxError, RelaxNoneIntError, RelaxNoPdbError
 from lib.io import file_root, open_read_file
 from lib.selection import Selection
+from lib.sequence import aa_codes_three_to_one
 from lib.structure import pdb_read, pdb_write
 from lib.structure.internal.displacements import Displacements
 from lib.structure.internal.models import ModelList
@@ -2266,6 +2267,38 @@
         return len(self.structural_data[0].mol)
 
 
+    def one_letter_codes(self, mol_name=None):
+        """Generate and return the one letter code sequence for the given 
molecule.
+
+        @keyword mol_name:  The name of the molecule to return the one 
letter codes for.
+        @type mol_name:     str
+        @return:            The one letter code sequence for the given 
molecule.
+        @rtype:             str
+        """
+
+        # Initialise.
+        codes = ''
+
+        # Use the first model.
+        model = self.structural_data[0]
+
+        # Loop over the molecules.
+        for mol_index in range(len(model.mol)):
+            # Alias.
+            mol = model.mol[mol_index]
+
+            # Skip non-matching molecules.
+            if mol_name and mol_name != mol.mol_name:
+                continue
+
+            # Loop over the residues.
+            for res_name, res_num in mol.loop_residues():
+                codes += aa_codes_three_to_one(res_name)
+            
+        # Return the codes.
+        return codes
+
+
     def pack_structs(self, data_matrix, orig_model_num=None, 
set_model_num=None, orig_mol_num=None, set_mol_name=None, file_name=None, 
file_path=None, file_path_abs=None, verbosity=1, merge=False):
         """From the given structural data, expand the structural data data 
structure.
 




Related Messages


Powered by MHonArc, Updated Fri Jan 23 11:20:02 2015