Difference between revisions of "Tutorial for R1/R2 Relaxation curve-fitting analysis on varian recorded as fid interleaved"
Line 1: | Line 1: | ||
+ | c | ||
== Intro == | == Intro == | ||
Made from [[Tutorial_for_Relaxation_dispersion_analysis_cpmg_fixed_time_recorded_on_varian_as_fid_interleaved | Tutorial for Relaxation dispersion analysis cpmg fixed time recorded on varian as fid interleaved]] | Made from [[Tutorial_for_Relaxation_dispersion_analysis_cpmg_fixed_time_recorded_on_varian_as_fid_interleaved | Tutorial for Relaxation dispersion analysis cpmg fixed time recorded on varian as fid interleaved]] | ||
Line 114: | Line 115: | ||
=== Analyse === | === Analyse === | ||
− | + | <source lang="bash"> | |
+ | relax_trunk relax_1_ini.py -t log_relax_1_ini.log | ||
+ | </source> | ||
+ | |||
+ | = Method 2 = | ||
+ | == Intro == | ||
+ | You have measured a range of HSQC with different settings of T1 and T2. | ||
+ | |||
+ | You have imported one spectrum in analysis, made peak assignment, and now wan't to analyse for all the spectrum. | ||
+ | |||
+ | == Export peak list from analysis == | ||
+ | We want to use the NMRPipe program, '''seriesTab'''.<br> | ||
+ | First export to Sparky format. | ||
+ | |||
+ | Go to | ||
+ | # Other | ||
+ | # Format converter | ||
+ | # Export | ||
+ | # Sparky | ||
+ | # Peaks export menu | ||
+ | # Select spectrum which contain your peaks | ||
+ | # Select export file. Save to somewhere. For example: '''test.sparky'''. | ||
+ | # Export | ||
+ | # In the last menu which pop-up, slect OK for moelcular system | ||
+ | # Then be SURE to have '''Proton first in Dim 0'''. | ||
+ | |||
+ | Remove potential un-assigned peaks '?'. | ||
+ | <source lang="bash"> | ||
+ | grep -v "?" test.sparky > test2.sparky | ||
+ | </source> | ||
+ | |||
+ | Then sort the file, according to residue number. Be aware of small tricks. | ||
+ | <source lang="bash"> | ||
+ | # Extraxt assignments, removing first letter | ||
+ | awk '{print $1}' test2.sparky | cut -d'-' -f1 | cut -c2- > sort.txt | ||
+ | |||
+ | # Merge columns to prepare for sort | ||
+ | paste sort.txt test2.sparky > sort2.tx | ||
+ | |||
+ | # Sort after natural sort of (version) numbers within text | ||
+ | sort -V sort2.tx | grep -v "Assignment" > sort3.txt | ||
+ | |||
+ | # Now extract columns | ||
+ | awk '{print $2, $3, $4, $5, $6, $7}' sort3.txt > test3.sparky | ||
+ | cat test3.sparky | ||
+ | </source> | ||
+ | |||
+ | You should now have a sorted peak list. Congratulations. | ||
+ | |||
+ | Now we convert the peak list from Sparky to NMRPipe format. First find directory with files. | ||
+ | |||
+ | <source lang="bash"> | ||
+ | # Go into directory, and copy the peak file | ||
+ | cd "/sbinlab2/rma/Desktop/Documents/.../XYZ.fid" | ||
+ | cp /sbinlab2/rma/Desktop/test/test3.sparky . | ||
+ | |||
+ | set SPEAKS=test3.sparky | ||
+ | set FTFILE=0/test.ft2 | ||
+ | |||
+ | stPeakList.pl $FTFILE $SPEAKS > test.tab | ||
+ | cat test.tab | ||
+ | |||
+ | # Now check file | ||
+ | nmrDraw $FTFILE | ||
+ | </source> | ||
+ | |||
+ | In NMRDraw, '''Shift + k'''. Push '''read'''. Now zoom into a peak. Be "sure", that you have not moved the spectrum in analysis or so. | ||
+ | |||
+ | == Do intensity measurements for all spectra == | ||
+ | <source lang="bash"> | ||
+ | # '-1': single column, 'v' natural sort of (version) numbers within text, | ||
+ | ls -v -d -1 */*.ft2 > ft2_files.ls | ||
+ | cat ft2_files.ls | ||
+ | |||
+ | # So. -in 'test.tab' contains information about x,y positions in frequency units. | ||
+ | # -out tells where to store file. | ||
+ | # -list tells which ft2 files to compare. | ||
+ | # -max takes the height. | ||
+ | # -max -dx 1 -dy 1, takes the height within a freqency box of +/- 1 freqeuncy unit. | ||
+ | seriesTab -in test.tab -out peaks_list_max_standard.ser -list ft2_files.ls -max | ||
+ | seriesTab -in test.tab -out peaks_list_max_dx1_dy1.ser -list ft2_files.ls -max -dx 1 -dy 1 | ||
+ | </source> | ||
+ | |||
+ | == Extract time delays from procpar== | ||
+ | <source lang="bash"> | ||
+ | # '^' look for line starting with. | ||
+ | # Then take next line. | ||
+ | # print from column 2 to end of line. | ||
+ | set RELAXT=`awk '/^relaxT /{f=1;next}f{print $0;exit}' procpar | cut -d" " -f 2-`; echo $RELAXT | ||
+ | |||
+ | set SFRQ=`awk '/^sfrq /{f=1;next}f{print $2;exit}' procpar`; echo $SFRQ | ||
+ | </source> | ||
+ | |||
+ | Now extract noise from spectrums | ||
+ | <source lang="bash"> | ||
+ | set FIDS=`cat ft2_files.ls` | ||
+ | set OUT=../apod_rmsd.txt | ||
+ | |||
+ | foreach I (`seq 1 ${#FIDS}`) | ||
+ | set FID=${FIDS[$I]}; set DIRN=`dirname $FID` | ||
+ | cd $DIRN | ||
+ | set apodrmsd=`showApod *.ft2 | grep "REMARK Automated Noise Std Dev in Processed Data:" | awk '{print $9}'` | ||
+ | set RELAXTI=${RELAXT[$I]} | ||
+ | echo $DIRN $RELAXTI $apodrmsd $SFRQ >> $OUT | ||
+ | cd .. | ||
+ | end | ||
+ | |||
+ | cat apod_rmsd.txt | ||
+ | </source> | ||
+ | |||
+ | You should now a file with settings, which tell the delay time and spectrum noise for the measurements. <br> | ||
+ | You also have a file, which have measured intensities for spins at each spectrum. | ||
+ | |||
+ | == Analyse in relax == | ||
+ | |||
+ | === In GUI === | ||
+ | <source lang="bash"> | ||
+ | gedit analyse_relax_gui.py | ||
+ | </source> | ||
+ | |||
+ | <source lang="python"> | ||
+ | # Create the spins | ||
+ | spectrum.read_spins(file="peaks_list_max_standard.ser", dir=None) | ||
+ | |||
+ | # Read the spectrum from NMRSeriesTab file. The "auto" will generate spectrum name of form: Z_A{i} | ||
+ | spectrum.read_intensities(file="peaks_list_max_standard.ser", dir=None, spectrum_id='auto', int_method='height') | ||
+ | |||
+ | # Open the settings file. | ||
+ | set_file = open('apod_rmsd.txt', 'r') | ||
+ | |||
+ | for i, line in enumerate(set_file): | ||
+ | # Set the current spectrum id | ||
+ | current_id = "Z_A%s"%(i) | ||
+ | |||
+ | # Get the relax time. | ||
+ | relaxT_i = float(line.split()[1]) | ||
+ | rmsd_i = float(line.split()[2]) | ||
+ | sfrq_i = float(line.split()[3]) | ||
+ | |||
+ | print relaxT_i, rmsd_i, sfrq_i | ||
+ | |||
+ | # Set time | ||
+ | relax_fit.relax_time(time=relaxT_i, spectrum_id=current_id) | ||
+ | |||
+ | # Set noise | ||
+ | spectrum.baseplane_rmsd(error=rmsd_i, spectrum_id=current_id) | ||
+ | |||
+ | # Set sfrq | ||
+ | spectrometer.frequency(id=current_id, frq=sfrq_i, units='MHz') | ||
+ | </source> | ||
+ | |||
+ | Then do | ||
+ | # relax -g | ||
+ | # New analysis | ||
+ | # R2 relaxation | ||
+ | # Create pipe | ||
+ | # User functions (n-z) -> script -> analyse_relax_gui.py | ||
+ | # Set in top '''NMR freqeuncy label''' to '''750'''. | ||
+ | # Go | ||
+ | |||
+ | === In GUI === | ||
+ | <source lang="bash"> | ||
+ | gedit analyse_relax.py | ||
+ | </source> | ||
+ | |||
+ | <source lang="python"> | ||
+ | from auto_analyses.relax_fit import Relax_fit | ||
+ | |||
+ | # Taken from the relax disp manual, section 10.6.1 Dispersion script mode - the sample script | ||
+ | # Create the data pipe. | ||
+ | pipe_name = 'base pipe' | ||
+ | pipe_bundle = 'RMA' | ||
+ | pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type='relax_fit') | ||
+ | |||
+ | # Create the spins | ||
+ | spectrum.read_spins(file="peaks_list_max_standard.ser", dir=None) | ||
+ | |||
+ | # Read the spectrum from NMRSeriesTab file. The "auto" will generate spectrum name of form: Z_A{i} | ||
+ | spectrum.read_intensities(file="peaks_list_max_standard.ser", dir=None, spectrum_id='auto', int_method='height') | ||
+ | |||
+ | # Open the settings file. | ||
+ | set_file = open('apod_rmsd.txt', 'r') | ||
+ | |||
+ | for i, line in enumerate(set_file): | ||
+ | # Set the current spectrum id | ||
+ | current_id = "Z_A%s"%(i) | ||
+ | |||
+ | # Get the relax time. | ||
+ | relaxT_i = float(line.split()[1]) | ||
+ | rmsd_i = float(line.split()[2]) | ||
+ | sfrq_i = float(line.split()[3]) | ||
+ | |||
+ | print relaxT_i, rmsd_i, sfrq_i | ||
+ | |||
+ | # Set time | ||
+ | relax_fit.relax_time(time=relaxT_i, spectrum_id=current_id) | ||
+ | |||
+ | # Set noise | ||
+ | spectrum.baseplane_rmsd(error=rmsd_i, spectrum_id=current_id) | ||
+ | |||
+ | # Set sfrq | ||
+ | spectrometer.frequency(id=current_id, frq=sfrq_i, units='MHz') | ||
+ | |||
+ | Relax_fit(pipe_name=pipe_name, pipe_bundle=pipe_bundle, file_root='R2', results_dir=None, grid_inc=11, mc_sim_num=500, view_plots=False) | ||
+ | </source> | ||
+ | |||
+ | Run relax | ||
+ | <source lang="bash"> | ||
+ | relax analyse_relax.py | ||
+ | </source> |
Revision as of 19:39, 11 September 2014
c
Contents
Intro
Made from Tutorial for Relaxation dispersion analysis cpmg fixed time recorded on varian as fid interleaved
Get the process helper scripts
Check the peak list matches
sparky 0/test.ucsf
Prepare files
Make standard peak list
stPeakList.pl 0/test.ft2 peak_list_SPARKY.list > peak_list_SPARKY.tab cat peak_list_SPARKY.tab
Find *.ft2 files
ls -v -d -1 */*.ft2 > ft2_files.ls cat ft2_files.ls
Measure heights
seriesTab -in peak_list_SPARKY.tab -out peaks_list_max_standard.ser -list ft2_files.ls -max cat peaks_list_max_standard.ser
Extract the spectra settings from Varian procpar file
set RELAXT=`awk '/^relaxT /{f=1;next}f{print $0;exit}' procpar`; echo $NCYCLIST
set SFRQ=`awk '/^sfrq /{f=1;next}f{print $2;exit}' procpar`; echo $SFRQ
foreach I (`seq 2 ${#RELAXT}`)
set T=${RELAXT[$I]}; echo $T $SFRQ >> relaxt.txt
end
cat relaxt.txt
Measure RMSD in spectra
Measure the backgorund noise RMSD in each of the .ft2 files
Very fast way - RMSD via nmrpipe showApod
We can also use the showApod rmsd.
set FIDS=`cat ft2_files.ls`
set OUT=${PWD}/apod_rmsd.txt
set CWD=$PWD
rm $OUT
foreach I (`seq 1 ${#FIDS}`)
set FID=${FIDS[$I]}; set DIRN=`dirname $FID`
cd $DIRN
set apodrmsd=`showApod *.ft2 | grep "REMARK Automated Noise Std Dev in Processed Data:" | awk '{print $9}'`
echo $apodrmsd $DIRN >> $OUT
cd $CWD
end
cat $OUT
paste relaxt.txt $OUT > settings.txt
Relax script
File: relax_1_ini.py
import os
from auto_analyses.relax_fit import Relax_fit
# Taken from the relax disp manual, section 10.6.1 Dispersion script mode - the sample script
# Create the data pipe.
pipe_name = 'base pipe'
pipe_bundle = 'relax_fit'
pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type='relax_fit')
# Create the spins
spectrum.read_spins(file='peaks_list_max_standard.ser', dir=None)
# Read the spectrum from NMRSeriesTab file. The "auto" will generate spectrum name of form: Z_A{i}
spectrum.read_intensities(file="peaks_list_max_standard.ser", dir=None, spectrum_id='auto', int_method='height')
# Loop over the spectra settings.
timesfile=open('settings.txt','r')
i = 0
for line in timesfile:
timeT = line.split()[0]
set_sfrq = float(line.split()[1])
rmsd_err = float(line.split()[2])
print timeT, set_sfrq, rmsd_err
# Set the current spectrum id
current_id = "Z_A%s"%(i)
# Set the relax time
relax_fit.relax_time(time=float(timeT), spectrum_id=current_id)
# Set the peak intensity errors, as defined as the baseplane RMSD.
spectrum.baseplane_rmsd(error=rmsd_err, spectrum_id=current_id)
i += 1
# Save the program state before run.
# This state file will also be used for loading, before a later cluster/global fit analysis.
state.save('ini_setup', force=True)
# Set settings for run.
results_directory = os.path.join(os.getcwd(),"model_sel_analyt")
pipe_name = 'base pipe'; pipe_bundle = 'relax_fit'
#GRID_INC = 11; MC_NUM = 500
GRID_INC = 21; MC_NUM = 100
Relax_fit(pipe_name=pipe_name, pipe_bundle=pipe_bundle, file_root='rx', results_dir=results_directory, grid_inc=GRID_INC, mc_sim_num=MC_NUM, view_plots=True)
Analyse
relax_trunk relax_1_ini.py -t log_relax_1_ini.log
Method 2
Intro
You have measured a range of HSQC with different settings of T1 and T2.
You have imported one spectrum in analysis, made peak assignment, and now wan't to analyse for all the spectrum.
Export peak list from analysis
We want to use the NMRPipe program, seriesTab.
First export to Sparky format.
Go to
- Other
- Format converter
- Export
- Sparky
- Peaks export menu
- Select spectrum which contain your peaks
- Select export file. Save to somewhere. For example: test.sparky.
- Export
- In the last menu which pop-up, slect OK for moelcular system
- Then be SURE to have Proton first in Dim 0.
Remove potential un-assigned peaks '?'.
grep -v "?" test.sparky > test2.sparky
Then sort the file, according to residue number. Be aware of small tricks.
# Extraxt assignments, removing first letter
awk '{print $1}' test2.sparky | cut -d'-' -f1 | cut -c2- > sort.txt
# Merge columns to prepare for sort
paste sort.txt test2.sparky > sort2.tx
# Sort after natural sort of (version) numbers within text
sort -V sort2.tx | grep -v "Assignment" > sort3.txt
# Now extract columns
awk '{print $2, $3, $4, $5, $6, $7}' sort3.txt > test3.sparky
cat test3.sparky
You should now have a sorted peak list. Congratulations.
Now we convert the peak list from Sparky to NMRPipe format. First find directory with files.
# Go into directory, and copy the peak file
cd "/sbinlab2/rma/Desktop/Documents/.../XYZ.fid"
cp /sbinlab2/rma/Desktop/test/test3.sparky .
set SPEAKS=test3.sparky
set FTFILE=0/test.ft2
stPeakList.pl $FTFILE $SPEAKS > test.tab
cat test.tab
# Now check file
nmrDraw $FTFILE
In NMRDraw, Shift + k. Push read. Now zoom into a peak. Be "sure", that you have not moved the spectrum in analysis or so.
Do intensity measurements for all spectra
# '-1': single column, 'v' natural sort of (version) numbers within text,
ls -v -d -1 */*.ft2 > ft2_files.ls
cat ft2_files.ls
# So. -in 'test.tab' contains information about x,y positions in frequency units.
# -out tells where to store file.
# -list tells which ft2 files to compare.
# -max takes the height.
# -max -dx 1 -dy 1, takes the height within a freqency box of +/- 1 freqeuncy unit.
seriesTab -in test.tab -out peaks_list_max_standard.ser -list ft2_files.ls -max
seriesTab -in test.tab -out peaks_list_max_dx1_dy1.ser -list ft2_files.ls -max -dx 1 -dy 1
Extract time delays from procpar
# '^' look for line starting with.
# Then take next line.
# print from column 2 to end of line.
set RELAXT=`awk '/^relaxT /{f=1;next}f{print $0;exit}' procpar | cut -d" " -f 2-`; echo $RELAXT
set SFRQ=`awk '/^sfrq /{f=1;next}f{print $2;exit}' procpar`; echo $SFRQ
Now extract noise from spectrums
set FIDS=`cat ft2_files.ls`
set OUT=../apod_rmsd.txt
foreach I (`seq 1 ${#FIDS}`)
set FID=${FIDS[$I]}; set DIRN=`dirname $FID`
cd $DIRN
set apodrmsd=`showApod *.ft2 | grep "REMARK Automated Noise Std Dev in Processed Data:" | awk '{print $9}'`
set RELAXTI=${RELAXT[$I]}
echo $DIRN $RELAXTI $apodrmsd $SFRQ >> $OUT
cd ..
end
cat apod_rmsd.txt
You should now a file with settings, which tell the delay time and spectrum noise for the measurements.
You also have a file, which have measured intensities for spins at each spectrum.
Analyse in relax
In GUI
gedit analyse_relax_gui.py
# Create the spins
spectrum.read_spins(file="peaks_list_max_standard.ser", dir=None)
# Read the spectrum from NMRSeriesTab file. The "auto" will generate spectrum name of form: Z_A{i}
spectrum.read_intensities(file="peaks_list_max_standard.ser", dir=None, spectrum_id='auto', int_method='height')
# Open the settings file.
set_file = open('apod_rmsd.txt', 'r')
for i, line in enumerate(set_file):
# Set the current spectrum id
current_id = "Z_A%s"%(i)
# Get the relax time.
relaxT_i = float(line.split()[1])
rmsd_i = float(line.split()[2])
sfrq_i = float(line.split()[3])
print relaxT_i, rmsd_i, sfrq_i
# Set time
relax_fit.relax_time(time=relaxT_i, spectrum_id=current_id)
# Set noise
spectrum.baseplane_rmsd(error=rmsd_i, spectrum_id=current_id)
# Set sfrq
spectrometer.frequency(id=current_id, frq=sfrq_i, units='MHz')
Then do
- relax -g
- New analysis
- R2 relaxation
- Create pipe
- User functions (n-z) -> script -> analyse_relax_gui.py
- Set in top NMR freqeuncy label to 750.
- Go
In GUI
gedit analyse_relax.py
from auto_analyses.relax_fit import Relax_fit
# Taken from the relax disp manual, section 10.6.1 Dispersion script mode - the sample script
# Create the data pipe.
pipe_name = 'base pipe'
pipe_bundle = 'RMA'
pipe.create(pipe_name=pipe_name, bundle=pipe_bundle, pipe_type='relax_fit')
# Create the spins
spectrum.read_spins(file="peaks_list_max_standard.ser", dir=None)
# Read the spectrum from NMRSeriesTab file. The "auto" will generate spectrum name of form: Z_A{i}
spectrum.read_intensities(file="peaks_list_max_standard.ser", dir=None, spectrum_id='auto', int_method='height')
# Open the settings file.
set_file = open('apod_rmsd.txt', 'r')
for i, line in enumerate(set_file):
# Set the current spectrum id
current_id = "Z_A%s"%(i)
# Get the relax time.
relaxT_i = float(line.split()[1])
rmsd_i = float(line.split()[2])
sfrq_i = float(line.split()[3])
print relaxT_i, rmsd_i, sfrq_i
# Set time
relax_fit.relax_time(time=relaxT_i, spectrum_id=current_id)
# Set noise
spectrum.baseplane_rmsd(error=rmsd_i, spectrum_id=current_id)
# Set sfrq
spectrometer.frequency(id=current_id, frq=sfrq_i, units='MHz')
Relax_fit(pipe_name=pipe_name, pipe_bundle=pipe_bundle, file_root='R2', results_dir=None, grid_inc=11, mc_sim_num=500, view_plots=False)
Run relax
relax analyse_relax.py