File: poller.py

package info (click to toggle)
qiime 1.8.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 130,508 kB
  • ctags: 10,145
  • sloc: python: 110,826; haskell: 379; sh: 169; makefile: 125
file content (71 lines) | stat: -rwxr-xr-x 2,936 bytes parent folder | download
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
#!/usr/bin/env python
# File created on 09 Feb 2010
from __future__ import division

__author__ = "Greg Caporaso"
__copyright__ = "Copyright 2011, The QIIME Project"
__credits__ = ["Greg Caporaso", "Jai Ram Rideout"]
__license__ = "GPL"
__version__ = "1.8.0"
__maintainer__ = "Greg Caporaso"
__email__ = "gregcaporaso@gmail.com"
 
from qiime.util import make_option
from qiime.parallel.poller import poller, get_function_handle
from qiime.util import parse_command_line_parameters

script_info={}
script_info['brief_description']="""Poller for parallel QIIME scripts."""
script_info['script_description'] = """Script for polling parallel runs to check completion."""
script_info['script_usage'] = [(
"Poller example",
"Runs the poller, which checks for the existence of two input files "
"(file1.txt and file2.txt) and merges their contents. A cleanup file is "
"provided that instructs the poller to remove the newly merged file.",
"%prog -f run_complete.txt -m poller_test_completed.txt -d clean_up.txt"
)]
script_info['version'] = __version__
script_info['output_description']= "No output created."

script_info['required_options'] = [
 make_option('-f','--check_run_complete_file',
           help='path to file containing a list of files that must exist to '
           'declare a run complete [REQUIRED]')
]

script_info['optional_options'] = [
 make_option('-r','--check_run_complete_f',
           help='function which returns True when run is completed '
           '[default: %default]',
           default='qiime.parallel.poller.basic_check_run_complete_f'),
 make_option('-p','--process_run_results_f',
           help='function to be called when runs complete [default: %default]',
           default='qiime.parallel.poller.basic_process_run_results_f'),
 make_option('-m','--process_run_results_file',
           help='path to file containing a map of tmp filepaths which should'
           ' be written to final output filepaths [default: %default]'),
 make_option('-c','--clean_up_f',
           help='function called after processing result [default: %default]',
           default='qiime.parallel.poller.basic_clean_up_f'),
 make_option('-d','--clean_up_file',
           help='List of files and directories to remove after run'
           ' [default: %default]'),
 make_option('-t','--time_to_sleep',type='int',
           help='time to wait between calls to status_callback_f'
           ' (in seconds) [default: %default]',default=3)
]


def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)
    poller(get_function_handle(opts.check_run_complete_f),
        get_function_handle(opts.process_run_results_f),
        get_function_handle(opts.clean_up_f),
        list(open(opts.check_run_complete_file)),
        list(open(opts.process_run_results_file)),
        list(open(opts.clean_up_file)),
        seconds_to_sleep=opts.time_to_sleep)


if __name__ == "__main__":
    main()