Loading ...
Sorry, an error occurred while loading the content.

1D trace from 2D spectrum

Expand Messages
  • anne_rintala
    Hi, I need to take a 1D trace of a peak from an HSQC spectrum and save it as a table - intensities in one column and point number (or frequency) in the other
    Message 1 of 7 , Apr 26, 2005
    • 0 Attachment
      Hi,

      I need to take a 1D trace of a peak from an HSQC spectrum and save it as a table -
      intensities in one column and point number (or frequency) in the other column. Is this
      possible using nmrpipe?

      Thanks,
      Anne
    • Frank Delaglio
      Many Greetings, There are numerous ways this could be accomplished. For example, one could write a TCL script that would take a 2D HSQC and its peak table as
      Message 2 of 7 , Apr 27, 2005
      • 0 Attachment
        Many Greetings,

        There are numerous ways this could be accomplished.

        For example, one could write a TCL script that would take a
        2D HSQC and its peak table as input, and produce a series of
        text files for each peak.

        There are also two existing TCL scripts "readROI" (a stand-alone
        version of our TCL command to read an ND spectral region) and
        "pipe2txt.tcl" which produces multi-column output of position and
        intensity. Then the commands below would produce an output like:

        test.dat
        129.306 53803.13672
        129.281 43901.86328
        129.256 32160.73828
        129.231 19294.99414
        129.206 5399.38525
        129.180 -7123.78516
        129.155 -17644.40625
        129.130 -24499.25195
        129.105 -29355.74609
        etc ...

        I will send the two scripts as the next two messages ...

        Example:


        #
        # Reads the 1D 15N column at 6.149ppm +/- 0 points.
        # Assumes input data has axis names HN N

        readROI -ndim 1 -in ft/relax001.ft2 -x N -dy HN 6.149ppm 0 -out test.dat

        pipe2txt.tcl -index ppm test.dat




        On Tue, 26 Apr 2005, anne_rintala wrote:

        >
        >
        >
        > Hi,
        >
        > I need to take a 1D trace of a peak from an HSQC spectrum and save it as a table -
        > intensities in one column and point number (or frequency) in the other column. Is this
        > possible using nmrpipe?
        >
        > Thanks,
        > Anne
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
        >
      • Frank Delaglio
        #!/bin/sh # The next line restarts using nmrWish exec nmrWish $0 -notk -- $@ set auto_path [split $env(TCLPATH) :] $auto_path set ARGV [concat
        Message 3 of 7 , Apr 27, 2005
        • 0 Attachment
          #!/bin/sh
          # The next line restarts using nmrWish \
          exec nmrWish "$0" -notk -- "$@"

          set auto_path "[split $env(TCLPATH) :] $auto_path"
          set ARGV [concat $argv0 $argv]
          set ARGC [llength $ARGV]

          if {$ARGC < 4 || [flagLoc $ARGV -help]} \
          {
          puts stderr "Display NMRPipe Format Series as Text Data;"
          puts stderr " $argv0 fileName1 \[fileName2 ...\]"
          puts stderr "Options:"
          puts stderr " -index indexType \[Pts\] Point Index Used for Output."
          puts stderr "Notes:"
          puts stderr " 1. All data files in the series are assumed to have"
          puts stderr " the same sizes and spectral windows."
          puts stderr " 2. Point Index Keywords: Pts Hz PPM % None"
          exit 0
          }

          set mode pts

          getArgD $ARGV -index mode

          #
          #--------------------------------------------------------------------------

          set aSize [llength $argv]
          set zSize 0
          set iz 0

          for {set ia 0} {$ia < $aSize} {incr ia } \
          {
          set thisArg [lindex $argv $ia]

          if {![strcasecmp $thisArg "-notk"]} continue
          if {![strcasecmp $thisArg "--"]} continue

          if {![strcasecmp $thisArg "-index"]} \
          {
          incr ia
          continue
          }

          set inName $thisArg

          if {![file exists $inName]} \
          {
          puts stderr "Error Finding Input File $inName"
          exit 1
          }

          incr zSize
          }

          for {set ia 0} {$ia < $aSize} {incr ia } \
          {
          set thisArg [lindex $argv $ia]

          if {![strcasecmp $thisArg "-notk"]} continue
          if {![strcasecmp $thisArg "--"]} continue

          if {![strcasecmp $thisArg "-index"]} \
          {
          incr ia
          continue
          }

          set inName $thisArg
          incr iz

          set inUnit [sysOpen $inName r]
          set error [rdFDATAU $inUnit fdata]

          if {$error} {exit 1}

          set qState [getParmI $fdata FDQUADFLAG NULL_DIM]

          if {$qState == 0.0} \
          {
          set qSize 2
          } \
          else \
          {
          set qSize 1
          }

          set dimCount [getParmI $fdata FDDIMCOUNT NULL_DIM]
          set xSize [getParmI $fdata NDSIZE CUR_XDIM]
          set ySize [getParmI $fdata NDSIZE CUR_YDIM]

          if {$dimCount < 2} {set ySize 1}

          set n [expr $xSize*$ySize*$qSize]

          set rdata [sysMalloc $n float]

          sysRead $inUnit $rdata $n
          sysClose $inUnit

          puts stderr $inName

          set i 0

          for {set iy 1} {$iy <= $ySize} {incr iy} \
          {
          for {set ix 1} {$ix <= $xSize} {incr ix} \
          {
          if {$qSize == 2} \
          {
          set rVal [getPtrVal $rdata $i]
          set iVal [getPtrVal $rdata [expr $i + $xSize]]
          set valStr [format " % 14.5f % 14.5f" $rVal $iVal]
          } \
          else \
          {
          set rVal [getPtrVal $rdata $i]
          set valStr [format " % 14.5f" $rVal]
          }

          if {![strcasecmp $mode None]} \
          {
          set locStr ""
          } \
          elseif {![strcasecmp $mode pts]} \
          {
          if {$ySize > 1 && $zSize > 1} \
          {
          set locStr [format " %5d %5d %4d" $ix $iy $iz]
          } \
          elseif {$ySize == 1 && $zSize > 1} \
          {
          set locStr [format " %5d %4d" $ix $iz]
          } \
          elseif {$ySize > 1 && $zSize == 1} \
          {
          set locStr [format " %5d %5d" $ix $iy]
          } \
          else \
          {
          set locStr [format " %5d" $ix]
          }
          } \
          else \
          {
          set px 0.0
          set py 0.0
          set pz 0.0

          if {$dimCount >= 1} {set px [pnt2spec $fdata X_AXIS $ix $mode]}
          if {$dimCount >= 2} {set py [pnt2spec $fdata Y_AXIS $iy $mode]}
          if {$dimCount >= 3} {set pz [pnt2spec $fdata Z_AXIS $iz $mode]}

          switch -exact [string tolower $mode] \
          {
          % {set fmt "% 8.3f"}
          ppm {set fmt "% 8.3f"}
          hz {set fmt "% 10.3f"}
          default {set fmt "% e"}
          }

          if {$ySize > 1 && $zSize > 1} \
          {
          set locStr [format " $fmt $fmt $fmt" $px $py $pz]
          } \
          elseif {$ySize == 1 && $zSize > 1} \
          {
          set locStr [format " $fmt %4d" $px $iz]
          } \
          elseif {$ySize > 1 && $zSize == 1} \
          {
          set locStr [format " $fmt $fmt" $px $py]
          } \
          else \
          {
          set locStr [format " $fmt" $px]
          }
          }

          puts " $locStr $valStr"
          incr i
          }
          }

          sysFree $fdata
          sysFree $rdata
          }

          exit 0
        • Frank Delaglio
          #!/bin/sh # The next line restarts using nmrWish exec nmrWish $0 -notk -- $@ set auto_path [split $env(TCLPATH) :] $auto_path set ARGV [concat
          Message 4 of 7 , Apr 27, 2005
          • 0 Attachment
            #!/bin/sh
            # The next line restarts using nmrWish \
            exec nmrWish "$0" -notk -- "$@"

            set auto_path "[split $env(TCLPATH) :] $auto_path"

            set ARGV [concat $argv0 $argv]
            set ARGC [llength $ARGV]

            if {[flagLoc $ARGV -help]} \
            {
            readROI -help
            writeROI -help
            exit 1
            }

            set aList [lrange $argv 2 end]
            set n [llength $aList]

            set rdCmnd readROI
            set wrCmnd writeROI

            set inName None
            set outName None

            for {set i 0} {$i < $n} {incr i} \
            {
            set str [lindex $aList $i]

            switch -exact -- $str \
            {
            -in {
            incr i
            set inName [lindex $aList $i]

            append rdCmnd " -in $inName -roi 1"
            }

            -out {
            incr i
            set outName [lindex $aList $i]

            append wrCmnd " -out $outName -ov -roi 1"
            }

            default {append rdCmnd " $str"}
            }
            }

            set thisName [format $inName 1 1]

            if {![file exists $thisName]} \
            {
            puts stderr "Error Finding Input File for $inName"
            exit 1
            }

            puts stderr $rdCmnd
            puts stderr $wrCmnd

            catch "eval $rdCmnd"
            catch "eval $wrCmnd"

            exit
          • Frank Delaglio
            #!/bin/sh # The next line restarts using nmrWish exec nmrWish $0 -notk -- $@ set auto_path [split $env(TCLPATH) :] $auto_path set ARGV [concat
            Message 5 of 7 , Apr 27, 2005
            • 0 Attachment
              #!/bin/sh
              # The next line restarts using nmrWish \
              exec nmrWish "$0" -notk -- "$@"

              set auto_path "[split $env(TCLPATH) :] $auto_path"
              set ARGV [concat $argv0 $argv]
              set ARGC [llength $ARGV]

              if {[flagLoc $ARGV -help]} \
              {
              puts stderr "Extract a Column from an NMRPipe format table:"
              puts stderr " -in tabName \[test.tab\] Input Table."
              puts stderr " -var varName \[INDEX\] Variable to Extract."
              exit 1
              }

              set inName test.tab
              set varName INDEX

              getArgD $ARGV -in inName
              getArgD $ARGV -var varName

              if {![file exists $inName]} \
              {
              puts stderr "Error Finding Input File $inName"
              exit 1
              }

              set inTab [gdbRead table -in $inName]
              set entry [gdbFirst $inTab]

              while {$entry} \
              {
              puts [gdbGet $entry $varName]
              set entry [gdbNext $entry]
              }

              exit 0
            • Frank Delaglio
              Ok, putting it all together: I created a new script, which extracts a column from an NMRPipe format table (e.g. an nmrDraw peak table). We can use this to
              Message 6 of 7 , Apr 27, 2005
              • 0 Attachment
                Ok, putting it all together:

                I created a new script, which extracts a column from an NMRPipe format
                table (e.g. an nmrDraw peak table). We can use this to generate a list
                of PPM positions, then use the other scripts to extract and save
                the columns.

                #!/bin/csh

                #
                # Reads the 1D 15N columns at HN ppm locations given in a peak table.
                # Assumes input data has axis names HN N and is not transposed.
                # Output data is numbered according to peak ID.

                if (!(-e txt)) then
                mkdir txt
                endif

                set pList = (`getTabCol.tcl -in relax.tab -var X_PPM`)
                set idList = (`getTabCol.tcl -in relax.tab -var INDEX`)

                set i = 0

                foreach p ($pList)
                @ i++

                set id = $idList[$i]
                set outName = (`printf txt/test%03d.txt $id`)

                readROI -ndim 1 -in ft/relax001.ft2 -x N -dy HN ${p}ppm 0 -out test.dat
                pipe2txt.tcl -index ppm test.dat > $outName
                end


                On Tue, 26 Apr 2005, anne_rintala wrote:

                >
                >
                >
                > Hi,
                >
                > I need to take a 1D trace of a peak from an HSQC spectrum and save it as a table -
                > intensities in one column and point number (or frequency) in the other column. Is this
                > possible using nmrpipe?
                >
                > Thanks,
                > Anne
                >
                >
                >
                >
                >
                >
                >
                >
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
                >
                >
                >
                >
                >
              • anne_rintala
                Thank you!!!! Scripts work perfectly! Anne ... this
                Message 7 of 7 , Apr 29, 2005
                • 0 Attachment
                  Thank you!!!! Scripts work perfectly!

                  Anne


                  --- In nmrpipe@yahoogroups.com, Frank Delaglio <delaglio@s...> wrote:
                  >
                  > Ok, putting it all together:
                  >
                  > I created a new script, which extracts a column from an NMRPipe format
                  > table (e.g. an nmrDraw peak table). We can use this to generate a list
                  > of PPM positions, then use the other scripts to extract and save
                  > the columns.
                  >
                  > #!/bin/csh
                  >
                  > #
                  > # Reads the 1D 15N columns at HN ppm locations given in a peak table.
                  > # Assumes input data has axis names HN N and is not transposed.
                  > # Output data is numbered according to peak ID.
                  >
                  > if (!(-e txt)) then
                  > mkdir txt
                  > endif
                  >
                  > set pList = (`getTabCol.tcl -in relax.tab -var X_PPM`)
                  > set idList = (`getTabCol.tcl -in relax.tab -var INDEX`)
                  >
                  > set i = 0
                  >
                  > foreach p ($pList)
                  > @ i++
                  >
                  > set id = $idList[$i]
                  > set outName = (`printf txt/test%03d.txt $id`)
                  >
                  > readROI -ndim 1 -in ft/relax001.ft2 -x N -dy HN ${p}ppm 0 -out test.dat
                  > pipe2txt.tcl -index ppm test.dat > $outName
                  > end
                  >
                  >
                  > On Tue, 26 Apr 2005, anne_rintala wrote:
                  >
                  > >
                  > >
                  > >
                  > > Hi,
                  > >
                  > > I need to take a 1D trace of a peak from an HSQC spectrum and save it as a table -
                  > > intensities in one column and point number (or frequency) in the other column. Is
                  this
                  > > possible using nmrpipe?
                  > >
                  > > Thanks,
                  > > Anne
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > > Yahoo! Groups Links
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                Your message has been successfully submitted and would be delivered to recipients shortly.