def command(self): regions_file = "{scratch}/{uuid}.regions".format(scratch=self.scratch, uuid=uuid.uuid4()) bed_to_regions_cmd = "cat {} | bed_to_regions.py > {}".format( self.target_bed, regions_file) call_somatic_cmd = " | {} -c 'from autoseq.util.bcbio import call_somatic; import sys; print call_somatic(sys.stdin.read())' ".format( sys.executable) freebayes_cmd = "freebayes-parallel {} {} ".format(regions_file, self.threads) + \ required("-f ", self.reference_sequence) + " --use-mapping-quality " + \ optional("--min-alternate-fraction ", self.min_alt_frac) + \ optional("--min-coverage ", self.min_coverage) + \ conditional(self.use_harmonic_indel_quals, "--harmonic-indel-quality") + \ optional("", self.params) + \ repeat(" ", self.input_bams) + \ """| bcftools filter -i 'ALT="<*>" || QUAL > 5' """ + \ "| filter_erroneus_alt.py -V /dev/stdin " + \ conditional(self.somatic_only, call_somatic_cmd) + \ " | " + vt_split_and_leftaln(self.reference_sequence) + \ " | vcfuniq | bcftools view --apply-filters .,PASS " + \ " | bgzip > {output} && tabix -p vcf {output}".format(output=self.output) # reason for 'vcfuniq': freebayes sometimes report duplicate variants that need to be uniqified. rm_regions_cmd = "rm {}".format(regions_file) return " && ".join([bed_to_regions_cmd, freebayes_cmd, rm_regions_cmd])
def command(self): required("", self.input_tumor) required("", self.input_normal) freq_filter = ( " bcftools filter -e 'STATUS !~ \".*Somatic\"' 2> /dev/null " "| %s -c 'from autoseq.util.bcbio import depth_freq_filter_input_stream; import sys; print depth_freq_filter_input_stream(sys.stdin, %s, \"%s\")' " % (sys.executable, 0, 'bwa')) somatic_filter = ( " sed 's/\\.*Somatic\\\"/Somatic/' " # changes \".*Somatic\" to Somatic "| sed 's/REJECT,Description=\".*\">/REJECT,Description=\"Not Somatic via VarDict\">/' " "| %s -c 'from autoseq.util.bcbio import call_somatic; import sys; print call_somatic(sys.stdin.read())' " % sys.executable) blacklist_filter = " | intersectBed -a . -b {} | ".format( self.blacklist_bed) cmd = "vardict-java " + required("-G ", self.reference_sequence) + \ optional("-f ", self.min_alt_frac) + \ required("-N ", self.tumorid) + \ optional("-r ", self.min_num_reads) + \ " -b \"{}|{}\" ".format(self.input_tumor, self.input_normal) + \ " -c 1 -S 2 -E 3 -g 4 -Q 10 " + required("", self.target_bed) + \ " | testsomatic.R " + \ " | var2vcf_paired.pl -P 0.9 -m 4.25 -M " + required("-f ", self.min_alt_frac) + \ " -N \"{}|{}\" ".format(self.tumorid, self.normalid) + \ " | " + freq_filter + " | " + somatic_filter + " | " + fix_ambiguous_cl() + " | " + remove_dup_cl() + \ " | vcfstreamsort -w 1000 " + \ " | " + vt_split_and_leftaln(self.reference_sequence) + \ " | bcftools view --apply-filters .,PASS " + \ " | vcfsorter.pl {} /dev/stdin ".format(self.reference_dict) + \ conditional(blacklist_filter, self.blacklist_bed) + \ " | bgzip > {output} && tabix -p vcf {output}".format(output=self.output) return cmd
def command(self): # activating conda env activate_cmd = "source activate purecn-env" # running PureCN running_cmd = "PureCN.R " + required("--out ", self.outdir) + \ required("--sampleid ", self.tumorid) + \ required("--segfile ", self.input_seg) + \ required("--tumor ", self.input_cnr) + \ required("--vcf ", self.input_vcf) + \ required("--genome ", self.genome) + \ optional("--funsegmentation ", self.funseg) + \ optional("--minpurity ", self.minpurity) + \ optional("--hzdev ", self.hzdev) + \ optional("--maxnonclonal ", self.maxnonclonal) + \ optional("--minaf ", self.minaf) + \ optional("--error ", self.error) + \ conditional(self.postopt, "--postoptimize") # deactivating the conda env deactivate_cmd = "conda deactivate" # touching required output files touch_cmd = "touch {} {} {} {}".format(self.out_csv, self.out_genes, self.out_variants, self.output) return " && ".join( [activate_cmd, running_cmd, deactivate_cmd, touch_cmd])
def command(self): return "picard -Xmx5g -XX:ParallelGCThreads=1 " + \ required("-Djava.io.tmpdir=", self.scratch) + \ " MarkDuplicates " + \ required("INPUT=", self.input_bam) + \ required("METRICS_FILE=", self.output_metrics) + \ required("OUTPUT=", self.output_bam) + \ conditional(self.remove_duplicates, "REMOVE_DUPLICATES=true") + \ " && samtools index " + required("", self.output_bam)
def command(self): return "gatk-klevebring -T HeterozygoteConcordance " + \ required("-R ", self.reference_sequence) + \ required("-V ", self.input_vcf) + \ required("-I ", self.input_bam) + \ required("-sid ", self.normalid) + \ optional("-L ", self.target_regions) + \ conditional(self.filter_reads_with_N_cigar, "--filter_reads_with_N_cigar") + \ required("-o ", self.output)
def command(self): if not self.reference and not self.targets_bed: raise ValueError("Either reference or targets_bed must be supplied") if self.reference and self.targets_bed: raise ValueError("Supply either reference OR targets_bed") tmpdir = "{}/cnvkit-{}".format(self.scratch, uuid.uuid4()) sample_prefix = stripsuffix(os.path.basename(self.input_bam), ".bam") cnvkit_cmd = "cnvkit.py batch " + required("", self.input_bam) + \ optional("-r ", self.reference) + \ conditional(self.targets_bed, "--fasta " + str(self.fasta) + " --split ") + \ conditional(self.targets_bed, "-n") + \ optional("-t ", self.targets_bed) + \ required("-d ", tmpdir) copy_cns_cmd = "cp {}/{}.cns ".format(tmpdir, sample_prefix) + required(" ", self.output_cns) copy_cnr_cmd = "cp {}/{}.cnr ".format(tmpdir, sample_prefix) + required(" ", self.output_cnr) rm_cmd = "rm -r {}".format(tmpdir) return " && ".join([cnvkit_cmd, copy_cns_cmd, copy_cnr_cmd, rm_cmd])
def command(self): tmpdir = "{}/write-alascca-report-{}".format(self.scratch, uuid.uuid4()) mkdir_tmp_cmd = "mkdir -p {}".format(tmpdir) tmp_pdf = os.path.join(tmpdir, 'Report.pdf') cmd = 'writeAlasccaReport ' + \ required(' --tmp_dir ', tmpdir) + \ required(' --output_dir ', tmpdir) + \ conditional(self.alascca_only, " --alascca_only ") + \ required('', self.input_genomic_json) + \ required('', self.input_metadata_json) cp_cmd = "cp {} {}".format(tmp_pdf, self.output_pdf) rmdir_cmd = "rm -r {}".format(tmpdir) return " && ".join([mkdir_tmp_cmd, cmd, cp_cmd, rmdir_cmd])
def command(self): filt_vcf = "{scratch}/{uuid}.vcf.gz".format(scratch=self.scratch, uuid=uuid.uuid4()) bgzip = "" tabix = "" if self.output.endswith('gz'): bgzip = "| bgzip" tabix = " && tabix -p vcf {}".format(self.output) filt_vcf_cmd = "vcf_filter.py --no-filtered " + required("", self.input_vcf) + " sq --site-quality 5 " + \ "|bgzip" + " > " + filt_vcf vcf_add_sample_cmd = "vcf_add_sample.py " + \ conditional(self.filter_hom, "--filter_hom") + \ required("--samplename ", self.samplename) + \ filt_vcf + " " + \ required("", self.input_bam) + \ bgzip + " > " + self.output + tabix rm_filt_cmd = "rm " + filt_vcf return " && ".join([filt_vcf_cmd, vcf_add_sample_cmd, rm_filt_cmd])
def command(self): # activating conda env activate_cmd = "source activate purecn-env" # running PureCN running_cmd = "PureCN.R " + required("--out ", self.outdir) + \ required("--sampleid ", self.tumorid) + \ required("--segfile ", self.input_seg) + \ required("--vcf ", self.input_vcf) + \ required("--gcgene ", self.gcgene_file) + \ required("--genome ", self.genome) + \ optional("--minpurity ", self.minpurity) + \ optional("--hzdev ", self.hzdev) + \ optional("--segfilesdev ", self.seg_sdev) + \ conditional(self.postopt, "--postoptimize") # deactivating the conda env deactivate_cmd = "source deactivate" return " && ".join([activate_cmd, running_cmd, deactivate_cmd])
def command(self): return "fastqc -o {} ".format(self.outdir) + \ conditional(self.extract, "--extract") + \ " --nogroup {}".format(self.input)
def vt_split_and_leftaln(reference_sequence, allow_ref_mismatches=False): cmd = "vt decompose -s - " + \ "|vt normalize " + conditional(allow_ref_mismatches, ' -n ') + \ " -r {} - ".format(reference_sequence) return cmd
def command(self): return "msisensor scan " + \ required("-d ", self.input_fasta) + \ required("-o ", self.output) + \ conditional(self.homopolymers_only, " -p 1 ")