Open main menu

Tutorial for Relaxation dispersion analysis r1rho fixed time recorded on varian as sequential spectra

Intro

This tutorial presently cover the relax_disp branch.
This branch is under development, for testing it out, you need to use the source code. See Installation_linux#Checking_out_a_relax_branch.

This tutorial is based on the analysis of R1rho data, analysed in a master thesis.

The spectra is not recorded interleaved, but as a series of spectra with experimental changes.

Preparation

You want to make a working dir, with different folders

peak_lists
spectrometer_data
scripts

You can create the folders by

mkdir peak_lists spectrometer_data scripts

In the folder peak_lists should contain SPARKY list in SPARKY list format.
In the folder scripts we put scripts which help us processing the files.
In the folder spectrometer_data should be a directory containing directories with all experiments where each directory contain files: fid and procpar as the output from recording on Varian.

Establish file-overview

Make file with paths to fid files

We make a file list of filepaths to fid files.

ls -v -d -1 */fid > fid_files.ls
cat fid_files.ls

Do something in each directory

With the fid_files.ls, we can do something in each directory.
For example do a list files in each direcory.

set FIDS=`cat fid_files.ls`

foreach I (`seq 1 ${#FIDS}`)
set FID=${FIDS[$I]}; set DIRN=`dirname $FID`
cd $DIRN
ls 
cd ..
end

Extract the spectra settings from Varian procpar file

Now we want to make a settings file we can read in relax.

set FIDS=`cat fid_files.ls`
set OUT=$PWD/exp_parameters.txt

echo "# DIRN I deltadof2 dpwr2slock ncyc trim ss sfrq" > $OUT
foreach I (`seq 1 ${#FIDS}`)
set FID=${FIDS[$I]}; set DIRN=`dirname $FID`
cd $DIRN
set deltadof2=`awk '/^deltadof2 /{f=1;next}f{print $2;exit}' procpar`
set dpwr2slock=`awk '/^dpwr2slock /{f=1;next}f{print $2;exit}' procpar`
set ncyc=`awk '/^ncyc /{f=1;next}f{print $2;exit}' procpar`
set trim=`awk '/^trim /{f=1;next}f{print $2;exit}' procpar`
set ss=`awk '/^ss /{f=1;next}f{print $2;exit}' procpar`
set sfrq=`awk '/^sfrq /{f=1;next}f{print $2;exit}' procpar`
echo "$DIRN $I $deltadof2 $dpwr2slock $ncyc $trim $ss $sfrq" >> $OUT
cd ..
end

cat $OUT

You can check, if you have repetitions of experiments, by sorting the parameters, and see if they are dublicated.
We do this, by numerical sort columns 3,4 and 5 with the values for "deltadof2, dpwr2slock, ncyc".

sort -b -k 3,3n -k 4,4n -k 5,5n exp_parameters.txt | awk '{print $3, $4, $5}'
sort -b -k 3,3n -k 4,4n -k 5,5n exp_parameters.txt > exp_parameters_sort.txt

Spectral process files

Copy data

We first copy the data

# Copy data
cp -r spectrometer_data spectrometer_data_processed
cd spectrometer_data_processed

Change format to NMRPipe

set CWD=$PWD
set DIRS=`cat fid_files.ls | sed 's/\/fid//g'`
cd ${DIRS[1]}
varian

Now we make a file to convert from binary format of Varian to NMRPipe.

  1. Now click, 'read parameters', check 'Rance-Kay'
  2. Remember to set Y-'Observe Freq MHz' to N15
  3. Remove sleep 5 from the script.
  4. Click 'Save script' to make fid.com file, and 'Quit', and run the script.

Spectral processing

This step can be done by following wiki page Spectral_processing.
Start nmrDraw by command

nmrDraw

Convert and spectral processing all

Now we want to convert all spectra.
You should have a fid.com and nmrproc.com in the first FID folder.
We now copy these script into all of the experimental folders, and execute them.

cd $CWD

set FIDS=`cat fid_files.ls`
set DIRN1=`dirname $PWD/${FIDS[1]}`
 
foreach I (`seq 2 ${#FIDS}`)
set FID=${FIDS[$I]}; set DIRN=`dirname $FID`
cd $DIRN
echo $DIRN
cp -f $DIRN1/fid.com .
cp -f $DIRN1/nmrproc.com .
./fid.com
./nmrproc.com
cd ..
end

Convert NMRPipe to Sparky

Next we also want to convert them to SPARKY format.

set FTS=`ls -v -d -1 */*.ft2`

foreach FT ($FTS)
    set DNAME=`dirname $FT`
    set BNAME=`basename $FT`
    set FNAME=`echo $BNAME | cut -d'.' -f1`
    echo $FT $DNAME $BNAME $FNAME
    pipe2ucsf $FT ${DNAME}/${FNAME}.ucsf
end

Working with peaks

Check the peak list matches

Check that your peak list matches your spectrum.
Read the section in Check the peak list matches.

set DIRS=`cat fid_files.ls | sed 's/\/fid//g'`
sparky ${DIRS[1]}/test.ucsf

The final peak list is expected to be in:

/peak_lists/peaks_corr_final.list

And have been saved by SPARKY, so it is in this format SPARKY_list.

Check for peak movement

Your should check, that the peaks do not move at the different experiments. Try opening some random spectra, and overlay them in SPARKY.
Read the section in Check for peak movement.

sparky ${DIRS[1]}/test.ucsf ${DIRS[10]}/test.ucsf ${DIRS[25]}/test.ucsf ${DIRS[50]}/test.ucsf

Measuring peak heights

We will use the program NMRPipe seriesTab to measure the intensities.

seriesTab needs a input file, where the ppm values from a SPARKY list has been converted to spectral points.
The spectral points value depends on the spectral processing parameters.

Generate spectral point file

Create a file with spectral point information with script stPeakList.pl .

stPeakList.pl ${DIRS[1]}/test.ft2 ../peak_lists/peaks_corr_final.list > peaks_list.tab
cat peaks_list.tab

Make a file name of .ft2 fil

echo "test.ft2" > ft2_file.ls

Measure the height or sum in a spectral point box

mkdir peak_lists
 
foreach line ("`tail -n+2 exp_parameters.txt`")
  set argv=( $line )
  set DIRN=$1
  set I=$2
  set deltadof2=$3
  set dpwr2slock=$4
  set ncyc=$5
  set trim=$6
  set ss=$7
  set sfrq=$8
  echo $I
  set FNAME=${I}_${deltadof2}_${dpwr2slock}_${ncyc}
  cd $DIRN
  seriesTab -in ../peaks_list.tab -out ${FNAME}_max_standard.ser -list ../ft2_file.ls -max
  seriesTab -in ../peaks_list.tab -out ${FNAME}_max_dx1_dy1.ser -list ../ft2_file.ls -max -dx 1 -dy 1
  seriesTab -in ../peaks_list.tab -out ${FNAME}_sum_dx1_dy1.ser -list ../ft2_file.ls -sum -dx 1 -dy 1
  cp ${FNAME}_max_standard.ser ../peak_lists
  cd ..
end

Analyse in relax

Preparation

making a spin file from SPARKY list

relax does not yet has the possibility to read spins from a sparky file. See support request.

So we create one.

set ATOMS=`tail -n+4 peaks_list.tab | awk '{print $7}'`
set SCRIPT=relax_2_spins.py

foreach I (`seq 1 ${#ATOMS}`)
set ATOM=${ATOMS[$I]}; set SPIN=`echo $ATOM | sed -e "s/N-HN//g"`; set RESN=`echo $SPIN | sed -e "s/[0-9]*//g"`; set RESI=`echo $SPIN | sed -e "s/[A-Za-z]//g"`
echo $ATOM $SPIN $RESN $RESI
echo "spin.create(spin_name='N', spin_num=$I, res_name='$RESN', res_num=$RESI, mol_name=None)" >> $SCRIPT
end

cat $SCRIPT

Prepare directory for relax run

Then we make a directory ready for relax

mkdir ../relax
cp exp_parameters.txt ../relax
cp exp_parameters_sort.txt ../relax
cp -r peak_lists* ../relax
cp peaks_list.tab ../relax
cp relax_2_spins.py ../relax
cd ../relax

See unique parameters

tail -n +2 exp_parameters.txt | awk '{print $3}' | sort -k1,1n | uniq
tail -n +2 exp_parameters.txt | awk '{print $4}' | sort -k1,1n | uniq
tail -n +2 exp_parameters.txt | awk '{print $5}' | sort -k1,1n | uniq
tail -n +2 exp_parameters.txt | awk '{print $6}' | sort -k1,1n | uniq
tail -n +2 exp_parameters.txt | awk '{print $7}' | sort -k1,1n | uniq
tail -n +2 exp_parameters.txt | awk '{print $8}' | sort -k1,1n | uniq

Analyse rx

Setup rx data

rx_1_ini.py

# 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
script(file='relax_2_spins.py', dir=None)

# Set the spectra experimental properties/settings.
script(file='rx_3_spectra_settings.py', dir=None)

# 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_rx', force=True)

rx_3_spectra_settings.py

# Set settings for experiment
import os

spin_locks = [0.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0]
lock_powers = [35.0, 39.0, 41.0, 43.0, 46.0, 48.0]
ncycs = [0, 4, 10, 14, 20, 40]

# Load the experiments settings file.
expfile = open('exp_parameters_sort.txt','r')
expfileslines = expfile.readlines()
fpipe = open('pipe_names_rx.txt','w')

for spin_lock in spin_locks:
    for lock_power in lock_powers:
        for i in range(len(expfileslines)):
            line=expfileslines[i]
            if line[0] == "#":
                continue
            else:
                # DIRN I deltadof2 dpwr2slock ncyc trim ss sfrq
                DIRN = line.split()[0]
                I = int(line.split()[1])
                deltadof2 = float(line.split()[2])
                dpwr2slock = float(line.split()[3])
                ncyc = int(line.split()[4])
                trim = float(line.split()[5])
                ss = int(line.split()[6])
                set_sfrq = float(line.split()[7])

                # Calculate spin_lock time
                time_sl = 2*ncyc*trim

                # Define file name for peak list.
                FNAME = "%s_%s_%s_%s_max_standard.ser"%(I, int(deltadof2), int(dpwr2slock), ncyc)
                sp_id = "%s_%s_%s_%s"%(I, int(deltadof2), int(dpwr2slock), ncyc)

                if deltadof2 == spin_lock and dpwr2slock == lock_power and ncyc == ncycs[0]:
                    pipename = "%s_%s"%(int(deltadof2), int(dpwr2slock))
                    pipebundle = 'relax_fit'
                    pipe.copy(pipe_from='base pipe', pipe_to=pipename, bundle_to=pipebundle)
                    pipe.switch(pipe_name=pipename)
                    fpipe.write("%s %s"%(pipename, pipebundle)+"\n")

                #print spin_lock, deltadof2, lock_power, dpwr2slock
                if deltadof2 == spin_lock and dpwr2slock == lock_power:
                    # Load the peak intensities (first the backbone NH, then the tryptophan indole NH).
                    spectrum.read_intensities(file=FNAME, dir=os.path.join(os.getcwd(),"peak_lists"), spectrum_id=sp_id, int_method='height')

                    # Set the relaxation times.
                    relax_fit.relax_time(time=time_sl, spectrum_id=sp_id)

                    # Set the peak intensity errors, as defined as the baseplane RMSD.
                    spectrum.baseplane_rmsd(error=1.33e+03, spectrum_id=sp_id)
                     

expfile.close()
fpipe.close()

Run by

relax rx_1_ini.py -t log_rx_1_ini.log

analyse rx data

rx_4_run.py

import os
from auto_analyses.relax_fit import Relax_fit

# Set settings for run.
GRID_INC = 11; MC_NUM = 3

# Load the initial state setup
state.load(state='ini_setup_rx.bz2')

# Load the pipe names.
fpipe = open('pipe_names_rx.txt','r')
pipenames = []
for line in fpipe:
    pipenames.append([line.split()[0], line.split()[1]])
fpipe.close()

for pipename, pipebundle in pipenames:
    pipe.switch(pipe_name=pipename)
    results_directory = os.path.join("rx", pipename)

    Relax_fit(pipe_name=pipename, pipe_bundle=pipebundle, file_root='rx', results_dir=results_directory, grid_inc=GRID_INC, mc_sim_num=MC_NUM, view_plots=False)

Run by

relax rx_4_run.py -t log_rx_4_run.log

See also