564d7150acdd107cf31883feece7c11098d33740 max Wed Oct 30 21:58:37 2019 -0700 making chromFixer py3 compatible, refs #24407 diff --git src/utils/chromFixer/chromFixer src/utils/chromFixer/chromFixer index f077e7f..bbf8216 100755 --- src/utils/chromFixer/chromFixer +++ src/utils/chromFixer/chromFixer @@ -1,23 +1,26 @@ #!/usr/bin/env python -import logging, optparse, gzip, StringIO +import logging, optparse, gzip from sys import stdin, stdout, stderr, exit -# support both py2 and py3 try: - from urllib.request import urlopen + from urllib.request import urlopen # py2 except ImportError: - from urllib2 import urlopen + from urllib2 import urlopen # py3 +try: + from cStringIO import StringIO # py2 +except ImportError: + from io import StringIO # py3 # ==== functions ===== def parseArgs(): " setup logging, parse command line arguments and options. -h shows auto-generated help page " parser = optparse.OptionParser("""usage: %prog [options] filename - change NCBI or Ensembl chromosome names to UCSC names using the chromAlias table of the genome browser. Examples: %prog -i test.bed -o test.ucsc.bed -g hg19 %prog -g mm10 --get %prog -i test2.bed -o test2.ucsc.bed -a mm10.chromAlias.tsv cat test.bed | %prog -a mm10.chromAlias.tsv > test.ucsc.edb """) parser.add_option("-g", "--genomeDb", dest="db", action="store", help="a UCSC assembly ID, like hg19, mm10 or similar. Not required if -a is used.") parser.add_option("-a", "--chromAlias", dest="aliasFname", action="store", help="a UCSC chromAlias table in tab-sep format.")