From beb3cd40fd1446357399f755f6188968b55fb2df Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Fri, 28 Jun 2013 11:36:31 -0700 Subject: [PATCH] Add option to copy source files for a submission. Sometimes it may be worth while to keep a copy of the files being submitted. --- encode_submission/trackhub.py | 12 +++++++++--- htsworkflow/submission/results.py | 7 +++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/encode_submission/trackhub.py b/encode_submission/trackhub.py index 4ee2061..41f76d1 100644 --- a/encode_submission/trackhub.py +++ b/encode_submission/trackhub.py @@ -77,8 +77,11 @@ def main(cmdline=None): else: logger.warn("File %s doesn't exist.", a) - if opts.make_tree_from is not None: - results.make_tree_from(opts.make_tree_from) + if opts.make_link_tree_from is not None: + results.make_tree_from(opts.make_tree_from, link=True) + + if opts.copy_tree_from is not None: + results.make_tree_from(opts.make_tree_from, link=False) if opts.fastq: logger.info("Building fastq extraction scripts") @@ -121,9 +124,12 @@ def make_parser(): parser.add_option_group(model) # commands commands = OptionGroup(parser, 'commands') - commands.add_option('--make-tree-from', + commands.add_option('--make-link-tree-from', help="create directories & link data files", default=None) + commands.add_option('--copy-tree-from', + help="create directories & copy data files", + default=None) commands.add_option('--fastq', default=False, action="store_true", help="generate scripts for making fastq files") commands.add_option('--scan-submission', default=False, action="store_true", diff --git a/htsworkflow/submission/results.py b/htsworkflow/submission/results.py index 36c2c78..5007752 100644 --- a/htsworkflow/submission/results.py +++ b/htsworkflow/submission/results.py @@ -45,7 +45,7 @@ class ResultMap(MutableMapping): lib_path = os.path.join(basepath, lib_path) self[lib_id] = lib_path - def make_tree_from(self, source_path, destpath = None): + def make_tree_from(self, source_path, destpath = None, link=True): """Create a tree using data files from source path. """ if destpath is None: @@ -76,7 +76,10 @@ class ResultMap(MutableMapping): raise IOError( "{0} does not exist".format(source_pathname)) if not os.path.exists(target_pathname): - os.symlink(source_pathname, target_pathname) + if link: + os.symlink(source_pathname, target_pathname) + else: + os.copy(source_pathname, target_pathname) LOGGER.info( 'LINK {0} to {1}'.format(source_pathname, target_pathname)) -- 2.30.2