dataSet.filters.addFilter(**filters) log.info("{i} other filters added".format(i=len(filters))) rlen = sanitize_read_length(read_length) if rlen: dataSet.filters.addRequirement(length=[('>=', rlen)]) if rlen or other_filters: dataSet.updateCounts() dataSet.write(out_file) return 0 @registry("filterdataset", "0.1.0", FileTypes.DS_SUBREADS, subreads_file_type, is_distributed=True, nproc=1, options={ "read_length": rl_opt, "other_filters": filters_opt }) def run_filterDataSet(rtc): return run_filter_dataset( rtc.task.input_files[0], rtc.task.output_files[0], rtc.task.options["pbcoretools.task_options.read_length"], rtc.task.options["pbcoretools.task_options.other_filters"]) if __name__ == '__main__': sys.exit(registry_runner(registry, sys.argv[1:]))
# This is just for test purposes log.info("Running example main with {i} {o} kw:{k}".format(i=input_file, o=output_file, k=kwargs)) # write mock output files, otherwise the End-to-End test will fail when # run within testkit with open(output_file, 'w') as f: f.write("MOCK TEST DATA") return 0 @registry("dev_mk_example_txt", "0.2.2", (FileTypes.TXT, ), (FileTypes.TXT, ), nproc=1, options=dict(alpha=1234)) def run_rtc(rtc): """Example Task for testing. Takes a txt file as input and writes a txt file with mock data""" # The above docstring will be used as the Task/ToolContract Description log.info("Got RTC task options {t}".format(t=rtc.task.options)) log.info("Got nproc {n}".format(n=rtc.task.nproc)) # The Task options are now accessible via global identifier alpha = rtc.task.options['pbsmrtpipe_examples.task_options.alpha'] return _example_main(rtc.task.input_files[0], rtc.task.output_files[0], nproc=rtc.task.nproc, alpha=alpha) if __name__ == '__main__': sys.exit(registry_runner(registry, sys.argv[1:]))
DRIVER_BASE = 'python -m pbinternal2.analysis_tools ' registry = registry_builder(TOOL_NAMESPACE, DRIVER_BASE) @registry("hello_world_analysis", "0.1.0", FileTypes.FASTA, FileTypes.REPORT, is_distributed=True, nproc=1) def run_rtc(rtc): return run_hello_world(rtc.task.input_files[0], rtc.task.output_files[0]) @registry("cond_to_report", "0.2.0", FileTypes.COND_RESEQ, FileTypes.REPORT, nproc=1, is_distributed=False) def run_rtc(rtc): return run_cond_to_report(rtc.task.input_files[0], rtc.task.output_files[0]) @registry("cond_to_alignmentsets_report", "0.2.0", FileTypes.COND_RESEQ, FileTypes.REPORT, nproc=1, is_distributed=True) def run_rtc(rtc): return run_cond_alignmentsets_to_report(rtc.task.input_files[0], rtc.task.output_files[0]) if __name__ == '__main__': default_log_level = logging.DEBUG sys.exit(registry_runner(registry, sys.argv[1:], default_log_level=default_log_level)) if __name__ == '__main__': sys.exit(registry_runner(registry, sys.argv[1:]))
label = "label_" + file_type.file_type_id desc = "File {f}".format(f=file_type) return OutputFileType(file_type.file_type_id, label, repr(file_type), desc, default_name) def _to_outputs(file_types): return [_to_output(i, ft) for i, ft in enumerate(file_types)] @registry("dev_txt_custom_outs", "0.1.0", FileTypes.TXT, _to_outputs((FileTypes.TXT, FileTypes.TXT)), name="Custom Txt Task") def run_rtc(rtc): """Test for using OutputFileTypes as outputs Output types can be specified as FileType, or OutputFileType instances """ return _example_main(rtc.task.input_files, rtc.task.output_files) if __name__ == '__main__': default_log_level = logging.DEBUG sys.exit( registry_runner(registry, sys.argv[1:], default_log_level=default_log_level, version=__version__))
DRIVER_BASE = "python -m pbinternal2.tasks.loading " LOADING_DIST_ID = "loading_dist" LOADING_DIST = 20 def _get_id(base_opt): return "{n}.task_options.{o}".format(n=TOOL_NAMESPACE, o=base_opt) registry = registry_builder(TOOL_NAMESPACE, Constants.DRIVER_BASE) @registry("loading_vs_poisson_report", "0.1.0", FileTypes.STS_H5, FileTypes.REPORT, is_distributed=True, nproc=1, options={Constants.LOADING_DIST_ID: Constants.LOADING_DIST}) def task_loading_vs_poisson_report(rtc): return loading_vs_poisson( rtc.task.input_files[0], rtc.task.output_files[0], rtc.task.nproc, rtc.task.options[_get_id(Constants.LOADING_DIST_ID)]) if __name__ == '__main__': sys.exit(registry_runner(registry, sys.argv[1:], default_log_level=logging.INFO))
@registry("dev_txt_hello", "0.1.0", FileTypes.TXT, (FileTypes.TXT, FileTypes.TXT), nproc=3, is_distributed=False) def run_rtc(rtc): return _example_main(rtc.task.input_files, rtc.task.output_files) def _to_output(i, file_type): default_name = "_".join([file_type.file_type_id, file_type.base_name + "_" + str(i)]) label = "label_" + file_type.file_type_id desc = "File {f}".format(f=file_type) return OutputFileType(file_type.file_type_id, label, repr(file_type), desc, default_name) def _to_outputs(file_types): return [_to_output(i, ft) for i, ft in enumerate(file_types)] @registry( "dev_txt_custom_outs", "0.1.0", FileTypes.TXT, _to_outputs((FileTypes.TXT, FileTypes.TXT)), name="Custom Txt Task" ) def run_rtc(rtc): """Test for using OutputFileTypes as outputs Output types can be specified as FileType, or OutputFileType instances """ return _example_main(rtc.task.input_files, rtc.task.output_files) if __name__ == "__main__": default_log_level = logging.DEBUG sys.exit(registry_runner(registry, sys.argv[1:], default_log_level=default_log_level, version=__version__))
@registry("dev_txt_hello", "0.1.0", FileTypes.TXT, (FileTypes.TXT, FileTypes.TXT), nproc=3, is_distributed=False) def run_rtc(rtc): return _example_main(rtc.task.input_files, rtc.task.output_files) def _to_output(i, file_type): default_name = "_".join([file_type.file_type_id, file_type.base_name + "_" + str(i)]) label = "label_" + file_type.file_type_id desc = "File {f}".format(f=file_type) return OutputFileType(file_type.file_type_id, label, repr(file_type), desc, default_name) def _to_outputs(file_types): return [_to_output(i, ft) for i, ft in enumerate(file_types)] @registry("dev_txt_custom_outs", "0.1.0", FileTypes.TXT, _to_outputs((FileTypes.TXT, FileTypes.TXT)), name="Custom Txt Task") def run_rtc(rtc): """Test for using OutputFileTypes as outputs Output types can be specified as FileType, or OutputFileType instances """ return _example_main(rtc.task.input_files, rtc.task.output_files) if __name__ == '__main__': default_log_level = logging.DEBUG sys.exit(registry_runner(registry, sys.argv[1:], default_log_level=default_log_level))