if len(sys.argv) == 1: print "Path to place chromInfo tables must be specified." sys.exit(1) dbpath = sys.argv[1] builds = [] if len(sys.argv) > 2: try: buildfile = fileinput.FileInput(sys.argv[2]) for line in buildfile: if line.startswith("#"): continue builds.append(line.split("\t")[0]) except: print "Bad input file." sys.exit(1) else: try: for build in parse_builds.getbuilds("http://genome-test.cse.ucsc.edu/cgi-bin/das/dsn"): builds.append(build[0]) except: print "Unable to retrieve builds." sys.exit(1) for build in builds: if build == "?": continue # no lengths for unspecified chrom outfile = open(dbpath + build + ".len", "w") print "Retrieving " + build for chrominfo in getchrominfo("http://genome-test.cse.ucsc.edu/cgi-bin/hgTables?", build): print >> outfile, "\t".join(chrominfo) outfile.close()
if len(sys.argv) == 1: sys.exit("Path to place chromInfo tables must be specified.") dbpath = sys.argv[1] builds = [] if len(sys.argv) > 2: try: buildfile = fileinput.FileInput(sys.argv[2]) for line in buildfile: if line.startswith("#"): continue builds.append(line.split("\t")[0]) except: sys.exit("Bad input file.") else: try: for build in parse_builds.getbuilds("http://genome.cse.ucsc.edu/cgi-bin/das/dsn"): builds.append(build[0]) except: sys.exit("Unable to retrieve builds.") for build in builds: if build == "?": continue # no lengths for unspecified chrom print("Retrieving " + build) outfile_name = dbpath + build + ".len" try: with open(outfile_name, "w") as outfile: for chrominfo in getchrominfo("http://genome-test.cse.ucsc.edu/cgi-bin/hgTables?", build): print("\t".join(chrominfo), file=outfile) except Exception as e: print("Failed to retrieve %s: %s" % (build, e)) os.remove(outfile_name)