diff jbrowse.py @ 41:8774b28235bb draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 8556ea066463f5e112b6ded2c1527011ab1e3b38"
author iuc
date Thu, 31 Dec 2020 16:00:42 +0000
parents 17359b808b01
children 87dc4ce42281
line wrap: on
line diff
--- a/jbrowse.py	Fri Aug 21 04:42:41 2020 -0400
+++ b/jbrowse.py	Thu Dec 31 16:00:42 2020 +0000
@@ -400,6 +400,14 @@
     def _jbrowse_bin(self, command):
         return os.path.realpath(os.path.join(self.jbrowse, 'bin', command))
 
+    def symlink_or_copy(self, src, dest):
+        if 'GALAXY_JBROWSE_SYMLINKS' in os.environ and bool(os.environ['GALAXY_JBROWSE_SYMLINKS']):
+            cmd = ['ln', '-s', src, dest]
+        else:
+            cmd = ['cp', src, dest]
+
+        return self.subprocess_check_call(cmd)
+
     def process_genomes(self):
         for genome_node in self.genome_paths:
             # We only expect one input genome per run. This for loop is just
@@ -507,8 +515,7 @@
 
     def add_bigwig(self, data, trackData, wiggleOpts, **kwargs):
         dest = os.path.join('data', 'raw', trackData['label'] + '.bw')
-        cmd = ['cp', data, dest]
-        self.subprocess_check_call(cmd)
+        self.symlink_or_copy(os.path.realpath(data), dest)
 
         url = os.path.join('raw', trackData['label'] + '.bw')
         trackData.update({
@@ -535,8 +542,7 @@
         urls = []
         for idx, bw in enumerate(data):
             dest = os.path.join('data', 'raw', trackData['label'] + '_' + str(idx) + '.bw')
-            cmd = ['ln', '-s', bw[1], dest]
-            self.subprocess_check_call(cmd)
+            self.symlink_or_copy(bw[1], dest)
 
             urls.append({"url": os.path.join('raw', trackData['label'] + '_' + str(idx) + '.bw'), "name": str(idx + 1) + ' - ' + bw[0]})
 
@@ -598,11 +604,8 @@
 
     def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs):
         dest = os.path.join('data', 'raw', trackData['label'] + '.bam')
-        cmd = ['ln', '-s', os.path.realpath(data), dest]
-        self.subprocess_check_call(cmd)
-
-        cmd = ['ln', '-s', os.path.realpath(bam_index), dest + '.bai']
-        self.subprocess_check_call(cmd)
+        self.symlink_or_copy(os.path.realpath(data), dest)
+        self.symlink_or_copy(os.path.realpath(bam_index), dest + '.bai')
 
         url = os.path.join('raw', trackData['label'] + '.bam')
         trackData.update({