mailr8946 - in /branches/bmrb/bmrblib: ./ assembly_supercategory/ kinetics/


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

Header


Content

Posted by edward on March 10, 2009 - 11:09:
Author: bugman
Date: Tue Mar 10 11:09:26 2009
New Revision: 8946

URL: http://svn.gna.org/viewcvs/relax?rev=8946&view=rev
Log:
Large code simplification via abstraction.

Most of the code from the create() method of the non-free TagTables has been 
abstracted away into
the TagCategory.create_tag_table() method.


Modified:
    branches/bmrb/bmrblib/assembly_supercategory/entity.py
    branches/bmrb/bmrblib/kinetics/heteronucl_NOEs.py
    branches/bmrb/bmrblib/kinetics/heteronucl_T1_relaxation.py
    branches/bmrb/bmrblib/kinetics/heteronucl_T2_relaxation.py
    branches/bmrb/bmrblib/kinetics/relax_base.py
    branches/bmrb/bmrblib/tag_category.py

Modified: branches/bmrb/bmrblib/assembly_supercategory/entity.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/assembly_supercategory/entity.py?rev=8946&r1=8945&r2=8946&view=diff
==============================================================================
--- branches/bmrb/bmrblib/assembly_supercategory/entity.py (original)
+++ branches/bmrb/bmrblib/assembly_supercategory/entity.py Tue Mar 10 
11:09:26 2009
@@ -81,6 +81,9 @@
 
         # Increment the number of entities.
         self.entity_num = self.entity_num + 1
+
+        # The entity ID list.
+        self.entity_ids = [str(self.entity_num)]*len(self.res_nums)
 
         # Initialise the save frame.
         self.frame = SaveFrame(title=mol_name)
@@ -196,26 +199,15 @@
     def create(self):
         """Create the Entity tag category."""
 
-        # The tag names.
-        tag_names = []
-        missing = []
-        for key in ['EntityCompIndexID', 'AuthSeqID', 'CompID', 'CompLabel', 
'SfID', 'EntryID', 'EntityID']:
-            if not self.tag_names.has_key(key):
-                missing.append(key)
-            else:
-                tag_names.append(self.tag_names_full[key])
-
-        # The tag values.
-        tag_values = []
-        if 'EntityCompIndexID' not in missing:
-            tag_values.append(self.sf.res_nums)
-        if 'CompID' not in missing:
-            tag_values.append(self.sf.res_names)
-        if 'EntityID' not in missing:
-            
tag_values.append([str(self.sf.entity_num)]*len(self.sf.res_nums))
-
-        # Add the data.
-        table = TagTable(tagnames=tag_names, tagvalues=tag_values)
+        # Keys and objects.
+        info = [
+            ['EntityCompIndexID',   'res_nums'],
+            ['CompID',              'res_names'],
+            ['EntityID',            'entity_ids']
+        ]
+
+        # Get the TabTable.
+        table = self.create_tag_table(info)
 
         # Add the tagtable to the save frame.
         self.sf.frame.tagtables.append(table)

Modified: branches/bmrb/bmrblib/kinetics/heteronucl_NOEs.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/kinetics/heteronucl_NOEs.py?rev=8946&r1=8945&r2=8946&view=diff
==============================================================================
--- branches/bmrb/bmrblib/kinetics/heteronucl_NOEs.py (original)
+++ branches/bmrb/bmrblib/kinetics/heteronucl_NOEs.py Tue Mar 10 11:09:26 2009
@@ -188,38 +188,6 @@
 class HeteronuclNOE(Rx):
     """Base class for the HeteronuclNOE tag category."""
 
-    def create(self):
-        """Create the HeteronuclNOE tag category."""
-
-        # The relaxation tag names.
-        tag_names = []
-        missing = []
-        for key in ['CompIndexID', 'CompID', 'AtomID', 'Val', 'ValErr']:
-            if not self.tag_names.has_key(key):
-                missing.append(key)
-            else:
-                tag_names.append(self.tag_names_full[key])
-
-        # The tag values.
-        tag_values = []
-        if 'CompIndexID' not in missing:
-            tag_values.append(self.sf.res_nums)
-        if 'CompID' not in missing:
-            tag_values.append(self.sf.res_names)
-        if 'AtomID' not in missing:
-            tag_values.append(self.sf.atom_names)
-        if 'Val' not in missing:
-            tag_values.append(self.sf.data)
-        if 'ValErr' not in missing:
-            tag_values.append(self.sf.errors)
-
-        # Add the data.
-        table = TagTable(tagnames=tag_names, tagvalues=tag_values)
-
-        # Add the tagtable to the save frame.
-        self.sf.frame.tagtables.append(table)
-
-
     def tag_setup(self, tag_category_label=None, sep=None):
         """Replacement method for setting up the tag names.
 

Modified: branches/bmrb/bmrblib/kinetics/heteronucl_T1_relaxation.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/kinetics/heteronucl_T1_relaxation.py?rev=8946&r1=8945&r2=8946&view=diff
==============================================================================
--- branches/bmrb/bmrblib/kinetics/heteronucl_T1_relaxation.py (original)
+++ branches/bmrb/bmrblib/kinetics/heteronucl_T1_relaxation.py Tue Mar 10 
11:09:26 2009
@@ -197,38 +197,6 @@
 class T1(Rx):
     """Base class for the T1 tag category."""
 
-    def create(self):
-        """Create the T1 tag category."""
-
-        # The relaxation tag names.
-        tag_names = []
-        missing = []
-        for key in ['CompIndexID', 'CompID', 'AtomID', 'Val', 'ValErr']:
-            if not self.tag_names.has_key(key):
-                missing.append(key)
-            else:
-                tag_names.append(self.tag_names_full[key])
-
-        # The tag values.
-        tag_values = []
-        if 'CompIndexID' not in missing:
-            tag_values.append(self.sf.res_nums)
-        if 'CompID' not in missing:
-            tag_values.append(self.sf.res_names)
-        if 'AtomID' not in missing:
-            tag_values.append(self.sf.atom_names)
-        if 'Val' not in missing:
-            tag_values.append(self.sf.data)
-        if 'ValErr' not in missing:
-            tag_values.append(self.sf.errors)
-
-        # Add the data.
-        table = TagTable(tagnames=tag_names, tagvalues=tag_values)
-
-        # Add the tagtable to the save frame.
-        self.sf.frame.tagtables.append(table)
-
-
     def tag_setup(self, tag_category_label=None, sep=None):
         """Replacement method for setting up the tag names.
 

Modified: branches/bmrb/bmrblib/kinetics/heteronucl_T2_relaxation.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/kinetics/heteronucl_T2_relaxation.py?rev=8946&r1=8945&r2=8946&view=diff
==============================================================================
--- branches/bmrb/bmrblib/kinetics/heteronucl_T2_relaxation.py (original)
+++ branches/bmrb/bmrblib/kinetics/heteronucl_T2_relaxation.py Tue Mar 10 
11:09:26 2009
@@ -197,38 +197,6 @@
 class T2(Rx):
     """Base class for the T2 tag category."""
 
-    def create(self):
-        """Create the T2 tag category."""
-
-        # The relaxation tag names.
-        tag_names = []
-        missing = []
-        for key in ['CompIndexID', 'CompID', 'AtomID', 'Val', 'ValErr']:
-            if not self.tag_names.has_key(key):
-                missing.append(key)
-            else:
-                tag_names.append(self.tag_names_full[key])
-
-        # The tag values.
-        tag_values = []
-        if 'CompIndexID' not in missing:
-            tag_values.append(self.sf.res_nums)
-        if 'CompID' not in missing:
-            tag_values.append(self.sf.res_names)
-        if 'AtomID' not in missing:
-            tag_values.append(self.sf.atom_names)
-        if 'Val' not in missing:
-            tag_values.append(self.sf.data)
-        if 'ValErr' not in missing:
-            tag_values.append(self.sf.errors)
-
-        # Add the data.
-        table = TagTable(tagnames=tag_names, tagvalues=tag_values)
-
-        # Add the tagtable to the save frame.
-        self.sf.frame.tagtables.append(table)
-
-
     def tag_setup(self, tag_category_label=None, sep=None):
         """Replacement method for setting up the tag names.
 

Modified: branches/bmrb/bmrblib/kinetics/relax_base.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/kinetics/relax_base.py?rev=8946&r1=8945&r2=8946&view=diff
==============================================================================
--- branches/bmrb/bmrblib/kinetics/relax_base.py (original)
+++ branches/bmrb/bmrblib/kinetics/relax_base.py Tue Mar 10 11:09:26 2009
@@ -88,6 +88,25 @@
 class Rx(TagCategory):
     """Base class for the Rx tag categories."""
 
+    def create(self):
+        """Create the Rx tag category."""
+
+        # Keys and objects.
+        info = [
+            ['CompIndexID', 'res_nums'],
+            ['CompID',      'res_names'],
+            ['AtomID',      'atom_names'],
+            ['Val',         'data'],
+            ['ValErr',      'errors']
+        ]
+
+        # Get the TabTable.
+        table = self.create_tag_table(info)
+
+        # Add the tagtable to the save frame.
+        self.sf.frame.tagtables.append(table)
+
+
     def read(self, tagtable):
         """Extract the Rx tag category info.
 

Modified: branches/bmrb/bmrblib/tag_category.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/tag_category.py?rev=8946&r1=8945&r2=8946&view=diff
==============================================================================
--- branches/bmrb/bmrblib/tag_category.py (original)
+++ branches/bmrb/bmrblib/tag_category.py Tue Mar 10 11:09:26 2009
@@ -66,7 +66,7 @@
         return self.tag_category_label_full + tag_name
 
 
-    def create_tag_table(self, info):
+    def create_tag_table(self, info, free=False):
         """Create and return a tag table based on the info structure.
 
         @param info:    The key and object pair list.  This consists of the 
keys of
@@ -74,6 +74,8 @@
                         the second element, both of the second dimension.  
The fist dimension are
                         the different pairs.
         @type info:     list of list of str
+        @keyword free:  Flag to create a free STAR table.
+        @type free:     bool
         @return:        The tag table.
         @rtype:         TagTable instance
         """
@@ -95,7 +97,7 @@
                 tag_values.append(getattr(self.sf, name))
 
         # Add the data and return the table.
-        return TagTable(tagnames=tag_names, tagvalues=tag_values)
+        return TagTable(free=free, tagnames=tag_names, tagvalues=tag_values)
 
 
     def tag_setup(self, tag_category_label=None, sep=None):




Related Messages


Powered by MHonArc, Updated Tue Mar 10 11:40:04 2009