mailr3127 - /1.3/data/mol_res_spin.py


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

Header


Content

Posted by edward on March 08, 2007 - 09:36:
Author: bugman
Date: Thu Mar  8 09:36:23 2007
New Revision: 3127

URL: http://svn.gna.org/viewcvs/relax?rev=3127&view=rev
Log:
Addition of the molecule-residue-spin data classes.

The following classes have been created:
    MoleculeList
    MoleculeContainer
    ResidueList
    ResidueContainer
    SpinList
    SpinContainer

These were modified from the original Residue and ResidueList classes.


Added:
    1.3/data/mol_res_spin.py
      - copied, changed from r3118, 1.3/data/data_classes.py

Copied: 1.3/data/mol_res_spin.py (from r3118, 1.3/data/data_classes.py)
URL: 
http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?p2=1.3/data/mol_res_spin.py&p1=1.3/data/data_classes.py&r1=3118&r2=3127&rev=3127&view=diff
==============================================================================
--- 1.3/data/data_classes.py (original)
+++ 1.3/data/mol_res_spin.py Thu Mar  8 09:36:23 2007
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2003-2004, 2006-2007 Edward d'Auvergne                       
 #
+# Copyright (C) 2007 Edward d'Auvergne                                       
 #
 #                                                                            
 #
 # This file is part of the program relax.                                    
 #
 #                                                                            
 #
@@ -25,76 +25,38 @@
 from types import DictType, ListType
 
 
+"""The molecule-residue-spin containers."""
 
-# Empty data container.
-#######################
 
-class Element:
-    def __init__(self):
-        """Empty data container."""
+
+# The molecule data.
+###################
+
+class MoleculeList(ListType):
+    """Empty data container for the molecule specific data."""
 
 
     def __repr__(self):
-        # Header.
-        text = "%-25s%-100s\n\n" % ("Data structure", "Value")
-
-        # Data structures.
-        for name in dir(self):
-            if match("^_", name):
-                continue
-            text = text + "%-25s%-100s\n" % (name, `getattr(self, name)`)
-
-        # Return the lot.
+        text = "Molecules.\n\n"
+        text = text + "%-8s%-8s%-8s%-10s" % ("Index", "Number", "Name", 
"Selected") + "\n"
+        for i in xrange(len(self)):
+            text = text + "%-8i%-8i%-8s%-10i" % (i, self[i].num, 
self[i].name, self[i].select) + "\n"
+        text = text + "\nThese can be accessed by typing 
'relax_data_store.res[key][index]'.\n"
         return text
 
 
-# Specific data class.
-######################
+    def add_item(self):
+        """Function for appending an empty container to the list."""
 
-class SpecificData(DictType):
-    def __init__(self):
-        """Dictionary type class for specific data."""
+        self.append(MoleculeContainer())
+
+
+class MoleculeContainer:
+    """Class containing all the molecule specific data."""
 
 
     def __repr__(self):
-        text = "Data:\n";
-        if len(self) == 0:
-            text = text + "  {}\n"
-        else:
-            i = 0
-            for key in self.keys():
-                if i == 0:
-                    text = text + "  { "
-                else:
-                    text = text + "  , "
-                text = text + "Key " + `key` + ":\n"
-                for name in dir(self[key]):
-                    if match("^_", name):
-                        continue
-                    text = text + "    " + name + ", " + 
`type(getattr(self[key], name))` + "\n"
-                i = i + 1
-            text = text + "  }\n"
-
-        return text
-
-
-    def add_item(self, key):
-        """Function for adding an empty container to the dictionary."""
-
-        self[key] = Element()
-
-
-
-# Residue specific data.
-########################
-
-class Residue(DictType):
-    def __init__(self):
-        """Class containing all the residue specific data."""
-
-
-    def __repr__(self):
-        text = "Class containing all the residue specific data.\n\n"
+        text = "Class containing all the molecule specific data.\n\n"
 
         # Empty.
         if not len(self):
@@ -102,7 +64,7 @@
 
         # Not empty.
         else:
-            text = text + "The residue container contains the following 
keys:\n"
+            text = text + "The molecule container has the following keys:\n"
             for key in self:
                 text = text + "    " + `key` + "\n"
             text = text + "\nThese can be accessed by typing 
'relax_data_store.res[key]'.\n"
@@ -116,9 +78,12 @@
         self[key] = ResidueList()
 
 
+
+# The residue data.
+###################
+
 class ResidueList(ListType):
-    def __init__(self):
-        """Empty data container for residue specific data."""
+    """Empty data container for residue specific data."""
 
 
     def __repr__(self):
@@ -133,4 +98,77 @@
     def add_item(self):
         """Function for appending an empty container to the list."""
 
-        self.append(Element())
+        self.append(ResidueContainer())
+
+
+class ResidueContainer:
+    """Class containing all the residue specific data."""
+
+
+    def __repr__(self):
+        text = "Class containing all the residue specific data.\n\n"
+
+        # Empty.
+        if not len(self):
+            text = text + "The class contains no data.\n"
+
+        # Not empty.
+        else:
+            text = text + "The residue container has the following keys:\n"
+            for key in self:
+                text = text + "    " + `key` + "\n"
+            text = text + "\nThese can be accessed by typing 
'relax_data_store.res[key]'.\n"
+
+        return text
+
+
+    def add_list(self, key):
+        """Function for adding an empty container to the dictionary."""
+
+        self[key] = ResidueList()
+
+
+
+# The spin system data.
+#######################
+
+class SpinList(ListType):
+    """Empty data container for spin system specific data."""
+
+
+    def __repr__(self):
+        text = "Spin systems.\n\n"
+        text = text + "%-8s%-8s%-8s%-10s" % ("Index", "Number", "Name", 
"Selected") + "\n"
+        for i in xrange(len(self)):
+            text = text + "%-8i%-8i%-8s%-10i" % (i, self[i].num, 
self[i].name, self[i].select) + "\n"
+        text = text + "\nThese can be accessed by typing 
'relax_data_store.res[key][index]'.\n"
+        return text
+
+
+    def add_item(self):
+        """Function for appending an empty container to the list."""
+
+        self.append(SpinContainer())
+
+
+class SpinContainer:
+    """Class containing all the spin system specific data."""
+
+
+    def __repr__(self):
+
+        # Intro.
+        text = "Class containing all the spin system specific data.\n\n"
+
+        # Empty.
+        if not len(self):
+            text = text + "The class contains no data.\n"
+
+        # Not empty.
+        else:
+            text = text + "The spin system container has the following 
keys:\n"
+            for key in self:
+                text = text + "    " + `key` + "\n"
+            text = text + "\nThese can be accessed by typing 
'relax_data_store.res[key]'.\n"
+
+        return text




Related Messages


Powered by MHonArc, Updated Thu Mar 08 11:00:09 2007