mailr8499 - in /branches/multi_structure/generic_fns/structure: api_base.py geometric.py internal.py


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

Header


Content

Posted by edward on January 16, 2009 - 17:49:
Author: bugman
Date: Fri Jan 16 17:49:01 2009
New Revision: 8499

URL: http://svn.gna.org/viewcvs/relax?rev=8499&view=rev
Log:
Started to redesign add_struct() to remove the struct_index arg and convert 
to the new model design.

The API base class function get_model() has been added to return or create 
the desired model.  The
add_struct() method has been renamed to add_molecule().  Much work remains to 
be done.


Modified:
    branches/multi_structure/generic_fns/structure/api_base.py
    branches/multi_structure/generic_fns/structure/geometric.py
    branches/multi_structure/generic_fns/structure/internal.py

Modified: branches/multi_structure/generic_fns/structure/api_base.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_structure/generic_fns/structure/api_base.py?rev=8499&r1=8498&r2=8499&view=diff
==============================================================================
--- branches/multi_structure/generic_fns/structure/api_base.py (original)
+++ branches/multi_structure/generic_fns/structure/api_base.py Fri Jan 16 
17:49:01 2009
@@ -62,22 +62,19 @@
         self.structural_data = ModelList()
 
 
-    def add_struct(self, name=None, model=None, file=None, path=None, 
str=None, struct_index=None):
-        """Prototype method stub for adding the given structure to the store.
-
-        @keyword name:          The structural identifier.
+    def add_molecule(self, name=None, model=None, file=None, path=None, 
str=None):
+        """Prototype method stub for adding the given molecule to the store.
+
+        @keyword name:          The molecule identification string.
         @type name:             str
-        @keyword model:         The structural model.
+        @keyword model:         The number of the model to add the molecule 
to.
         @type model:            int or None
-        @keyword file:          The name of the file containing the 
structure.
+        @keyword file:          The name of the file containing the molecule.
         @type file:             str
         @keyword path:          The optional path where the file is located.
         @type path:             str
-        @keyword str:           The object containing the structural data.
-        @type str:              Structure_container instance
-        @keyword struct_index:  The index of the structural container, used 
for replacing the
-                                structure.
-        @type struct_index:     int or None.
+        @keyword str:           The molecule object, containing the 
structural data.
+        @type str:              class instance
         """
 
         # Raise the error.
@@ -232,6 +229,43 @@
                     warn(RelaxWarning("The structure file " + `self.file[i]` 
+ " cannot be found in the current directory or the directory of the results 
file."))
 
 
+    def get_model(self, model):
+        """Return or create the model.
+
+        @param model:   The model number.
+        @type model:    int or None
+        @return:        The ModelContainer corresponding to the model number 
or that newly created.
+        @rteyp:         ModelContainer instance
+        """
+
+        # Check if the target is a single model.
+        if model == None and self.num_models() > 1:
+            raise RelaxError, "The target model cannot be determined as 
there are %s models already present." % self.num_modes()
+
+        # No model specified.
+        if model == None:
+            # Create the first model, if necessary.
+            if self.num_models():
+                self.structural_data.add_item()
+
+            # Alias the first model.
+            model_cont = self.structural_data[0]
+
+        # The model has been specified.
+        else:
+            # Get the preexisting model.
+            found = False
+            for model_cont in self.structural_data:
+                if model_cont.num == model:
+                    found = True
+                    break
+
+            # Add the model if it doesn't exist.
+            if not found:
+                self.structural_data.add_item(model)
+                model_cont = self.structural_data[-1]
+
+
     def load_pdb(self, file_path, read_mol=None, set_mol_name=None, 
read_model=None, set_model_num=None, verbosity=False):
         """Prototype method stub for loading structures from a PDB file.
 

Modified: branches/multi_structure/generic_fns/structure/geometric.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_structure/generic_fns/structure/geometric.py?rev=8499&r1=8498&r2=8499&view=diff
==============================================================================
--- branches/multi_structure/generic_fns/structure/geometric.py (original)
+++ branches/multi_structure/generic_fns/structure/geometric.py Fri Jan 16 
17:49:01 2009
@@ -181,7 +181,7 @@
     structure = Internal()
 
     # Add a structure.
-    structure.add_struct(name='diff_tensor')
+    structure.add_molecule(name='diff_tensor')
 
     # Loop over the pipes.
     for pipe_index in xrange(len(pipe_list)):
@@ -351,7 +351,7 @@
     structure = Internal()
 
     # Add a structure.
-    structure.add_struct(name='vector_dist')
+    structure.add_molecule(name='vector_dist')
 
     # Initialise the residue and atom numbers.
     res_num = 1

Modified: branches/multi_structure/generic_fns/structure/internal.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_structure/generic_fns/structure/internal.py?rev=8499&r1=8498&r2=8499&view=diff
==============================================================================
--- branches/multi_structure/generic_fns/structure/internal.py (original)
+++ branches/multi_structure/generic_fns/structure/internal.py Fri Jan 16 
17:49:01 2009
@@ -53,12 +53,12 @@
     id = 'internal'
 
 
-    def add_struct(self, name=None, model=None, file=None, path=None, 
str=None, struct_index=None):
+    def add_molecule(self, name=None, model=None, file=None, path=None, 
str=None):
         """Add the given structure to the store.
 
         @keyword name:          The structural identifier.
         @type name:             str
-        @keyword model:         The structural model.
+        @keyword model:         The number of the model to add the molecule 
to.
         @type model:            int or None
         @keyword file:          The name of the file containing the 
structure.
         @type file:             str
@@ -66,13 +66,19 @@
         @type path:             str
         @keyword str:           The object containing the structural data.
         @type str:              Structure_container instance
-        @keyword struct_index:  The index of the structural container, used 
for replacing the
-                                structure.
-        @type struct_index:     int or None.
-        """
+        """
+
+        # Check if the target is a single model.
+        if model == None and self.num_models() > 1:
+            raise RelaxError, "The target model cannot be determined as 
there are %s models already present." % self.num_modes()
+
+        # Get the model.
+        model_cont = self.get_model(model)
+
+        # Check that the name does not already exist.
 
         # Some checks.
-        if struct_index != None:
+        if model != None:
             # Index check.
             if struct_index >= self.num:
                 raise RelaxError, "The structure index of " + `struct_index` 
+ " cannot be more than the total number of structures of " + `self.num` + "."




Related Messages


Powered by MHonArc, Updated Fri Jan 16 18:00:04 2009