Skip to content

Commit

Permalink
Merge pull request #184 from I2PC/legacy
Browse files Browse the repository at this point in the history
Adding protocols to legacy
  • Loading branch information
albertmena authored May 23, 2024
2 parents a0e4f7b + 28b3335 commit aa81664
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 3 deletions.
71 changes: 71 additions & 0 deletions xmipptomo/legacy/tests/test_protocol_score_transform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# **************************************************************************
# *
# * Authors: Federico P. de Isidro-Gomez
# *
# * [1] Centro Nacional de Biotecnologia, CSIC, Spain
# *
# * 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 2 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
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * 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 '[email protected]'
# *
# **************************************************************************
import numpy as np
from pyworkflow.tests import BaseTest, setupTestProject
from tomo.tests import DataSet

from xmipptomo.protocols import XmippProtScoreTransform
from tomo.protocols import ProtImportSubTomograms

class TestXmippTomoScoreTransform(BaseTest):
"""This class check if the protocol score_transform works properly."""

@classmethod
def setUpClass(cls):
setupTestProject(cls)
cls.dataset = DataSet.getDataSet('tomo-em')
cls.setOfSubtomograms = cls.dataset.getFile('basename.hdf')

def _runImportSubtomos(self, label):
protImport = self.newProtocol(ProtImportSubTomograms,
filesPath=self.setOfSubtomograms,
samplingRate=5,
label=label)
self.launchProtocol(protImport)
self.assertIsNotNone(protImport.outputSubTomograms,
"There was a problem with import subtomograms output")
return protImport.outputSubTomograms

def _scoreTransformations(self, firstSubtomos, secondSubtomos):
scoredTr = self.newProtocol(XmippProtScoreTransform,
firstSubtomos=firstSubtomos,
secondSubtomos=secondSubtomos,
label='Score Subtomogram Transformations')
self.launchProtocol(scoredTr)
self.assertIsNotNone(scoredTr.outputSetOfSubtomogram,
"There was a problem with score subtomograms output")
return scoredTr.outputSetOfSubtomogram

def test_scoreTransformations(self):
firstSubtomos = self._runImportSubtomos('First Subtomograms')
secondSubtomos = self._runImportSubtomos('Second Subtomograms')
scoredSubtomos = self._scoreTransformations(firstSubtomos, secondSubtomos)
self.assertTrue(scoredSubtomos.getSize() == 4)
dist = scoredSubtomos.aggregate(["MAX"], "distanceScore", ["distanceScore"])
dist = np.asarray([d["distanceScore"] for d in dist])
meanDist = np.mean(dist)
self.assertTrue(meanDist == 0)
return scoredSubtomos
File renamed without changes.
2 changes: 0 additions & 2 deletions xmipptomo/protocols/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from .protocol_dose_filter import XmippProtDoseFilter
from .protocol_filter_coordinates_by_map import XmippProtFilterCoordinatesByMap
from .protocol_crop_tomograms import XmippProtCropTomograms
from .protocol_denoising_confidence import XmippProtConfTomo
from .protocol_extract_particlestacks import XmippProtExtractParticleStacks
from .protocol_extract_subtomos import XmippProtExtractSubtomos
from .protocol_flexalign import XmippProtTsFlexAlign
Expand All @@ -49,7 +48,6 @@
from .protocol_resolution_local_monotomo import XmippProtMonoTomo
from .protocol_roiIJ import XmippProtRoiIJ
from .protocol_score_coordinates import XmippProtScoreCoordinates
from .protocol_score_transform import XmippProtScoreTransform
from .protocol_splitTS import XmippProtSplitTiltSeries
from .protocol_subtraction_subtomo import XmippProtSubtractionSubtomo
from .protocol_subtomo_map_back import XmippProtSubtomoMapBack
Expand Down
1 change: 0 additions & 1 deletion xmipptomo/viewers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@
from .viewer_cltomo import XmippCLTomoViewer, XmippProtTsFlexAlignViewer
from .viewer_resolution_local_monotomo import XmippMonoTomoViewer
from .viewer_phantom_create import XmippPhantomSubtomoViewer
from .viewer_score_subtomos import XmippTomoScoreSubtomoViewer

0 comments on commit aa81664

Please sign in to comment.