9b025ae8f9ec2c72f1c7d72e2b3b9c25be099e05
jnavarr5
  Tue Jun 11 11:46:05 2024 -0700
Adding a usage statement to the updateJaspar.py script. Now prints the usage statement when no arguments are given and runs the script when using a -e flag to run the script. refs #32537

diff --git src/utils/qa/jasparUpdate.py src/utils/qa/jasparUpdate.py
index fe87711..41ebb28 100755
--- src/utils/qa/jasparUpdate.py
+++ src/utils/qa/jasparUpdate.py
@@ -1,25 +1,37 @@
 #!/usr/bin/python3
+"""
+Program to automate the update of the JASPAR tracks for mm10, mm39, hg19, and hg38.
+Builds shared trackDb stanza based on hg38's trackDb and writes to a file (jaspar.ra).
+Downloads all files to the current directory (bigBeds and HTML).
+Creates a file with the steps to complete the update (updateSteps.txt).
+
+Assumptions:
+   * Shared HTML, PFMs, and bigBeds are all obtained from:
+     https://frigg.uio.no/JASPAR/JASPAR_genome_browser_tracks/current/
+"""
 import argparse
 import sys
 import subprocess
 from io import BytesIO
 from zipfile import ZipFile
 from urllib.request import urlopen
 from ucscGb.qa.tables import trackUtils
 from ucscGb.qa import qaUtils
 
+
+
 def bash(cmd):
     """Run the cmd in bash subprocess"""
     try:
         rawBashOutput = subprocess.run(cmd, check=True, shell=True,\
                                        stdout=subprocess.PIPE, universal_newlines=True, stderr=subprocess.STDOUT)
         bashStdoutt = rawBashOutput.stdout
     except subprocess.CalledProcessError as e:
         raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
     return (bashStdoutt)
 
 def download(URL):
     '''
     Generic command to wget a URL and prints the command to STDOUT.
     '''
     cmd = "wget %s" % URL
@@ -115,38 +127,59 @@
         elif setting == "html": #skip the HTML section for now
             continue
         elif setting == "bigDataUrl": # Make the bigDataUrl point to /gbdb
             #download file
             path = "/gbdb/$D/jaspar/JASPAR%s.bb" % year
             newTrackDb.append([setting, path])
         elif setting == "filterValues.name":
             # test to make sure the filters are in alphebetical order
             sortedFilter = sorted(value.split(","), key=str.casefold)
             newTrackDb.append([setting, ",".join(sortedFilter)])
         else:
             newTrackDb.append([setting,value])
 
     return newTrackDb
 
+def get_options():
+    '''
+    Parses the command line options
+    '''
+    parser = argparse.ArgumentParser(description=__doc__,
+                                     formatter_class=argparse.RawDescriptionHelpFormatter,
+                                     usage="%(prog)s -e")
+    parser.add_argument('-e', '--execute', action='store_true',
+                        help='Flag to run the program')
+    if len(sys.argv)==1:  # if no arguments are given, print the usage statment
+        parser.print_help(sys.stderr)
+        sys.exit(1)
+
+    options =  parser.parse_args()
+
+    if not options.execute: # if you do not specify the execute flag, print the usage statment
+        parser.print_help(sys.stderr)
+
 def main(args):
     '''
     Program to automate the update of the JASPAR tracks for mm10, mm39, hg19, and hg38.
 
     Assumptions:
        * Shared HTML, PFMs, and bigBeds are all obtained from:
          https://frigg.uio.no/JASPAR/JASPAR_genome_browser_tracks/current/
     '''
+    
+    get_options() # Parse the user's command line arguenments. 
+
     # Setting some definitions
     assemblies= ["hg19", "hg38", "mm10", "mm39"]
     # Any broken links in the script can be fixed below.
     currentAddress = "https://frigg.uio.no/JASPAR/JASPAR_genome_browser_tracks/current/"
     PFMs = currentAddress + "PFMs.zip"
     sharedHtml = currentAddress + "JASPAR2024_TFBS_help.html"
     bigBedUrl = currentAddress + "%s/JASPAR2024_%s.bb"
 
     #################################################################
     #                           Build trackDb                       #
     #################################################################
     print ("########################################################")
     print ("#            Creating the new trackDb stanza           #")
     print ("########################################################")
     newTrackDb = buildTrackDb("hg38") #container for all trackDb settings