Difference between revisions of "Tutorial for the relaxation dispersion auto-analysis in the GUI"
Jump to navigation
Jump to search
(→Tutorial: Formatting improvements.) |
|||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | __TOC__ | ||
+ | |||
== Tutorial == | == Tutorial == | ||
This follows the setup for test data in the Manual | This follows the setup for test data in the Manual | ||
Line 19: | Line 21: | ||
We run relax repeatedly, to execute code. Then we write new code in the script, and run again. | We run relax repeatedly, to execute code. Then we write new code in the script, and run again. | ||
− | + | <source lang="bash"> | |
− | + | relax test.py | |
+ | </source> | ||
When we are satisfied, one can then do like this. | When we are satisfied, one can then do like this. | ||
Start relax | Start relax | ||
− | + | <source lang="bash"> | |
+ | relax -g -t log.txt | ||
+ | </source> | ||
+ | |||
Then do | Then do | ||
User functions -> Script -> test.py | User functions -> Script -> test.py | ||
Line 40: | Line 46: | ||
Then a quick click on spin.isotope function, and GO. | Then a quick click on spin.isotope function, and GO. | ||
− | === test.py | + | === The script === |
− | + | ||
− | # | + | {{collapsible script |
+ | | type = Python script | ||
+ | | title = The test.py script. | ||
+ | | lang = python | ||
+ | | script = | ||
+ | # Python modules. | ||
import os | import os | ||
import glob | import glob | ||
+ | from time import asctime, localtime | ||
− | # relax modules | + | # relax modules. |
from lib.io import sort_filenames | from lib.io import sort_filenames | ||
− | # Set path to data | + | # Set path to data. |
data = '/sbinlab2/tlinnet/software/NMR-relax/relax_trunk/test_suite/shared_data/dispersion/Hansen' | data = '/sbinlab2/tlinnet/software/NMR-relax/relax_trunk/test_suite/shared_data/dispersion/Hansen' | ||
# Create the data pipe. | # Create the data pipe. | ||
− | + | pipe_bundle = "relax_disp (%s)" % asctime(localtime()) | |
− | pipe_bundle | + | pipe_name = "origin - %s" % pipe_bundle |
pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type='relax_disp') | pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type='relax_disp') | ||
Line 67: | Line 79: | ||
# Do for 500. | # Do for 500. | ||
− | ############# | + | ############# |
+ | |||
# Change directory. | # Change directory. | ||
os.chdir(data + os.sep + '500_MHz') | os.chdir(data + os.sep + '500_MHz') | ||
− | # Get the file list, and sort the file list | + | # Get the file list, and sort the file list alphanumeric. |
flist500 = glob.glob('*.in_sparky') | flist500 = glob.glob('*.in_sparky') | ||
flist500 = sort_filenames(filenames=flist500) | flist500 = sort_filenames(filenames=flist500) | ||
− | # Make ID | + | # Make ID. |
ID500 = [] | ID500 = [] | ||
− | for f in flist500: ID500.append("500_"+f.split(".in_sparky")[0]) | + | for f in flist500: |
+ | ID500.append("500_"+f.split(".in_sparky")[0]) | ||
− | # Then | + | # Then read. |
spectrum.read_intensities(file=flist500, spectrum_id=ID500) | spectrum.read_intensities(file=flist500, spectrum_id=ID500) | ||
Line 86: | Line 100: | ||
flist500rep = sort_filenames(filenames=flist500rep) | flist500rep = sort_filenames(filenames=flist500rep) | ||
− | # Make ID | + | # Make ID. |
ID500rep = [] | ID500rep = [] | ||
− | for f in flist500rep: ID500rep.append("500_"+f.split(".in.bis_sparky")[0]+'b') | + | for f in flist500rep: |
+ | ID500rep.append("500_"+f.split(".in.bis_sparky")[0]+'b') | ||
− | # Then | + | # Then read. |
spectrum.read_intensities(file=flist500rep, spectrum_id=ID500rep) | spectrum.read_intensities(file=flist500rep, spectrum_id=ID500rep) | ||
− | # Then map replicated | + | # Then map replicated. |
for b_id in ID500rep: | for b_id in ID500rep: | ||
a_id = b_id[:-1] | a_id = b_id[:-1] | ||
spectrum.replicated(spectrum_ids=[a_id, b_id]) | spectrum.replicated(spectrum_ids=[a_id, b_id]) | ||
− | # Then check | + | # Then check. |
− | print cdp.replicates | + | print(cdp.replicates) |
# Then repeat for 800. | # Then repeat for 800. | ||
− | ###################### | + | ###################### |
+ | |||
# Change directory. | # Change directory. | ||
os.chdir(data + os.sep + '800_MHz') | os.chdir(data + os.sep + '800_MHz') | ||
− | # Get the file list, and sort the file list | + | # Get the file list, and sort the file list alphanumeric. |
flist800 = glob.glob('*.in_sparky') | flist800 = glob.glob('*.in_sparky') | ||
flist800 = sort_filenames(filenames=flist800) | flist800 = sort_filenames(filenames=flist800) | ||
− | # Make ID | + | # Make ID. |
ID800 = [] | ID800 = [] | ||
− | for f in flist800: ID800.append("800_"+f.split(".in_sparky")[0]) | + | for f in flist800: |
+ | ID800.append("800_"+f.split(".in_sparky")[0]) | ||
− | # Then | + | # Then read. |
spectrum.read_intensities(file=flist800, spectrum_id=ID800) | spectrum.read_intensities(file=flist800, spectrum_id=ID800) | ||
Line 121: | Line 138: | ||
flist800rep = sort_filenames(filenames=flist800rep) | flist800rep = sort_filenames(filenames=flist800rep) | ||
− | # Make ID | + | # Make ID. |
ID800rep = [] | ID800rep = [] | ||
− | for f in flist800rep: ID800rep.append("800_"+f.split(".in.bis_sparky")[0]+'b') | + | for f in flist800rep: |
+ | ID800rep.append("800_"+f.split(".in.bis_sparky")[0]+'b') | ||
− | # Then | + | # Then read. |
spectrum.read_intensities(file=flist800rep, spectrum_id=ID800rep) | spectrum.read_intensities(file=flist800rep, spectrum_id=ID800rep) | ||
− | # Then map replicated | + | # Then map replicated. |
for b_id in ID800rep: | for b_id in ID800rep: | ||
a_id = b_id[:-1] | a_id = b_id[:-1] | ||
spectrum.replicated(spectrum_ids=[a_id, b_id]) | spectrum.replicated(spectrum_ids=[a_id, b_id]) | ||
− | # Then check | + | # Then check. |
− | print cdp.replicates | + | print(cdp.replicates) |
− | + | print("%s %s %s %s" % (len(ID500), len(ID500rep), len(ID800), len(ID800rep))) | |
− | print len(ID500), len(ID500rep), len(ID800), len(ID800rep) | ||
− | # Then set spectrum properties | + | # Then set spectrum properties. |
all_ID = ID500 + ID500rep + ID800 + ID800rep | all_ID = ID500 + ID500rep + ID800 + ID800rep | ||
for cur_id in all_ID: | for cur_id in all_ID: | ||
− | # Split from name | + | # Split from name. |
sfrq_str, vcpmg_str = cur_id.split("_") | sfrq_str, vcpmg_str = cur_id.split("_") | ||
Line 149: | Line 166: | ||
else: | else: | ||
vcpmg = float(vcpmg_str.split("b")[0]) | vcpmg = float(vcpmg_str.split("b")[0]) | ||
− | print cur_id, sfrq_str, vcpmg | + | print("%s %s %s" % (cur_id, sfrq_str, vcpmg)) |
# Set the current experiment type. | # Set the current experiment type. | ||
Line 162: | Line 179: | ||
# Set the relaxation dispersion CPMG frequencies. | # Set the relaxation dispersion CPMG frequencies. | ||
relax_disp.cpmg_setup(spectrum_id=cur_id, cpmg_frq=vcpmg) | relax_disp.cpmg_setup(spectrum_id=cur_id, cpmg_frq=vcpmg) | ||
− | + | }} | |
== Inspect results == | == Inspect results == | ||
Line 168: | Line 185: | ||
Execute | Execute | ||
− | + | <source lang="bash"> | |
− | + | cd $HOME/test/final | |
− | + | ./grace2images.py | |
+ | </source> | ||
Go through the PNG images | Go through the PNG images | ||
Also open | Also open | ||
− | + | <source lang="bash"> | |
+ | gedit $HOME/test/log.txt $HOME/test/final/chi2.out $HOME/test/final/models.out | ||
+ | gedit $HOME/test/No_Rex/chi2.out | ||
+ | gedit $HOME/test/CR72/chi2.out $HOME/test/CR72/kex.out | ||
+ | gedit $HOME/test/NS_CPMG_2-site_expanded/chi2.out $HOME/test/NS_CPMG_2-site_expanded/kex.out | ||
+ | </source> | ||
== Get info from log.txt == | == Get info from log.txt == | ||
− | + | See [[Grep_log_file|Grep log file]] for inspiration. | |
+ | |||
+ | Try these different grep commands | ||
+ | <source lang="bash"> | ||
+ | egrep -wi --color 'relax>| model -' $HOME/test/log.txt | ||
+ | </source> | ||
+ | |||
+ | Find '''eliminate''' function | ||
+ | <source lang="bash"> | ||
+ | egrep -wi --color -A 10 'relax> eliminate' $HOME/test/log.txt | ||
+ | </source> | ||
+ | |||
+ | Find '''model_selection''' function | ||
+ | <source lang="bash"> | ||
+ | egrep -wi --color -A 100 'relax> model_selection' $HOME/test/log.txt | ||
+ | </source> | ||
== See also == | == See also == | ||
[[Category:Tutorials]] | [[Category:Tutorials]] | ||
[[Category:Relaxation dispersion analysis]] | [[Category:Relaxation dispersion analysis]] |
Latest revision as of 18:37, 6 November 2015
Tutorial
This follows the setup for test data in the Manual
- The relaxation dispersion auto-analysis in the GUI
- http://www.nmr-relax.com/manual/The_relaxation_dispersion_auto_analysis_in_the_GUI.html
Where the test data is in:
test_suite/shared_data/dispersion/Hansen
It is written up here as a script instead. This goes a little faster testing.
In terminal
mkdir -p $HOME/test
cd $HOME/test
gedit test.py
Then we build the script onwards.
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.
The script
Python script: The test.py script.
Inspect results
Go to the final folder.
Execute
cd $HOME/test/final
./grace2images.py
Go through the PNG images
Also open
gedit $HOME/test/log.txt $HOME/test/final/chi2.out $HOME/test/final/models.out
gedit $HOME/test/No_Rex/chi2.out
gedit $HOME/test/CR72/chi2.out $HOME/test/CR72/kex.out
gedit $HOME/test/NS_CPMG_2-site_expanded/chi2.out $HOME/test/NS_CPMG_2-site_expanded/kex.out
Get info from log.txt
See Grep log file for inspiration.
Try these different grep commands
egrep -wi --color 'relax>| model -' $HOME/test/log.txt
Find eliminate function
egrep -wi --color -A 10 'relax> eliminate' $HOME/test/log.txt
Find model_selection function
egrep -wi --color -A 100 'relax> model_selection' $HOME/test/log.txt