mailRe: Most efficient way to compare spin.X values between pipes


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

Header


Content

Posted by Troels Emtekær Linnet on February 14, 2014 - 15:16:
Hi Edward.

Thank you for your suggestion.
I will keep this possibility in mind. :-)

I think I aim at exporting to a flat text files.
Here the value.write function actually fulfil my needs.

The loading and saving of state files is to slow for me, and I prefer to also be able to inspect text files quickly. :-)

This seems to be a good way to handle the value.write files:

-----------------
# Importing this to prepare for python 3.x
#from __future__ import print_function

# Import other
import os, re
import itertools
import numpy as np
import matplotlib.pyplot as plt

# Loop through methods.
METHODS = ['XXX']

for METHOD in METHODS:
    # Open pipe names file
    pipes_r2eff_filename = 'pipes_r2eff_%s.txt'%(METHOD)
    pipes_r2eff_file = open(pipes_r2eff_filename,'r')
    pipes_r2eff_filelines = pipes_r2eff_file.readlines()
    pipes_r2eff_file.close()

    # Extract pipe names
    setup_pipe_bundle = "%s"%pipes_r2eff_filelines[0].strip()
    state_save_name = "%s.bz2"%pipes_r2eff_filelines[1].strip()

    # Extract which to compare to
    compare_ni_pipe_name_r2eff = pipes_r2eff_filelines[2].strip()

    # Get index of file
    with open(os.path.join('r2eff', compare_ni_pipe_name_r2eff), 'r') as f:
        for line in f:
            if line.startswith('# mol_name'):
                fileindex = line.split()[1:]
    # Remove not allowed letters
    fileindex = [w.replace('(', '') for w in fileindex]
    fileindex = [w.replace(')', '') for w in fileindex]
    fileindex = [w.replace('.', '') for w in fileindex]
    # Prepare to define what file exist of
    fdtype="S20,i,S3,i,S5"
    for item in fileindex[5:]:
        fdtype += ",f8"

    print fdtype

    data = "" compare_ni_pipe_name_r2eff), dtype=fdtype, names=fileindex)
    print(data.dtype)
    print(data.dtype.names)
    print data['%s'%fileindex[0]]
    print data['%s'%fileindex[6]]





2014-02-14 14:21 GMT+01:00 Edward d'Auvergne <edward@xxxxxxxxxxxxx>:
Hi,

This is a difficult question as efficiency changes with any change to
the pipe_control.mol_res_spin module, as well as the data set up and
specific questions you have.  You should browse the functions in that
module to see what you have access to:

$ grep "def " pipe_control/mol_res_spin.py

You may even find that implementing your own custom function in that
module would be the best.  I think for your purposes though, that the
spin_index_loop() function is what you need.  This loops over the
molecule, residue, and spin indices.  From what I understand of your
aims, you will have the same sequence data for all the data pipes you
would like to compare.  Is this correct?  If this is the case, then
the molecule, residue, and spin indices will be the same for all
pipes.  So you could use code in your script such as:

# relax module imports.
from pipe_control.mol_res_spin import spin_index_loop
from pipe_control.pipes import get_pipe

# Get the two pipes.
dp1 = get_pipe('first pipe')
dp2 = get_pipe('second pipe')

# Loop over the sequence data.
for mol_index, res_index, spin_index in spin_index_loop():
    # Alias the spins for the two pipes.
    spin1 = dp1.mol[mol_index].res[res_index].spin[spin_index]
    spin2 = dp2.mol[mol_index].res[res_index].spin[spin_index]

    # Sanity check.
    if spin1.x != spin2.x:
        raise RelaxError("X is not X?!?")


That should be the absolute fastest implementation.  But have a look
at the code to get a better idea.  As I know you are after the fastest
possible solution to be able to scan lots of data, looking at the
relax code would give you an idea of what the best solution is.  You
may find inefficiencies that can be fixed in the relax code too.

Regards,

Edward



On 14 February 2014 12:50, Troels Emtekær Linnet <tlinnet@xxxxxxxxxxxxx> wrote:
> Hi,
>
> I need an efficient way to compare spin.X values between pipes.
> Here X could be:
>
> - spin.r2eff
> - spin.chi2
> - spin.kex
> etc.
>
> I have tried implementing the following:
>
> for spin, mol_name, res_num, res_name, spin_id in spin_loop(full_info=True,
> return_id=True, skip_desel=True):
>     cur_r2eff = spin.r2eff[index_str]
>
> The problem is that r2eff is a saved as a dictionary, with a current name
> convention of:
> sq_cpmg_599.%8f_0.000_100.000
> sq_cpmg_599.%8f_0.000_133.333
> sq_cpmg_599.%8f_0.000_133.%3f
>
> This naming convention is likely to change pattern.
>
> Do there exist a efficient way to compare data values between two pipes?
>
> I would need to compare one pipe to about 50 other pipes, where each
> pipe contains about 80 spins recorded at 10-15 v_cpmg frequencies.
>
> The difference between pipe data would undergo standard statistics as RMS
> etc.
>
> Best
> Troels
>
> _______________________________________________
> relax (http://www.nmr-relax.com)
>
> This is the relax-users mailing list
> relax-users@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-users
>


Related Messages


Powered by MHonArc, Updated Tue Feb 18 02:00:10 2014