diff jbrowse2.py @ 53:bdfa6a7c4543 draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 44df75b3714aa9e02983e0b67ef43fc0eee4a8d4-dirty
author fubar
date Thu, 07 Mar 2024 09:23:06 +0000
parents f350467f9433
children d6b0feb22584
line wrap: on
line diff
--- a/jbrowse2.py	Thu Mar 07 06:41:01 2024 +0000
+++ b/jbrowse2.py	Thu Mar 07 09:23:06 2024 +0000
@@ -10,6 +10,7 @@
 import shutil
 import struct
 import subprocess
+import sys
 import tempfile
 import urllib.request
 import xml.etree.ElementTree as ET
@@ -467,6 +468,7 @@
                     self.genome_name = (
                         genome_name  # first one for all tracks - other than paf
                     )
+                    self.genome_sequence_adapter = assem["sequence"]["adapter"]
                     self.genome_firstcontig = None
                     if not useuri:
                         # https://lazarus.name/jbrowse/fish/bigwig_0_coverage_bedgraph_cov_count_count_bw.bigwig
@@ -529,7 +531,7 @@
                     "uri": faname + ".gzi",
                 },
             }
-        self.genome_sequence_adapter = adapter
+
         trackDict = {
             "name": gname,
             "sequence": {
@@ -874,27 +876,20 @@
         else:
             fname = "%s.cram" % trackData["label"]
             dest = "%s/%s" % (self.outdir, fname)
-            bindex = fname + '.bai'
+            bindex = fname + '.crai'
             url = fname
             self.subprocess_check_call(["cp", data, dest])
-
             if bindex is not None and os.path.exists(bindex):
                 if not os.path.exists(dest+'.crai'):
                     # most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
                     self.subprocess_check_call(
                         ["cp", os.path.realpath(cram_index), dest + ".crai"]
                     )
-                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) + ".crai"):
-                        self.symlink_or_copy(
-                            os.path.realpath(data) + ".crai", dest + ".crai"
-                        )
-                    else:
-                        log.warn("Could not find a cram index (.crai file) for %s", data)
+            else:
+                cpath = os.path.realpath(dest) + '.crai'
+                cmd = ["samtools", "index", "-c", "-o", cpath, os.path.realpath(dest)]
+                logging.debug('executing cmd %s' % ' '.join(cmd))
+                self.subprocess_check_call(cmd)
         trackDict = {
             "type": "AlignmentsTrack",
             "trackId": tId,
@@ -1280,8 +1275,8 @@
         drdict = {
             "reversed": False,
             "assemblyName": self.genome_name,
-            "start": 0,
-            "end": 100000,
+            "start": 2000,
+            "end": 0,
             "refName": "x",
         }