Ejemplo n.º 1
0
    def run(self):

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

        VcfFilterO = GATK(vcf=self.param_required('filepath'),
                          caller=self.param_required('caller'),
                          gatk_folder=self.param_required('gatk_folder'),
                          reference=self.param_required('reference'),
                          bgzip_folder=self.param('bgzip_folder'),
                          tabix_folder=self.param('tabix_folder'),
                          tmp_dir=self.param('tmp_dir'))

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

        outprefix = None
        filename = os.path.split(self.param_required('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(self.param_required('filepath'))[0]
        outprefix = "{0}/{1}".format(work_dir, filename)

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

        log_file = None
        if self.param_is_defined('log_file'):
            log_file = "{0}_{1}.log".format(self.param('log_file'),
                                            time.strftime("%Y%m%d_%H%M%S"))

        outfile = VcfFilterO.run_applyrecalibration(
            mode=self.param_required('mode'),
            recal_file=self.param_required('recal_file'),
            ts_filter_level=ts_filter_level,
            tranches_file=self.param_required('tranches_file'),
            num_threads=threads,
            outprefix=outprefix,
            log_file=log_file)

        self.param('vcf_filt', outfile)
        self.param('vcf_filt_ix', outfile + ".tbi")
Ejemplo n.º 2
0
def vcf_object():
    '''Returns an  object'''
    vcf_file = pytest.config.getoption("--vcf")
    gatk_folder = pytest.config.getoption("--gatk_folder")
    reference = pytest.config.getoption("--reference")
    vcf_object = GATK(vcf=vcf_file,
                      gatk_folder=gatk_folder,
                      reference=reference)
    return vcf_object
Ejemplo n.º 3
0
def test_applyrecalibration_tmpdir(clean_tmp):
    '''
    Test method to run ApplyRecalibration by setting the tmp_dir for Java.
    This test throw an error because the 'recal_file' and 'tranches_file' files are fictitious
    '''

    vcf_file = pytest.config.getoption("--vcf")
    gatk_folder = pytest.config.getoption("--gatk_folder")
    reference = pytest.config.getoption("--reference")
    vcf_object = GATK(vcf=vcf_file,
                      gatk_folder=gatk_folder,
                      reference=reference,
                      tmp_dir='data/tmp')

    with pytest.raises(Exception):
        vcf_object.run_applyrecalibration(mode='SNP',
                                          recal_file='data/test.recal',
                                          tranches_file='data/test.tranches',
                                          outprefix='data/outdir/test',
                                          compress=False,
                                          verbose=True)
Ejemplo n.º 4
0
    def run(self):

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

        vcf = GATK(vcf=self.param_required('filepath'),
                   caller=self.param_required('caller'),
                   gatk_folder=self.param_required('gatk_folder'),
                   reference=self.param_required('reference'))

        optional_params = {}
        if self.param_is_defined('annotations'):
            optional_params['annotations'] = self.param('annotations')
        if self.param_is_defined('intervals'):
            optional_params['intervals'] = self.param('intervals')
        if self.param_is_defined('max_gaussians'):
            optional_params['max_gaussians'] = self.param('max_gaussians')
        if self.param_is_defined('tranches'):
            optional_params['tranches'] = self.param('tranches')

        verbose = False
        if self.param_is_defined('verbose'):
            verbose = True

        log_file = None
        if self.param_is_defined('log_file'):
            log_file = "{0}_{1}.log".format(self.param('log_file'),
                                            time.strftime("%Y%m%d_%H%M%S"))

        d_out = vcf.run_variantrecalibrator(
            self.param_required('resources'),
            mode=self.param_required('mode'),
            outprefix=self.param_required('filepath'),
            verbose=verbose,
            log_file=log_file,
            **optional_params)

        self.param('recal_f', d_out['recal_f'])
        self.param('tranches_f', d_out['tranches_f'])