mailr8907 - in /branches/bmrb: bmrblib/assembly_supercategory/entity.py generic_fns/mol_res_spin.py specific_fns/model_free/bmrb.py


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

Header


Content

Posted by edward on March 05, 2009 - 15:07:
Author: bugman
Date: Thu Mar  5 15:07:18 2009
New Revision: 8907

URL: http://svn.gna.org/viewcvs/relax?rev=8907&view=rev
Log:
The Entity saveframes are now being read and the sequence info recreated.


Modified:
    branches/bmrb/bmrblib/assembly_supercategory/entity.py
    branches/bmrb/generic_fns/mol_res_spin.py
    branches/bmrb/specific_fns/model_free/bmrb.py

Modified: branches/bmrb/bmrblib/assembly_supercategory/entity.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/assembly_supercategory/entity.py?rev=8907&r1=8906&r2=8907&view=diff
==============================================================================
--- branches/bmrb/bmrblib/assembly_supercategory/entity.py (original)
+++ branches/bmrb/bmrblib/assembly_supercategory/entity.py Thu Mar  5 
15:07:18 2009
@@ -101,6 +101,40 @@
         self.entity_comp_index = EntityCompIndex(self)
 
 
+    def loop(self):
+        """Loop over the entity saveframes, yielding the entity info.
+
+        @return:    The entity information consisting of the molecule name, 
molecule type, residue
+                    numbers, and residue names.
+        @rtype:     tuple of str, str, list of int, list of str
+        """
+
+        # Loop over all datanodes.
+        for datanode in self.datanodes:
+            # Find the Entity saveframes via the SfCategory tag index.
+            found = False
+            for index in range(len(datanode.tagtables[0].tagnames)):
+                # First match the tag names.
+                if datanode.tagtables[0].tagnames[index] == 
self.entity.create_tag_label(self.entity.tag_names['SfCategory']):
+                    # Then the tag value.
+                    if datanode.tagtables[0].tagvalues[index][0] == 'entity':
+                        found = True
+                        break
+
+            # Skip the datanode.
+            if not found:
+                continue
+
+            # Get entity info.
+            mol_name, mol_type = self.entity.read(datanode.tagtables[0])
+
+            # Get the EntityCompIndex info.
+            res_nums, res_names = 
self.entity_comp_index.read(datanode.tagtables[1])
+
+            # Yield the data.
+            yield mol_name, mol_type, res_nums, res_names
+
+
 class Entity(TagCategory):
     """Base class for the Entity tag category."""
 
@@ -118,6 +152,23 @@
 
         # The entity type.
         self.sf.frame.tagtables.append(TagTable(free=True, 
tagnames=[self.create_tag_label(self.tag_names['Type'])], 
tagvalues=[[self.sf.mol_type]]))
+
+
+    def read(self, tagtable):
+        """Extract the Entity tag category info.
+
+        @param tagtable:    The Entity tagtable.
+        @type tagtable:     Tagtable instance
+        @return:            The entity name and type.
+        @rtype:             tuple of str, str
+        """
+
+        # The entity info.
+        mol_name = 
tagtable.tagvalues[tagtable.tagnames.index(self.create_tag_label(self.tag_names['Name']))][0]
+        mol_type = 
tagtable.tagvalues[tagtable.tagnames.index(self.create_tag_label(self.tag_names['Type']))][0]
+
+        # Return the data.
+        return mol_name, mol_type
 
 
     def tag_setup(self, tag_category_label=None, sep=None):
@@ -170,6 +221,27 @@
         self.sf.frame.tagtables.append(table)
 
 
+    def read(self, tagtable):
+        """Extract the EntityCompIndex tag category info.
+
+        @param tagtable:    The Entity tagtable.
+        @type tagtable:     Tagtable instance
+        @return:            The residue numbers and names.
+        @rtype:             tuple of list of int, list of str
+        """
+
+        # The entity info.
+        res_nums = 
tagtable.tagvalues[tagtable.tagnames.index(self.create_tag_label(self.tag_names['EntityCompIndexID']))]
+        res_names = 
tagtable.tagvalues[tagtable.tagnames.index(self.create_tag_label(self.tag_names['CompID']))]
+
+        # Convert the residue numbers to ints.
+        for i in range(len(res_nums)):
+            res_nums[i] = int(res_nums[i])
+
+        # Return the data.
+        return res_nums, res_names
+
+
     def tag_setup(self, tag_category_label=None, sep=None):
         """Replacement method for setting up the tag names.
 

Modified: branches/bmrb/generic_fns/mol_res_spin.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/mol_res_spin.py?rev=8907&r1=8906&r2=8907&view=diff
==============================================================================
--- branches/bmrb/generic_fns/mol_res_spin.py (original)
+++ branches/bmrb/generic_fns/mol_res_spin.py Thu Mar  5 15:07:18 2009
@@ -488,6 +488,23 @@
         # Create the union.
         self._union = (select_obj0, select_obj1)
 
+
+
+def bmrb_read(star):
+    """Generate the molecule and residue spin containers from the entity 
saveframe records.
+
+    @param star:    The NMR-STAR dictionary object.
+    @type star:     NMR_STAR instance
+    """
+
+    # Get the entities.
+    for mol_name, mol_type, res_nums, res_names in star.entity.loop():
+        # Add the molecule.
+        create_molecule(mol_name)
+
+        # Add the residues.
+        for i in range(len(res_nums)):
+            create_residue(res_nums[i], res_names[i], mol_id='#'+mol_name)
 
 
 def bmrb_write_entity(star):

Modified: branches/bmrb/specific_fns/model_free/bmrb.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/specific_fns/model_free/bmrb.py?rev=8907&r1=8906&r2=8907&view=diff
==============================================================================
--- branches/bmrb/specific_fns/model_free/bmrb.py (original)
+++ branches/bmrb/specific_fns/model_free/bmrb.py Thu Mar  5 15:07:18 2009
@@ -42,6 +42,9 @@
         # Read the contents of the STAR formatted file.
         star.read()
 
+        # Generate the molecule and residue containers.
+        mol_res_spin.bmrb_read(star)
+
 
     def bmrb_write(self, file_path):
         """Write the model-free results to a BMRB NMR-STAR v3.1 formatted 
file.




Related Messages


Powered by MHonArc, Updated Thu Mar 05 16:40:03 2009