c1bdbd09670416fb6efd05466977c45e2e9c9d95
max
  Fri May 23 08:54:09 2025 -0700
adding cbtools quickgenes command

diff --git src/cbPyLib/cellbrowser/convert.py src/cbPyLib/cellbrowser/convert.py
index bedd27f..1f0f13d 100644
--- src/cbPyLib/cellbrowser/convert.py
+++ src/cbPyLib/cellbrowser/convert.py
@@ -1,46 +1,48 @@
 # various format converters for single cell data:
 # - cellranger, mtx to tsv, matcat, metaCat etc
 
 import logging, optparse, io, sys, os, shutil, operator, glob, re, json, subprocess
 from collections import defaultdict, OrderedDict
 
 from .cellbrowser import runGzip, openFile, errAbort, setDebug, moveOrGzip, makeDir, iterItems
 from .cellbrowser import mtxToTsvGz, writeCellbrowserConf, getAllFields, readMatrixAnndata, adataStringFix
 from .cellbrowser import anndataMatrixToTsv, loadConfig, sanitizeName, lineFileNextRow, scanpyToCellbrowser, build
 from .cellbrowser import generateHtmls, getObsKeys, renameFile, getMatrixFormat, generateDataDesc
 from .cellbrowser import copyFileIfDiffSize
+from .cellbrowser import generateQuickGenes
 
 from os.path import join, basename, dirname, isfile, isdir, relpath, abspath, getsize, getmtime, expanduser
 
 def cbToolCli_parseArgs(showHelp=False):
     " setup logging, parse command line arguments and options. -h shows auto-generated help page "
     parser = optparse.OptionParser("""usage: %prog [options] command filenames - convert various single-cell related files
 
 Command is one of:
     mtx2tsv   - convert matrix market to .tsv.gz
     matCatCells - merge expression matrices into a big tsv.gz matrix.
         This command adds more cells. Adds cells on the right side of the matrix.
         If you have files from different cells, same assay, same genes, this
         allows to merge them into a bigger matrix. Format is one-line-per-gene.
         Matrices must have identical genes in the same order and the same number of
         lines. Handles .csv files, otherwise defaults to tab-sep input. gzip OK.
     matCatGenes - concatenate expression matrices. If you have data from the same cells but with different
         genes (assays, multi-modal), this allows to merge them and add a prefix to every gene.
         This command adds more genes. Adds genes to the end of the matrix.
     metaCat - concat/join meta tables on the first (cell ID) field or reorder their fields
     reorder - reorder the meta fields
+    quickgenes - make quickgenes.tsv from markers.tsv in current directory
 
 Examples:
     - %prog mtx2tsv matrix.mtx genes.tsv barcodes.tsv exprMatrix.tsv.gz - convert .mtx to .tsv.gz file
     - %prog matCatCells mat1.tsv.gz mat2.tsv.gz exprMatrix.tsv.gz - merge expression matrices
     - %prog matCatGenes mat1.csv.gz mat2.tsv.gz=atac- exprMatrix.tsv.gz - concatenate expression matrices
            and prefix all genes in the second file with 'atac-'
     - %prog metaCat meta.tsv seurat/meta.tsv scanpy/meta.tsv newMeta.tsv - merge meta matrices
     - %prog reorder meta.tsv meta.newOrder.tsv --del samId --order=cluster,cellType,age - reorder meta fields
     """)
 
     parser.add_option("-d", "--debug", dest="debug", action="store_true",
         help="show debug messages")
     parser.add_option("", "--fixDots", dest="fixDots", action="store_true",
             help="for reorder and metaCat: try to fix R's mangling of various special chars to '.' in the cell IDs")
     parser.add_option("", "--order", dest="order", action="store",
@@ -52,37 +54,37 @@
 
 
     (options, args) = parser.parse_args()
 
     if showHelp:
         parser.print_help()
         exit(1)
 
     setDebug(options.debug)
     return args, options
 
 def cbToolCli():
     " run various tools from the command line "
     args, options = cbToolCli_parseArgs()
 
-    if len(args)<=1:
+    if len(args)<=1 and args[0] != "quickgenes":
         cbToolCli_parseArgs(showHelp=True)
         sys.exit(1)
 
     cmd = args[0]
 
-    cmds = ["mtx2tsv", "matCatCells", "matCatGenes" "metaCat", "reorder", "cxg"]
+    cmds = ["mtx2tsv", "matCatCells", "matCatGenes" "metaCat", "reorder", "cxg", "quickgenes"]
 
     if cmd=="mtx2tsv":
         mtxFname = args[1]
         geneFname = args[2]
         barcodeFname = args[3]
         outFname = args[4]
         mtxToTsvGz(mtxFname, geneFname, barcodeFname, outFname)
     elif cmd=="matCatCells":
         inFnames = args[1:-1]
         outFname = args[-1]
         matCat(inFnames, outFname)
     elif cmd=="matCatGenes":
         inFnames = args[1:-1]
         outFname = args[-1]
         matCatGenes(inFnames, outFname)
@@ -111,30 +113,34 @@
         outFname = args[-1]
 
         if len(inFnames)==0:
             errAbort("You must provide at least two filenames: one input filename and one output filename")
 
         if len(inFnames)==1 and isfile(outFname):
             errAbort("You provided only one input file and the output file already exists. To avoid "
             "accidentally overwriting a file, please either remove the output file or provide at least "
             "three filenames: two input files and one output file. The second input file can be 'none', "
             "which will suppress this error message.")
 
         if len(inFnames)==2 and inFnames[1]=="none":
             inFnames.pop()
 
         metaCat(inFnames, outFname, options)
+
+    elif cmd=="quickgenes":
+        generateQuickGenes(".")
+
     else:
         errAbort("Command %s is not a valid command. Valid commands are: %s" % (cmd, ", ".join(cmds)))
 
 def getLabels(l):
     " given a list of dicts, return a |-sep list of 'label' values "
     labels = []
     for d in l:
         if type(d)==str:
             labels.append(d)
         else:
             labels.append(d["label"])
     return "|".join(labels)
 
 def printRows(iterator, headDone=False):
     " print all rows gotten from an iterator "