Exemplo n.º 1
0
    def snp_and_indel_bcf(self):
        jobs = []
        input_bams = [os.path.join("alignment", sample.name, sample.name + ".sorted.dup.recal.bam") for sample in self.samples]
        nb_jobs = config.param('snp_and_indel_bcf', 'approxNbJobs', required=False, type='int')
        output_directory = "variants/rawBCF"
        bcftools_view_options = "-bvcg"

        if nb_jobs and nb_jobs > 1:
            for region in self.generate_approximate_windows(nb_jobs):
                job = pipe_jobs([
                    samtools.mpileup(input_bams, None, config.param('snp_and_indel_bcf', 'extra_mpileup_options'), region),
                    samtools.bcftools_view("-", os.path.join(output_directory, "allSamples." + region + ".bcf"), bcftools_view_options),
                ])
                job.name = "snp_and_indel_bcf.allSamples." + re.sub(":", "_", region)
                jobs.append(job)
        else:
            job = pipe_jobs([
                samtools.mpileup(input_bams, None, config.param('snp_and_indel_bcf', 'extra_mpileup_options')),
                samtools.bcftools_view("-", os.path.join(output_directory, "allSamples.bcf"), bcftools_view_options),
            ])
            job.name = "snp_and_indel_bcf.allSamples"
            jobs.append(job)
        for job in jobs:
            job.command = "mkdir -p " + output_directory + " && \\\n" + job.command
        return jobs
Exemplo n.º 2
0
    def merge_filter_bcf(self):
        nb_jobs = config.param('snp_and_indel_bcf', 'approxNbJobs', type='int')
        inputs = ["variants/rawBCF/allSamples." + region + ".bcf" for region in self.generate_approximate_windows(nb_jobs)]
        output_file_prefix = "variants/allSamples.merged."

        bcf = output_file_prefix + "bcf"
        job = concat_jobs([
            samtools.bcftools_cat(inputs, bcf),
            samtools.bcftools_view(bcf, output_file_prefix + "flt.vcf")
        ])
        job.name = "merge_filter_bcf"
        return [job]