Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release 3.2.0 #73

Merged
merged 20 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v3.2.0:
- Wizard to apply operation in relion particles
- 3D Classification defines its possible outputs
- An initio fixed (not using optimization set)
- Other FSCs are plotted in the refine and postprocess protocols
v3.1.6:
- 3D Classification more completed/standard
- 3D classes can be fed to mapback or others
Expand Down
2 changes: 1 addition & 1 deletion reliontomo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

_logo = "relion_logo.png"
_references = ['Scheres2012a', 'Scheres2012b', 'Kimanius2016', 'Zivanov2018']
__version__ = '3.1.6'
__version__ = '3.2.0'


class Plugin(relion.Plugin):
Expand Down
11 changes: 11 additions & 0 deletions reliontomo/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,19 @@
OUT_PARTICLES_STAR = 'particles.star'
TRAJECTORIES_STAR = 'trajectories.star'
MANIFOLDS_STAR = 'manifolds.star'

REFINE_FSC_REF_STAR = '_model.star'
REFINE_STAR_FSC_TABLE = 'model_class_1'
REFINE_STAR_FSC_COLUMNS = ['rlnGoldStandardFsc', 'rlnFourierCompleteness']

POSTPROCESS_DIR = 'PostProcess'
FSC_REF_STAR = join(POSTPROCESS_DIR, 'postprocess.star')
POSTPROCESS_STAR_FSC_TABLE = 'fsc'
POSTPROCESS_STAR_FSC_COLUMNS = ['rlnFourierShellCorrelationCorrected',
'rlnFourierShellCorrelationUnmaskedMaps',
'rlnFourierShellCorrelationMaskedMaps',
'rlnCorrectedFourierShellCorrelationPhaseRandomizedMaskedMaps']

RE4_INDIV_GEN_FILES = [OUT_TOMOS_STAR, OUT_PARTICLES_STAR, TRAJECTORIES_STAR, MANIFOLDS_STAR, FSC_REF_STAR]
OPTIMISATION_SET_STAR = 'optimisation_set.star'
PSUBTOMOS_SQLITE = 'pseudosubtomograms%s.sqlite'
Expand Down
2 changes: 1 addition & 1 deletion reliontomo/convert/convert40_tomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def pseudoSubtomograms2Star(self, pSubtomoSet, outStar, withPriors=False):
partsWriter = Table.Writer(f)
partsWriter.writeTableName(PARTICLES_TABLE)
partsWriter.writeHeader(tomoTable.getColumns())
for pSubtomo in pSubtomoSet:
for pSubtomo in pSubtomoSet.iterSubtomos():
angles, shifts = getTransformInfoFromCoordOrSubtomo(pSubtomo, pSubtomo.getSamplingRate())
pSubtomoFile = pSubtomo.getFileName()
pSubtomoFile = pSubtomoFile.replace(':' + MRC, '') if pSubtomoFile else FILE_NOT_FOUND
Expand Down
1 change: 1 addition & 0 deletions reliontomo/protocols/protocol_3d_classify_subtomograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ProtRelion3DClassifySubtomograms(ProtRelionRefineSubtomograms):
classesTable = Table()
opticsTable = Table()
particlesTable = Table()
_possibleOutputs = outputObjects

def __init__(self, **kwargs):
super().__init__(**kwargs)
Expand Down
16 changes: 10 additions & 6 deletions reliontomo/protocols/protocol_base_refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,26 @@ def convertInputStep(self):
# -------------------------- INFO functions -------------------------------

# --------------------------- UTILS functions -----------------------------
def _genBaseCommand(self):
def _genBaseCommand(self, useOptimizationSet=True ):
cmd = ''
cmd += self._genIOBaseCmd() # I/O args
cmd += self._genIOBaseCmd(useOptimizationSet=useOptimizationSet) # I/O args
cmd += self._genCTFBaseCmd() # CTF args
cmd += self._genOptimisationBaseCmd() # Optimisation args
cmd += self._genComputeBaseCmd() # Compute args
cmd += self._genAddiotionalBaseCmd() # Additional args
return cmd

def _genIOBaseCmd(self):
def _genIOBaseCmd(self, useOptimizationSet=True):

inRelionParticles = self.getInputParticles()

# Use optimization set file
self.info("Using optimization_set: %s" % inRelionParticles.filesMaster)
cmd = '--ios %s ' % inRelionParticles.filesMaster
cmd = ''

if useOptimizationSet:
# Use optimization set file
self.info("Using optimization_set: %s" % inRelionParticles.filesMaster)
cmd += '--ios %s ' % inRelionParticles.filesMaster


cmd += '--i %s ' % self.getOutStarFileName()
cmd += '--o %s ' % (self._getExtraPath() + '/') # If not, Relion will concatenate it directly as a prefix
Expand Down
16 changes: 15 additions & 1 deletion reliontomo/protocols/protocol_base_relion.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
# *
# **************************************************************************
from os.path import exists, join
from emtable import Table

from pwem.objects import VolumeMask
from pwem.objects import VolumeMask, FSC
from pwem.protocols import EMProtocol
from pyworkflow.protocol import PointerParam
from pyworkflow.utils import Message, createLink
Expand Down Expand Up @@ -105,3 +106,16 @@ def genRelionParticles(self, optimisationFileName=OPTIMISATION_SET_STAR, particl

return psubtomoSet

def genFSCs(self, starFile, tableName, fscColumns):
fscSet = self._createSetOfFSCs()
table = Table(fileName=starFile, tableName=tableName)
resolution_inv = table.getColumnValues('rlnResolution')
for columnName in fscColumns:
columValues = table.getColumnValues(columnName)
fsc = FSC(objLabel=columnName[3:])
fsc.setData(resolution_inv, columValues)
fscSet.append(fsc)

fscSet.write()
return fscSet

2 changes: 1 addition & 1 deletion reliontomo/protocols/protocol_de_novo_initial_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def createOutputStep(self):
# --------------------------- UTILS functions -----------------------------
def _genInitModelCommand(self):
# Common parameters from base protocol
cmd = self._genBaseCommand()
cmd = self._genBaseCommand(useOptimizationSet=False)

# Initial model specific commands
cmd += ' --denovo_3dref --grad --zero_mask --auto_sampling --pad 1 '
Expand Down
15 changes: 14 additions & 1 deletion reliontomo/protocols/protocol_edit_particles_star.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
# **************************************************************************
from enum import Enum
from pyworkflow import BETA
from pyworkflow.protocol import BooleanParam, FloatParam, EnumParam
from pyworkflow.protocol import BooleanParam, FloatParam, EnumParam, \
PointerParam
from reliontomo import Plugin
from reliontomo.constants import OUT_PARTICLES_STAR, COORD_X, COORD_Y, COORD_Z, SHIFTX_ANGST, SHIFTY_ANGST, \
SHIFTZ_ANGST, ROT, TILT, PSI
Expand Down Expand Up @@ -73,6 +74,12 @@ def _defineParams(self, form):
default=False,
help='Perform centering of particles according to a position in the reference.')
group = form.addGroup('Shift center', condition='doRecenter')
group.addParam('averageSubTomogram', PointerParam, pointerClass='AverageSubTomogram',
label='Average of subtomogram (optional)', allowsNull=True,
)
group.addParam('refMask', PointerParam, pointerClass='VolumeMask',
label='Reference mask (optional)', allowsNull=True,
)
group.addParam('shiftX', FloatParam,
label='X (pix.)',
default=0,
Expand Down Expand Up @@ -216,3 +223,9 @@ def _genOperateCmd(self):

return operateCmd

def getAverageSubTomogram(self):
return self.averageSubTomogram.get()

def getMask3D(self):
return self.refMask.get()

17 changes: 14 additions & 3 deletions reliontomo/protocols/protocol_post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
# *
# **************************************************************************
from enum import Enum
from pwem.objects import VolumeMask
from pwem.objects import VolumeMask, FSC
from pyworkflow import BETA
from pyworkflow.protocol import PointerParam, BooleanParam, FloatParam, GE, LE, IntParam, FileParam
from pyworkflow.utils import makePath
from reliontomo import Plugin
from reliontomo.constants import POST_PROCESS_MRC, POSTPROCESS_DIR
from reliontomo.constants import POST_PROCESS_MRC, POSTPROCESS_DIR, \
POSTPROCESS_STAR_FSC_TABLE, \
POSTPROCESS_STAR_FSC_COLUMNS, FSC_REF_STAR
from reliontomo.objects import RelionSetOfPseudoSubtomograms
from reliontomo.protocols.protocol_base_relion import ProtRelionTomoBase

Expand All @@ -40,6 +42,7 @@
class outputObjects(Enum):
relionParticles = RelionSetOfPseudoSubtomograms
postProcessVolume = VolumeMask
outputFSC = FSC


class ProtRelionPostProcess(ProtRelionTomoBase):
Expand Down Expand Up @@ -154,8 +157,16 @@ def createOutputStep(self):
inParticles = self.inReParticles.get()
pSubtomoSet = self.genRelionParticles()
postProccesMrc = self._genPostProcessOutputMrcFile(POST_PROCESS_MRC)

# Output FSC

fn = self._getExtraPath(FSC_REF_STAR)
setOfFSC = self.genFSCs(fn, POSTPROCESS_STAR_FSC_TABLE,
POSTPROCESS_STAR_FSC_COLUMNS)

self._defineOutputs(**{outputObjects.postProcessVolume.name: postProccesMrc,
outputObjects.relionParticles.name: pSubtomoSet})
outputObjects.relionParticles.name: pSubtomoSet,
outputObjects.outputFSC.name: setOfFSC})
self._defineSourceRelation(inParticles, postProccesMrc)
self._defineSourceRelation(inParticles, pSubtomoSet)

Expand Down
22 changes: 11 additions & 11 deletions reliontomo/protocols/protocol_refine_subtomograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,25 @@
from enum import Enum
from emtable import Table
from pwem.convert.headers import fixVolume
from pwem.objects import FSC
from pwem.objects import SetOfFSCs
from pyworkflow import BETA
from reliontomo.objects import RelionSetOfPseudoSubtomograms
from reliontomo.protocols.protocol_base_refine import ProtRelionRefineBase
from reliontomo import Plugin
from os.path import getmtime
from pyworkflow.protocol import PointerParam, LEVEL_ADVANCED, FloatParam, StringParam, BooleanParam, EnumParam
from pyworkflow.utils import createLink
from reliontomo.constants import ANGULAR_SAMPLING_LIST, SYMMETRY_HELP_MSG, OUT_PARTICLES_STAR
from reliontomo.constants import ANGULAR_SAMPLING_LIST, SYMMETRY_HELP_MSG, \
OUT_PARTICLES_STAR, REFINE_FSC_REF_STAR, REFINE_STAR_FSC_TABLE, \
REFINE_STAR_FSC_COLUMNS
from reliontomo.utils import getProgram
from tomo.objects import AverageSubTomogram


class outputObjects(Enum):
relionParticles = RelionSetOfPseudoSubtomograms
average = AverageSubTomogram
outputFSC = FSC
outputFSC = SetOfFSCs


class ProtRelionRefineSubtomograms(ProtRelionRefineBase):
Expand Down Expand Up @@ -229,20 +231,18 @@ def createOutputStep(self):
vol.setHalfMaps([half1, half2])

# Output FSC
fsc = FSC(objLabel=self.getRunName())
fn = self._getExtraPath("_model.star")
table = Table(fileName=fn, tableName='model_class_1')
resolution_inv = table.getColumnValues('rlnResolution')
frc = table.getColumnValues('rlnGoldStandardFsc')
fsc.setData(resolution_inv, frc)
fn = self._getExtraPath(REFINE_FSC_REF_STAR)

setOfFSC = self.genFSCs(fn, REFINE_STAR_FSC_TABLE,
REFINE_STAR_FSC_COLUMNS)

outputDict = {outputObjects.relionParticles.name: relionParticles,
outputObjects.average.name: vol,
outputObjects.outputFSC.name: fsc}
outputObjects.outputFSC.name: setOfFSC}
self._defineOutputs(**outputDict)
self._defineSourceRelation(inParticles, relionParticles)
self._defineSourceRelation(inParticles, vol)
self._defineSourceRelation(inParticles, fsc)
self._defineSourceRelation(inParticles, setOfFSC)

# -------------------------- INFO functions -------------------------------

Expand Down
Loading