X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=blobdiff_plain;f=encode_submission%2Ftrackhub.py;h=197d7f34092ef87e9b2a617b0a8474d3896ae3f9;hp=fb0cea8771dcbc25b11dc95654e1e12ed62d2eb9;hb=ad6adfee371e67084e55b94a1e5335263d6fb26b;hpb=6f05ae54b482745afbacc8da7d9cc31f9b067d23 diff --git a/encode_submission/trackhub.py b/encode_submission/trackhub.py index fb0cea8..197d7f3 100644 --- a/encode_submission/trackhub.py +++ b/encode_submission/trackhub.py @@ -96,8 +96,11 @@ def main(cmdline=None): mapper.scan_submission_dirs(results) if opts.make_hub: - make_hub(results) + make_hub(mapper, results, opts.make_hub) + if opts.make_manifest: + make_manifest(mapper, results, opts.make_manifest) + if opts.sparql: sparql_query(model, opts.sparql) @@ -106,17 +109,23 @@ def main(cmdline=None): print writer.serialize_model_to_string(model) -def make_hub(results): +def make_hub(mapper, results, filename=None): trackdb = mapper.make_hub(results) - manifest = mapper.make_manifest(results) - trackstream = sys.stdout - #with open('trackDb.txt', 'w') as trackstream: - trackstream.write(trackdb) + if filename is None or filename == '-': + sys.stdout.write(trackdb) + else: + with open('trackDb.txt', 'w') as trackstream: + trackstream.write(trackdb) - #with open('manifest.txt', 'w') as mainifeststream: - manifeststream = sys.stdout - mainifeststream.write(mainifest) +def make_manifest(mapper, results, filename=None): + manifest = mapper.make_manifest(results) + + if filename is None or filename == '-': + sys.stdout.write(manifest) + else: + with open(filename, 'w') as mainifeststream: + mainifeststream.write(manifest) def make_parser(): parser = OptionParser() @@ -145,8 +154,12 @@ def make_parser(): help="generate scripts for making fastq files") commands.add_option('--scan-submission', default=False, action="store_true", help="Import metadata for submission into our model") - commands.add_option('--make-hub', help='make the hub file', default=False, - action="store_true") + commands.add_option('--make-hub', default=None, + help='name the hub file or - for stdout to create it') + commands.add_option('--make-manifest', + help='name the manifest file name or - for stdout to create it', + default=None) + parser.add_option_group(commands)