c8cf0851df29747fc97ace2912d452ac4d815b45 chmalee Mon Aug 10 06:24:35 2020 -0700 Fixing some problems in clinGenDosage otto job after code review feedback, refs #25996 diff --git src/hg/utils/otto/clinGen/processClinGenDosage.py src/hg/utils/otto/clinGen/processClinGenDosage.py index fe22d0f..be84d97 100755 --- src/hg/utils/otto/clinGen/processClinGenDosage.py +++ src/hg/utils/otto/clinGen/processClinGenDosage.py @@ -53,37 +53,41 @@ print("Only one of regionFile or geneFile can be stdin") sys.exit(1) return args def getColor(bed): """Return the shade of the item according to ClinGen rules. Red or blue for score 3, everything else gray.""" retColors = {"haplo": "128,128,128", "triplo": "128,128,128"} if bed["Haploinsufficiency Score"] == "3": retColors["haplo"] = "255,0,0" if bed["Triplosensitivity Score"] == "3": retColors["triplo"] = "0,0,255" return retColors def getMouseover(bed): """Return the mouseOver strings for this bed record.""" hapScore = bed["Haploinsufficiency Score"] + if not hapScore or hapScore == "Not yet evaluated": + hapScore = -1 tripScore = bed["Triplosensitivity Score"] + if not tripScore or tripScore == "Not yet evaluated": + tripScore = -1 ret = {"haplo": "", "triplo": ""} mouseOver = "Gene/ISCA ID: %s" % bed["name"] ret["triplo"] = mouseOver + ", Triplosensitivity: " - ret["triplo"] += "%s - %s" % (tripScore, scoreExplanation[int(tripScore)] if tripScore and tripScore != "Not yet evaluated" else -1) + ret["triplo"] += "%s - %s" % (tripScore, scoreExplanation[int(tripScore)]) ret["haplo"] = mouseOver + ", Haploinsufficiency: " - ret["haplo"] += "%s - %s" % (hapScore, scoreExplanation[int(hapScore)] if hapScore and hapScore != "Not yet evaluated" else -1) + ret["haplo"] += "%s - %s" % (hapScore, scoreExplanation[int(hapScore)]) return ret def parsePosition(posStr): """Turn a chr:start-stop string into bed chrom, chromStart, chromEnd""" try: colonDelim = posStr.split(":") chrom = colonDelim[0] dashDelim = colonDelim[1].split("-") start = int(dashDelim[0]) - 1 end = int(dashDelim[1]) except IndexError: sys.stderr.write("bad position string: %s\n" % posStr) sys.exit(1) return (chrom, start, end) @@ -185,31 +189,33 @@ triploBed += [bed[field] for field in triploFields] + [bed ["_mouseOver"]["triplo"]] print("\t".join(haploBed), file=haploFile) print("\t".join(triploBed), file=triploFile) haploFile.close() triploFile.close() def parseOmim(infh): with open(infh) as f: for line in f: omimId,phenotype = line.strip().split('\t') omimData[omimId] = phenotype def parseInFile(fname, fileType="gene"): if fname != "stdin": f = open(fname) - lineNumber = 1 + else: + f = sys.stdin + lineNumber = 0 for line in f: lineNumber += 1 bizarreRecord = False if line.startswith("#"): continue l = line.strip("\n").split("\t") key = l[0] # geneSymbol or ISCA id extra = l[1:] if key in inData: print("duplicate info for gene symbol: '%s'" % (geneSymbol)) sys.exit(1) else: temp = {} fileFields = [] if fileType == "gene":