changeset 29:f728cf0df71d draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit fe89199bded3f50aefb6958f0c4e85eede77ad81-dirty
author fubar
date Fri, 16 Feb 2024 00:04:37 +0000
parents 9a5c409f33f4
children 8f02a84ee278
files jb2_webserver.py jbrowse2.py pafcount.py
diffstat 3 files changed, 9 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/jb2_webserver.py	Wed Feb 07 22:51:54 2024 +0000
+++ b/jb2_webserver.py	Fri Feb 16 00:04:37 2024 +0000
@@ -1,4 +1,5 @@
-#!/usr/bin/env python3# spec: simplest python web server with range support and multithreading that takes root path,
+#!/usr/bin/env python3
+# spec: simplest python web server with range support and multithreading that takes root path,
 # port and bind address as command line arguments; by default uses the current dir as webroot,
 # port 8000 and bind address of 0.0.0.0
 # borrowed from https://github.com/danvk/RangeHTTPServer
--- a/jbrowse2.py	Wed Feb 07 22:51:54 2024 +0000
+++ b/jbrowse2.py	Fri Feb 16 00:04:37 2024 +0000
@@ -564,11 +564,7 @@
         # can be served - if public.
         # dsId = trackData["metadata"]["dataset_id"]
         # url = "%s/api/datasets/%s/display?to_ext=hic " % (self.giURL, dsId)
-        hname = trackData["name"]
-        dest = os.path.join(self.outdir, hname)
-        cmd = ["cp", data, dest]
-        # these can be very big.
-        self.subprocess_check_call(cmd)
+        hname = trackData["hic_url"]
         floc = {
             "uri": hname,
         }
@@ -774,7 +770,6 @@
         trackDict["style"] = style_json
         self.tracksToAdd.append(trackDict)
         self.trackIdlist.append(tId)
-        logging.info("#### wig trackData=%s" % str(trackData))
 
     def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs):
         tId = trackData["label"]
@@ -1152,9 +1147,8 @@
                     outputTrackConfig,
                 )
             elif dataset_ext in ("cool", "mcool", "scool"):
-                hic_path = os.path.join(
-                    self.outdir, "%s_%d_%s.hic" % (track_human_label, i, dataset_ext)
-                )
+                hic_url = "%s_%d.hic" % (track_human_label, i)
+                hic_path = os.path.join(self.outdir, hic_url)
                 self.subprocess_check_call(
                     [
                         "hictk",
@@ -1166,6 +1160,7 @@
                         hic_path,
                     ]
                 )
+                outputTrackConfig["hic_url"] = hic_url
                 self.add_hic(
                     hic_path,
                     outputTrackConfig,
@@ -1227,7 +1222,7 @@
                     track["conf"]["options"]["paf"],
                 )
             else:
-                log.warn("Do not know how to handle %s", dataset_ext)
+                logging.warn("Do not know how to handle %s", dataset_ext)
             # Return non-human label for use in other fields
             yield outputTrackConfig["label"]
 
@@ -1292,7 +1287,8 @@
                     "@@@ regexp could not match contig:start..end in the supplied location %s - please fix"
                     % ddl
                 )
-
+        else:
+            drdict["refName"] = self.genome_firstcontig
         if drdict.get("refName", None):
             # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome
             view_json["displayedRegions"] = [
--- a/pafcount.py	Wed Feb 07 22:51:54 2024 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-import sys
-
-"""
-
-Col     Type    Description
-1   string  Query sequence name
-2   int     Query sequence length
-3   int     Query start (0-based; BED-like; closed)
-4   int     Query end (0-based; BED-like; open)
-5   char    Relative strand: "+" or "-"
-6   string  Target sequence name
-7   int     Target sequence length
-8   int     Target start on original strand (0-based)
-9   int     Target end on original strand (0-based)
-10  int     Number of residue matches
-11  int     Alignment block length
-12  int     Mapping quality (0-255; 255 for missing)
-"""
-
-qcis = {}
-tcis = {}
-qtrans = {}
-ttrans = {}
-pafname = sys.argv[1]
-pf = open(pafname, "r").readlines()
-for row in pf:
-    qn, ql, qs, qe, qrs, tn, tl, ts, te, nm, abl, mq = row.strip().split("\t")[:12]
-
-    if qn == tn:  # cis
-        print("cis", qn, tn)
-        tcis.setdefault(tn, 0)
-        tcis[tn] = tcis[tn] + 1
-        qcis.setdefault(qn, 0)
-        qcis[qn] = qcis[qn] + 1
-    else:  # trans
-        print("trans", qn, tn)
-        k = "%s_%s" % (qn, tn)
-        ttrans.setdefault(k, 0)
-        ttrans[k] = ttrans[k] + 1
-        qtrans.setdefault(k, 0)
-        qtrans[k] = qtrans[k] + 1
-# print('qcis', qcis,'\nqtrans', qtrans,'\ntcis', tcis,'\ntt', ttrans)
-# print('\nqtrans', qtrans,'\nttrans', ttrans)
-chroms = list(qtrans.keys())
-print("chroms=", chroms)
-# print('chrom\tqcis\ttcis\tqtrans\tttrans')
-print("chrom\tqtrans\tttrans")
-for cr in chroms:
-    # print('%s\t%d\t%d\t%d\t%d' % (cr, qcis[cr], tcis[cr], qtrans[cr], ttrans[cr]))
-    print("%s\t%d\t%d" % (cr, qtrans[cr], ttrans[cr]))