#=========================================================================================
# Licence, Reference and Credits
#=========================================================================================
__copyright__ = "Copyright (C) CCPN project (http://www.ccpn.ac.uk) 2014 - 2021"
__credits__ = ("Ed Brooksbank, Joanna Fox, Victoria A Higman, Luca Mureddu, Eliza Płoskoń",
"Timothy J Ragan, Brian O Smith, Gary S Thompson & Geerten W Vuister")
__licence__ = ("CCPN licence. See http://www.ccpn.ac.uk/v3-software/downloads/license")
__reference__ = ("Skinner, S.P., Fogh, R.H., Boucher, W., Ragan, T.J., Mureddu, L.G., & Vuister, G.W.",
"CcpNmr AnalysisAssign: a flexible platform for integrated NMR analysis",
"J.Biomol.Nmr (2016), 66, 111-124, http://doi.org/10.1007/s10858-016-0060-y")
#=========================================================================================
# Last code modification
#=========================================================================================
__modifiedBy__ = "$modifiedBy: Ed Brooksbank $"
__dateModified__ = "$dateModified: 2021-06-04 19:38:33 +0100 (Fri, June 04, 2021) $"
__version__ = "$Revision: 3.0.4 $"
#=========================================================================================
# Created
#=========================================================================================
__author__ = "$Author: Luca Mureddu $"
__date__ = "$Date: 2017-05-20 10:28:42 +0000 (Sun, May 28, 2017) $"
#=========================================================================================
# Start of code
#=========================================================================================
#### GUI IMPORTS
from ccpn.ui.gui.widgets.PipelineWidgets import GuiPipe
from ccpn.AnalysisScreen.gui.widgets import HitFinderWidgets as hw
#### NON GUI IMPORTS
from ccpn.framework.lib.pipeline.PipeBase import SpectraPipe, PIPE_SCREEN
from ccpn.util.Logging import getLogger
########################################################################################################################
### Attributes:
### Used in setting the dictionary keys on _kwargs either in GuiPipe and Pipe
########################################################################################################################
PipeName = 'Setup NmrAtoms from Peaks'
DefaultPeakListIndex = -1
SpectrumGroup = 'SpectrumGroup'
SGVarNames = [SpectrumGroup]
########################################################################################################################
########################################## ALGORITHM ########################################################
########################################################################################################################
########################################################################################################################
########################################## GUI PIPE #############################################################
########################################################################################################################
[docs]class SetupNmrAtomsFromSGroupGuiPipe(GuiPipe):
pipeName = PipeName
def __init__(self, name=pipeName, parent=None, project=None, **kwds):
super(SetupNmrAtomsFromSGroupGuiPipe, self)
GuiPipe.__init__(self, parent=parent, name=name, project=project, **kwds)
self._parent = parent
row = 0
hw._addSGpulldowns(self, row, SGVarNames)
row += len(SGVarNames)
self._updateWidgets()
def _updateWidgets(self):
self._setSpectrumGroupPullDowns(SGVarNames)
########################################################################################################################
########################################## PIPE #############################################################
########################################################################################################################
[docs]class SetupNmrAtomsFromSGroupPipe(SpectraPipe):
guiPipe = SetupNmrAtomsFromSGroupGuiPipe
pipeName = PipeName
pipeCategory = PIPE_SCREEN
_kwargs = {
SpectrumGroup: 'spectrumGroup.pid', #this will be replaced by the SG pid from the gui selection
}
[docs] def runPipe(self, spectra):
'''
'''
getLogger().info(self._startedInfo)
spectrumGroup = self._getSpectrumGroup(self._kwargs[SpectrumGroup])
nmrChain = self.project.fetchNmrChain(spectrumGroup.name)
for spectrum in spectrumGroup.spectra:
peakList = spectrum.peakLists[DefaultPeakListIndex]
nmrResidue = nmrChain.fetchNmrResidue(str(spectrum.name).replace('-','_')) # name by spectrum and replace the - if in the nane, otherwise API crashes
peaks = peakList.peaks
peaks.sort(key=lambda x: x.position[0], reverse=True) # reorder peaks by position 0. Done for 1D
for seq, peak in enumerate(peaks):
# only process those that are empty OR those not empty when checkbox cleared
for i, axisCode in enumerate(peak.axisCodes):
nmrAtom = nmrResidue.fetchNmrAtom(name=str(axisCode+'_'+str(seq)))
peak.assignDimension(axisCode=axisCode, value=[nmrAtom])
return spectra
# SetupNmrAtomsFromSGroupPipe.register() # Registers the pipe in the pipeline