def getLiftUpBedFile(halPath, genomeName, genomeBedPath, outBedPath): parentName = getParentGenomeName(halPath, genomeName) runShellCommand( "halLiftover %s %s %s %s %s_lotmp" % (halPath, genomeName, genomeBedPath, parentName, outBedPath)) runShellCommand("cat %s_lotmp |sortBed |mergeBed > %s && rm -f %s_lotmp" % (outBedPath, outBedPath, outBedPath))
def getLiftUpBedFile(halPath, genomeName, genomeBedPath, outBedPath): parentName = getParentGenomeName(halPath, genomeName) runShellCommand("halLiftover %s %s %s %s %s_lotmp" % (halPath, genomeName, genomeBedPath, parentName, outBedPath)) runShellCommand("cat %s_lotmp |sortBed |mergeBed > %s && rm -f %s_lotmp" % (outBedPath, outBedPath, outBedPath))
def getHalTreeBackground(halPath, args, rootName=None): root = rootName if root is None: root = getHalRootName(halPath) for child in getHalChildrenNames(halPath, root): bgFile = os.path.join(args.workDir, args.backgroundBedName % child) if args.ar is True: command = "halMaskExtract %s %s --maskFile %s --extend %d --extendPct %f" % (halPath, child, bgFile, args.arExtend, args.arExtendPct) else: command = "halStats %s --bedSequences %s > %s" % (halPath, child, bgFile) print command runShellCommand(command) getHalTreeBackground(halPath, args, child)
def getHalTreeBackground(halPath, args, rootName=None): root = rootName if root is None: root = getHalRootName(halPath) for child in getHalChildrenNames(halPath, root): bgFile = os.path.join(args.workDir, args.backgroundBedName % child) if args.ar is True: command = "halMaskExtract %s %s --maskFile %s --extend %d --extendPct %f" % (halPath, child, bgFile, args.arExtend, args.arExtendPct) else: command = "halStats %s --bedSequences %s > %s" % (halPath, child, bgFile) print(command) runShellCommand(command) getHalTreeBackground(halPath, args, child)
def genomeLength(halPath, genome): command = "halStats %s --bedSequences %s" % (halPath, genome) genomeBed = runShellCommand(command) length = 0 for line in genomeBed.split("\n"): tokens = line.split() if len(tokens) > 2: length += int(tokens[2]) return length
def getSortBed(inBed, outBed=None): if outBed is None: runShellCommand("sortBed -i %s > %s_temp && mv %s_temp %s" % (inBed, inBed, inBed, inBed)) else: runShellCommand("sortBed -i %s > %s" % (inBed, outBed))
def getUnionBed(inBed1, inBed2, outBed): runShellCommand("cat %s %s | sortBed | mergeBed > %s" % (inBed1, inBed2, outBed))
def getSortBed(inBed, outBed = None): if outBed is None: runShellCommand("sortBed -i %s > %s_temp && mv %s_temp %s" % ( inBed, inBed, inBed, inBed)) else: runShellCommand("sortBed -i %s > %s" % (inBed, outBed))
def getIntersectBed(inBed1, inBed2, outBed): runShellCommand("intersectBed -a %s -b %s > %s" % (inBed1, inBed2, outBed))
def getSubtractBed(inBed1, inBed2, outBed): runShellCommand("subtractBed -a %s -b %s > %s" % (inBed1, inBed2, outBed))
def getBranchLength(halPath, genomeName): return float( runShellCommand("halStats %s --branchLength %s" % (halPath, genomeName)).strip("\n"))
def getAlignedBed(halPath, genomeName, outBedPath): runShellCommand("halAlignedExtract %s %s | sortBed | mergeBed> %s" % (halPath, genomeName, outBedPath))
def getBranchLength(halPath, genomeName): return float(runShellCommand("halStats %s --branchLength %s" % ( halPath, genomeName)).strip("\n"))
def getParentGenomeName(halPath, genomeName): return runShellCommand("halStats %s --parent %s" % ( halPath, genomeName)).strip("\n")
def getParentGenomeName(halPath, genomeName): return runShellCommand("halStats %s --parent %s" % (halPath, genomeName)).strip("\n")