repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bcbio/bcbio-nextgen | bcbio/variation/strelka2.py | _postprocess_somatic | def _postprocess_somatic(in_file, paired):
"""Post-process somatic calls to provide standard output.
- Converts SGT and NT into standard VCF GT fields
- Replace generic TUMOR NORMAL names in VCF with sample names.
"""
out_file = in_file.replace(".vcf.gz", "-fixed.vcf")
if not utils.file_exists(... | python | def _postprocess_somatic(in_file, paired):
"""Post-process somatic calls to provide standard output.
- Converts SGT and NT into standard VCF GT fields
- Replace generic TUMOR NORMAL names in VCF with sample names.
"""
out_file = in_file.replace(".vcf.gz", "-fixed.vcf")
if not utils.file_exists(... | [
"def",
"_postprocess_somatic",
"(",
"in_file",
",",
"paired",
")",
":",
"out_file",
"=",
"in_file",
".",
"replace",
"(",
"\".vcf.gz\"",
",",
"\"-fixed.vcf\"",
")",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
"and",
"not",
"utils",
".",
... | Post-process somatic calls to provide standard output.
- Converts SGT and NT into standard VCF GT fields
- Replace generic TUMOR NORMAL names in VCF with sample names. | [
"Post",
"-",
"process",
"somatic",
"calls",
"to",
"provide",
"standard",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/strelka2.py#L272-L307 | train |
bcbio/bcbio-nextgen | bcbio/variation/strelka2.py | _run_workflow | def _run_workflow(data, workflow_file, work_dir):
"""Run Strelka2 analysis inside prepared workflow directory.
"""
utils.remove_safe(os.path.join(work_dir, "workspace"))
cmd = [utils.get_program_python("configureStrelkaGermlineWorkflow.py"),
workflow_file, "-m", "local", "-j", dd.get_num_core... | python | def _run_workflow(data, workflow_file, work_dir):
"""Run Strelka2 analysis inside prepared workflow directory.
"""
utils.remove_safe(os.path.join(work_dir, "workspace"))
cmd = [utils.get_program_python("configureStrelkaGermlineWorkflow.py"),
workflow_file, "-m", "local", "-j", dd.get_num_core... | [
"def",
"_run_workflow",
"(",
"data",
",",
"workflow_file",
",",
"work_dir",
")",
":",
"utils",
".",
"remove_safe",
"(",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"\"workspace\"",
")",
")",
"cmd",
"=",
"[",
"utils",
".",
"get_program_python",
... | Run Strelka2 analysis inside prepared workflow directory. | [
"Run",
"Strelka2",
"analysis",
"inside",
"prepared",
"workflow",
"directory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/strelka2.py#L320-L327 | train |
bcbio/bcbio-nextgen | bcbio/variation/strelka2.py | run_gvcfgenotyper | def run_gvcfgenotyper(data, orig_region, vrn_files, out_file):
"""Merge strelka2 and Illumina compatible gVCFs with gvcfgenotyper.
https://github.com/Illumina/gvcfgenotyper
Also need to explore GLnexus (https://github.com/dnanexus-rnd/GLnexus)
"""
if not utils.file_exists(out_file):
with f... | python | def run_gvcfgenotyper(data, orig_region, vrn_files, out_file):
"""Merge strelka2 and Illumina compatible gVCFs with gvcfgenotyper.
https://github.com/Illumina/gvcfgenotyper
Also need to explore GLnexus (https://github.com/dnanexus-rnd/GLnexus)
"""
if not utils.file_exists(out_file):
with f... | [
"def",
"run_gvcfgenotyper",
"(",
"data",
",",
"orig_region",
",",
"vrn_files",
",",
"out_file",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"data",
",",
"out_file",
")",
"as",
"tx_out_file",... | Merge strelka2 and Illumina compatible gVCFs with gvcfgenotyper.
https://github.com/Illumina/gvcfgenotyper
Also need to explore GLnexus (https://github.com/dnanexus-rnd/GLnexus) | [
"Merge",
"strelka2",
"and",
"Illumina",
"compatible",
"gVCFs",
"with",
"gvcfgenotyper",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/strelka2.py#L331-L351 | train |
bcbio/bcbio-nextgen | bcbio/variation/strelka2.py | _run_gvcfgenotyper | def _run_gvcfgenotyper(data, region, vrn_files, out_file):
"""Run gvcfgenotyper on a single gVCF region in input file.
"""
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
input_file = "%s-inputs.txt" % utils.splitext_plus(tx_out_file)[0]
... | python | def _run_gvcfgenotyper(data, region, vrn_files, out_file):
"""Run gvcfgenotyper on a single gVCF region in input file.
"""
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
input_file = "%s-inputs.txt" % utils.splitext_plus(tx_out_file)[0]
... | [
"def",
"_run_gvcfgenotyper",
"(",
"data",
",",
"region",
",",
"vrn_files",
",",
"out_file",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"data",
",",
"out_file",
")",
"as",
"tx_out_file",
"... | Run gvcfgenotyper on a single gVCF region in input file. | [
"Run",
"gvcfgenotyper",
"on",
"a",
"single",
"gVCF",
"region",
"in",
"input",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/strelka2.py#L353-L364 | train |
bcbio/bcbio-nextgen | bcbio/variation/strelka2.py | _find_gvcf_blocks | def _find_gvcf_blocks(vcf_file, region, tmp_dir):
"""Retrieve gVCF blocks within our current evaluation region.
gvcfgenotyper does not support calling larger regions with individual
coverage blocks, so we split our big region into potentially multiple.
"""
region_file = os.path.join(tmp_dir, "cur_r... | python | def _find_gvcf_blocks(vcf_file, region, tmp_dir):
"""Retrieve gVCF blocks within our current evaluation region.
gvcfgenotyper does not support calling larger regions with individual
coverage blocks, so we split our big region into potentially multiple.
"""
region_file = os.path.join(tmp_dir, "cur_r... | [
"def",
"_find_gvcf_blocks",
"(",
"vcf_file",
",",
"region",
",",
"tmp_dir",
")",
":",
"region_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tmp_dir",
",",
"\"cur_region.bed\"",
")",
"with",
"open",
"(",
"region_file",
",",
"\"w\"",
")",
"as",
"out_hand... | Retrieve gVCF blocks within our current evaluation region.
gvcfgenotyper does not support calling larger regions with individual
coverage blocks, so we split our big region into potentially multiple. | [
"Retrieve",
"gVCF",
"blocks",
"within",
"our",
"current",
"evaluation",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/strelka2.py#L366-L385 | train |
bcbio/bcbio-nextgen | bcbio/hla/__init__.py | run | def run(samples, run_parallel):
"""Run HLA detection on the input samples.
"""
to_process = []
extras = []
for data in (xs[0] for xs in samples):
hlacaller = tz.get_in(["config", "algorithm", "hlacaller"], data)
if hlacaller:
to_process.append(data)
else:
... | python | def run(samples, run_parallel):
"""Run HLA detection on the input samples.
"""
to_process = []
extras = []
for data in (xs[0] for xs in samples):
hlacaller = tz.get_in(["config", "algorithm", "hlacaller"], data)
if hlacaller:
to_process.append(data)
else:
... | [
"def",
"run",
"(",
"samples",
",",
"run_parallel",
")",
":",
"to_process",
"=",
"[",
"]",
"extras",
"=",
"[",
"]",
"for",
"data",
"in",
"(",
"xs",
"[",
"0",
"]",
"for",
"xs",
"in",
"samples",
")",
":",
"hlacaller",
"=",
"tz",
".",
"get_in",
"(",
... | Run HLA detection on the input samples. | [
"Run",
"HLA",
"detection",
"on",
"the",
"input",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/__init__.py#L20-L32 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/bwa.py | align_bam | def align_bam(in_bam, ref_file, names, align_dir, data):
"""Perform direct alignment of an input BAM file with BWA using pipes.
This avoids disk IO by piping between processes:
- samtools sort of input BAM to queryname
- bedtools conversion to interleaved FASTQ
- bwa-mem alignment
- samtool... | python | def align_bam(in_bam, ref_file, names, align_dir, data):
"""Perform direct alignment of an input BAM file with BWA using pipes.
This avoids disk IO by piping between processes:
- samtools sort of input BAM to queryname
- bedtools conversion to interleaved FASTQ
- bwa-mem alignment
- samtool... | [
"def",
"align_bam",
"(",
"in_bam",
",",
"ref_file",
",",
"names",
",",
"align_dir",
",",
"data",
")",
":",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"align_dir",
",",
"\"{0}-sort.bam\"",
".",
"... | Perform direct alignment of an input BAM file with BWA using pipes.
This avoids disk IO by piping between processes:
- samtools sort of input BAM to queryname
- bedtools conversion to interleaved FASTQ
- bwa-mem alignment
- samtools conversion to BAM
- samtools sort to coordinate | [
"Perform",
"direct",
"alignment",
"of",
"an",
"input",
"BAM",
"file",
"with",
"BWA",
"using",
"pipes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/bwa.py#L21-L53 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/bwa.py | _get_bwa_mem_cmd | def _get_bwa_mem_cmd(data, out_file, ref_file, fastq1, fastq2=""):
"""Perform piped bwa mem mapping potentially with alternative alleles in GRCh38 + HLA typing.
Commands for HLA post-processing:
base=TEST
run-HLA $base.hla > $base.hla.top
cat $base.hla.HLA*.gt | grep ^GT | cut -f2- > $base... | python | def _get_bwa_mem_cmd(data, out_file, ref_file, fastq1, fastq2=""):
"""Perform piped bwa mem mapping potentially with alternative alleles in GRCh38 + HLA typing.
Commands for HLA post-processing:
base=TEST
run-HLA $base.hla > $base.hla.top
cat $base.hla.HLA*.gt | grep ^GT | cut -f2- > $base... | [
"def",
"_get_bwa_mem_cmd",
"(",
"data",
",",
"out_file",
",",
"ref_file",
",",
"fastq1",
",",
"fastq2",
"=",
"\"\"",
")",
":",
"alt_file",
"=",
"ref_file",
"+",
"\".alt\"",
"if",
"utils",
".",
"file_exists",
"(",
"alt_file",
")",
"and",
"dd",
".",
"get_h... | Perform piped bwa mem mapping potentially with alternative alleles in GRCh38 + HLA typing.
Commands for HLA post-processing:
base=TEST
run-HLA $base.hla > $base.hla.top
cat $base.hla.HLA*.gt | grep ^GT | cut -f2- > $base.hla.all
rm -f $base.hla.HLA*gt
rm -f $base.hla.HLA*gz | [
"Perform",
"piped",
"bwa",
"mem",
"mapping",
"potentially",
"with",
"alternative",
"alleles",
"in",
"GRCh38",
"+",
"HLA",
"typing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/bwa.py#L55-L94 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/bwa.py | _align_mem | def _align_mem(fastq_file, pair_file, ref_file, out_file, names, rg_info, data):
"""Perform bwa-mem alignment on supported read lengths.
"""
with postalign.tobam_cl(data, out_file, pair_file != "") as (tobam_cl, tx_out_file):
cmd = ("unset JAVA_HOME && "
"%s | %s" % (_get_bwa_mem_cmd(... | python | def _align_mem(fastq_file, pair_file, ref_file, out_file, names, rg_info, data):
"""Perform bwa-mem alignment on supported read lengths.
"""
with postalign.tobam_cl(data, out_file, pair_file != "") as (tobam_cl, tx_out_file):
cmd = ("unset JAVA_HOME && "
"%s | %s" % (_get_bwa_mem_cmd(... | [
"def",
"_align_mem",
"(",
"fastq_file",
",",
"pair_file",
",",
"ref_file",
",",
"out_file",
",",
"names",
",",
"rg_info",
",",
"data",
")",
":",
"with",
"postalign",
".",
"tobam_cl",
"(",
"data",
",",
"out_file",
",",
"pair_file",
"!=",
"\"\"",
")",
"as"... | Perform bwa-mem alignment on supported read lengths. | [
"Perform",
"bwa",
"-",
"mem",
"alignment",
"on",
"supported",
"read",
"lengths",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/bwa.py#L174-L182 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/bwa.py | _align_backtrack | def _align_backtrack(fastq_file, pair_file, ref_file, out_file, names, rg_info, data):
"""Perform a BWA alignment using 'aln' backtrack algorithm.
"""
bwa = config_utils.get_program("bwa", data["config"])
config = data["config"]
sai1_file = "%s_1.sai" % os.path.splitext(out_file)[0]
sai2_file = ... | python | def _align_backtrack(fastq_file, pair_file, ref_file, out_file, names, rg_info, data):
"""Perform a BWA alignment using 'aln' backtrack algorithm.
"""
bwa = config_utils.get_program("bwa", data["config"])
config = data["config"]
sai1_file = "%s_1.sai" % os.path.splitext(out_file)[0]
sai2_file = ... | [
"def",
"_align_backtrack",
"(",
"fastq_file",
",",
"pair_file",
",",
"ref_file",
",",
"out_file",
",",
"names",
",",
"rg_info",
",",
"data",
")",
":",
"bwa",
"=",
"config_utils",
".",
"get_program",
"(",
"\"bwa\"",
",",
"data",
"[",
"\"config\"",
"]",
")",... | Perform a BWA alignment using 'aln' backtrack algorithm. | [
"Perform",
"a",
"BWA",
"alignment",
"using",
"aln",
"backtrack",
"algorithm",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/bwa.py#L184-L203 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/main.py | run_main | def run_main(workdir, config_file=None, fc_dir=None, run_info_yaml=None,
parallel=None, workflow=None):
"""Run variant analysis, handling command line options.
"""
# Set environment to standard to use periods for decimals and avoid localization
os.environ["LC_ALL"] = "C"
os.environ["LC"... | python | def run_main(workdir, config_file=None, fc_dir=None, run_info_yaml=None,
parallel=None, workflow=None):
"""Run variant analysis, handling command line options.
"""
# Set environment to standard to use periods for decimals and avoid localization
os.environ["LC_ALL"] = "C"
os.environ["LC"... | [
"def",
"run_main",
"(",
"workdir",
",",
"config_file",
"=",
"None",
",",
"fc_dir",
"=",
"None",
",",
"run_info_yaml",
"=",
"None",
",",
"parallel",
"=",
"None",
",",
"workflow",
"=",
"None",
")",
":",
"# Set environment to standard to use periods for decimals and ... | Run variant analysis, handling command line options. | [
"Run",
"variant",
"analysis",
"handling",
"command",
"line",
"options",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/main.py#L29-L55 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/main.py | _setup_resources | def _setup_resources():
"""Attempt to increase resource limits up to hard limits.
This allows us to avoid out of file handle limits where we can
move beyond the soft limit up to the hard limit.
"""
target_procs = 10240
cur_proc, max_proc = resource.getrlimit(resource.RLIMIT_NPROC)
target_pr... | python | def _setup_resources():
"""Attempt to increase resource limits up to hard limits.
This allows us to avoid out of file handle limits where we can
move beyond the soft limit up to the hard limit.
"""
target_procs = 10240
cur_proc, max_proc = resource.getrlimit(resource.RLIMIT_NPROC)
target_pr... | [
"def",
"_setup_resources",
"(",
")",
":",
"target_procs",
"=",
"10240",
"cur_proc",
",",
"max_proc",
"=",
"resource",
".",
"getrlimit",
"(",
"resource",
".",
"RLIMIT_NPROC",
")",
"target_proc",
"=",
"min",
"(",
"max_proc",
",",
"target_procs",
")",
"if",
"ma... | Attempt to increase resource limits up to hard limits.
This allows us to avoid out of file handle limits where we can
move beyond the soft limit up to the hard limit. | [
"Attempt",
"to",
"increase",
"resource",
"limits",
"up",
"to",
"hard",
"limits",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/main.py#L57-L69 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/main.py | _wres | def _wres(parallel, progs, fresources=None, ensure_mem=None):
"""Add resource information to the parallel environment on required programs and files.
Enables spinning up required machines and operating in non-shared filesystem
environments.
progs -- Third party tools used in processing
fresources ... | python | def _wres(parallel, progs, fresources=None, ensure_mem=None):
"""Add resource information to the parallel environment on required programs and files.
Enables spinning up required machines and operating in non-shared filesystem
environments.
progs -- Third party tools used in processing
fresources ... | [
"def",
"_wres",
"(",
"parallel",
",",
"progs",
",",
"fresources",
"=",
"None",
",",
"ensure_mem",
"=",
"None",
")",
":",
"parallel",
"=",
"copy",
".",
"deepcopy",
"(",
"parallel",
")",
"parallel",
"[",
"\"progs\"",
"]",
"=",
"progs",
"if",
"fresources",
... | Add resource information to the parallel environment on required programs and files.
Enables spinning up required machines and operating in non-shared filesystem
environments.
progs -- Third party tools used in processing
fresources -- Required file-based resources needed. These will be transferred on... | [
"Add",
"resource",
"information",
"to",
"the",
"parallel",
"environment",
"on",
"required",
"programs",
"and",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/main.py#L94-L112 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/main.py | rnaseq_prep_samples | def rnaseq_prep_samples(config, run_info_yaml, parallel, dirs, samples):
"""
organizes RNA-seq and small-RNAseq samples, converting from BAM if
necessary and trimming if necessary
"""
pipeline = dd.get_in_samples(samples, dd.get_analysis)
trim_reads_set = any([tz.get_in(["algorithm", "trim_reads... | python | def rnaseq_prep_samples(config, run_info_yaml, parallel, dirs, samples):
"""
organizes RNA-seq and small-RNAseq samples, converting from BAM if
necessary and trimming if necessary
"""
pipeline = dd.get_in_samples(samples, dd.get_analysis)
trim_reads_set = any([tz.get_in(["algorithm", "trim_reads... | [
"def",
"rnaseq_prep_samples",
"(",
"config",
",",
"run_info_yaml",
",",
"parallel",
",",
"dirs",
",",
"samples",
")",
":",
"pipeline",
"=",
"dd",
".",
"get_in_samples",
"(",
"samples",
",",
"dd",
".",
"get_analysis",
")",
"trim_reads_set",
"=",
"any",
"(",
... | organizes RNA-seq and small-RNAseq samples, converting from BAM if
necessary and trimming if necessary | [
"organizes",
"RNA",
"-",
"seq",
"and",
"small",
"-",
"RNAseq",
"samples",
"converting",
"from",
"BAM",
"if",
"necessary",
"and",
"trimming",
"if",
"necessary"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/main.py#L394-L418 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/main.py | _pair_samples_with_pipelines | def _pair_samples_with_pipelines(run_info_yaml, config):
"""Map samples defined in input file to pipelines to run.
"""
samples = config_utils.load_config(run_info_yaml)
if isinstance(samples, dict):
resources = samples.pop("resources")
samples = samples["details"]
else:
resou... | python | def _pair_samples_with_pipelines(run_info_yaml, config):
"""Map samples defined in input file to pipelines to run.
"""
samples = config_utils.load_config(run_info_yaml)
if isinstance(samples, dict):
resources = samples.pop("resources")
samples = samples["details"]
else:
resou... | [
"def",
"_pair_samples_with_pipelines",
"(",
"run_info_yaml",
",",
"config",
")",
":",
"samples",
"=",
"config_utils",
".",
"load_config",
"(",
"run_info_yaml",
")",
"if",
"isinstance",
"(",
"samples",
",",
"dict",
")",
":",
"resources",
"=",
"samples",
".",
"p... | Map samples defined in input file to pipelines to run. | [
"Map",
"samples",
"defined",
"in",
"input",
"file",
"to",
"pipelines",
"to",
"run",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/main.py#L430-L461 | train |
bcbio/bcbio-nextgen | bcbio/hla/bwakit.py | run | def run(data):
"""HLA typing with bwakit, parsing output from called genotype files.
"""
bwakit_dir = os.path.dirname(os.path.realpath(utils.which("run-bwamem")))
hla_fqs = tz.get_in(["hla", "fastq"], data, [])
if len(hla_fqs) > 0:
hla_base = os.path.commonprefix(hla_fqs)
while hla_b... | python | def run(data):
"""HLA typing with bwakit, parsing output from called genotype files.
"""
bwakit_dir = os.path.dirname(os.path.realpath(utils.which("run-bwamem")))
hla_fqs = tz.get_in(["hla", "fastq"], data, [])
if len(hla_fqs) > 0:
hla_base = os.path.commonprefix(hla_fqs)
while hla_b... | [
"def",
"run",
"(",
"data",
")",
":",
"bwakit_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"utils",
".",
"which",
"(",
"\"run-bwamem\"",
")",
")",
")",
"hla_fqs",
"=",
"tz",
".",
"get_in",
"(",
"[",
"... | HLA typing with bwakit, parsing output from called genotype files. | [
"HLA",
"typing",
"with",
"bwakit",
"parsing",
"output",
"from",
"called",
"genotype",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/bwakit.py#L18-L34 | train |
bcbio/bcbio-nextgen | bcbio/hla/bwakit.py | _organize_calls | def _organize_calls(out_file, hla_base, data):
"""Prepare genotype calls, reporting best call along with quality metrics.
"""
hla_truth = get_hla_truthset(data)
sample = dd.get_sample_name(data)
with file_transaction(data, out_file) as tx_out_file:
with open(tx_out_file, "w") as out_handle:
... | python | def _organize_calls(out_file, hla_base, data):
"""Prepare genotype calls, reporting best call along with quality metrics.
"""
hla_truth = get_hla_truthset(data)
sample = dd.get_sample_name(data)
with file_transaction(data, out_file) as tx_out_file:
with open(tx_out_file, "w") as out_handle:
... | [
"def",
"_organize_calls",
"(",
"out_file",
",",
"hla_base",
",",
"data",
")",
":",
"hla_truth",
"=",
"get_hla_truthset",
"(",
"data",
")",
"sample",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"with",
"file_transaction",
"(",
"data",
",",
"out_file"... | Prepare genotype calls, reporting best call along with quality metrics. | [
"Prepare",
"genotype",
"calls",
"reporting",
"best",
"call",
"along",
"with",
"quality",
"metrics",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/bwakit.py#L36-L64 | train |
bcbio/bcbio-nextgen | bcbio/hla/bwakit.py | matches_truth | def matches_truth(call_alleles, truth_alleles, data):
"""Flexibly check if truth and call alleles match, using p-groups.
"""
if not truth_alleles:
return ""
else:
def _remove_p(x):
return x[:-1] if x.endswith("P") else x
t_cmp = set([_remove_p(hla_groups.hla_protein(x... | python | def matches_truth(call_alleles, truth_alleles, data):
"""Flexibly check if truth and call alleles match, using p-groups.
"""
if not truth_alleles:
return ""
else:
def _remove_p(x):
return x[:-1] if x.endswith("P") else x
t_cmp = set([_remove_p(hla_groups.hla_protein(x... | [
"def",
"matches_truth",
"(",
"call_alleles",
",",
"truth_alleles",
",",
"data",
")",
":",
"if",
"not",
"truth_alleles",
":",
"return",
"\"\"",
"else",
":",
"def",
"_remove_p",
"(",
"x",
")",
":",
"return",
"x",
"[",
":",
"-",
"1",
"]",
"if",
"x",
"."... | Flexibly check if truth and call alleles match, using p-groups. | [
"Flexibly",
"check",
"if",
"truth",
"and",
"call",
"alleles",
"match",
"using",
"p",
"-",
"groups",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/bwakit.py#L66-L76 | train |
bcbio/bcbio-nextgen | bcbio/hla/bwakit.py | get_hla_truthset | def get_hla_truthset(data):
"""Retrieve expected truth calls for annotating HLA called output.
"""
val_csv = tz.get_in(["config", "algorithm", "hlavalidate"], data)
out = {}
if val_csv and utils.file_exists(val_csv):
with open(val_csv) as in_handle:
reader = csv.reader(in_handle)... | python | def get_hla_truthset(data):
"""Retrieve expected truth calls for annotating HLA called output.
"""
val_csv = tz.get_in(["config", "algorithm", "hlavalidate"], data)
out = {}
if val_csv and utils.file_exists(val_csv):
with open(val_csv) as in_handle:
reader = csv.reader(in_handle)... | [
"def",
"get_hla_truthset",
"(",
"data",
")",
":",
"val_csv",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
",",
"\"algorithm\"",
",",
"\"hlavalidate\"",
"]",
",",
"data",
")",
"out",
"=",
"{",
"}",
"if",
"val_csv",
"and",
"utils",
".",
"file_exists",... | Retrieve expected truth calls for annotating HLA called output. | [
"Retrieve",
"expected",
"truth",
"calls",
"for",
"annotating",
"HLA",
"called",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/bwakit.py#L78-L89 | train |
bcbio/bcbio-nextgen | scripts/utils/bam_to_fastq_region.py | bam_to_fastq_pair | def bam_to_fastq_pair(in_file, target_region, pair):
"""Generator to convert BAM files into name, seq, qual in a region.
"""
space, start, end = target_region
bam_file = pysam.Samfile(in_file, "rb")
for read in bam_file:
if (not read.is_unmapped and not read.mate_is_unmapped
... | python | def bam_to_fastq_pair(in_file, target_region, pair):
"""Generator to convert BAM files into name, seq, qual in a region.
"""
space, start, end = target_region
bam_file = pysam.Samfile(in_file, "rb")
for read in bam_file:
if (not read.is_unmapped and not read.mate_is_unmapped
... | [
"def",
"bam_to_fastq_pair",
"(",
"in_file",
",",
"target_region",
",",
"pair",
")",
":",
"space",
",",
"start",
",",
"end",
"=",
"target_region",
"bam_file",
"=",
"pysam",
".",
"Samfile",
"(",
"in_file",
",",
"\"rb\"",
")",
"for",
"read",
"in",
"bam_file",... | Generator to convert BAM files into name, seq, qual in a region. | [
"Generator",
"to",
"convert",
"BAM",
"files",
"into",
"name",
"seq",
"qual",
"in",
"a",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/bam_to_fastq_region.py#L32-L50 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | sample_callable_bed | def sample_callable_bed(bam_file, ref_file, data):
"""Retrieve callable regions for a sample subset by defined analysis regions.
"""
from bcbio.heterogeneity import chromhacks
CovInfo = collections.namedtuple("CovInfo", "callable, raw_callable, depth_files")
noalt_calling = "noalt_calling" in dd.get... | python | def sample_callable_bed(bam_file, ref_file, data):
"""Retrieve callable regions for a sample subset by defined analysis regions.
"""
from bcbio.heterogeneity import chromhacks
CovInfo = collections.namedtuple("CovInfo", "callable, raw_callable, depth_files")
noalt_calling = "noalt_calling" in dd.get... | [
"def",
"sample_callable_bed",
"(",
"bam_file",
",",
"ref_file",
",",
"data",
")",
":",
"from",
"bcbio",
".",
"heterogeneity",
"import",
"chromhacks",
"CovInfo",
"=",
"collections",
".",
"namedtuple",
"(",
"\"CovInfo\"",
",",
"\"callable, raw_callable, depth_files\"",
... | Retrieve callable regions for a sample subset by defined analysis regions. | [
"Retrieve",
"callable",
"regions",
"for",
"a",
"sample",
"subset",
"by",
"defined",
"analysis",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L32-L57 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | get_ref_bedtool | def get_ref_bedtool(ref_file, config, chrom=None):
"""Retrieve a pybedtool BedTool object with reference sizes from input reference.
"""
broad_runner = broad.runner_from_path("picard", config)
ref_dict = broad_runner.run_fn("picard_index_ref", ref_file)
ref_lines = []
with pysam.Samfile(ref_dict... | python | def get_ref_bedtool(ref_file, config, chrom=None):
"""Retrieve a pybedtool BedTool object with reference sizes from input reference.
"""
broad_runner = broad.runner_from_path("picard", config)
ref_dict = broad_runner.run_fn("picard_index_ref", ref_file)
ref_lines = []
with pysam.Samfile(ref_dict... | [
"def",
"get_ref_bedtool",
"(",
"ref_file",
",",
"config",
",",
"chrom",
"=",
"None",
")",
":",
"broad_runner",
"=",
"broad",
".",
"runner_from_path",
"(",
"\"picard\"",
",",
"config",
")",
"ref_dict",
"=",
"broad_runner",
".",
"run_fn",
"(",
"\"picard_index_re... | Retrieve a pybedtool BedTool object with reference sizes from input reference. | [
"Retrieve",
"a",
"pybedtool",
"BedTool",
"object",
"with",
"reference",
"sizes",
"from",
"input",
"reference",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L59-L69 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | _get_nblock_regions | def _get_nblock_regions(in_file, min_n_size, ref_regions):
"""Retrieve coordinates of regions in reference genome with no mapping.
These are potential breakpoints for parallelizing analysis.
"""
out_lines = []
called_contigs = set([])
with utils.open_gzipsafe(in_file) as in_handle:
for l... | python | def _get_nblock_regions(in_file, min_n_size, ref_regions):
"""Retrieve coordinates of regions in reference genome with no mapping.
These are potential breakpoints for parallelizing analysis.
"""
out_lines = []
called_contigs = set([])
with utils.open_gzipsafe(in_file) as in_handle:
for l... | [
"def",
"_get_nblock_regions",
"(",
"in_file",
",",
"min_n_size",
",",
"ref_regions",
")",
":",
"out_lines",
"=",
"[",
"]",
"called_contigs",
"=",
"set",
"(",
"[",
"]",
")",
"with",
"utils",
".",
"open_gzipsafe",
"(",
"in_file",
")",
"as",
"in_handle",
":",... | Retrieve coordinates of regions in reference genome with no mapping.
These are potential breakpoints for parallelizing analysis. | [
"Retrieve",
"coordinates",
"of",
"regions",
"in",
"reference",
"genome",
"with",
"no",
"mapping",
".",
"These",
"are",
"potential",
"breakpoints",
"for",
"parallelizing",
"analysis",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L71-L87 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | _combine_regions | def _combine_regions(all_regions, ref_regions):
"""Combine multiple BEDtools regions of regions into sorted final BEDtool.
"""
chrom_order = {}
for i, x in enumerate(ref_regions):
chrom_order[x.chrom] = i
def wchrom_key(x):
chrom, start, end = x
return (chrom_order[chrom], st... | python | def _combine_regions(all_regions, ref_regions):
"""Combine multiple BEDtools regions of regions into sorted final BEDtool.
"""
chrom_order = {}
for i, x in enumerate(ref_regions):
chrom_order[x.chrom] = i
def wchrom_key(x):
chrom, start, end = x
return (chrom_order[chrom], st... | [
"def",
"_combine_regions",
"(",
"all_regions",
",",
"ref_regions",
")",
":",
"chrom_order",
"=",
"{",
"}",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"ref_regions",
")",
":",
"chrom_order",
"[",
"x",
".",
"chrom",
"]",
"=",
"i",
"def",
"wchrom_key",
... | Combine multiple BEDtools regions of regions into sorted final BEDtool. | [
"Combine",
"multiple",
"BEDtools",
"regions",
"of",
"regions",
"into",
"sorted",
"final",
"BEDtool",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L89-L104 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | _add_config_regions | def _add_config_regions(nblock_regions, ref_regions, data):
"""Add additional nblock regions based on configured regions to call.
Identifies user defined regions which we should not be analyzing.
"""
input_regions_bed = dd.get_variant_regions(data)
if input_regions_bed:
input_regions = pybed... | python | def _add_config_regions(nblock_regions, ref_regions, data):
"""Add additional nblock regions based on configured regions to call.
Identifies user defined regions which we should not be analyzing.
"""
input_regions_bed = dd.get_variant_regions(data)
if input_regions_bed:
input_regions = pybed... | [
"def",
"_add_config_regions",
"(",
"nblock_regions",
",",
"ref_regions",
",",
"data",
")",
":",
"input_regions_bed",
"=",
"dd",
".",
"get_variant_regions",
"(",
"data",
")",
"if",
"input_regions_bed",
":",
"input_regions",
"=",
"pybedtools",
".",
"BedTool",
"(",
... | Add additional nblock regions based on configured regions to call.
Identifies user defined regions which we should not be analyzing. | [
"Add",
"additional",
"nblock",
"regions",
"based",
"on",
"configured",
"regions",
"to",
"call",
".",
"Identifies",
"user",
"defined",
"regions",
"which",
"we",
"should",
"not",
"be",
"analyzing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L106-L130 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | block_regions | def block_regions(callable_bed, in_bam, ref_file, data):
"""Find blocks of regions for analysis from mapped input BAM file.
Identifies islands of callable regions, surrounding by regions
with no read support, that can be analyzed independently.
"""
min_n_size = int(data["config"]["algorithm"].get("... | python | def block_regions(callable_bed, in_bam, ref_file, data):
"""Find blocks of regions for analysis from mapped input BAM file.
Identifies islands of callable regions, surrounding by regions
with no read support, that can be analyzed independently.
"""
min_n_size = int(data["config"]["algorithm"].get("... | [
"def",
"block_regions",
"(",
"callable_bed",
",",
"in_bam",
",",
"ref_file",
",",
"data",
")",
":",
"min_n_size",
"=",
"int",
"(",
"data",
"[",
"\"config\"",
"]",
"[",
"\"algorithm\"",
"]",
".",
"get",
"(",
"\"nomap_split_size\"",
",",
"250",
")",
")",
"... | Find blocks of regions for analysis from mapped input BAM file.
Identifies islands of callable regions, surrounding by regions
with no read support, that can be analyzed independently. | [
"Find",
"blocks",
"of",
"regions",
"for",
"analysis",
"from",
"mapped",
"input",
"BAM",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L182-L207 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | _analysis_block_stats | def _analysis_block_stats(regions, samples):
"""Provide statistics on sizes and number of analysis blocks.
"""
prev = None
between_sizes = []
region_sizes = []
for region in regions:
if prev and prev.chrom == region.chrom:
between_sizes.append(region.start - prev.end)
... | python | def _analysis_block_stats(regions, samples):
"""Provide statistics on sizes and number of analysis blocks.
"""
prev = None
between_sizes = []
region_sizes = []
for region in regions:
if prev and prev.chrom == region.chrom:
between_sizes.append(region.start - prev.end)
... | [
"def",
"_analysis_block_stats",
"(",
"regions",
",",
"samples",
")",
":",
"prev",
"=",
"None",
"between_sizes",
"=",
"[",
"]",
"region_sizes",
"=",
"[",
"]",
"for",
"region",
"in",
"regions",
":",
"if",
"prev",
"and",
"prev",
".",
"chrom",
"==",
"region"... | Provide statistics on sizes and number of analysis blocks. | [
"Provide",
"statistics",
"on",
"sizes",
"and",
"number",
"of",
"analysis",
"blocks",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L216-L244 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | _needs_region_update | def _needs_region_update(out_file, samples):
"""Check if we need to update BED file of regions, supporting back compatibility.
"""
nblock_files = [x["regions"]["nblock"] for x in samples if "regions" in x]
# For older approaches and do not create a new set of analysis
# regions, since the new algori... | python | def _needs_region_update(out_file, samples):
"""Check if we need to update BED file of regions, supporting back compatibility.
"""
nblock_files = [x["regions"]["nblock"] for x in samples if "regions" in x]
# For older approaches and do not create a new set of analysis
# regions, since the new algori... | [
"def",
"_needs_region_update",
"(",
"out_file",
",",
"samples",
")",
":",
"nblock_files",
"=",
"[",
"x",
"[",
"\"regions\"",
"]",
"[",
"\"nblock\"",
"]",
"for",
"x",
"in",
"samples",
"if",
"\"regions\"",
"in",
"x",
"]",
"# For older approaches and do not create ... | Check if we need to update BED file of regions, supporting back compatibility. | [
"Check",
"if",
"we",
"need",
"to",
"update",
"BED",
"file",
"of",
"regions",
"supporting",
"back",
"compatibility",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L246-L261 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | combine_sample_regions | def combine_sample_regions(*samples):
"""Create batch-level sets of callable regions for multi-sample calling.
Intersects all non-callable (nblock) regions from all samples in a batch,
producing a global set of callable regions.
"""
samples = utils.unpack_worlds(samples)
samples = cwlutils.unpa... | python | def combine_sample_regions(*samples):
"""Create batch-level sets of callable regions for multi-sample calling.
Intersects all non-callable (nblock) regions from all samples in a batch,
producing a global set of callable regions.
"""
samples = utils.unpack_worlds(samples)
samples = cwlutils.unpa... | [
"def",
"combine_sample_regions",
"(",
"*",
"samples",
")",
":",
"samples",
"=",
"utils",
".",
"unpack_worlds",
"(",
"samples",
")",
"samples",
"=",
"cwlutils",
".",
"unpack_tarballs",
"(",
"samples",
",",
"samples",
"[",
"0",
"]",
")",
"# back compatibility --... | Create batch-level sets of callable regions for multi-sample calling.
Intersects all non-callable (nblock) regions from all samples in a batch,
producing a global set of callable regions. | [
"Create",
"batch",
"-",
"level",
"sets",
"of",
"callable",
"regions",
"for",
"multi",
"-",
"sample",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L263-L311 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | _combine_sample_regions_batch | def _combine_sample_regions_batch(batch, items):
"""Combine sample regions within a group of batched samples.
"""
config = items[0]["config"]
work_dir = utils.safe_makedir(os.path.join(items[0]["dirs"]["work"], "regions"))
analysis_file = os.path.join(work_dir, "%s-analysis_blocks.bed" % batch)
... | python | def _combine_sample_regions_batch(batch, items):
"""Combine sample regions within a group of batched samples.
"""
config = items[0]["config"]
work_dir = utils.safe_makedir(os.path.join(items[0]["dirs"]["work"], "regions"))
analysis_file = os.path.join(work_dir, "%s-analysis_blocks.bed" % batch)
... | [
"def",
"_combine_sample_regions_batch",
"(",
"batch",
",",
"items",
")",
":",
"config",
"=",
"items",
"[",
"0",
"]",
"[",
"\"config\"",
"]",
"work_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"items",
"[",
"0",
"]"... | Combine sample regions within a group of batched samples. | [
"Combine",
"sample",
"regions",
"within",
"a",
"group",
"of",
"batched",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L313-L347 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | get_split_regions | def get_split_regions(bed_file, data):
"""Retrieve a set of split regions using the input BED for callable regions.
Provides a less inclusive hook for parallelizing over multiple regions.
"""
out_file = "%s-analysis_blocks.bed" % utils.splitext_plus(bed_file)[0]
with shared.bedtools_tmpdir(data):
... | python | def get_split_regions(bed_file, data):
"""Retrieve a set of split regions using the input BED for callable regions.
Provides a less inclusive hook for parallelizing over multiple regions.
"""
out_file = "%s-analysis_blocks.bed" % utils.splitext_plus(bed_file)[0]
with shared.bedtools_tmpdir(data):
... | [
"def",
"get_split_regions",
"(",
"bed_file",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-analysis_blocks.bed\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"bed_file",
")",
"[",
"0",
"]",
"with",
"shared",
".",
"bedtools_tmpdir",
"(",
"data",
")",
":",
"if",... | Retrieve a set of split regions using the input BED for callable regions.
Provides a less inclusive hook for parallelizing over multiple regions. | [
"Retrieve",
"a",
"set",
"of",
"split",
"regions",
"using",
"the",
"input",
"BED",
"for",
"callable",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L349-L374 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | NBlockRegionPicker.include_block | def include_block(self, x):
"""Check for inclusion of block based on distance from previous.
"""
last_pos = self._chr_last_blocks.get(x.chrom, 0)
# Region excludes an entire chromosome, typically decoy/haplotypes
if last_pos <= self._end_buffer and x.stop >= self._ref_sizes.get(x... | python | def include_block(self, x):
"""Check for inclusion of block based on distance from previous.
"""
last_pos = self._chr_last_blocks.get(x.chrom, 0)
# Region excludes an entire chromosome, typically decoy/haplotypes
if last_pos <= self._end_buffer and x.stop >= self._ref_sizes.get(x... | [
"def",
"include_block",
"(",
"self",
",",
"x",
")",
":",
"last_pos",
"=",
"self",
".",
"_chr_last_blocks",
".",
"get",
"(",
"x",
".",
"chrom",
",",
"0",
")",
"# Region excludes an entire chromosome, typically decoy/haplotypes",
"if",
"last_pos",
"<=",
"self",
".... | Check for inclusion of block based on distance from previous. | [
"Check",
"for",
"inclusion",
"of",
"block",
"based",
"on",
"distance",
"from",
"previous",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L155-L169 | train |
bcbio/bcbio-nextgen | bcbio/bam/callable.py | NBlockRegionPicker.expand_block | def expand_block(self, feat):
"""Expand any blocks which are near the start or end of a contig.
"""
chrom_end = self._ref_sizes.get(feat.chrom)
if chrom_end:
if feat.start < self._end_buffer:
feat.start = 0
if feat.stop >= chrom_end - self._end_buf... | python | def expand_block(self, feat):
"""Expand any blocks which are near the start or end of a contig.
"""
chrom_end = self._ref_sizes.get(feat.chrom)
if chrom_end:
if feat.start < self._end_buffer:
feat.start = 0
if feat.stop >= chrom_end - self._end_buf... | [
"def",
"expand_block",
"(",
"self",
",",
"feat",
")",
":",
"chrom_end",
"=",
"self",
".",
"_ref_sizes",
".",
"get",
"(",
"feat",
".",
"chrom",
")",
"if",
"chrom_end",
":",
"if",
"feat",
".",
"start",
"<",
"self",
".",
"_end_buffer",
":",
"feat",
".",... | Expand any blocks which are near the start or end of a contig. | [
"Expand",
"any",
"blocks",
"which",
"are",
"near",
"the",
"start",
"or",
"end",
"of",
"a",
"contig",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/callable.py#L171-L180 | train |
bcbio/bcbio-nextgen | bcbio/chipseq/__init__.py | _keep_assembled_chrom | def _keep_assembled_chrom(bam_file, genome, config):
"""Remove contigs from the BAM file"""
fai = "%s.fai" % genome
chrom = []
with open(fai) as inh:
for line in inh:
c = line.split("\t")[0]
if c.find("_") < 0:
chrom.append(c)
chroms = " ".join(chrom)
... | python | def _keep_assembled_chrom(bam_file, genome, config):
"""Remove contigs from the BAM file"""
fai = "%s.fai" % genome
chrom = []
with open(fai) as inh:
for line in inh:
c = line.split("\t")[0]
if c.find("_") < 0:
chrom.append(c)
chroms = " ".join(chrom)
... | [
"def",
"_keep_assembled_chrom",
"(",
"bam_file",
",",
"genome",
",",
"config",
")",
":",
"fai",
"=",
"\"%s.fai\"",
"%",
"genome",
"chrom",
"=",
"[",
"]",
"with",
"open",
"(",
"fai",
")",
"as",
"inh",
":",
"for",
"line",
"in",
"inh",
":",
"c",
"=",
... | Remove contigs from the BAM file | [
"Remove",
"contigs",
"from",
"the",
"BAM",
"file"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/__init__.py#L40-L57 | train |
bcbio/bcbio-nextgen | bcbio/chipseq/__init__.py | _prepare_bam | def _prepare_bam(bam_file, bed_file, config):
"""Remove regions from bed files"""
if not bam_file or not bed_file:
return bam_file
out_file = utils.append_stem(bam_file, '_filter')
bedtools = config_utils.get_program("bedtools", config)
if not utils.file_exists(out_file):
with file_t... | python | def _prepare_bam(bam_file, bed_file, config):
"""Remove regions from bed files"""
if not bam_file or not bed_file:
return bam_file
out_file = utils.append_stem(bam_file, '_filter')
bedtools = config_utils.get_program("bedtools", config)
if not utils.file_exists(out_file):
with file_t... | [
"def",
"_prepare_bam",
"(",
"bam_file",
",",
"bed_file",
",",
"config",
")",
":",
"if",
"not",
"bam_file",
"or",
"not",
"bed_file",
":",
"return",
"bam_file",
"out_file",
"=",
"utils",
".",
"append_stem",
"(",
"bam_file",
",",
"'_filter'",
")",
"bedtools",
... | Remove regions from bed files | [
"Remove",
"regions",
"from",
"bed",
"files"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/__init__.py#L60-L70 | train |
bcbio/bcbio-nextgen | bcbio/chipseq/__init__.py | _bam_coverage | def _bam_coverage(name, bam_input, data):
"""Run bamCoverage from deeptools"""
cmd = ("{bam_coverage} -b {bam_input} -o {bw_output} "
"--binSize 20 --effectiveGenomeSize {size} "
"--smoothLength 60 --extendReads 150 --centerReads -p {cores}")
size = bam.fasta.total_sequence_length(dd.get... | python | def _bam_coverage(name, bam_input, data):
"""Run bamCoverage from deeptools"""
cmd = ("{bam_coverage} -b {bam_input} -o {bw_output} "
"--binSize 20 --effectiveGenomeSize {size} "
"--smoothLength 60 --extendReads 150 --centerReads -p {cores}")
size = bam.fasta.total_sequence_length(dd.get... | [
"def",
"_bam_coverage",
"(",
"name",
",",
"bam_input",
",",
"data",
")",
":",
"cmd",
"=",
"(",
"\"{bam_coverage} -b {bam_input} -o {bw_output} \"",
"\"--binSize 20 --effectiveGenomeSize {size} \"",
"\"--smoothLength 60 --extendReads 150 --centerReads -p {cores}\"",
")",
"size",
"... | Run bamCoverage from deeptools | [
"Run",
"bamCoverage",
"from",
"deeptools"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/__init__.py#L72-L94 | train |
bcbio/bcbio-nextgen | bcbio/structural/manta.py | _get_out_file | def _get_out_file(work_dir, paired):
"""Retrieve manta output variant file, depending on analysis.
"""
if paired:
if paired.normal_bam:
base_file = "somaticSV.vcf.gz"
else:
base_file = "tumorSV.vcf.gz"
else:
base_file = "diploidSV.vcf.gz"
return os.pat... | python | def _get_out_file(work_dir, paired):
"""Retrieve manta output variant file, depending on analysis.
"""
if paired:
if paired.normal_bam:
base_file = "somaticSV.vcf.gz"
else:
base_file = "tumorSV.vcf.gz"
else:
base_file = "diploidSV.vcf.gz"
return os.pat... | [
"def",
"_get_out_file",
"(",
"work_dir",
",",
"paired",
")",
":",
"if",
"paired",
":",
"if",
"paired",
".",
"normal_bam",
":",
"base_file",
"=",
"\"somaticSV.vcf.gz\"",
"else",
":",
"base_file",
"=",
"\"tumorSV.vcf.gz\"",
"else",
":",
"base_file",
"=",
"\"dipl... | Retrieve manta output variant file, depending on analysis. | [
"Retrieve",
"manta",
"output",
"variant",
"file",
"depending",
"on",
"analysis",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/manta.py#L71-L81 | train |
bcbio/bcbio-nextgen | bcbio/structural/manta.py | _get_evidence_bam | def _get_evidence_bam(work_dir, data):
"""Retrieve evidence BAM for the sample if it exists
"""
evidence_bam = glob.glob(os.path.join(work_dir, "results", "evidence",
"evidence_*.%s*.bam" % (dd.get_sample_name(data))))
if evidence_bam:
return evidence_... | python | def _get_evidence_bam(work_dir, data):
"""Retrieve evidence BAM for the sample if it exists
"""
evidence_bam = glob.glob(os.path.join(work_dir, "results", "evidence",
"evidence_*.%s*.bam" % (dd.get_sample_name(data))))
if evidence_bam:
return evidence_... | [
"def",
"_get_evidence_bam",
"(",
"work_dir",
",",
"data",
")",
":",
"evidence_bam",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"\"results\"",
",",
"\"evidence\"",
",",
"\"evidence_*.%s*.bam\"",
"%",
"(",
"dd",
".",... | Retrieve evidence BAM for the sample if it exists | [
"Retrieve",
"evidence",
"BAM",
"for",
"the",
"sample",
"if",
"it",
"exists"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/manta.py#L83-L89 | train |
bcbio/bcbio-nextgen | bcbio/structural/manta.py | _run_workflow | def _run_workflow(items, paired, workflow_file, work_dir):
"""Run manta analysis inside prepared workflow directory.
"""
utils.remove_safe(os.path.join(work_dir, "workspace"))
data = paired.tumor_data if paired else items[0]
cmd = [utils.get_program_python("configManta.py"), workflow_file, "-m", "lo... | python | def _run_workflow(items, paired, workflow_file, work_dir):
"""Run manta analysis inside prepared workflow directory.
"""
utils.remove_safe(os.path.join(work_dir, "workspace"))
data = paired.tumor_data if paired else items[0]
cmd = [utils.get_program_python("configManta.py"), workflow_file, "-m", "lo... | [
"def",
"_run_workflow",
"(",
"items",
",",
"paired",
",",
"workflow_file",
",",
"work_dir",
")",
":",
"utils",
".",
"remove_safe",
"(",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"\"workspace\"",
")",
")",
"data",
"=",
"paired",
".",
"tumor_da... | Run manta analysis inside prepared workflow directory. | [
"Run",
"manta",
"analysis",
"inside",
"prepared",
"workflow",
"directory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/manta.py#L91-L98 | train |
bcbio/bcbio-nextgen | bcbio/structural/manta.py | _prep_config | def _prep_config(items, paired, work_dir):
"""Run initial configuration, generating a run directory for Manta.
"""
assert utils.which("configManta.py"), "Could not find installed configManta.py"
out_file = os.path.join(work_dir, "runWorkflow.py")
if not utils.file_exists(out_file) or _out_of_date(ou... | python | def _prep_config(items, paired, work_dir):
"""Run initial configuration, generating a run directory for Manta.
"""
assert utils.which("configManta.py"), "Could not find installed configManta.py"
out_file = os.path.join(work_dir, "runWorkflow.py")
if not utils.file_exists(out_file) or _out_of_date(ou... | [
"def",
"_prep_config",
"(",
"items",
",",
"paired",
",",
"work_dir",
")",
":",
"assert",
"utils",
".",
"which",
"(",
"\"configManta.py\"",
")",
",",
"\"Could not find installed configManta.py\"",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
... | Run initial configuration, generating a run directory for Manta. | [
"Run",
"initial",
"configuration",
"generating",
"a",
"run",
"directory",
"for",
"Manta",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/manta.py#L100-L129 | train |
bcbio/bcbio-nextgen | bcbio/structural/manta.py | _prep_streamlined_config | def _prep_streamlined_config(config_script, work_dir):
"""Create manta INI file without steps that potentially increase runtimes.
This removes calling of small indels.
"""
new_min_size = 100
in_file = config_script + ".ini"
out_file = os.path.join(work_dir, os.path.basename(in_file))
with o... | python | def _prep_streamlined_config(config_script, work_dir):
"""Create manta INI file without steps that potentially increase runtimes.
This removes calling of small indels.
"""
new_min_size = 100
in_file = config_script + ".ini"
out_file = os.path.join(work_dir, os.path.basename(in_file))
with o... | [
"def",
"_prep_streamlined_config",
"(",
"config_script",
",",
"work_dir",
")",
":",
"new_min_size",
"=",
"100",
"in_file",
"=",
"config_script",
"+",
"\".ini\"",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"os",
".",
"path",
".",
... | Create manta INI file without steps that potentially increase runtimes.
This removes calling of small indels. | [
"Create",
"manta",
"INI",
"file",
"without",
"steps",
"that",
"potentially",
"increase",
"runtimes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/manta.py#L131-L146 | train |
bcbio/bcbio-nextgen | bcbio/structural/manta.py | _maybe_limit_chromosomes | def _maybe_limit_chromosomes(data):
"""Potentially limit chromosomes to avoid problematically named HLA contigs.
HLAs have ':' characters in them which confuse downstream processing. If
we have no problematic chromosomes we don't limit anything.
"""
std_chroms = []
prob_chroms = []
noalt_ca... | python | def _maybe_limit_chromosomes(data):
"""Potentially limit chromosomes to avoid problematically named HLA contigs.
HLAs have ':' characters in them which confuse downstream processing. If
we have no problematic chromosomes we don't limit anything.
"""
std_chroms = []
prob_chroms = []
noalt_ca... | [
"def",
"_maybe_limit_chromosomes",
"(",
"data",
")",
":",
"std_chroms",
"=",
"[",
"]",
"prob_chroms",
"=",
"[",
"]",
"noalt_calling",
"=",
"\"noalt_calling\"",
"in",
"dd",
".",
"get_tools_on",
"(",
"data",
")",
"or",
"\"altcontigs\"",
"in",
"dd",
".",
"get_e... | Potentially limit chromosomes to avoid problematically named HLA contigs.
HLAs have ':' characters in them which confuse downstream processing. If
we have no problematic chromosomes we don't limit anything. | [
"Potentially",
"limit",
"chromosomes",
"to",
"avoid",
"problematically",
"named",
"HLA",
"contigs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/manta.py#L148-L165 | train |
bcbio/bcbio-nextgen | bcbio/structural/manta.py | _out_of_date | def _out_of_date(rw_file):
"""Check if a run workflow file points to an older version of manta and needs a refresh.
"""
with open(rw_file) as in_handle:
for line in in_handle:
if line.startswith("sys.path.append"):
file_version = line.split("/lib/python")[0].split("Cellar... | python | def _out_of_date(rw_file):
"""Check if a run workflow file points to an older version of manta and needs a refresh.
"""
with open(rw_file) as in_handle:
for line in in_handle:
if line.startswith("sys.path.append"):
file_version = line.split("/lib/python")[0].split("Cellar... | [
"def",
"_out_of_date",
"(",
"rw_file",
")",
":",
"with",
"open",
"(",
"rw_file",
")",
"as",
"in_handle",
":",
"for",
"line",
"in",
"in_handle",
":",
"if",
"line",
".",
"startswith",
"(",
"\"sys.path.append\"",
")",
":",
"file_version",
"=",
"line",
".",
... | Check if a run workflow file points to an older version of manta and needs a refresh. | [
"Check",
"if",
"a",
"run",
"workflow",
"file",
"points",
"to",
"an",
"older",
"version",
"of",
"manta",
"and",
"needs",
"a",
"refresh",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/manta.py#L171-L180 | train |
bcbio/bcbio-nextgen | bcbio/variation/freebayes.py | _freebayes_options_from_config | def _freebayes_options_from_config(items, config, out_file, region=None):
"""Prepare standard options from configuration input.
Input BED target files are merged to avoid overlapping regions which
cause FreeBayes to call multiple times.
Checks for empty sets of target regions after filtering for high ... | python | def _freebayes_options_from_config(items, config, out_file, region=None):
"""Prepare standard options from configuration input.
Input BED target files are merged to avoid overlapping regions which
cause FreeBayes to call multiple times.
Checks for empty sets of target regions after filtering for high ... | [
"def",
"_freebayes_options_from_config",
"(",
"items",
",",
"config",
",",
"out_file",
",",
"region",
"=",
"None",
")",
":",
"opts",
"=",
"[",
"\"--genotype-qualities\"",
",",
"\"--strict-vcf\"",
"]",
"cur_ploidy",
"=",
"ploidy",
".",
"get_ploidy",
"(",
"items",... | Prepare standard options from configuration input.
Input BED target files are merged to avoid overlapping regions which
cause FreeBayes to call multiple times.
Checks for empty sets of target regions after filtering for high depth,
in which case we should skip the FreeBayes run. | [
"Prepare",
"standard",
"options",
"from",
"configuration",
"input",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/freebayes.py#L29-L64 | train |
bcbio/bcbio-nextgen | bcbio/variation/freebayes.py | _add_somatic_opts | def _add_somatic_opts(opts, paired):
"""Add somatic options to current set. See _run_freebayes_paired for references.
"""
if "--min-alternate-fraction" not in opts and "-F" not in opts:
# add minimum reportable allele frequency
# FreeBayes defaults to 20%, but use 10% by default for the
... | python | def _add_somatic_opts(opts, paired):
"""Add somatic options to current set. See _run_freebayes_paired for references.
"""
if "--min-alternate-fraction" not in opts and "-F" not in opts:
# add minimum reportable allele frequency
# FreeBayes defaults to 20%, but use 10% by default for the
... | [
"def",
"_add_somatic_opts",
"(",
"opts",
",",
"paired",
")",
":",
"if",
"\"--min-alternate-fraction\"",
"not",
"in",
"opts",
"and",
"\"-F\"",
"not",
"in",
"opts",
":",
"# add minimum reportable allele frequency",
"# FreeBayes defaults to 20%, but use 10% by default for the",
... | Add somatic options to current set. See _run_freebayes_paired for references. | [
"Add",
"somatic",
"options",
"to",
"current",
"set",
".",
"See",
"_run_freebayes_paired",
"for",
"references",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/freebayes.py#L66-L79 | train |
bcbio/bcbio-nextgen | bcbio/variation/freebayes.py | _run_freebayes_caller | def _run_freebayes_caller(align_bams, items, ref_file, assoc_files,
region=None, out_file=None, somatic=None):
"""Detect SNPs and indels with FreeBayes.
Performs post-filtering to remove very low quality variants which
can cause issues feeding into GATK. Breaks variants into indiv... | python | def _run_freebayes_caller(align_bams, items, ref_file, assoc_files,
region=None, out_file=None, somatic=None):
"""Detect SNPs and indels with FreeBayes.
Performs post-filtering to remove very low quality variants which
can cause issues feeding into GATK. Breaks variants into indiv... | [
"def",
"_run_freebayes_caller",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"assoc_files",
",",
"region",
"=",
"None",
",",
"out_file",
"=",
"None",
",",
"somatic",
"=",
"None",
")",
":",
"config",
"=",
"items",
"[",
"0",
"]",
"[",
"\"config\"... | Detect SNPs and indels with FreeBayes.
Performs post-filtering to remove very low quality variants which
can cause issues feeding into GATK. Breaks variants into individual
allelic primitives for analysis and evaluation. | [
"Detect",
"SNPs",
"and",
"indels",
"with",
"FreeBayes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/freebayes.py#L102-L144 | train |
bcbio/bcbio-nextgen | bcbio/variation/freebayes.py | _check_lods | def _check_lods(parts, tumor_thresh, normal_thresh, indexes):
"""Ensure likelihoods for tumor and normal pass thresholds.
Skipped if no FreeBayes GL annotations available.
"""
try:
gl_index = parts[8].split(":").index("GL")
except ValueError:
return True
try:
tumor_gls =... | python | def _check_lods(parts, tumor_thresh, normal_thresh, indexes):
"""Ensure likelihoods for tumor and normal pass thresholds.
Skipped if no FreeBayes GL annotations available.
"""
try:
gl_index = parts[8].split(":").index("GL")
except ValueError:
return True
try:
tumor_gls =... | [
"def",
"_check_lods",
"(",
"parts",
",",
"tumor_thresh",
",",
"normal_thresh",
",",
"indexes",
")",
":",
"try",
":",
"gl_index",
"=",
"parts",
"[",
"8",
"]",
".",
"split",
"(",
"\":\"",
")",
".",
"index",
"(",
"\"GL\"",
")",
"except",
"ValueError",
":"... | Ensure likelihoods for tumor and normal pass thresholds.
Skipped if no FreeBayes GL annotations available. | [
"Ensure",
"likelihoods",
"for",
"tumor",
"and",
"normal",
"pass",
"thresholds",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/freebayes.py#L197-L224 | train |
bcbio/bcbio-nextgen | bcbio/variation/freebayes.py | _check_freqs | def _check_freqs(parts, indexes):
"""Ensure frequency of tumor to normal passes a reasonable threshold.
Avoids calling low frequency tumors also present at low frequency in normals,
which indicates a contamination or persistent error.
"""
thresh_ratio = 2.7
try: # FreeBayes
ao_index = ... | python | def _check_freqs(parts, indexes):
"""Ensure frequency of tumor to normal passes a reasonable threshold.
Avoids calling low frequency tumors also present at low frequency in normals,
which indicates a contamination or persistent error.
"""
thresh_ratio = 2.7
try: # FreeBayes
ao_index = ... | [
"def",
"_check_freqs",
"(",
"parts",
",",
"indexes",
")",
":",
"thresh_ratio",
"=",
"2.7",
"try",
":",
"# FreeBayes",
"ao_index",
"=",
"parts",
"[",
"8",
"]",
".",
"split",
"(",
"\":\"",
")",
".",
"index",
"(",
"\"AO\"",
")",
"ro_index",
"=",
"parts",
... | Ensure frequency of tumor to normal passes a reasonable threshold.
Avoids calling low frequency tumors also present at low frequency in normals,
which indicates a contamination or persistent error. | [
"Ensure",
"frequency",
"of",
"tumor",
"to",
"normal",
"passes",
"a",
"reasonable",
"threshold",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/freebayes.py#L226-L260 | train |
bcbio/bcbio-nextgen | bcbio/variation/freebayes.py | _clean_freebayes_output | def _clean_freebayes_output(line):
"""Clean FreeBayes output to make post-processing with GATK happy.
XXX Not applied on recent versions which fix issues to be more compatible
with bgzip output, but retained in case of need.
- Remove lines from FreeBayes outputs where REF/ALT are identical:
2 ... | python | def _clean_freebayes_output(line):
"""Clean FreeBayes output to make post-processing with GATK happy.
XXX Not applied on recent versions which fix issues to be more compatible
with bgzip output, but retained in case of need.
- Remove lines from FreeBayes outputs where REF/ALT are identical:
2 ... | [
"def",
"_clean_freebayes_output",
"(",
"line",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"\"#\"",
")",
":",
"line",
"=",
"line",
".",
"replace",
"(",
"\"Type=Int,D\"",
",",
"\"Type=Integer,D\"",
")",
"return",
"line",
"else",
":",
"parts",
"=",
"line... | Clean FreeBayes output to make post-processing with GATK happy.
XXX Not applied on recent versions which fix issues to be more compatible
with bgzip output, but retained in case of need.
- Remove lines from FreeBayes outputs where REF/ALT are identical:
2 22816178 . G G ... | [
"Clean",
"FreeBayes",
"output",
"to",
"make",
"post",
"-",
"processing",
"with",
"GATK",
"happy",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/freebayes.py#L332-L353 | train |
bcbio/bcbio-nextgen | bcbio/variation/freebayes.py | clean_vcf_output | def clean_vcf_output(orig_file, clean_fn, config, name="clean"):
"""Provide framework to clean a file in-place, with the specified clean
function.
"""
base, ext = utils.splitext_plus(orig_file)
out_file = "{0}-{1}{2}".format(base, name, ext)
if not utils.file_exists(out_file):
with open(... | python | def clean_vcf_output(orig_file, clean_fn, config, name="clean"):
"""Provide framework to clean a file in-place, with the specified clean
function.
"""
base, ext = utils.splitext_plus(orig_file)
out_file = "{0}-{1}{2}".format(base, name, ext)
if not utils.file_exists(out_file):
with open(... | [
"def",
"clean_vcf_output",
"(",
"orig_file",
",",
"clean_fn",
",",
"config",
",",
"name",
"=",
"\"clean\"",
")",
":",
"base",
",",
"ext",
"=",
"utils",
".",
"splitext_plus",
"(",
"orig_file",
")",
"out_file",
"=",
"\"{0}-{1}{2}\"",
".",
"format",
"(",
"bas... | Provide framework to clean a file in-place, with the specified clean
function. | [
"Provide",
"framework",
"to",
"clean",
"a",
"file",
"in",
"-",
"place",
"with",
"the",
"specified",
"clean",
"function",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/freebayes.py#L355-L372 | train |
bcbio/bcbio-nextgen | bcbio/variation/effects.py | get_type | def get_type(data):
"""Retrieve the type of effects calculation to do.
"""
if data["analysis"].lower().startswith("var") or dd.get_variantcaller(data):
return tz.get_in(("config", "algorithm", "effects"), data, "snpeff") | python | def get_type(data):
"""Retrieve the type of effects calculation to do.
"""
if data["analysis"].lower().startswith("var") or dd.get_variantcaller(data):
return tz.get_in(("config", "algorithm", "effects"), data, "snpeff") | [
"def",
"get_type",
"(",
"data",
")",
":",
"if",
"data",
"[",
"\"analysis\"",
"]",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"\"var\"",
")",
"or",
"dd",
".",
"get_variantcaller",
"(",
"data",
")",
":",
"return",
"tz",
".",
"get_in",
"(",
"(",
... | Retrieve the type of effects calculation to do. | [
"Retrieve",
"the",
"type",
"of",
"effects",
"calculation",
"to",
"do",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/effects.py#L46-L50 | train |
bcbio/bcbio-nextgen | bcbio/variation/effects.py | prep_vep_cache | def prep_vep_cache(dbkey, ref_file, tooldir=None, config=None):
"""Ensure correct installation of VEP cache file.
"""
if config is None: config = {}
resource_file = os.path.join(os.path.dirname(ref_file), "%s-resources.yaml" % dbkey)
if os.path.exists(resource_file):
with open(resource_file)... | python | def prep_vep_cache(dbkey, ref_file, tooldir=None, config=None):
"""Ensure correct installation of VEP cache file.
"""
if config is None: config = {}
resource_file = os.path.join(os.path.dirname(ref_file), "%s-resources.yaml" % dbkey)
if os.path.exists(resource_file):
with open(resource_file)... | [
"def",
"prep_vep_cache",
"(",
"dbkey",
",",
"ref_file",
",",
"tooldir",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"if",
"config",
"is",
"None",
":",
"config",
"=",
"{",
"}",
"resource_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
... | Ensure correct installation of VEP cache file. | [
"Ensure",
"correct",
"installation",
"of",
"VEP",
"cache",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/effects.py#L74-L117 | train |
bcbio/bcbio-nextgen | bcbio/variation/effects.py | _get_G2P | def _get_G2P(data):
"""
A VEP plugin that uses G2P allelic requirements to assess variants in genes
for potential phenotype involvement.
"""
G2P_file = os.path.realpath(tz.get_in(("genome_resources", "variation", "genotype2phenotype"), data))
args = ["--plugin", "G2P,file:%s" % (G2P_file)]
i... | python | def _get_G2P(data):
"""
A VEP plugin that uses G2P allelic requirements to assess variants in genes
for potential phenotype involvement.
"""
G2P_file = os.path.realpath(tz.get_in(("genome_resources", "variation", "genotype2phenotype"), data))
args = ["--plugin", "G2P,file:%s" % (G2P_file)]
i... | [
"def",
"_get_G2P",
"(",
"data",
")",
":",
"G2P_file",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"tz",
".",
"get_in",
"(",
"(",
"\"genome_resources\"",
",",
"\"variation\"",
",",
"\"genotype2phenotype\"",
")",
",",
"data",
")",
")",
"args",
"=",
"[",
... | A VEP plugin that uses G2P allelic requirements to assess variants in genes
for potential phenotype involvement. | [
"A",
"VEP",
"plugin",
"that",
"uses",
"G2P",
"allelic",
"requirements",
"to",
"assess",
"variants",
"in",
"genes",
"for",
"potential",
"phenotype",
"involvement",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/effects.py#L234-L244 | train |
bcbio/bcbio-nextgen | bcbio/variation/effects.py | _snpeff_args_from_config | def _snpeff_args_from_config(data):
"""Retrieve snpEff arguments supplied through input configuration.
"""
config = data["config"]
args = ["-hgvs"]
# General supplied arguments
resources = config_utils.get_resources("snpeff", config)
if resources.get("options"):
args += [str(x) for x... | python | def _snpeff_args_from_config(data):
"""Retrieve snpEff arguments supplied through input configuration.
"""
config = data["config"]
args = ["-hgvs"]
# General supplied arguments
resources = config_utils.get_resources("snpeff", config)
if resources.get("options"):
args += [str(x) for x... | [
"def",
"_snpeff_args_from_config",
"(",
"data",
")",
":",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"args",
"=",
"[",
"\"-hgvs\"",
"]",
"# General supplied arguments",
"resources",
"=",
"config_utils",
".",
"get_resources",
"(",
"\"snpeff\"",
",",
"config",
... | Retrieve snpEff arguments supplied through input configuration. | [
"Retrieve",
"snpEff",
"arguments",
"supplied",
"through",
"input",
"configuration",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/effects.py#L266-L288 | train |
bcbio/bcbio-nextgen | bcbio/variation/effects.py | get_db | def get_db(data):
"""Retrieve a snpEff database name and location relative to reference file.
"""
snpeff_db = utils.get_in(data, ("genome_resources", "aliases", "snpeff"))
snpeff_base_dir = None
if snpeff_db:
snpeff_base_dir = utils.get_in(data, ("reference", "snpeff"))
if not (isins... | python | def get_db(data):
"""Retrieve a snpEff database name and location relative to reference file.
"""
snpeff_db = utils.get_in(data, ("genome_resources", "aliases", "snpeff"))
snpeff_base_dir = None
if snpeff_db:
snpeff_base_dir = utils.get_in(data, ("reference", "snpeff"))
if not (isins... | [
"def",
"get_db",
"(",
"data",
")",
":",
"snpeff_db",
"=",
"utils",
".",
"get_in",
"(",
"data",
",",
"(",
"\"genome_resources\"",
",",
"\"aliases\"",
",",
"\"snpeff\"",
")",
")",
"snpeff_base_dir",
"=",
"None",
"if",
"snpeff_db",
":",
"snpeff_base_dir",
"=",
... | Retrieve a snpEff database name and location relative to reference file. | [
"Retrieve",
"a",
"snpEff",
"database",
"name",
"and",
"location",
"relative",
"to",
"reference",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/effects.py#L290-L320 | train |
bcbio/bcbio-nextgen | bcbio/variation/effects.py | _get_snpeff_cmd | def _get_snpeff_cmd(cmd_name, datadir, data, out_file):
"""Retrieve snpEff base command line.
"""
resources = config_utils.get_resources("snpeff", data["config"])
jvm_opts = resources.get("jvm_opts", ["-Xms750m", "-Xmx3g"])
# scale by cores, defaulting to 2x base usage to ensure we have enough memor... | python | def _get_snpeff_cmd(cmd_name, datadir, data, out_file):
"""Retrieve snpEff base command line.
"""
resources = config_utils.get_resources("snpeff", data["config"])
jvm_opts = resources.get("jvm_opts", ["-Xms750m", "-Xmx3g"])
# scale by cores, defaulting to 2x base usage to ensure we have enough memor... | [
"def",
"_get_snpeff_cmd",
"(",
"cmd_name",
",",
"datadir",
",",
"data",
",",
"out_file",
")",
":",
"resources",
"=",
"config_utils",
".",
"get_resources",
"(",
"\"snpeff\"",
",",
"data",
"[",
"\"config\"",
"]",
")",
"jvm_opts",
"=",
"resources",
".",
"get",
... | Retrieve snpEff base command line. | [
"Retrieve",
"snpEff",
"base",
"command",
"line",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/effects.py#L339-L358 | train |
bcbio/bcbio-nextgen | bcbio/variation/effects.py | _run_snpeff | def _run_snpeff(snp_in, out_format, data):
"""Run effects prediction with snpEff, skipping if snpEff database not present.
"""
snpeff_db, datadir = get_db(data)
if not snpeff_db:
return None, None
assert os.path.exists(os.path.join(datadir, snpeff_db)), \
"Did not find %s snpEff gen... | python | def _run_snpeff(snp_in, out_format, data):
"""Run effects prediction with snpEff, skipping if snpEff database not present.
"""
snpeff_db, datadir = get_db(data)
if not snpeff_db:
return None, None
assert os.path.exists(os.path.join(datadir, snpeff_db)), \
"Did not find %s snpEff gen... | [
"def",
"_run_snpeff",
"(",
"snp_in",
",",
"out_format",
",",
"data",
")",
":",
"snpeff_db",
",",
"datadir",
"=",
"get_db",
"(",
"data",
")",
"if",
"not",
"snpeff_db",
":",
"return",
"None",
",",
"None",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
... | Run effects prediction with snpEff, skipping if snpEff database not present. | [
"Run",
"effects",
"prediction",
"with",
"snpEff",
"skipping",
"if",
"snpEff",
"database",
"not",
"present",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/effects.py#L360-L386 | train |
bcbio/bcbio-nextgen | bcbio/variation/effects.py | _installed_snpeff_genome | def _installed_snpeff_genome(base_name, config):
"""Find the most recent installed genome for snpEff with the given name.
"""
snpeff_config_file = os.path.join(config_utils.get_program("snpeff", config, "dir"),
"snpEff.config")
if os.path.exists(snpeff_config_file):... | python | def _installed_snpeff_genome(base_name, config):
"""Find the most recent installed genome for snpEff with the given name.
"""
snpeff_config_file = os.path.join(config_utils.get_program("snpeff", config, "dir"),
"snpEff.config")
if os.path.exists(snpeff_config_file):... | [
"def",
"_installed_snpeff_genome",
"(",
"base_name",
",",
"config",
")",
":",
"snpeff_config_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"config_utils",
".",
"get_program",
"(",
"\"snpeff\"",
",",
"config",
",",
"\"dir\"",
")",
",",
"\"snpEff.config\"",
"... | Find the most recent installed genome for snpEff with the given name. | [
"Find",
"the",
"most",
"recent",
"installed",
"genome",
"for",
"snpEff",
"with",
"the",
"given",
"name",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/effects.py#L400-L415 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/minimap2.py | remap_index_fn | def remap_index_fn(ref_file):
"""minimap2 can build indexes on the fly but will also store commons ones.
"""
index_dir = os.path.join(os.path.dirname(ref_file), os.pardir, "minimap2")
if os.path.exists(index_dir) and os.path.isdir(index_dir):
return index_dir
else:
return os.path.dir... | python | def remap_index_fn(ref_file):
"""minimap2 can build indexes on the fly but will also store commons ones.
"""
index_dir = os.path.join(os.path.dirname(ref_file), os.pardir, "minimap2")
if os.path.exists(index_dir) and os.path.isdir(index_dir):
return index_dir
else:
return os.path.dir... | [
"def",
"remap_index_fn",
"(",
"ref_file",
")",
":",
"index_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"ref_file",
")",
",",
"os",
".",
"pardir",
",",
"\"minimap2\"",
")",
"if",
"os",
".",
"path",
".",
"e... | minimap2 can build indexes on the fly but will also store commons ones. | [
"minimap2",
"can",
"build",
"indexes",
"on",
"the",
"fly",
"but",
"will",
"also",
"store",
"commons",
"ones",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/minimap2.py#L44-L51 | train |
bcbio/bcbio-nextgen | scripts/bcbio_prepare_samples.py | create_new_csv | def create_new_csv(samples, args):
"""create csv file that can be use with bcbio -w template"""
out_fn = os.path.splitext(args.csv)[0] + "-merged.csv"
logger.info("Preparing new csv: %s" % out_fn)
with file_transaction(out_fn) as tx_out:
with open(tx_out, 'w') as handle:
handle.write... | python | def create_new_csv(samples, args):
"""create csv file that can be use with bcbio -w template"""
out_fn = os.path.splitext(args.csv)[0] + "-merged.csv"
logger.info("Preparing new csv: %s" % out_fn)
with file_transaction(out_fn) as tx_out:
with open(tx_out, 'w') as handle:
handle.write... | [
"def",
"create_new_csv",
"(",
"samples",
",",
"args",
")",
":",
"out_fn",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"args",
".",
"csv",
")",
"[",
"0",
"]",
"+",
"\"-merged.csv\"",
"logger",
".",
"info",
"(",
"\"Preparing new csv: %s\"",
"%",
"out_fn"... | create csv file that can be use with bcbio -w template | [
"create",
"csv",
"file",
"that",
"can",
"be",
"use",
"with",
"bcbio",
"-",
"w",
"template"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/bcbio_prepare_samples.py#L23-L32 | train |
bcbio/bcbio-nextgen | scripts/bcbio_prepare_samples.py | _get_samples_to_process | def _get_samples_to_process(fn, out_dir, config, force_single, separators):
"""parse csv file with one line per file. It will merge
all files that have the same description name"""
out_dir = os.path.abspath(out_dir)
samples = defaultdict(list)
with open(fn) as handle:
for l in handle:
... | python | def _get_samples_to_process(fn, out_dir, config, force_single, separators):
"""parse csv file with one line per file. It will merge
all files that have the same description name"""
out_dir = os.path.abspath(out_dir)
samples = defaultdict(list)
with open(fn) as handle:
for l in handle:
... | [
"def",
"_get_samples_to_process",
"(",
"fn",
",",
"out_dir",
",",
"config",
",",
"force_single",
",",
"separators",
")",
":",
"out_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"out_dir",
")",
"samples",
"=",
"defaultdict",
"(",
"list",
")",
"with",
... | parse csv file with one line per file. It will merge
all files that have the same description name | [
"parse",
"csv",
"file",
"with",
"one",
"line",
"per",
"file",
".",
"It",
"will",
"merge",
"all",
"files",
"that",
"have",
"the",
"same",
"description",
"name"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/bcbio_prepare_samples.py#L41-L83 | train |
bcbio/bcbio-nextgen | scripts/bcbio_prepare_samples.py | _check_stems | def _check_stems(files):
"""check if stem names are the same and use full path then"""
used = set()
for fn in files:
if os.path.basename(fn) in used:
logger.warning("%s stem is multiple times in your file list, "
"so we don't know "
"how ... | python | def _check_stems(files):
"""check if stem names are the same and use full path then"""
used = set()
for fn in files:
if os.path.basename(fn) in used:
logger.warning("%s stem is multiple times in your file list, "
"so we don't know "
"how ... | [
"def",
"_check_stems",
"(",
"files",
")",
":",
"used",
"=",
"set",
"(",
")",
"for",
"fn",
"in",
"files",
":",
"if",
"os",
".",
"path",
".",
"basename",
"(",
"fn",
")",
"in",
"used",
":",
"logger",
".",
"warning",
"(",
"\"%s stem is multiple times in yo... | check if stem names are the same and use full path then | [
"check",
"if",
"stem",
"names",
"are",
"the",
"same",
"and",
"use",
"full",
"path",
"then"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/bcbio_prepare_samples.py#L86-L101 | train |
bcbio/bcbio-nextgen | scripts/bcbio_prepare_samples.py | get_cluster_view | def get_cluster_view(p):
"""get ipython running"""
from cluster_helper import cluster as ipc
return ipc.cluster_view(p['scheduler'], p['queue'], p['num_jobs'], p['cores_per_job'], start_wait=p['timeout'], extra_params={"resources": p['resources'], "mem": p['mem'], "tag": p['tag'], "run_local": False}) | python | def get_cluster_view(p):
"""get ipython running"""
from cluster_helper import cluster as ipc
return ipc.cluster_view(p['scheduler'], p['queue'], p['num_jobs'], p['cores_per_job'], start_wait=p['timeout'], extra_params={"resources": p['resources'], "mem": p['mem'], "tag": p['tag'], "run_local": False}) | [
"def",
"get_cluster_view",
"(",
"p",
")",
":",
"from",
"cluster_helper",
"import",
"cluster",
"as",
"ipc",
"return",
"ipc",
".",
"cluster_view",
"(",
"p",
"[",
"'scheduler'",
"]",
",",
"p",
"[",
"'queue'",
"]",
",",
"p",
"[",
"'num_jobs'",
"]",
",",
"p... | get ipython running | [
"get",
"ipython",
"running"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/bcbio_prepare_samples.py#L114-L117 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | from_sample | def from_sample(sample):
"""Upload results of processing from an analysis pipeline sample.
"""
upload_config = sample.get("upload")
if upload_config:
approach = _approaches[upload_config.get("method", "filesystem")]
for finfo in _get_files(sample):
approach.update_file(finfo,... | python | def from_sample(sample):
"""Upload results of processing from an analysis pipeline sample.
"""
upload_config = sample.get("upload")
if upload_config:
approach = _approaches[upload_config.get("method", "filesystem")]
for finfo in _get_files(sample):
approach.update_file(finfo,... | [
"def",
"from_sample",
"(",
"sample",
")",
":",
"upload_config",
"=",
"sample",
".",
"get",
"(",
"\"upload\"",
")",
"if",
"upload_config",
":",
"approach",
"=",
"_approaches",
"[",
"upload_config",
".",
"get",
"(",
"\"method\"",
",",
"\"filesystem\"",
")",
"]... | Upload results of processing from an analysis pipeline sample. | [
"Upload",
"results",
"of",
"processing",
"from",
"an",
"analysis",
"pipeline",
"sample",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L29-L37 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | _get_files | def _get_files(sample):
"""Retrieve files for the sample, dispatching by analysis type.
Each file is a dictionary containing the path plus associated
metadata about the file and pipeline versions.
"""
analysis = sample.get("analysis")
if analysis.lower() in ["variant", "snp calling", "variant2"... | python | def _get_files(sample):
"""Retrieve files for the sample, dispatching by analysis type.
Each file is a dictionary containing the path plus associated
metadata about the file and pipeline versions.
"""
analysis = sample.get("analysis")
if analysis.lower() in ["variant", "snp calling", "variant2"... | [
"def",
"_get_files",
"(",
"sample",
")",
":",
"analysis",
"=",
"sample",
".",
"get",
"(",
"\"analysis\"",
")",
"if",
"analysis",
".",
"lower",
"(",
")",
"in",
"[",
"\"variant\"",
",",
"\"snp calling\"",
",",
"\"variant2\"",
",",
"\"standard\"",
"]",
":",
... | Retrieve files for the sample, dispatching by analysis type.
Each file is a dictionary containing the path plus associated
metadata about the file and pipeline versions. | [
"Retrieve",
"files",
"for",
"the",
"sample",
"dispatching",
"by",
"analysis",
"type",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L56-L74 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | _add_meta | def _add_meta(xs, sample=None, config=None):
"""Add top level information about the sample or flowcell to output.
Sorts outputs into sample names (sample input) and project (config input).
"""
out = []
for x in xs:
if not isinstance(x["path"], six.string_types) or not os.path.exists(x["path... | python | def _add_meta(xs, sample=None, config=None):
"""Add top level information about the sample or flowcell to output.
Sorts outputs into sample names (sample input) and project (config input).
"""
out = []
for x in xs:
if not isinstance(x["path"], six.string_types) or not os.path.exists(x["path... | [
"def",
"_add_meta",
"(",
"xs",
",",
"sample",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"out",
"=",
"[",
"]",
"for",
"x",
"in",
"xs",
":",
"if",
"not",
"isinstance",
"(",
"x",
"[",
"\"path\"",
"]",
",",
"six",
".",
"string_types",
")",
... | Add top level information about the sample or flowcell to output.
Sorts outputs into sample names (sample input) and project (config input). | [
"Add",
"top",
"level",
"information",
"about",
"the",
"sample",
"or",
"flowcell",
"to",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L123-L144 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | _get_files_variantcall | def _get_files_variantcall(sample):
"""Return output files for the variant calling pipeline.
"""
out = []
algorithm = sample["config"]["algorithm"]
out = _maybe_add_summary(algorithm, sample, out)
out = _maybe_add_alignment(algorithm, sample, out)
out = _maybe_add_callable(sample, out)
o... | python | def _get_files_variantcall(sample):
"""Return output files for the variant calling pipeline.
"""
out = []
algorithm = sample["config"]["algorithm"]
out = _maybe_add_summary(algorithm, sample, out)
out = _maybe_add_alignment(algorithm, sample, out)
out = _maybe_add_callable(sample, out)
o... | [
"def",
"_get_files_variantcall",
"(",
"sample",
")",
":",
"out",
"=",
"[",
"]",
"algorithm",
"=",
"sample",
"[",
"\"config\"",
"]",
"[",
"\"algorithm\"",
"]",
"out",
"=",
"_maybe_add_summary",
"(",
"algorithm",
",",
"sample",
",",
"out",
")",
"out",
"=",
... | Return output files for the variant calling pipeline. | [
"Return",
"output",
"files",
"for",
"the",
"variant",
"calling",
"pipeline",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L146-L161 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | _maybe_add_callable | def _maybe_add_callable(data, out):
"""Add callable and depth regions to output folder.
"""
callable_bed = dd.get_sample_callable(data)
if callable_bed:
out.append({"path": callable_bed, "type": "bed", "ext": "callable"})
perbase_bed = tz.get_in(["depth", "variant_regions", "per_base"], data... | python | def _maybe_add_callable(data, out):
"""Add callable and depth regions to output folder.
"""
callable_bed = dd.get_sample_callable(data)
if callable_bed:
out.append({"path": callable_bed, "type": "bed", "ext": "callable"})
perbase_bed = tz.get_in(["depth", "variant_regions", "per_base"], data... | [
"def",
"_maybe_add_callable",
"(",
"data",
",",
"out",
")",
":",
"callable_bed",
"=",
"dd",
".",
"get_sample_callable",
"(",
"data",
")",
"if",
"callable_bed",
":",
"out",
".",
"append",
"(",
"{",
"\"path\"",
":",
"callable_bed",
",",
"\"type\"",
":",
"\"b... | Add callable and depth regions to output folder. | [
"Add",
"callable",
"and",
"depth",
"regions",
"to",
"output",
"folder",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L183-L192 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | _get_batch_name | def _get_batch_name(sample):
"""Retrieve batch name for use in SV calling outputs.
Handles multiple batches split via SV calling.
"""
batch = dd.get_batch(sample) or dd.get_sample_name(sample)
if isinstance(batch, (list, tuple)) and len(batch) > 1:
batch = dd.get_sample_name(sample)
ret... | python | def _get_batch_name(sample):
"""Retrieve batch name for use in SV calling outputs.
Handles multiple batches split via SV calling.
"""
batch = dd.get_batch(sample) or dd.get_sample_name(sample)
if isinstance(batch, (list, tuple)) and len(batch) > 1:
batch = dd.get_sample_name(sample)
ret... | [
"def",
"_get_batch_name",
"(",
"sample",
")",
":",
"batch",
"=",
"dd",
".",
"get_batch",
"(",
"sample",
")",
"or",
"dd",
".",
"get_sample_name",
"(",
"sample",
")",
"if",
"isinstance",
"(",
"batch",
",",
"(",
"list",
",",
"tuple",
")",
")",
"and",
"l... | Retrieve batch name for use in SV calling outputs.
Handles multiple batches split via SV calling. | [
"Retrieve",
"batch",
"name",
"for",
"use",
"in",
"SV",
"calling",
"outputs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L236-L244 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | _sample_variant_file_in_population | def _sample_variant_file_in_population(x):
"""Check if a sample file is the same as the population file.
This is true for batches where we don't extract into samples and do not
run decomposition for gemini.
'"""
if "population" in x:
a = _get_project_vcf(x)
b = _get_variant_file(x, ... | python | def _sample_variant_file_in_population(x):
"""Check if a sample file is the same as the population file.
This is true for batches where we don't extract into samples and do not
run decomposition for gemini.
'"""
if "population" in x:
a = _get_project_vcf(x)
b = _get_variant_file(x, ... | [
"def",
"_sample_variant_file_in_population",
"(",
"x",
")",
":",
"if",
"\"population\"",
"in",
"x",
":",
"a",
"=",
"_get_project_vcf",
"(",
"x",
")",
"b",
"=",
"_get_variant_file",
"(",
"x",
",",
"(",
"\"vrn_file\"",
",",
")",
")",
"decomposed",
"=",
"tz",... | Check if a sample file is the same as the population file.
This is true for batches where we don't extract into samples and do not
run decomposition for gemini. | [
"Check",
"if",
"a",
"sample",
"file",
"is",
"the",
"same",
"as",
"the",
"population",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L316-L329 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | _get_variant_file | def _get_variant_file(x, key, suffix="", sample=None, ignore_do_upload=False):
"""Retrieve VCF file with the given key if it exists, handling bgzipped.
"""
out = []
fname = utils.get_in(x, key)
upload_key = list(key)
upload_key[-1] = "do_upload"
do_upload = tz.get_in(tuple(upload_key), x, Tr... | python | def _get_variant_file(x, key, suffix="", sample=None, ignore_do_upload=False):
"""Retrieve VCF file with the given key if it exists, handling bgzipped.
"""
out = []
fname = utils.get_in(x, key)
upload_key = list(key)
upload_key[-1] = "do_upload"
do_upload = tz.get_in(tuple(upload_key), x, Tr... | [
"def",
"_get_variant_file",
"(",
"x",
",",
"key",
",",
"suffix",
"=",
"\"\"",
",",
"sample",
"=",
"None",
",",
"ignore_do_upload",
"=",
"False",
")",
":",
"out",
"=",
"[",
"]",
"fname",
"=",
"utils",
".",
"get_in",
"(",
"x",
",",
"key",
")",
"uploa... | Retrieve VCF file with the given key if it exists, handling bgzipped. | [
"Retrieve",
"VCF",
"file",
"with",
"the",
"given",
"key",
"if",
"it",
"exists",
"handling",
"bgzipped",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L331-L368 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | _add_batch | def _add_batch(x, sample):
"""Potentially add batch name to an upload file.
"""
added = False
for batch in sorted(dd.get_batches(sample) or [], key=len, reverse=True):
if batch and os.path.basename(x["path"]).startswith(("%s-" % batch, "%s.vcf" % batch)):
x["batch"] = batch
... | python | def _add_batch(x, sample):
"""Potentially add batch name to an upload file.
"""
added = False
for batch in sorted(dd.get_batches(sample) or [], key=len, reverse=True):
if batch and os.path.basename(x["path"]).startswith(("%s-" % batch, "%s.vcf" % batch)):
x["batch"] = batch
... | [
"def",
"_add_batch",
"(",
"x",
",",
"sample",
")",
":",
"added",
"=",
"False",
"for",
"batch",
"in",
"sorted",
"(",
"dd",
".",
"get_batches",
"(",
"sample",
")",
"or",
"[",
"]",
",",
"key",
"=",
"len",
",",
"reverse",
"=",
"True",
")",
":",
"if",... | Potentially add batch name to an upload file. | [
"Potentially",
"add",
"batch",
"name",
"to",
"an",
"upload",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L638-L649 | train |
bcbio/bcbio-nextgen | bcbio/upload/__init__.py | _get_project_vcf | def _get_project_vcf(x, suffix=""):
"""Get our project VCF, either from the population or the variant batch file.
"""
vcfs = _get_variant_file(x, ("population", "vcf"), suffix=suffix)
if not vcfs:
vcfs = _get_variant_file(x, ("vrn_file_batch", ), suffix=suffix, ignore_do_upload=True)
if ... | python | def _get_project_vcf(x, suffix=""):
"""Get our project VCF, either from the population or the variant batch file.
"""
vcfs = _get_variant_file(x, ("population", "vcf"), suffix=suffix)
if not vcfs:
vcfs = _get_variant_file(x, ("vrn_file_batch", ), suffix=suffix, ignore_do_upload=True)
if ... | [
"def",
"_get_project_vcf",
"(",
"x",
",",
"suffix",
"=",
"\"\"",
")",
":",
"vcfs",
"=",
"_get_variant_file",
"(",
"x",
",",
"(",
"\"population\"",
",",
"\"vcf\"",
")",
",",
"suffix",
"=",
"suffix",
")",
"if",
"not",
"vcfs",
":",
"vcfs",
"=",
"_get_vari... | Get our project VCF, either from the population or the variant batch file. | [
"Get",
"our",
"project",
"VCF",
"either",
"from",
"the",
"population",
"or",
"the",
"variant",
"batch",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L651-L659 | train |
bcbio/bcbio-nextgen | scripts/utils/resort_bam_karyotype.py | _id_remapper | def _id_remapper(orig, new):
"""Provide a dictionary remapping original read indexes to new indexes.
When re-ordering the header, the individual read identifiers need to be
updated as well.
"""
new_chrom_to_index = {}
for i_n, (chr_n, _) in enumerate(new):
new_chrom_to_index[chr_n] = i_... | python | def _id_remapper(orig, new):
"""Provide a dictionary remapping original read indexes to new indexes.
When re-ordering the header, the individual read identifiers need to be
updated as well.
"""
new_chrom_to_index = {}
for i_n, (chr_n, _) in enumerate(new):
new_chrom_to_index[chr_n] = i_... | [
"def",
"_id_remapper",
"(",
"orig",
",",
"new",
")",
":",
"new_chrom_to_index",
"=",
"{",
"}",
"for",
"i_n",
",",
"(",
"chr_n",
",",
"_",
")",
"in",
"enumerate",
"(",
"new",
")",
":",
"new_chrom_to_index",
"[",
"chr_n",
"]",
"=",
"i_n",
"remap_indexes"... | Provide a dictionary remapping original read indexes to new indexes.
When re-ordering the header, the individual read identifiers need to be
updated as well. | [
"Provide",
"a",
"dictionary",
"remapping",
"original",
"read",
"indexes",
"to",
"new",
"indexes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/resort_bam_karyotype.py#L67-L81 | train |
bcbio/bcbio-nextgen | scripts/bcbio_setup_genome.py | _clean_rec_name | def _clean_rec_name(rec):
"""Clean illegal characters in input fasta file which cause problems downstream.
"""
out_id = []
for char in list(rec.id):
if char in ALLOWED_CONTIG_NAME_CHARS:
out_id.append(char)
else:
out_id.append("_")
rec.id = "".join(out_id)
... | python | def _clean_rec_name(rec):
"""Clean illegal characters in input fasta file which cause problems downstream.
"""
out_id = []
for char in list(rec.id):
if char in ALLOWED_CONTIG_NAME_CHARS:
out_id.append(char)
else:
out_id.append("_")
rec.id = "".join(out_id)
... | [
"def",
"_clean_rec_name",
"(",
"rec",
")",
":",
"out_id",
"=",
"[",
"]",
"for",
"char",
"in",
"list",
"(",
"rec",
".",
"id",
")",
":",
"if",
"char",
"in",
"ALLOWED_CONTIG_NAME_CHARS",
":",
"out_id",
".",
"append",
"(",
"char",
")",
"else",
":",
"out_... | Clean illegal characters in input fasta file which cause problems downstream. | [
"Clean",
"illegal",
"characters",
"in",
"input",
"fasta",
"file",
"which",
"cause",
"problems",
"downstream",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/bcbio_setup_genome.py#L151-L162 | train |
bcbio/bcbio-nextgen | bcbio/qc/kraken.py | run | def run(_, data, out_dir):
"""Run kraken, generating report in specified directory and parsing metrics.
Using only first paired reads.
"""
# logger.info("Number of aligned reads < than 0.60 in %s: %s" % (dd.get_sample_name(data), ratio))
logger.info("Running kraken to determine contaminant: %s" %... | python | def run(_, data, out_dir):
"""Run kraken, generating report in specified directory and parsing metrics.
Using only first paired reads.
"""
# logger.info("Number of aligned reads < than 0.60 in %s: %s" % (dd.get_sample_name(data), ratio))
logger.info("Running kraken to determine contaminant: %s" %... | [
"def",
"run",
"(",
"_",
",",
"data",
",",
"out_dir",
")",
":",
"# logger.info(\"Number of aligned reads < than 0.60 in %s: %s\" % (dd.get_sample_name(data), ratio))",
"logger",
".",
"info",
"(",
"\"Running kraken to determine contaminant: %s\"",
"%",
"dd",
".",
"get_sample_name... | Run kraken, generating report in specified directory and parsing metrics.
Using only first paired reads. | [
"Run",
"kraken",
"generating",
"report",
"in",
"specified",
"directory",
"and",
"parsing",
"metrics",
".",
"Using",
"only",
"first",
"paired",
"reads",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/kraken.py#L16-L57 | train |
bcbio/bcbio-nextgen | bcbio/qc/kraken.py | _parse_kraken_output | def _parse_kraken_output(out_dir, db, data):
"""Parse kraken stat info comming from stderr,
generating report with kraken-report
"""
in_file = os.path.join(out_dir, "kraken_out")
stat_file = os.path.join(out_dir, "kraken_stats")
out_file = os.path.join(out_dir, "kraken_summary")
kraken_cm... | python | def _parse_kraken_output(out_dir, db, data):
"""Parse kraken stat info comming from stderr,
generating report with kraken-report
"""
in_file = os.path.join(out_dir, "kraken_out")
stat_file = os.path.join(out_dir, "kraken_stats")
out_file = os.path.join(out_dir, "kraken_summary")
kraken_cm... | [
"def",
"_parse_kraken_output",
"(",
"out_dir",
",",
"db",
",",
"data",
")",
":",
"in_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"\"kraken_out\"",
")",
"stat_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"\"krake... | Parse kraken stat info comming from stderr,
generating report with kraken-report | [
"Parse",
"kraken",
"stat",
"info",
"comming",
"from",
"stderr",
"generating",
"report",
"with",
"kraken",
"-",
"report"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/kraken.py#L59-L81 | train |
bcbio/bcbio-nextgen | bcbio/qc/kraken.py | _summarize_kraken | def _summarize_kraken(fn):
"""get the value at species level"""
kraken = {}
list_sp, list_value = [], []
with open(fn) as handle:
for line in handle:
cols = line.strip().split("\t")
sp = cols[5].strip()
if len(sp.split(" ")) > 1 and not sp.startswith("cellular... | python | def _summarize_kraken(fn):
"""get the value at species level"""
kraken = {}
list_sp, list_value = [], []
with open(fn) as handle:
for line in handle:
cols = line.strip().split("\t")
sp = cols[5].strip()
if len(sp.split(" ")) > 1 and not sp.startswith("cellular... | [
"def",
"_summarize_kraken",
"(",
"fn",
")",
":",
"kraken",
"=",
"{",
"}",
"list_sp",
",",
"list_value",
"=",
"[",
"]",
",",
"[",
"]",
"with",
"open",
"(",
"fn",
")",
"as",
"handle",
":",
"for",
"line",
"in",
"handle",
":",
"cols",
"=",
"line",
".... | get the value at species level | [
"get",
"the",
"value",
"at",
"species",
"level"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/kraken.py#L83-L95 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _get_main_and_json | def _get_main_and_json(directory):
"""Retrieve the main CWL and sample JSON files from a bcbio generated directory.
"""
directory = os.path.normpath(os.path.abspath(directory))
checker_main = os.path.normpath(os.path.join(directory, os.path.pardir, "checker-workflow-wrapping-tool.cwl"))
if checker_m... | python | def _get_main_and_json(directory):
"""Retrieve the main CWL and sample JSON files from a bcbio generated directory.
"""
directory = os.path.normpath(os.path.abspath(directory))
checker_main = os.path.normpath(os.path.join(directory, os.path.pardir, "checker-workflow-wrapping-tool.cwl"))
if checker_m... | [
"def",
"_get_main_and_json",
"(",
"directory",
")",
":",
"directory",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"directory",
")",
")",
"checker_main",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
... | Retrieve the main CWL and sample JSON files from a bcbio generated directory. | [
"Retrieve",
"the",
"main",
"CWL",
"and",
"sample",
"JSON",
"files",
"from",
"a",
"bcbio",
"generated",
"directory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L18-L32 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _run_tool | def _run_tool(cmd, use_container=True, work_dir=None, log_file=None):
"""Run with injection of bcbio path.
Place at end for runs without containers to avoid overriding other
bcbio installations.
"""
if isinstance(cmd, (list, tuple)):
cmd = " ".join([str(x) for x in cmd])
cmd = utils.loc... | python | def _run_tool(cmd, use_container=True, work_dir=None, log_file=None):
"""Run with injection of bcbio path.
Place at end for runs without containers to avoid overriding other
bcbio installations.
"""
if isinstance(cmd, (list, tuple)):
cmd = " ".join([str(x) for x in cmd])
cmd = utils.loc... | [
"def",
"_run_tool",
"(",
"cmd",
",",
"use_container",
"=",
"True",
",",
"work_dir",
"=",
"None",
",",
"log_file",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"cmd",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"cmd",
"=",
"\" \"",
".",
"join"... | Run with injection of bcbio path.
Place at end for runs without containers to avoid overriding other
bcbio installations. | [
"Run",
"with",
"injection",
"of",
"bcbio",
"path",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L34-L50 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _pack_cwl | def _pack_cwl(unpacked_cwl):
"""Pack CWL into a single document for submission.
"""
out_file = "%s-pack%s" % os.path.splitext(unpacked_cwl)
cmd = "cwltool --pack {unpacked_cwl} > {out_file}"
_run_tool(cmd.format(**locals()))
return out_file | python | def _pack_cwl(unpacked_cwl):
"""Pack CWL into a single document for submission.
"""
out_file = "%s-pack%s" % os.path.splitext(unpacked_cwl)
cmd = "cwltool --pack {unpacked_cwl} > {out_file}"
_run_tool(cmd.format(**locals()))
return out_file | [
"def",
"_pack_cwl",
"(",
"unpacked_cwl",
")",
":",
"out_file",
"=",
"\"%s-pack%s\"",
"%",
"os",
".",
"path",
".",
"splitext",
"(",
"unpacked_cwl",
")",
"cmd",
"=",
"\"cwltool --pack {unpacked_cwl} > {out_file}\"",
"_run_tool",
"(",
"cmd",
".",
"format",
"(",
"*"... | Pack CWL into a single document for submission. | [
"Pack",
"CWL",
"into",
"a",
"single",
"document",
"for",
"submission",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L52-L58 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _remove_bcbiovm_path | def _remove_bcbiovm_path():
"""Avoid referencing minimal bcbio_nextgen in bcbio_vm installation.
"""
cur_path = os.path.dirname(os.path.realpath(sys.executable))
paths = os.environ["PATH"].split(":")
if cur_path in paths:
paths.remove(cur_path)
os.environ["PATH"] = ":".join(paths) | python | def _remove_bcbiovm_path():
"""Avoid referencing minimal bcbio_nextgen in bcbio_vm installation.
"""
cur_path = os.path.dirname(os.path.realpath(sys.executable))
paths = os.environ["PATH"].split(":")
if cur_path in paths:
paths.remove(cur_path)
os.environ["PATH"] = ":".join(paths) | [
"def",
"_remove_bcbiovm_path",
"(",
")",
":",
"cur_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"sys",
".",
"executable",
")",
")",
"paths",
"=",
"os",
".",
"environ",
"[",
"\"PATH\"",
"]",
".",
"split"... | Avoid referencing minimal bcbio_nextgen in bcbio_vm installation. | [
"Avoid",
"referencing",
"minimal",
"bcbio_nextgen",
"in",
"bcbio_vm",
"installation",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L74-L81 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _run_arvados | def _run_arvados(args):
"""Run CWL on Arvados.
"""
assert not args.no_container, "Arvados runs require containers"
assert "ARVADOS_API_TOKEN" in os.environ and "ARVADOS_API_HOST" in os.environ, \
"Need to set ARVADOS_API_TOKEN and ARVADOS_API_HOST in environment to run"
main_file, json_file,... | python | def _run_arvados(args):
"""Run CWL on Arvados.
"""
assert not args.no_container, "Arvados runs require containers"
assert "ARVADOS_API_TOKEN" in os.environ and "ARVADOS_API_HOST" in os.environ, \
"Need to set ARVADOS_API_TOKEN and ARVADOS_API_HOST in environment to run"
main_file, json_file,... | [
"def",
"_run_arvados",
"(",
"args",
")",
":",
"assert",
"not",
"args",
".",
"no_container",
",",
"\"Arvados runs require containers\"",
"assert",
"\"ARVADOS_API_TOKEN\"",
"in",
"os",
".",
"environ",
"and",
"\"ARVADOS_API_HOST\"",
"in",
"os",
".",
"environ",
",",
"... | Run CWL on Arvados. | [
"Run",
"CWL",
"on",
"Arvados",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L99-L108 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _run_toil | def _run_toil(args):
"""Run CWL with Toil.
"""
main_file, json_file, project_name = _get_main_and_json(args.directory)
work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "toil_work"))
tmp_dir = utils.safe_makedir(os.path.join(work_dir, "tmpdir"))
os.environ["TMPDIR"] = tmp_dir
log_file ... | python | def _run_toil(args):
"""Run CWL with Toil.
"""
main_file, json_file, project_name = _get_main_and_json(args.directory)
work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "toil_work"))
tmp_dir = utils.safe_makedir(os.path.join(work_dir, "tmpdir"))
os.environ["TMPDIR"] = tmp_dir
log_file ... | [
"def",
"_run_toil",
"(",
"args",
")",
":",
"main_file",
",",
"json_file",
",",
"project_name",
"=",
"_get_main_and_json",
"(",
"args",
".",
"directory",
")",
"work_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
"... | Run CWL with Toil. | [
"Run",
"CWL",
"with",
"Toil",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L110-L135 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _run_bunny | def _run_bunny(args):
"""Run CWL with rabix bunny.
"""
main_file, json_file, project_name = _get_main_and_json(args.directory)
work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "bunny_work"))
flags = ["-b", work_dir]
log_file = os.path.join(work_dir, "%s-bunny.log" % project_name)
if o... | python | def _run_bunny(args):
"""Run CWL with rabix bunny.
"""
main_file, json_file, project_name = _get_main_and_json(args.directory)
work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "bunny_work"))
flags = ["-b", work_dir]
log_file = os.path.join(work_dir, "%s-bunny.log" % project_name)
if o... | [
"def",
"_run_bunny",
"(",
"args",
")",
":",
"main_file",
",",
"json_file",
",",
"project_name",
"=",
"_get_main_and_json",
"(",
"args",
".",
"directory",
")",
"work_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
... | Run CWL with rabix bunny. | [
"Run",
"CWL",
"with",
"rabix",
"bunny",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L137-L154 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _run_wes_stratus | def _run_wes_stratus(args, main_file, json_file):
"""Run WES on Illumina stratus endpoint server, which wes-client doesn't support.
https://stratus-docs.readme.io/docs/quick-start-4
"""
import requests
base_url = args.host
if not base_url.startswith("http"):
base_url = "https://%s" % ba... | python | def _run_wes_stratus(args, main_file, json_file):
"""Run WES on Illumina stratus endpoint server, which wes-client doesn't support.
https://stratus-docs.readme.io/docs/quick-start-4
"""
import requests
base_url = args.host
if not base_url.startswith("http"):
base_url = "https://%s" % ba... | [
"def",
"_run_wes_stratus",
"(",
"args",
",",
"main_file",
",",
"json_file",
")",
":",
"import",
"requests",
"base_url",
"=",
"args",
".",
"host",
"if",
"not",
"base_url",
".",
"startswith",
"(",
"\"http\"",
")",
":",
"base_url",
"=",
"\"https://%s\"",
"%",
... | Run WES on Illumina stratus endpoint server, which wes-client doesn't support.
https://stratus-docs.readme.io/docs/quick-start-4 | [
"Run",
"WES",
"on",
"Illumina",
"stratus",
"endpoint",
"server",
"which",
"wes",
"-",
"client",
"doesn",
"t",
"support",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L172-L187 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _estimate_runner_memory | def _estimate_runner_memory(json_file):
"""Estimate Java memory requirements based on number of samples.
A rough approach to selecting correct allocated memory for Cromwell.
"""
with open(json_file) as in_handle:
sinfo = json.load(in_handle)
num_parallel = 1
for key in ["config__algorit... | python | def _estimate_runner_memory(json_file):
"""Estimate Java memory requirements based on number of samples.
A rough approach to selecting correct allocated memory for Cromwell.
"""
with open(json_file) as in_handle:
sinfo = json.load(in_handle)
num_parallel = 1
for key in ["config__algorit... | [
"def",
"_estimate_runner_memory",
"(",
"json_file",
")",
":",
"with",
"open",
"(",
"json_file",
")",
"as",
"in_handle",
":",
"sinfo",
"=",
"json",
".",
"load",
"(",
"in_handle",
")",
"num_parallel",
"=",
"1",
"for",
"key",
"in",
"[",
"\"config__algorithm__va... | Estimate Java memory requirements based on number of samples.
A rough approach to selecting correct allocated memory for Cromwell. | [
"Estimate",
"Java",
"memory",
"requirements",
"based",
"on",
"number",
"of",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L189-L218 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _run_cromwell | def _run_cromwell(args):
"""Run CWL with Cromwell.
"""
main_file, json_file, project_name = _get_main_and_json(args.directory)
work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "cromwell_work"))
final_dir = utils.safe_makedir(os.path.join(work_dir, "final"))
if args.no_container:
_... | python | def _run_cromwell(args):
"""Run CWL with Cromwell.
"""
main_file, json_file, project_name = _get_main_and_json(args.directory)
work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "cromwell_work"))
final_dir = utils.safe_makedir(os.path.join(work_dir, "final"))
if args.no_container:
_... | [
"def",
"_run_cromwell",
"(",
"args",
")",
":",
"main_file",
",",
"json_file",
",",
"project_name",
"=",
"_get_main_and_json",
"(",
"args",
".",
"directory",
")",
"work_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",... | Run CWL with Cromwell. | [
"Run",
"CWL",
"with",
"Cromwell",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L220-L251 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _cromwell_debug | def _cromwell_debug(metadata):
"""Format Cromwell failures to make debugging easier.
"""
def get_failed_calls(cur, key=None):
if key is None: key = []
out = []
if isinstance(cur, dict) and "failures" in cur and "callRoot" in cur:
out.append((key, cur))
elif isinst... | python | def _cromwell_debug(metadata):
"""Format Cromwell failures to make debugging easier.
"""
def get_failed_calls(cur, key=None):
if key is None: key = []
out = []
if isinstance(cur, dict) and "failures" in cur and "callRoot" in cur:
out.append((key, cur))
elif isinst... | [
"def",
"_cromwell_debug",
"(",
"metadata",
")",
":",
"def",
"get_failed_calls",
"(",
"cur",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"[",
"]",
"out",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"cur",
",",
"dict",
... | Format Cromwell failures to make debugging easier. | [
"Format",
"Cromwell",
"failures",
"to",
"make",
"debugging",
"easier",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L253-L277 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _cromwell_move_outputs | def _cromwell_move_outputs(metadata, final_dir):
"""Move Cromwell outputs to the final upload directory.
"""
sample_key = [k for k in metadata["outputs"].keys() if k.endswith(("rgnames__sample", "rgnames__sample_out"))][0]
project_dir = utils.safe_makedir(os.path.join(final_dir, "project"))
samples ... | python | def _cromwell_move_outputs(metadata, final_dir):
"""Move Cromwell outputs to the final upload directory.
"""
sample_key = [k for k in metadata["outputs"].keys() if k.endswith(("rgnames__sample", "rgnames__sample_out"))][0]
project_dir = utils.safe_makedir(os.path.join(final_dir, "project"))
samples ... | [
"def",
"_cromwell_move_outputs",
"(",
"metadata",
",",
"final_dir",
")",
":",
"sample_key",
"=",
"[",
"k",
"for",
"k",
"in",
"metadata",
"[",
"\"outputs\"",
"]",
".",
"keys",
"(",
")",
"if",
"k",
".",
"endswith",
"(",
"(",
"\"rgnames__sample\"",
",",
"\"... | Move Cromwell outputs to the final upload directory. | [
"Move",
"Cromwell",
"outputs",
"to",
"the",
"final",
"upload",
"directory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L279-L311 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _run_sbgenomics | def _run_sbgenomics(args):
"""Run CWL on SevenBridges platform and Cancer Genomics Cloud.
"""
assert not args.no_container, "Seven Bridges runs require containers"
main_file, json_file, project_name = _get_main_and_json(args.directory)
flags = []
cmd = ["sbg-cwl-runner"] + flags + args.toolargs ... | python | def _run_sbgenomics(args):
"""Run CWL on SevenBridges platform and Cancer Genomics Cloud.
"""
assert not args.no_container, "Seven Bridges runs require containers"
main_file, json_file, project_name = _get_main_and_json(args.directory)
flags = []
cmd = ["sbg-cwl-runner"] + flags + args.toolargs ... | [
"def",
"_run_sbgenomics",
"(",
"args",
")",
":",
"assert",
"not",
"args",
".",
"no_container",
",",
"\"Seven Bridges runs require containers\"",
"main_file",
",",
"json_file",
",",
"project_name",
"=",
"_get_main_and_json",
"(",
"args",
".",
"directory",
")",
"flags... | Run CWL on SevenBridges platform and Cancer Genomics Cloud. | [
"Run",
"CWL",
"on",
"SevenBridges",
"platform",
"and",
"Cancer",
"Genomics",
"Cloud",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L313-L320 | train |
bcbio/bcbio-nextgen | bcbio/cwl/tool.py | _run_funnel | def _run_funnel(args):
"""Run funnel TES server with rabix bunny for CWL.
"""
host = "localhost"
port = "8088"
main_file, json_file, project_name = _get_main_and_json(args.directory)
work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "funnel_work"))
log_file = os.path.join(work_dir, "%s... | python | def _run_funnel(args):
"""Run funnel TES server with rabix bunny for CWL.
"""
host = "localhost"
port = "8088"
main_file, json_file, project_name = _get_main_and_json(args.directory)
work_dir = utils.safe_makedir(os.path.join(os.getcwd(), "funnel_work"))
log_file = os.path.join(work_dir, "%s... | [
"def",
"_run_funnel",
"(",
"args",
")",
":",
"host",
"=",
"\"localhost\"",
"port",
"=",
"\"8088\"",
"main_file",
",",
"json_file",
",",
"project_name",
"=",
"_get_main_and_json",
"(",
"args",
".",
"directory",
")",
"work_dir",
"=",
"utils",
".",
"safe_makedir"... | Run funnel TES server with rabix bunny for CWL. | [
"Run",
"funnel",
"TES",
"server",
"with",
"rabix",
"bunny",
"for",
"CWL",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/tool.py#L322-L357 | train |
bcbio/bcbio-nextgen | bcbio/qc/qualimap.py | _parse_qualimap_globals_inregion | def _parse_qualimap_globals_inregion(table):
"""Retrieve metrics from the global targeted region table.
"""
out = {}
for row in table.find_all("tr"):
col, val = [x.text for x in row.find_all("td")]
if col == "Mapped reads":
out.update(_parse_num_pct("%s (in regions)" % col, v... | python | def _parse_qualimap_globals_inregion(table):
"""Retrieve metrics from the global targeted region table.
"""
out = {}
for row in table.find_all("tr"):
col, val = [x.text for x in row.find_all("td")]
if col == "Mapped reads":
out.update(_parse_num_pct("%s (in regions)" % col, v... | [
"def",
"_parse_qualimap_globals_inregion",
"(",
"table",
")",
":",
"out",
"=",
"{",
"}",
"for",
"row",
"in",
"table",
".",
"find_all",
"(",
"\"tr\"",
")",
":",
"col",
",",
"val",
"=",
"[",
"x",
".",
"text",
"for",
"x",
"in",
"row",
".",
"find_all",
... | Retrieve metrics from the global targeted region table. | [
"Retrieve",
"metrics",
"from",
"the",
"global",
"targeted",
"region",
"table",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/qualimap.py#L131-L139 | train |
bcbio/bcbio-nextgen | bcbio/qc/qualimap.py | _parse_qualimap_coverage | def _parse_qualimap_coverage(table):
"""Parse summary qualimap coverage metrics.
"""
out = {}
for row in table.find_all("tr"):
col, val = [x.text for x in row.find_all("td")]
if col == "Mean":
out["Coverage (Mean)"] = val
return out | python | def _parse_qualimap_coverage(table):
"""Parse summary qualimap coverage metrics.
"""
out = {}
for row in table.find_all("tr"):
col, val = [x.text for x in row.find_all("td")]
if col == "Mean":
out["Coverage (Mean)"] = val
return out | [
"def",
"_parse_qualimap_coverage",
"(",
"table",
")",
":",
"out",
"=",
"{",
"}",
"for",
"row",
"in",
"table",
".",
"find_all",
"(",
"\"tr\"",
")",
":",
"col",
",",
"val",
"=",
"[",
"x",
".",
"text",
"for",
"x",
"in",
"row",
".",
"find_all",
"(",
... | Parse summary qualimap coverage metrics. | [
"Parse",
"summary",
"qualimap",
"coverage",
"metrics",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/qualimap.py#L141-L149 | train |
bcbio/bcbio-nextgen | bcbio/qc/qualimap.py | _bed_to_bed6 | def _bed_to_bed6(orig_file, out_dir):
"""Convert bed to required bed6 inputs.
"""
bed6_file = os.path.join(out_dir, "%s-bed6%s" % os.path.splitext(os.path.basename(orig_file)))
if not utils.file_exists(bed6_file):
with open(bed6_file, "w") as out_handle:
for i, region in enumerate(li... | python | def _bed_to_bed6(orig_file, out_dir):
"""Convert bed to required bed6 inputs.
"""
bed6_file = os.path.join(out_dir, "%s-bed6%s" % os.path.splitext(os.path.basename(orig_file)))
if not utils.file_exists(bed6_file):
with open(bed6_file, "w") as out_handle:
for i, region in enumerate(li... | [
"def",
"_bed_to_bed6",
"(",
"orig_file",
",",
"out_dir",
")",
":",
"bed6_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"\"%s-bed6%s\"",
"%",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"orig_file... | Convert bed to required bed6 inputs. | [
"Convert",
"bed",
"to",
"required",
"bed6",
"inputs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/qualimap.py#L161-L172 | train |
bcbio/bcbio-nextgen | bcbio/qc/qualimap.py | _detect_duplicates | def _detect_duplicates(bam_file, out_dir, data):
"""
count duplicate percentage
"""
out_file = os.path.join(out_dir, "dup_metrics.txt")
if not utils.file_exists(out_file):
dup_align_bam = postalign.dedup_bam(bam_file, data)
logger.info("Detecting duplicates in %s." % dup_align_bam)
... | python | def _detect_duplicates(bam_file, out_dir, data):
"""
count duplicate percentage
"""
out_file = os.path.join(out_dir, "dup_metrics.txt")
if not utils.file_exists(out_file):
dup_align_bam = postalign.dedup_bam(bam_file, data)
logger.info("Detecting duplicates in %s." % dup_align_bam)
... | [
"def",
"_detect_duplicates",
"(",
"bam_file",
",",
"out_dir",
",",
"data",
")",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"\"dup_metrics.txt\"",
")",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"d... | count duplicate percentage | [
"count",
"duplicate",
"percentage"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/qualimap.py#L219-L239 | train |
bcbio/bcbio-nextgen | bcbio/qc/qualimap.py | run_rnaseq | def run_rnaseq(bam_file, data, out_dir):
"""
Run qualimap for a rnaseq bam file and parse results
"""
strandedness = {"firststrand": "strand-specific-reverse",
"secondstrand": "strand-specific-forward",
"unstranded": "non-strand-specific"}
# Qualimap results ... | python | def run_rnaseq(bam_file, data, out_dir):
"""
Run qualimap for a rnaseq bam file and parse results
"""
strandedness = {"firststrand": "strand-specific-reverse",
"secondstrand": "strand-specific-forward",
"unstranded": "non-strand-specific"}
# Qualimap results ... | [
"def",
"run_rnaseq",
"(",
"bam_file",
",",
"data",
",",
"out_dir",
")",
":",
"strandedness",
"=",
"{",
"\"firststrand\"",
":",
"\"strand-specific-reverse\"",
",",
"\"secondstrand\"",
":",
"\"strand-specific-forward\"",
",",
"\"unstranded\"",
":",
"\"non-strand-specific\... | Run qualimap for a rnaseq bam file and parse results | [
"Run",
"qualimap",
"for",
"a",
"rnaseq",
"bam",
"file",
"and",
"parse",
"results"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/qualimap.py#L317-L354 | train |
bcbio/bcbio-nextgen | bcbio/qc/qualimap.py | _rnaseq_qualimap_cmd | def _rnaseq_qualimap_cmd(data, bam_file, out_dir, gtf_file=None, library="non-strand-specific"):
"""
Create command lines for qualimap
"""
config = data["config"]
qualimap = config_utils.get_program("qualimap", config)
resources = config_utils.get_resources("qualimap", config)
num_cores = re... | python | def _rnaseq_qualimap_cmd(data, bam_file, out_dir, gtf_file=None, library="non-strand-specific"):
"""
Create command lines for qualimap
"""
config = data["config"]
qualimap = config_utils.get_program("qualimap", config)
resources = config_utils.get_resources("qualimap", config)
num_cores = re... | [
"def",
"_rnaseq_qualimap_cmd",
"(",
"data",
",",
"bam_file",
",",
"out_dir",
",",
"gtf_file",
"=",
"None",
",",
"library",
"=",
"\"non-strand-specific\"",
")",
":",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"qualimap",
"=",
"config_utils",
".",
"get_progr... | Create command lines for qualimap | [
"Create",
"command",
"lines",
"for",
"qualimap"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/qualimap.py#L356-L373 | train |
bcbio/bcbio-nextgen | bcbio/qc/qualimap.py | _find_qualimap_secondary_files | def _find_qualimap_secondary_files(results_dir, base_file):
"""Retrieve additional files, avoiding double uploading the base file.
"""
def not_dup(x):
is_dup = (os.path.basename(x) == os.path.basename(base_file) and
os.path.getsize(x) == os.path.getsize(base_file))
return n... | python | def _find_qualimap_secondary_files(results_dir, base_file):
"""Retrieve additional files, avoiding double uploading the base file.
"""
def not_dup(x):
is_dup = (os.path.basename(x) == os.path.basename(base_file) and
os.path.getsize(x) == os.path.getsize(base_file))
return n... | [
"def",
"_find_qualimap_secondary_files",
"(",
"results_dir",
",",
"base_file",
")",
":",
"def",
"not_dup",
"(",
"x",
")",
":",
"is_dup",
"=",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"x",
")",
"==",
"os",
".",
"path",
".",
"basename",
"(",
"base_f... | Retrieve additional files, avoiding double uploading the base file. | [
"Retrieve",
"additional",
"files",
"avoiding",
"double",
"uploading",
"the",
"base",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/qualimap.py#L375-L392 | train |
bcbio/bcbio-nextgen | bcbio/variation/validateplot.py | classifyplot_from_plotfiles | def classifyplot_from_plotfiles(plot_files, out_csv, outtype="png", title=None, size=None):
"""Create a plot from individual summary csv files with classification metrics.
"""
dfs = [pd.read_csv(x) for x in plot_files]
samples = []
for df in dfs:
for sample in df["sample"].unique():
... | python | def classifyplot_from_plotfiles(plot_files, out_csv, outtype="png", title=None, size=None):
"""Create a plot from individual summary csv files with classification metrics.
"""
dfs = [pd.read_csv(x) for x in plot_files]
samples = []
for df in dfs:
for sample in df["sample"].unique():
... | [
"def",
"classifyplot_from_plotfiles",
"(",
"plot_files",
",",
"out_csv",
",",
"outtype",
"=",
"\"png\"",
",",
"title",
"=",
"None",
",",
"size",
"=",
"None",
")",
":",
"dfs",
"=",
"[",
"pd",
".",
"read_csv",
"(",
"x",
")",
"for",
"x",
"in",
"plot_files... | Create a plot from individual summary csv files with classification metrics. | [
"Create",
"a",
"plot",
"from",
"individual",
"summary",
"csv",
"files",
"with",
"classification",
"metrics",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/validateplot.py#L22-L33 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.