mailr17144 - /branches/interatomic/generic_fns/structure/geometric.py


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

Header


Content

Posted by edward on July 02, 2012 - 22:09:
Author: bugman
Date: Mon Jul  2 22:09:16 2012
New Revision: 17144

URL: http://svn.gna.org/viewcvs/relax?rev=17144&view=rev
Log:
Converted generic_fns.structure.geometric.create_vector_dist() to the 
interatomic data design.


Modified:
    branches/interatomic/generic_fns/structure/geometric.py

Modified: branches/interatomic/generic_fns/structure/geometric.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/interatomic/generic_fns/structure/geometric.py?rev=17144&r1=17143&r2=17144&view=diff
==============================================================================
--- branches/interatomic/generic_fns/structure/geometric.py (original)
+++ branches/interatomic/generic_fns/structure/geometric.py Mon Jul  2 
22:09:16 2012
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2003-2011 Edward d'Auvergne                                  
 #
+# Copyright (C) 2003-2012 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax.                                    
 #
 #                                                                            
 #
@@ -28,7 +28,8 @@
 from warnings import warn
 
 # relax module imports.
-from generic_fns.mol_res_spin import exists_mol_res_spin_data, spin_loop
+from generic_fns.interatomic import interatomic_loop
+from generic_fns.mol_res_spin import exists_mol_res_spin_data, return_spin, 
spin_loop
 from generic_fns import pipes
 from generic_fns.structure.mass import centre_of_mass
 from internal import Internal
@@ -582,12 +583,11 @@
 
 
 def create_vector_dist(length=None, symmetry=True, file=None, dir=None, 
force=False):
-    """Create a PDB representation of the XH vector distribution.
+    """Create a PDB representation of the vector distribution.
 
     @param length:      The length to set the vectors to in the PDB file.
     @type length:       float
-    @param symmetry:    The symmetry flag which if set will create a second 
PDB chain 'B' which
-        is the same as chain 'A' but with the XH vectors reversed.
+    @param symmetry:    The symmetry flag which if set will create a second 
PDB chain 'B' which is the same as chain 'A' but with the vectors reversed.
     @type symmetry:     bool
     @param file:        The name of the PDB file to create.
     @type file:         str
@@ -609,10 +609,10 @@
         raise RelaxNoSequenceError
 
     # Test if unit vectors exist.
-    vectors = 0
-    for spin in spin_loop():
-        if hasattr(spin, 'xh_vect'):
-            vectors = 1
+    vectors = False
+    for interatom in interatomic_loop():
+        if hasattr(interatom, 'vector'):
+            vectors = True
             break
     if not vectors:
         raise RelaxNoVectorsError
@@ -645,27 +645,31 @@
     res_num = res_num + 1
 
 
-    # The XH vectors.
-    #################
-
-    # Loop over the spin systems.
-    for spin, mol_name, res_num, res_name in spin_loop(full_info=True):
+    # The vectors.
+    ##############
+
+    # Loop over the interatomic data containers.
+    for interatom in interatomic_loop():
+        # Get the spins.
+        spin1 = return_spin(interatom.spin_id1)
+        spin2 = return_spin(interatom.spin_id2)
+
         # Skip deselected spin systems.
-        if not spin.select:
+        if not spin1.select or not spin2.select:
             continue
 
-        # Skip spin systems missing the xh_vect structure.
-        if not hasattr(spin, 'xh_vect'):
+        # Skip containers missing vectors.
+        if not hasattr(interatom, 'vector'):
             continue
 
         # Scale the vector.
-        vector = spin.xh_vect * length * 1e10
-
-        # Add the central X atom.
-        mol.atom_add(pdb_record='ATOM', atom_num=atom_num, 
atom_name=spin.name, res_name=res_name, chain_id='A', res_num=res_num, pos=R, 
segment_id=None, element=spin.element)
-
-        # Add the H atom.
-        mol.atom_add(pdb_record='ATOM', atom_num=atom_num+1, atom_name='H', 
res_name=res_name, chain_id='A', res_num=res_num, pos=R+vector, 
segment_id=None, element='H')
+        vector = interatom.vector * length * 1e10
+
+        # Add the first spin as the central atom.
+        mol.atom_add(pdb_record='ATOM', atom_num=atom_num, 
atom_name=spin1.name, res_name=spin1._res_name, chain_id='A', 
res_num=spin1._res_num, pos=R, segment_id=None, element=spin1.element)
+
+        # Add the second spin as the end atom.
+        mol.atom_add(pdb_record='ATOM', atom_num=atom_num+1, 
atom_name=spin2.name, res_name=spin2._res_name, chain_id='A', 
res_num=spin2._res_num, pos=R+vector, segment_id=None, element=spin2.element)
 
         # Connect the two atoms.
         mol.atom_connect(index1=atom_num-1, index2=atom_num)
@@ -675,24 +679,28 @@
 
     # Symmetry chain.
     if symmetry:
-        # Loop over the spin systems.
-        for spin, mol_name, res_num, res_name in spin_loop(full_info=True):
+        # Loop over the interatomic data containers.
+        for interatom in interatomic_loop():
+            # Get the spins.
+            spin1 = return_spin(interatom.spin_id1)
+            spin2 = return_spin(interatom.spin_id2)
+
             # Skip deselected spin systems.
-            if not spin.select:
+            if not spin1.select or not spin2.select:
                 continue
 
-            # Skip spin systems missing the xh_vect structure.
-            if not hasattr(spin, 'xh_vect'):
+            # Skip containers missing vectors.
+            if not hasattr(interatom, 'vector'):
                 continue
 
             # Scale the vector.
-            vector = spin.xh_vect * length * 1e10
-
-            # Add the central X atom.
-            mol.atom_add(pdb_record='ATOM', atom_num=atom_num, 
atom_name=spin.name, res_name=res_name, chain_id='B', res_num=res_num, pos=R, 
segment_id=None, element=spin.element)
-
-            # Add the H atom.
-            mol.atom_add(pdb_record='ATOM', atom_num=atom_num+1, 
atom_name='H', res_name=res_name, chain_id='B', res_num=res_num, 
pos=R-vector, segment_id=None, element='H')
+            vector = interatom.vector * length * 1e10
+
+            # Add the first spin as the central atom.
+            mol.atom_add(pdb_record='ATOM', atom_num=atom_num, 
atom_name=spin1.name, res_name=spin1._res_name, chain_id='B', 
res_num=spin1._res_num, pos=R, segment_id=None, element=spin1.element)
+
+            # Add the second spin as the end atom.
+            mol.atom_add(pdb_record='ATOM', atom_num=atom_num+1, 
atom_name=spin2.name, res_name=spin2._res_name, chain_id='B', 
res_num=spin2._res_num, pos=R-vector, segment_id=None, element=spin2.element)
 
             # Connect the two atoms.
             mol.atom_connect(index1=atom_num-1, index2=atom_num)




Related Messages


Powered by MHonArc, Updated Mon Jul 02 22:20:01 2012