-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrepeat_steps.py
66 lines (48 loc) · 1.9 KB
/
repeat_steps.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
63
64
65
66
#!/usr/bin/env python
"""
This script repeats a two steps of the workflow many times
varying some of the run parameters.
It can be modified to be used for other cases.
"""
import sys
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 run_steps.py PROJECT PROCOTOL [N=3]
PROJECT: provide the project name to execute the workflow.
PROCOTOL: provide the protocol id to be used as input.
N: the number of times to repeat the workflow.
""" % 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]
n = int(sys.argv[3]) if argc == 4 else 3
# Create a new project
manager = Manager()
if not manager.hasProject(projName):
usage("Unexistent project: %s" % pwutils.red(projName))
project = manager.loadProject(projName)
protExtractParts = project.getProtocol(protId)
protVol = project.getProtocol(1256)
protRelionAllParts = project.getProtocol(1291)
protRelionBestParts = project.getProtocol(1359)
project.launchProtocol(protRelionAllParts, wait=True)
project.launchProtocol(protRelionBestParts, wait=True)
for i in range(n):
protSubSet = project.newProtocol(em.ProtSubSet,
objLabel='Subset #%d' %n,
chooseAtRandom=True,
nElements=13245)
protSubSet.inputFullSet.set(protExtractParts.outputParticles)
project.launchProtocol(protSubSet, wait=True)
relionRefine = project.copyProtocol(protRelionBestParts)
relionRefine.objLabel.set('Refine Test #%d' %n)
relionRefine.inputParticles.set(protSubSet.outputParticles)
project.launchProtocol(relionRefine, wait=True)