-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport_particles.py
63 lines (41 loc) · 1.35 KB
/
export_particles.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
59
60
61
62
#!/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 output_stack
PROJECT: provide the project name to execute the workflow.
PROCOTOL: provide the protocol id to be used as input.
output_stack: stack file to write particles.
""" % 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'")
outputStack = sys.argv[3]
outputParticles.printAll()
print "Writing particles to : %s" % outputStack
t = pwutils.Timer()
t.tic()
outputParticles.writeStack(outputStack)
t.toc()