mailr18851 - in /trunk/generic_fns/structure: api_base.py internal.py main.py scientific.py


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

Header


Content

Posted by edward on March 18, 2013 - 13:51:
Author: bugman
Date: Mon Mar 18 13:51:56 2013
New Revision: 18851

URL: http://svn.gna.org/viewcvs/relax?rev=18851&view=rev
Log:
The merge flag for the structure.read_pdb user function is now propaged to 
the pack_structs() method.

This structure API method calls the ModelList.merge_item() method which is 
yet to be implemented.


Modified:
    trunk/generic_fns/structure/api_base.py
    trunk/generic_fns/structure/internal.py
    trunk/generic_fns/structure/main.py
    trunk/generic_fns/structure/scientific.py

Modified: trunk/generic_fns/structure/api_base.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/structure/api_base.py?rev=18851&r1=18850&r2=18851&view=diff
==============================================================================
--- trunk/generic_fns/structure/api_base.py (original)
+++ trunk/generic_fns/structure/api_base.py Mon Mar 18 13:51:56 2013
@@ -351,7 +351,7 @@
         raise RelaxImplementError
 
 
-    def load_pdb(self, file_path, read_mol=None, set_mol_name=None, 
read_model=None, set_model_num=None, alt_loc=None, verbosity=False):
+    def load_pdb(self, file_path, read_mol=None, set_mol_name=None, 
read_model=None, set_model_num=None, alt_loc=None, verbosity=False, 
merge=False):
         """Prototype method stub for loading structures from a PDB file.
 
         This inherited prototype method is a stub which, if the 
functionality is desired, should be overwritten by the derived class.
@@ -371,6 +371,8 @@
         @type alt_loc:          str or None
         @keyword verbosity:     A flag which if True will cause messages to 
be printed.
         @type verbosity:        bool
+        @keyword merge:         A flag which if set to True will try to 
merge the PDB structure into the currently loaded structures.
+        @type merge:            bool
         @return:                The status of the loading of the PDB file.
         @rtype:                 bool
         """
@@ -477,7 +479,7 @@
         return len(self.structural_data[0].mol)
 
 
-    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):
+    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, merge=False):
         """From the given structural data, expand the structural data data 
structure.
 
         @param data_matrix:         A matrix of structural objects.
@@ -490,11 +492,12 @@
         @type orig_mol_num:         list of int
         @keyword set_mol_name:      The new molecule names.
         @type set_mol_name:         list of str
-        @keyword file_name:         The name of the file from which the 
molecular data has been
-                                    extracted.
+        @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 merge:             A flag which if set to True will try to 
merge the structure into the currently loaded structures.
+        @type merge:                bool
         """
 
         # Test the number of models.
@@ -525,7 +528,7 @@
 
             # Loop over the structures.
             for j in range(len(self.structural_data[i].mol)):
-                if self.structural_data[i].num in set_model_num and 
self.structural_data[i].mol[j].mol_name in set_mol_name:
+                if not merge and self.structural_data[i].num in 
set_model_num and self.structural_data[i].mol[j].mol_name in set_mol_name:
                     raise RelaxError("The molecule '%s' of model %s already 
exists." % (self.structural_data[i].mol[j].mol_name, 
self.structural_data[i].num))
 
         # Loop over the models.
@@ -556,7 +559,10 @@
                     raise RelaxError("The new molecule name of '%s' in model 
%s does not match the corresponding molecule's name of '%s' in model %s." % 
(set_mol_name[j], set_model_num[i], 
self.structural_data[0].mol[index].mol_name, self.structural_data[0].num))
 
                 # Pack the structures.
-                model.mol.add_item(mol_name=set_mol_name[j], 
mol_cont=data_matrix[i][j])
+                if merge:
+                    mol = model.mol.merge_item(mol_name=set_mol_name[j], 
mol_cont=data_matrix[i][j])
+                else:
+                    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]

Modified: trunk/generic_fns/structure/internal.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/structure/internal.py?rev=18851&r1=18850&r2=18851&view=diff
==============================================================================
--- trunk/generic_fns/structure/internal.py (original)
+++ trunk/generic_fns/structure/internal.py Mon Mar 18 13:51:56 2013
@@ -1232,7 +1232,7 @@
                     return mol
 
 
-    def load_pdb(self, file_path, read_mol=None, set_mol_name=None, 
read_model=None, set_model_num=None, alt_loc=None, verbosity=False):
+    def load_pdb(self, file_path, read_mol=None, set_mol_name=None, 
read_model=None, set_model_num=None, alt_loc=None, verbosity=False, 
merge=False):
         """Method for loading structures from a PDB file.
 
         @param file_path:       The full path of the PDB file.
@@ -1249,6 +1249,8 @@
         @type alt_loc:          str or None
         @keyword verbosity:     A flag which if True will cause messages to 
be printed.
         @type verbosity:        bool
+        @keyword merge:         A flag which if set to True will try to 
merge the PDB structure into the currently loaded structures.
+        @type merge:            bool
         @return:                The status of the loading of the PDB file.
         @rtype:                 bool
         """
@@ -1352,7 +1354,7 @@
             return False
 
         # 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, file_name=file, file_path=path)
+        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, merge=merge)
 
         # Loading worked.
         return True

Modified: trunk/generic_fns/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/structure/main.py?rev=18851&r1=18850&r2=18851&view=diff
==============================================================================
--- trunk/generic_fns/structure/main.py (original)
+++ trunk/generic_fns/structure/main.py Mon Mar 18 13:51:56 2013
@@ -559,7 +559,7 @@
             cdp.structure = Internal()
 
     # Load the structures.
-    cdp.structure.load_pdb(file_path, read_mol=read_mol, 
set_mol_name=set_mol_name, read_model=read_model, 
set_model_num=set_model_num, alt_loc=alt_loc, verbosity=verbosity)
+    cdp.structure.load_pdb(file_path, read_mol=read_mol, 
set_mol_name=set_mol_name, read_model=read_model, 
set_model_num=set_model_num, alt_loc=alt_loc, verbosity=verbosity, 
merge=merge)
 
     # Load into Molmol (if running).
     molmol.molmol_obj.open_pdb()

Modified: trunk/generic_fns/structure/scientific.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/structure/scientific.py?rev=18851&r1=18850&r2=18851&view=diff
==============================================================================
--- trunk/generic_fns/structure/scientific.py (original)
+++ trunk/generic_fns/structure/scientific.py Mon Mar 18 13:51:56 2013
@@ -529,7 +529,7 @@
                     return mol
 
 
-    def load_pdb(self, file_path, read_mol=None, set_mol_name=None, 
read_model=None, set_model_num=None, alt_loc=None, verbosity=False):
+    def load_pdb(self, file_path, read_mol=None, set_mol_name=None, 
read_model=None, set_model_num=None, alt_loc=None, verbosity=False, 
merge=False):
         """Function for loading the structures from the PDB file.
 
         @param file_path:       The full path of the file.
@@ -546,6 +546,8 @@
         @type alt_loc:          str or None
         @keyword verbosity:     A flag which if True will cause messages to 
be printed.
         @type verbosity:        bool
+        @keyword merge:         A flag which if set to True will try to 
merge the PDB structure into the currently loaded structures.
+        @type merge:            bool
         @return:                The status of the loading of the PDB file.
         @rtype:                 bool
         """
@@ -693,7 +695,7 @@
             model_load_num = model_load_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=list(range(1, 
len(mol_conts[0])+1)), set_mol_name=new_mol_name, file_name=file, 
file_path=path)
+        self.pack_structs(mol_conts, orig_model_num=orig_model_num, 
set_model_num=set_model_num, orig_mol_num=list(range(1, 
len(mol_conts[0])+1)), set_mol_name=new_mol_name, file_name=file, 
file_path=path, merge=merge)
 
         # Loading worked.
         return True




Related Messages


Powered by MHonArc, Updated Mon Mar 18 14:00:02 2013