Exemple #1
0
def main():
    print('\nRunning copyCaller.py')

    args = parseArgs() 
    varFile = utility.getProgramPath('varScan.jar')
    rScript = utility.getProgramPath('segmentation.R')
    cnFile = '%s/output.cn.call' %(args.outputFolder)

    sTime = utility.startTime()

    adjustment = 0
    correction = 0
    counter = -1

    while not adjustment == 'Centered':
        counter = counter + 1
        correction = correction + adjustment

        copyCall(varFile, 
                 args.inputFile,
                 cnFile,
                 correction)
        removeCommas(cnFile)
        adjustment = runRScript(rScript,
                                cnFile,
                                args.outputFolder)
        
    print('\nFinal correction value is %s' %(str(correction)))
    print('Number of adjustments: %s' %(str(counter)))

    eTime = utility.endTime()
    utility.executionTime(sTime, eTime)
    return
def runCopyNumber(control, tumoral, bed, ref, outFolder, toRun):
    prog = utility.getProgramPath('copyNumber.py')

    cmdList = [prog, '-b', bed, '-r', ref, '-o', outFolder, control, tumoral]
    runCmd('CopyNumber', cmdList, toRun)

    return outFolder + '/output.copynumber'
def runMultipleCopyCall(copyFile, iterations, outFolder, toRun):
    prog = utility.getProgramPath('multipleCopyCall.py')

    cmdList = [prog, '-o', outFolder, copyFile, iterations]
    runCmd('MultipleCopyCall', cmdList, toRun)

    return outFolder + '/copyCalls'
def runGeneFilter(inFile, ref, outFolder, toRun):
    prog = utility.getProgramPath('filterGenes.py')
    outFile = outFolder + '/output.cancer.tsv'

    cmdList = [prog, '-r', ref, '-o', outFile, inFile]
    runCmd('GeneFilter', cmdList, toRun)

    return outFile
def runAnnoteSegments(inFile, annRef, outFolder, toRun):
    prog = utility.getProgramPath('annoteSegments.py')
    outFile = outFolder + '/output.annotated.tsv'

    cmdList = [prog, '-r', annRef, '-o', outFile, inFile]
    runCmd('AnnoteSegments', cmdList, toRun)

    return outFile
def runMergeCopyCalls(ccDir, fileName, threshold, patient, outFolder, toRun):
    prog = utility.getProgramPath('mergeCopyCalls.py')
    filesPath = '%s/*/%s' % (ccDir, fileName)
    outFile = outFolder + '/output.cumulative.tsv'

    cmdList = [prog, '-o', outFile, '-n', patient, filesPath, threshold]
    runCmd('MergeCopyCalls', cmdList, toRun)

    return outFile
def runCopyCall(inFile, outDir):
    prog = utility.getProgramPath('copyCaller.py')

    cmdList = [prog, '-o', outDir, inFile]
    utility.printCmdLine('copyCaller', cmdList)

    subprocess.call(cmdList)
    #runProg = subprocess.Popen(cmdList)
    #runProg.wait()

    return outDir + '/output.r.tsv'
def runMergeSegments(inFile, armRef, maxThreshold, minThreshold, outFolder,
                     toRun):
    prog = utility.getProgramPath('mergeSegments.py')
    outFile = outFolder + '/output.merged.tsv'

    cmdList = [
        prog, '-r', armRef, '-a', maxThreshold, '-d', minThreshold, '-o',
        outFile, inFile
    ]
    runCmd('MergeSegments', cmdList, toRun)

    return outFile
def runCoverageFilter(inFile, control, tumoral, bed, ref, minCov, outFolder,
                      toRun):
    prog = utility.getProgramPath('filterCoverage.py')
    outFile = outFolder + '/output.coverage.tsv'

    cmdList = [
        prog, '-c', control, '-t', tumoral, '-b', bed, '-r', ref, '-m', minCov,
        '-o', outFile, inFile
    ]
    runCmd('CoverageFilter', cmdList, toRun)

    return outFile
def main():
    print('\nRunning copyNumber.py')

    args = parseArgs()
    varFile = utility.getProgramPath('varScan.jar')

    sTime = utility.startTime()

    os.chdir(args.outputFolder)
    pileUpBams(varFile, args.controlFile, args.tumoralFile, args.bedFile,
               args.refFile, args.outputFolder)

    eTime = utility.endTime()
    utility.executionTime(sTime, eTime)
    return
def runAnnoteSegments(inFile, annRef, outDir):
    prog = utility.getProgramPath('annoteSegments.py')
    valOut = outDir + '/output.annotated.tsv'

    cmdList = [prog, '-o', valOut]
    if not annRef == None:
        cmdList.append('-r')
        cmdList.append(annRef)
    cmdList.append(inFile)
    utility.printCmdLine('annoteSegment', cmdList)

    subprocess.call(cmdList)
    #runProg = subprocess.Popen(cmdList)
    #runProg.wait()

    return valOut
def runMergeSegments(inFile, armRef, tMin, tMax, patientId, outDir):
    prog = utility.getProgramPath('mergeSegments.py')
    valOut = outDir + '/output.merged.tsv'

    cmdList = [prog, '-o', valOut, '-n', patientId]
    if not armRef == None:
        cmdList.append('-r')
        cmdList.append(armRef)
    if not tMin == None:
        cmdList.append('-d')
        cmdList.append(str(tMin))
    if not tMax == None:
        cmdList.append('-a')
        cmdList.append(str(tMax))
    cmdList.append(inFile)
    utility.printCmdLine('mergeSegment', cmdList)

    subprocess.call(cmdList)
    #runProg = subprocess.Popen(cmdList)
    #runProg.wait()

    return valOut