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

From relax wiki
Jump to navigation Jump to search

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}'

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 file with paths to .ft2 files

Then we make a file list of filepaths to .ft2 files.

set DIRS=`cat fid_files.ls | sed 's/\/fid//g'`

foreach DIR ($DIRS)
echo $DIR/test.ft2 >> ft2_files.ls
end
cat ft2_files.ls

Measure the height or sum in a spectral point box

seriesTab -in peaks_list.tab -out peaks_list_max_standard.ser -list ft2_files.ls -max
seriesTab -in peaks_list.tab -out peaks_list_max_dx1_dy1.ser -list ft2_files.ls -max -dx 1 -dy 1

OR make the sum in a box:

seriesTab -in peaks_list.tab -out peaks_list_sum_dx1_dy1.ser -list ft2_files.ls -sum -dx 1 -dy 1

Analyse in relax

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 peaks_list* ../relax
cp relax_2_spins.py ../relax
cd ../relax

relax script for setting experiment settings to spectra

Add the following python relax script file to the relax directory.

This can be modified as wanted.
This is to save "time" on the tedious work on setting the experimental conditions for each spectra.

relax_3_spectra_settings.py

# Loop over the spectra settings.
ncycfile=open('ncyc.txt','r')

# Make empty ncyclist
ncyclist = []

i = 0
for line in ncycfile:
    ncyc = line.split()[0]
    time_T2 = float(line.split()[1])
    vcpmg = line.split()[2]
    set_sfrq = float(line.split()[3])
    rmsd_err = float(line.split()[4])

    print ncyc, time_T2, vcpmg

    # Test if spectrum is a reference
    if float(vcpmg) == 0.0:
        vcpmg = None
    else:
        vcpmg = round(float(vcpmg),3)

    # Add ncyc to list
    ncyclist.append(int(ncyc))

    # Set the current spectrum id
    current_id = "Z_A%s"%(i)

    # Set the current experiment type.
    relax_disp.exp_type(spectrum_id=current_id, exp_type='cpmg fixed')

    # Set the peak intensity errors, as defined as the baseplane RMSD.
    spectrum.baseplane_rmsd(error=rmsd_err, spectrum_id=current_id)

    # Set the NMR field strength of the spectrum.
    spectrometer.frequency(id=current_id, frq=set_sfrq, units='MHz')

    # Relaxation dispersion CPMG constant time delay T (in s).
    relax_disp.relax_time(spectrum_id=current_id, time=time_T2)

    # Set the relaxation dispersion CPMG frequencies.
    relax_disp.cpmg_frq(spectrum_id=current_id, cpmg_frq=vcpmg)

    i += 1

# Specify the duplicated spectra.
#spectrum.replicated(spectrum_ids=['Z_A1', 'Z_A15'])

# The automatic way
dublicates = map(lambda val: (val, [i for i in xrange(len(ncyclist)) if ncyclist[i] == val]), ncyclist)
for dub in dublicates:
    ncyc, list_index_occur = dub
    if len(list_index_occur) > 1:
        id_list = []
        for list_index in list_index_occur:
            id_list.append('Z_A%s'%list_index)
        # We don't setup replications, since we have RMSD values from background noise
        print id_list
        #spectrum.replicated(spectrum_ids=id_list)

# Delete replicate spectrum
spectrum.delete('Z_A15')

See also