JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for CCPNMR Archives


CCPNMR Archives

CCPNMR Archives


CCPNMR@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

CCPNMR Home

CCPNMR Home

CCPNMR  September 2009

CCPNMR September 2009

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Analysis and RDC's

From:

Ben Goult <[log in to unmask]>

Reply-To:

CcpNmr software mailing list <[log in to unmask]>

Date:

Tue, 29 Sep 2009 15:11:08 +0100

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (13 lines) , RDCcalculator_v2b.py.txt (751 lines)

Hi 

I modified Graeme Balls macro so I could get it to would work in v2. 

I attach it here. 

Cheers

Ben





from Tkinter import * from tkMessageBox import * from ScrolledText import ScrolledText from tkFileDialog import asksaveasfilename import math from memops.gui.Frame import Frame from memops.gui.Label import Label from memops.gui.ScrolledMatrix import ScrolledMatrix from ccp.api.nmr import Nmr from ccpnmr.analysis.core.ExperimentBasic import getSpectra from ccpnmr.analysis.core.Util import getSpectrumActivePeakList from ccpnmr.analysis.core.PeakBasic import getPeakDimPpm class InputError: pass class MyError: pass def RDCcalculator(argServer=None):      assert argServer   class calculator(Frame):     def __init__(self, root, spectra):       Frame.__init__(self, root)       self.root=root       self.master.title("RDC calculator")       self._main()       self.spectra=spectra        def _main(self):       num = 1 # row number for grid       self.vars=[] # self.vars stores sepctrum selection       self.results=[] # empty self.results       self.restraints=[] # empty self.restraints       self.atms=[] # empty restraint atom names       # 4 spectra (IPAP) or 2 spectra (doublet) must be selected - see Help       Label(self.root, text = ' Spectrum Name').grid(row=0, column=0, columnspan=2, sticky=W)       Label(self.root, text = ' J(+)').grid(row=0, column=2, sticky=W)       Label(self.root, text = ' J(-)').grid(row=0, column=3, sticky=W)       Label(self.root, text = ' JD(+)').grid(row=0, column=4, sticky=W)       Label(self.root, text = ' JD(-)').grid(row=0, column=5, sticky=W)       # creates a row for each spectrum - TBD: display only RDC spectra       for spectrum in spectra:         spectrumname = spectrum.name         Label(self.root, text=spectrumname).grid(row=num, column=0, columnspan=2, sticky=W)         var=IntVar()         Checkbutton(root, text=None, variable=var).grid(row=num, column=2, sticky=NSEW)         self.vars.append(var)         var=IntVar()         Checkbutton(root, text=None, variable=var).grid(row=num, column=3, sticky=NSEW)         self.vars.append(var)         var=IntVar()         Checkbutton(root, text=None, variable=var).grid(row=num, column=4, sticky=NSEW)         self.vars.append(var)         var=IntVar()         Checkbutton(root, text=None, variable=var).grid(row=num, column=5, sticky=NSEW)         self.vars.append(var)         var=IntVar()         num = num + 1       Label(self.root, text = '').grid(row=num, column=0, sticky=NSEW)       num = num + 1       # ask user to specify experiment type (Radiobutton exptVar - stored in self.exptType)       # choices: 1 = IPAP, 2 = doublet       Label(self.root, text = ' Experiment Type:').grid(row=num, column=0, columnspan=5, sticky=W)       num = num + 1       exptVar = IntVar()       Label(self.root, text = ' IPAP').grid(row=num, column=0, columnspan=2, sticky=W)       exptRad = Radiobutton(root, variable=exptVar, value=1).grid(row=num, column=2, sticky=W)       num = num + 1       Label(self.root, text = ' doublet').grid(row=num, column=0, columnspan=2, sticky=W)       exptRad = Radiobutton(root, variable=exptVar, value=2).grid(row=num, column=2, sticky=W)       num = num + 1       self.exptType=exptVar       Label(self.root, text = '').grid(row=num, column=0, sticky=NSEW)       num = num + 1       # ask user to specify nuclei for which J or J+D is being measured       # NB - not necessarily the same as the nuclei represented by the axes!       Label(self.root, text = ' Coupling Type: Atom Name Residue').grid(row=num, column=0, columnspan=5, sticky=W)       num = num + 1       atm1 = 'HN'       atm2 = 'N'       resid1 = '0'       resid2 = '0'       Label(self.root, text = ' Atom 1').grid(row=num, column=0, columnspan=2, sticky=W)       ent=Entry(root)       ent.config(bg='white', width=5)       ent.insert(0, atm1)       ent.grid(row=num, column=2)       self.coupAtm1=ent       ent=Entry(root)       ent.config(bg='white', width=5)       ent.insert(0, resid1)       ent.grid(row=num, column=4)       self.coupResid1=ent       num = num + 1       Label(self.root, text = ' Atom 2').grid(row=num, column=0, columnspan=2, sticky=W)       ent=Entry(root)       ent.config(bg='white', width=5)       ent.insert(0, atm2)       ent.grid(row=num, column=2)       self.coupAtm2=ent       ent=Entry(root)       ent.config(bg='white', width=5)       ent.insert(0, resid2)       ent.grid(row=num, column=4)       self.coupResid2=ent       num = num + 1       Label(self.root, text = '').grid(row=num, column=0, sticky=NSEW)       num = num + 1       # allow user to scale couplings and supply error estimates - see Help       scaleF='1.0'       # get scaling factor that includes gyromagnetic ratio / bond length and, potentially, other scaling       Label(self.root, text = 'Scaling Factor:').grid(row=num, column=0, columnspan=2, sticky=W)       ent=Entry(root)       ent.config(bg='white', width=5)       ent.insert(0, scaleF)       ent.grid(row=num, column=2)       self.scaleF=ent       num = num + 1       Label(self.root, text = '').grid(row=num, column=0, sticky=NSEW)       num = num + 1       # get error estimate for each spectrum (or for IPAP, each pair of spectra)       JErr='1.0'       JDErr='1.0'       Label(self.root, text = ' Error estimates J JD').grid(row=num, column=0, columnspan=5, sticky=W)       num = num + 1       Label(self.root, text = 'Error Estimate (Hz): ').grid(row=num, column=0, columnspan=2, sticky=W)       ent=Entry(root)       ent.config(bg='white', width=5)       ent.insert(0, JErr)       ent.grid(row=num, column=2)       self.JErr=ent       ent=Entry(root)       ent.config(bg='white', width=5)       ent.insert(0, JDErr)       ent.grid(row=num, column=4)       self.JDErr=ent       num = num + 1       Label(self.root, text = '').grid(row=num, column=0, sticky=NSEW)       num = num + 1       # ask user to specify whether JorJD, or D to be calculated (Radiobutton calcVar - stored in self.calcType)       # choices: 1 = D, 2 = (J or J+D)       Label(self.root, text = ' Calculate what?').grid(row=num, column=0, columnspan=5, sticky=W)       num = num + 1       calcVar = IntVar()       Label(self.root, text = ' D').grid(row=num, column=0, columnspan=2, sticky=W)       calcRad = Radiobutton(root, variable=calcVar, value=1).grid(row=num, column=2, sticky=W)       num = num + 1       Label(self.root, text = ' J or J+D').grid(row=num, column=0, columnspan=2, sticky=W)       calcRad = Radiobutton(root, variable=calcVar, value=2).grid(row=num, column=2, sticky=W)       num = num + 1       self.calcType=calcVar       Label(self.root, text = '').grid(row=num, column=0, sticky=NSEW)       num = num + 1       Button(root, text='Next', command=self._onNext).grid(row=num, column=0)       Button(root, text='Close', command=root.destroy).grid(row=num, column=1)       Button(root, text='Help', command=self._onHelp).grid(row=num, column=2)     def _onNext(self):       # get selected spectra and calc type       selection = []       for var in self.vars:         selection.append(var.get())       exptType=self.exptType.get()       calcType=self.calcType.get()       # run through the selected spectra and store names       ctr = 0       self.spectrumJplus = None       self.spectrumJminus = None       self.spectrumJDplus = None       self.spectrumJDminus = None       for spectrum in self.spectra:         spectrumname = spectrum.name         if((selection[ctr] == 1)or(selection[ctr+1] == 1)or(selection[ctr+2] == 1)or(selection[ctr+3] == 1)):           if(selection[ctr] == 1):             self.spectrumJplus = spectrum           elif(selection[ctr+1] == 1):             self.spectrumJminus = spectrum           elif(selection[ctr+2] == 1):             self.spectrumJDplus = spectrum           elif(selection[ctr+3] == 1):             self.spectrumJDminus = spectrum         ctr=ctr+4       # collect remaining user input from main and store in 'self.atms'       coupAtm1=self.coupAtm1.get()       coupAtm2=self.coupAtm2.get()       coupResid1=int(self.coupResid1.get())       coupResid2=int(self.coupResid2.get())       self.atms = [ coupAtm1, coupResid1, coupAtm2, coupResid2 ]       # check the input makes some sense at least       if not ( (self.spectrumJplus and self.spectrumJminus and self.spectrumJDplus and self.spectrumJDminus and exptType==1 and calcType==1) or \         ( (self.spectrumJplus or self.spectrumJminus) and (self.spectrumJDplus or self.spectrumJDminus) and exptType==2 and calcType==1) or \         ( ( (self.spectrumJplus and self.spectrumJminus) or (self.spectrumJDplus and self.spectrumJDminus) ) and exptType==1 and calcType==2) or \         ( (self.spectrumJplus or self.spectrumJminus or self.spectrumJDplus or self.spectrumJDminus) and exptType==2 and calcType==2) ):           print '\n RDCcalculator user input error - please read Help!\n'           raise InputError       # ask user to choose frequency axis which encodes RDC       # NB - uses spectrumJplus or spectrumJminus,       # i.e. assumes all experiments the same       win=Toplevel()       win.title("Select Axis")       axisChoice = Frame(win)       axisChoice.pack()       num = 0       axes = []       self.aXvar = []       spectrum = None       if(self.spectrumJplus):         spectrum = self.spectrumJplus       elif(self.spectrumJminus):         spectrum = self.spectrumJminus       elif(self.spectrumJDplus):         spectrum = self.spectrumJDplus       elif(self.spectrumJDminus):         spectrum = self.spectrumJDminus       for dataDim in spectrum.dataDims:         expDimRef = dataDim.expDim.findFirstExpDimRef()         isotopeCode = expDimRef.isotopeCodes[0]         sf = expDimRef.sf         axes.append( (expDimRef.expDim.dim, isotopeCode, sf) )       self.axes = axes       for axis in axes:         Label(axisChoice, text=axis).grid(row=num, column=0, columnspan=2, sticky=W)         aXvar=IntVar()         Checkbutton(axisChoice, text=None, variable=aXvar).grid(row=num, column=2, sticky=NSEW)         self.aXvar.append(aXvar)         num += 1       optButtons=Frame(win)       optButtons.pack()       Button(optButtons, text='Go', command=self._onGo).grid(row=num, column=0)       Button(optButtons, text='Close', command=win.destroy).grid(row=num, column=1)       Button(optButtons, text='Help', command=self._onHelp).grid(row=num, column=2)                def _onGo(self):       # which axis was selected ? (to get spectrometer freq for calc)       ctr=0       aXselect = []       self.freq = None       self.dim = None       for var in self.aXvar:         aXselect.append(var.get())       for axis in self.axes:         if(aXselect[ctr]==1):           if(self.freq==None and self.dim==None):             self.freq = axis[2]             self.dim = axis[0]           else:             raise InputError         ctr = ctr+1       exptType=self.exptType.get()       calcType=self.calcType.get()       self.results = {}       # check calcType (D=1 or JorJD=2) and exptType (IPAP=1 or doublet=2) and run appropriate calc       if(calcType==1 and exptType==1):         self.results = self._calcDIPAP(self.spectrumJplus,self.spectrumJminus,self.spectrumJDplus,self.spectrumJDminus)         self._displayResults('D')       elif(calcType==1 and exptType==2):         if(self.spectrumJplus and self.spectrumJDplus):           self.results = self._calcDdoub(self.spectrumJplus,self.spectrumJDplus,'+','+')           self._displayResults('D')         elif(self.spectrumJplus and self.spectrumJDminus):           self.results = self._calcDdoub(self.spectrumJplus,self.spectrumJDminus,'+','-')           self._displayResults('D')         elif(self.spectrumJminus and self.spectrumJDplus):           self.results = self._calcDdoub(self.spectrumJminus,self.spectrumJDplus,'-','+')           self._displayResults('D')         elif(self.spectrumJminus and self.spectrumJDminus):           self.results = self._calcDdoub(self.spectrumJminus,self.spectrumJDminus,'-','-')           self._displayResults('D')         else:           raise MyError       elif(calcType==2 and exptType==1):         if(self.spectrumJplus and self.spectrumJminus):           JErr=float(self.JErr.get())           self.results = self._calcJorJDIPAP(self.spectrumJplus,self.spectrumJminus,JErr)           self._displayResults('J')         elif(self.spectrumJDplus and self.spectrumJDminus):           JDErr=float(self.JDErr.get())           self.results = self._calcJorJDIPAP(self.spectrumJDplus,self.spectrumJDminus,JDErr)           self._displayResults('JD')         else:           raise MyError       elif(calcType==2 and exptType==2):         if(self.spectrumJplus):           JErr=float(self.JErr.get())           self.results = self._calcJorJDdoub(self.spectrumJplus,JErr,'+')           self._displayResults('J')         elif(self.spectrumJminus):           JErr=float(self.JErr.get())           self.results = self._calcJorJDdoub(self.spectrumJminus,JErr,'-')           self._displayResults('J')         elif(self.spectrumJDplus):           JDErr=float(self.JDErr.get())           self.results = self._calcJorJDdoub(self.spectrumJDplus,JDErr,'+')           self._displayResults('JD')         elif(self.spectrumJDminus):           JDErr=float(self.JDErr.get())           self.results = self._calcJorJDdoub(self.spectrumJDminus,JDErr,'-')           self._displayResults('JD')         else:           raise MyError         def _calcDIPAP(self,spec1,spec2,spec3,spec4):       # results[] consists of (D, errD) pairs       results = {}       resid = []       JplusHz = {}       JminusHz = {}       JDplusHz = {}       JDminusHz = {}       sf = self.freq       dim = self.dim       # get RDC scaling and error estimates from main       scaleF=float(self.scaleF.get())       JErr=float(self.JErr.get())       JDErr=float(self.JDErr.get())       # will calculate spec1 - spec2 + spec3 - spec4       self._fillPpmDict(JplusHz,spec1,dim)       self._fillPpmDict(JminusHz,spec2,dim)       self._fillPpmDict(JDplusHz,spec3,dim)       self._fillPpmDict(JDminusHz,spec4,dim)       # to calculate splitting, go through Dicts and check there's       # only one entry for each residue - otherwise return string       # containing number of entries instead       for resid in JplusHz.keys():         result = None         error = None         try:           if ( len(JplusHz[resid]) != 1) or \             ( len(JminusHz[resid]) != 1) or \             ( len(JDplusHz[resid]) != 1) or \             ( len(JDminusHz[resid]) != 1) :               results[resid] = 'Missing or duplicated peaks'           else:             # NB - the order of Dicts for Jresult below is intentional             Jresult = (JminusHz[resid][0] - JplusHz[resid][0]) * sf * scaleF             JDresult = (JDplusHz[resid][0] - JDminusHz[resid][0]) * sf * scaleF             result = JDresult - Jresult             error = scaleF * math.sqrt( (JErr**2) + (JDErr**2) )             results[resid] = ( str(Jresult), str(JDresult), str(result), str(error) )         except KeyError:           results[resid] = 'Missing or duplicated peaks'       return results     def _calcDdoub(self,spec1,spec2,signJ,signJD):       # results[] consists of (D, errD) pairs       results = {}       resid = []       JHz = {}       JDHz = {}       sf = self.freq       dim = self.dim       # get RDC scaling and error estimates from main       scaleF=float(self.scaleF.get())       JErr=float(self.JErr.get())       JDErr=float(self.JDErr.get())       self._fillPpmDict(JHz,spec1,dim)       self._fillPpmDict(JDHz,spec2,dim)       # to calculate splitting, go through Dicts and check there are       # two entries for each residue - otherwise return string       # containing number of entries instead       for resid in JHz.keys():         result = None         error = None         try:           if ( len(JHz[resid]) != 2 ) or ( len(JDHz[resid]) != 2 ):               results[resid] = 'Missing or duplicated peaks'           else:             # ensure if J(+) has been selected J is +ve             # ensure if JD(+) has been selected J+D is +ve             # - bit of a fudge - otherwise sign of each coupling depends on             # which of a pair of a peaks was picked first             bigJHz = JHz[resid][0]             littleJHz = JHz[resid][0]             if JHz[resid][1] > bigJHz:               bigJHz = JHz[resid][1]             else:               littleJHz = JHz[resid][1]             bigJDHz = JDHz[resid][0]             littleJDHz = JDHz[resid][0]             Jresult = None             JDresult = None             if JDHz[resid][1] > bigJDHz:               bigJDHz = JDHz[resid][1]             else:               littleJDHz = JDHz[resid][1]             if signJ == '+':               Jresult = (bigJHz - littleJHz) * sf * scaleF             else:               Jresult = (littleJHz - bigJHz) * sf * scaleF             if signJD == '+':               JDresult = (bigJDHz - littleJDHz) * sf * scaleF             else:               JDresult = (littleJDHz - bigJDHz) * sf * scaleF             result = JDresult-Jresult             error = math.sqrt((JErr**2)+(JDErr**2)) * scaleF             results[resid] = ( str(Jresult), str(JDresult), str(result), str(error) )         except KeyError:           results[resid] = 'Missing or duplicated peaks'       return results     def _calcJorJDIPAP(self,spec1,spec2,err):       # results[] consists of (JD, errJD) pairs       results = {}       resid = []       JorJDplusHz = {}       JorJDminusHz = {}       JorJDErr=err       sf = self.freq       dim = self.dim       # get RDC scaling and error estimates from main       scaleF=float(self.scaleF.get())       # will calculate spec1 - spec2       self._fillPpmDict(JorJDplusHz,spec1,dim)       self._fillPpmDict(JorJDminusHz,spec2,dim)       # to calculate splitting, go through Dicts and check there's       # only one entry for each residue - otherwise return string       # containing number of entries instead       for resid in JorJDplusHz.keys():         result = None         error = None         try:           if ( len(JorJDplusHz[resid]) != 1) or \             ( len(JorJDminusHz[resid]) != 1):               results[resid] = 'Missing or duplicated peaks'           else:             result = (JorJDplusHz[resid][0] - JorJDminusHz[resid][0]) * sf * scaleF             error = float(1)             results[resid] = ( str(result), str(error) )         except KeyError:           results[resid] = 'Missing or duplicated peaks'       return results     def _calcJorJDdoub(self,spec1,err,sign):       # results[] consists of (JD, errJD) pairs       results = {}       resid = []       JorJDHz = {}       JorJDErr=err       sf = self.freq       dim = self.dim       # get RDC scaling and error estimates from main       scaleF=float(self.scaleF.get())       self._fillPpmDict(JorJDHz,spec1,dim)       # to calculate splitting, go through a Dict and check there are       # two entries for each residue - otherwise return string       # containing number of entries instead       for resid in JorJDHz.keys():         result = None         error = None         try:           if ( len(JorJDHz[resid]) != 2):             results[resid] = 'Missing or duplicated peaks'           else:             # ensure if JorJD(+) has been selected the result is +ve             # - bit of a fudge - otherwise sign depends on which of a pair of             # peaks was picked first             bigHz = JorJDHz[resid][0]             littleHz = JorJDHz[resid][0]             if JorJDHz[resid][1] > bigHz:               bigHz = JorJDHz[resid][1]             else:               littleHz = JorJDHz[resid][1]             if sign == '+':               result = (bigHz - littleHz) * sf * scaleF             else:               result = (littleHz - bigHz) * sf * scaleF             error = err * scaleF             results[resid] = ( str(result), str(error) )         except KeyError:           results[resid] = 'Missing or duplicated peaks'       return results     def _fillPpmDict(self,ppmDict,spectrum,dim):       activList = getSpectrumActivePeakList(spectrum)       for peak in activList.peaks:         # the 'dim-1' is a bit of a fudge...         peakDims = peak.sortedPeakDims()         peakDim = peakDims[ dim-1 ]         ppm = getPeakDimPpm( peakDim )         # note - you'll get the last contrib if there's >1 (RDC probably meaningless anyway)         for contrib in peakDim.sortedPeakDimContribs():           residue = contrib.resonance.resonanceGroup.residue           if residue:             resid = residue.seqCode             # note - ppm values stored in a Dict of Lists (to cope with spectra containing doublets)             # TBD with subpeaks instead             if ppmDict.has_key(resid):               ppmDict[resid].append(ppm)             else:               ppmList = []               ppmList.append(ppm)               ppmDict[resid] = ppmList              def _displayResults(self,resultType):       # build the basic frame       win=Toplevel()       win.title("Results")       scrollyBit=Frame(win)       scrollyBit.pack(expand=YES, fill=BOTH)       sbar=Scrollbar(scrollyBit)       sbar.pack(side=RIGHT, fill=Y)       resultBox=Listbox(scrollyBit)       resultBox.pack(side=LEFT, expand=YES, fill=BOTH)       sbar.config(command=resultBox.yview)       resultBox.config(yscrollcommand=sbar.set)       outputStr = ''       # check what was calculated and display       if resultType == 'J':         resultBox.insert(END, 'Res J(Hz) errJ(Hz)')         keyList = self.results.keys()         keyList.sort()         for key in keyList:           thisStr = ''           if self.results[key][0] == 'M' :             thisStr = str(key) + ' ' + self.results[key]           else:             thisStr = ( "%d %.3f %.3f" % (key, float(self.results[key][0]), float(self.results[key][1])) )           resultBox.insert(END, thisStr)           outputStr = outputStr + thisStr + '\n'         self.output = outputStr         # final packing and buttons         optButtons=Frame(win)         optButtons.pack()         Button(optButtons, text='Save Results', command=self._onSave).pack(side=LEFT)         Button(optButtons, text='Close', command=win.destroy).pack(side=LEFT)       elif resultType == 'JD':         resultBox.insert(END, 'Res JD(Hz) errJD(Hz)')         keyList = self.results.keys()         keyList.sort()         for key in keyList:           if self.results[key][0] == 'M' :             thisStr = str(key) + ' ' + self.results[key]           else:             thisStr = ( "%d %.3f %.3f" % (key, float(self.results[key][0]), float(self.results[key][1])) )           resultBox.insert(END, thisStr)           outputStr = outputStr + thisStr + '\n'         self.output = outputStr         # final packing and buttons         optButtons=Frame(win)         optButtons.pack()         Button(optButtons, text='Save Results', command=self._onSave).pack(side=LEFT)         Button(optButtons, text='Close', command=win.destroy).pack(side=LEFT)       else:         resultBox.insert(END, 'Res J(Hz) JD(Hz) D(Hz) errD(Hz)')         keyList = self.results.keys()         keyList.sort()         for key in keyList:           if self.results[key][0] == 'M' :             thisStr = str(key) + ' ' + self.results[key]           else:             thisStr = ( "%d %.3f %.3f %.3f %.3f" % (key, float(self.results[key][0]), float(self.results[key][1]),float(self.results[key][2]), float(self.results[key][3])) )           resultBox.insert(END, thisStr)           outputStr = outputStr + thisStr + '\n'         self.output = outputStr         # final packing and buttons         optButtons=Frame(win)         optButtons.pack()         Button(optButtons, text='Save Results', command=self._onSave).pack(side=LEFT)         Button(optButtons, text='TENSO tbl', command=self._onTENSO).pack(side=LEFT)         Button(optButtons, text='SANI tbl', command=self._onSANI).pack(side=LEFT)         Button(optButtons, text='Close', command=win.destroy).pack(side=LEFT)     # Save Results in a text file     def _onSave(self):       filename=asksaveasfilename()       if filename:         open(filename, 'w').write(self.output)     # TBD - store RDCs in project     def _onStore(self):       filename=asksaveasfilename()       if filename:         open(filename, 'w').write(self.output)     # export a CNS sani-style table     def _onSANI(self):       saniStr = ''       atensorAtmStr = 'assign ( resid 999 and name OO )\n ( resid 999 and name Z )\n'       atensorAtmStr = atensorAtmStr + ' ( resid 999 and name X )\n ( resid 999 and name Y )\n'       atm1 = self.coupAtm1.get()       atm2 = self.coupAtm2.get()       offs1 = int(self.coupResid1.get())       offs2 = int(self.coupResid2.get())       keyList = self.results.keys()       keyList.sort()       for resid in keyList:         if self.results[resid][0] != 'M' :           rdc = float(self.results[resid][2])           err = float(self.results[resid][3])           saniStr = saniStr + atensorAtmStr           saniStr = saniStr + ( ' (resid %d and name %s) (resid %d and name %s) %.3f %.3f\n\n' % (resid+offs1, atm1, resid+offs2, atm2, rdc, err) )       filename=asksaveasfilename()       if filename:         open(filename, 'w').write(saniStr)     # export a CNS tenso-style table     def _onTENSO(self):       tensoStr = ''       atm1 = self.coupAtm1.get()       atm2 = self.coupAtm2.get()       offs1 = int(self.coupResid1.get())       offs2 = int(self.coupResid2.get())       keyList = self.results.keys()       keyList.sort()       for resid in keyList:         if self.results[resid][0] != 'M' :           rdc = float(self.results[resid][2])           err = float(self.results[resid][3])           tensoStr = tensoStr + ( 'assign (resid %d and name %s) (resid %d and name %s) %.3f %.3f\n' % (resid+offs1, atm1, resid+offs2, atm2, rdc, err) )       filename=asksaveasfilename()       if filename:         open(filename, 'w').write(tensoStr)     def _onHelp(self):       win=Toplevel()       win.title("Help")       helpbox = ScrolledText(win,height=40,width=80)       helpbox.pack(side=LEFT, expand=YES, fill=BOTH)       helpstr = \ """ Used for:   Measuring J or J+D or D from experiments in which the coupling is   encoded as a splitting - i.e. doublet or IPAP methods - uses peaks   rather than subpeaks for the moment. Before using:   To assign a pair of split peaks to the same resonance you must increase   the tolerance for the dimension in which the splitting appears: given 3   peaks - e.g. 1 assigned HSQC peak and 2 unassigned NH IPAP peaks - the   macro 'ipap_ass' can be used to perform the copying for each assigned peak   in the HSQC in turn - go to the peak list and use Find peak. Helpful to give   ipap_ass a keyboard shortcut for this. Usage:   The main RDCcalculator popup displays a list of available spectra in   columns marked J(+), J(-), JD(+) and JD(-): the meaning of these labels   depends on whether Experiment Type is 'IPAP' or 'doublet'. It is   possible to calculate J, J+D or D as follows:     - to calculate J or J+D for IPAP spectra,         - select a spectrum for J(+) and J(-) to calculate J         - select a spectrum for JD(+) and JD(-) to calculate J+D         - swap selection of J(+)/JD(+) and J(-)/JD(-) to change sign     - to calculate J or J+D for a single spectrum containing doublets,         - select a spectrum for J(+) OR J(-) to calculate J         - select a spectrum for JD(+) OR JD(-) to calculate J+D         - switch selection J(+) to J(-) or JD(+) to JD(-) to change sign     - to calculate D for IPAP spectra,         - select a spectrum for J(+), J(-), JD(+) and JD(-)         - D is calculated as D = ( JD(+) - JD(-) ) - ( J(-) - J(+) )         - play with selection of four spectra to change sign         - the signs of J and J+D are shown in the results window!     - to calculate D using two spectra that contain doublets,         - select a spectrum for ( J(+) OR J(-) ) and ( JD(+) OR JD(-) )         - switch selection J(+) to J(-) / JD(+) to JD(-) to change signs         - again, signs of J and J+D are shown in the results window   You can specify atom names (e.g. HN, N, C', CA, HA) in the 'Atom Name'   entry boxes - the neighbouring 'Residue' entry boxes modify the   residue number of the restraint for this atom (taken from the assignment   for Atom1). e.g. for NC' RDCs, enter N 0, C' -1 (the carbonyl carbon is   from the previous residue). Scaling factor is required to scale all RDCs   relative to the NH RDC for use as restraints (e.g. 8.33 for NC', -5.05   for CaC', -0.481 for CaHa). Error estimates for J and J+D will be used   to calculate a corresponding error in D according to:     errD = scaling * sqrt( (errJ^2) + (errJD^2) )   Estimates for errJ and errJD (error in a splitting) e.g. from:     err = LW / SN   where LW = linewidth and SN = signal-to-noise. This error estimation   procedure and the scaling factors for gyromagnetic ratio / bond length   are empirical and are taken from: Bax A, Kontaxis G, Tjandra N.   Methods Enzymol. 2001;339:127-174.   A second popup requests selection of the spectrum axis along which   the splitting appears. The Results can be printed to a text file or   restraint file for CNS/XPLOR (either SANI or TENSO).   Limitations:   - When changing selections, it's best to close and restart the macro...   - Not all residues with missing peaks will be reported - only those for     which a peak is present in the first spectrum.   - Experiments measuring J and J+D must be of the same type (using     different experiments is a bad idea anyway). Questions? E-mail: [log in to unmask] Phone: +44 131 650 7111 Graeme Ball Wellcome Trust Centre for Cell Biology School of Biological Sciences University of Edinburgh Mayfield Road Edinburgh EH9 3JR """       helpbox.insert(END, helpstr)   # RUNNING THE CALCULATOR STARTS HERE   project = argServer.getProject()   spectra = getSpectra(project)   root=Toplevel()   top=calculator(root, spectra)   top.mainloop()

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

May 2024
April 2024
March 2024
February 2024
January 2024
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
September 2003


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager