Skip to content

Commit

Permalink
Merge pull request #31 from scipion-em/devel
Browse files Browse the repository at this point in the history
send devel to pypi
  • Loading branch information
JorMaister committed Jun 11, 2021
2 parents ecb631e + 614f885 commit 65d92a1
Show file tree
Hide file tree
Showing 19 changed files with 1,282 additions and 240 deletions.
16 changes: 10 additions & 6 deletions pyseg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# **************************************************************************
# *
# * Authors: you (you@yourinstitution.email)
# * Authors: Scipion Team
# *
# * your institution
# * National Center of Biotechnology, 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
Expand Down Expand Up @@ -96,8 +97,8 @@ def defineBinaries(cls, env):
@classmethod
def _genCmdToGetPySegSrcCode(cls, pySegDir):
installationCmd = 'wget ' + PYSEG_SOURCE_URL
installationCmd += ' && tar zxf %s' % join(pySegDir, basename(PYSEG_SOURCE_URL))
installationCmd += ' && rm -rf %s' % join(pySegDir, DEFAULT_VERSION + '.tar') # rm downloaded file (>600 MB)
installationCmd += ' && unzip %s' % join(pySegDir, basename(PYSEG_SOURCE_URL))
installationCmd += ' && rm -rf %s' % join(pySegDir, DEFAULT_VERSION + '.zip') # rm downloaded file (>600 MB)

return installationCmd

Expand Down Expand Up @@ -131,7 +132,7 @@ def _genCmdToDefineSegCondaEnv(cls):
installationCmd = cls.getCondaActivationCmd()

# Create the environment
installationCmd += 'conda create -y -n %s -c conda-forge -c anaconda python=2.7 ' \
installationCmd += 'conda create -y -n %s -c conda-forge -c anaconda python=3.6 ' \
'opencv=4.2.0 ' \
'graph-tool=2.29 && ' % PYSEG_ENV_NAME

Expand All @@ -147,7 +148,10 @@ def _genCmdToDefineSegCondaEnv(cls):
installationCmd += 'pip install scikit-learn==0.20.4 && '
installationCmd += 'pip install scikit-fmm==2021.2.2 && '
installationCmd += 'pip install scipy==1.2.1 && '
installationCmd += 'pip install vtk==8.1.2'
installationCmd += 'pip install vtk==8.1.2 '
installationCmd += 'pip install astropy==4.1 '
installationCmd += 'pip install imageio==2.9.0 '
installationCmd += 'pip install future'

return installationCmd

Expand Down
21 changes: 13 additions & 8 deletions pyseg/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
# **************************************************************************
# *
# * Authors: you (you@yourinstitution.email)
# * Authors: Scipion Team
# *
# * your institution
# * National Center of Biotechnology, 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
Expand All @@ -21,15 +21,17 @@
# * 02111-1307 USA
# *
# * All comments concerning this program package may be sent to the
# * e-mail address 'you@yourinstitution.email'
# * e-mail address 'scipion@cnb.csic.es'
# *
# **************************************************************************
from os.path import join

PYSEG = 'pySeg'
PYSEG_HOME = 'PYSEG_HOME'
DEFAULT_VERSION = '1.1.0'
PYSEG_SOURCE_URL = 'https://github.com/anmartinezs/pyseg_system/archive/refs/tags/v%s.tar.gz' % DEFAULT_VERSION
# DEFAULT_VERSION = '1.1.0'
# PYSEG_SOURCE_URL = 'https://github.com/anmartinezs/pyseg_system/archive/refs/tags/v%s.tar.gz' % DEFAULT_VERSION
DEFAULT_VERSION = 'jj_py3'
PYSEG_SOURCE_URL = 'https://github.com/anmartinezs/pyseg_system/archive/refs/heads/%s.zip' % DEFAULT_VERSION

PYSEG_ENV_NAME = 'pySeg-%s' % DEFAULT_VERSION
PYSEG_ENV_ACTIVATION = 'PYSEG_ENV_ACTIVATION'
Expand All @@ -38,24 +40,27 @@
# Required files location in pyseg-system
PYSEG_SYSTEM_MAIN = 'pyseg_system-%s' % DEFAULT_VERSION
DATA_TUTORIALS = join(PYSEG_SYSTEM_MAIN, 'data', 'tutorials')
FILS_XML_FILES_PATH = join(DATA_TUTORIALS, 'synth_sumb', 'fils', 'in')
CODE_TUTORIALS = join(PYSEG_SYSTEM_MAIN, 'code', 'tutorials')
EXP_SOMB = join(CODE_TUTORIALS, 'exp_somb')
SYNTH_SUMB = join(DATA_TUTORIALS, 'synth_sumb')
SYNTH_SUMB = join(CODE_TUTORIALS, 'synth_sumb')

PRESEG_SCRIPT = join(EXP_SOMB, 'pre_tomos_seg.py')
GRAPHS_SCRIPT = join(SYNTH_SUMB, 'tracing', 'mb_graph_mp.py')
FILS_SCRIPT = join(SYNTH_SUMB, 'tracing', 'mb_fils_network.py')
FILS_SOURCES = join(SYNTH_SUMB, 'fils', 'in', 'mb_sources.xml')
FILS_TARGETS = join(SYNTH_SUMB, 'fils', 'in', 'no_mb_targets.xml')
FILS_SOURCES = join(FILS_XML_FILES_PATH, 'mb_sources.xml')
FILS_TARGETS = join(FILS_XML_FILES_PATH, 'no_mb_targets.xml')
PICKING_SCRIPT = join(EXP_SOMB, 'mbo_picking.py')
PICKING_SLICES = join(DATA_TUTORIALS, 'exp_somb', 'mb_ext.xml')
POST_REC_SCRIPT = join(SYNTH_SUMB, 'rln', 'post_rec_particles.py')
PLANE_ALIGN_CLASS_SCRIPT = join(SYNTH_SUMB, 'class', 'plane_align_class.py')

# Generated data
GRAPHS_OUT = 'graphs'
FILS_OUT = 'fils'
PICKING_OUT = 'picking'
POST_REC_OUT = 'subtomos_post_rec'
PLANE_ALIGN_CLASS_OUT = 'plane_align_classification'

# Third parties software
CFITSIO = 'cfitsio'
Expand Down
27 changes: 16 additions & 11 deletions pyseg/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from relion.convert import Table
from reliontomo.convert.convert30_tomo import TOMO_NAME, SUBTOMO_NAME, COORD_X, COORD_Y, COORD_Z, ROT, TILT, PSI, \
RELION_TOMO_LABELS, TILT_PRIOR, PSI_PRIOR, CTF_MISSING_WEDGE, SHIFTX, SHIFTY, SHIFTZ
from tomo.constants import BOTTOM_LEFT_CORNER
from tomo.objects import SubTomogram, Coordinate3D, TomoAcquisition, Tomogram

FILE_NOT_FOUND = 'file_not_found'
Expand All @@ -57,7 +58,7 @@
PYSEG_PICKING_STAR = 1


def readStarFile(prot, outputSetObject, fileType, starFile=None, invert=True):
def readStarFile(prot, outputSetObject, fileType, starFile=None, invert=True, returnTable=False):
warningMsg = None
# Star file can be provided by the user or not, depending on the protocol invoking this method
if not starFile:
Expand Down Expand Up @@ -88,7 +89,10 @@ def readStarFile(prot, outputSetObject, fileType, starFile=None, invert=True):
'values will be considered as 0.' \
% ' '.join(['*' + colName + '*' for colName in missingCols])

return warningMsg
if returnTable:
return warningMsg, tomoTable
else:
return warningMsg


def manageIhDims(fileName, z, n):
Expand Down Expand Up @@ -132,9 +136,9 @@ def _relionTomoStar2Subtomograms(prot, outputSubTomogramsSet, tomoTable, starPat
tiltPrior = row.get(TILT_PRIOR, 0)
psiPrior = row.get(PSI_PRIOR, 0)
ctf3d = row.get(CTF_MISSING_WEDGE, FILE_NOT_FOUND)
coordinate3d.setX(float(x))
coordinate3d.setY(float(y))
coordinate3d.setZ(float(z))
coordinate3d.setX(float(x), BOTTOM_LEFT_CORNER)
coordinate3d.setY(float(y), BOTTOM_LEFT_CORNER)
coordinate3d.setZ(float(z), BOTTOM_LEFT_CORNER)
coordinate3d._3dcftMrcFile = String(join(starPath, ctf3d)) # Used for the ctf3d generation in Relion
M = _getTransformMatrix(row, invert)
transform.setMatrix(M)
Expand Down Expand Up @@ -236,19 +240,20 @@ def getTomoSetFromStar(prot, starFile):
def _pysegStar2Coords3D(prot, output3DCoordSet, tomoTable, invert):
for tomoNum, tomo in enumerate(prot.tomoSet.iterItems()):
tomoName = tomo.getFileName().replace(':mrc', '')
for ancestorName, row in zip(prot.tomoList, tomoTable):
if ancestorName == tomoName:
for row in tomoTable:
# Create the set of coordinates referring each of them to its corresponding tomogram (ancestor)
if row.get(TOMO_NAME) == tomoName:
coordinate3d = Coordinate3D()
coordinate3d.setVolId(tomoNum)
coordinate3d.setVolume(tomo)
x = row.get(COORD_X, 0)
y = row.get(COORD_Y, 0)
z = row.get(COORD_Z, 0)
M = _getTransformMatrix(row, invert)
coordinate3d.setX(float(x))
coordinate3d.setY(float(y))
coordinate3d.setZ(float(z))
coordinate3d.setX(float(x), BOTTOM_LEFT_CORNER)
coordinate3d.setY(float(y), BOTTOM_LEFT_CORNER)
coordinate3d.setZ(float(z), BOTTOM_LEFT_CORNER)
coordinate3d.setMatrix(M)
coordinate3d.setVolume(tomo)
coordinate3d._pysegMembrane = String(row.get(SUBTOMO_NAME, FILE_NOT_FOUND))

# Add current subtomogram to the output set
Expand Down
6 changes: 5 additions & 1 deletion pyseg/protocols.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ Tomography = [
{"tag": "protocol", "value": "ProtPySegGFP", "text": "pyseg - graphs, fils and picking"},
{"tag": "protocol", "value": "ProtPySegPostRecParticles", "text": "pyseg - post rec particles"}
]}
]}
]},
{"tag": "section", "text": "Subtomogram averaging", "icon": "bookmark.png", "children": [
{"tag": "protocol", "value": "ProtPySegPostRecParticles", "text": "pyseg - post rec particles"},
{"tag": "protocol", "value": "ProtPySegPlaneAlignClassification", "text": "pyseg - 2d classification"}
]}
]
1 change: 1 addition & 0 deletions pyseg/protocols/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@
from .protocol_fils import ProtPySegFils
from .protocol_picking import ProtPySegPicking
from .protocol_pre_seg import ProtPySegPreSegParticles
from .protocol_2d_classification import ProtPySegPlaneAlignClassification
Loading

0 comments on commit 65d92a1

Please sign in to comment.