mailr18486 - in /trunk: generic_fns/structure/internal.py generic_fns/structure/main.py user_functions/structure.py


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

Header


Content

Posted by edward on February 18, 2013 - 18:32:
Author: bugman
Date: Mon Feb 18 18:32:51 2013
New Revision: 18486

URL: http://svn.gna.org/viewcvs/relax?rev=18486&view=rev
Log:
Modified the structure.add_atom user function to allow the position argument 
to be a rank-2 array.

This allows a different coordinate for each model to be specified.


Modified:
    trunk/generic_fns/structure/internal.py
    trunk/generic_fns/structure/main.py
    trunk/user_functions/structure.py

Modified: trunk/generic_fns/structure/internal.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/structure/internal.py?rev=18486&r1=18485&r2=18486&view=diff
==============================================================================
--- trunk/generic_fns/structure/internal.py (original)
+++ trunk/generic_fns/structure/internal.py Mon Feb 18 18:32:51 2013
@@ -31,6 +31,7 @@
 from warnings import warn
 
 # relax module imports.
+from check_types import is_float
 from data.relax_xml import fill_object_contents, xml_to_object
 from generic_fns import pipes, relax_re
 from generic_fns.mol_res_spin import spin_loop
@@ -581,8 +582,8 @@
         @type res_name:         str or None
         @keyword res_num:       The residue number.
         @type res_num:          int or None
-        @keyword pos:           The position vector of coordinates.
-        @type pos:              list (length = 3)
+        @keyword pos:           The position vector of coordinates.  If a 
rank-2 array is supplied, the length of the first dimension must match the 
number of models.
+        @type pos:              rank-1 or rank-2 array or list of float
         @keyword element:       The element symbol.
         @type element:          str or None
         @keyword atom_num:      The atom number.
@@ -602,8 +603,19 @@
         if len(self.structural_data) == 0:
             self.add_model()
 
+        # Check the position.
+        if is_float(pos[0]):
+            if len(pos) != 3:
+                raise RelaxError("The single atomic position %s must be a 3D 
list." % pos)
+        else:
+            if len(pos) != len(self.structural_data):
+                raise RelaxError("The %s atomic positions does not match the 
%s models present." % (len(pos), len(self.structural_data)))
+
         # Loop over each model.
-        for model in self.structural_data:
+        for i in range(len(self.structural_data)):
+            # Alias the model.
+            model = self.structural_data[i]
+
             # Specific molecule.
             mol = self.get_molecule(mol_name, model=model.num)
 
@@ -611,6 +623,12 @@
             if mol == None:
                 self.add_molecule(name=mol_name)
                 mol = self.get_molecule(mol_name, model=model.num)
+
+            # Split up the position if needed.
+            if is_float(pos[0]):
+                model_pos = pos
+            else:
+                model_pos = pos[i]
 
             # Add the atom.
             mol.atom_add(atom_name=atom_name, res_name=res_name, 
res_num=res_num, pos=pos, element=element, atom_num=atom_num, 
chain_id=chain_id, segment_id=segment_id, pdb_record=pdb_record)

Modified: trunk/generic_fns/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/structure/main.py?rev=18486&r1=18485&r2=18486&view=diff
==============================================================================
--- trunk/generic_fns/structure/main.py (original)
+++ trunk/generic_fns/structure/main.py Mon Feb 18 18:32:51 2013
@@ -54,8 +54,8 @@
     @type res_name:         str or None
     @keyword res_num:       The residue number.
     @type res_num:          int or None
-    @keyword pos:           The position vector of coordinates.
-    @type pos:              list (length = 3)
+    @keyword pos:           The position vector of coordinates.  If a rank-2 
array is supplied, the length of the first dimension must match the number of 
models.
+    @type pos:              rank-1 or rank-2 array or list of float
     @keyword element:       The element symbol.
     @type element:          str or None
     @keyword atom_num:      The atom number.

Modified: trunk/user_functions/structure.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/user_functions/structure.py?rev=18486&r1=18485&r2=18486&view=diff
==============================================================================
--- trunk/user_functions/structure.py (original)
+++ trunk/user_functions/structure.py Mon Feb 18 18:32:51 2013
@@ -75,8 +75,7 @@
 uf.add_keyarg(
     name = "pos",
     default = [None, None, None],
-    py_type = "float_array",
-    dim = 3,
+    py_type = "float_matrix",
     desc_short = "atomic position",
     desc = "The atomic coordinates."
 )
@@ -119,11 +118,11 @@
 )
 # Description.
 uf.desc.append(Desc_container())
-uf.desc[-1].add_paragraph("This allows atoms to be added to the internal 
structural object.")
+uf.desc[-1].add_paragraph("This allows atoms to be added to the internal 
structural object.  To use the same atomic coordinates for all models, the 
atomic position can be an array of 3 values.  Alternatively different 
coordinates can be used for each model if the atomic position is a rank-2 
array where the first dimension matches the number of models currently 
present.")
 uf.backend = generic_fns.structure.main.add_atom
 uf.menu_text = "&add_atom"
 uf.gui_icon = "oxygen.actions.list-add-relax-blue"
-uf.wizard_size = (800, 600)
+uf.wizard_size = (900, 700)
 uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png'
 
 




Related Messages


Powered by MHonArc, Updated Mon Feb 18 19:00:02 2013