예제 #1
0
    def customize(cls, reference, infiles, outfile, options, dependencies= ()):
        assert outfile.lower().endswith('.vcf')
       
        # Create the pileup command 
        pileup = AtomicCmdBuilder(
            ['samtools','mpileup'],
            IN_REFERENCE = reference,
            OUT_STDOUT   = AtomicCmd.PIPE,
            CHECK_SAM    = SAMTOOLS_VERSION
        )
        pileup.set_option('-u') # uncompressed output
        pileup.set_option('-r','chrUn2:1-19214051')
        pileup.set_option('-f', "%(IN_REFERENCE)s") # Add reference option

        
        for bam in infiles:
            pileup.add_option(bam)

        # Create variant caller command
        bcftools = AtomicCmdBuilder(
                ['bcftools','view'],
                IN_STDIN = pileup,
                OUT_STDOUT = outfile
        )
        bcftools.set_option('-v') # output potential variant sites
        bcftools.set_option('-c') # SNP calling
        bcftools.set_option('-g') # call genotypes at vairant sites
        bcftools.set_option('-')  # STDIN

        return {
            "commands" : {
                "pileup" : pileup,
                "bcftools" : bcftools, 
            }
        }
예제 #2
0
 def customize(cls, reference, infile, outfile, filters, options, dependencies = ()):
     # filter reads
     percentile = str(options.makefile['vcf_percentile_threshold'])
     flt = AtomicCmdBuilder(['vcf_qual_percentile'],
         IN_VCF = infile,
         OUT_VCF = outfile
     )
     for key,val in filters.items():
         flt.add_option(key,val)
     flt.set_option('--out','%(OUT_VCF)s')
     flt.add_option(infile)
     return {
         'commands':{
             'Filter': flt
         }
     }
예제 #3
0
def test_builder__finalize__calls_atomiccmd():
    was_called = []
    class _AtomicCmdMock:
        def __init__(self, *args, **kwargs):
            assert_equal(args, (["echo", "-out", "%(OUT_FILE)s", "%(IN_FILE)s"],))
            assert_equal(kwargs, {"IN_FILE" : "/in/file", "OUT_FILE" : "/out/file", "set_cwd" : True})
            was_called.append(True)

    with Monkeypatch("pypeline.atomiccmd.builder.AtomicCmd", _AtomicCmdMock):
        builder = AtomicCmdBuilder("echo", set_cwd = True)
        builder.add_option("-out", "%(OUT_FILE)s")
        builder.add_value("%(IN_FILE)s")
        builder.set_kwargs(OUT_FILE = "/out/file",
                           IN_FILE  = "/in/file")

        builder.finalize()
        assert was_called
예제 #4
0
def test_builder__add_option__overwrite():
    builder = AtomicCmdBuilder("find")
    builder.add_option("-name", "*.txt")
    builder.add_option("-or")
    builder.add_option("-name", "*.bat")
    assert_equal(builder.call,
                 ["find", "-name", "*.txt", "-or", "-name", "*.bat"])
예제 #5
0
def test_builder__finalize__calls_atomiccmd():
    was_called = []

    class _AtomicCmdMock:
        def __init__(self, *args, **kwargs):
            assert_equal(args,
                         (["echo", "-out", "%(OUT_FILE)s", "%(IN_FILE)s"], ))
            assert_equal(kwargs, {
                "IN_FILE": "/in/file",
                "OUT_FILE": "/out/file",
                "set_cwd": True
            })
            was_called.append(True)

    with Monkeypatch("pypeline.atomiccmd.builder.AtomicCmd", _AtomicCmdMock):
        builder = AtomicCmdBuilder("echo", set_cwd=True)
        builder.add_option("-out", "%(OUT_FILE)s")
        builder.add_value("%(IN_FILE)s")
        builder.set_kwargs(OUT_FILE="/out/file", IN_FILE="/in/file")

        builder.finalize()
        assert was_called
예제 #6
0
    def customize(cls, groups, prefix, options, dependencies = ()):
        # Merge the VCF files
        merge_vcf = AtomicCmdBuilder(['vcf_merge'], OUT_VCF = "merged.vcf")
        for group in groups:
            vcf_file = os.path.join(options.makefile['RecalDir'],
                'gatk.{}.{}.raw.recal_final.vcf'.format(group,prefix)
            )
            merge_vcf.add_option("-i",vcf_file)
        merge_vcf.add_option("-o", '%(OUT_VCF)s')
    

        # Create the snp list
        snp_list = AtomicCmdBuilder(['vcf_snp_list'])
        snp_list.add_option('--recal_dir',options.makefile['RecalDir'])
        snp_list.add_option('')
        return {
            'commands' : {
                'merge' : merge_vcf,
                'Snp' : snp_list
            }
        }
예제 #7
0
def test_builder__pop_option__last_option():
    builder = AtomicCmdBuilder("find")
    builder.add_option("-size", "0", fixed=False)
    builder.add_option("-size", "1", fixed=False)
    builder.pop_option("-size")
    assert_equal(builder.call, ["find", "-size", "0"])
예제 #8
0
def test_builder__pop_option__last_option():
    builder = AtomicCmdBuilder("find")
    builder.add_option("-size", "0", fixed = False)
    builder.add_option("-size", "1", fixed = False)
    builder.pop_option("-size")
    assert_equal(builder.call, ["find", "-size", "0"])
예제 #9
0
def test_builder__add_option__overwrite():
    builder = AtomicCmdBuilder("find")
    builder.add_option("-name", "*.txt")
    builder.add_option("-or")
    builder.add_option("-name", "*.bat")
    assert_equal(builder.call, ["find", "-name", "*.txt", "-or", "-name", "*.bat"])