Difference between revisions of "Spin loop"

From relax wiki
Jump to navigation Jump to search
(Added an intro sentence.)
(Changed the section ordering to be more logical - the spin loop now comes first.)
Line 7: Line 7:
 
# Looking at the cdp.mol[i].res[j].spin[k] data structure.
 
# Looking at the cdp.mol[i].res[j].spin[k] data structure.
  
 +
=== Looping over spin ===
 +
The automated looping over all spin systems is provided by the <code>pipe_control.mol_res_spin.spin_loop()</code> function.
 +
<source lang="python">
 +
from pipe_control.mol_res_spin import spin_loop
 +
for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
 +
    print("Spin '%s', model '%s'" % (spin_id, spin.model))
 +
</source>
 +
 +
To see available information in the spin class
 +
<source lang="python">
 +
dir(spin)
 +
['__class__', '__clone__', '__deepcopy__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__',
 +
'__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
 +
'__subclasshook__', '__weakref__', '_back_compat_hook', '_back_compat_hook_mf_data', '_back_compat_hook_ri_data',
 +
'_mol_index', '_mol_name', '_res_index', '_res_name', '_res_num', '_spin_ids', '_spin_index',
 +
'chi2', 'chi2_sim', 'f_count', 'f_count_sim', 'g_count', 'g_count_sim', 'h_count', 'h_count_sim', 'intensities', 'intensity_err', 'is_empty',
 +
'isotope', 'iter', 'iter_sim', 'kex', 'kex_err', 'kex_sim', 'model', 'name', 'num', 'params', 'phi_ex', 'phi_ex_err',
 +
'phi_ex_sim', 'r2', 'r2_err', 'r2_sim', 'r2eff', 'r2eff_bc', 'r2eff_err', 'r2eff_sim', 'select', 'select_sim', 'warning', 'warning_sim']
 +
</source>
  
 
=== Looping over cdp ===
 
=== Looping over cdp ===
Line 63: Line 82:
 
   warning_sim: [None, None, None]
 
   warning_sim: [None, None, None]
  
</source>
 
 
=== Looping over spin ===
 
<source lang="python">
 
from pipe_control.mol_res_spin import spin_loop
 
for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
 
    print("Spin '%s', model '%s'" % (spin_id, spin.model))
 
</source>
 
 
To see available information in the spin class
 
<source lang="python">
 
dir(spin)
 
['__class__', '__clone__', '__deepcopy__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__',
 
'__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
 
'__subclasshook__', '__weakref__', '_back_compat_hook', '_back_compat_hook_mf_data', '_back_compat_hook_ri_data',
 
'_mol_index', '_mol_name', '_res_index', '_res_name', '_res_num', '_spin_ids', '_spin_index',
 
'chi2', 'chi2_sim', 'f_count', 'f_count_sim', 'g_count', 'g_count_sim', 'h_count', 'h_count_sim', 'intensities', 'intensity_err', 'is_empty',
 
'isotope', 'iter', 'iter_sim', 'kex', 'kex_err', 'kex_sim', 'model', 'name', 'num', 'params', 'phi_ex', 'phi_ex_err',
 
'phi_ex_sim', 'r2', 'r2_err', 'r2_sim', 'r2eff', 'r2eff_bc', 'r2eff_err', 'r2eff_sim', 'select', 'select_sim', 'warning', 'warning_sim']
 
 
</source>
 
</source>
  

Revision as of 18:13, 19 October 2015

The spin loop is a powerful concept built into the relax data model for allowing for programmatic access to the spin system information for power users.


View results per spin

  1. Looking at the contents of the spin viewer window in the GUI,
  2. Opening a relax results or state XML file in a text editor,
  3. Looking at the cdp.mol[i].res[j].spin[k] data structure.

Looping over spin

The automated looping over all spin systems is provided by the pipe_control.mol_res_spin.spin_loop() function.

from pipe_control.mol_res_spin import spin_loop
for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
    print("Spin '%s', model '%s'" % (spin_id, spin.model))

To see available information in the spin class

dir(spin)
['__class__', '__clone__', '__deepcopy__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', 
'__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', 
'__subclasshook__', '__weakref__', '_back_compat_hook', '_back_compat_hook_mf_data', '_back_compat_hook_ri_data', 
'_mol_index', '_mol_name', '_res_index', '_res_name', '_res_num', '_spin_ids', '_spin_index', 
'chi2', 'chi2_sim', 'f_count', 'f_count_sim', 'g_count', 'g_count_sim', 'h_count', 'h_count_sim', 'intensities', 'intensity_err', 'is_empty', 
'isotope', 'iter', 'iter_sim', 'kex', 'kex_err', 'kex_sim', 'model', 'name', 'num', 'params', 'phi_ex', 'phi_ex_err', 
'phi_ex_sim', 'r2', 'r2_err', 'r2_sim', 'r2eff', 'r2eff_bc', 'r2eff_err', 'r2eff_sim', 'select', 'select_sim', 'warning', 'warning_sim']

Looping over cdp

print cdp.mol
for resiob in cdp.mol[0].res:
    print resiob.name, resiob.num, resiob.spin[0].kex, resiob.spin[0].model

print dir(resiob)
['__class__', '__clone__', '__deepcopy__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__',
'__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
'__subclasshook__', '__weakref__', '_mol_index', '_mol_name', '_res_index', '_spin_name_count', '_spin_num_count',
'is_empty', 'name', 'num', 'spin']

print resiob.spin[0]
Class containing all the spin system specific data.


Objects:
  chi2: 11.874300873564689
  chi2_sim: [14.523790384116937, 10.421984394434467, 5.782991669673739]
  f_count: 4346
  f_count_sim: [3091, 3066, 3088]
  g_count: 0
  g_count_sim: [0, 0, 0]
  h_count: 0
  h_count_sim: [0, 0, 0]
  intensities: {...}
  intensity_err: {...}
  isotope: '15N'
  iter: 2321
  iter_sim: [1445, 1489, 1499]
  kex: 1518.3336310465504
  kex_err: 24.718400260552574
  kex_sim: [1547.3705743455107, 1500.7295092586053, 1509.8565144042634]
  model: 'LM63'
  name: 'N'
  num: 299
  params: ['r2', 'phi_ex', 'kex']
  phi_ex: 0.03280687317441723
  phi_ex_err: 0.0010729815517414483
  phi_ex_sim: [0.032435172864419055, 0.03258987358910283, 0.0343661464342843]
  r2: [4.368523460822981]
  r2_err: [0.08171058470725454]
  r2_sim: [[4.435626855491755], [4.4791162202194625], [4.320948059941103]]
  r2eff: {...}
  r2eff_bc: {...}
  r2eff_err: {...}
  r2eff_sim: [{...}]
  select: True
  select_sim: [True, True, True]
  tex: 0.0003293083876798291
  tex_err: 5.312950569801097e-06
  tex_sim: [0.00032312880203986323, 0.0003331712989684673, 0.00033115729556413014]
  warning: None
  warning_sim: [None, None, None]

See also