8e22b36e5cba

More
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 17 Jul 2024 15:51:26 -0400
parents eb9f31c299b8
children 14b2a5152bea
branches/tags (none)
files bin/trst remote/bin/trst stumpwm/igv.lisp stumpwm/key-mapping.lisp stumpwm/miscellaneous.lisp stumpwm/screenshots.lisp stumpwm/stumpconfig.asd vim/custom-dictionary.utf-8.add

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/trst	Wed Jul 17 15:51:26 2024 -0400
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+tr ' ' $'\t'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/remote/bin/trst	Wed Jul 17 15:51:26 2024 -0400
@@ -0,0 +1,1 @@
+../../bin/trst
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stumpwm/igv.lisp	Wed Jul 17 15:51:26 2024 -0400
@@ -0,0 +1,72 @@
+(in-package :stumpwm-user)
+
+(defun send-igv-command (string &key want-resp)
+  (usocket:with-client-socket (socket stream "127.0.0.1" 60151)
+    ;; Do this here instead of passing :timeout above because that only sets
+    ;; *read* timeout and we don't want to permahang stump when IGV hangs and
+    ;; can't read.
+    (setf (sb-impl::fd-stream-timeout (usocket:socket-stream socket)) 5.0f0)
+    (unwind-protect (progn (write-line string stream)
+                           (force-output stream)
+                           (when want-resp
+                             (read-line stream)))
+      (usocket:socket-close socket))))
+
+(defun send-igv-batch-file (path)
+  (send-igv-command (alexandria:read-file-into-string path)))
+
+(defun igv-alignment-tracks ()
+  (str:split #\, (send-igv-command "alignmentTrackNames ," :want-resp t)))
+
+(defvar *igv/supplementary-alignments* t)
+
+(defun igv/select-reads% ()
+  (dolist (track-name (igv-alignment-tracks))
+    (let ((read-names (ppcre:all-matches-as-strings
+                        "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
+                        (pbpaste))))
+      (send-igv-command (format nil "selectByName ~A ~A ," track-name (str:join "," read-names)))
+      (echo (format nil "Selected ~D read~:P." (length read-names))))))
+
+(defun igv/goto% ()
+  (ppcre:register-groups-bind (chr start end)
+      ("(chr[A-Za-z0-9_]+)\\s+(\\d+)(?:\\s+)?(\\d+)?" (pbpaste))
+    (send-igv-command (format nil "goto ~A:~A~@[-~A~]" chr start end))))
+
+(defun igv/clear-read-selections% ()
+  (dolist (track-name (igv-alignment-tracks))
+    (send-igv-command (format nil "clearSelections ~A" track-name))))
+
+(defcommand igv/toggle-supplementary-alignments () ()
+  (callf *igv/supplementary-alignments* #'not)
+  (send-igv-command
+    (format nil "preference SAM.FILTER_SUPPLEMENTARY_ALIGNMENTS ~A"
+            (if *igv/supplementary-alignments* "FALSE" "TRUE")))
+  (echo (if *igv/supplementary-alignments*
+            "Supplementary alignments now on."
+            "Supplementary alignments now off.")))
+
+(defcommand igv/supplementary-on () ()
+  (send-igv-command "preference SAM.FILTER_SUPPLEMENTARY_ALIGNMENTS FALSE")
+  (echo "Supplementary alignments now on."))
+
+(defcommand igv/supplementary-off () ()
+  (send-igv-command "preference SAM.FILTER_SUPPLEMENTARY_ALIGNMENTS TRUE")
+  (echo "Supplementary alignments now off."))
+
+(defcommand igv/clear-read-selections () ()
+  (igv/clear-read-selections%))
+
+(defcommand igv/select-reads () ()
+  (igv/select-reads%))
+
+(defcommand igv/goto () ()
+  (igv/goto%))
+
+(defcommand igv/goto-read () ()
+  (igv/clear-read-selections%)
+  (igv/goto%)
+  (igv/select-reads%))
+
+(defcommand igv/init () ()
+  (send-igv-batch-file "/home/sjl/bin/igv.batch"))
--- a/stumpwm/key-mapping.lisp	Tue Jul 02 10:03:59 2024 -0400
+++ b/stumpwm/key-mapping.lisp	Wed Jul 17 15:51:26 2024 -0400
@@ -38,6 +38,7 @@
   ("S-F26" "next")
   ("H-q" "exec lock-screen")
   ("H-y" "screenshot")
+  ("H-Y" "delayed-screenshot")
   ("H-f" "save-fucked-screenshot")
   ("H-F" "delete-fucked-screenshot")
   ("H-r" "rain")
@@ -162,7 +163,13 @@
 
 (defvar *keymap/igv* (make-sparse-keymap))
 
-(define-key *keymap/igv* (kbd "s") "igv/toggle-supplementary-alignments")
+(define-key *keymap/igv* (kbd "s") "igv/supplementary-on")
+(define-key *keymap/igv* (kbd "S") "igv/supplementary-off")
+(define-key *keymap/igv* (kbd "r") "igv/select-reads")
+(define-key *keymap/igv* (kbd "R") "igv/clear-read-selections")
+(define-key *keymap/igv* (kbd "g") "igv/goto")
+(define-key *keymap/igv* (kbd "G") "igv/goto-read")
+(define-key *keymap/igv* (kbd "i") "igv/init")
 
 (define-top-keys ;; alternate maps
   ("H-i" *keymap/igv*))
--- a/stumpwm/miscellaneous.lisp	Tue Jul 02 10:03:59 2024 -0400
+++ b/stumpwm/miscellaneous.lisp	Wed Jul 17 15:51:26 2024 -0400
@@ -79,20 +79,3 @@
   (echo "Starting VM.")
   (run-shell-command "/home/sjl/vms/run"))
 
-
-(defun send-igv-command (string)
-  (usocket:with-client-socket (socket stream "127.0.0.1" 60151)
-    (unwind-protect (progn (write-line string stream)
-                           (force-output stream))
-      (usocket:socket-close socket))))
-
-(defvar *igv/supplementary-alignments* t)
-
-(defcommand igv/toggle-supplementary-alignments () ()
-  (callf *igv/supplementary-alignments* #'not)
-  (send-igv-command
-    (format nil "preference SAM.FILTER_SUPPLEMENTARY_ALIGNMENTS ~A"
-            (if *igv/supplementary-alignments* "FALSE" "TRUE")))
-  (echo (if *igv/supplementary-alignments*
-            "Supplementary alignments now on."
-            "Supplementary alignments now off.")))
--- a/stumpwm/screenshots.lisp	Tue Jul 02 10:03:59 2024 -0400
+++ b/stumpwm/screenshots.lisp	Wed Jul 17 15:51:26 2024 -0400
@@ -1,5 +1,8 @@
 (in-package :stumpwm-user)
 
+(defcommand delayed-screenshot () ()
+  (run-shell-command "sleep 10 && screenshot"))
+
 (defcommand screenshot () ()
   (run-shell-command "screenshot"))
 
--- a/stumpwm/stumpconfig.asd	Tue Jul 02 10:03:59 2024 -0400
+++ b/stumpwm/stumpconfig.asd	Wed Jul 17 15:51:26 2024 -0400
@@ -34,4 +34,5 @@
                (:file "vlime")
                (:file "external-screens")
                (:file "miscellaneous")
+               (:file "igv")
                (:file "key-mapping")))
--- a/vim/custom-dictionary.utf-8.add	Tue Jul 02 10:03:59 2024 -0400
+++ b/vim/custom-dictionary.utf-8.add	Wed Jul 17 15:51:26 2024 -0400
@@ -487,3 +487,12 @@
 Ansible
 SMaHT
 NOP
+unboxing
+NUCs
+Torrin's
+Margit
+hederas
+auth
+MinKNOW
+MinION
+deduplicate