mailr23238 - in /branches/disp_speed: ./ lib/structure/internal/ pipe_control/structure/ user_functions/


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

Header


Content

Posted by tlinnet on May 19, 2014 - 13:49:
Author: tlinnet
Date: Mon May 19 13:49:04 2014
New Revision: 23238

URL: http://svn.gna.org/viewcvs/relax?rev=23238&view=rev
Log:
Merged revisions 23230,23232,23234-23236 via svnmerge from 
svn+ssh://tlinnet@xxxxxxxxxxx/svn/relax/trunk

........
  r23230 | bugman | 2014-05-19 11:57:56 +0200 (Mon, 19 May 2014) | 7 lines
  
  Exposed the backend verbosity flag of the structure.read_* user functions.
  
  This allows the user to silence these user functions, which can be very 
useful when loading many
  3D structures in the scripting UI mode.  This change is for the 
structure.read_gaussian,
  structure.read_pdb, and structure.read_xyz user functions.
........
  r23232 | bugman | 2014-05-19 12:09:17 +0200 (Mon, 19 May 2014) | 7 lines
  
  Expanded the structure.delete user function to add the 'verbosity' and 
'spin_info' arguments.
  
  The verbosity argument, when set to zero, allows all output to be 
suppressed.  The spin_info flag
  allows the deletion of spin and interatomic data to now be turned off, so 
that only 3D data is
  deleted.
........
  r23234 | bugman | 2014-05-19 12:21:31 +0200 (Mon, 19 May 2014) | 5 lines
  
  The new structure.delete 'verbosity' argument is now propagated into the 
structural object.
  
  This allows the printouts to now be completely suppressed.
........
  r23235 | bugman | 2014-05-19 12:25:49 +0200 (Mon, 19 May 2014) | 5 lines
  
  The structure.read_* user function 'verbosity' argument is now passed into 
the structural object.
  
  This allows another printout to be silenced.
........
  r23236 | bugman | 2014-05-19 12:29:36 +0200 (Mon, 19 May 2014) | 5 lines
  
  The structure.read_* user function 'verbosity' argument is now passed into 
lib.io.open_read_file().
  
  This allows all printouts from these three user functions to be suppressed.
........

Modified:
    branches/disp_speed/   (props changed)
    branches/disp_speed/lib/structure/internal/object.py
    branches/disp_speed/pipe_control/structure/main.py
    branches/disp_speed/user_functions/structure.py

Propchange: branches/disp_speed/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon May 19 13:49:04 2014
@@ -1 +1 @@
-/trunk:1-23213
+/trunk:1-23237

Modified: branches/disp_speed/lib/structure/internal/object.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/lib/structure/internal/object.py?rev=23238&r1=23237&r2=23238&view=diff
==============================================================================
--- branches/disp_speed/lib/structure/internal/object.py        (original)
+++ branches/disp_speed/lib/structure/internal/object.py        Mon May 19 
13:49:04 2014
@@ -240,17 +240,19 @@
             return 'Average vector'
 
 
-    def _parse_models_gaussian(self, file_path):
+    def _parse_models_gaussian(self, file_path, verbosity=1):
         """Generator function for looping over the models in the Gaussian 
log file.
 
         @param file_path:   The full path of the Gaussian log file.
         @type file_path:    str
         @return:            The model number and all the records for that 
model.
         @rtype:             tuple of int and array of str
+        @keyword verbosity: The amount of information to print to screen.  
Zero corresponds to minimal output while higher values increase the amount of 
output.  The default value is 1.
+        @type verbosity:    int
         """
 
         # Open the file.
-        file = open_read_file(file_path)
+        file = open_read_file(file_path, verbosity=verbosity)
         lines = file.readlines()
         file.close()
 
@@ -580,17 +582,19 @@
         return lines[i:]
 
 
-    def _parse_models_xyz(self, file_path):
+    def _parse_models_xyz(self, file_path, verbosity=1):
         """Generator function for looping over the models in the XYZ file.
 
         @param file_path:   The full path of the XYZ file.
         @type file_path:    str
+        @keyword verbosity: The amount of information to print to screen.  
Zero corresponds to minimal output while higher values increase the amount of 
output.  The default value is 1.
+        @type verbosity:    int
         @return:            The model number and all the records for that 
model.
         @rtype:             tuple of int and array of str
         """
 
         # Open the file.
-        file = open_read_file(file_path)
+        file = open_read_file(file_path, verbosity=verbosity)
         lines = file.readlines()
         file.close()
 
@@ -1499,18 +1503,21 @@
             mol.atom_connect(index1=index1, index2=index2)
 
 
-    def delete(self, atom_id=None):
+    def delete(self, atom_id=None, verbosity=1):
         """Deletion of structural information.
 
         @keyword atom_id:   The molecule, residue, and atom identifier 
string.  This matches the spin ID string format.  If not given, then all 
structural data will be deleted.
         @type atom_id:      str or None
+        @keyword verbosity: The amount of information to print to screen.  
Zero corresponds to minimal output while higher values increase the amount of 
output.  The default value is 1.
+        @type verbosity:    int
         """
 
         # All data.
         if atom_id == None:
-            # Print out.
-            print("Deleting the following structural data:\n")
-            print(self.structural_data)
+            # Printout.
+            if verbosity:
+                print("Deleting the following structural data:\n")
+                print(self.structural_data)
 
             # Delete the structural data.
             del self.structural_data
@@ -1795,7 +1802,7 @@
             set_model_num = [1]
 
         # Loop over all models in the Gaussian log file, doing nothing so 
the last model records are stored.
-        for model_records in self._parse_models_gaussian(file_path):
+        for model_records in self._parse_models_gaussian(file_path, 
verbosity=verbosity):
             pass
 
         # Generate the molecule container.
@@ -1805,7 +1812,7 @@
         mol.fill_object_from_gaussian(model_records)
 
         # Create the structural data data structures.
-        self.pack_structs([[mol]], orig_model_num=[1], 
set_model_num=set_model_num, orig_mol_num=[0], set_mol_name=set_mol_name, 
file_name=file_name, file_path=path, file_path_abs=path_abs)
+        self.pack_structs([[mol]], orig_model_num=[1], 
set_model_num=set_model_num, orig_mol_num=[0], set_mol_name=set_mol_name, 
file_name=file_name, file_path=path, file_path_abs=path_abs, 
verbosity=verbosity)
 
         # Loading worked.
         return True
@@ -1860,7 +1867,7 @@
             set_model_num = [set_model_num]
 
         # Open the PDB file.
-        pdb_file = open_read_file(file_path)
+        pdb_file = open_read_file(file_path, verbosity=verbosity)
         pdb_lines = pdb_file.readlines()
         pdb_file.close()
 
@@ -1938,7 +1945,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, 
file_path_abs=path_abs, merge=merge)
+        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, 
file_path_abs=path_abs, merge=merge, verbosity=verbosity)
 
         # Loading worked.
         return True
@@ -1996,7 +2003,7 @@
         mol_conts = []
         orig_mol_num = []
         new_mol_name = []
-        for model_records in self._parse_models_xyz(file_path):
+        for model_records in self._parse_models_xyz(file_path, 
verbosity=verbosity):
             # Increment the xyz_model_increment
             xyz_model_increment = xyz_model_increment +1
 
@@ -2040,7 +2047,7 @@
 
         # Create the structural data data structures.
         orig_mol_num = [0]
-        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, 
file_path_abs=path_abs)
+        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, 
file_path_abs=path_abs, verbosity=verbosity)
 
         # Loading worked.
         return True
@@ -2114,7 +2121,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, file_path_abs=None, merge=False):
+    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, file_path_abs=None, verbosity=1, merge=False):
         """From the given structural data, expand the structural data data 
structure.
 
         @param data_matrix:         A matrix of structural objects.
@@ -2133,6 +2140,8 @@
         @type file_path:            None or str
         @keyword file_path_abs:     The absolute path to the file specified 
by 'file_name'.  This is a fallback mechanism in case results or save files 
are located somewhere other than the working directory.
         @type file_path_abs:        None or str
+        @keyword verbosity: The amount of information to print to screen.  
Zero corresponds to minimal output while higher values increase the amount of 
output.  The default value is 1.
+        @type verbosity:    int
         @keyword merge:             A flag which if set to True will try to 
merge the structure into the currently loaded structures.
         @type merge:                bool
         """
@@ -2189,11 +2198,12 @@
 
             # Loop over the molecules.
             for j in range(len(set_mol_name)):
-                # Print out.
-                if merge:
-                    print("Merging with model %s of molecule '%s' (from the 
original molecule number %s of model %s)" % (set_model_num[i], 
set_mol_name[j], orig_mol_num[j], orig_model_num[i]))
-                else:
-                    print("Adding molecule '%s' to model %s (from the 
original molecule number %s of model %s)" % (set_mol_name[j], 
set_model_num[i], orig_mol_num[j], orig_model_num[i]))
+                # Printout.
+                if verbosity:
+                    if merge:
+                        print("Merging with model %s of molecule '%s' (from 
the original molecule number %s of model %s)" % (set_model_num[i], 
set_mol_name[j], orig_mol_num[j], orig_model_num[i]))
+                    else:
+                        print("Adding molecule '%s' to model %s (from the 
original molecule number %s of model %s)" % (set_mol_name[j], 
set_model_num[i], orig_mol_num[j], orig_model_num[i]))
 
                 # The index of the new molecule to add or merge.
                 index = len(model.mol)

Modified: branches/disp_speed/pipe_control/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/pipe_control/structure/main.py?rev=23238&r1=23237&r2=23238&view=diff
==============================================================================
--- branches/disp_speed/pipe_control/structure/main.py  (original)
+++ branches/disp_speed/pipe_control/structure/main.py  Mon May 19 13:49:04 
2014
@@ -293,11 +293,15 @@
     status.observers.result_file.notify()
 
 
-def delete(atom_id=None):
+def delete(atom_id=None, verbosity=1, spin_info=True):
     """Delete structural data.
     
     @keyword atom_id:   The molecule, residue, and atom identifier string.  
This matches the spin ID string format.  If not given, then all structural 
data will be deleted.
     @type atom_id:      str or None
+    @keyword verbosity: The amount of information to print to screen.  Zero 
corresponds to minimal output while higher values increase the amount of 
output.  The default value is 1.
+    @type verbosity:    int
+    @keyword spin_info: A flag which if True will cause all structural 
information in the spin containers and interatomic data containers to be 
deleted as well.  If False, then only the 3D structural data will be deleted.
+    @type spin_info:    bool
     """
 
     # Test if the current data pipe exists.
@@ -305,20 +309,27 @@
 
     # Run the object method.
     if hasattr(cdp, 'structure'):
-        print("Deleting structural data from the current pipe.")
-        cdp.structure.delete(atom_id=atom_id)
-    else:
+        if verbosity:
+            print("Deleting structural data from the current pipe.")
+        cdp.structure.delete(atom_id=atom_id, verbosity=verbosity)
+    elif verbosity:
         print("No structures are present.")
 
+    # Skip the rest.
+    if not spin_info:
+        return
+
     # Then remove any spin specific structural info.
-    print("Deleting all spin specific structural info.")
+    if verbosity:
+        print("Deleting all spin specific structural info.")
     for spin in spin_loop(selection=atom_id):
         # Delete positional information.
         if hasattr(spin, 'pos'):
             del spin.pos
 
     # Then remove any interatomic vector structural info.
-    print("Deleting all interatomic vectors.")
+    if verbosity:
+        print("Deleting all interatomic vectors.")
     for interatom in interatomic_loop(selection1=atom_id):
         # Delete bond vectors.
         if hasattr(interatom, 'vector'):

Modified: branches/disp_speed/user_functions/structure.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_speed/user_functions/structure.py?rev=23238&r1=23237&r2=23238&view=diff
==============================================================================
--- branches/disp_speed/user_functions/structure.py     (original)
+++ branches/disp_speed/user_functions/structure.py     Mon May 19 13:49:04 
2014
@@ -426,6 +426,20 @@
     desc_short = "atom ID string",
     desc = "The atom identification string.",
     can_be_none = True
+)
+uf.add_keyarg(
+    name = "verbosity",
+    default = 1,
+    py_type = "int",
+    desc_short = "verbosity level",
+    desc = "The amount of information to print out.  Set to zero to silence 
the user function, or one to see all messages."
+)
+uf.add_keyarg(
+    name = "spin_info",
+    default = True,
+    py_type = "bool",
+    desc_short = "spin information flag",
+    desc = "A flag which if True will cause all structural information in 
the spin containers and interatomic data containers to be deleted as well.  
If False, then only the 3D structural data will be deleted."
 )
 # Description.
 uf.desc.append(Desc_container())
@@ -644,6 +658,13 @@
     desc = "Set the model numbers of the loaded molecules.  This can be a 
single number or list of numbers.",
     can_be_none = True
 )
+uf.add_keyarg(
+    name = "verbosity",
+    default = 1,
+    py_type = "int",
+    desc_short = "verbosity level",
+    desc = "The amount of information to print out.  Set to zero to silence 
the user function, or one to see all messages."
+)
 # Description.
 uf.desc.append(Desc_container())
 uf.desc[-1].add_paragraph("The atomic positions from a Gaussian log file can 
be read into relax.  If optimisation has been preformed, the last set of 
atomic coordinates from the log will be read to obtain the final structure.  
The log file can be Gzip or Bzip2 compressed.")
@@ -716,6 +737,13 @@
     desc_short = "alternate location indicator",
     desc = "The PDB ATOM record 'Alternate location indicator' field value.",
     can_be_none = True
+)
+uf.add_keyarg(
+    name = "verbosity",
+    default = 1,
+    py_type = "int",
+    desc_short = "verbosity level",
+    desc = "The amount of information to print out.  Set to zero to silence 
the user function, or one to see all messages."
 )
 uf.add_keyarg(
     name = "merge",
@@ -805,6 +833,13 @@
     desc = "Set the model numbers of the loaded molecules.  If unset, then 
the PDB model numbers will be preserved if they exist.  This can be a single 
number or list of numbers.",
     can_be_none = True
 )
+uf.add_keyarg(
+    name = "verbosity",
+    default = 1,
+    py_type = "int",
+    desc_short = "verbosity level",
+    desc = "The amount of information to print out.  Set to zero to silence 
the user function, or one to see all messages."
+)
 # Description.
 uf.desc.append(Desc_container())
 uf.desc[-1].add_paragraph("The XYZ files with different models, which 
defined as an ensemble of the same molecule but with different atomic 
positions, can be read into relax.  If there are several molecules in one xyz 
file, please separate them into different files and then load them 
individually.  Loading different models and different molecules is controlled 
by specifying the molecule number read, setting the molecule names, 
specifying which model to read, and setting the model numbers.")




Related Messages


Powered by MHonArc, Updated Mon May 19 15:00:02 2014