#!/bin/sh # The next line restarts using nmrWish \ exec nmrWish "$0" -- "$@" set auto_path "[split $env(TCLPATH) :] $auto_path" set ARGV [concat $argv0 $argv] set ARGC [llength $ARGV] set assName hsqc_ass.tab set isoName iso.tab set othName align.tab set outName RDC_nesg.tab gdbInit # Runs through ISO and OTH files to find an ASS # match with assName base table and ouptuts the value from the specified column. proc searchAss { ass rdc column } { global isoName othName if {$rdc == "iso"} { set Tab [gdbRead table -in $isoName] } if {$rdc == "oth"} { set Tab [gdbRead table -in $othName] } set rdcASS [gdbSelect -new -from $Tab -cond 1] set rdcASStab [gdbFirst $rdcASS] while {$rdcASStab} { set compass [gdbGet $rdcASStab ASS] set vals [gdbGet $rdcASStab $column] if {$ass == $compass} { return $vals } set rdcASStab [gdbNext $rdcASStab] } } set inTab [gdbRead table -in $assName -verb] set rdcTab [gdbSelect -new -from $inTab -cond 1 -verb] # Create RDC table entry set rdcEntry [gdbFirst $rdcTab] gdbCreate variable -parent $rdcTab -name RDC -varType text -varFmt %10s gdbCreate variable -parent $rdcTab -name RDC_Error -varType text -varFmt %10s gdbCreate variable -parent $rdcTab -name R2 -varType text -varFmt %10s gdbCreate variable -parent $rdcTab -name R2_Error -varType text -varFmt %10s # Cycle through hsqc_ass.tab values while {$rdcEntry} { set ass [gdbGet $rdcEntry ASS] set iso [searchAss $ass iso J_Hz] set oth [searchAss $ass oth J_Hz] set isoerr [searchAss $ass iso J_Error] set otherr [searchAss $ass oth J_Error] set isor2 [searchAss $ass iso R2] set isor2err [searchAss $ass iso R2_Error] if {$iso == ""} { set iso 0 } if {$oth == ""} { set oth 0 } if {$isoerr == ""} { set isoerr 0 } if {$otherr == ""} { set otherr 0 } #This accounts for the larger aligned J value indicating a negative D value for the negative N-H coupling, modify for nuclei with both positive or both negative gyromagnetic ratios set calc [expr ( -$oth + $iso )] set calcerr [expr ( $otherr + $isoerr )] if {$iso != 0 && $oth != 0} { gdbSet $rdcEntry RDC $calc gdbSet $rdcEntry RDC_Error $calcerr gdbSet $rdcEntry R2 $isor2 gdbSet $rdcEntry R2_Error $isor2err } else { set calc NO_RDC set calcerr NO_RDC set isor2 NO_VALUE set isor2err NO_VALUE gdbSet $rdcEntry RDC $calc gdbSet $rdcEntry RDC_Error $calcerr gdbSet $rdcEntry R2 $isor2 gdbSet $rdcEntry R2_Error $isor2err } set rdcEntry [gdbNext $rdcEntry] } gdbWrite $rdcTab $outName set in [open $outName] set out [open temptemptemp.txt w] set zk 0 while {![eof $in]} { gets $in line if {$zk > 0} { if {$line == "VARS ASS N HN RDC RDC_Error R2 R2_Error"} { set line "ASS\t\tN\tHN\tRDC\tRDC_Error\tR2\tR2_Error" } if {$line == "FORMAT %5s %10.3f %10.3f %10s %10s %10s %10s"} { set line "" } # if {$line == "VARS ASS N HN RDC RDC_Error"} { # set line "ASS\t\tN\tHN\tRDC\tRDC_Error" # } # if {$line == "FORMAT %5s %10.3f %10.3f %10s %10s"} { # set line "" # } #puts "[string trimleft $line]" if {[lindex $line 0] != "Null"} { puts $out [string trimleft $line] #puts $out $line } } incr zk } close $in close $out file rename -force temptemptemp.txt $outName exit