示例#1
0
    def loadRootJob(self):
        """
        Loads the root job in the current job store.

        :raises toil.job.JobException: If no root job is set or if the root job doesn't exist in
                this job store
        :return: The root job.
        :rtype: toil.jobGraph.JobGraph
        """
        try:
            with self.readSharedFileStream(self.rootJobStoreIDFileName) as f:
                rootJobStoreID = f.read()
        except NoSuchFileException:
            raise JobException('No job has been set as the root in this job store')
        if not self.exists(rootJobStoreID):
            raise JobException("The root job '%s' doesn't exist. Either the Toil workflow "
                               "is finished or has never been started" % rootJobStoreID)
        return self.load(rootJobStoreID)
示例#2
0
def scalpel_single(job, config, name, samples, input_bam):
    """Run Scalpel on an an unmatched tumour sample and call somatic variants
    :param config: The configuration dictionary.
    :type config: dict.
    :param sample: sample name.
    :type sample: str.
    :param input_bam: The input_bam file name to process.
    :type input_bam: str.
    :returns:  str -- The output vcf file name.
    """

    cwd = os.getcwd()
    output_dir = os.path.join(cwd, "{}-scalpel-output".format(name))
    scalpel_vcf = os.path.join(output_dir, "variants.indel.vcf")
    fixed_vcf = "{}.scalpel.vcf".format(name)
    logfile = "{}.scalpel.log".format(name)
    logfile2 = "{}.scalpel_fix.log".format(name)

    scalpel_command = [
        "{}".format(config['scalpel']['bin']),
        "--single",
        "--intarget",
        # "--covthr",
        # "3",
        # "--lowcov",
        # "1",
        "--ref",
        "{}".format(config['reference']),
        "--bed",
        "{}".format(samples[name]['regions']),
        "--format",
        "vcf",
        "--numprocs",
        "{}".format(config['scalpel']['num_cores']),
        "--bam",
        "{}".format(input_bam),
        "--dir",
        "{}".format(output_dir)
    ]

    fix_sample_name_command = [
        "cat", "{}".format(scalpel_vcf), "|", "sed",
        "'s/sample/{}/g'".format(name), ">", "{}".format(fixed_vcf)
    ]

    job.fileStore.logToMaster("Scalpel Command: {}\n".format(scalpel_command))
    run_and_log_command(" ".join(scalpel_command), logfile)

    job.fileStore.logToMaster(
        "Scalpel Fix Command: {}\n".format(fix_sample_name_command))
    run_and_log_command(" ".join(fix_sample_name_command), logfile2)

    file_path = os.path.join(cwd, fixed_vcf)
    if os.path.exists(file_path) and os.path.getsize(file_path) > 0:
        return scalpel_vcf
    else:
        job.fileStore.logToMaster(
            "Scalpel ran into a problem and no output was generated for file {}. Check logfile"
            "{} for details\n".format(scalpel_vcf, logfile))
        return JobException(
            "Scalpel ran into a problem and no output was generated for file {}. Check logfile"
            "{} for details\n".format(scalpel_vcf, logfile))