def run(self): self.warning('Analysing file: %s' % self.param_required('filepath')) filepath = self.param_required('filepath') vcf = BCFTools(vcf=filepath, bcftools_folder=self.param_required('bcftools_folder')) outprefix = "" if self.param_is_defined('work_dir'): file = os.path.split(filepath)[1] outprefix = self.param('work_dir') + "/" + file else: outprefix = filepath uncalled = None if self.param_is_defined('uncalled'): uncalled = self.param('uncalled') if uncalled != 'include' and uncalled != 'exclude': raise Exception( "Valid 'uncalled' values are 'include'/'exclude'") threads = 1 if self.param_is_defined('threads'): threads = self.param('threads') outfile = vcf.select_variants(outprefix=outprefix, threads=threads, uncalled=uncalled) self.param('out_vcf', outfile)
def run(self): self.warning('Analysing file: %s'% self.param_required('filepath')) vcf = BCFTools(vcf=self.param_required('filepath'), bcftools_folder=self.param_required('bcftools_folder')) outvcf = vcf.filter(name=self.param_required('filter_name'), expression=self.param_required('filter_expression')) self.param('out_vcf', outvcf)
def run(self): self.warning('Analysing file: %s' % self.param_required('filepath')) filepath = self.param_required('filepath') vcf = BCFTools(vcf=filepath, bcftools_folder=self.param_required('bcftools_folder')) outprefix = "" if self.param_is_defined('work_dir'): file = os.path.split(filepath)[1] outprefix = self.param('work_dir') + "/" + file else: outprefix = filepath biallelic = None if self.param_is_defined('biallelic'): if self.param('biallelic') == "True": biallelic = True elif self.param('biallelic') == "False": biallelic = False else: raise Exception( "Error. biallelic option should be True or False") compress = True if self.param_is_defined('compress'): if self.param('compress') == "True": compress = True elif self.param('compress') == "False": compress = False else: raise Exception( "Error. compress option should be True or False") outfile = vcf.filter_by_variant_type( v_type=self.param_required('type'), outprefix=outprefix, biallelic=biallelic, compress=compress) self.param('out_vcf', outfile)
def run(self): self.warning('Split file: %s' % self.param_required('filepath')) ifile = self.param_required('filepath') file = os.path.split(ifile)[1] outdir = self.param_required('work_dir') faix = self.param_required('faix') verbose = None if self.param_is_defined('verbose'): verbose = self.__str_to_bool(self.param('verbose')) filt_string = None if self.param_is_defined('filt_string'): filt_string = self.param('filt_string') bcftools_o = BCFTools(vcf=ifile, bcftools_folder=self.param('bcftools_folder')) files = [] ix = 1 for line in open(faix): if line.startswith("\n"): continue chrom = line.split('\t')[0] self.warning('Splitting %s' % chrom) chr_folder = outdir + "/" + chrom if not os.path.isdir(chr_folder): os.mkdir(chr_folder) vcffile = bcftools_o.subset_vcf(region=chrom, outprefix=file, outdir=chr_folder, create_index=True, apply_filters=filt_string, threads=self.param('threads'), action='include', verbose=verbose) files.append({'chr': vcffile, 'ix': ix, 'chromname': chrom}) ix += 1 self.param('files', files)
def run(self): filepath = self.param('filepath') file = os.path.split(filepath)[1] work_dir = os.path.split(filepath)[0] if self.param_is_defined('work_dir'): work_dir = self.param('work_dir') self.warning('Analysing file: %s' % filepath) if self.param('verbose') == "True": print("Workdir is %s" % work_dir) vcfFilter = BCFTools(vcf=filepath, bcftools_folder=self.param('bcftools_folder')) vcffile = vcfFilter.subset_vcf(bed=self.param_required('bed'), outprefix=file + ".exc.vcf.gz", outdir=work_dir, create_index=True, threads=self.param('threads'), action=self.param('action')) self.param('subset_file', vcffile) self.param('subset_file_ix', vcffile + '.tbi')
def vcf_object(): '''Returns an object''' vcf_file = pytest.config.getoption("--vcf") bcftools_folder = pytest.config.getoption("--bcftools_folder") vcf_object = BCFTools(vcf=vcf_file, bcftools_folder=bcftools_folder) return vcf_object