mailRe: r13246 - /branches/xyz/prompt/structure.py


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

Header


Content

Posted by Edward d'Auvergne on June 28, 2011 - 14:39:
Hi,

This should work automatically for relax as well then.  If you ask for
atom @9, then you get that unique atom.  So every proton will have
it's own unique number based on the position in the XYZ file.  The
current user functions will work with this without issue, so there
will be no need to come up with new ones.  The only problem with this
is that there would have to be a call to structure.vectors() for every
atom.  The attached argument will need to be modified though to accept
a spin ID string rather than the name of the attached atom.  So that
instead of:

relax> structure.vectors(attached='H', spin_id='@C&@1')

i.e. the proton attached to carbon 1, you would type:

relax> structure.vectors(spin_id='@C&@1', attached='@H&@2')

or even more simply:

relax> structure.vectors(spin_id='@1', attached='@2')

where atom 1 is the carbon loaded as a spin, and atom 2 is the
attached proton.  The user could come up with a loop over a list of
carbon atoms and protons to load all vectors.  I think this would be
the best approach.  Is there another way we could do this?

Regards,

Edward





On 28 June 2011 14:13, Han Sun <hasu@xxxxxxxxxxxxxxxxx> wrote:
Hi,

In NMRDev and in openbabel they name the atom after their atom number,
because the atom number is unique for its atom.

And in NMRDev if I want to load a vector between two spins, then I just give
the two atom numbers. It works very well.

Best,
Han


On Jun 28, 2011, at 1:59 PM, Edward d'Auvergne wrote:

Hi,

It sounds like we need to come up with a way of identifying the two
atoms in a consistent way.  Do you know how is this done in other
programs?  For example in NMRDev
(http://magcid.uvigo.es/~armando/nmrdev/)?  Or in other organic
chemistry software.  I have a feeling we will have to come up with a
way of naming the atoms.  We cannot use the atom number as these are
sequential from the file and a number is only allowed to be used once.
 Normally the atoms are differentiated using atom names such as H1 and
H2.  Should we attempt to determine connectivities and rename the
atoms?  Essentially there is no atom name in the XYZ file, it is more
the element type.  I think we need to study other software to see how
this is handled.  We can then document what they do in an post to the
mailing list, and decide what the best way to do this in relax would
be.  What do you think?

Regards,

Edward


P. S.  I may not be able to answer emails for a while as I'll soon be
catching the train to Goettingen.  I could answer questions tonight.


On 28 June 2011 13:01, Han Sun <hasu@xxxxxxxxxxxxxxxxx> wrote:

Hi Edward,

that is reason why I want to generate a new function for the xyz
yesterday.
I think the best way to do is to load atoms specific.
For example:

self.interpreter.structure.vectors_xyz(spin_id1='#SSS-cluster4-new-test_mol1@1',
spin_id2='#SSS-cluster4-new-test_mol1@2')

And we don't need to care whether it is bonded or not, because in the RDC
analysis sometime you have 2 or 3 bonded couplings. What do you think?

Best,
Han


On Jun 28, 2011, at 12:20 PM, Edward d'Auvergne wrote:

Hi,

Yes, this would be a problem.  The code is a temporary work around,
and is avoided if you specify a unique proton name (assuming the
protons have different names).  The problem here is if you have RDCs
for both of the CH bonds in a CH2 group, how are we going to specify
which RDC belongs to which atom from the XYZ file?  How do we
differentiate the different values?  We will need to think about that
one for a bit.  How did we previously do this?

Regards,

Edward



On 28 June 2011 12:09, Han Sun <hasu@xxxxxxxxxxxxxxxxx> wrote:

Hi Edward,

in the function __bonded_atom() I found following code:

     # Problem.
     if num_attached > 1:
         # Get the atom names.
         matching_names = []
         for i in matching_list:
             matching_names.append(mol.atom_name[i])

         # Return nothing but a warning.
         return None, None, None, None, None, 'More than one attached
atom
found: ' + repr(matching_names)

This means that it can only load one atom. But this is often not the
case
for small molecule. For example if I have a CH3 group and I asked it to
load
protons, all three protons should be loaded.

Best,
Han


On Jun 27, 2011, at 7:26 PM, Edward d'Auvergne wrote:

Hi Han,

This is another case were the current code can be used, and if it
doesn't work then it should be fixed rather than a new function added.
 The structure.vectors() method is independent of the format of the
structural file.  Normally when I use it, the PDB file has been read
in and is in the internal structure format.  After reading the XYZ
file, it should also be in the internal format.  So the
structure.vectors() user function should work on both.  So if you load
all the carbons as spins from the organic molecule, the CH vectors
should be extractable with:

relax> structure.vectors(attached='H', spin_id='@C')

The 'H' needs no '*' characters as all protons in the XYZ file are
called 'H'.  The internal structural object will then determine which
'H' atoms are attached to the C atoms.  This is either taken from the
structural file, or it uses a very basic distance based algorithm in
__bonded_atom() and __find_bonded_atoms().  I have a feeling that this
will work automatically.

Regards,

Edward



On 27 June 2011 18:55,  <hasu@xxxxxxxxxxxxxxxxx> wrote:

Author: han87
Date: Mon Jun 27 18:55:51 2011
New Revision: 13246

URL: http://svn.gna.org/viewcvs/relax?rev=13246&view=rev
Log:
A new function vector_xyz() was generated.

A new function vector_xyz() was generated in '/prompt/structure.py'
for
extracting a vector of two given atoms in a xyz file.

Modified:
 branches/xyz/prompt/structure.py

Modified: branches/xyz/prompt/structure.py
URL:


http://svn.gna.org/viewcvs/relax/branches/xyz/prompt/structure.py?rev=13246&r1=13245&r2=13246&view=diff



==============================================================================
--- branches/xyz/prompt/structure.py (original)
+++ branches/xyz/prompt/structure.py Mon Jun 27 18:55:51 2011
@@ -686,6 +686,76 @@
     generic_fns.structure.main.vectors(attached=attached,
spin_id=spin_id, model=model, verbosity=verbosity, ave=ave,
unit=unit)


+    def vectors_xyz(self, spin_id1=None, spin_id2=None, model=None,
verbosity=1, ave=True, unit=True):
+        """Extract and store the bond vectors from the loaded
structures
in the spin container.
+
+        Keyword arguments
+        ~~~~~~~~~~~~~~~~~
+
+        spin_id1:  The spin identification string of the spin 1.
+
+        spin_id2:  The spin identification string of the spin 2.
+
+        model:  The model to extract bond vectors from (which if set
to
None will cause the vectors
+        of all models to be extracted).
+
+        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.
+
+        ave:  A flag which if True will cause the bond vectors from
all
models to be averaged.  If
+        vectors from only one model is extracted, this argument will
have no effect.
+
+        unit:  A flag which if True will cause the unit vector to
calculated rather than the full
+        length bond vector.
+
+
+        Description
+        ~~~~~~~~~~~
+
+        For a number of types of analysis, bond vectors or unit bond
vectors are required for the
+        calculations.  This user function allows these vectors to be
extracted from the loaded
+        structures. The bond vector will be that from the two atoms
of
a
xyz file loaded in relax.
+
+        The extraction of vectors can occur in a number of ways.
 For
example if an NMR structure
+        with N models is loaded or if multiple molecules, from any
source, of the same compound are
+        loaded as different models, there are three options for
extracting the bond vector.  Firstly
+        the bond vector of a single model can be extracted by
setting
the 'model' argument.
+        Secondly the bond vectors from all models can be extracted
if
'model' is None and 'ave' is
+        set to False.  Thirdly, if 'model' is None and 'ave' is set
to
True, then a single vector
+        which is the average for all models will be calculated.
+
+
+        Example
+        ~~~~~~~
+
+        To extract a vector of two atoms from xyz file, type:
+
+        relax>
structure.vectors(spin_id1='#SSS-cluster4-new-test_mol1@2',
spin_id1='#SSS-cluster4-new-test_mol1@1')
+        """
+
+        # Function intro text.
+        if self._exec_info.intro:
+            text = self._exec_info.ps3 + "structure.vectors("
+            text = text + "spin_id1=" + repr(spin_id1)
+            text = text + ", spin_id2=" + repr(spin_id2)
+            text = text + ", model=" + repr(model)
+            text = text + ", verbosity=" + repr(verbosity)
+            text = text + ", ave=" + repr(ave)
+            text = text + ", unit=" + repr(unit) + ")"
+            print(text)
+
+        # The argument checks.
+        arg_check.is_str(spin_id1, 'spin_identification_string',
can_be_none=True)
+        arg_check.is_str(spin_id2, 'spin identification string',
can_be_none=True)
+        arg_check.is_int(model, 'model', can_be_none=True)
+        arg_check.is_int(verbosity, 'verbosity level')
+        arg_check.is_bool(ave, 'average vector flag')
+        arg_check.is_bool(unit, 'unit vector flag')
+
+        # Execute the functional code.
+        generic_fns.structure.main.vectors_xyz(spin_id1=spin_id1,
spin_id2=spin_id2, model=model, verbosity=verbosity, ave=ave,
unit=unit)
+
+
 def write_pdb(self, file=None, dir=None, model_num=None,
force=False):
     """The PDB writing function.



_______________________________________________
relax (http://nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits


_______________________________________________
relax (http://nmr-relax.com)

This is the relax-devel mailing list
relax-devel@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel









Related Messages


Powered by MHonArc, Updated Tue Jun 28 15:20:20 2011