id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
223,900 | bcbio/bcbio-nextgen | bcbio/rnaseq/ericscript.py | EricScriptConfig.get_run_command | def get_run_command(self, tx_output_dir, input_files):
"""Constructs a command to run EricScript via do.run function.
:param tx_output_dir: A location where all EricScript output will be
written during execution.
:param input_files: an iterable with paths to 2 fastq files
with i... | python | def get_run_command(self, tx_output_dir, input_files):
"""Constructs a command to run EricScript via do.run function.
:param tx_output_dir: A location where all EricScript output will be
written during execution.
:param input_files: an iterable with paths to 2 fastq files
with i... | [
"def",
"get_run_command",
"(",
"self",
",",
"tx_output_dir",
",",
"input_files",
")",
":",
"logger",
".",
"debug",
"(",
"\"Input data: %s\"",
"%",
"', '",
".",
"join",
"(",
"input_files",
")",
")",
"cmd",
"=",
"[",
"self",
".",
"EXECUTABLE",
",",
"'-db'",
... | Constructs a command to run EricScript via do.run function.
:param tx_output_dir: A location where all EricScript output will be
written during execution.
:param input_files: an iterable with paths to 2 fastq files
with input data.
:return: list | [
"Constructs",
"a",
"command",
"to",
"run",
"EricScript",
"via",
"do",
".",
"run",
"function",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/ericscript.py#L107-L123 |
223,901 | bcbio/bcbio-nextgen | bcbio/rnaseq/ericscript.py | EricScriptConfig._get_ericscript_path | def _get_ericscript_path(self):
"""Retrieve PATH to the isolated eriscript anaconda environment.
"""
es = utils.which(os.path.join(utils.get_bcbio_bin(), self.EXECUTABLE))
return os.path.dirname(os.path.realpath(es)) | python | def _get_ericscript_path(self):
"""Retrieve PATH to the isolated eriscript anaconda environment.
"""
es = utils.which(os.path.join(utils.get_bcbio_bin(), self.EXECUTABLE))
return os.path.dirname(os.path.realpath(es)) | [
"def",
"_get_ericscript_path",
"(",
"self",
")",
":",
"es",
"=",
"utils",
".",
"which",
"(",
"os",
".",
"path",
".",
"join",
"(",
"utils",
".",
"get_bcbio_bin",
"(",
")",
",",
"self",
".",
"EXECUTABLE",
")",
")",
"return",
"os",
".",
"path",
".",
"... | Retrieve PATH to the isolated eriscript anaconda environment. | [
"Retrieve",
"PATH",
"to",
"the",
"isolated",
"eriscript",
"anaconda",
"environment",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/ericscript.py#L125-L129 |
223,902 | bcbio/bcbio-nextgen | bcbio/rnaseq/ericscript.py | EricScriptConfig._get_samtools0_path | def _get_samtools0_path(self):
"""Retrieve PATH to the samtools version specific for eriscript.
"""
samtools_path = os.path.realpath(os.path.join(self._get_ericscript_path(),"..", "..", "bin"))
return samtools_path | python | def _get_samtools0_path(self):
"""Retrieve PATH to the samtools version specific for eriscript.
"""
samtools_path = os.path.realpath(os.path.join(self._get_ericscript_path(),"..", "..", "bin"))
return samtools_path | [
"def",
"_get_samtools0_path",
"(",
"self",
")",
":",
"samtools_path",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_get_ericscript_path",
"(",
")",
",",
"\"..\"",
",",
"\"..\"",
",",
"\"bin\"",
")",
"... | Retrieve PATH to the samtools version specific for eriscript. | [
"Retrieve",
"PATH",
"to",
"the",
"samtools",
"version",
"specific",
"for",
"eriscript",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/ericscript.py#L130-L134 |
223,903 | bcbio/bcbio-nextgen | bcbio/rnaseq/ericscript.py | EricScriptConfig.output_dir | def output_dir(self):
"""Absolute path to permanent location in working directory
where EricScript output will be stored.
"""
if self._output_dir is None:
self._output_dir = self._get_output_dir()
return self._output_dir | python | def output_dir(self):
"""Absolute path to permanent location in working directory
where EricScript output will be stored.
"""
if self._output_dir is None:
self._output_dir = self._get_output_dir()
return self._output_dir | [
"def",
"output_dir",
"(",
"self",
")",
":",
"if",
"self",
".",
"_output_dir",
"is",
"None",
":",
"self",
".",
"_output_dir",
"=",
"self",
".",
"_get_output_dir",
"(",
")",
"return",
"self",
".",
"_output_dir"
] | Absolute path to permanent location in working directory
where EricScript output will be stored. | [
"Absolute",
"path",
"to",
"permanent",
"location",
"in",
"working",
"directory",
"where",
"EricScript",
"output",
"will",
"be",
"stored",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/ericscript.py#L137-L143 |
223,904 | bcbio/bcbio-nextgen | bcbio/rnaseq/ericscript.py | EricScriptConfig.reference_index | def reference_index(self):
"""Absolute path to the BWA index for EricScript reference data."""
if self._db_location:
ref_indices = glob.glob(os.path.join(self._db_location, "*", self._REF_INDEX))
if ref_indices:
return ref_indices[0] | python | def reference_index(self):
"""Absolute path to the BWA index for EricScript reference data."""
if self._db_location:
ref_indices = glob.glob(os.path.join(self._db_location, "*", self._REF_INDEX))
if ref_indices:
return ref_indices[0] | [
"def",
"reference_index",
"(",
"self",
")",
":",
"if",
"self",
".",
"_db_location",
":",
"ref_indices",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_db_location",
",",
"\"*\"",
",",
"self",
".",
"_REF_INDEX",
")",
... | Absolute path to the BWA index for EricScript reference data. | [
"Absolute",
"path",
"to",
"the",
"BWA",
"index",
"for",
"EricScript",
"reference",
"data",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/ericscript.py#L158-L163 |
223,905 | bcbio/bcbio-nextgen | bcbio/rnaseq/ericscript.py | EricScriptConfig.reference_fasta | def reference_fasta(self):
"""Absolute path to the fasta file with EricScript reference data."""
if self._db_location:
ref_files = glob.glob(os.path.join(self._db_location, "*", self._REF_FASTA))
if ref_files:
return ref_files[0] | python | def reference_fasta(self):
"""Absolute path to the fasta file with EricScript reference data."""
if self._db_location:
ref_files = glob.glob(os.path.join(self._db_location, "*", self._REF_FASTA))
if ref_files:
return ref_files[0] | [
"def",
"reference_fasta",
"(",
"self",
")",
":",
"if",
"self",
".",
"_db_location",
":",
"ref_files",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_db_location",
",",
"\"*\"",
",",
"self",
".",
"_REF_FASTA",
")",
... | Absolute path to the fasta file with EricScript reference data. | [
"Absolute",
"path",
"to",
"the",
"fasta",
"file",
"with",
"EricScript",
"reference",
"data",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/ericscript.py#L166-L171 |
223,906 | bcbio/bcbio-nextgen | bcbio/qc/contamination.py | _get_input_args | def _get_input_args(bam_file, data, out_base, background):
"""Retrieve input args, depending on genome build.
VerifyBamID2 only handles GRCh37 (1, 2, 3) not hg19, so need to generate
a pileup for hg19 and fix chromosome naming.
"""
if dd.get_genome_build(data) in ["hg19"]:
return ["--Pileup... | python | def _get_input_args(bam_file, data, out_base, background):
"""Retrieve input args, depending on genome build.
VerifyBamID2 only handles GRCh37 (1, 2, 3) not hg19, so need to generate
a pileup for hg19 and fix chromosome naming.
"""
if dd.get_genome_build(data) in ["hg19"]:
return ["--Pileup... | [
"def",
"_get_input_args",
"(",
"bam_file",
",",
"data",
",",
"out_base",
",",
"background",
")",
":",
"if",
"dd",
".",
"get_genome_build",
"(",
"data",
")",
"in",
"[",
"\"hg19\"",
"]",
":",
"return",
"[",
"\"--PileupFile\"",
",",
"_create_pileup",
"(",
"ba... | Retrieve input args, depending on genome build.
VerifyBamID2 only handles GRCh37 (1, 2, 3) not hg19, so need to generate
a pileup for hg19 and fix chromosome naming. | [
"Retrieve",
"input",
"args",
"depending",
"on",
"genome",
"build",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/contamination.py#L78-L87 |
223,907 | bcbio/bcbio-nextgen | bcbio/qc/contamination.py | _create_pileup | def _create_pileup(bam_file, data, out_base, background):
"""Create pileup calls in the regions of interest for hg19 -> GRCh37 chromosome mapping.
"""
out_file = "%s-mpileup.txt" % out_base
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
back... | python | def _create_pileup(bam_file, data, out_base, background):
"""Create pileup calls in the regions of interest for hg19 -> GRCh37 chromosome mapping.
"""
out_file = "%s-mpileup.txt" % out_base
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
back... | [
"def",
"_create_pileup",
"(",
"bam_file",
",",
"data",
",",
"out_base",
",",
"background",
")",
":",
"out_file",
"=",
"\"%s-mpileup.txt\"",
"%",
"out_base",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
... | Create pileup calls in the regions of interest for hg19 -> GRCh37 chromosome mapping. | [
"Create",
"pileup",
"calls",
"in",
"the",
"regions",
"of",
"interest",
"for",
"hg19",
"-",
">",
"GRCh37",
"chromosome",
"mapping",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/contamination.py#L89-L111 |
223,908 | bcbio/bcbio-nextgen | bcbio/structural/convert.py | _cnvbed_to_bed | def _cnvbed_to_bed(in_file, caller, out_file):
"""Convert cn_mops CNV based bed files into flattened BED
"""
with open(out_file, "w") as out_handle:
for feat in pybedtools.BedTool(in_file):
out_handle.write("\t".join([feat.chrom, str(feat.start), str(feat.end),
... | python | def _cnvbed_to_bed(in_file, caller, out_file):
"""Convert cn_mops CNV based bed files into flattened BED
"""
with open(out_file, "w") as out_handle:
for feat in pybedtools.BedTool(in_file):
out_handle.write("\t".join([feat.chrom, str(feat.start), str(feat.end),
... | [
"def",
"_cnvbed_to_bed",
"(",
"in_file",
",",
"caller",
",",
"out_file",
")",
":",
"with",
"open",
"(",
"out_file",
",",
"\"w\"",
")",
"as",
"out_handle",
":",
"for",
"feat",
"in",
"pybedtools",
".",
"BedTool",
"(",
"in_file",
")",
":",
"out_handle",
"."... | Convert cn_mops CNV based bed files into flattened BED | [
"Convert",
"cn_mops",
"CNV",
"based",
"bed",
"files",
"into",
"flattened",
"BED"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/convert.py#L44-L51 |
223,909 | bcbio/bcbio-nextgen | bcbio/structural/convert.py | to_bed | def to_bed(call, sample, work_dir, calls, data):
"""Create a simplified BED file from caller specific input.
"""
out_file = os.path.join(work_dir, "%s-%s-flat.bed" % (sample, call["variantcaller"]))
if call.get("vrn_file") and not utils.file_uptodate(out_file, call["vrn_file"]):
with file_transa... | python | def to_bed(call, sample, work_dir, calls, data):
"""Create a simplified BED file from caller specific input.
"""
out_file = os.path.join(work_dir, "%s-%s-flat.bed" % (sample, call["variantcaller"]))
if call.get("vrn_file") and not utils.file_uptodate(out_file, call["vrn_file"]):
with file_transa... | [
"def",
"to_bed",
"(",
"call",
",",
"sample",
",",
"work_dir",
",",
"calls",
",",
"data",
")",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"\"%s-%s-flat.bed\"",
"%",
"(",
"sample",
",",
"call",
"[",
"\"variantcaller\"",
"... | Create a simplified BED file from caller specific input. | [
"Create",
"a",
"simplified",
"BED",
"file",
"from",
"caller",
"specific",
"input",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/convert.py#L65-L80 |
223,910 | bcbio/bcbio-nextgen | bcbio/structural/convert.py | _subset_by_support | def _subset_by_support(orig_vcf, cmp_calls, data):
"""Subset orig_vcf to calls also present in any of the comparison callers.
"""
cmp_vcfs = [x["vrn_file"] for x in cmp_calls]
out_file = "%s-inensemble.vcf.gz" % utils.splitext_plus(orig_vcf)[0]
if not utils.file_uptodate(out_file, orig_vcf):
... | python | def _subset_by_support(orig_vcf, cmp_calls, data):
"""Subset orig_vcf to calls also present in any of the comparison callers.
"""
cmp_vcfs = [x["vrn_file"] for x in cmp_calls]
out_file = "%s-inensemble.vcf.gz" % utils.splitext_plus(orig_vcf)[0]
if not utils.file_uptodate(out_file, orig_vcf):
... | [
"def",
"_subset_by_support",
"(",
"orig_vcf",
",",
"cmp_calls",
",",
"data",
")",
":",
"cmp_vcfs",
"=",
"[",
"x",
"[",
"\"vrn_file\"",
"]",
"for",
"x",
"in",
"cmp_calls",
"]",
"out_file",
"=",
"\"%s-inensemble.vcf.gz\"",
"%",
"utils",
".",
"splitext_plus",
"... | Subset orig_vcf to calls also present in any of the comparison callers. | [
"Subset",
"orig_vcf",
"to",
"calls",
"also",
"present",
"in",
"any",
"of",
"the",
"comparison",
"callers",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/convert.py#L82-L94 |
223,911 | bcbio/bcbio-nextgen | bcbio/qc/coverage.py | run | def run(bam_file, data, out_dir):
"""Run coverage QC analysis
"""
out = dict()
out_dir = utils.safe_makedir(out_dir)
if dd.get_coverage(data) and dd.get_coverage(data) not in ["None"]:
merged_bed_file = bedutils.clean_file(dd.get_coverage_merged(data), data, prefix="cov-", simple=True)
... | python | def run(bam_file, data, out_dir):
"""Run coverage QC analysis
"""
out = dict()
out_dir = utils.safe_makedir(out_dir)
if dd.get_coverage(data) and dd.get_coverage(data) not in ["None"]:
merged_bed_file = bedutils.clean_file(dd.get_coverage_merged(data), data, prefix="cov-", simple=True)
... | [
"def",
"run",
"(",
"bam_file",
",",
"data",
",",
"out_dir",
")",
":",
"out",
"=",
"dict",
"(",
")",
"out_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"out_dir",
")",
"if",
"dd",
".",
"get_coverage",
"(",
"data",
")",
"and",
"dd",
".",
"get_coverage"... | Run coverage QC analysis | [
"Run",
"coverage",
"QC",
"analysis"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/coverage.py#L15-L82 |
223,912 | bcbio/bcbio-nextgen | bcbio/qc/coverage.py | _goleft_indexcov | def _goleft_indexcov(bam_file, data, out_dir):
"""Use goleft indexcov to estimate coverage distributions using BAM index.
Only used for whole genome runs as captures typically don't have enough data
to be useful for index-only summaries.
"""
if not dd.get_coverage_interval(data) == "genome":
... | python | def _goleft_indexcov(bam_file, data, out_dir):
"""Use goleft indexcov to estimate coverage distributions using BAM index.
Only used for whole genome runs as captures typically don't have enough data
to be useful for index-only summaries.
"""
if not dd.get_coverage_interval(data) == "genome":
... | [
"def",
"_goleft_indexcov",
"(",
"bam_file",
",",
"data",
",",
"out_dir",
")",
":",
"if",
"not",
"dd",
".",
"get_coverage_interval",
"(",
"data",
")",
"==",
"\"genome\"",
":",
"return",
"[",
"]",
"out_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".... | Use goleft indexcov to estimate coverage distributions using BAM index.
Only used for whole genome runs as captures typically don't have enough data
to be useful for index-only summaries. | [
"Use",
"goleft",
"indexcov",
"to",
"estimate",
"coverage",
"distributions",
"using",
"BAM",
"index",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/coverage.py#L84-L118 |
223,913 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_sort | def picard_sort(picard, align_bam, sort_order="coordinate",
out_file=None, compression_level=None, pipe=False):
"""Sort a BAM file by coordinates.
"""
base, ext = os.path.splitext(align_bam)
if out_file is None:
out_file = "%s-sort%s" % (base, ext)
if not file_exists(out_file... | python | def picard_sort(picard, align_bam, sort_order="coordinate",
out_file=None, compression_level=None, pipe=False):
"""Sort a BAM file by coordinates.
"""
base, ext = os.path.splitext(align_bam)
if out_file is None:
out_file = "%s-sort%s" % (base, ext)
if not file_exists(out_file... | [
"def",
"picard_sort",
"(",
"picard",
",",
"align_bam",
",",
"sort_order",
"=",
"\"coordinate\"",
",",
"out_file",
"=",
"None",
",",
"compression_level",
"=",
"None",
",",
"pipe",
"=",
"False",
")",
":",
"base",
",",
"ext",
"=",
"os",
".",
"path",
".",
... | Sort a BAM file by coordinates. | [
"Sort",
"a",
"BAM",
"file",
"by",
"coordinates",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L46-L63 |
223,914 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_merge | def picard_merge(picard, in_files, out_file=None,
merge_seq_dicts=False):
"""Merge multiple BAM files together with Picard.
"""
if out_file is None:
out_file = "%smerge.bam" % os.path.commonprefix(in_files)
if not file_exists(out_file):
with tx_tmpdir(picard._config) as ... | python | def picard_merge(picard, in_files, out_file=None,
merge_seq_dicts=False):
"""Merge multiple BAM files together with Picard.
"""
if out_file is None:
out_file = "%smerge.bam" % os.path.commonprefix(in_files)
if not file_exists(out_file):
with tx_tmpdir(picard._config) as ... | [
"def",
"picard_merge",
"(",
"picard",
",",
"in_files",
",",
"out_file",
"=",
"None",
",",
"merge_seq_dicts",
"=",
"False",
")",
":",
"if",
"out_file",
"is",
"None",
":",
"out_file",
"=",
"\"%smerge.bam\"",
"%",
"os",
".",
"path",
".",
"commonprefix",
"(",
... | Merge multiple BAM files together with Picard. | [
"Merge",
"multiple",
"BAM",
"files",
"together",
"with",
"Picard",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L65-L83 |
223,915 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_reorder | def picard_reorder(picard, in_bam, ref_file, out_file):
"""Reorder BAM file to match reference file ordering.
"""
if not file_exists(out_file):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_file) as tx_out_file:
opts = [("INPUT", in_... | python | def picard_reorder(picard, in_bam, ref_file, out_file):
"""Reorder BAM file to match reference file ordering.
"""
if not file_exists(out_file):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_file) as tx_out_file:
opts = [("INPUT", in_... | [
"def",
"picard_reorder",
"(",
"picard",
",",
"in_bam",
",",
"ref_file",
",",
"out_file",
")",
":",
"if",
"not",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"tx_tmpdir",
"(",
"picard",
".",
"_config",
")",
"as",
"tmp_dir",
":",
"with",
"file_transacti... | Reorder BAM file to match reference file ordering. | [
"Reorder",
"BAM",
"file",
"to",
"match",
"reference",
"file",
"ordering",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L95-L107 |
223,916 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_fix_rgs | def picard_fix_rgs(picard, in_bam, names):
"""Add read group information to BAM files and coordinate sort.
"""
out_file = "%s-fixrgs.bam" % os.path.splitext(in_bam)[0]
if not file_exists(out_file):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_f... | python | def picard_fix_rgs(picard, in_bam, names):
"""Add read group information to BAM files and coordinate sort.
"""
out_file = "%s-fixrgs.bam" % os.path.splitext(in_bam)[0]
if not file_exists(out_file):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_f... | [
"def",
"picard_fix_rgs",
"(",
"picard",
",",
"in_bam",
",",
"names",
")",
":",
"out_file",
"=",
"\"%s-fixrgs.bam\"",
"%",
"os",
".",
"path",
".",
"splitext",
"(",
"in_bam",
")",
"[",
"0",
"]",
"if",
"not",
"file_exists",
"(",
"out_file",
")",
":",
"wit... | Add read group information to BAM files and coordinate sort. | [
"Add",
"read",
"group",
"information",
"to",
"BAM",
"files",
"and",
"coordinate",
"sort",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L109-L126 |
223,917 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_index_ref | def picard_index_ref(picard, ref_file):
"""Provide a Picard style dict index file for a reference genome.
"""
dict_file = "%s.dict" % os.path.splitext(ref_file)[0]
if not file_exists(dict_file):
with file_transaction(picard._config, dict_file) as tx_dict_file:
opts = [("REFERENCE", r... | python | def picard_index_ref(picard, ref_file):
"""Provide a Picard style dict index file for a reference genome.
"""
dict_file = "%s.dict" % os.path.splitext(ref_file)[0]
if not file_exists(dict_file):
with file_transaction(picard._config, dict_file) as tx_dict_file:
opts = [("REFERENCE", r... | [
"def",
"picard_index_ref",
"(",
"picard",
",",
"ref_file",
")",
":",
"dict_file",
"=",
"\"%s.dict\"",
"%",
"os",
".",
"path",
".",
"splitext",
"(",
"ref_file",
")",
"[",
"0",
"]",
"if",
"not",
"file_exists",
"(",
"dict_file",
")",
":",
"with",
"file_tran... | Provide a Picard style dict index file for a reference genome. | [
"Provide",
"a",
"Picard",
"style",
"dict",
"index",
"file",
"for",
"a",
"reference",
"genome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L142-L151 |
223,918 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_bam_to_fastq | def picard_bam_to_fastq(picard, in_bam, fastq_one, fastq_two=None):
"""Convert BAM file to fastq.
"""
if not file_exists(fastq_one):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, fastq_one) as tx_out1:
opts = [("INPUT", in_bam),
... | python | def picard_bam_to_fastq(picard, in_bam, fastq_one, fastq_two=None):
"""Convert BAM file to fastq.
"""
if not file_exists(fastq_one):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, fastq_one) as tx_out1:
opts = [("INPUT", in_bam),
... | [
"def",
"picard_bam_to_fastq",
"(",
"picard",
",",
"in_bam",
",",
"fastq_one",
",",
"fastq_two",
"=",
"None",
")",
":",
"if",
"not",
"file_exists",
"(",
"fastq_one",
")",
":",
"with",
"tx_tmpdir",
"(",
"picard",
".",
"_config",
")",
"as",
"tmp_dir",
":",
... | Convert BAM file to fastq. | [
"Convert",
"BAM",
"file",
"to",
"fastq",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L174-L186 |
223,919 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_sam_to_bam | def picard_sam_to_bam(picard, align_sam, fastq_bam, ref_file,
is_paired=False):
"""Convert SAM to BAM, including unmapped reads from fastq BAM file.
"""
to_retain = ["XS", "XG", "XM", "XN", "XO", "YT"]
if align_sam.endswith(".sam"):
out_bam = "%s.bam" % os.path.splitext(ali... | python | def picard_sam_to_bam(picard, align_sam, fastq_bam, ref_file,
is_paired=False):
"""Convert SAM to BAM, including unmapped reads from fastq BAM file.
"""
to_retain = ["XS", "XG", "XM", "XN", "XO", "YT"]
if align_sam.endswith(".sam"):
out_bam = "%s.bam" % os.path.splitext(ali... | [
"def",
"picard_sam_to_bam",
"(",
"picard",
",",
"align_sam",
",",
"fastq_bam",
",",
"ref_file",
",",
"is_paired",
"=",
"False",
")",
":",
"to_retain",
"=",
"[",
"\"XS\"",
",",
"\"XG\"",
",",
"\"XM\"",
",",
"\"XN\"",
",",
"\"XO\"",
",",
"\"YT\"",
"]",
"if... | Convert SAM to BAM, including unmapped reads from fastq BAM file. | [
"Convert",
"SAM",
"to",
"BAM",
"including",
"unmapped",
"reads",
"from",
"fastq",
"BAM",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L188-L211 |
223,920 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_formatconverter | def picard_formatconverter(picard, align_sam):
"""Convert aligned SAM file to BAM format.
"""
out_bam = "%s.bam" % os.path.splitext(align_sam)[0]
if not file_exists(out_bam):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_bam) as tx_out_bam:
... | python | def picard_formatconverter(picard, align_sam):
"""Convert aligned SAM file to BAM format.
"""
out_bam = "%s.bam" % os.path.splitext(align_sam)[0]
if not file_exists(out_bam):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_bam) as tx_out_bam:
... | [
"def",
"picard_formatconverter",
"(",
"picard",
",",
"align_sam",
")",
":",
"out_bam",
"=",
"\"%s.bam\"",
"%",
"os",
".",
"path",
".",
"splitext",
"(",
"align_sam",
")",
"[",
"0",
"]",
"if",
"not",
"file_exists",
"(",
"out_bam",
")",
":",
"with",
"tx_tmp... | Convert aligned SAM file to BAM format. | [
"Convert",
"aligned",
"SAM",
"file",
"to",
"BAM",
"format",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L213-L224 |
223,921 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_fixmate | def picard_fixmate(picard, align_bam):
"""Run Picard's FixMateInformation generating an aligned output file.
"""
base, ext = os.path.splitext(align_bam)
out_file = "%s-sort%s" % (base, ext)
if not file_exists(out_file):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transac... | python | def picard_fixmate(picard, align_bam):
"""Run Picard's FixMateInformation generating an aligned output file.
"""
base, ext = os.path.splitext(align_bam)
out_file = "%s-sort%s" % (base, ext)
if not file_exists(out_file):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transac... | [
"def",
"picard_fixmate",
"(",
"picard",
",",
"align_bam",
")",
":",
"base",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"align_bam",
")",
"out_file",
"=",
"\"%s-sort%s\"",
"%",
"(",
"base",
",",
"ext",
")",
"if",
"not",
"file_exists",
"("... | Run Picard's FixMateInformation generating an aligned output file. | [
"Run",
"Picard",
"s",
"FixMateInformation",
"generating",
"an",
"aligned",
"output",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L244-L257 |
223,922 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | picard_idxstats | def picard_idxstats(picard, align_bam):
"""Retrieve alignment stats from picard using BamIndexStats.
"""
opts = [("INPUT", align_bam)]
stdout = picard.run("BamIndexStats", opts, get_stdout=True)
out = []
AlignInfo = collections.namedtuple("AlignInfo", ["contig", "length", "aligned", "unaligned"]... | python | def picard_idxstats(picard, align_bam):
"""Retrieve alignment stats from picard using BamIndexStats.
"""
opts = [("INPUT", align_bam)]
stdout = picard.run("BamIndexStats", opts, get_stdout=True)
out = []
AlignInfo = collections.namedtuple("AlignInfo", ["contig", "length", "aligned", "unaligned"]... | [
"def",
"picard_idxstats",
"(",
"picard",
",",
"align_bam",
")",
":",
"opts",
"=",
"[",
"(",
"\"INPUT\"",
",",
"align_bam",
")",
"]",
"stdout",
"=",
"picard",
".",
"run",
"(",
"\"BamIndexStats\"",
",",
"opts",
",",
"get_stdout",
"=",
"True",
")",
"out",
... | Retrieve alignment stats from picard using BamIndexStats. | [
"Retrieve",
"alignment",
"stats",
"from",
"picard",
"using",
"BamIndexStats",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L259-L277 |
223,923 | bcbio/bcbio-nextgen | bcbio/broad/picardrun.py | bed2interval | def bed2interval(align_file, bed, out_file=None):
"""Converts a bed file to an interval file for use with some of the
Picard tools by grabbing the header from the alignment file, reording
the bed file columns and gluing them together.
align_file can be in BAM or SAM format.
bed needs to be in bed12... | python | def bed2interval(align_file, bed, out_file=None):
"""Converts a bed file to an interval file for use with some of the
Picard tools by grabbing the header from the alignment file, reording
the bed file columns and gluing them together.
align_file can be in BAM or SAM format.
bed needs to be in bed12... | [
"def",
"bed2interval",
"(",
"align_file",
",",
"bed",
",",
"out_file",
"=",
"None",
")",
":",
"import",
"pysam",
"base",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"align_file",
")",
"if",
"out_file",
"is",
"None",
":",
"out_file",
"=",
... | Converts a bed file to an interval file for use with some of the
Picard tools by grabbing the header from the alignment file, reording
the bed file columns and gluing them together.
align_file can be in BAM or SAM format.
bed needs to be in bed12 format:
http://genome.ucsc.edu/FAQ/FAQformat.html#fo... | [
"Converts",
"a",
"bed",
"file",
"to",
"an",
"interval",
"file",
"for",
"use",
"with",
"some",
"of",
"the",
"Picard",
"tools",
"by",
"grabbing",
"the",
"header",
"from",
"the",
"alignment",
"file",
"reording",
"the",
"bed",
"file",
"columns",
"and",
"gluing... | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/broad/picardrun.py#L279-L309 |
223,924 | bcbio/bcbio-nextgen | bcbio/variation/vardict.py | _enforce_max_region_size | def _enforce_max_region_size(in_file, data):
"""Ensure we don't have any chunks in the region greater than 20kb.
VarDict memory usage depends on size of individual windows in the input
file. This breaks regions into 20kb chunks with 250bp overlaps. 20kb gives
~1Gb/core memory usage and the overlaps avo... | python | def _enforce_max_region_size(in_file, data):
"""Ensure we don't have any chunks in the region greater than 20kb.
VarDict memory usage depends on size of individual windows in the input
file. This breaks regions into 20kb chunks with 250bp overlaps. 20kb gives
~1Gb/core memory usage and the overlaps avo... | [
"def",
"_enforce_max_region_size",
"(",
"in_file",
",",
"data",
")",
":",
"max_size",
"=",
"20000",
"overlap_size",
"=",
"250",
"def",
"_has_larger_regions",
"(",
"f",
")",
":",
"return",
"any",
"(",
"r",
".",
"stop",
"-",
"r",
".",
"start",
">",
"max_si... | Ensure we don't have any chunks in the region greater than 20kb.
VarDict memory usage depends on size of individual windows in the input
file. This breaks regions into 20kb chunks with 250bp overlaps. 20kb gives
~1Gb/core memory usage and the overlaps avoid missing indels spanning a
gap. Downstream Var... | [
"Ensure",
"we",
"don",
"t",
"have",
"any",
"chunks",
"in",
"the",
"region",
"greater",
"than",
"20kb",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vardict.py#L90-L113 |
223,925 | bcbio/bcbio-nextgen | bcbio/variation/vardict.py | run_vardict | def run_vardict(align_bams, items, ref_file, assoc_files, region=None,
out_file=None):
"""Run VarDict variant calling.
"""
items = shared.add_highdepth_genome_exclusion(items)
if vcfutils.is_paired_analysis(align_bams, items):
call_file = _run_vardict_paired(align_bams, items, re... | python | def run_vardict(align_bams, items, ref_file, assoc_files, region=None,
out_file=None):
"""Run VarDict variant calling.
"""
items = shared.add_highdepth_genome_exclusion(items)
if vcfutils.is_paired_analysis(align_bams, items):
call_file = _run_vardict_paired(align_bams, items, re... | [
"def",
"run_vardict",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"assoc_files",
",",
"region",
"=",
"None",
",",
"out_file",
"=",
"None",
")",
":",
"items",
"=",
"shared",
".",
"add_highdepth_genome_exclusion",
"(",
"items",
")",
"if",
"vcfutils"... | Run VarDict variant calling. | [
"Run",
"VarDict",
"variant",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vardict.py#L115-L127 |
223,926 | bcbio/bcbio-nextgen | bcbio/variation/vardict.py | _get_jvm_opts | def _get_jvm_opts(data, out_file):
"""Retrieve JVM options when running the Java version of VarDict.
"""
if get_vardict_command(data) == "vardict-java":
resources = config_utils.get_resources("vardict", data["config"])
jvm_opts = resources.get("jvm_opts", ["-Xms750m", "-Xmx4g"])
jvm_... | python | def _get_jvm_opts(data, out_file):
"""Retrieve JVM options when running the Java version of VarDict.
"""
if get_vardict_command(data) == "vardict-java":
resources = config_utils.get_resources("vardict", data["config"])
jvm_opts = resources.get("jvm_opts", ["-Xms750m", "-Xmx4g"])
jvm_... | [
"def",
"_get_jvm_opts",
"(",
"data",
",",
"out_file",
")",
":",
"if",
"get_vardict_command",
"(",
"data",
")",
"==",
"\"vardict-java\"",
":",
"resources",
"=",
"config_utils",
".",
"get_resources",
"(",
"\"vardict\"",
",",
"data",
"[",
"\"config\"",
"]",
")",
... | Retrieve JVM options when running the Java version of VarDict. | [
"Retrieve",
"JVM",
"options",
"when",
"running",
"the",
"Java",
"version",
"of",
"VarDict",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vardict.py#L129-L138 |
223,927 | bcbio/bcbio-nextgen | bcbio/variation/vardict.py | _run_vardict_caller | def _run_vardict_caller(align_bams, items, ref_file, assoc_files,
region=None, out_file=None):
"""Detect SNPs and indels with VarDict.
var2vcf_valid uses -A flag which reports all alleles and improves sensitivity:
https://github.com/AstraZeneca-NGS/VarDict/issues/35#issuecomment-2... | python | def _run_vardict_caller(align_bams, items, ref_file, assoc_files,
region=None, out_file=None):
"""Detect SNPs and indels with VarDict.
var2vcf_valid uses -A flag which reports all alleles and improves sensitivity:
https://github.com/AstraZeneca-NGS/VarDict/issues/35#issuecomment-2... | [
"def",
"_run_vardict_caller",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"assoc_files",
",",
"region",
"=",
"None",
",",
"out_file",
"=",
"None",
")",
":",
"config",
"=",
"items",
"[",
"0",
"]",
"[",
"\"config\"",
"]",
"if",
"out_file",
"is",... | Detect SNPs and indels with VarDict.
var2vcf_valid uses -A flag which reports all alleles and improves sensitivity:
https://github.com/AstraZeneca-NGS/VarDict/issues/35#issuecomment-276738191 | [
"Detect",
"SNPs",
"and",
"indels",
"with",
"VarDict",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vardict.py#L140-L201 |
223,928 | bcbio/bcbio-nextgen | bcbio/variation/vardict.py | _lowfreq_linear_filter | def _lowfreq_linear_filter(tumor_index, is_paired):
"""Linear classifier for removing low frequency false positives.
Uses a logistic classifier based on 0.5% tumor only variants from the smcounter2 paper:
https://github.com/bcbio/bcbio_validations/tree/master/somatic-lowfreq
The classifier uses stran... | python | def _lowfreq_linear_filter(tumor_index, is_paired):
"""Linear classifier for removing low frequency false positives.
Uses a logistic classifier based on 0.5% tumor only variants from the smcounter2 paper:
https://github.com/bcbio/bcbio_validations/tree/master/somatic-lowfreq
The classifier uses stran... | [
"def",
"_lowfreq_linear_filter",
"(",
"tumor_index",
",",
"is_paired",
")",
":",
"if",
"is_paired",
":",
"sbf",
"=",
"\"FORMAT/SBF[%s]\"",
"%",
"tumor_index",
"nm",
"=",
"\"FORMAT/NM[%s]\"",
"%",
"tumor_index",
"else",
":",
"sbf",
"=",
"\"INFO/SBF\"",
"nm",
"=",... | Linear classifier for removing low frequency false positives.
Uses a logistic classifier based on 0.5% tumor only variants from the smcounter2 paper:
https://github.com/bcbio/bcbio_validations/tree/master/somatic-lowfreq
The classifier uses strand bias (SBF) and read mismatches (NM) and
applies only ... | [
"Linear",
"classifier",
"for",
"removing",
"low",
"frequency",
"false",
"positives",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vardict.py#L203-L222 |
223,929 | bcbio/bcbio-nextgen | bcbio/variation/vardict.py | add_db_germline_flag | def add_db_germline_flag(line):
"""Adds a DB flag for Germline filters, allowing downstream compatibility with PureCN.
"""
if line.startswith("#CHROM"):
headers = ['##INFO=<ID=DB,Number=0,Type=Flag,Description="Likely germline variant">']
return "\n".join(headers) + "\n" + line
elif line... | python | def add_db_germline_flag(line):
"""Adds a DB flag for Germline filters, allowing downstream compatibility with PureCN.
"""
if line.startswith("#CHROM"):
headers = ['##INFO=<ID=DB,Number=0,Type=Flag,Description="Likely germline variant">']
return "\n".join(headers) + "\n" + line
elif line... | [
"def",
"add_db_germline_flag",
"(",
"line",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"\"#CHROM\"",
")",
":",
"headers",
"=",
"[",
"'##INFO=<ID=DB,Number=0,Type=Flag,Description=\"Likely germline variant\">'",
"]",
"return",
"\"\\n\"",
".",
"join",
"(",
"headers... | Adds a DB flag for Germline filters, allowing downstream compatibility with PureCN. | [
"Adds",
"a",
"DB",
"flag",
"for",
"Germline",
"filters",
"allowing",
"downstream",
"compatibility",
"with",
"PureCN",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vardict.py#L224-L236 |
223,930 | bcbio/bcbio-nextgen | bcbio/variation/vardict.py | depth_freq_filter | def depth_freq_filter(line, tumor_index, aligner):
"""Command line to filter VarDict calls based on depth, frequency and quality.
Looks at regions with low depth for allele frequency (AF * DP < 6, the equivalent
of < 13bp for heterogygote calls, but generalized. Within these calls filters if a
calls ha... | python | def depth_freq_filter(line, tumor_index, aligner):
"""Command line to filter VarDict calls based on depth, frequency and quality.
Looks at regions with low depth for allele frequency (AF * DP < 6, the equivalent
of < 13bp for heterogygote calls, but generalized. Within these calls filters if a
calls ha... | [
"def",
"depth_freq_filter",
"(",
"line",
",",
"tumor_index",
",",
"aligner",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"\"#CHROM\"",
")",
":",
"headers",
"=",
"[",
"(",
"'##FILTER=<ID=LowAlleleDepth,Description=\"Low depth per allele frequency '",
"'along with poo... | Command line to filter VarDict calls based on depth, frequency and quality.
Looks at regions with low depth for allele frequency (AF * DP < 6, the equivalent
of < 13bp for heterogygote calls, but generalized. Within these calls filters if a
calls has:
- Low mapping quality and multiple mismatches in a... | [
"Command",
"line",
"to",
"filter",
"VarDict",
"calls",
"based",
"on",
"depth",
"frequency",
"and",
"quality",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vardict.py#L238-L293 |
223,931 | bcbio/bcbio-nextgen | bcbio/variation/vardict.py | get_vardict_command | def get_vardict_command(data):
"""
convert variantcaller specification to proper vardict command, handling
string or list specification
"""
vcaller = dd.get_variantcaller(data)
if isinstance(vcaller, list):
vardict = [x for x in vcaller if "vardict" in x]
if not vardict:
... | python | def get_vardict_command(data):
"""
convert variantcaller specification to proper vardict command, handling
string or list specification
"""
vcaller = dd.get_variantcaller(data)
if isinstance(vcaller, list):
vardict = [x for x in vcaller if "vardict" in x]
if not vardict:
... | [
"def",
"get_vardict_command",
"(",
"data",
")",
":",
"vcaller",
"=",
"dd",
".",
"get_variantcaller",
"(",
"data",
")",
"if",
"isinstance",
"(",
"vcaller",
",",
"list",
")",
":",
"vardict",
"=",
"[",
"x",
"for",
"x",
"in",
"vcaller",
"if",
"\"vardict\"",
... | convert variantcaller specification to proper vardict command, handling
string or list specification | [
"convert",
"variantcaller",
"specification",
"to",
"proper",
"vardict",
"command",
"handling",
"string",
"or",
"list",
"specification"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vardict.py#L362-L378 |
223,932 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | run | def run(vrn_info, calls_by_name, somatic_info, do_plots=True, handle_failures=True):
"""Run BubbleTree given variant calls, CNVs and somatic
"""
if "seq2c" in calls_by_name:
cnv_info = calls_by_name["seq2c"]
elif "cnvkit" in calls_by_name:
cnv_info = calls_by_name["cnvkit"]
else:
... | python | def run(vrn_info, calls_by_name, somatic_info, do_plots=True, handle_failures=True):
"""Run BubbleTree given variant calls, CNVs and somatic
"""
if "seq2c" in calls_by_name:
cnv_info = calls_by_name["seq2c"]
elif "cnvkit" in calls_by_name:
cnv_info = calls_by_name["cnvkit"]
else:
... | [
"def",
"run",
"(",
"vrn_info",
",",
"calls_by_name",
",",
"somatic_info",
",",
"do_plots",
"=",
"True",
",",
"handle_failures",
"=",
"True",
")",
":",
"if",
"\"seq2c\"",
"in",
"calls_by_name",
":",
"cnv_info",
"=",
"calls_by_name",
"[",
"\"seq2c\"",
"]",
"el... | Run BubbleTree given variant calls, CNVs and somatic | [
"Run",
"BubbleTree",
"given",
"variant",
"calls",
"CNVs",
"and",
"somatic"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L34-L57 |
223,933 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | _run_bubbletree | def _run_bubbletree(vcf_csv, cnv_csv, data, wide_lrr=False, do_plots=True,
handle_failures=True):
"""Create R script and run on input data
BubbleTree has some internal hardcoded paramters that assume a smaller
distribution of log2 scores. This is not true for tumor-only calls, so if
... | python | def _run_bubbletree(vcf_csv, cnv_csv, data, wide_lrr=False, do_plots=True,
handle_failures=True):
"""Create R script and run on input data
BubbleTree has some internal hardcoded paramters that assume a smaller
distribution of log2 scores. This is not true for tumor-only calls, so if
... | [
"def",
"_run_bubbletree",
"(",
"vcf_csv",
",",
"cnv_csv",
",",
"data",
",",
"wide_lrr",
"=",
"False",
",",
"do_plots",
"=",
"True",
",",
"handle_failures",
"=",
"True",
")",
":",
"lrr_scale",
"=",
"10.0",
"if",
"wide_lrr",
"else",
"1.0",
"local_sitelib",
"... | Create R script and run on input data
BubbleTree has some internal hardcoded paramters that assume a smaller
distribution of log2 scores. This is not true for tumor-only calls, so if
we specify wide_lrr we scale the calculations to actually get calls. Need a
better long term solution with flexible para... | [
"Create",
"R",
"script",
"and",
"run",
"on",
"input",
"data"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L59-L93 |
223,934 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | _prep_cnv_file | def _prep_cnv_file(cns_file, svcaller, work_dir, data):
"""Create a CSV file of CNV calls with log2 and number of marks.
"""
in_file = cns_file
out_file = os.path.join(work_dir, "%s-%s-prep.csv" % (utils.splitext_plus(os.path.basename(in_file))[0],
... | python | def _prep_cnv_file(cns_file, svcaller, work_dir, data):
"""Create a CSV file of CNV calls with log2 and number of marks.
"""
in_file = cns_file
out_file = os.path.join(work_dir, "%s-%s-prep.csv" % (utils.splitext_plus(os.path.basename(in_file))[0],
... | [
"def",
"_prep_cnv_file",
"(",
"cns_file",
",",
"svcaller",
",",
"work_dir",
",",
"data",
")",
":",
"in_file",
"=",
"cns_file",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"\"%s-%s-prep.csv\"",
"%",
"(",
"utils",
".",
"splitext_pl... | Create a CSV file of CNV calls with log2 and number of marks. | [
"Create",
"a",
"CSV",
"file",
"of",
"CNV",
"calls",
"with",
"log2",
"and",
"number",
"of",
"marks",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L104-L123 |
223,935 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | prep_vrn_file | def prep_vrn_file(in_file, vcaller, work_dir, somatic_info, writer_class, seg_file=None, params=None):
"""Select heterozygous variants in the normal sample with sufficient depth.
writer_class implements write_header and write_row to write VCF outputs
from a record and extracted tumor/normal statistics.
... | python | def prep_vrn_file(in_file, vcaller, work_dir, somatic_info, writer_class, seg_file=None, params=None):
"""Select heterozygous variants in the normal sample with sufficient depth.
writer_class implements write_header and write_row to write VCF outputs
from a record and extracted tumor/normal statistics.
... | [
"def",
"prep_vrn_file",
"(",
"in_file",
",",
"vcaller",
",",
"work_dir",
",",
"somatic_info",
",",
"writer_class",
",",
"seg_file",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"data",
"=",
"somatic_info",
".",
"tumor_data",
"if",
"not",
"params",
":... | Select heterozygous variants in the normal sample with sufficient depth.
writer_class implements write_header and write_row to write VCF outputs
from a record and extracted tumor/normal statistics. | [
"Select",
"heterozygous",
"variants",
"in",
"the",
"normal",
"sample",
"with",
"sufficient",
"depth",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L125-L153 |
223,936 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | max_normal_germline_depth | def max_normal_germline_depth(in_file, params, somatic_info):
"""Calculate threshold for excluding potential heterozygotes based on normal depth.
"""
bcf_in = pysam.VariantFile(in_file)
depths = []
for rec in bcf_in:
stats = _is_possible_loh(rec, bcf_in, params, somatic_info)
if tz.g... | python | def max_normal_germline_depth(in_file, params, somatic_info):
"""Calculate threshold for excluding potential heterozygotes based on normal depth.
"""
bcf_in = pysam.VariantFile(in_file)
depths = []
for rec in bcf_in:
stats = _is_possible_loh(rec, bcf_in, params, somatic_info)
if tz.g... | [
"def",
"max_normal_germline_depth",
"(",
"in_file",
",",
"params",
",",
"somatic_info",
")",
":",
"bcf_in",
"=",
"pysam",
".",
"VariantFile",
"(",
"in_file",
")",
"depths",
"=",
"[",
"]",
"for",
"rec",
"in",
"bcf_in",
":",
"stats",
"=",
"_is_possible_loh",
... | Calculate threshold for excluding potential heterozygotes based on normal depth. | [
"Calculate",
"threshold",
"for",
"excluding",
"potential",
"heterozygotes",
"based",
"on",
"normal",
"depth",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L162-L172 |
223,937 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | _identify_heterogeneity_blocks_hmm | def _identify_heterogeneity_blocks_hmm(in_file, params, work_dir, somatic_info):
"""Use a HMM to identify blocks of heterogeneity to use for calculating allele frequencies.
The goal is to subset the genome to a more reasonable section that contains potential
loss of heterogeneity or other allele frequency ... | python | def _identify_heterogeneity_blocks_hmm(in_file, params, work_dir, somatic_info):
"""Use a HMM to identify blocks of heterogeneity to use for calculating allele frequencies.
The goal is to subset the genome to a more reasonable section that contains potential
loss of heterogeneity or other allele frequency ... | [
"def",
"_identify_heterogeneity_blocks_hmm",
"(",
"in_file",
",",
"params",
",",
"work_dir",
",",
"somatic_info",
")",
":",
"def",
"_segment_by_hmm",
"(",
"chrom",
",",
"freqs",
",",
"coords",
")",
":",
"cur_coords",
"=",
"[",
"]",
"for",
"j",
",",
"state",
... | Use a HMM to identify blocks of heterogeneity to use for calculating allele frequencies.
The goal is to subset the genome to a more reasonable section that contains potential
loss of heterogeneity or other allele frequency adjustment based on selection. | [
"Use",
"a",
"HMM",
"to",
"identify",
"blocks",
"of",
"heterogeneity",
"to",
"use",
"for",
"calculating",
"allele",
"frequencies",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L195-L216 |
223,938 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | _predict_states | def _predict_states(freqs):
"""Use frequencies to predict states across a chromosome.
Normalize so heterozygote blocks are assigned state 0 and homozygous
are assigned state 1.
"""
from hmmlearn import hmm
freqs = np.column_stack([np.array(freqs)])
model = hmm.GaussianHMM(2, covariance_type... | python | def _predict_states(freqs):
"""Use frequencies to predict states across a chromosome.
Normalize so heterozygote blocks are assigned state 0 and homozygous
are assigned state 1.
"""
from hmmlearn import hmm
freqs = np.column_stack([np.array(freqs)])
model = hmm.GaussianHMM(2, covariance_type... | [
"def",
"_predict_states",
"(",
"freqs",
")",
":",
"from",
"hmmlearn",
"import",
"hmm",
"freqs",
"=",
"np",
".",
"column_stack",
"(",
"[",
"np",
".",
"array",
"(",
"freqs",
")",
"]",
")",
"model",
"=",
"hmm",
".",
"GaussianHMM",
"(",
"2",
",",
"covari... | Use frequencies to predict states across a chromosome.
Normalize so heterozygote blocks are assigned state 0 and homozygous
are assigned state 1. | [
"Use",
"frequencies",
"to",
"predict",
"states",
"across",
"a",
"chromosome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L230-L246 |
223,939 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | _freqs_by_chromosome | def _freqs_by_chromosome(in_file, params, somatic_info):
"""Retrieve frequencies across each chromosome as inputs to HMM.
"""
freqs = []
coords = []
cur_chrom = None
with pysam.VariantFile(in_file) as bcf_in:
for rec in bcf_in:
if _is_biallelic_snp(rec) and _passes_plus_germl... | python | def _freqs_by_chromosome(in_file, params, somatic_info):
"""Retrieve frequencies across each chromosome as inputs to HMM.
"""
freqs = []
coords = []
cur_chrom = None
with pysam.VariantFile(in_file) as bcf_in:
for rec in bcf_in:
if _is_biallelic_snp(rec) and _passes_plus_germl... | [
"def",
"_freqs_by_chromosome",
"(",
"in_file",
",",
"params",
",",
"somatic_info",
")",
":",
"freqs",
"=",
"[",
"]",
"coords",
"=",
"[",
"]",
"cur_chrom",
"=",
"None",
"with",
"pysam",
".",
"VariantFile",
"(",
"in_file",
")",
"as",
"bcf_in",
":",
"for",
... | Retrieve frequencies across each chromosome as inputs to HMM. | [
"Retrieve",
"frequencies",
"across",
"each",
"chromosome",
"as",
"inputs",
"to",
"HMM",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L248-L270 |
223,940 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | _create_subset_file | def _create_subset_file(in_file, het_region_bed, work_dir, data):
"""Subset the VCF to a set of pre-calculated smaller regions.
"""
cnv_regions = shared.get_base_cnv_regions(data, work_dir)
region_bed = bedutils.intersect_two(het_region_bed, cnv_regions, work_dir, data)
out_file = os.path.join(work_... | python | def _create_subset_file(in_file, het_region_bed, work_dir, data):
"""Subset the VCF to a set of pre-calculated smaller regions.
"""
cnv_regions = shared.get_base_cnv_regions(data, work_dir)
region_bed = bedutils.intersect_two(het_region_bed, cnv_regions, work_dir, data)
out_file = os.path.join(work_... | [
"def",
"_create_subset_file",
"(",
"in_file",
",",
"het_region_bed",
",",
"work_dir",
",",
"data",
")",
":",
"cnv_regions",
"=",
"shared",
".",
"get_base_cnv_regions",
"(",
"data",
",",
"work_dir",
")",
"region_bed",
"=",
"bedutils",
".",
"intersect_two",
"(",
... | Subset the VCF to a set of pre-calculated smaller regions. | [
"Subset",
"the",
"VCF",
"to",
"a",
"set",
"of",
"pre",
"-",
"calculated",
"smaller",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L272-L283 |
223,941 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | is_info_germline | def is_info_germline(rec):
"""Check if a variant record is germline based on INFO attributes.
Works with VarDict's annotation of STATUS.
"""
if hasattr(rec, "INFO"):
status = rec.INFO.get("STATUS", "").lower()
else:
status = rec.info.get("STATUS", "").lower()
return status == "g... | python | def is_info_germline(rec):
"""Check if a variant record is germline based on INFO attributes.
Works with VarDict's annotation of STATUS.
"""
if hasattr(rec, "INFO"):
status = rec.INFO.get("STATUS", "").lower()
else:
status = rec.info.get("STATUS", "").lower()
return status == "g... | [
"def",
"is_info_germline",
"(",
"rec",
")",
":",
"if",
"hasattr",
"(",
"rec",
",",
"\"INFO\"",
")",
":",
"status",
"=",
"rec",
".",
"INFO",
".",
"get",
"(",
"\"STATUS\"",
",",
"\"\"",
")",
".",
"lower",
"(",
")",
"else",
":",
"status",
"=",
"rec",
... | Check if a variant record is germline based on INFO attributes.
Works with VarDict's annotation of STATUS. | [
"Check",
"if",
"a",
"variant",
"record",
"is",
"germline",
"based",
"on",
"INFO",
"attributes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L290-L299 |
223,942 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | _tumor_normal_stats | def _tumor_normal_stats(rec, somatic_info, vcf_rec):
"""Retrieve depth and frequency of tumor and normal samples.
"""
out = {"normal": {"alt": None, "depth": None, "freq": None},
"tumor": {"alt": 0, "depth": 0, "freq": None}}
if hasattr(vcf_rec, "samples"):
samples = [(s, {}) for s in... | python | def _tumor_normal_stats(rec, somatic_info, vcf_rec):
"""Retrieve depth and frequency of tumor and normal samples.
"""
out = {"normal": {"alt": None, "depth": None, "freq": None},
"tumor": {"alt": 0, "depth": 0, "freq": None}}
if hasattr(vcf_rec, "samples"):
samples = [(s, {}) for s in... | [
"def",
"_tumor_normal_stats",
"(",
"rec",
",",
"somatic_info",
",",
"vcf_rec",
")",
":",
"out",
"=",
"{",
"\"normal\"",
":",
"{",
"\"alt\"",
":",
"None",
",",
"\"depth\"",
":",
"None",
",",
"\"freq\"",
":",
"None",
"}",
",",
"\"tumor\"",
":",
"{",
"\"a... | Retrieve depth and frequency of tumor and normal samples. | [
"Retrieve",
"depth",
"and",
"frequency",
"of",
"tumor",
"and",
"normal",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L328-L356 |
223,943 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | _is_possible_loh | def _is_possible_loh(rec, vcf_rec, params, somatic_info, use_status=False, max_normal_depth=None):
"""Check if the VCF record is a het in the normal with sufficient support.
Only returns SNPs, since indels tend to have less precise frequency measurements.
"""
if _is_biallelic_snp(rec) and _passes_plus_... | python | def _is_possible_loh(rec, vcf_rec, params, somatic_info, use_status=False, max_normal_depth=None):
"""Check if the VCF record is a het in the normal with sufficient support.
Only returns SNPs, since indels tend to have less precise frequency measurements.
"""
if _is_biallelic_snp(rec) and _passes_plus_... | [
"def",
"_is_possible_loh",
"(",
"rec",
",",
"vcf_rec",
",",
"params",
",",
"somatic_info",
",",
"use_status",
"=",
"False",
",",
"max_normal_depth",
"=",
"None",
")",
":",
"if",
"_is_biallelic_snp",
"(",
"rec",
")",
"and",
"_passes_plus_germline",
"(",
"rec",
... | Check if the VCF record is a het in the normal with sufficient support.
Only returns SNPs, since indels tend to have less precise frequency measurements. | [
"Check",
"if",
"the",
"VCF",
"record",
"is",
"a",
"het",
"in",
"the",
"normal",
"with",
"sufficient",
"support",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L358-L378 |
223,944 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | _has_population_germline | def _has_population_germline(rec):
"""Check if header defines population annotated germline samples for tumor only.
"""
for k in population_keys:
if k in rec.header.info:
return True
return False | python | def _has_population_germline(rec):
"""Check if header defines population annotated germline samples for tumor only.
"""
for k in population_keys:
if k in rec.header.info:
return True
return False | [
"def",
"_has_population_germline",
"(",
"rec",
")",
":",
"for",
"k",
"in",
"population_keys",
":",
"if",
"k",
"in",
"rec",
".",
"header",
".",
"info",
":",
"return",
"True",
"return",
"False"
] | Check if header defines population annotated germline samples for tumor only. | [
"Check",
"if",
"header",
"defines",
"population",
"annotated",
"germline",
"samples",
"for",
"tumor",
"only",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L380-L386 |
223,945 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | is_population_germline | def is_population_germline(rec):
"""Identify a germline calls based on annoations with ExAC or other population databases.
"""
min_count = 50
for k in population_keys:
if k in rec.info:
val = rec.info.get(k)
if "," in val:
val = val.split(",")[0]
... | python | def is_population_germline(rec):
"""Identify a germline calls based on annoations with ExAC or other population databases.
"""
min_count = 50
for k in population_keys:
if k in rec.info:
val = rec.info.get(k)
if "," in val:
val = val.split(",")[0]
... | [
"def",
"is_population_germline",
"(",
"rec",
")",
":",
"min_count",
"=",
"50",
"for",
"k",
"in",
"population_keys",
":",
"if",
"k",
"in",
"rec",
".",
"info",
":",
"val",
"=",
"rec",
".",
"info",
".",
"get",
"(",
"k",
")",
"if",
"\",\"",
"in",
"val"... | Identify a germline calls based on annoations with ExAC or other population databases. | [
"Identify",
"a",
"germline",
"calls",
"based",
"on",
"annoations",
"with",
"ExAC",
"or",
"other",
"population",
"databases",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L388-L401 |
223,946 | bcbio/bcbio-nextgen | bcbio/heterogeneity/bubbletree.py | sample_alt_and_depth | def sample_alt_and_depth(rec, sample):
"""Flexibly get ALT allele and depth counts, handling FreeBayes, MuTect and other cases.
"""
if sample and "AD" in sample:
all_counts = [int(x) for x in sample["AD"]]
alt_counts = sum(all_counts[1:])
depth = sum(all_counts)
elif sample and "... | python | def sample_alt_and_depth(rec, sample):
"""Flexibly get ALT allele and depth counts, handling FreeBayes, MuTect and other cases.
"""
if sample and "AD" in sample:
all_counts = [int(x) for x in sample["AD"]]
alt_counts = sum(all_counts[1:])
depth = sum(all_counts)
elif sample and "... | [
"def",
"sample_alt_and_depth",
"(",
"rec",
",",
"sample",
")",
":",
"if",
"sample",
"and",
"\"AD\"",
"in",
"sample",
":",
"all_counts",
"=",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"sample",
"[",
"\"AD\"",
"]",
"]",
"alt_counts",
"=",
"sum",
"("... | Flexibly get ALT allele and depth counts, handling FreeBayes, MuTect and other cases. | [
"Flexibly",
"get",
"ALT",
"allele",
"and",
"depth",
"counts",
"handling",
"FreeBayes",
"MuTect",
"and",
"other",
"cases",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L403-L425 |
223,947 | bcbio/bcbio-nextgen | bcbio/bam/ref.py | fasta_idx | def fasta_idx(in_file, config=None):
"""Retrieve samtools style fasta index.
"""
fasta_index = in_file + ".fai"
if not utils.file_exists(fasta_index):
samtools = config_utils.get_program("samtools", config) if config else "samtools"
cmd = "{samtools} faidx {in_file}"
do.run(cmd.f... | python | def fasta_idx(in_file, config=None):
"""Retrieve samtools style fasta index.
"""
fasta_index = in_file + ".fai"
if not utils.file_exists(fasta_index):
samtools = config_utils.get_program("samtools", config) if config else "samtools"
cmd = "{samtools} faidx {in_file}"
do.run(cmd.f... | [
"def",
"fasta_idx",
"(",
"in_file",
",",
"config",
"=",
"None",
")",
":",
"fasta_index",
"=",
"in_file",
"+",
"\".fai\"",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"fasta_index",
")",
":",
"samtools",
"=",
"config_utils",
".",
"get_program",
"(",
"\"s... | Retrieve samtools style fasta index. | [
"Retrieve",
"samtools",
"style",
"fasta",
"index",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/ref.py#L9-L17 |
223,948 | bcbio/bcbio-nextgen | bcbio/bam/ref.py | file_contigs | def file_contigs(ref_file, config=None):
"""Iterator of reference contigs and lengths from a reference file.
"""
ContigInfo = collections.namedtuple("ContigInfo", "name size")
with open(fasta_idx(ref_file, config)) as in_handle:
for line in (l for l in in_handle if l.strip()):
name, ... | python | def file_contigs(ref_file, config=None):
"""Iterator of reference contigs and lengths from a reference file.
"""
ContigInfo = collections.namedtuple("ContigInfo", "name size")
with open(fasta_idx(ref_file, config)) as in_handle:
for line in (l for l in in_handle if l.strip()):
name, ... | [
"def",
"file_contigs",
"(",
"ref_file",
",",
"config",
"=",
"None",
")",
":",
"ContigInfo",
"=",
"collections",
".",
"namedtuple",
"(",
"\"ContigInfo\"",
",",
"\"name size\"",
")",
"with",
"open",
"(",
"fasta_idx",
"(",
"ref_file",
",",
"config",
")",
")",
... | Iterator of reference contigs and lengths from a reference file. | [
"Iterator",
"of",
"reference",
"contigs",
"and",
"lengths",
"from",
"a",
"reference",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/ref.py#L19-L26 |
223,949 | bcbio/bcbio-nextgen | bcbio/variation/smcounter2.py | run | def run(align_bams, items, ref_file, assoc_files, region=None, out_file=None):
"""Run tumor only smCounter2 calling.
"""
paired = vcfutils.get_paired_bams(align_bams, items)
assert paired and not paired.normal_bam, ("smCounter2 supports tumor-only variant calling: %s" %
... | python | def run(align_bams, items, ref_file, assoc_files, region=None, out_file=None):
"""Run tumor only smCounter2 calling.
"""
paired = vcfutils.get_paired_bams(align_bams, items)
assert paired and not paired.normal_bam, ("smCounter2 supports tumor-only variant calling: %s" %
... | [
"def",
"run",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"assoc_files",
",",
"region",
"=",
"None",
",",
"out_file",
"=",
"None",
")",
":",
"paired",
"=",
"vcfutils",
".",
"get_paired_bams",
"(",
"align_bams",
",",
"items",
")",
"assert",
"pa... | Run tumor only smCounter2 calling. | [
"Run",
"tumor",
"only",
"smCounter2",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/smcounter2.py#L17-L44 |
223,950 | bcbio/bcbio-nextgen | bcbio/bam/readstats.py | number_of_mapped_reads | def number_of_mapped_reads(data, bam_file, keep_dups=True, bed_file=None, target_name=None):
"""Count mapped reads, allow adjustment for duplicates and BED regions.
Since samtools view does not use indexes for BED files
(https://github.com/samtools/samtools/issues/88)
we loop over regions in a BED file... | python | def number_of_mapped_reads(data, bam_file, keep_dups=True, bed_file=None, target_name=None):
"""Count mapped reads, allow adjustment for duplicates and BED regions.
Since samtools view does not use indexes for BED files
(https://github.com/samtools/samtools/issues/88)
we loop over regions in a BED file... | [
"def",
"number_of_mapped_reads",
"(",
"data",
",",
"bam_file",
",",
"keep_dups",
"=",
"True",
",",
"bed_file",
"=",
"None",
",",
"target_name",
"=",
"None",
")",
":",
"# Flag explainer https://broadinstitute.github.io/picard/explain-flags.html",
"callable_flags",
"=",
"... | Count mapped reads, allow adjustment for duplicates and BED regions.
Since samtools view does not use indexes for BED files
(https://github.com/samtools/samtools/issues/88)
we loop over regions in a BED file and add the counts together.
Uses a global cache file to store counts, making it possible to p... | [
"Count",
"mapped",
"reads",
"allow",
"adjustment",
"for",
"duplicates",
"and",
"BED",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/readstats.py#L37-L102 |
223,951 | bcbio/bcbio-nextgen | bcbio/bam/readstats.py | _simple_lock | def _simple_lock(f):
"""Simple file lock, times out after 20 second assuming lock is stale
"""
lock_file = f + ".lock"
timeout = 20
curtime = 0
interval = 2
while os.path.exists(lock_file):
time.sleep(interval)
curtime += interval
if curtime > timeout:
os.... | python | def _simple_lock(f):
"""Simple file lock, times out after 20 second assuming lock is stale
"""
lock_file = f + ".lock"
timeout = 20
curtime = 0
interval = 2
while os.path.exists(lock_file):
time.sleep(interval)
curtime += interval
if curtime > timeout:
os.... | [
"def",
"_simple_lock",
"(",
"f",
")",
":",
"lock_file",
"=",
"f",
"+",
"\".lock\"",
"timeout",
"=",
"20",
"curtime",
"=",
"0",
"interval",
"=",
"2",
"while",
"os",
".",
"path",
".",
"exists",
"(",
"lock_file",
")",
":",
"time",
".",
"sleep",
"(",
"... | Simple file lock, times out after 20 second assuming lock is stale | [
"Simple",
"file",
"lock",
"times",
"out",
"after",
"20",
"second",
"assuming",
"lock",
"is",
"stale"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/readstats.py#L105-L121 |
223,952 | bcbio/bcbio-nextgen | bcbio/pipeline/region.py | get_max_counts | def get_max_counts(samples):
"""Retrieve number of regions that can be processed in parallel from current samples.
"""
counts = []
for data in (x[0] for x in samples):
count = tz.get_in(["config", "algorithm", "callable_count"], data, 1)
vcs = tz.get_in(["config", "algorithm", "variantca... | python | def get_max_counts(samples):
"""Retrieve number of regions that can be processed in parallel from current samples.
"""
counts = []
for data in (x[0] for x in samples):
count = tz.get_in(["config", "algorithm", "callable_count"], data, 1)
vcs = tz.get_in(["config", "algorithm", "variantca... | [
"def",
"get_max_counts",
"(",
"samples",
")",
":",
"counts",
"=",
"[",
"]",
"for",
"data",
"in",
"(",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"samples",
")",
":",
"count",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
",",
"\"algorithm\"",
",",
... | Retrieve number of regions that can be processed in parallel from current samples. | [
"Retrieve",
"number",
"of",
"regions",
"that",
"can",
"be",
"processed",
"in",
"parallel",
"from",
"current",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L16-L28 |
223,953 | bcbio/bcbio-nextgen | bcbio/pipeline/region.py | _split_by_regions | def _split_by_regions(dirname, out_ext, in_key):
"""Split a BAM file data analysis into chromosomal regions.
"""
def _do_work(data):
# XXX Need to move retrieval of regions into preparation to avoid
# need for files when running in non-shared filesystems
regions = _get_parallel_regio... | python | def _split_by_regions(dirname, out_ext, in_key):
"""Split a BAM file data analysis into chromosomal regions.
"""
def _do_work(data):
# XXX Need to move retrieval of regions into preparation to avoid
# need for files when running in non-shared filesystems
regions = _get_parallel_regio... | [
"def",
"_split_by_regions",
"(",
"dirname",
",",
"out_ext",
",",
"in_key",
")",
":",
"def",
"_do_work",
"(",
"data",
")",
":",
"# XXX Need to move retrieval of regions into preparation to avoid",
"# need for files when running in non-shared filesystems",
"regions",
"=",
"_get... | Split a BAM file data analysis into chromosomal regions. | [
"Split",
"a",
"BAM",
"file",
"data",
"analysis",
"into",
"chromosomal",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L40-L65 |
223,954 | bcbio/bcbio-nextgen | bcbio/pipeline/region.py | _get_parallel_regions | def _get_parallel_regions(data):
"""Retrieve regions to run in parallel, putting longest intervals first.
"""
callable_regions = tz.get_in(["config", "algorithm", "callable_regions"], data)
if not callable_regions:
raise ValueError("Did not find any callable regions for sample: %s\n"
... | python | def _get_parallel_regions(data):
"""Retrieve regions to run in parallel, putting longest intervals first.
"""
callable_regions = tz.get_in(["config", "algorithm", "callable_regions"], data)
if not callable_regions:
raise ValueError("Did not find any callable regions for sample: %s\n"
... | [
"def",
"_get_parallel_regions",
"(",
"data",
")",
":",
"callable_regions",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
",",
"\"algorithm\"",
",",
"\"callable_regions\"",
"]",
",",
"data",
")",
"if",
"not",
"callable_regions",
":",
"raise",
"ValueError",
... | Retrieve regions to run in parallel, putting longest intervals first. | [
"Retrieve",
"regions",
"to",
"run",
"in",
"parallel",
"putting",
"longest",
"intervals",
"first",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L67-L79 |
223,955 | bcbio/bcbio-nextgen | bcbio/pipeline/region.py | get_parallel_regions | def get_parallel_regions(batch):
"""CWL target to retrieve a list of callable regions for parallelization.
"""
samples = [utils.to_single_data(d) for d in batch]
regions = _get_parallel_regions(samples[0])
return [{"region": "%s:%s-%s" % (c, s, e)} for c, s, e in regions] | python | def get_parallel_regions(batch):
"""CWL target to retrieve a list of callable regions for parallelization.
"""
samples = [utils.to_single_data(d) for d in batch]
regions = _get_parallel_regions(samples[0])
return [{"region": "%s:%s-%s" % (c, s, e)} for c, s, e in regions] | [
"def",
"get_parallel_regions",
"(",
"batch",
")",
":",
"samples",
"=",
"[",
"utils",
".",
"to_single_data",
"(",
"d",
")",
"for",
"d",
"in",
"batch",
"]",
"regions",
"=",
"_get_parallel_regions",
"(",
"samples",
"[",
"0",
"]",
")",
"return",
"[",
"{",
... | CWL target to retrieve a list of callable regions for parallelization. | [
"CWL",
"target",
"to",
"retrieve",
"a",
"list",
"of",
"callable",
"regions",
"for",
"parallelization",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L81-L86 |
223,956 | bcbio/bcbio-nextgen | bcbio/pipeline/region.py | get_parallel_regions_block | def get_parallel_regions_block(batch):
"""CWL target to retrieve block group of callable regions for parallelization.
Uses blocking to handle multicore runs.
"""
samples = [utils.to_single_data(d) for d in batch]
regions = _get_parallel_regions(samples[0])
out = []
# Currently don't have co... | python | def get_parallel_regions_block(batch):
"""CWL target to retrieve block group of callable regions for parallelization.
Uses blocking to handle multicore runs.
"""
samples = [utils.to_single_data(d) for d in batch]
regions = _get_parallel_regions(samples[0])
out = []
# Currently don't have co... | [
"def",
"get_parallel_regions_block",
"(",
"batch",
")",
":",
"samples",
"=",
"[",
"utils",
".",
"to_single_data",
"(",
"d",
")",
"for",
"d",
"in",
"batch",
"]",
"regions",
"=",
"_get_parallel_regions",
"(",
"samples",
"[",
"0",
"]",
")",
"out",
"=",
"[",... | CWL target to retrieve block group of callable regions for parallelization.
Uses blocking to handle multicore runs. | [
"CWL",
"target",
"to",
"retrieve",
"block",
"group",
"of",
"callable",
"regions",
"for",
"parallelization",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L88-L100 |
223,957 | bcbio/bcbio-nextgen | bcbio/pipeline/region.py | _add_combine_info | def _add_combine_info(output, combine_map, file_key):
"""Do not actually combine, but add details for later combining work.
Each sample will contain information on the out file and additional files
to merge, enabling other splits and recombines without losing information.
"""
files_per_output = col... | python | def _add_combine_info(output, combine_map, file_key):
"""Do not actually combine, but add details for later combining work.
Each sample will contain information on the out file and additional files
to merge, enabling other splits and recombines without losing information.
"""
files_per_output = col... | [
"def",
"_add_combine_info",
"(",
"output",
",",
"combine_map",
",",
"file_key",
")",
":",
"files_per_output",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"part_file",
",",
"out_file",
"in",
"combine_map",
".",
"items",
"(",
")",
":",
"fi... | Do not actually combine, but add details for later combining work.
Each sample will contain information on the out file and additional files
to merge, enabling other splits and recombines without losing information. | [
"Do",
"not",
"actually",
"combine",
"but",
"add",
"details",
"for",
"later",
"combining",
"work",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L102-L141 |
223,958 | bcbio/bcbio-nextgen | bcbio/pipeline/region.py | parallel_prep_region | def parallel_prep_region(samples, run_parallel):
"""Perform full pre-variant calling BAM prep work on regions.
"""
file_key = "work_bam"
split_fn = _split_by_regions("bamprep", "-prep.bam", file_key)
# identify samples that do not need preparation -- no recalibration or realignment
extras = []
... | python | def parallel_prep_region(samples, run_parallel):
"""Perform full pre-variant calling BAM prep work on regions.
"""
file_key = "work_bam"
split_fn = _split_by_regions("bamprep", "-prep.bam", file_key)
# identify samples that do not need preparation -- no recalibration or realignment
extras = []
... | [
"def",
"parallel_prep_region",
"(",
"samples",
",",
"run_parallel",
")",
":",
"file_key",
"=",
"\"work_bam\"",
"split_fn",
"=",
"_split_by_regions",
"(",
"\"bamprep\"",
",",
"\"-prep.bam\"",
",",
"file_key",
")",
"# identify samples that do not need preparation -- no recali... | Perform full pre-variant calling BAM prep work on regions. | [
"Perform",
"full",
"pre",
"-",
"variant",
"calling",
"BAM",
"prep",
"work",
"on",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L143-L164 |
223,959 | bcbio/bcbio-nextgen | bcbio/pipeline/region.py | delayed_bamprep_merge | def delayed_bamprep_merge(samples, run_parallel):
"""Perform a delayed merge on regional prepared BAM files.
"""
if any("combine" in data[0] for data in samples):
return run_parallel("delayed_bam_merge", samples)
else:
return samples | python | def delayed_bamprep_merge(samples, run_parallel):
"""Perform a delayed merge on regional prepared BAM files.
"""
if any("combine" in data[0] for data in samples):
return run_parallel("delayed_bam_merge", samples)
else:
return samples | [
"def",
"delayed_bamprep_merge",
"(",
"samples",
",",
"run_parallel",
")",
":",
"if",
"any",
"(",
"\"combine\"",
"in",
"data",
"[",
"0",
"]",
"for",
"data",
"in",
"samples",
")",
":",
"return",
"run_parallel",
"(",
"\"delayed_bam_merge\"",
",",
"samples",
")"... | Perform a delayed merge on regional prepared BAM files. | [
"Perform",
"a",
"delayed",
"merge",
"on",
"regional",
"prepared",
"BAM",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L166-L172 |
223,960 | bcbio/bcbio-nextgen | bcbio/pipeline/region.py | clean_sample_data | def clean_sample_data(samples):
"""Clean unnecessary information from sample data, reducing size for message passing.
"""
out = []
for data in (utils.to_single_data(x) for x in samples):
if "dirs" in data:
data["dirs"] = {"work": data["dirs"]["work"], "galaxy": data["dirs"]["galaxy"]... | python | def clean_sample_data(samples):
"""Clean unnecessary information from sample data, reducing size for message passing.
"""
out = []
for data in (utils.to_single_data(x) for x in samples):
if "dirs" in data:
data["dirs"] = {"work": data["dirs"]["work"], "galaxy": data["dirs"]["galaxy"]... | [
"def",
"clean_sample_data",
"(",
"samples",
")",
":",
"out",
"=",
"[",
"]",
"for",
"data",
"in",
"(",
"utils",
".",
"to_single_data",
"(",
"x",
")",
"for",
"x",
"in",
"samples",
")",
":",
"if",
"\"dirs\"",
"in",
"data",
":",
"data",
"[",
"\"dirs\"",
... | Clean unnecessary information from sample data, reducing size for message passing. | [
"Clean",
"unnecessary",
"information",
"from",
"sample",
"data",
"reducing",
"size",
"for",
"message",
"passing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L176-L189 |
223,961 | bcbio/bcbio-nextgen | bcbio/ngsalign/star.py | _add_sj_index_commands | def _add_sj_index_commands(fq1, ref_file, gtf_file):
"""
newer versions of STAR can generate splice junction databases on thephfly
this is preferable since we can tailor it to the read lengths
"""
if _has_sj_index(ref_file):
return ""
else:
rlength = fastq.estimate_maximum_read_l... | python | def _add_sj_index_commands(fq1, ref_file, gtf_file):
"""
newer versions of STAR can generate splice junction databases on thephfly
this is preferable since we can tailor it to the read lengths
"""
if _has_sj_index(ref_file):
return ""
else:
rlength = fastq.estimate_maximum_read_l... | [
"def",
"_add_sj_index_commands",
"(",
"fq1",
",",
"ref_file",
",",
"gtf_file",
")",
":",
"if",
"_has_sj_index",
"(",
"ref_file",
")",
":",
"return",
"\"\"",
"else",
":",
"rlength",
"=",
"fastq",
".",
"estimate_maximum_read_length",
"(",
"fq1",
")",
"cmd",
"=... | newer versions of STAR can generate splice junction databases on thephfly
this is preferable since we can tailor it to the read lengths | [
"newer",
"versions",
"of",
"STAR",
"can",
"generate",
"splice",
"junction",
"databases",
"on",
"thephfly",
"this",
"is",
"preferable",
"since",
"we",
"can",
"tailor",
"it",
"to",
"the",
"read",
"lengths"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L119-L130 |
223,962 | bcbio/bcbio-nextgen | bcbio/ngsalign/star.py | _has_sj_index | def _has_sj_index(ref_file):
"""this file won't exist if we can do on the fly splice junction indexing"""
return (file_exists(os.path.join(ref_file, "sjdbInfo.txt")) and
(file_exists(os.path.join(ref_file, "transcriptInfo.tab")))) | python | def _has_sj_index(ref_file):
"""this file won't exist if we can do on the fly splice junction indexing"""
return (file_exists(os.path.join(ref_file, "sjdbInfo.txt")) and
(file_exists(os.path.join(ref_file, "transcriptInfo.tab")))) | [
"def",
"_has_sj_index",
"(",
"ref_file",
")",
":",
"return",
"(",
"file_exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"ref_file",
",",
"\"sjdbInfo.txt\"",
")",
")",
"and",
"(",
"file_exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"ref_file",
"... | this file won't exist if we can do on the fly splice junction indexing | [
"this",
"file",
"won",
"t",
"exist",
"if",
"we",
"can",
"do",
"on",
"the",
"fly",
"splice",
"junction",
"indexing"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L132-L135 |
223,963 | bcbio/bcbio-nextgen | bcbio/ngsalign/star.py | remap_index_fn | def remap_index_fn(ref_file):
"""Map sequence references to equivalent star indexes
"""
return os.path.join(os.path.dirname(os.path.dirname(ref_file)), "star") | python | def remap_index_fn(ref_file):
"""Map sequence references to equivalent star indexes
"""
return os.path.join(os.path.dirname(os.path.dirname(ref_file)), "star") | [
"def",
"remap_index_fn",
"(",
"ref_file",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"ref_file",
")",
")",
",",
"\"star\"",
")"
] | Map sequence references to equivalent star indexes | [
"Map",
"sequence",
"references",
"to",
"equivalent",
"star",
"indexes"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L171-L174 |
223,964 | bcbio/bcbio-nextgen | bcbio/ngsalign/star.py | index | def index(ref_file, out_dir, data):
"""Create a STAR index in the defined reference directory.
"""
(ref_dir, local_file) = os.path.split(ref_file)
gtf_file = dd.get_gtf_file(data)
if not utils.file_exists(gtf_file):
raise ValueError("%s not found, could not create a star index." % (gtf_file)... | python | def index(ref_file, out_dir, data):
"""Create a STAR index in the defined reference directory.
"""
(ref_dir, local_file) = os.path.split(ref_file)
gtf_file = dd.get_gtf_file(data)
if not utils.file_exists(gtf_file):
raise ValueError("%s not found, could not create a star index." % (gtf_file)... | [
"def",
"index",
"(",
"ref_file",
",",
"out_dir",
",",
"data",
")",
":",
"(",
"ref_dir",
",",
"local_file",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"ref_file",
")",
"gtf_file",
"=",
"dd",
".",
"get_gtf_file",
"(",
"data",
")",
"if",
"not",
"... | Create a STAR index in the defined reference directory. | [
"Create",
"a",
"STAR",
"index",
"in",
"the",
"defined",
"reference",
"directory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L176-L193 |
223,965 | bcbio/bcbio-nextgen | bcbio/ngsalign/star.py | get_splicejunction_file | def get_splicejunction_file(out_dir, data):
"""
locate the splicejunction file starting from the alignment directory
"""
samplename = dd.get_sample_name(data)
sjfile = os.path.join(out_dir, os.pardir, "{0}SJ.out.tab").format(samplename)
if file_exists(sjfile):
return sjfile
else:
... | python | def get_splicejunction_file(out_dir, data):
"""
locate the splicejunction file starting from the alignment directory
"""
samplename = dd.get_sample_name(data)
sjfile = os.path.join(out_dir, os.pardir, "{0}SJ.out.tab").format(samplename)
if file_exists(sjfile):
return sjfile
else:
... | [
"def",
"get_splicejunction_file",
"(",
"out_dir",
",",
"data",
")",
":",
"samplename",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"sjfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"os",
".",
"pardir",
",",
"\"{0}SJ.out.tab\"",
... | locate the splicejunction file starting from the alignment directory | [
"locate",
"the",
"splicejunction",
"file",
"starting",
"from",
"the",
"alignment",
"directory"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L207-L216 |
223,966 | bcbio/bcbio-nextgen | bcbio/ngsalign/star.py | junction2bed | def junction2bed(junction_file):
"""
reformat the STAR junction file to BED3 format, one end of the splice junction per line
"""
base, _ = os.path.splitext(junction_file)
out_file = base + "-minimized.bed"
if file_exists(out_file):
return out_file
if not file_exists(junction_file):
... | python | def junction2bed(junction_file):
"""
reformat the STAR junction file to BED3 format, one end of the splice junction per line
"""
base, _ = os.path.splitext(junction_file)
out_file = base + "-minimized.bed"
if file_exists(out_file):
return out_file
if not file_exists(junction_file):
... | [
"def",
"junction2bed",
"(",
"junction_file",
")",
":",
"base",
",",
"_",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"junction_file",
")",
"out_file",
"=",
"base",
"+",
"\"-minimized.bed\"",
"if",
"file_exists",
"(",
"out_file",
")",
":",
"return",
"out_... | reformat the STAR junction file to BED3 format, one end of the splice junction per line | [
"reformat",
"the",
"STAR",
"junction",
"file",
"to",
"BED3",
"format",
"one",
"end",
"of",
"the",
"splice",
"junction",
"per",
"line"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L218-L242 |
223,967 | bcbio/bcbio-nextgen | bcbio/hla/optitype.py | run | def run(data):
"""HLA typing with OptiType, parsing output from called genotype files.
"""
hlas = []
for hla_fq in tz.get_in(["hla", "fastq"], data, []):
hla_type = re.search("[.-](?P<hlatype>HLA-[\w-]+).fq", hla_fq).group("hlatype")
if hla_type in SUPPORTED_HLAS:
if utils.fi... | python | def run(data):
"""HLA typing with OptiType, parsing output from called genotype files.
"""
hlas = []
for hla_fq in tz.get_in(["hla", "fastq"], data, []):
hla_type = re.search("[.-](?P<hlatype>HLA-[\w-]+).fq", hla_fq).group("hlatype")
if hla_type in SUPPORTED_HLAS:
if utils.fi... | [
"def",
"run",
"(",
"data",
")",
":",
"hlas",
"=",
"[",
"]",
"for",
"hla_fq",
"in",
"tz",
".",
"get_in",
"(",
"[",
"\"hla\"",
",",
"\"fastq\"",
"]",
",",
"data",
",",
"[",
"]",
")",
":",
"hla_type",
"=",
"re",
".",
"search",
"(",
"\"[.-](?P<hlatyp... | HLA typing with OptiType, parsing output from called genotype files. | [
"HLA",
"typing",
"with",
"OptiType",
"parsing",
"output",
"from",
"called",
"genotype",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/optitype.py#L23-L50 |
223,968 | bcbio/bcbio-nextgen | bcbio/hla/optitype.py | combine_hla_fqs | def combine_hla_fqs(hlas, out_file, data):
"""OptiType performs best on a combination of all extracted HLAs.
"""
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
with open(tx_out_file, "w") as out_handle:
for hla_type, hla_fq in hl... | python | def combine_hla_fqs(hlas, out_file, data):
"""OptiType performs best on a combination of all extracted HLAs.
"""
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
with open(tx_out_file, "w") as out_handle:
for hla_type, hla_fq in hl... | [
"def",
"combine_hla_fqs",
"(",
"hlas",
",",
"out_file",
",",
"data",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"data",
",",
"out_file",
")",
"as",
"tx_out_file",
":",
"with",
"open",
"... | OptiType performs best on a combination of all extracted HLAs. | [
"OptiType",
"performs",
"best",
"on",
"a",
"combination",
"of",
"all",
"extracted",
"HLAs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/optitype.py#L52-L62 |
223,969 | bcbio/bcbio-nextgen | bcbio/hla/optitype.py | _prepare_calls | def _prepare_calls(result_file, out_dir, data):
"""Write summary file of results of HLA typing by allele.
"""
sample = dd.get_sample_name(data)
out_file = os.path.join(out_dir, "%s-optitype.csv" % (sample))
if not utils.file_uptodate(out_file, result_file):
hla_truth = bwakit.get_hla_truthse... | python | def _prepare_calls(result_file, out_dir, data):
"""Write summary file of results of HLA typing by allele.
"""
sample = dd.get_sample_name(data)
out_file = os.path.join(out_dir, "%s-optitype.csv" % (sample))
if not utils.file_uptodate(out_file, result_file):
hla_truth = bwakit.get_hla_truthse... | [
"def",
"_prepare_calls",
"(",
"result_file",
",",
"out_dir",
",",
"data",
")",
":",
"sample",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"\"%s-optitype.csv\"",
"%",
"(",
"sam... | Write summary file of results of HLA typing by allele. | [
"Write",
"summary",
"file",
"of",
"results",
"of",
"HLA",
"typing",
"by",
"allele",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/optitype.py#L64-L88 |
223,970 | bcbio/bcbio-nextgen | bcbio/hla/optitype.py | _call_hla | def _call_hla(hla_fq, out_dir, data):
"""Run OptiType HLA calling for a specific fastq input.
"""
bin_dir = os.path.dirname(os.path.realpath(sys.executable))
out_dir = utils.safe_makedir(out_dir)
with tx_tmpdir(data, os.path.dirname(out_dir)) as tx_out_dir:
config_file = os.path.join(tx_out_... | python | def _call_hla(hla_fq, out_dir, data):
"""Run OptiType HLA calling for a specific fastq input.
"""
bin_dir = os.path.dirname(os.path.realpath(sys.executable))
out_dir = utils.safe_makedir(out_dir)
with tx_tmpdir(data, os.path.dirname(out_dir)) as tx_out_dir:
config_file = os.path.join(tx_out_... | [
"def",
"_call_hla",
"(",
"hla_fq",
",",
"out_dir",
",",
"data",
")",
":",
"bin_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"sys",
".",
"executable",
")",
")",
"out_dir",
"=",
"utils",
".",
"safe_makedir... | Run OptiType HLA calling for a specific fastq input. | [
"Run",
"OptiType",
"HLA",
"calling",
"for",
"a",
"specific",
"fastq",
"input",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/optitype.py#L108-L132 |
223,971 | bcbio/bcbio-nextgen | bcbio/heterogeneity/chromhacks.py | is_autosomal | def is_autosomal(chrom):
"""Keep chromosomes that are a digit 1-22, or chr prefixed digit chr1-chr22
"""
try:
int(chrom)
return True
except ValueError:
try:
int(str(chrom.lower().replace("chr", "").replace("_", "").replace("-", "")))
return True
ex... | python | def is_autosomal(chrom):
"""Keep chromosomes that are a digit 1-22, or chr prefixed digit chr1-chr22
"""
try:
int(chrom)
return True
except ValueError:
try:
int(str(chrom.lower().replace("chr", "").replace("_", "").replace("-", "")))
return True
ex... | [
"def",
"is_autosomal",
"(",
"chrom",
")",
":",
"try",
":",
"int",
"(",
"chrom",
")",
"return",
"True",
"except",
"ValueError",
":",
"try",
":",
"int",
"(",
"str",
"(",
"chrom",
".",
"lower",
"(",
")",
".",
"replace",
"(",
"\"chr\"",
",",
"\"\"",
")... | Keep chromosomes that are a digit 1-22, or chr prefixed digit chr1-chr22 | [
"Keep",
"chromosomes",
"that",
"are",
"a",
"digit",
"1",
"-",
"22",
"or",
"chr",
"prefixed",
"digit",
"chr1",
"-",
"chr22"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/chromhacks.py#L11-L22 |
223,972 | bcbio/bcbio-nextgen | bcbio/qc/variant.py | _bcftools_stats | def _bcftools_stats(data, out_dir, vcf_file_key=None, germline=False):
"""Run bcftools stats.
"""
vcinfo = get_active_vcinfo(data)
if vcinfo:
out_dir = utils.safe_makedir(out_dir)
vcf_file = vcinfo[vcf_file_key or "vrn_file"]
if dd.get_jointcaller(data) or "gvcf" in dd.get_tools_... | python | def _bcftools_stats(data, out_dir, vcf_file_key=None, germline=False):
"""Run bcftools stats.
"""
vcinfo = get_active_vcinfo(data)
if vcinfo:
out_dir = utils.safe_makedir(out_dir)
vcf_file = vcinfo[vcf_file_key or "vrn_file"]
if dd.get_jointcaller(data) or "gvcf" in dd.get_tools_... | [
"def",
"_bcftools_stats",
"(",
"data",
",",
"out_dir",
",",
"vcf_file_key",
"=",
"None",
",",
"germline",
"=",
"False",
")",
":",
"vcinfo",
"=",
"get_active_vcinfo",
"(",
"data",
")",
"if",
"vcinfo",
":",
"out_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
... | Run bcftools stats. | [
"Run",
"bcftools",
"stats",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L50-L77 |
223,973 | bcbio/bcbio-nextgen | bcbio/qc/variant.py | _add_filename_details | def _add_filename_details(full_f):
"""Add variant callers and germline information standard CWL filenames.
This is an ugly way of working around not having metadata with calls.
"""
out = {"vrn_file": full_f}
f = os.path.basename(full_f)
for vc in list(genotype.get_variantcallers().keys()) + ["e... | python | def _add_filename_details(full_f):
"""Add variant callers and germline information standard CWL filenames.
This is an ugly way of working around not having metadata with calls.
"""
out = {"vrn_file": full_f}
f = os.path.basename(full_f)
for vc in list(genotype.get_variantcallers().keys()) + ["e... | [
"def",
"_add_filename_details",
"(",
"full_f",
")",
":",
"out",
"=",
"{",
"\"vrn_file\"",
":",
"full_f",
"}",
"f",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"full_f",
")",
"for",
"vc",
"in",
"list",
"(",
"genotype",
".",
"get_variantcallers",
"(",
... | Add variant callers and germline information standard CWL filenames.
This is an ugly way of working around not having metadata with calls. | [
"Add",
"variant",
"callers",
"and",
"germline",
"information",
"standard",
"CWL",
"filenames",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L79-L91 |
223,974 | bcbio/bcbio-nextgen | bcbio/qc/variant.py | _get_variants | def _get_variants(data):
"""Retrieve variants from CWL and standard inputs for organizing variants.
"""
active_vs = []
if "variants" in data:
variants = data["variants"]
# CWL based list of variants
if isinstance(variants, dict) and "samples" in variants:
variants = v... | python | def _get_variants(data):
"""Retrieve variants from CWL and standard inputs for organizing variants.
"""
active_vs = []
if "variants" in data:
variants = data["variants"]
# CWL based list of variants
if isinstance(variants, dict) and "samples" in variants:
variants = v... | [
"def",
"_get_variants",
"(",
"data",
")",
":",
"active_vs",
"=",
"[",
"]",
"if",
"\"variants\"",
"in",
"data",
":",
"variants",
"=",
"data",
"[",
"\"variants\"",
"]",
"# CWL based list of variants",
"if",
"isinstance",
"(",
"variants",
",",
"dict",
")",
"and... | Retrieve variants from CWL and standard inputs for organizing variants. | [
"Retrieve",
"variants",
"from",
"CWL",
"and",
"standard",
"inputs",
"for",
"organizing",
"variants",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L93-L118 |
223,975 | bcbio/bcbio-nextgen | bcbio/qc/variant.py | get_active_vcinfo | def get_active_vcinfo(data, use_ensemble=True):
"""Use first caller if ensemble is not active
"""
active_vs = _get_variants(data)
if len(active_vs) > 0:
e_active_vs = []
if use_ensemble:
e_active_vs = [v for v in active_vs if v.get("variantcaller") == "ensemble"]
if l... | python | def get_active_vcinfo(data, use_ensemble=True):
"""Use first caller if ensemble is not active
"""
active_vs = _get_variants(data)
if len(active_vs) > 0:
e_active_vs = []
if use_ensemble:
e_active_vs = [v for v in active_vs if v.get("variantcaller") == "ensemble"]
if l... | [
"def",
"get_active_vcinfo",
"(",
"data",
",",
"use_ensemble",
"=",
"True",
")",
":",
"active_vs",
"=",
"_get_variants",
"(",
"data",
")",
"if",
"len",
"(",
"active_vs",
")",
">",
"0",
":",
"e_active_vs",
"=",
"[",
"]",
"if",
"use_ensemble",
":",
"e_activ... | Use first caller if ensemble is not active | [
"Use",
"first",
"caller",
"if",
"ensemble",
"is",
"not",
"active"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L120-L131 |
223,976 | bcbio/bcbio-nextgen | bcbio/qc/variant.py | extract_germline_vcinfo | def extract_germline_vcinfo(data, out_dir):
"""Extract germline VCFs from existing tumor inputs.
"""
supported_germline = set(["vardict", "octopus", "freebayes"])
if dd.get_phenotype(data) in ["tumor"]:
for v in _get_variants(data):
if v.get("variantcaller") in supported_germline:
... | python | def extract_germline_vcinfo(data, out_dir):
"""Extract germline VCFs from existing tumor inputs.
"""
supported_germline = set(["vardict", "octopus", "freebayes"])
if dd.get_phenotype(data) in ["tumor"]:
for v in _get_variants(data):
if v.get("variantcaller") in supported_germline:
... | [
"def",
"extract_germline_vcinfo",
"(",
"data",
",",
"out_dir",
")",
":",
"supported_germline",
"=",
"set",
"(",
"[",
"\"vardict\"",
",",
"\"octopus\"",
",",
"\"freebayes\"",
"]",
")",
"if",
"dd",
".",
"get_phenotype",
"(",
"data",
")",
"in",
"[",
"\"tumor\""... | Extract germline VCFs from existing tumor inputs. | [
"Extract",
"germline",
"VCFs",
"from",
"existing",
"tumor",
"inputs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L133-L147 |
223,977 | bcbio/bcbio-nextgen | bcbio/pipeline/merge.py | merge_bam_files | def merge_bam_files(bam_files, work_dir, data, out_file=None, batch=None):
"""Merge multiple BAM files from a sample into a single BAM for processing.
Checks system open file limit and merges in batches if necessary to avoid
file handle limits.
"""
out_file = _merge_outfile_fname(out_file, bam_file... | python | def merge_bam_files(bam_files, work_dir, data, out_file=None, batch=None):
"""Merge multiple BAM files from a sample into a single BAM for processing.
Checks system open file limit and merges in batches if necessary to avoid
file handle limits.
"""
out_file = _merge_outfile_fname(out_file, bam_file... | [
"def",
"merge_bam_files",
"(",
"bam_files",
",",
"work_dir",
",",
"data",
",",
"out_file",
"=",
"None",
",",
"batch",
"=",
"None",
")",
":",
"out_file",
"=",
"_merge_outfile_fname",
"(",
"out_file",
",",
"bam_files",
",",
"work_dir",
",",
"batch",
")",
"if... | Merge multiple BAM files from a sample into a single BAM for processing.
Checks system open file limit and merges in batches if necessary to avoid
file handle limits. | [
"Merge",
"multiple",
"BAM",
"files",
"from",
"a",
"sample",
"into",
"a",
"single",
"BAM",
"for",
"processing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/merge.py#L39-L79 |
223,978 | bcbio/bcbio-nextgen | bcbio/pipeline/merge.py | _create_merge_filelist | def _create_merge_filelist(bam_files, base_file, config):
"""Create list of input files for merge, ensuring all files are valid.
"""
bam_file_list = "%s.list" % os.path.splitext(base_file)[0]
samtools = config_utils.get_program("samtools", config)
with open(bam_file_list, "w") as out_handle:
... | python | def _create_merge_filelist(bam_files, base_file, config):
"""Create list of input files for merge, ensuring all files are valid.
"""
bam_file_list = "%s.list" % os.path.splitext(base_file)[0]
samtools = config_utils.get_program("samtools", config)
with open(bam_file_list, "w") as out_handle:
... | [
"def",
"_create_merge_filelist",
"(",
"bam_files",
",",
"base_file",
",",
"config",
")",
":",
"bam_file_list",
"=",
"\"%s.list\"",
"%",
"os",
".",
"path",
".",
"splitext",
"(",
"base_file",
")",
"[",
"0",
"]",
"samtools",
"=",
"config_utils",
".",
"get_progr... | Create list of input files for merge, ensuring all files are valid. | [
"Create",
"list",
"of",
"input",
"files",
"for",
"merge",
"ensuring",
"all",
"files",
"are",
"valid",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/merge.py#L81-L91 |
223,979 | bcbio/bcbio-nextgen | bcbio/pipeline/merge.py | _merge_outfile_fname | def _merge_outfile_fname(out_file, bam_files, work_dir, batch):
"""Derive correct name of BAM file based on batching.
"""
if out_file is None:
out_file = os.path.join(work_dir, os.path.basename(sorted(bam_files)[0]))
if batch is not None:
base, ext = os.path.splitext(out_file)
ou... | python | def _merge_outfile_fname(out_file, bam_files, work_dir, batch):
"""Derive correct name of BAM file based on batching.
"""
if out_file is None:
out_file = os.path.join(work_dir, os.path.basename(sorted(bam_files)[0]))
if batch is not None:
base, ext = os.path.splitext(out_file)
ou... | [
"def",
"_merge_outfile_fname",
"(",
"out_file",
",",
"bam_files",
",",
"work_dir",
",",
"batch",
")",
":",
"if",
"out_file",
"is",
"None",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"os",
".",
"path",
".",
"basename",
"... | Derive correct name of BAM file based on batching. | [
"Derive",
"correct",
"name",
"of",
"BAM",
"file",
"based",
"on",
"batching",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/merge.py#L93-L101 |
223,980 | bcbio/bcbio-nextgen | bcbio/pipeline/merge.py | _finalize_merge | def _finalize_merge(out_file, bam_files, config):
"""Handle indexes and cleanups of merged BAM and input files.
"""
# Ensure timestamps are up to date on output file and index
# Works around issues on systems with inconsistent times
for ext in ["", ".bai"]:
if os.path.exists(out_file + ext):... | python | def _finalize_merge(out_file, bam_files, config):
"""Handle indexes and cleanups of merged BAM and input files.
"""
# Ensure timestamps are up to date on output file and index
# Works around issues on systems with inconsistent times
for ext in ["", ".bai"]:
if os.path.exists(out_file + ext):... | [
"def",
"_finalize_merge",
"(",
"out_file",
",",
"bam_files",
",",
"config",
")",
":",
"# Ensure timestamps are up to date on output file and index",
"# Works around issues on systems with inconsistent times",
"for",
"ext",
"in",
"[",
"\"\"",
",",
"\".bai\"",
"]",
":",
"if",... | Handle indexes and cleanups of merged BAM and input files. | [
"Handle",
"indexes",
"and",
"cleanups",
"of",
"merged",
"BAM",
"and",
"input",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/merge.py#L103-L112 |
223,981 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _cwl_workflow_template | def _cwl_workflow_template(inputs, top_level=False):
"""Retrieve CWL inputs shared amongst different workflows.
"""
ready_inputs = []
for inp in inputs:
cur_inp = copy.deepcopy(inp)
for attr in ["source", "valueFrom", "wf_duplicate"]:
cur_inp.pop(attr, None)
if top_le... | python | def _cwl_workflow_template(inputs, top_level=False):
"""Retrieve CWL inputs shared amongst different workflows.
"""
ready_inputs = []
for inp in inputs:
cur_inp = copy.deepcopy(inp)
for attr in ["source", "valueFrom", "wf_duplicate"]:
cur_inp.pop(attr, None)
if top_le... | [
"def",
"_cwl_workflow_template",
"(",
"inputs",
",",
"top_level",
"=",
"False",
")",
":",
"ready_inputs",
"=",
"[",
"]",
"for",
"inp",
"in",
"inputs",
":",
"cur_inp",
"=",
"copy",
".",
"deepcopy",
"(",
"inp",
")",
"for",
"attr",
"in",
"[",
"\"source\"",
... | Retrieve CWL inputs shared amongst different workflows. | [
"Retrieve",
"CWL",
"inputs",
"shared",
"amongst",
"different",
"workflows",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L42-L63 |
223,982 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _get_disk_estimates | def _get_disk_estimates(name, parallel, inputs, file_estimates, samples, disk,
cur_remotes, no_files):
"""Retrieve disk usage estimates as CWL ResourceRequirement and hint.
Disk specification for temporary files and outputs.
Also optionally includes disk input estimates as a custom... | python | def _get_disk_estimates(name, parallel, inputs, file_estimates, samples, disk,
cur_remotes, no_files):
"""Retrieve disk usage estimates as CWL ResourceRequirement and hint.
Disk specification for temporary files and outputs.
Also optionally includes disk input estimates as a custom... | [
"def",
"_get_disk_estimates",
"(",
"name",
",",
"parallel",
",",
"inputs",
",",
"file_estimates",
",",
"samples",
",",
"disk",
",",
"cur_remotes",
",",
"no_files",
")",
":",
"tmp_disk",
",",
"out_disk",
",",
"in_disk",
"=",
"0",
",",
"0",
",",
"0",
"if",... | Retrieve disk usage estimates as CWL ResourceRequirement and hint.
Disk specification for temporary files and outputs.
Also optionally includes disk input estimates as a custom hint for
platforms which need to stage these and don't pre-estimate these when
allocating machine sizes. | [
"Retrieve",
"disk",
"usage",
"estimates",
"as",
"CWL",
"ResourceRequirement",
"and",
"hint",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L65-L107 |
223,983 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _add_current_quay_tag | def _add_current_quay_tag(repo, container_tags):
"""Lookup the current quay tag for the repository, adding to repo string.
Enables generation of CWL explicitly tied to revisions.
"""
if ':' in repo:
return repo, container_tags
try:
latest_tag = container_tags[repo]
except KeyErr... | python | def _add_current_quay_tag(repo, container_tags):
"""Lookup the current quay tag for the repository, adding to repo string.
Enables generation of CWL explicitly tied to revisions.
"""
if ':' in repo:
return repo, container_tags
try:
latest_tag = container_tags[repo]
except KeyErr... | [
"def",
"_add_current_quay_tag",
"(",
"repo",
",",
"container_tags",
")",
":",
"if",
"':'",
"in",
"repo",
":",
"return",
"repo",
",",
"container_tags",
"try",
":",
"latest_tag",
"=",
"container_tags",
"[",
"repo",
"]",
"except",
"KeyError",
":",
"repo_id",
"=... | Lookup the current quay tag for the repository, adding to repo string.
Enables generation of CWL explicitly tied to revisions. | [
"Lookup",
"the",
"current",
"quay",
"tag",
"for",
"the",
"repository",
"adding",
"to",
"repo",
"string",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L109-L134 |
223,984 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _write_expressiontool | def _write_expressiontool(step_dir, name, inputs, outputs, expression, parallel):
"""Create an ExpressionTool output for the given inputs
"""
out_file = os.path.join(step_dir, "%s.cwl" % name)
out = {"class": "ExpressionTool",
"cwlVersion": "v1.0",
"requirements": [{"class": "Inlin... | python | def _write_expressiontool(step_dir, name, inputs, outputs, expression, parallel):
"""Create an ExpressionTool output for the given inputs
"""
out_file = os.path.join(step_dir, "%s.cwl" % name)
out = {"class": "ExpressionTool",
"cwlVersion": "v1.0",
"requirements": [{"class": "Inlin... | [
"def",
"_write_expressiontool",
"(",
"step_dir",
",",
"name",
",",
"inputs",
",",
"outputs",
",",
"expression",
",",
"parallel",
")",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"step_dir",
",",
"\"%s.cwl\"",
"%",
"name",
")",
"out",
"=",
... | Create an ExpressionTool output for the given inputs | [
"Create",
"an",
"ExpressionTool",
"output",
"for",
"the",
"given",
"inputs"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L208-L221 |
223,985 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _clean_record | def _clean_record(rec):
"""Remove secondary files from record fields, which are currently not supported.
To be removed later when secondaryFiles added to records.
"""
if workflow.is_cwl_record(rec):
def _clean_fields(d):
if isinstance(d, dict):
if "fields" in d:
... | python | def _clean_record(rec):
"""Remove secondary files from record fields, which are currently not supported.
To be removed later when secondaryFiles added to records.
"""
if workflow.is_cwl_record(rec):
def _clean_fields(d):
if isinstance(d, dict):
if "fields" in d:
... | [
"def",
"_clean_record",
"(",
"rec",
")",
":",
"if",
"workflow",
".",
"is_cwl_record",
"(",
"rec",
")",
":",
"def",
"_clean_fields",
"(",
"d",
")",
":",
"if",
"isinstance",
"(",
"d",
",",
"dict",
")",
":",
"if",
"\"fields\"",
"in",
"d",
":",
"out",
... | Remove secondary files from record fields, which are currently not supported.
To be removed later when secondaryFiles added to records. | [
"Remove",
"secondary",
"files",
"from",
"record",
"fields",
"which",
"are",
"currently",
"not",
"supported",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L265-L290 |
223,986 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _get_record_fields | def _get_record_fields(d):
"""Get field names from a potentially nested record.
"""
if isinstance(d, dict):
if "fields" in d:
return d["fields"]
else:
for v in d.values():
fields = _get_record_fields(v)
if fields:
re... | python | def _get_record_fields(d):
"""Get field names from a potentially nested record.
"""
if isinstance(d, dict):
if "fields" in d:
return d["fields"]
else:
for v in d.values():
fields = _get_record_fields(v)
if fields:
re... | [
"def",
"_get_record_fields",
"(",
"d",
")",
":",
"if",
"isinstance",
"(",
"d",
",",
"dict",
")",
":",
"if",
"\"fields\"",
"in",
"d",
":",
"return",
"d",
"[",
"\"fields\"",
"]",
"else",
":",
"for",
"v",
"in",
"d",
".",
"values",
"(",
")",
":",
"fi... | Get field names from a potentially nested record. | [
"Get",
"field",
"names",
"from",
"a",
"potentially",
"nested",
"record",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L292-L302 |
223,987 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _get_sentinel_val | def _get_sentinel_val(v):
"""Retrieve expected sentinel value for an output, expanding records.
"""
out = workflow.get_base_id(v["id"])
if workflow.is_cwl_record(v):
out += ":%s" % ";".join([x["name"] for x in _get_record_fields(v)])
return out | python | def _get_sentinel_val(v):
"""Retrieve expected sentinel value for an output, expanding records.
"""
out = workflow.get_base_id(v["id"])
if workflow.is_cwl_record(v):
out += ":%s" % ";".join([x["name"] for x in _get_record_fields(v)])
return out | [
"def",
"_get_sentinel_val",
"(",
"v",
")",
":",
"out",
"=",
"workflow",
".",
"get_base_id",
"(",
"v",
"[",
"\"id\"",
"]",
")",
"if",
"workflow",
".",
"is_cwl_record",
"(",
"v",
")",
":",
"out",
"+=",
"\":%s\"",
"%",
"\";\"",
".",
"join",
"(",
"[",
... | Retrieve expected sentinel value for an output, expanding records. | [
"Retrieve",
"expected",
"sentinel",
"value",
"for",
"an",
"output",
"expanding",
"records",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L304-L310 |
223,988 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _place_input_binding | def _place_input_binding(inp_tool, inp_binding, parallel):
"""Check nesting of variables to determine where to place the input binding.
We want to allow having multiple files together (like fasta_indices), combined
with the itemSeparator, but also support having multiple samples where we pass
things in... | python | def _place_input_binding(inp_tool, inp_binding, parallel):
"""Check nesting of variables to determine where to place the input binding.
We want to allow having multiple files together (like fasta_indices), combined
with the itemSeparator, but also support having multiple samples where we pass
things in... | [
"def",
"_place_input_binding",
"(",
"inp_tool",
",",
"inp_binding",
",",
"parallel",
")",
":",
"if",
"(",
"parallel",
"in",
"[",
"\"multi-combined\"",
",",
"\"multi-batch\"",
",",
"\"batch-split\"",
",",
"\"batch-parallel\"",
",",
"\"batch-merge\"",
",",
"\"batch-si... | Check nesting of variables to determine where to place the input binding.
We want to allow having multiple files together (like fasta_indices), combined
with the itemSeparator, but also support having multiple samples where we pass
things independently. | [
"Check",
"nesting",
"of",
"variables",
"to",
"determine",
"where",
"to",
"place",
"the",
"input",
"binding",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L312-L325 |
223,989 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _place_secondary_files | def _place_secondary_files(inp_tool, inp_binding=None):
"""Put secondaryFiles at the level of the File item to ensure indexes get passed.
"""
def _is_file(val):
return (val == "File" or (isinstance(val, (list, tuple)) and
("File" in val or any(isinstance(x, dict) an... | python | def _place_secondary_files(inp_tool, inp_binding=None):
"""Put secondaryFiles at the level of the File item to ensure indexes get passed.
"""
def _is_file(val):
return (val == "File" or (isinstance(val, (list, tuple)) and
("File" in val or any(isinstance(x, dict) an... | [
"def",
"_place_secondary_files",
"(",
"inp_tool",
",",
"inp_binding",
"=",
"None",
")",
":",
"def",
"_is_file",
"(",
"val",
")",
":",
"return",
"(",
"val",
"==",
"\"File\"",
"or",
"(",
"isinstance",
"(",
"val",
",",
"(",
"list",
",",
"tuple",
")",
")",... | Put secondaryFiles at the level of the File item to ensure indexes get passed. | [
"Put",
"secondaryFiles",
"at",
"the",
"level",
"of",
"the",
"File",
"item",
"to",
"ensure",
"indexes",
"get",
"passed",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L327-L347 |
223,990 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _do_scatter_var | def _do_scatter_var(v, parallel):
"""Logic for scattering a variable.
"""
# For batches, scatter records only at the top level (double nested)
if parallel.startswith("batch") and workflow.is_cwl_record(v):
return (tz.get_in(["type", "type"], v) == "array" and
tz.get_in(["type", "... | python | def _do_scatter_var(v, parallel):
"""Logic for scattering a variable.
"""
# For batches, scatter records only at the top level (double nested)
if parallel.startswith("batch") and workflow.is_cwl_record(v):
return (tz.get_in(["type", "type"], v) == "array" and
tz.get_in(["type", "... | [
"def",
"_do_scatter_var",
"(",
"v",
",",
"parallel",
")",
":",
"# For batches, scatter records only at the top level (double nested)",
"if",
"parallel",
".",
"startswith",
"(",
"\"batch\"",
")",
"and",
"workflow",
".",
"is_cwl_record",
"(",
"v",
")",
":",
"return",
... | Logic for scattering a variable. | [
"Logic",
"for",
"scattering",
"a",
"variable",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L352-L361 |
223,991 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _step_template | def _step_template(name, run_file, inputs, outputs, parallel, step_parallelism, scatter=None):
"""Templating function for writing a step to avoid repeating namespaces.
"""
scatter_inputs = []
sinputs = []
for inp in inputs:
step_inp = {"id": workflow.get_base_id(inp["id"]), "source": inp["id... | python | def _step_template(name, run_file, inputs, outputs, parallel, step_parallelism, scatter=None):
"""Templating function for writing a step to avoid repeating namespaces.
"""
scatter_inputs = []
sinputs = []
for inp in inputs:
step_inp = {"id": workflow.get_base_id(inp["id"]), "source": inp["id... | [
"def",
"_step_template",
"(",
"name",
",",
"run_file",
",",
"inputs",
",",
"outputs",
",",
"parallel",
",",
"step_parallelism",
",",
"scatter",
"=",
"None",
")",
":",
"scatter_inputs",
"=",
"[",
"]",
"sinputs",
"=",
"[",
"]",
"for",
"inp",
"in",
"inputs"... | Templating function for writing a step to avoid repeating namespaces. | [
"Templating",
"function",
"for",
"writing",
"a",
"step",
"to",
"avoid",
"repeating",
"namespaces",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L363-L393 |
223,992 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _get_cur_remotes | def _get_cur_remotes(path):
"""Retrieve remote references defined in the CWL.
"""
cur_remotes = set([])
if isinstance(path, (list, tuple)):
for v in path:
cur_remotes |= _get_cur_remotes(v)
elif isinstance(path, dict):
for v in path.values():
cur_remotes |= _g... | python | def _get_cur_remotes(path):
"""Retrieve remote references defined in the CWL.
"""
cur_remotes = set([])
if isinstance(path, (list, tuple)):
for v in path:
cur_remotes |= _get_cur_remotes(v)
elif isinstance(path, dict):
for v in path.values():
cur_remotes |= _g... | [
"def",
"_get_cur_remotes",
"(",
"path",
")",
":",
"cur_remotes",
"=",
"set",
"(",
"[",
"]",
")",
"if",
"isinstance",
"(",
"path",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"for",
"v",
"in",
"path",
":",
"cur_remotes",
"|=",
"_get_cur_remotes",
"... | Retrieve remote references defined in the CWL. | [
"Retrieve",
"remote",
"references",
"defined",
"in",
"the",
"CWL",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L395-L408 |
223,993 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _flatten_samples | def _flatten_samples(samples, base_file, get_retriever):
"""Create a flattened JSON representation of data from the bcbio world map.
"""
flat_data = []
for data in samples:
data["reference"] = _indexes_to_secondary_files(data["reference"], data["genome_build"])
cur_flat = {}
for ... | python | def _flatten_samples(samples, base_file, get_retriever):
"""Create a flattened JSON representation of data from the bcbio world map.
"""
flat_data = []
for data in samples:
data["reference"] = _indexes_to_secondary_files(data["reference"], data["genome_build"])
cur_flat = {}
for ... | [
"def",
"_flatten_samples",
"(",
"samples",
",",
"base_file",
",",
"get_retriever",
")",
":",
"flat_data",
"=",
"[",
"]",
"for",
"data",
"in",
"samples",
":",
"data",
"[",
"\"reference\"",
"]",
"=",
"_indexes_to_secondary_files",
"(",
"data",
"[",
"\"reference\... | Create a flattened JSON representation of data from the bcbio world map. | [
"Create",
"a",
"flattened",
"JSON",
"representation",
"of",
"data",
"from",
"the",
"bcbio",
"world",
"map",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L478-L503 |
223,994 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _indexes_to_secondary_files | def _indexes_to_secondary_files(gresources, genome_build):
"""Convert a list of genome indexes into a single file plus secondary files.
This ensures that all indices are staged together in a single directory.
"""
out = {}
for refname, val in gresources.items():
if isinstance(val, dict) and ... | python | def _indexes_to_secondary_files(gresources, genome_build):
"""Convert a list of genome indexes into a single file plus secondary files.
This ensures that all indices are staged together in a single directory.
"""
out = {}
for refname, val in gresources.items():
if isinstance(val, dict) and ... | [
"def",
"_indexes_to_secondary_files",
"(",
"gresources",
",",
"genome_build",
")",
":",
"out",
"=",
"{",
"}",
"for",
"refname",
",",
"val",
"in",
"gresources",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"dict",
")",
"and",
"\"index... | Convert a list of genome indexes into a single file plus secondary files.
This ensures that all indices are staged together in a single directory. | [
"Convert",
"a",
"list",
"of",
"genome",
"indexes",
"into",
"a",
"single",
"file",
"plus",
"secondary",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L505-L530 |
223,995 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _add_suppl_info | def _add_suppl_info(inp, val):
"""Add supplementary information to inputs from file values.
"""
inp["type"] = _get_avro_type(val)
secondary = _get_secondary_files(val)
if secondary:
inp["secondaryFiles"] = secondary
return inp | python | def _add_suppl_info(inp, val):
"""Add supplementary information to inputs from file values.
"""
inp["type"] = _get_avro_type(val)
secondary = _get_secondary_files(val)
if secondary:
inp["secondaryFiles"] = secondary
return inp | [
"def",
"_add_suppl_info",
"(",
"inp",
",",
"val",
")",
":",
"inp",
"[",
"\"type\"",
"]",
"=",
"_get_avro_type",
"(",
"val",
")",
"secondary",
"=",
"_get_secondary_files",
"(",
"val",
")",
"if",
"secondary",
":",
"inp",
"[",
"\"secondaryFiles\"",
"]",
"=",
... | Add supplementary information to inputs from file values. | [
"Add",
"supplementary",
"information",
"to",
"inputs",
"from",
"file",
"values",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L532-L539 |
223,996 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _get_secondary_files | def _get_secondary_files(val):
"""Retrieve associated secondary files.
Normalizes input values into definitions of available secondary files.
Requires indices to be present in all files, since declared CWL secondary
files are not optional. So if we have a mix of BAM (bai) and fastq (gbi) we
ignore ... | python | def _get_secondary_files(val):
"""Retrieve associated secondary files.
Normalizes input values into definitions of available secondary files.
Requires indices to be present in all files, since declared CWL secondary
files are not optional. So if we have a mix of BAM (bai) and fastq (gbi) we
ignore ... | [
"def",
"_get_secondary_files",
"(",
"val",
")",
":",
"out",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"val",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"s_counts",
"=",
"collections",
".",
"defaultdict",
"(",
"int",
")",
"for",
"x",
"in",
"val",
... | Retrieve associated secondary files.
Normalizes input values into definitions of available secondary files.
Requires indices to be present in all files, since declared CWL secondary
files are not optional. So if we have a mix of BAM (bai) and fastq (gbi) we
ignore the existing indices and will have to ... | [
"Retrieve",
"associated",
"secondary",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L541-L564 |
223,997 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _get_relative_ext | def _get_relative_ext(of, sf):
"""Retrieve relative extension given the original and secondary files.
"""
def half_finished_trim(orig, prefix):
return (os.path.basename(prefix).count(".") > 0 and
os.path.basename(orig).count(".") == os.path.basename(prefix).count("."))
# Handle r... | python | def _get_relative_ext(of, sf):
"""Retrieve relative extension given the original and secondary files.
"""
def half_finished_trim(orig, prefix):
return (os.path.basename(prefix).count(".") > 0 and
os.path.basename(orig).count(".") == os.path.basename(prefix).count("."))
# Handle r... | [
"def",
"_get_relative_ext",
"(",
"of",
",",
"sf",
")",
":",
"def",
"half_finished_trim",
"(",
"orig",
",",
"prefix",
")",
":",
"return",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"prefix",
")",
".",
"count",
"(",
"\".\"",
")",
">",
"0",
"and",
... | Retrieve relative extension given the original and secondary files. | [
"Retrieve",
"relative",
"extension",
"given",
"the",
"original",
"and",
"secondary",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L566-L586 |
223,998 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _get_avro_type | def _get_avro_type(val):
"""Infer avro type for the current input.
"""
if isinstance(val, dict):
assert val.get("class") == "File" or "File" in val.get("class")
return "File"
elif isinstance(val, (tuple, list)):
types = []
for ctype in [_get_avro_type(v) for v in val]:
... | python | def _get_avro_type(val):
"""Infer avro type for the current input.
"""
if isinstance(val, dict):
assert val.get("class") == "File" or "File" in val.get("class")
return "File"
elif isinstance(val, (tuple, list)):
types = []
for ctype in [_get_avro_type(v) for v in val]:
... | [
"def",
"_get_avro_type",
"(",
"val",
")",
":",
"if",
"isinstance",
"(",
"val",
",",
"dict",
")",
":",
"assert",
"val",
".",
"get",
"(",
"\"class\"",
")",
"==",
"\"File\"",
"or",
"\"File\"",
"in",
"val",
".",
"get",
"(",
"\"class\"",
")",
"return",
"\... | Infer avro type for the current input. | [
"Infer",
"avro",
"type",
"for",
"the",
"current",
"input",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L588-L634 |
223,999 | bcbio/bcbio-nextgen | bcbio/cwl/create.py | _avoid_duplicate_arrays | def _avoid_duplicate_arrays(types):
"""Collapse arrays when we have multiple types.
"""
arrays = [t for t in types if isinstance(t, dict) and t["type"] == "array"]
others = [t for t in types if not (isinstance(t, dict) and t["type"] == "array")]
if arrays:
items = set([])
for t in ar... | python | def _avoid_duplicate_arrays(types):
"""Collapse arrays when we have multiple types.
"""
arrays = [t for t in types if isinstance(t, dict) and t["type"] == "array"]
others = [t for t in types if not (isinstance(t, dict) and t["type"] == "array")]
if arrays:
items = set([])
for t in ar... | [
"def",
"_avoid_duplicate_arrays",
"(",
"types",
")",
":",
"arrays",
"=",
"[",
"t",
"for",
"t",
"in",
"types",
"if",
"isinstance",
"(",
"t",
",",
"dict",
")",
"and",
"t",
"[",
"\"type\"",
"]",
"==",
"\"array\"",
"]",
"others",
"=",
"[",
"t",
"for",
... | Collapse arrays when we have multiple types. | [
"Collapse",
"arrays",
"when",
"we",
"have",
"multiple",
"types",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L636-L653 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.