Пример #1
0
    def run(self):

        vcf_paths = self.param_required('allfiles2combine')
        labels = self.param_required('alldatasets2combine')

        vcf_utils = VcfUtils(
            vcflist=vcf_paths,
            bcftools_folder=self.param_required('bcftools_folder'),
            gatk_folder=self.param_required('gatk_folder'),
            tmp_dir=self.param('tmp_dir'))

        ginterval = None
        if self.param_is_defined('ginterval'):
            ginterval = self.param('ginterval')

        outfile = vcf_utils.combine(
            labels=labels,
            reference=self.param_required('reference'),
            threads=self.param_required('threads'),
            outprefix=self.param_required('outprefix'),
            outdir=self.param_required('work_dir'),
            compress=True,
            genotypemergeoption='UNIQUIFY',
            ginterval=ginterval,
            options=['-env', '-sites_only', '--filteredAreUncalled'])
        self.param('out_vcf', outfile)
Пример #2
0
    def run(self):
        filepath = self.param_required('filepath')

        self.warning('Analysing file: %s' % filepath)

        if not os.path.isdir(self.param_required('work_dir')):
            os.makedirs(self.param_required('work_dir'))

        threads = 1
        if self.param_is_defined('threads'):
            threads = self.param('threads')

        outprefix = os.path.split(self.param_required('outprefix'))[1]

        outfile = "{0}/{1}.GL.vcf.gz".format(self.param_required('work_dir'),
                                             outprefix)

        vcf_object = VcfUtils(
            vcf=filepath,
            bcftools_folder=self.param_required('bcftools_folder'))

        vcf_file = vcf_object.convert_PL2GL(outfile,
                                            threads=threads,
                                            verbose=True)

        self.param('out_vcf', vcf_file)
Пример #3
0
    def run(self):
        filepath = self.param_required('filepath')

        self.warning('Analysing file: %s' % filepath)

        basename = os.path.split(filepath)[1]
        work_dir = None
        if self.param_is_defined('work_dir'):
            if not os.path.isdir(self.param('work_dir')):
                os.makedirs(self.param('work_dir'))
            work_dir = self.param('work_dir')
        else:
            work_dir = os.path.split(filepath)[0]

        vcf_object = VcfUtils(vcf=filepath,
                              bgzip_folder=self.param('bgzip_folder'))

        outprefix = "{0}/{1}".format(
            work_dir,
            basename + ".{0}".format(self.param_required('chr_types')))

        outfile = vcf_object.rename_chros(
            chr_types=self.param_required('chr_types'),
            outfile=outprefix + ".vcf.gz")

        self.param('vcf_f', outfile)
Пример #4
0
def test_convert_PL2GL(clean_tmp):
    '''
    Test the method change PL fields to GL in a VCF file
    '''
    vcf_object=VcfUtils(vcf='data/test.gatk.vcf.gz',
                        bcftools_folder=pytest.config.getoption("--bcftools_folder"))
    
    vcf_object.convert_PL2GL(outfile='data/outdir/test.gatk.GL.vcf.gz',verbose=True)

    assert os.path.exists("data/outdir/test.gatk.GL.vcf.gz")
Пример #5
0
def vcf_ambiguity():
    '''
    Returns a VcfUtils object that contains the REF or ALT column with some ambiguity codes
    '''
    vcf_file = pytest.config.getoption("--vcf_ambiguity")
    vcf_object = VcfUtils(vcf=vcf_file)
    return vcf_object
Пример #6
0
    def run(self):

        filepath = self.param_required('filepath')
        newheader = self.param_required('newheader')

        self.warning('Analysing file: %s' % filepath)

        basename = os.path.split(filepath)[1]
        work_dir = None
        if self.param_is_defined('work_dir'):
            work_dir = self.param_required('work_dir')
        else:
            work_dir = os.path.split(filepath)[0]

        vcf_object = VcfUtils(
            vcf=filepath,
            bcftools_folder=self.param_required('bcftools_folder'))

        outprefix = "{0}/{1}".format(work_dir, basename)

        outfile = ""

        if self.param_is_defined('samplename'):
            samplename = self.param('samplename')

            try:
                tfile = tempfile.NamedTemporaryFile(mode='w', dir='data/')
                tfile.write(samplename + "\n")
                tfile.flush()
                outfile = vcf_object.reheader(
                    newheader=self.param_required('newheader'),
                    samplefile=tfile.name,
                    outprefix=outprefix)
            finally:
                # Automatically cleans up the file
                tfile.close()
        elif self.param_is_defined('samplefile'):
            outfile = vcf_object.reheader(
                newheader=self.param_required('newheader'),
                samplefile=self.param('samplefile'),
                outprefix=outprefix)
        else:
            outfile = vcf_object.reheader(
                newheader=self.param_required('newheader'),
                outprefix=outprefix)

        self.param('vcf_f', outfile)
Пример #7
0
def vcf_object():
    '''Returns an  object'''

    vcf_file = pytest.config.getoption("--vcf")
    vcflist = pytest.config.getoption("--vcflist")
    bcftools_folder = pytest.config.getoption("--bcftools_folder")
    bgzip_folder = pytest.config.getoption("--bgzip_folder")
    gatk_folder = pytest.config.getoption("--gatk_folder")
    vcf_object=VcfUtils(vcf=vcf_file,bgzip_folder=bgzip_folder,vcflist=vcflist,bcftools_folder=bcftools_folder,
                        gatk_folder=gatk_folder)
    return vcf_object
Пример #8
0
def test_change_chrnames_2ucsc():
    '''
    Test the method to change the style of the chrnames (from Ensembl to UCSC)
    '''
    vcf_object=VcfUtils(vcf='data/outdir/test.ensembl.vcf.gz',
                        bgzip_folder=pytest.config.getoption("--bgzip_folder"))

    vcf_object.rename_chros(chr_types='ucsc', outfile='data/outdir/test.ucsc.vcf.gz')
    vcf_object.rename_chros(chr_types='ucsc', outfile='data/outdir/test.ucsc.vcf', compress=False)
    
    assert os.path.exists("data/outdir/test.ucsc.vcf.gz")
    assert os.path.exists("data/outdir/test.ucsc.vcf")