diff jbrowse.py @ 44:87dc4ce42281 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 00fb3ea114827e72a2ef344f490eb43a672aa492"
author iuc
date Thu, 22 Apr 2021 20:26:48 +0000
parents 8774b28235bb
children a6e57ff585c0
line wrap: on
line diff
--- a/jbrowse.py	Tue Mar 16 17:19:14 2021 +0000
+++ b/jbrowse.py	Thu Apr 22 20:26:48 2021 +0000
@@ -605,7 +605,18 @@
     def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs):
         dest = os.path.join('data', 'raw', trackData['label'] + '.bam')
         self.symlink_or_copy(os.path.realpath(data), dest)
-        self.symlink_or_copy(os.path.realpath(bam_index), dest + '.bai')
+        if bam_index is not None:
+            # bai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
+            self.subprocess_check_call(['cp', os.path.realpath(bam_index), dest + '.bai'])
+        else:
+            # Can happen in exotic condition
+            # e.g. if bam imported as symlink with datatype=unsorted.bam, then datatype changed to bam
+            #      => no index generated by galaxy, but there might be one next to the symlink target
+            #      this trick allows to skip the bam sorting made by galaxy if already done outside
+            if os.path.exists(os.path.realpath(data) + '.bai'):
+                self.symlink_or_copy(os.path.realpath(data) + '.bai', dest)
+            else:
+                log.warn('Could not find a bam index (.bai file) for %s', data)
 
         url = os.path.join('raw', trackData['label'] + '.bam')
         trackData.update({