-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparticles_fixdim.py
62 lines (41 loc) · 1.34 KB
/
particles_fixdim.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
"""
This script load a protocol from a given project to
export the outputParticles as an stack of images.
"""
import sys, os
from pyworkflow.manager import Manager
import pyworkflow.utils as pwutils
import pyworkflow.em as em
from pyworkflow.em.packages.relion import ProtRelionRefine3D
def usage(error):
print """
ERROR: %s
Usage: scipion python export_particles.py PROJECT PROCOTOL
PROJECT: provide the project name
PROCOTOL: provide the protocol id to be used as input.
""" % error
sys.exit(1)
argc = len(sys.argv)
if argc < 3 or argc > 4:
usage("Incorrect number of input parameters")
projName = sys.argv[1]
protId = sys.argv[2]
manager = Manager()
if not manager.hasProject(projName):
usage("Unexistent project: %s" % pwutils.red(projName))
project = manager.loadProject(projName)
prot = project.getProtocol(protId)
if prot is None:
usage("Unexistent protocol: %s" % protId)
outputParticles = getattr(prot, 'outputParticles', None)
if outputParticles is None:
usage("Protocol does not have 'outputParticles'")
realDims = outputParticles.getDimensions()
print "Real dimensions: ", realDims
print "DB dimensions: ", outputParticles.getDim()
# Set the new dimensions
outputParticles.setDim(realDims)
outputParticles.write()
project.mapper.store(prot)
project.mapper.commit()