Add the option to copy tree in addition to making a symlink tree from elsewhere.
authorDiane Trout <diane@caltech.edu>
Mon, 1 Jul 2013 22:59:10 +0000 (15:59 -0700)
committerDiane Trout <diane@caltech.edu>
Mon, 1 Jul 2013 22:59:10 +0000 (15:59 -0700)
Also don't copy subdirectories in an analysis directory tree being copied
from elsewhere.

encode_submission/trackhub.py
htsworkflow/submission/results.py

index 41f76d14f6d552f5a25eb0ee1bc74f9db32e18c6..4fea5cc827eca6ef7aa08c39642e6bd4aa1dac0b 100644 (file)
@@ -27,7 +27,6 @@ import RDF
 if not 'DJANGO_SETTINGS_MODULE' in os.environ:
     os.environ['DJANGO_SETTINGS_MODULE'] = 'htsworkflow.settings'
 
-
 from htsworkflow.util import api
 from htsworkflow.util.rdfhelp import \
      dafTermOntology, \
@@ -78,10 +77,10 @@ def main(cmdline=None):
             logger.warn("File %s doesn't exist.", a)
 
     if opts.make_link_tree_from is not None:
-        results.make_tree_from(opts.make_tree_from, link=True)
+        results.make_tree_from(opts.make_link_tree_from, link=True)
 
     if opts.copy_tree_from is not None:
-        results.make_tree_from(opts.make_tree_from, link=False)
+        results.make_tree_from(opts.copy_tree_from, link=False)
 
     if opts.fastq:
         logger.info("Building fastq extraction scripts")
index 50077523aca3970a517973adbd69f119f4f17e3d..5633745687c70cc9954685fa582b66c6d62a730f 100644 (file)
@@ -2,6 +2,7 @@
 """
 from collections import MutableMapping
 import os
+import shutil
 import logging
 
 from collections import namedtuple
@@ -75,11 +76,11 @@ class ResultMap(MutableMapping):
                 if not os.path.exists(source_pathname):
                     raise IOError(
                         "{0} does not exist".format(source_pathname))
-                if not os.path.exists(target_pathname):
+                if not (os.path.exists(target_pathname) or os.path.isdir(source_pathname)):
                     if link:
                         os.symlink(source_pathname, target_pathname)
                     else:
-                        os.copy(source_pathname, target_pathname)
+                        shutil.copy(source_pathname, target_pathname)
                     LOGGER.info(
                         'LINK {0} to {1}'.format(source_pathname,
                                                  target_pathname))