Tutorial for Relaxation dispersion analysis cpmg fixed time recorded on varian as fid interleaved scripts

From relax wiki
Jump to: navigation, search

Get the process helper scripts

As of August 2013, one can download the scripts easily, by following this.

cd scripts
# Change shell
tcsh
# Set array of scripts to download
set SCRIPTS="CPMG_1_sort_pseudo3D_initialize_files.sh CPMG_2_convert_and_process.sh CPMG_3_fft_all.sh convert_all.com fft_all.com sparky_add.sh stPeakList.pl NMRPipe_to_Sparky.sh"
 
# Download scripts
foreach SCRIPT ( ${SCRIPTS} )
curl https://raw.github.com/nmr-relax/relax_scripts/master/shell_scripts/$SCRIPT -o $SCRIPT
end
 
# Make them executable
chmod +x *.sh *.com *.pl
 
# Add scripts to PATH
setenv PATH ${PWD}:${PATH}

If the scripts are not possible to download, they are here for reference.

Helper scripts for Spectral processing

convert_all.com

#!/bin/csh -f
 
set x = 0
 
while ( $x <= 35 )
    mv $x.fid $x.fid.temp
 	mkdir $x.fid
	cd $x.fid
	mv ../$x.fid.temp ./fid
	cp ../fid.com .
	./fid.com
	cd ..
	@ x = $x + 1
end

fft_all.com

#! /bin/csh -f
 
set x = 0
 
while ( $x <= 35 )
	cd $x.fid
	cp ../fft.com .
	./fft.com
	cd ..
	@ x = $x + 1
end

Scripts used in Tutorial

CPMG_1_sort_pseudo3D_initialize_files.sh

#!/bin/bash -e
 
if [ -f fid ]; then
    echo "File exist: fid"
    IN=fid
else
    echo "FID file not found in current folder"
    exit $?
fi
 
if [ -f procpar ]; then
PLANE=`awk '/^ncyc /{f=1;next}f{print $1;exit}' procpar`
echo "Number of ncyc/planes in procpar: $PLANE"
MODEPAR=`awk '/^array /{f=1;next}f{print $2;exit}' procpar`
IFS=',' read -a MODEARR <<< "$MODEPAR"
echo "Modearray is: $MODEARR"
if [ ${MODEARR[0]} == '"phase' ]; then
MODE=1
fi
if [ ${MODEARR[0]} == '"ncyc' ]; then
MODE=0
fi
echo "Array is recorded: $MODEPAR, so mode should be: $MODE"
NI=`awk '/^ni /{f=1;next}f{print $2;exit}' procpar`
echo "Found in the file procpar that ni=$NI"
NP=`awk '/^np /{f=1;next}f{print $2;exit}' procpar`
echo "Found in the file procpar that np=$NP"
fi
 
echo 
echo "I suggest following sort_psedo3D command, which I will do for you"
echo "####################"
echo "sort_pseudo3D -in $IN -plane $PLANE -mode $MODE -ni $NI -np $NP"
echo "####################"
sort_pseudo3D -in $IN -plane $PLANE -mode $MODE -ni $NI -np $NP
echo 
echo "I moved your 'fid' to 'fid_original_interleaved"
echo "And made a link from 0.fid to fid, to use in varian"
echo 
echo "Now just click, 'read parameters', check 'Rance-Kay'"
echo "Remember to set Y-'Observe Freq MHz' to N15"
echo "Click 'Save script' to make 'fid.com' file, and 'Quit', and run the next CPMG script"
 
mv -n fid fid_original_interleaved
ln -s 0.fid fid
varian
rm fid
ln -s fid_original_interleaved fid

CPMG_2_convert_and_process.sh

#!/bin/bash
 
PLANE="ERR"
if [ -f procpar ]; then
PLANE=`awk '/^ncyc /{f=1;next}f{print $1;exit}' procpar`
PLANE=$(($PLANE -1))
#echo $PLANE
fi
 
if [ -f fid.com ]; then
  if grep -Fq "sleep" fid.com; then
  echo "sleep found in fid.com and is removed"
  sed -i '/^sleep/d' fid.com
  fi
  if grep -Fq "var2pipe -in ./0.fid" fid.com; then
  echo "0.fid found in fid.com and changed to 'fid'"
  sed -i "s/0.fid/fid/g" fid.com
  fi
fi
 
if [ ! -f convert_all.com ]; then
echo "'convert_all.com' does not exist, I will copy it over, alter it, and run it"
cp ./../scripts/convert_all.com $PWD
  if [ $PLANE != "ERR" ]; then
  sed -i "s/x <= 35/x <= $PLANE/g" convert_all.com
  fi
fi
 
echo 
echo "I suggest run convert_all.com, which I will do for you"
echo "####################"
echo "csh convert_all.com"
echo "####################"
tcsh convert_all.com
echo "Now we need to transform the spectra."
echo "Process one of the files normally and copy the processing script to the experiment folder."
echo "[m]->Right-Click Process 2D->Basic 2D"
echo "Save->Execute->Done; then; RClick File->Select File->test.ft2->Read/draw->Done"
echo "If your spectra look reversed (i.e. if your peaks do not seem to match your reference spectrum) it might be solved by changing to"
echo "[m] '| nmrPipe -fn FT -neg \' to the script to the third lowest line."
echo "Save->Execute->Done. Then push [r] to refresh."
echo "Press [h], and find P0 and P1, and push [m], change parameters and update script"
echo "The changes to '| nmrPipe  -fn PS xxx \' should be the FIRST line (The proton dimension) with PS"
echo "save/execute, push [r] (read) and the [e] (erase settings) to see result in NMRdraw"
echo "And then run the next CPMG script"
cd 0.fid
nmrDraw
cp nmrproc.com ../fft.com
cd ..

CPMG_3_fft_all.sh

#!/bin/bash -e
 
PLANE="ERR"
if [ -f procpar ]; then
PLANE=`awk '/^ncyc /{f=1;next}f{print $1;exit}' procpar`
PLANE=$(($PLANE -1))
#echo $PLANE
fi
 
if [ -f fft.com ]; then
  echo "fft.com in your folder"
else
echo "no fft.com in your folder"
  if [ -f 0.fid/fft.com ]; then
  echo "fft.com in your 0 folder, and copy it to here"
  cp 0.fid/fft.com .
  elif [ -f 0.fid/nmrproc.com ]; then
  echo "nmrproc.com in your 0 folder, and copy it to here as fft.com"
  cp 0.fid/nmrproc.com ./fft.com
  else
  exit
  fi
fi
 
if [ ! -f fft_all.com ]; then
echo "'fft_all.com' does not exist, I will copy it over, alter it, and run it"
cp ./../scripts/fft_all.com $PWD
  if [ $PLANE != "ERR" ]; then
  sed -i "s/x <= 35/x <= $PLANE/g" fft_all.com
  sed -i '/^$/d' fft_all.com
  fi
fi
 
echo 
echo "I suggest run fft_all.com, which I will do for you"
echo "####################"
echo "csh fft_all.com"
echo "####################"
csh fft_all.com
echo
echo "Now get a peak list"
echo "In CCPNMR Analysis, you open one of you spectra from the relaxation series."
echo "Assign all the peaks you want to analyse. Usually, this is done by copying a peaklist from a HSQC experiment"
echo "and adjusting the crosses so they lie exactly on top of the peaks."
echo "It is important to remove all unassigned peaks from the peak list."
echo "If your spectrum is folded, pick the peaks at their position in the folded spectrum."
echo "Export this peak list in to you data folder as Sparky peak list using FormatConverter. (Other>FormatConverter and export>Sparky)"
echo "In analysis: Other->Format Converter->Export->Sparky->Peaks export menu->Select peak list->Select export file->"
echo "Save it for example as: 'peaks_20121005.sparky' in your experiment folder"

Script to convert into SPARKY and add to SPARKY lists

NMRPipe_to_Sparky.sh

#!/bin/tcsh -e
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

sparky_add.sh

#!/bin/tcsh -e
 
if ($#argv < 4) then
    echo "Change value of column"
    echo "Usage: $0 file" "'"'$X'"'" "'"'0.1'"' peaks_out.list "
    echo "sparky_add.sh sparky.list" "'"'$2'"'" "-0.132 peaks_out.list"
    goto done
endif
 
set PEAKS=$1
set PEAKSTEMP=${PEAKS}.temp
set COL=$2
set COLOFFSET=$3
set PEAKSOUT=$4
set LINE='$0'
 
awk '$2 ~ /^[0-9]/{print $0}' $PEAKS > $PEAKSTEMP
awk "{ ${COL} = ${COL} + $COLOFFSET; print $LINE } " $PEAKSTEMP > $PEAKSOUT
rm $PEAKSTEMP
 
done: ; exit 0

Script to input for NMRPipe SeriesTab

stPeakList.pl

EDIT 2013108: The script was modified for correct calculation of X_AXIS Y_AXIS for folded peaks. And writing of X1 X3 Y1 Y3 to be able to read peak list in nmrDraw.

#! /usr/bin/perl
 
# Creates a peak list for seriesTab given a 
# nmrPipe spektrum and a Sparky peak list
#
# usage: stPeakList [pipe spectrum] [Sparky peak list]
#
# Kaare Teilum 061025
# Modified 131008 by Troels E. Linnet
 
$pipeFile = $ARGV[0];
$sparkyList = $ARGV[1];
 
open HDR, "showhdr $pipeFile |" or die "can't run: showhdr $pipeFile";
while (<HDR>){
        if (/OBS MHz/){
                /([0-9]+\.[0-9]+)\s+([0-9]+\.[0-9]+)/;
                $frqX=$1;
                $frqY=$2;
        };
        if (/DATA SIZE/){
                /([0-9]+)\s+([0-9]+)/;
                $sizeX=$1;
                $sizeY=$2;
        };
        if (/ORIG Hz/){
                /(-*[0-9]+\.[0-9]+)\s+(-*[0-9]+\.[0-9]+)/;
                $origX=$1;
                $origY=$2;
        };
        if (/SW Hz/){
                /([0-9]+\.[0-9]+)\s+([0-9]+\.[0-9]+)/;
                $swX=$1;
                $swY=$2;
        };
};
close(HDR);
 
$stepX=$swX/$frqX/$sizeX;
$highX=($origX+$swX)/$frqX;
$highX2SW=($origX+2*$swX)/$frqX;
$stepY=$swY/$frqY/$sizeY;
$highY=($origY+$swY)/$frqY;
$highY2SW=($origY+2*$swY)/$frqY;
$i=1;
print "VARS   INDEX X_AXIS Y_AXIS X_PPM Y_PPM VOL ASS X1 X3 Y1 Y3\n";
print "FORMAT %5d %9.3f %9.3f %8.3f %8.3f %+e %s %4d %4d %4d %4d\n\n";
 
open IN, "$sparkyList" or die "Cannot open $sparkyList for read";
        while (<IN>){
                @process = split (/\s+/, $_);
                if ($process[0] eq ""){splice (@process, 0, 1)};
                if ($process[0] ne "Assignment" && $process[0] ne ""){
                        $ptsX=($highX-$process[2])/$stepX;
                        if ($ptsX < 0){
                        $ptsX=($highX2SW-$process[2])/$stepX;
                        }
                        $ptsX_X1=$ptsX-1;
                        $ptsX_X3=$ptsX+1;
                        $ptsY=($highY-$process[1])/$stepY;
                        if ($ptsY < 0){
                        $ptsY=($highY2SW-$process[1])/$stepY;
                        }
                        $ptsY_Y1=$ptsY-1;
                        $ptsY_Y3=$ptsY+1;
                        printf "%5d %9.3f %9.3f %8.3f %8.3f %+e %s %4.0f %4.0f %4.0f %4.0f\n",$i,$ptsX,$ptsY,$process[2],$process[1],700000,$process[0],$ptsX_X1,$ptsX_X3,$ptsY_Y1,$ptsY_Y3;
                        $i++;
                };
        };
close (IN);


See also