Source code for spider.protocols.protocol_align_pairwise

# **************************************************************************
# *
# * Authors:     J.M. De la Rosa Trevin (
#                Tapu Shaikh            (
# *
# * Unidad de  Bioinformatica of Centro Nacional de Biotecnologia , CSIC
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 3 of the License, or
# * (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program; if not, write to the Free Software
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# * 02111-1307  USA
# *
# *  All comments concerning this program package may be sent to the
# *  e-mail address ''
# *
# **************************************************************************

import pyworkflow.utils as pwutils
from pyworkflow.protocol.params import IntParam

from .. import Plugin
from .protocol_align_base import SpiderProtAlign

[docs]class SpiderProtAlignPairwise(SpiderProtAlign): """ This protocol wraps SPIDER AP SR command (pairwise alignment). Reference-free alignment (both translational and rotational) of an image series. This alignment scheme aligns a pair of images at a time and then averages them. Then, the averages of each of those pairs are aligned and averaged, and then pairs of those pairs, etc. Compared to [[][AP SR]], this alignment scheme appears to be less random, which chooses seed images as alignment references. For more information, see Step 2b at [[][SPIDER's MDA online manual]] """ _label = 'align pairwise' def __init__(self, **args): SpiderProtAlign.__init__(self, 'mda/pairwise.msa', 'pairwise', **args) # --------------------------- DEFINE param functions ---------------------- def _defineAlignParams(self, form): SpiderProtAlign._defineAlignParams(self, form) form.addParam('searchRange', IntParam, default=8, label='Search range (px):', help='In the translational alignment, shifts of up to\n' '_searchRange_ (in pixel units) will be allowed.') form.addParam('stepSize', IntParam, default=2, label='Step size (px):', help='Alignments will be evaluated in units of _stepSize_ \n' '(in pixel units) up to a maximum of +/- _searchRange_.') form.addParallelSection(threads=2, mpi=0) # --------------------------- STEPS functions -----------------------------
[docs] def alignParticlesStep(self, innerRadius, outerRadius): """ Execute the pairwise.msa script to align the particles. """ particles = self.inputParticles.get() xdim = particles.getDimensions()[0] self._params.update({ '[idim-header]': xdim, '[cg-option]': self.cgOption.get(), '[inner-rad]': innerRadius, '[outer-rad]': outerRadius, # convert radius to diameter '[search-range]': self.searchRange.get(), '[step-size]': self.stepSize.get(), '[selection_list]': self._params['particlesSel'], '[unaligned_image]': self._params['particles'] + '@******', '[nummps]': self.numberOfThreads.get(), }) copy1Script = Plugin.getScript('mda/center1.msa') newScript = pwutils.replaceBaseExt(copy1Script, self.getExt()) pwutils.copyFile(copy1Script, self._getPath(newScript)) self.runTemplate(self.getScript(), self.getExt(), self._params)
[docs] def getAverage(self): return self._getPath(self.getAlignDir(), 'rfreeavg001.%s' % self.getExt())
# --------------------------- INFO functions ------------------------------ def _citations(self): return ['Marco1996'] def _summary(self): summary = list() summary.append('Radius range (px): *%s - %s*' % (self.innerRadius, self.outerRadius)) summary.append('Search range (px): *%s*' % self.searchRange) summary.append('Step size (px): *%s*' % self.stepSize) return summary def _methods(self): msg = "Input particles %s " % self.getObjectTag('inputParticles') msg += "were subjected to a pairwise reference-free alignment using the " msg += "'pyramidal system for prealignment construction' ([Marco1996]), " msg += "using radii %s to %s pixels. " % (self.innerRadius, self.outerRadius) msg += "Particles were then aligned to this initial reference-free average " msg += "using SPIDER command _AP SH_ using a " msg += "search range of %s pixels and a step size of %s pixels. " %\ (self.searchRange, self.stepSize) if self.hasAttribute('outputParticles'): msg += "Output particles: %s" % self.getObjectTag('outputParticles') return [msg]