Sorry, forgot about the second file with the functions. Attached. Just
put it into the same directory as the main macro file. If you still get
complains, add the directory to the PYTHONPATH.
Cheers
Igor
Vicky Higman wrote:
> Hi Igor,
>
> thanks for the macro. I have tried installing it, but get an error as
> the program can't seem to find 'IgorFuncs'. Is that another set of
> macros on which this one is based, or simply a path which I need to
> rename?
>
> Thanks.
>
> Vicky
>
>
>
>
> On 21/02/06, *igor barsukov* <[log in to unmask]
> <mailto:[log in to unmask]>> wrote:
>
> Hi Linda,
>
> I attached the macro we use for side chain assignments. You may
> find it
> useful and can modify it further.
>
> In general, if this macro is of interest, it can be added to the
> CCPN site.
>
> Cheers
> Igor
>
> Linda Ball wrote:
>
> >Hi all,
> >
> >What we really need here is a macro that does the equivalent job of
> >ANSIG's
> >incredibly useful 'seq_C' macro, which, upon receiving a sequence
> number
> >as
> >input displays the desired C/H nucleus pair for that residue, e.g.
> >Ca/Ha, Cb/Hb1,
> >Cb/Hb2, etc, etc. I'm sure that such a central macro must already
> exist
> >for
> >Analysis. If so, could anyone point us to it?
> >While I'm on the subject, is there also a macro equivalent to ANSIGs
> >'show_ss'
> >(show spin system)? This simply displays only those assignment labels
> >that are
> >required for a user-specified residue, while all other assignment
> labels
> >are
> >undisplayed, and would be much les cluttered than the current display
> >where all
> >labels are shown.
> >
> >Cheers,
> >
> >Linda
> >
> >
> >
> >
> >
> >>>> [log in to unmask]
> <mailto:[log in to unmask]> >>>
> >>>>
> >>>>
> >Hi,
> >
> >I am wanting to check my 3D 13C-NOESY specifically for Ha(i)-Hb(i+3)
> >helical
> >NOEs. I have Ha and Hb shifts from my HBHA(CO)NH spectrum and the
> Ca/Cb
> >shifts from the CBCA(CO)NH or CBCANH spectra. So in theory,
> finding the
> >NOEs should not be a problem. If I try to get to the correct
> place in
> >the
> >13C NOESY simply by using the RightMouse Navigate tool, it takes my a
> >while
> >to get there.
> >Is there any chance someone might be able to write me a macro, or
> >perhaps
> >has a macro (or one which could be easily changed) where I could
> specify
> >residue i and then would be taken to the Ha(i), Hb(i+3),Ca(i)
> location
> >in
> >the 13C spctrum?
> >Thanks.
> >
> >Vicky
> >
> >
>
>
> --
> Dr. Igor Barsukov
>
> Biological NMR Centre,
> University of Leicester
> PO Box 138,
> University Road,
> Henry Wellcome Building,
> Leicester LE1 9HN
> UK
> E-mail: [log in to unmask] <mailto:[log in to unmask]>
> Tel: +44 (0)116 229 7098
> FAX: +44 (0)116 229 7053
>
>
>
>
> import re,os,sys
> import Tkinter
>
> from ccpnmr.analysis.WindowBasic import getActiveWindows
> from ccpnmr.api import Analysis
>
> from memops.general import Implementation
> from memops.gui.ButtonList import ButtonList
>
> from ccpnmr.analysis.BrowseResonancesPopup import
> BrowseResonancesPopup
> #from BrowseResonancesPopup_nmrc import BrowseResonancesPopup
> from igorFuncs import getResidueProtElementResFromRes,
> getBoundProtonResonances, getProtonResFromCarbRes
>
> from memops.gui.Button import Button
> from memops.gui.Entry import Entry
> from memops.gui.FloatEntry import FloatEntry
> from memops.gui.Frame import Frame
> from memops.gui.LabelFrame import LabelFrame
> from memops.gui.Label import Label
> from memops.gui.PulldownMenu import PulldownMenu
> from memops.gui.MessageReporter import showOkCancel, showWarning,
> showYesNo
> from memops.gui.ScrolledMatrix import ScrolledMatrix
> from memops.gui.Text import Text
> from memops.gui.Spacer import Spacer
>
> from memops.editor.Util import createDismissHelpButtonList
> from ccpnmr.analysis.AssignmentBasic import getResonanceResidue,
> findResonanceSet, deassignResonance, getResonanceAtomTuple,
> removeSpinSystemResonance, makeResonanceGuiName, assignAtomsToRes,
> mergeResonances, addSpinSystemResonance,
> removeSpinSystemResonance, assignResonanceResidue
> from ccpnmr.analysis.MarkBasic import createPeakMark,
> createNonPeakMark, createRuler, \
> removeMarks, removeRulers, createPeakDimRuler, markCounter
>
>
> class SlimButton(Button):
> def __init__(self, parent,*args, **kw):
> Button.__init__(self, parent, borderwidth=1,padx=2,pady=2,
> *args, **kw)
>
>
> class ResTblSc(BrowseResonancesPopup):
>
> def __init__(self,parent,project = None,argServer=None):
> BrowseResonancesPopup.__init__(self, parent,project =
> parent.project)
> self.winDic={}
> self.WindowPositionDic={}
> self.WindowPositionDic2D={}
> self.argServer=argServer
> self.project = argServer.getProject()
> self.orthogonalDict={}
>
>
> def body(self, guiFrame):
>
> self.isotope = 'Any'
> self.status = 'Any'
> self.waitingForAtoms = 0
> self.waitingForSpinSystem = None
> hilightColor = '#%02x%02x%02x' % (128, 128, 200)
> self.titleColor = '#%02x%02x%02x' % (0, 0, 128)
> self.untoggledDict = { 'fg': 'black', 'relief': 'raised' ,
> 'bg': 'grey83'}
> self.toggledDict = { 'fg': 'white', 'relief': 'raised' ,
> 'bg': hilightColor}
> self.isotopeNames = ['Any','1H','15N','13C','unknown']
> self.statusNames = ['Any','Assigned','Unassigned','Orphaned']
> shiftListNames = self.getShiftListNames (self.project)
> shiftLists =
> list(self.project.findAllNmrMeasurementLists(className = 'ShiftList'))
> self.shiftList = None
> self.chain = None
> self.ccpCode = None
>
> row = 0
>
> frame=LabelFrame(guiFrame, text='Navigation')
> frame.grid(row=row, column=0, columnspan=10, rowspan=2,
> sticky=Tkinter.EW)
> frame.grid_columnconfigure(1, weight=1)
>
> self.orthogPulldown = PulldownMenu(frame, entries=['None'],
> callback=None)
> self.orthogPulldown.grid(row=0, column=0, sticky=Tkinter.W)
> self.orthogPulldown1 = PulldownMenu(frame, entries=['None'],
> callback=None)
> self.orthogPulldown1.grid(row=0, column=1, sticky=Tkinter.W)
> self.orthogPulldown2D = PulldownMenu(frame, entries=['None'],
> callback=None)
> self.orthogPulldown2D.grid(row=0, column=2, sticky=Tkinter.W)
> self.orthogButton = SlimButton(frame,text='Goto
> position:',command= self.gotoOrthogPlaneAll)
> self.orthogButton.grid(row=0, column=3, sticky=Tkinter.EW)
> self.markButton = SlimButton(frame,text='Nxt
> strip',command=self.incrementActiveStripAll)
> self.markButton.grid(row=0, column=4, sticky= Tkinter.EW)
> self.markButton = SlimButton(frame,text='Prv
> strip',command=self.decrementActiveStripAll)
> self.markButton.grid(row=0, column=5, sticky=Tkinter.EW)
> self.markButton = SlimButton(frame,text='0 strip',command=
> self.zeroActiveStrip)
> self.markButton.grid(row=0, column=6, sticky=Tkinter.EW)
> self.markButton = SlimButton(frame,text='Mark
> Res',command=self.markAllResShift)
> self.markButton.grid(row=0, column=7, sticky= Tkinter.EW)
>
> self.showAllRes = SlimButton(frame,text='Shw All
> Rs',command=self.showAllRes)
> self.showAllRes.grid(row=1, column=3, sticky=Tkinter.EW)
> self.markAllRes = SlimButton(frame,text='Mrk All Rs',command=
> self.markAllRes)
> self.markAllRes.grid(row=1, column=4, sticky=Tkinter.EW)
> self.markRemoveButton = SlimButton(frame,text='Del
> Marks',command=self.removeAllMarks)
> self.markRemoveButton.grid(row=1, column=5, sticky= Tkinter.EW)
> row += 1
> row += 1
>
>
> if shiftLists:
> self.shiftList = shiftLists[0]
>
> guiFrame.grid_columnconfigure(9, weight=1)
> # row = 0
> self.shiftValueEntry = FloatEntry(self, returnCallback=
> self.setShiftValue, width=10)
> self.nameEntry = Entry(self,
> returnCallback=self.setName, width=12)
>
> self.shiftListLabel = Label(guiFrame, text = 'ShiftList:')
> self.shiftListPulldown = PulldownMenu(guiFrame,
> self.changeShiftList, shiftListNames, selected_index=0,
> label_color = self.titleColor, do_initial_callback=False)
> self.isotopeLabel = Label(guiFrame, text = ' Isotope:')
> self.isotopePulldown = PulldownMenu(guiFrame,
> self.changeIsotope, self.isotopeNames, selected_index=0,
> label_color = self.titleColor, do_initial_callback=False)
> self.statusLabel = Label(guiFrame, text = ' Status:')
> self.statusPulldown = PulldownMenu(guiFrame,
> self.changeStatus, self.statusNames, selected_index=0, label_color
> = self.titleColor, do_initial_callback=False)
> self.chainLabel = Label(guiFrame, text = ' Chain:')
> self.chainPulldown = PulldownMenu(guiFrame,
> self.changeChain, selected_index=0, label_color = self.titleColor,
> do_initial_callback=False)
> self.ccpCodeLabel = Label(guiFrame, text = ' CcpCode:')
> self.ccpCodePulldown = PulldownMenu(guiFrame,
> self.changeCcpCode, selected_index=0, label_color =
> self.titleColor, do_initial_callback=False)
> #self.spacer2 = Spacer(guiFrame)
>
> self.shiftListLabel.grid (row=row, column=0, columnspan=1,
> sticky=Tkinter.W)
> self.shiftListPulldown.grid (row=row, column=1, columnspan=1,
> sticky=Tkinter.W)
> self.isotopeLabel.grid (row=row, column=2, columnspan=1,
> sticky=Tkinter.W)
> self.isotopePulldown.grid (row=row, column=3, columnspan=1,
> sticky=Tkinter.W )
> self.statusLabel.grid (row=row, column=4, columnspan=1,
> sticky=Tkinter.W)
> self.statusPulldown.grid (row=row, column=5, columnspan=1,
> sticky=Tkinter.W)
> self.chainLabel.grid (row=row, column=6, columnspan=1,
> sticky=Tkinter.W)
> self.chainPulldown.grid (row=row, column=7, columnspan=1,
> sticky=Tkinter.W)
> self.ccpCodeLabel.grid (row=row, column=8, columnspan=1,
> sticky=Tkinter.W )
> self.ccpCodePulldown.grid (row=row, column=9, columnspan=1,
> sticky=Tkinter.W)
>
> row += 1
> guiFrame.grid_rowconfigure(row, weight=1)
> #shift list experiments
> #shift list unit
> justifyList =
> ['center','right','left','left','center','center','center','center','center','center']
>
> colHeadings =
> ['#',"Shift","SD",'Assign\nName','Residue','Isotope','Other\nName','Total\nPeaks','Shift
> List\nPeaks','Spin\nSystem #']
> editWidgets =
> [None,self.shiftValueEntry,None,None,None,None,self.nameEntry,None,None,None]
> editGetCallbacks =
> [None,self.getShiftValue, None,None,None,None,self.getName ,self.showPeaks,
> self.showShiftListPeaks,None]
> editSetCallbacks =
> [None,self.setShiftValue, None,None,None,None,self.setName ,None,None,None]
> self.scrolledMatrix = ScrolledMatrix(guiFrame,
> justifyList=justifyList, initialRows=16, headingList=colHeadings,
> editWidgets=editWidgets,
>
> editGetCallbacks=editGetCallbacks,
>
> editSetCallbacks=editSetCallbacks,
> font=self.smallFont,
> callback=self.selectCell, multiSelect=1)
> self.scrolledMatrix.grid (row=row, column=0, columnspan=10,
> sticky = Tkinter.NSEW, padx=1)
> self.scrolledMatrix.doEditMarkExtraRules =
> self.doEditMarkExtraRules
>
>
> texts = ['Deassign','Assign','Add to\nSpin System','Remove
> from\nSpin System','Swap\nProchirals']
> commands =
> [self.disconnectAtoms,self.waitForAtoms,self.addToSpinSys,self.removeFromSpinSys,self.swapProchiral]
> buttonList = ButtonList(guiFrame, texts=texts,
> commands=commands, expands=True)
> buttonList.grid(row = 4, column = 0, columnspan=10, sticky =
> Tkinter.EW)
> self.assignButton = buttonList.buttons[1]
> self.assSpinSysButton = buttonList.buttons[2]
> self.swapProchiralButton = buttonList.buttons[4]
>
> texts = ['Delete','Delete\nOrphans','Merge','Show
> Total\nPeaks','Show Shift List\nPeaks']
> commands =
> [self.deleteResonance,self.deleteOrphans,self.mergeResonances,self.showPeaks,
> self.showShiftListPeaks]
> self.bottomButtons = createDismissHelpButtonList(guiFrame,
> texts=texts, expands=1,
> commands=commands, help_url=self.help_url)
> self.bottomButtons.grid(row = 5, columnspan = 10, sticky =
> Tkinter.EW)
>
>
> self.registerNotify(self.updateShiftLists,
> 'ccp.Nmr.ShiftList', 'setName')
> self.registerNotify (self.updateShiftLists,
> 'ccp.Nmr.ShiftList', '__init__')
> self.registerNotify(self.updateShiftLists,
> 'ccp.Nmr.ShiftList', 'delete')
>
> for func in ('__init__', 'delete'):
> for clazz in ('ccp.Nmr.PeakDimContrib',
> 'ccp.Nmr.Shift','ccp.Nmr.ResonanceSet', 'ccp.Nmr.Resonance'):
> self.registerNotify(self.updateAfter, clazz, func)
>
> self.registerNotify(self.updateAfter, 'ccp.Nmr.ResonanceSet',
> 'addResonance')
> self.registerNotify(self.updateAfter, 'ccp.Nmr.Shift',
> 'setValue')
> self.registerNotify(self.updateAfter, 'ccp.Nmr.Shift', 'setError')
>
> for func in ('setDetails', 'setIsotopeCode',
> 'setName','removeAssignName','setAssignNames','addAssignName'):
> self.registerNotify(self.updateAfter, 'ccp.Nmr.Resonance', func)
>
> for func in ('setCcpCode', 'addResonance', 'removeResonance',
> 'setResonances','addAtomSet', 'delete'):
> self.registerNotify(self.updateAfter ,
> 'ccp.Nmr.ResonanceGroup', func)
>
> self.registerNotify(self.updateAfter, 'ccp.Nmr.Shift',
> 'getResonance')
>
> self.resonances=[]
> self.resonance = None
>
> self.refresh = 0
> self.update ()
>
>
> def gotoOrthogPlane(self,windowName,col=0,active='y'):
>
> if windowName!='None':
> if active=='y':
> col=self.activeStrip(windowName)
>
> popup=self.argServer.parent.getWindowPopup (windowName)
> if windowName in self.WindowPositionDic.keys():
> position=self.WindowPositionDic[windowName]
> else:
> position=self.WindowPositionDic2D[windowName]
> popup.gotoPosition (position,col=col)
>
> def gotoOrthogPlaneAll(self):
>
> self.gotoOrthogPlane(self.orthogPulldown.getSelected())
> self.gotoOrthogPlane(self.orthogPulldown1.getSelected())
> self.gotoOrthogPlane(self.orthogPulldown2D.getSelected ())
>
> def activeStrip(self,windowName):
>
> window=self.orthogonalDict[windowName]
> for n in range(0,len(window.axisPanels[0].axisRegions)):
> if window.axisPanels[0].axisRegions[n].isActive: return n
>
> def zeroActiveStrip(self):
>
> windowName=self.orthogPulldown.getSelected()
> if windowName!='None':
> popup=self.argServer.parent.getWindowPopup (windowName)
> popup.activateStrip(0)
>
> windowName=self.orthogPulldown1.getSelected()
> if windowName!='None':
> popup=self.argServer.parent.getWindowPopup(windowName)
> popup.activateStrip (0)
>
> windowName=self.orthogPulldown2D.getSelected()
> if windowName!='None':
> popup=self.argServer.parent.getWindowPopup(windowName)
> popup.activateStrip(0)
>
> def incrementActiveStripAll(self):
>
> self.incrementActiveStrip(self.orthogPulldown.getSelected())
> self.incrementActiveStrip(self.orthogPulldown1.getSelected())
> self.incrementActiveStrip(self.orthogPulldown2D.getSelected())
>
> #mark all resonances from the residue identified by the selected
> resonance
> def markAllRes(self):
> resonance = self.scrolledMatrix.currentObjects[0]
> if resonance.resonanceSet:
> for r in
> getResidueProtElementResFromRes(resonance,elementSymbol='C'):
> self.markResShift (r)
> for r1 in
> getProtonResFromCarbRes(r): self.markResShift(r1)
>
> for r in
> getResidueProtElementResFromRes(resonance,elementSymbol='N'):
> self.markResShift(r)
> for r1 in
> getProtonResFromCarbRes(r): self.markResShift(r1)
>
> #display strips for the whole residue, alphabetical order
> def showAllRes(self):
> self.zeroActiveStrip()
> resonance = self.scrolledMatrix.currentObjects [0]
> ResPairs=[]
> CarbResDic={}
> if resonance.resonanceSet:
> for r in
> getResidueProtElementResFromRes(resonance,elementSymbol='C'):
> (molSystem, chain, residue, name) =
> getResonanceAtomTuple(r)
> CarbResDic[name]=r
> CarbNames=CarbResDic.keys()
> CarbNames.sort()
> print CarbNames
> for name in CarbNames:
> r=CarbResDic[name]
> for r1 in getProtonResFromCarbRes(r):
> (molSystem1, chain1, residue1, name1) =
> getResonanceAtomTuple(r1)
> if name=='Cga' or name=='Cgb' or name=='Cda' or
> name=='Cdb':
> if name[1:3]!=name1[1:3]: continue
> ResPairs.append([r,r1])
>
> #windows may have different number of pannels, ans smaller
> than numer of atoms
> cntMax=0
> windowName=self.orthogPulldown.getSelected ()
> if windowName!='None':
> window=self.orthogonalDict[self.orthogPulldown.getSelected()]
> cntMax=len(window.axisPanels[0].axisRegions)
> cntMax1=0
> windowName=self.orthogPulldown1.getSelected ()
> if windowName!='None':
> window=self.orthogonalDict[self.orthogPulldown1.getSelected()]
> cntMax1=len(window.axisPanels[0].axisRegions)
> cntMax2D=0
> windowName=self.orthogPulldown2D.getSelected ()
> if windowName!='None':
> window=self.orthogonalDict[self.orthogPulldown2D.getSelected()]
> cntMax2D=len(window.axisPanels[0].axisRegions)
>
> for ResPair in ResPairs:
> if cntMax>0:
> self.goToPosition(self.orthogPulldown.getSelected(),ResPair)
> if cntMax1>0:
> self.goToPosition(self.orthogPulldown1.getSelected(),ResPair)
> if cntMax2D>0:
> self.goToPosition(self.orthogPulldown2D.getSelected(),ResPair)
> self.incrementActiveStripAll()
> cntMax-=1
> cntMax1-=1
> cntMax2D-=1
>
> #resonances = [r1,r2]
> def goToPosition(self,windowName,resonances):
> if windowName=='None': return
> window=self.orthogonalDict[windowName]
> resTypesDic={}
> if len(resonances)>2: return
> if len(resonances)==2:
> if
> resonances[0].isotope.massNumber==resonances[1].isotope.massNumber:
> return
>
> for resonance in resonances:
> isotopeText = '%d%s' % (resonance.isotope.massNumber,
> resonance.isotope.chemElement.symbol)
> resTypesDic[isotopeText]=resonance
>
> position={}
> for axisPanel in window.axisPanels:
> if axisPanel.label=='y ' and len(window.axisPanels)!=2:
> continue
> for key in resTypesDic.keys():
> if key == axisPanel.axisType.name
> <http://axisPanel.axisType.name>:
> position[axisPanel.label
> ]=self.getResShift(resTypesDic[key])
>
> if len(resTypesDic.keys())!=len(position.keys()): return
> # print position
>
> popup=self.argServer.parent.getWindowPopup(windowName)
> col=self.activeStrip (windowName)
> popup.gotoPosition(position,col=col)
> ##~ if len(window.axisPanels)==2:
> ##~ self.WindowPositionDic2D[window.name
> <http://window.name>]=d_tmp
> ##~ else:
> ##~ self.WindowPositionDic[window.name
> <http://window.name>]=d_tmp
> #
>
>
> def incrementActiveStrip(self,windowName):
>
> if windowName!='None':
> window=self.orthogonalDict [windowName]
> popup=self.argServer.parent.getWindowPopup(windowName)
> col=popup.getActiveStrip()
> if col=='all': col=0
> if col<len(window.axisPanels[0].axisRegions)-1: col+=1
> popup.activateStrip(col)
>
> def decrementActiveStrip(self,windowName):
>
> if windowName!='None':
> window=self.orthogonalDict[windowName]
> popup=self.argServer.parent.getWindowPopup (windowName)
> col=popup.getActiveStrip()
> if col=='all': col=0
> if col>0: col-=1
> popup.activateStrip(col)
>
> def decrementActiveStripAll(self):
>
> self.decrementActiveStrip (self.orthogPulldown.getSelected())
> self.decrementActiveStrip(self.orthogPulldown1.getSelected())
> self.decrementActiveStrip(self.orthogPulldown2D.getSelected())
>
> def selectCell(self, resonance, row, col):
>
> self.resonance = resonance
>
> self.findWindows()
>
> def getResShift(self, resonance):
>
> if self.shiftList:
> shift= resonance.findFirstShift(parentList = self.shiftList)
> return shift.value
> else: return None
>
> def markResShift(self, resonance):
> positions=[self.getResShift(resonance)]
> isotopeText = '%d%s' % (resonance.isotope.massNumber,
> resonance.isotope.chemElement.symbol )
> axisType =None
> activeWindows = getActiveWindows(self.project)
> for window in activeWindows:
> if axisType: break
> for axisPanel in window.axisPanels:
> if isotopeText == axisPanel.axisType.name
> <http://axisPanel.axisType.name>:
> axisTypes=[axisPanel.axisType]
> break
>
> createNonPeakMark1(positions, axisTypes)
>
> def markAllResShift(self):
> for resonance in self.scrolledMatrix.currentObjects:
> self.markResShift(resonance)
>
> def removeAllMarks(self):
> removeMarks(self.project,removeAll=True)
>
> def findWindows(self):
> resTypesDic={}
> if len(self.scrolledMatrix.currentObjects)>2: return
> if len(self.scrolledMatrix.currentObjects)==2:
> if
> self.scrolledMatrix.currentObjects[0].isotope.massNumber==self.scrolledMatrix.currentObjects
> [1].isotope.massNumber: return
>
> for resonance in self.scrolledMatrix.currentObjects:
> isotopeText = '%d%s' % (resonance.isotope.massNumber,
> resonance.isotope.chemElement.symbol)
> resTypesDic[isotopeText]=resonance
>
> activeWindows = getActiveWindows(self.project)
> self.WindowPositionDic={}
> self.WindowPositionDic2D={}
> self.orthogonalDict={}
> for window in activeWindows:
> self.orthogonalDict[window.name <http://window.name>]=window
> d_tmp={}
> for axisPanel in window.axisPanels:
> if axisPanel.label=='y' and len(window.axisPanels)!=2:
> continue
> for key in resTypesDic.keys():
> if key == axisPanel.axisType.name
> <http://axisPanel.axisType.name>:
> d_tmp[axisPanel.label]=self.getResShift(resTypesDic[key])
>
> if len(resTypesDic.keys())==len(d_tmp.keys()):
> if len(window.axisPanels)==2:
> self.WindowPositionDic2D[window.name
> <http://window.name>]=d_tmp
> else:
> self.WindowPositionDic[ window.name
> <http://window.name>]=d_tmp
>
> list=self.WindowPositionDic.keys()
> list.append('None')
> n=0
> try:
> n=list.index(self.orthogPulldown.getSelected())
> except: pass
> self.orthogPulldown.setup (list,n)
>
> n=0
> try:
> n=list.index(self.orthogPulldown1.getSelected())
> except: pass
> self.orthogPulldown1.setup(list,n)
>
> list=self.WindowPositionDic2D.keys()
> list.append ('None')
> n=0
> try:
> n=list.index(self.orthogPulldown2D.getSelected())
> except: pass
> self.orthogPulldown2D.setup(list,n)
>
> def ResTblScGui(argServer=None):
> # popup = self.openPopup ('browse_resonances', ResTblSc)
> # popup.update() # TBD: not sure if this is really needed
>
> RT=ResTblSc(argServer.parent,argServer=argServer)
>
> def createNonPeakMark1(positions, axisTypes, lineWidth = 1,
> dashLength = 2, gapLength = 2, color = None,
> remove=False):
> """Descrn: Create a mark at a general (i.e. non-peak) position.
> Inputs: List of Floats (Analysis.Mark.positions), List of
> Analysis.AxisTypes,
> Int, Int, Int, Word (Analysis.Color.name
> <http://Analysis.Color.name>)
> Output: Analysis.Mark
> """
>
> global markCounter
>
> project = axisTypes[0].project
>
> if (not color):
> name = project.application.getValue(project, keyword='marksColor',
> defaultValue='red')
> colorScheme = project.findFirstColorScheme(name=name)
> if (colorScheme):
> names = colorScheme.colorNames
> ncolors = len(names)
> color = project.findFirstColor(name=names[markCounter %
> ncolors])
> if (not color):
> color = project.findFirstColor (name='black')
> markCounter = markCounter + 1
> else:
> color = project.findFirstColor(name='black')
>
> mark = Analysis.Mark(project, lineWidth=lineWidth,
> dashLength=dashLength,
> gapLength=gapLength, color=color)
>
> for n in range(len(positions)):
> markDim = Analysis.MarkDim(mark, position=positions[n],
> axisType=axisTypes[n])
>
> mark.peak = None
>
> if remove:
> removeMarks(project)
>
> return mark
>
>
>
>
>
>
>
--
Dr. Igor Barsukov
Biological NMR Centre,
University of Leicester
PO Box 138,
University Road,
Henry Wellcome Building,
Leicester LE1 9HN
UK
E-mail: [log in to unmask]
Tel: +44 (0)116 229 7098
FAX: +44 (0)116 229 7053
from ccp.general.Util import getOtherAtom
def getBoundProtonResonances(resonance):
from ccpnmr.analysis.MoleculeBasic import findBoundResonances
resonances = findBoundResonances(resonance)
return [x for x in resonances if (x.isotopeCode == '1H')]
#In attached file, this is getProtonResFromCarbRes(). Note that in case of
#an ambiguous assignment, it will return all the possible proton resonances
#(so if you've got an ambiguous CGa for VAL, you'll get the HG1* and HG2*
#resonances back).
def getResonancesForAtoms(atomList):
resonanceList = []
if atomList:
# Now look for the resonances that are linked to these atoms...
# First get the project level object to get the atomSets
ccpnProject = atomList[0].root
# Loop over all atomSets
for atomSet in ccpnProject.atomSets:
# Loop over the MolSystem level atoms in the list
for atom in atomList:
# If they belong to the atomSet, continue and get the resonances
if atom in atomSet.atoms:
for resSet in atomSet.resonanceSets:
for resonance in resSet.resonances:
# Doublecheck if resonance not yet in list
if not resonance in resonanceList:
resonanceList.append(resonance)
return resonanceList
def getResidueProtElementResFromRes(resonance,elementSymbol='C'):
# The atoms for protonated carbons for this residue will go in here...
protCarbAtoms = []
# Check whether the resonance has a resonanceSet
if resonance and resonance.resonanceSet:
# Get the MolSystem residue
residue = resonance.resonanceSet.atomSets[0].atoms[0].residue
# Get the reference ChemCompVar
# (this is the relevant variant of the chemical compound (amino acid in case of proteins))
chemCompVar = residue.chemCompVar
# The relevant carbon chemAtoms for this chemCompVar
carbChemAtoms = chemCompVar.findAllChemAtoms(elementSymbol = elementSymbol)
# Find the ones that have hydrogens attached and track them in a Python list
protCarbChemAtoms = []
for carbChemAtom in carbChemAtoms:
# Necessary to get the chemBond via the ChemCompVar because a 'superset' of ChemAtoms
# is defined with the relevant ones picked per ChemCompVar. This means that a carbon could
# have more than four bonds... but not if you select them via the ChemCompVar.
for chemBond in chemCompVar.chemBonds:
if carbChemAtom in chemBond.chemAtoms:
otherChemAtom = getOtherAtom(carbChemAtom,chemBond)
if otherChemAtom.elementSymbol == 'H':
protCarbChemAtoms.append(carbChemAtom)
break
# Now get the relevant atoms on the MolSystem level and track them
for protCarbChemAtom in protCarbChemAtoms:
protCarbAtom = residue.findFirstAtom(name = protCarbChemAtom.name)
protCarbAtoms.append(protCarbAtom)
# Get resonances for Molsystem level atoms (function at top)
protCarbResonances = getResonancesForAtoms(protCarbAtoms)
return protCarbResonances
def getProtonResFromCarbRes(resonance):
# The atoms for the protons for this carbon resonance
protAtoms = []
# Check whether the resonance has a resonanceSet
if resonance and resonance.resonanceSet:
# Get atoms per atomSet...
for atomSet in resonance.resonanceSet.atomSets:
carbAtom = atomSet.atoms[0]
# Get the chemCompVar
chemCompVar = atomSet.atoms[0].residue.chemCompVar
# Get the carbon chemAtom
carbChemAtom = carbAtom.chemAtom
# Find the hydrogens attached to it and track in a Python list
protChemAtoms = []
# Again necessary to select the chemBonds from the chemCompVar
for chemBond in chemCompVar.chemBonds:
if carbChemAtom in chemBond.chemAtoms:
otherChemAtom = getOtherAtom(carbChemAtom,chemBond)
if otherChemAtom.elementSymbol == 'H':
protChemAtoms.append(otherChemAtom)
# Now get the relevant atoms on the MolSystem level and track them
for protChemAtom in protChemAtoms:
protAtom = carbAtom.residue.findFirstAtom(name = protChemAtom.name)
protAtoms.append(protAtom)
# Get resonances for Molsystem level atoms (function at top)
protResonances = getResonancesForAtoms(protAtoms)
return protResonances
if __name__ == '__main__':
from memops.general.Io import loadXmlProjectFile
project = loadXmlProjectFile(file = 'methylTest.xml')
for resonance in project.resonances:
if resonance.resonanceSet:
print getResidueProtCarbResFromRes(resonance)
print getProtonResFromCarbRes(resonance)
|