forked from abcsFrederick/cryoem_pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline
executable file
·89 lines (83 loc) · 3.57 KB
/
pipeline
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python3
from workflow.workflow import Project
from workflow.scipion import Config
import argparse
import logging
import os
import sys
def _check_applications():
if sys.version_info < (3, 5):
msg = ''.join(
('This application requires Python 3.5 or greater.\n',
'Version',
str(sys.version_info),
'detected.'))
sys.exit(msg)
from shutil import which
if which('lbzip2') is None:
sys.exit('This application requires lbzip2 be installed. Exiting')
if which('scipion') is None:
sys.exit('This application requires scipion be installed. Exiting')
if which('imod') is None:
sys.exit('This application requires imod be installed. Exiting')
def _parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('--project', '-p',
required=False,
type=str,
help='Unique project identifier.')
parser.add_argument('--src-pattern', '-s',
required=False,
type=str,
help='A globbing pattern to match files for import and\
processing. Usually matches the files directly output\
by the camera.')
parser.add_argument('--dst-directory', '-d',
required=False,
type=str,
help='Destination directory for Globus transfer.')
parser.add_argument('--frames', '-f',
required=False,
type=int,
help='Set to the number of frames that will need to be\
stacked per-movie. Defaults to 1 (already stacked).')
parser.add_argument('--no-scipion',
required=False,
action='store_true',
help='Disable scipion startup. Useful for restarting\
transfers if scipion is already running or is being\
started separately.')
parser.add_argument('-v', '--debug', '--verbosity',
required=False,
type=str,
help='Provide a verbosity level like INFO or DEBUG\n\
Defaults to the equivalent of --debug INFO')
parser.add_argument('--log-file', '-o',
required=False,
type=str,
help='Path to write log file.')
args = parser.parse_args()
return args
if __name__ == '__main__':
args = _parse_arguments()
_check_applications()
config = Config(**vars(args))
config.generate_config()
project_name = config.project_name or args.project
logging.basicConfig(
level=getattr(logging, args.debug) if args.debug else logging.INFO,
filename=args.log_file or '/mnt/nas/pipeline/'+project_name+'.log')
logging.getLogger('transitions').setLevel(logging.WARNING)
logger = logging.getLogger(__name__)
if os.fork():
sys.exit()
project = Project(project=project_name,
pattern=config.source_pattern or args.src_pattern,
frames=config.frames_to_stack or args.frames or 1,
scipion_config=(None if args.no_scipion
else config.scipion_config_path),
globus_root=args.dst_directory)
logger.info('Parameters')
for val in vars(config):
logger.info(': '.join((val, str(getattr(config, val)))))
project.start()