mailr8468 - in /branches/multi_structure/generic_fns/structure: api_base.py internal.py scientific.py


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

Header


Content

Posted by edward on January 15, 2009 - 13:42:
Author: bugman
Date: Thu Jan 15 13:42:44 2009
New Revision: 8468

URL: http://svn.gna.org/viewcvs/relax?rev=8468&view=rev
Log:
Redesign of the set up of the molecule container data structures.

The file info is now set by the pack_structs() base API method rather than 
the MolContainer internal
object or the ScientificPython code.


Modified:
    branches/multi_structure/generic_fns/structure/api_base.py
    branches/multi_structure/generic_fns/structure/internal.py
    branches/multi_structure/generic_fns/structure/scientific.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=8468&r1=8467&r2=8468&view=diff
==============================================================================
--- branches/multi_structure/generic_fns/structure/api_base.py (original)
+++ branches/multi_structure/generic_fns/structure/api_base.py Thu Jan 15 
13:42:44 2009
@@ -276,7 +276,7 @@
         return len(self.structural_data)
 
 
-    def pack_structs(self, data_matrix, orig_model_num=None, 
set_model_num=None, orig_mol_num=None, set_mol_name=None):
+    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):
         """From the given structural data, expand the structural data data 
structure.
 
         @param data_matrix:         A matrix of structural objects.
@@ -287,8 +287,13 @@
         @type set_model_num:        list of int
         @keyword orig_mol_num:      The original molecule numbers (for 
storage).
         @type orig_mol_num:         list of int
-        @keyword set_mol_name:      The molecule names (for naming the 
molecules).
-        @type set_mol_name:         list of str
+        @keyword mol_name:          The molecule ID string.
+        @type mol_name:             str
+        @keyword file_name:         The name of the file from which the 
molecular data has been
+                                    extracted.
+        @type file_name:            None or str
+        @keyword file_path:         The full path to the file specified by 
'file_name'.
+        @type file_path:            None or str
         """
 
         # Test the number of models.
@@ -346,6 +351,14 @@
 
                 # Pack the structures.
                 model.mol.add_item(mol_name=set_mol_name[j], 
mol_cont=data_matrix[i][j])
+
+                # Set the molecule name and store the structure file info. 
+                model.mol[-1].mol_name = set_mol_name[j]
+                model.mol[-1].file_name = file_name
+                model.mol[-1].file_path = file_path
+                model.mol[-1].file_mol_num = orig_mol_num[j]
+                model.mol[-1].file_model = orig_model_num[j]
+
 
 
     def target_mol_name(self, set=None, target=None, index=None, 
mol_num=None, file=None):

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=8468&r1=8467&r2=8468&view=diff
==============================================================================
--- branches/multi_structure/generic_fns/structure/internal.py (original)
+++ branches/multi_structure/generic_fns/structure/internal.py Thu Jan 15 
13:42:44 2009
@@ -416,7 +416,7 @@
                 mol = model.mol[mol_index]
 
                 # Skip non-matching molecules.
-                if sel_obj and not sel_obj.contains_mol(mol.name):
+                if sel_obj and not sel_obj.contains_mol(mol.mol_name):
                     continue
 
                 # Loop over all atoms.
@@ -453,7 +453,7 @@
                         pos = array([mol.x[i], mol.y[i], mol.z[i]], float64)
 
                     # The molecule name.
-                    mol_name = mol.name
+                    mol_name = mol.mol_name
 
                     # Build the tuple to be yielded.
                     atomic_tuple = ()
@@ -652,7 +652,7 @@
                 orig_mol_num.append(mol_num)
 
                 # Generate the molecule container.
-                mol = MolContainer(mol_name=new_mol_name[-1], 
file_name=file, file_path=path, file_model=model_num, file_mol_num=mol_num)
+                mol = MolContainer()
 
                 # Fill the molecular data object.
                 mol.fill_object_from_pdb(mol_records)
@@ -667,7 +667,7 @@
             model_index = model_index + 1
 
         # Create the structural data data structures.
-        self.pack_structs(mol_conts, orig_model_num=orig_model_num, 
set_model_num=set_model_num, orig_mol_num=orig_mol_num, 
set_mol_name=new_mol_name)
+        self.pack_structs(mol_conts, orig_model_num=orig_model_num, 
set_model_num=set_model_num, orig_mol_num=orig_mol_num, 
set_mol_name=new_mol_name, file_name=file, file_path=path)
 
         # Loading worked.
         return True
@@ -1044,28 +1044,8 @@
     """
 
 
-    def __init__(self, mol_name=None, file_name=None, file_path=None, 
file_model=None, file_mol_num=None):
-        """Initialise the molecular container.
-
-        @keyword mol_name:          The molecule ID string.
-        @type mol_name:             str
-        @keyword file_name:         The name of the file from which the 
molecular data has been
-                                    extracted.
-        @type file_name:            None or str
-        @keyword file_path:         The full path to the file specified by 
'file_name'.
-        @type file_path:            None or str
-        @keyword file_model:        The model in the file from which this 
data has been extracted.
-        @type file_model:           None or str
-        @keyword file_mol_num:      The molecule in the file from which this 
data has been extracted.
-        @type file_mol_num:         None or str
-        """
-
-        # Set the molecule info.
-        self.mol_name = mol_name
-        self.file_name = file_name
-        self.file_path = file_path
-        self.file_model = file_model
-        self.file_mol_num = file_mol_num
+    def __init__(self):
+        """Initialise the molecular container."""
 
         # The atom num (array of int).
         self.atom_num = []

Modified: branches/multi_structure/generic_fns/structure/scientific.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/multi_structure/generic_fns/structure/scientific.py?rev=8468&r1=8467&r2=8468&view=diff
==============================================================================
--- branches/multi_structure/generic_fns/structure/scientific.py (original)
+++ branches/multi_structure/generic_fns/structure/scientific.py Thu Jan 15 
13:42:44 2009
@@ -193,7 +193,7 @@
                 res_index = res_index + 1
 
                 # Skip non-matching residues.
-                if sel_obj and not sel_obj.contains_res(res_num, res_name, 
mol.name):
+                if sel_obj and not sel_obj.contains_res(res_num, res_name, 
mol.mol_name):
                     continue
 
                 # Yield the residue info.
@@ -207,7 +207,7 @@
                 res_index = res_index + 1
 
                 # Skip non-matching residues.
-                if sel_obj and not sel_obj.contains_res(res.number, 
res.name, mol.name):
+                if sel_obj and not sel_obj.contains_res(res.number, 
res.name, mol.mol_name):
                     continue
 
                 # Yield the residue info.
@@ -262,7 +262,7 @@
                 mol = model.mol[mol_index]
 
                 # Skip non-matching molecules.
-                if sel_obj and not sel_obj.contains_mol(mol.name):
+                if sel_obj and not sel_obj.contains_mol(mol.mol_name):
                     continue
 
                 # Loop over the residues.
@@ -277,7 +277,7 @@
                         atom_index = atom_index + 1
 
                         # Skip non-matching atoms.
-                        if sel_obj and not sel_obj.contains_spin(atom_num, 
atom_name, res_num, res_name, mol.name):
+                        if sel_obj and not sel_obj.contains_spin(atom_num, 
atom_name, res_num, res_name, mol.mol_name):
                             continue
 
                         # The atom position.
@@ -287,10 +287,10 @@
                             pos = atom.position.array
 
                         # The molecule name.
-                        mol_name = mol.name
+                        mol_name = mol.mol_name
 
                         # Replace empty variables with None.
-                        if not mol.name:
+                        if not mol.mol_name:
                             mol_name = None
                         if not res_num:
                             res_num = None
@@ -646,7 +646,7 @@
             model_num = model_num + 1
 
         # Create the structural data data structures.
-        self.pack_structs(mol_conts, orig_model_num=orig_model_num, 
set_model_num=set_model_num, orig_mol_num=range(1, len(mol_conts[0])+1), 
set_mol_name=new_mol_name)
+        self.pack_structs(mol_conts, orig_model_num=orig_model_num, 
set_model_num=set_model_num, orig_mol_num=range(1, len(mol_conts[0])+1), 
set_mol_name=new_mol_name, file_name=file, file_path=path)
 
         # Loading worked.
         return True




Related Messages


Powered by MHonArc, Updated Thu Jan 15 14:00:04 2009