Changes

Jump to navigation Jump to search

Tutorial for the relaxation dispersion auto-analysis in the GUI

4,381 bytes added, 11:02, 18 November 2014
no edit summary
gedit test.py
</source>
 
Then we build the script onwards.<br>
 
We run relax repeatedly, to execute code. Then we write new code in the script, and run again.
relax test.py
 
When we are satisfied, one can then do like this.
 
Start relax
relax -g -t log.txt
Then do
User functions -> Script -> test.py
 
THEN do:
View -> Data pipe editor -> Right click on pipe -> Associate with a new Auto analysis
 
'''This should bring you to a window, where all settings have been set.'''
 
Set
* Relaxations dispersion models: ['R2eff', 'No Rex', 'CR72', 'NS CPMG 2-site expanded']
* Grid increements: 11 (For speed-up in test phase)
* Monte-Carlo simulations number: 5 (For speed up in test phase)
 
Then a quick click on spin.isotope function, and GO.
 
=== test.py ===
<source lang="python">
#python modules
import os
import glob
 
# relax modules
from lib.io import sort_filenames
 
# Set path to data
data = '/sbinlab2/tlinnet/software/NMR-relax/relax_trunk/test_suite/shared_data/dispersion/Hansen'
 
# Create the data pipe.
pipe_name = 'origin - relax_disp (Tue Nov 18 10:39:36 2014)'
pipe_bundle = 'relax_disp (Tue Nov 18 10:39:36 2014)'
pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type='relax_disp')
 
# Create spin to hold data.
sequence.read(file='fake_sequence.in', dir=data, res_num_col=1, res_name_col=2)
deselect.read(file='unresolved', dir=data+os.sep+'500_MHz', spin_id_col=None, mol_name_col=None, res_num_col=1, boolean='AND', change_all=False)
deselect.read(file='unresolved', dir=data+os.sep+'800_MHz', spin_id_col=None, mol_name_col=None, res_num_col=1, res_name_col=2, boolean='AND', change_all=False)
 
# Give the spins attributes.
spin.isotope(isotope='15N', spin_id='@*', force=True)
spin.name(name='N')
 
# Do for 800.
###############################################
# Change directory.
os.chdir(data + os.sep + '500_MHz')
 
# Get the file list, and sort the file list Alphanumeric.
flist500 = glob.glob('*.in_sparky')
flist500 = sort_filenames(filenames=flist500)
 
# Make ID
ID500 = []
for f in flist500: ID500.append("500_"+f.split(".in_sparky")[0])
 
# Then Read
spectrum.read_intensities(file=flist500, spectrum_id=ID500)
 
# Repeat for the replicated spectra.
flist500rep = glob.glob('*in.bis_sparky')
flist500rep = sort_filenames(filenames=flist500rep)
 
# Make ID
ID500rep = []
for f in flist500rep: ID500rep.append("500_"+f.split(".in.bis_sparky")[0]+'b')
 
# Then Read
spectrum.read_intensities(file=flist500rep, spectrum_id=ID500rep)
 
# Then map replicated
for b_id in ID500rep:
a_id = b_id[:-1]
spectrum.replicated(spectrum_ids=[a_id, b_id])
 
# Then check
print cdp.replicates
 
# Then repeat for 800.
###############################################
# Change directory.
os.chdir(data + os.sep + '800_MHz')
 
# Get the file list, and sort the file list Alphanumeric.
flist800 = glob.glob('*.in_sparky')
flist800 = sort_filenames(filenames=flist800)
 
# Make ID
ID800 = []
for f in flist800: ID800.append("800_"+f.split(".in_sparky")[0])
 
# Then Read
spectrum.read_intensities(file=flist800, spectrum_id=ID800)
 
# Repeat for the replicated spectra.
flist800rep = glob.glob('*in.bis_sparky')
flist800rep = sort_filenames(filenames=flist800rep)
 
# Make ID
ID800rep = []
for f in flist800rep: ID800rep.append("800_"+f.split(".in.bis_sparky")[0]+'b')
 
# Then Read
spectrum.read_intensities(file=flist800rep, spectrum_id=ID800rep)
 
# Then map replicated
for b_id in ID800rep:
a_id = b_id[:-1]
spectrum.replicated(spectrum_ids=[a_id, b_id])
 
# Then check
print cdp.replicates
################################################
print len(ID500), len(ID500rep), len(ID800), len(ID800rep)
 
# Then set spectrum properties
all_ID = ID500 + ID500rep + ID800 + ID800rep
 
for cur_id in all_ID:
# Split from name
sfrq_str, vcpmg_str = cur_id.split("_")
 
if vcpmg_str == 'reference':
vcpmg = None
else:
vcpmg = float(vcpmg_str.split("b")[0])
print cur_id, sfrq_str, vcpmg
 
# Set the current experiment type.
relax_disp.exp_type(spectrum_id=cur_id, exp_type='SQ CPMG')
 
# Set the NMR field strength of the spectrum.
spectrometer.frequency(id=cur_id, frq=float(sfrq_str), units='MHz')
 
# Relaxation dispersion CPMG constant time delay T (in s).
relax_disp.relax_time(spectrum_id=cur_id, time=0.03)
 
# Set the relaxation dispersion CPMG frequencies.
relax_disp.cpmg_setup(spectrum_id=cur_id, cpmg_frq=vcpmg)
</source>
 
== See also ==
[[Category:Tutorials]]
[[Category:Relaxation dispersion analysis]]
Trusted, Bureaucrats
1,382

edits

Navigation menu