repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bcbio/bcbio-nextgen | bcbio/structural/shared.py | calc_paired_insert_stats_save | def calc_paired_insert_stats_save(in_bam, stat_file, nsample=1000000):
"""Calculate paired stats, saving to a file for re-runs.
"""
if utils.file_exists(stat_file):
with open(stat_file) as in_handle:
return yaml.safe_load(in_handle)
else:
stats = calc_paired_insert_stats(in_b... | python | def calc_paired_insert_stats_save(in_bam, stat_file, nsample=1000000):
"""Calculate paired stats, saving to a file for re-runs.
"""
if utils.file_exists(stat_file):
with open(stat_file) as in_handle:
return yaml.safe_load(in_handle)
else:
stats = calc_paired_insert_stats(in_b... | [
"def",
"calc_paired_insert_stats_save",
"(",
"in_bam",
",",
"stat_file",
",",
"nsample",
"=",
"1000000",
")",
":",
"if",
"utils",
".",
"file_exists",
"(",
"stat_file",
")",
":",
"with",
"open",
"(",
"stat_file",
")",
"as",
"in_handle",
":",
"return",
"yaml",... | Calculate paired stats, saving to a file for re-runs. | [
"Calculate",
"paired",
"stats",
"saving",
"to",
"a",
"file",
"for",
"re",
"-",
"runs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L321-L331 | train |
bcbio/bcbio-nextgen | scripts/utils/upload_to_synapse.py | _accumulate_remotes | def _accumulate_remotes(synapse_parent_id, syn):
"""Retrieve references to all remote directories and files.
"""
remotes = {}
s_base_folder = syn.get(synapse_parent_id)
for (s_dirpath, s_dirpath_id), _, s_filenames in synapseutils.walk(syn, synapse_parent_id):
remotes[s_dirpath] = s_dirpath_... | python | def _accumulate_remotes(synapse_parent_id, syn):
"""Retrieve references to all remote directories and files.
"""
remotes = {}
s_base_folder = syn.get(synapse_parent_id)
for (s_dirpath, s_dirpath_id), _, s_filenames in synapseutils.walk(syn, synapse_parent_id):
remotes[s_dirpath] = s_dirpath_... | [
"def",
"_accumulate_remotes",
"(",
"synapse_parent_id",
",",
"syn",
")",
":",
"remotes",
"=",
"{",
"}",
"s_base_folder",
"=",
"syn",
".",
"get",
"(",
"synapse_parent_id",
")",
"for",
"(",
"s_dirpath",
",",
"s_dirpath_id",
")",
",",
"_",
",",
"s_filenames",
... | Retrieve references to all remote directories and files. | [
"Retrieve",
"references",
"to",
"all",
"remote",
"directories",
"and",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/upload_to_synapse.py#L38-L48 | train |
bcbio/bcbio-nextgen | scripts/utils/upload_to_synapse.py | _remote_folder | def _remote_folder(dirpath, remotes, syn):
"""Retrieve the remote folder for files, creating if necessary.
"""
if dirpath in remotes:
return remotes[dirpath], remotes
else:
parent_dir, cur_dir = os.path.split(dirpath)
parent_folder, remotes = _remote_folder(parent_dir, remotes, s... | python | def _remote_folder(dirpath, remotes, syn):
"""Retrieve the remote folder for files, creating if necessary.
"""
if dirpath in remotes:
return remotes[dirpath], remotes
else:
parent_dir, cur_dir = os.path.split(dirpath)
parent_folder, remotes = _remote_folder(parent_dir, remotes, s... | [
"def",
"_remote_folder",
"(",
"dirpath",
",",
"remotes",
",",
"syn",
")",
":",
"if",
"dirpath",
"in",
"remotes",
":",
"return",
"remotes",
"[",
"dirpath",
"]",
",",
"remotes",
"else",
":",
"parent_dir",
",",
"cur_dir",
"=",
"os",
".",
"path",
".",
"spl... | Retrieve the remote folder for files, creating if necessary. | [
"Retrieve",
"the",
"remote",
"folder",
"for",
"files",
"creating",
"if",
"necessary",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/upload_to_synapse.py#L50-L60 | train |
bcbio/bcbio-nextgen | bcbio/structural/wham.py | run | def run(items, background=None):
"""Detect copy number variations from batched set of samples using WHAM.
"""
if not background: background = []
background_bams = []
paired = vcfutils.get_paired_bams([x["align_bam"] for x in items], items)
if paired:
inputs = [paired.tumor_data]
... | python | def run(items, background=None):
"""Detect copy number variations from batched set of samples using WHAM.
"""
if not background: background = []
background_bams = []
paired = vcfutils.get_paired_bams([x["align_bam"] for x in items], items)
if paired:
inputs = [paired.tumor_data]
... | [
"def",
"run",
"(",
"items",
",",
"background",
"=",
"None",
")",
":",
"if",
"not",
"background",
":",
"background",
"=",
"[",
"]",
"background_bams",
"=",
"[",
"]",
"paired",
"=",
"vcfutils",
".",
"get_paired_bams",
"(",
"[",
"x",
"[",
"\"align_bam\"",
... | Detect copy number variations from batched set of samples using WHAM. | [
"Detect",
"copy",
"number",
"variations",
"from",
"batched",
"set",
"of",
"samples",
"using",
"WHAM",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/wham.py#L19-L42 | train |
bcbio/bcbio-nextgen | bcbio/structural/wham.py | _run_wham | def _run_wham(inputs, background_bams):
"""Run WHAM on a defined set of inputs and targets.
"""
out_file = os.path.join(_sv_workdir(inputs[0]), "%s-wham.vcf.gz" % dd.get_sample_name(inputs[0]))
if not utils.file_exists(out_file):
with file_transaction(inputs[0], out_file) as tx_out_file:
... | python | def _run_wham(inputs, background_bams):
"""Run WHAM on a defined set of inputs and targets.
"""
out_file = os.path.join(_sv_workdir(inputs[0]), "%s-wham.vcf.gz" % dd.get_sample_name(inputs[0]))
if not utils.file_exists(out_file):
with file_transaction(inputs[0], out_file) as tx_out_file:
... | [
"def",
"_run_wham",
"(",
"inputs",
",",
"background_bams",
")",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_sv_workdir",
"(",
"inputs",
"[",
"0",
"]",
")",
",",
"\"%s-wham.vcf.gz\"",
"%",
"dd",
".",
"get_sample_name",
"(",
"inputs",
"[",... | Run WHAM on a defined set of inputs and targets. | [
"Run",
"WHAM",
"on",
"a",
"defined",
"set",
"of",
"inputs",
"and",
"targets",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/wham.py#L48-L62 | train |
bcbio/bcbio-nextgen | bcbio/structural/wham.py | filter_by_background | def filter_by_background(in_vcf, full_vcf, background, data):
"""Filter SV calls also present in background samples.
Skips filtering of inversions, which are not characterized differently
between cases and controls in test datasets.
"""
Filter = collections.namedtuple('Filter', ['id', 'desc'])
... | python | def filter_by_background(in_vcf, full_vcf, background, data):
"""Filter SV calls also present in background samples.
Skips filtering of inversions, which are not characterized differently
between cases and controls in test datasets.
"""
Filter = collections.namedtuple('Filter', ['id', 'desc'])
... | [
"def",
"filter_by_background",
"(",
"in_vcf",
",",
"full_vcf",
",",
"background",
",",
"data",
")",
":",
"Filter",
"=",
"collections",
".",
"namedtuple",
"(",
"'Filter'",
",",
"[",
"'id'",
",",
"'desc'",
"]",
")",
"back_filter",
"=",
"Filter",
"(",
"id",
... | Filter SV calls also present in background samples.
Skips filtering of inversions, which are not characterized differently
between cases and controls in test datasets. | [
"Filter",
"SV",
"calls",
"also",
"present",
"in",
"background",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/wham.py#L64-L87 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkjoint.py | run_region | def run_region(data, region, vrn_files, out_file):
"""Perform variant calling on gVCF inputs in a specific genomic region.
"""
broad_runner = broad.runner_from_config(data["config"])
if broad_runner.gatk_type() == "gatk4":
genomics_db = _run_genomicsdb_import(vrn_files, region, out_file, data)
... | python | def run_region(data, region, vrn_files, out_file):
"""Perform variant calling on gVCF inputs in a specific genomic region.
"""
broad_runner = broad.runner_from_config(data["config"])
if broad_runner.gatk_type() == "gatk4":
genomics_db = _run_genomicsdb_import(vrn_files, region, out_file, data)
... | [
"def",
"run_region",
"(",
"data",
",",
"region",
",",
"vrn_files",
",",
"out_file",
")",
":",
"broad_runner",
"=",
"broad",
".",
"runner_from_config",
"(",
"data",
"[",
"\"config\"",
"]",
")",
"if",
"broad_runner",
".",
"gatk_type",
"(",
")",
"==",
"\"gatk... | Perform variant calling on gVCF inputs in a specific genomic region. | [
"Perform",
"variant",
"calling",
"on",
"gVCF",
"inputs",
"in",
"a",
"specific",
"genomic",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkjoint.py#L18-L27 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkjoint.py | _incomplete_genomicsdb | def _incomplete_genomicsdb(dbdir):
"""Check if a GenomicsDB output is incomplete and we should regenerate.
Works around current inability to move GenomicsDB outputs and support
transactional directories.
"""
for test_file in ["callset.json", "vidmap.json", "genomicsdb_array/genomicsdb_meta.json"]:
... | python | def _incomplete_genomicsdb(dbdir):
"""Check if a GenomicsDB output is incomplete and we should regenerate.
Works around current inability to move GenomicsDB outputs and support
transactional directories.
"""
for test_file in ["callset.json", "vidmap.json", "genomicsdb_array/genomicsdb_meta.json"]:
... | [
"def",
"_incomplete_genomicsdb",
"(",
"dbdir",
")",
":",
"for",
"test_file",
"in",
"[",
"\"callset.json\"",
",",
"\"vidmap.json\"",
",",
"\"genomicsdb_array/genomicsdb_meta.json\"",
"]",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",... | Check if a GenomicsDB output is incomplete and we should regenerate.
Works around current inability to move GenomicsDB outputs and support
transactional directories. | [
"Check",
"if",
"a",
"GenomicsDB",
"output",
"is",
"incomplete",
"and",
"we",
"should",
"regenerate",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkjoint.py#L64-L73 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkjoint.py | _run_genotype_gvcfs_gatk3 | def _run_genotype_gvcfs_gatk3(data, region, vrn_files, ref_file, out_file):
"""Performs genotyping of gVCFs into final VCF files.
"""
if not utils.file_exists(out_file):
broad_runner = broad.runner_from_config(data["config"])
with file_transaction(data, out_file) as tx_out_file:
... | python | def _run_genotype_gvcfs_gatk3(data, region, vrn_files, ref_file, out_file):
"""Performs genotyping of gVCFs into final VCF files.
"""
if not utils.file_exists(out_file):
broad_runner = broad.runner_from_config(data["config"])
with file_transaction(data, out_file) as tx_out_file:
... | [
"def",
"_run_genotype_gvcfs_gatk3",
"(",
"data",
",",
"region",
",",
"vrn_files",
",",
"ref_file",
",",
"out_file",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"broad_runner",
"=",
"broad",
".",
"runner_from_config",
"(",
"... | Performs genotyping of gVCFs into final VCF files. | [
"Performs",
"genotyping",
"of",
"gVCFs",
"into",
"final",
"VCF",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkjoint.py#L102-L133 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkjoint.py | _batch_gvcfs | def _batch_gvcfs(data, region, vrn_files, ref_file, out_file=None):
"""Perform batching of gVCF files if above recommended input count.
"""
if out_file is None:
out_file = vrn_files[0]
# group to get below the maximum batch size, using 200 as the baseline
max_batch = int(dd.get_joint_group_s... | python | def _batch_gvcfs(data, region, vrn_files, ref_file, out_file=None):
"""Perform batching of gVCF files if above recommended input count.
"""
if out_file is None:
out_file = vrn_files[0]
# group to get below the maximum batch size, using 200 as the baseline
max_batch = int(dd.get_joint_group_s... | [
"def",
"_batch_gvcfs",
"(",
"data",
",",
"region",
",",
"vrn_files",
",",
"ref_file",
",",
"out_file",
"=",
"None",
")",
":",
"if",
"out_file",
"is",
"None",
":",
"out_file",
"=",
"vrn_files",
"[",
"0",
"]",
"# group to get below the maximum batch size, using 20... | Perform batching of gVCF files if above recommended input count. | [
"Perform",
"batching",
"of",
"gVCF",
"files",
"if",
"above",
"recommended",
"input",
"count",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkjoint.py#L137-L153 | train |
bcbio/bcbio-nextgen | bcbio/qc/preseq.py | _get_preseq_params | def _get_preseq_params(data, preseq_cmd, read_count):
""" Get parameters through resources.
If "step" or "extrap" limit are not provided, then calculate optimal values based on read count.
"""
defaults = {
'seg_len': 100000, # maximum segment length when merging paired end bam reads
... | python | def _get_preseq_params(data, preseq_cmd, read_count):
""" Get parameters through resources.
If "step" or "extrap" limit are not provided, then calculate optimal values based on read count.
"""
defaults = {
'seg_len': 100000, # maximum segment length when merging paired end bam reads
... | [
"def",
"_get_preseq_params",
"(",
"data",
",",
"preseq_cmd",
",",
"read_count",
")",
":",
"defaults",
"=",
"{",
"'seg_len'",
":",
"100000",
",",
"# maximum segment length when merging paired end bam reads",
"'steps'",
":",
"300",
",",
"# number of points on the plot",
"... | Get parameters through resources.
If "step" or "extrap" limit are not provided, then calculate optimal values based on read count. | [
"Get",
"parameters",
"through",
"resources",
".",
"If",
"step",
"or",
"extrap",
"limit",
"are",
"not",
"provided",
"then",
"calculate",
"optimal",
"values",
"based",
"on",
"read",
"count",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/preseq.py#L51-L114 | train |
bcbio/bcbio-nextgen | bcbio/variation/germline.py | split_somatic | def split_somatic(items):
"""Split somatic batches, adding a germline target.
Enables separate germline calling of samples using shared alignments.
"""
items = [_clean_flat_variantcaller(x) for x in items]
somatic_groups, somatic, non_somatic = vcfutils.somatic_batches(items)
# extract germline... | python | def split_somatic(items):
"""Split somatic batches, adding a germline target.
Enables separate germline calling of samples using shared alignments.
"""
items = [_clean_flat_variantcaller(x) for x in items]
somatic_groups, somatic, non_somatic = vcfutils.somatic_batches(items)
# extract germline... | [
"def",
"split_somatic",
"(",
"items",
")",
":",
"items",
"=",
"[",
"_clean_flat_variantcaller",
"(",
"x",
")",
"for",
"x",
"in",
"items",
"]",
"somatic_groups",
",",
"somatic",
",",
"non_somatic",
"=",
"vcfutils",
".",
"somatic_batches",
"(",
"items",
")",
... | Split somatic batches, adding a germline target.
Enables separate germline calling of samples using shared alignments. | [
"Split",
"somatic",
"batches",
"adding",
"a",
"germline",
"target",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L19-L50 | train |
bcbio/bcbio-nextgen | bcbio/variation/germline.py | _clean_flat_variantcaller | def _clean_flat_variantcaller(data):
"""Convert flattened dictionary from CWL representation into dictionary.
CWL flattens somatic/germline tags into a set of strings, which we
reconstitute as a dictionary.
"""
vc = dd.get_variantcaller(data)
if isinstance(vc, (list, tuple)) and all([x.count(":... | python | def _clean_flat_variantcaller(data):
"""Convert flattened dictionary from CWL representation into dictionary.
CWL flattens somatic/germline tags into a set of strings, which we
reconstitute as a dictionary.
"""
vc = dd.get_variantcaller(data)
if isinstance(vc, (list, tuple)) and all([x.count(":... | [
"def",
"_clean_flat_variantcaller",
"(",
"data",
")",
":",
"vc",
"=",
"dd",
".",
"get_variantcaller",
"(",
"data",
")",
"if",
"isinstance",
"(",
"vc",
",",
"(",
"list",
",",
"tuple",
")",
")",
"and",
"all",
"(",
"[",
"x",
".",
"count",
"(",
"\":\"",
... | Convert flattened dictionary from CWL representation into dictionary.
CWL flattens somatic/germline tags into a set of strings, which we
reconstitute as a dictionary. | [
"Convert",
"flattened",
"dictionary",
"from",
"CWL",
"representation",
"into",
"dictionary",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L52-L68 | train |
bcbio/bcbio-nextgen | bcbio/variation/germline.py | remove_align_qc_tools | def remove_align_qc_tools(data):
"""Remove alignment based QC tools we don't need for data replicates.
When we do multiple variant calling on a sample file (somatic/germline),
avoid re-running QC.
"""
align_qc = set(["qsignature", "coverage", "picard", "samtools", "fastqc"])
data["config"]["alg... | python | def remove_align_qc_tools(data):
"""Remove alignment based QC tools we don't need for data replicates.
When we do multiple variant calling on a sample file (somatic/germline),
avoid re-running QC.
"""
align_qc = set(["qsignature", "coverage", "picard", "samtools", "fastqc"])
data["config"]["alg... | [
"def",
"remove_align_qc_tools",
"(",
"data",
")",
":",
"align_qc",
"=",
"set",
"(",
"[",
"\"qsignature\"",
",",
"\"coverage\"",
",",
"\"picard\"",
",",
"\"samtools\"",
",",
"\"fastqc\"",
"]",
")",
"data",
"[",
"\"config\"",
"]",
"[",
"\"algorithm\"",
"]",
"[... | Remove alignment based QC tools we don't need for data replicates.
When we do multiple variant calling on a sample file (somatic/germline),
avoid re-running QC. | [
"Remove",
"alignment",
"based",
"QC",
"tools",
"we",
"don",
"t",
"need",
"for",
"data",
"replicates",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L70-L79 | train |
bcbio/bcbio-nextgen | bcbio/variation/germline.py | extract | def extract(data, items, out_dir=None):
"""Extract germline calls for the given sample, if tumor only.
"""
if vcfutils.get_paired_phenotype(data):
if len(items) == 1:
germline_vcf = _remove_prioritization(data["vrn_file"], data, out_dir)
germline_vcf = vcfutils.bgzip_and_inde... | python | def extract(data, items, out_dir=None):
"""Extract germline calls for the given sample, if tumor only.
"""
if vcfutils.get_paired_phenotype(data):
if len(items) == 1:
germline_vcf = _remove_prioritization(data["vrn_file"], data, out_dir)
germline_vcf = vcfutils.bgzip_and_inde... | [
"def",
"extract",
"(",
"data",
",",
"items",
",",
"out_dir",
"=",
"None",
")",
":",
"if",
"vcfutils",
".",
"get_paired_phenotype",
"(",
"data",
")",
":",
"if",
"len",
"(",
"items",
")",
"==",
"1",
":",
"germline_vcf",
"=",
"_remove_prioritization",
"(",
... | Extract germline calls for the given sample, if tumor only. | [
"Extract",
"germline",
"calls",
"for",
"the",
"given",
"sample",
"if",
"tumor",
"only",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L81-L89 | train |
bcbio/bcbio-nextgen | bcbio/variation/germline.py | fix_germline_samplename | def fix_germline_samplename(in_file, sample_name, data):
"""Replace germline sample names, originally from normal BAM file.
"""
out_file = "%s-fixnames%s" % utils.splitext_plus(in_file)
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
sample_f... | python | def fix_germline_samplename(in_file, sample_name, data):
"""Replace germline sample names, originally from normal BAM file.
"""
out_file = "%s-fixnames%s" % utils.splitext_plus(in_file)
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
sample_f... | [
"def",
"fix_germline_samplename",
"(",
"in_file",
",",
"sample_name",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-fixnames%s\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"... | Replace germline sample names, originally from normal BAM file. | [
"Replace",
"germline",
"sample",
"names",
"originally",
"from",
"normal",
"BAM",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L133-L144 | train |
bcbio/bcbio-nextgen | bcbio/variation/germline.py | _remove_prioritization | def _remove_prioritization(in_file, data, out_dir=None):
"""Remove tumor-only prioritization and return non-filtered calls.
"""
out_file = "%s-germline.vcf" % utils.splitext_plus(in_file)[0]
if out_dir:
out_file = os.path.join(out_dir, os.path.basename(out_file))
if not utils.file_uptodate(o... | python | def _remove_prioritization(in_file, data, out_dir=None):
"""Remove tumor-only prioritization and return non-filtered calls.
"""
out_file = "%s-germline.vcf" % utils.splitext_plus(in_file)[0]
if out_dir:
out_file = os.path.join(out_dir, os.path.basename(out_file))
if not utils.file_uptodate(o... | [
"def",
"_remove_prioritization",
"(",
"in_file",
",",
"data",
",",
"out_dir",
"=",
"None",
")",
":",
"out_file",
"=",
"\"%s-germline.vcf\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"if",
"out_dir",
":",
"out_file",
"=",
"os"... | Remove tumor-only prioritization and return non-filtered calls. | [
"Remove",
"tumor",
"-",
"only",
"prioritization",
"and",
"return",
"non",
"-",
"filtered",
"calls",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L146-L163 | train |
bcbio/bcbio-nextgen | bcbio/variation/germline.py | _extract_germline | def _extract_germline(in_file, data):
"""Extract germline calls non-somatic, non-filtered calls.
"""
out_file = "%s-germline.vcf" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file) and not utils.file_uptodate(out_file + ".gz", in_file):
with file_transaction(data, ou... | python | def _extract_germline(in_file, data):
"""Extract germline calls non-somatic, non-filtered calls.
"""
out_file = "%s-germline.vcf" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file) and not utils.file_uptodate(out_file + ".gz", in_file):
with file_transaction(data, ou... | [
"def",
"_extract_germline",
"(",
"in_file",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-germline.vcf\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"if",
"not",
"utils",
".",
"file_uptodate",
"(",
"out_file",
",",
"in_file",
... | Extract germline calls non-somatic, non-filtered calls. | [
"Extract",
"germline",
"calls",
"non",
"-",
"somatic",
"non",
"-",
"filtered",
"calls",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L169-L184 | train |
bcbio/bcbio-nextgen | bcbio/variation/germline.py | _is_somatic | def _is_somatic(rec):
"""Handle somatic classifications from MuTect, MuTect2, VarDict and VarScan
"""
if _has_somatic_flag(rec):
return True
if _is_mutect2_somatic(rec):
return True
ss_flag = rec.INFO.get("SS")
if ss_flag is not None:
if str(ss_flag) == "2":
r... | python | def _is_somatic(rec):
"""Handle somatic classifications from MuTect, MuTect2, VarDict and VarScan
"""
if _has_somatic_flag(rec):
return True
if _is_mutect2_somatic(rec):
return True
ss_flag = rec.INFO.get("SS")
if ss_flag is not None:
if str(ss_flag) == "2":
r... | [
"def",
"_is_somatic",
"(",
"rec",
")",
":",
"if",
"_has_somatic_flag",
"(",
"rec",
")",
":",
"return",
"True",
"if",
"_is_mutect2_somatic",
"(",
"rec",
")",
":",
"return",
"True",
"ss_flag",
"=",
"rec",
".",
"INFO",
".",
"get",
"(",
"\"SS\"",
")",
"if"... | Handle somatic classifications from MuTect, MuTect2, VarDict and VarScan | [
"Handle",
"somatic",
"classifications",
"from",
"MuTect",
"MuTect2",
"VarDict",
"and",
"VarScan"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L210-L228 | train |
bcbio/bcbio-nextgen | bcbio/variation/germline.py | _is_germline | def _is_germline(rec):
"""Handle somatic INFO classifications from MuTect, MuTect2, VarDict, VarScan and Octopus.
"""
if _has_somatic_flag(rec):
return False
if _is_mutect2_somatic(rec):
return False
ss_flag = rec.INFO.get("SS")
if ss_flag is not None:
if str(ss_flag) == ... | python | def _is_germline(rec):
"""Handle somatic INFO classifications from MuTect, MuTect2, VarDict, VarScan and Octopus.
"""
if _has_somatic_flag(rec):
return False
if _is_mutect2_somatic(rec):
return False
ss_flag = rec.INFO.get("SS")
if ss_flag is not None:
if str(ss_flag) == ... | [
"def",
"_is_germline",
"(",
"rec",
")",
":",
"if",
"_has_somatic_flag",
"(",
"rec",
")",
":",
"return",
"False",
"if",
"_is_mutect2_somatic",
"(",
"rec",
")",
":",
"return",
"False",
"ss_flag",
"=",
"rec",
".",
"INFO",
".",
"get",
"(",
"\"SS\"",
")",
"... | Handle somatic INFO classifications from MuTect, MuTect2, VarDict, VarScan and Octopus. | [
"Handle",
"somatic",
"INFO",
"classifications",
"from",
"MuTect",
"MuTect2",
"VarDict",
"VarScan",
"and",
"Octopus",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L242-L262 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | get_sort_cmd | def get_sort_cmd(tmp_dir=None):
"""Retrieve GNU coreutils sort command, using version-sort if available.
Recent versions of sort have alpha-numeric sorting, which provides
more natural sorting of chromosomes (chr1, chr2) instead of (chr1, chr10).
This also fixes versions of sort, like 8.22 in CentOS 7.... | python | def get_sort_cmd(tmp_dir=None):
"""Retrieve GNU coreutils sort command, using version-sort if available.
Recent versions of sort have alpha-numeric sorting, which provides
more natural sorting of chromosomes (chr1, chr2) instead of (chr1, chr10).
This also fixes versions of sort, like 8.22 in CentOS 7.... | [
"def",
"get_sort_cmd",
"(",
"tmp_dir",
"=",
"None",
")",
":",
"has_versionsort",
"=",
"subprocess",
".",
"check_output",
"(",
"\"sort --help | grep version-sort; exit 0\"",
",",
"shell",
"=",
"True",
")",
".",
"strip",
"(",
")",
"if",
"has_versionsort",
":",
"cm... | Retrieve GNU coreutils sort command, using version-sort if available.
Recent versions of sort have alpha-numeric sorting, which provides
more natural sorting of chromosomes (chr1, chr2) instead of (chr1, chr10).
This also fixes versions of sort, like 8.22 in CentOS 7.1, that have broken
sorting without... | [
"Retrieve",
"GNU",
"coreutils",
"sort",
"command",
"using",
"version",
"-",
"sort",
"if",
"available",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L18-L36 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | check_bed_contigs | def check_bed_contigs(in_file, data):
"""Ensure BED file contigs match the reference genome.
"""
if not dd.get_ref_file(data):
return
contigs = set([])
with utils.open_gzipsafe(in_file) as in_handle:
for line in in_handle:
if not line.startswith(("#", "track", "browser", ... | python | def check_bed_contigs(in_file, data):
"""Ensure BED file contigs match the reference genome.
"""
if not dd.get_ref_file(data):
return
contigs = set([])
with utils.open_gzipsafe(in_file) as in_handle:
for line in in_handle:
if not line.startswith(("#", "track", "browser", ... | [
"def",
"check_bed_contigs",
"(",
"in_file",
",",
"data",
")",
":",
"if",
"not",
"dd",
".",
"get_ref_file",
"(",
"data",
")",
":",
"return",
"contigs",
"=",
"set",
"(",
"[",
"]",
")",
"with",
"utils",
".",
"open_gzipsafe",
"(",
"in_file",
")",
"as",
"... | Ensure BED file contigs match the reference genome. | [
"Ensure",
"BED",
"file",
"contigs",
"match",
"the",
"reference",
"genome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L38-L52 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | check_bed_coords | def check_bed_coords(in_file, data):
"""Ensure BED file coordinates match reference genome.
Catches errors like using a hg38 BED file for an hg19 genome run.
"""
if dd.get_ref_file(data):
contig_sizes = {}
for contig in ref.file_contigs(dd.get_ref_file(data)):
contig_sizes[c... | python | def check_bed_coords(in_file, data):
"""Ensure BED file coordinates match reference genome.
Catches errors like using a hg38 BED file for an hg19 genome run.
"""
if dd.get_ref_file(data):
contig_sizes = {}
for contig in ref.file_contigs(dd.get_ref_file(data)):
contig_sizes[c... | [
"def",
"check_bed_coords",
"(",
"in_file",
",",
"data",
")",
":",
"if",
"dd",
".",
"get_ref_file",
"(",
"data",
")",
":",
"contig_sizes",
"=",
"{",
"}",
"for",
"contig",
"in",
"ref",
".",
"file_contigs",
"(",
"dd",
".",
"get_ref_file",
"(",
"data",
")"... | Ensure BED file coordinates match reference genome.
Catches errors like using a hg38 BED file for an hg19 genome run. | [
"Ensure",
"BED",
"file",
"coordinates",
"match",
"reference",
"genome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L54-L77 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | clean_file | def clean_file(in_file, data, prefix="", bedprep_dir=None, simple=None):
"""Prepare a clean sorted input BED file without headers
"""
# Remove non-ascii characters. Used in coverage analysis, to support JSON code in one column
# and be happy with sambamba:
simple = "iconv -c -f utf-8 -t ascii | se... | python | def clean_file(in_file, data, prefix="", bedprep_dir=None, simple=None):
"""Prepare a clean sorted input BED file without headers
"""
# Remove non-ascii characters. Used in coverage analysis, to support JSON code in one column
# and be happy with sambamba:
simple = "iconv -c -f utf-8 -t ascii | se... | [
"def",
"clean_file",
"(",
"in_file",
",",
"data",
",",
"prefix",
"=",
"\"\"",
",",
"bedprep_dir",
"=",
"None",
",",
"simple",
"=",
"None",
")",
":",
"# Remove non-ascii characters. Used in coverage analysis, to support JSON code in one column",
"# and be happy with sambam... | Prepare a clean sorted input BED file without headers | [
"Prepare",
"a",
"clean",
"sorted",
"input",
"BED",
"file",
"without",
"headers"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L79-L108 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | remove_bad | def remove_bad():
"""Remove non-increasing BED lines which will cause variant callers to choke.
Also fixes space separated BED inputs.
"""
for line in sys.stdin:
parts = line.strip().split("\t")
if len(parts) == 1 and len(line.strip().split()) > 1:
parts = line.strip().split... | python | def remove_bad():
"""Remove non-increasing BED lines which will cause variant callers to choke.
Also fixes space separated BED inputs.
"""
for line in sys.stdin:
parts = line.strip().split("\t")
if len(parts) == 1 and len(line.strip().split()) > 1:
parts = line.strip().split... | [
"def",
"remove_bad",
"(",
")",
":",
"for",
"line",
"in",
"sys",
".",
"stdin",
":",
"parts",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"\"\\t\"",
")",
"if",
"len",
"(",
"parts",
")",
"==",
"1",
"and",
"len",
"(",
"line",
".",
"stri... | Remove non-increasing BED lines which will cause variant callers to choke.
Also fixes space separated BED inputs. | [
"Remove",
"non",
"-",
"increasing",
"BED",
"lines",
"which",
"will",
"cause",
"variant",
"callers",
"to",
"choke",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L134-L144 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | merge_overlaps | def merge_overlaps(in_file, data, distance=None, out_dir=None):
"""Merge bed file intervals to avoid overlapping regions. Output is always a 3 column file.
Overlapping regions (1:1-100, 1:90-100) cause issues with callers like FreeBayes
that don't collapse BEDs prior to using them.
"""
config = dat... | python | def merge_overlaps(in_file, data, distance=None, out_dir=None):
"""Merge bed file intervals to avoid overlapping regions. Output is always a 3 column file.
Overlapping regions (1:1-100, 1:90-100) cause issues with callers like FreeBayes
that don't collapse BEDs prior to using them.
"""
config = dat... | [
"def",
"merge_overlaps",
"(",
"in_file",
",",
"data",
",",
"distance",
"=",
"None",
",",
"out_dir",
"=",
"None",
")",
":",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"if",
"in_file",
":",
"bedtools",
"=",
"config_utils",
".",
"get_program",
"(",
"\"b... | Merge bed file intervals to avoid overlapping regions. Output is always a 3 column file.
Overlapping regions (1:1-100, 1:90-100) cause issues with callers like FreeBayes
that don't collapse BEDs prior to using them. | [
"Merge",
"bed",
"file",
"intervals",
"to",
"avoid",
"overlapping",
"regions",
".",
"Output",
"is",
"always",
"a",
"3",
"column",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L146-L170 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | population_variant_regions | def population_variant_regions(items, merged=False):
"""Retrieve the variant region BED file from a population of items.
If tumor/normal, return the tumor BED file. If a population, return
the BED file covering the most bases.
"""
def _get_variant_regions(data):
out = dd.get_variant_regions... | python | def population_variant_regions(items, merged=False):
"""Retrieve the variant region BED file from a population of items.
If tumor/normal, return the tumor BED file. If a population, return
the BED file covering the most bases.
"""
def _get_variant_regions(data):
out = dd.get_variant_regions... | [
"def",
"population_variant_regions",
"(",
"items",
",",
"merged",
"=",
"False",
")",
":",
"def",
"_get_variant_regions",
"(",
"data",
")",
":",
"out",
"=",
"dd",
".",
"get_variant_regions",
"(",
"data",
")",
"or",
"dd",
".",
"get_sample_callable",
"(",
"data... | Retrieve the variant region BED file from a population of items.
If tumor/normal, return the tumor BED file. If a population, return
the BED file covering the most bases. | [
"Retrieve",
"the",
"variant",
"region",
"BED",
"file",
"from",
"a",
"population",
"of",
"items",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L172-L203 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | combine | def combine(in_files, out_file, config):
"""Combine multiple BED files into a single output.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
with open(tx_out_file, "w") as out_handle:
for in_file in in_files:
... | python | def combine(in_files, out_file, config):
"""Combine multiple BED files into a single output.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
with open(tx_out_file, "w") as out_handle:
for in_file in in_files:
... | [
"def",
"combine",
"(",
"in_files",
",",
"out_file",
",",
"config",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"config",
",",
"out_file",
")",
"as",
"tx_out_file",
":",
"with",
"open",
"... | Combine multiple BED files into a single output. | [
"Combine",
"multiple",
"BED",
"files",
"into",
"a",
"single",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L205-L214 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | intersect_two | def intersect_two(f1, f2, work_dir, data):
"""Intersect two regions, handling cases where either file is not present.
"""
bedtools = config_utils.get_program("bedtools", data, default="bedtools")
f1_exists = f1 and utils.file_exists(f1)
f2_exists = f2 and utils.file_exists(f2)
if not f1_exists a... | python | def intersect_two(f1, f2, work_dir, data):
"""Intersect two regions, handling cases where either file is not present.
"""
bedtools = config_utils.get_program("bedtools", data, default="bedtools")
f1_exists = f1 and utils.file_exists(f1)
f2_exists = f2 and utils.file_exists(f2)
if not f1_exists a... | [
"def",
"intersect_two",
"(",
"f1",
",",
"f2",
",",
"work_dir",
",",
"data",
")",
":",
"bedtools",
"=",
"config_utils",
".",
"get_program",
"(",
"\"bedtools\"",
",",
"data",
",",
"default",
"=",
"\"bedtools\"",
")",
"f1_exists",
"=",
"f1",
"and",
"utils",
... | Intersect two regions, handling cases where either file is not present. | [
"Intersect",
"two",
"regions",
"handling",
"cases",
"where",
"either",
"file",
"is",
"not",
"present",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L216-L234 | train |
bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | subset_to_genome | def subset_to_genome(in_file, out_file, data):
"""Subset a BED file to only contain contigs present in the reference genome.
"""
if not utils.file_uptodate(out_file, in_file):
contigs = set([x.name for x in ref.file_contigs(dd.get_ref_file(data))])
with utils.open_gzipsafe(in_file) as in_han... | python | def subset_to_genome(in_file, out_file, data):
"""Subset a BED file to only contain contigs present in the reference genome.
"""
if not utils.file_uptodate(out_file, in_file):
contigs = set([x.name for x in ref.file_contigs(dd.get_ref_file(data))])
with utils.open_gzipsafe(in_file) as in_han... | [
"def",
"subset_to_genome",
"(",
"in_file",
",",
"out_file",
",",
"data",
")",
":",
"if",
"not",
"utils",
".",
"file_uptodate",
"(",
"out_file",
",",
"in_file",
")",
":",
"contigs",
"=",
"set",
"(",
"[",
"x",
".",
"name",
"for",
"x",
"in",
"ref",
".",... | Subset a BED file to only contain contigs present in the reference genome. | [
"Subset",
"a",
"BED",
"file",
"to",
"only",
"contain",
"contigs",
"present",
"in",
"the",
"reference",
"genome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L247-L259 | train |
bcbio/bcbio-nextgen | bcbio/variation/octopus.py | run | def run(align_bams, items, ref_file, assoc_files, region, out_file):
"""Run octopus variant calling, handling both somatic and germline calling.
"""
if not utils.file_exists(out_file):
paired = vcfutils.get_paired_bams(align_bams, items)
vrs = bedutils.population_variant_regions(items)
... | python | def run(align_bams, items, ref_file, assoc_files, region, out_file):
"""Run octopus variant calling, handling both somatic and germline calling.
"""
if not utils.file_exists(out_file):
paired = vcfutils.get_paired_bams(align_bams, items)
vrs = bedutils.population_variant_regions(items)
... | [
"def",
"run",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"assoc_files",
",",
"region",
",",
"out_file",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"paired",
"=",
"vcfutils",
".",
"get_paired_bams",
"(",
"al... | Run octopus variant calling, handling both somatic and germline calling. | [
"Run",
"octopus",
"variant",
"calling",
"handling",
"both",
"somatic",
"and",
"germline",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L17-L29 | train |
bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _produce_compatible_vcf | def _produce_compatible_vcf(out_file, data, is_somatic):
"""Create a compatible VCF that downstream tools can deal with.
- htsjdk and thus GATK and Picard do not support VCF4.3:
https://github.com/broadinstitute/gatk/issues/2092
- Use octopus legacy format to avoid incompatibilities.
https://gi... | python | def _produce_compatible_vcf(out_file, data, is_somatic):
"""Create a compatible VCF that downstream tools can deal with.
- htsjdk and thus GATK and Picard do not support VCF4.3:
https://github.com/broadinstitute/gatk/issues/2092
- Use octopus legacy format to avoid incompatibilities.
https://gi... | [
"def",
"_produce_compatible_vcf",
"(",
"out_file",
",",
"data",
",",
"is_somatic",
")",
":",
"base",
",",
"ext",
"=",
"utils",
".",
"splitext_plus",
"(",
"out_file",
")",
"legacy_file",
"=",
"\"%s.legacy%s\"",
"%",
"(",
"base",
",",
"ext",
")",
"if",
"is_s... | Create a compatible VCF that downstream tools can deal with.
- htsjdk and thus GATK and Picard do not support VCF4.3:
https://github.com/broadinstitute/gatk/issues/2092
- Use octopus legacy format to avoid incompatibilities.
https://github.com/luntergroup/octopus#output-format
- Fixes `##contig... | [
"Create",
"a",
"compatible",
"VCF",
"that",
"downstream",
"tools",
"can",
"deal",
"with",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L31-L55 | train |
bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _covert_to_diploid | def _covert_to_diploid(in_file, data):
"""Converts non-diploid somatic outputs into diploid.
https://github.com/luntergroup/octopus/wiki/Case-study:-Tumour-only-UMI#evaluate-variant-calls
"""
sample = dd.get_sample_name(data)
out_file = "%s-diploid.vcf" % utils.splitext_plus(in_file)[0]
in_vcf ... | python | def _covert_to_diploid(in_file, data):
"""Converts non-diploid somatic outputs into diploid.
https://github.com/luntergroup/octopus/wiki/Case-study:-Tumour-only-UMI#evaluate-variant-calls
"""
sample = dd.get_sample_name(data)
out_file = "%s-diploid.vcf" % utils.splitext_plus(in_file)[0]
in_vcf ... | [
"def",
"_covert_to_diploid",
"(",
"in_file",
",",
"data",
")",
":",
"sample",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"out_file",
"=",
"\"%s-diploid.vcf\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"in_vcf",
"=",... | Converts non-diploid somatic outputs into diploid.
https://github.com/luntergroup/octopus/wiki/Case-study:-Tumour-only-UMI#evaluate-variant-calls | [
"Converts",
"non",
"-",
"diploid",
"somatic",
"outputs",
"into",
"diploid",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L57-L81 | train |
bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _run_germline | def _run_germline(align_bams, items, ref_file, target, out_file):
"""Run germline calling, handling populations.
TODO:
- We could better handle trio calling with ped inputs as octopus
has special support.
"""
align_bams = " ".join(align_bams)
cores = dd.get_num_cores(items[0])
cmd... | python | def _run_germline(align_bams, items, ref_file, target, out_file):
"""Run germline calling, handling populations.
TODO:
- We could better handle trio calling with ped inputs as octopus
has special support.
"""
align_bams = " ".join(align_bams)
cores = dd.get_num_cores(items[0])
cmd... | [
"def",
"_run_germline",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"target",
",",
"out_file",
")",
":",
"align_bams",
"=",
"\" \"",
".",
"join",
"(",
"align_bams",
")",
"cores",
"=",
"dd",
".",
"get_num_cores",
"(",
"items",
"[",
"0",
"]",
... | Run germline calling, handling populations.
TODO:
- We could better handle trio calling with ped inputs as octopus
has special support. | [
"Run",
"germline",
"calling",
"handling",
"populations",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L83-L100 | train |
bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _run_somatic | def _run_somatic(paired, ref_file, target, out_file):
"""Run somatic calling with octopus, handling both paired and tumor-only cases.
Tweaks for low frequency, tumor only and UMI calling documented in:
https://github.com/luntergroup/octopus/blob/develop/configs/UMI.config
"""
align_bams = paired.tu... | python | def _run_somatic(paired, ref_file, target, out_file):
"""Run somatic calling with octopus, handling both paired and tumor-only cases.
Tweaks for low frequency, tumor only and UMI calling documented in:
https://github.com/luntergroup/octopus/blob/develop/configs/UMI.config
"""
align_bams = paired.tu... | [
"def",
"_run_somatic",
"(",
"paired",
",",
"ref_file",
",",
"target",
",",
"out_file",
")",
":",
"align_bams",
"=",
"paired",
".",
"tumor_bam",
"if",
"paired",
".",
"normal_bam",
":",
"align_bams",
"+=",
"\" %s --normal-sample %s\"",
"%",
"(",
"paired",
".",
... | Run somatic calling with octopus, handling both paired and tumor-only cases.
Tweaks for low frequency, tumor only and UMI calling documented in:
https://github.com/luntergroup/octopus/blob/develop/configs/UMI.config | [
"Run",
"somatic",
"calling",
"with",
"octopus",
"handling",
"both",
"paired",
"and",
"tumor",
"-",
"only",
"cases",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L102-L135 | train |
bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _is_umi_consensus_bam | def _is_umi_consensus_bam(in_file):
"""Check if input BAM file generated by fgbio consensus calls on UMIs.
Identify these by lack of duplicated reads.
This is useful for pre-aligned consensus BAMs feeding into octopus.
"""
cmd = "samtools view -h %s | head -500000 | samtools view -c -f 1024"
co... | python | def _is_umi_consensus_bam(in_file):
"""Check if input BAM file generated by fgbio consensus calls on UMIs.
Identify these by lack of duplicated reads.
This is useful for pre-aligned consensus BAMs feeding into octopus.
"""
cmd = "samtools view -h %s | head -500000 | samtools view -c -f 1024"
co... | [
"def",
"_is_umi_consensus_bam",
"(",
"in_file",
")",
":",
"cmd",
"=",
"\"samtools view -h %s | head -500000 | samtools view -c -f 1024\"",
"count",
"=",
"subprocess",
".",
"check_output",
"(",
"cmd",
"%",
"in_file",
",",
"shell",
"=",
"True",
")",
"return",
"int",
"... | Check if input BAM file generated by fgbio consensus calls on UMIs.
Identify these by lack of duplicated reads.
This is useful for pre-aligned consensus BAMs feeding into octopus. | [
"Check",
"if",
"input",
"BAM",
"file",
"generated",
"by",
"fgbio",
"consensus",
"calls",
"on",
"UMIs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L137-L145 | train |
bcbio/bcbio-nextgen | bcbio/upload/s3.py | update_file | def update_file(finfo, sample_info, config):
"""Update the file to an Amazon S3 bucket, using server side encryption.
"""
ffinal = filesystem.update_file(finfo, sample_info, config, pass_uptodate=True)
if os.path.isdir(ffinal):
to_transfer = []
for path, dirs, files in os.walk(ffinal):
... | python | def update_file(finfo, sample_info, config):
"""Update the file to an Amazon S3 bucket, using server side encryption.
"""
ffinal = filesystem.update_file(finfo, sample_info, config, pass_uptodate=True)
if os.path.isdir(ffinal):
to_transfer = []
for path, dirs, files in os.walk(ffinal):
... | [
"def",
"update_file",
"(",
"finfo",
",",
"sample_info",
",",
"config",
")",
":",
"ffinal",
"=",
"filesystem",
".",
"update_file",
"(",
"finfo",
",",
"sample_info",
",",
"config",
",",
"pass_uptodate",
"=",
"True",
")",
"if",
"os",
".",
"path",
".",
"isdi... | Update the file to an Amazon S3 bucket, using server side encryption. | [
"Update",
"the",
"file",
"to",
"an",
"Amazon",
"S3",
"bucket",
"using",
"server",
"side",
"encryption",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/s3.py#L20-L49 | train |
bcbio/bcbio-nextgen | bcbio/upload/s3.py | _upload_file_aws_cli | def _upload_file_aws_cli(local_fname, bucket, keyname, config=None, mditems=None):
"""Streaming upload via the standard AWS command line interface.
"""
s3_fname = "s3://%s/%s" % (bucket, keyname)
args = ["--sse", "--expected-size", str(os.path.getsize(local_fname))]
if config:
if config.get(... | python | def _upload_file_aws_cli(local_fname, bucket, keyname, config=None, mditems=None):
"""Streaming upload via the standard AWS command line interface.
"""
s3_fname = "s3://%s/%s" % (bucket, keyname)
args = ["--sse", "--expected-size", str(os.path.getsize(local_fname))]
if config:
if config.get(... | [
"def",
"_upload_file_aws_cli",
"(",
"local_fname",
",",
"bucket",
",",
"keyname",
",",
"config",
"=",
"None",
",",
"mditems",
"=",
"None",
")",
":",
"s3_fname",
"=",
"\"s3://%s/%s\"",
"%",
"(",
"bucket",
",",
"keyname",
")",
"args",
"=",
"[",
"\"--sse\"",
... | Streaming upload via the standard AWS command line interface. | [
"Streaming",
"upload",
"via",
"the",
"standard",
"AWS",
"command",
"line",
"interface",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/s3.py#L69-L81 | train |
bcbio/bcbio-nextgen | bcbio/upload/s3.py | upload_file_boto | def upload_file_boto(fname, remote_fname, mditems=None):
"""Upload a file using boto instead of external tools.
"""
r_fname = objectstore.parse_remote(remote_fname)
conn = objectstore.connect(remote_fname)
bucket = conn.lookup(r_fname.bucket)
if not bucket:
bucket = conn.create_bucket(r_... | python | def upload_file_boto(fname, remote_fname, mditems=None):
"""Upload a file using boto instead of external tools.
"""
r_fname = objectstore.parse_remote(remote_fname)
conn = objectstore.connect(remote_fname)
bucket = conn.lookup(r_fname.bucket)
if not bucket:
bucket = conn.create_bucket(r_... | [
"def",
"upload_file_boto",
"(",
"fname",
",",
"remote_fname",
",",
"mditems",
"=",
"None",
")",
":",
"r_fname",
"=",
"objectstore",
".",
"parse_remote",
"(",
"remote_fname",
")",
"conn",
"=",
"objectstore",
".",
"connect",
"(",
"remote_fname",
")",
"bucket",
... | Upload a file using boto instead of external tools. | [
"Upload",
"a",
"file",
"using",
"boto",
"instead",
"of",
"external",
"tools",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/s3.py#L83-L98 | train |
bcbio/bcbio-nextgen | bcbio/qc/chipseq.py | run | def run(bam_file, sample, out_dir):
"""Standard QC metrics for chipseq"""
out = {}
# if "rchipqc" in dd.get_tools_on(sample):
# out = chipqc(bam_file, sample, out_dir)
peaks = sample.get("peaks_files", {}).get("main")
if peaks:
out.update(_reads_in_peaks(bam_file, peaks, sample))
... | python | def run(bam_file, sample, out_dir):
"""Standard QC metrics for chipseq"""
out = {}
# if "rchipqc" in dd.get_tools_on(sample):
# out = chipqc(bam_file, sample, out_dir)
peaks = sample.get("peaks_files", {}).get("main")
if peaks:
out.update(_reads_in_peaks(bam_file, peaks, sample))
... | [
"def",
"run",
"(",
"bam_file",
",",
"sample",
",",
"out_dir",
")",
":",
"out",
"=",
"{",
"}",
"# if \"rchipqc\" in dd.get_tools_on(sample):",
"# out = chipqc(bam_file, sample, out_dir)",
"peaks",
"=",
"sample",
".",
"get",
"(",
"\"peaks_files\"",
",",
"{",
"}",
... | Standard QC metrics for chipseq | [
"Standard",
"QC",
"metrics",
"for",
"chipseq"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/chipseq.py#L16-L25 | train |
bcbio/bcbio-nextgen | bcbio/qc/chipseq.py | _reads_in_peaks | def _reads_in_peaks(bam_file, peaks_file, sample):
"""Calculate number of reads in peaks"""
if not peaks_file:
return {}
rip = number_of_mapped_reads(sample, bam_file, bed_file = peaks_file)
return {"metrics": {"RiP": rip}} | python | def _reads_in_peaks(bam_file, peaks_file, sample):
"""Calculate number of reads in peaks"""
if not peaks_file:
return {}
rip = number_of_mapped_reads(sample, bam_file, bed_file = peaks_file)
return {"metrics": {"RiP": rip}} | [
"def",
"_reads_in_peaks",
"(",
"bam_file",
",",
"peaks_file",
",",
"sample",
")",
":",
"if",
"not",
"peaks_file",
":",
"return",
"{",
"}",
"rip",
"=",
"number_of_mapped_reads",
"(",
"sample",
",",
"bam_file",
",",
"bed_file",
"=",
"peaks_file",
")",
"return"... | Calculate number of reads in peaks | [
"Calculate",
"number",
"of",
"reads",
"in",
"peaks"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/chipseq.py#L27-L32 | train |
bcbio/bcbio-nextgen | bcbio/qc/chipseq.py | chipqc | def chipqc(bam_file, sample, out_dir):
"""Attempt code to run ChIPQC bioconductor packate in one sample"""
sample_name = dd.get_sample_name(sample)
logger.warning("ChIPQC is unstable right now, if it breaks, turn off the tool.")
if utils.file_exists(out_dir):
return _get_output(out_dir)
with... | python | def chipqc(bam_file, sample, out_dir):
"""Attempt code to run ChIPQC bioconductor packate in one sample"""
sample_name = dd.get_sample_name(sample)
logger.warning("ChIPQC is unstable right now, if it breaks, turn off the tool.")
if utils.file_exists(out_dir):
return _get_output(out_dir)
with... | [
"def",
"chipqc",
"(",
"bam_file",
",",
"sample",
",",
"out_dir",
")",
":",
"sample_name",
"=",
"dd",
".",
"get_sample_name",
"(",
"sample",
")",
"logger",
".",
"warning",
"(",
"\"ChIPQC is unstable right now, if it breaks, turn off the tool.\"",
")",
"if",
"utils",
... | Attempt code to run ChIPQC bioconductor packate in one sample | [
"Attempt",
"code",
"to",
"run",
"ChIPQC",
"bioconductor",
"packate",
"in",
"one",
"sample"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/chipseq.py#L34-L47 | train |
bcbio/bcbio-nextgen | bcbio/qc/chipseq.py | _sample_template | def _sample_template(sample, out_dir):
"""R code to get QC for one sample"""
bam_fn = dd.get_work_bam(sample)
genome = dd.get_genome_build(sample)
if genome in supported:
peaks = sample.get("peaks_files", []).get("main")
if peaks:
r_code = ("library(ChIPQC);\n"
... | python | def _sample_template(sample, out_dir):
"""R code to get QC for one sample"""
bam_fn = dd.get_work_bam(sample)
genome = dd.get_genome_build(sample)
if genome in supported:
peaks = sample.get("peaks_files", []).get("main")
if peaks:
r_code = ("library(ChIPQC);\n"
... | [
"def",
"_sample_template",
"(",
"sample",
",",
"out_dir",
")",
":",
"bam_fn",
"=",
"dd",
".",
"get_work_bam",
"(",
"sample",
")",
"genome",
"=",
"dd",
".",
"get_genome_build",
"(",
"sample",
")",
"if",
"genome",
"in",
"supported",
":",
"peaks",
"=",
"sam... | R code to get QC for one sample | [
"R",
"code",
"to",
"get",
"QC",
"for",
"one",
"sample"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/chipseq.py#L56-L72 | train |
bcbio/bcbio-nextgen | bcbio/rnaseq/featureCounts.py | _change_sample_name | def _change_sample_name(in_file, sample_name, data=None):
"""Fix name in feature counts log file to get the same
name in multiqc report.
"""
out_file = append_stem(in_file, "_fixed")
with file_transaction(data, out_file) as tx_out:
with open(tx_out, "w") as out_handle:
with op... | python | def _change_sample_name(in_file, sample_name, data=None):
"""Fix name in feature counts log file to get the same
name in multiqc report.
"""
out_file = append_stem(in_file, "_fixed")
with file_transaction(data, out_file) as tx_out:
with open(tx_out, "w") as out_handle:
with op... | [
"def",
"_change_sample_name",
"(",
"in_file",
",",
"sample_name",
",",
"data",
"=",
"None",
")",
":",
"out_file",
"=",
"append_stem",
"(",
"in_file",
",",
"\"_fixed\"",
")",
"with",
"file_transaction",
"(",
"data",
",",
"out_file",
")",
"as",
"tx_out",
":",
... | Fix name in feature counts log file to get the same
name in multiqc report. | [
"Fix",
"name",
"in",
"feature",
"counts",
"log",
"file",
"to",
"get",
"the",
"same",
"name",
"in",
"multiqc",
"report",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/featureCounts.py#L57-L69 | train |
bcbio/bcbio-nextgen | bcbio/rnaseq/featureCounts.py | _format_count_file | def _format_count_file(count_file, data):
"""
this cuts the count file produced from featureCounts down to
a two column file of gene ids and number of reads mapping to
each gene
"""
COUNT_COLUMN = 5
out_file = os.path.splitext(count_file)[0] + ".fixed.counts"
if file_exists(out_file):
... | python | def _format_count_file(count_file, data):
"""
this cuts the count file produced from featureCounts down to
a two column file of gene ids and number of reads mapping to
each gene
"""
COUNT_COLUMN = 5
out_file = os.path.splitext(count_file)[0] + ".fixed.counts"
if file_exists(out_file):
... | [
"def",
"_format_count_file",
"(",
"count_file",
",",
"data",
")",
":",
"COUNT_COLUMN",
"=",
"5",
"out_file",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"count_file",
")",
"[",
"0",
"]",
"+",
"\".fixed.counts\"",
"if",
"file_exists",
"(",
"out_file",
")"... | this cuts the count file produced from featureCounts down to
a two column file of gene ids and number of reads mapping to
each gene | [
"this",
"cuts",
"the",
"count",
"file",
"produced",
"from",
"featureCounts",
"down",
"to",
"a",
"two",
"column",
"file",
"of",
"gene",
"ids",
"and",
"number",
"of",
"reads",
"mapping",
"to",
"each",
"gene"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/featureCounts.py#L71-L86 | train |
bcbio/bcbio-nextgen | bcbio/variation/peddy.py | run_qc | def run_qc(_, data, out_dir):
"""Run quality control in QC environment on a single sample.
Enables peddy integration with CWL runs.
"""
if cwlutils.is_cwl_run(data):
qc_data = run_peddy([data], out_dir)
if tz.get_in(["summary", "qc", "peddy"], qc_data):
return tz.get_in(["su... | python | def run_qc(_, data, out_dir):
"""Run quality control in QC environment on a single sample.
Enables peddy integration with CWL runs.
"""
if cwlutils.is_cwl_run(data):
qc_data = run_peddy([data], out_dir)
if tz.get_in(["summary", "qc", "peddy"], qc_data):
return tz.get_in(["su... | [
"def",
"run_qc",
"(",
"_",
",",
"data",
",",
"out_dir",
")",
":",
"if",
"cwlutils",
".",
"is_cwl_run",
"(",
"data",
")",
":",
"qc_data",
"=",
"run_peddy",
"(",
"[",
"data",
"]",
",",
"out_dir",
")",
"if",
"tz",
".",
"get_in",
"(",
"[",
"\"summary\"... | Run quality control in QC environment on a single sample.
Enables peddy integration with CWL runs. | [
"Run",
"quality",
"control",
"in",
"QC",
"environment",
"on",
"a",
"single",
"sample",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/peddy.py#L35-L43 | train |
bcbio/bcbio-nextgen | bcbio/chipseq/macs2.py | run | def run(name, chip_bam, input_bam, genome_build, out_dir, method, resources, data):
"""
Run macs2 for chip and input samples avoiding
errors due to samples.
"""
# output file name need to have the caller name
config = dd.get_config(data)
out_file = os.path.join(out_dir, name + "_peaks_macs2.... | python | def run(name, chip_bam, input_bam, genome_build, out_dir, method, resources, data):
"""
Run macs2 for chip and input samples avoiding
errors due to samples.
"""
# output file name need to have the caller name
config = dd.get_config(data)
out_file = os.path.join(out_dir, name + "_peaks_macs2.... | [
"def",
"run",
"(",
"name",
",",
"chip_bam",
",",
"input_bam",
",",
"genome_build",
",",
"out_dir",
",",
"method",
",",
"resources",
",",
"data",
")",
":",
"# output file name need to have the caller name",
"config",
"=",
"dd",
".",
"get_config",
"(",
"data",
"... | Run macs2 for chip and input samples avoiding
errors due to samples. | [
"Run",
"macs2",
"for",
"chip",
"and",
"input",
"samples",
"avoiding",
"errors",
"due",
"to",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/macs2.py#L11-L41 | train |
bcbio/bcbio-nextgen | bcbio/chipseq/macs2.py | _macs2_cmd | def _macs2_cmd(method="chip"):
"""Main command for macs2 tool."""
if method.lower() == "chip":
cmd = ("{macs2} callpeak -t {chip_bam} -c {input_bam} {paired} "
" {genome_size} -n {name} -B {options}")
elif method.lower() == "atac":
cmd = ("{macs2} callpeak -t {chip_bam} --nom... | python | def _macs2_cmd(method="chip"):
"""Main command for macs2 tool."""
if method.lower() == "chip":
cmd = ("{macs2} callpeak -t {chip_bam} -c {input_bam} {paired} "
" {genome_size} -n {name} -B {options}")
elif method.lower() == "atac":
cmd = ("{macs2} callpeak -t {chip_bam} --nom... | [
"def",
"_macs2_cmd",
"(",
"method",
"=",
"\"chip\"",
")",
":",
"if",
"method",
".",
"lower",
"(",
")",
"==",
"\"chip\"",
":",
"cmd",
"=",
"(",
"\"{macs2} callpeak -t {chip_bam} -c {input_bam} {paired} \"",
"\" {genome_size} -n {name} -B {options}\"",
")",
"elif",
"met... | Main command for macs2 tool. | [
"Main",
"command",
"for",
"macs2",
"tool",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/macs2.py#L60-L71 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/archive.py | to_cram | def to_cram(data):
"""Convert BAM archive files into indexed CRAM.
"""
data = utils.to_single_data(data)
cram_file = cram.compress(dd.get_work_bam(data) or dd.get_align_bam(data), data)
out_key = "archive_bam" if cwlutils.is_cwl_run(data) else "work_bam"
data[out_key] = cram_file
return [[da... | python | def to_cram(data):
"""Convert BAM archive files into indexed CRAM.
"""
data = utils.to_single_data(data)
cram_file = cram.compress(dd.get_work_bam(data) or dd.get_align_bam(data), data)
out_key = "archive_bam" if cwlutils.is_cwl_run(data) else "work_bam"
data[out_key] = cram_file
return [[da... | [
"def",
"to_cram",
"(",
"data",
")",
":",
"data",
"=",
"utils",
".",
"to_single_data",
"(",
"data",
")",
"cram_file",
"=",
"cram",
".",
"compress",
"(",
"dd",
".",
"get_work_bam",
"(",
"data",
")",
"or",
"dd",
".",
"get_align_bam",
"(",
"data",
")",
"... | Convert BAM archive files into indexed CRAM. | [
"Convert",
"BAM",
"archive",
"files",
"into",
"indexed",
"CRAM",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/archive.py#L11-L18 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/archive.py | compress | def compress(samples, run_parallel):
"""Perform compression of output files for long term storage.
"""
to_cram = []
finished = []
for data in [x[0] for x in samples]:
if "cram" in dd.get_archive(data) or "cram-lossless" in dd.get_archive(data):
to_cram.append([data])
else... | python | def compress(samples, run_parallel):
"""Perform compression of output files for long term storage.
"""
to_cram = []
finished = []
for data in [x[0] for x in samples]:
if "cram" in dd.get_archive(data) or "cram-lossless" in dd.get_archive(data):
to_cram.append([data])
else... | [
"def",
"compress",
"(",
"samples",
",",
"run_parallel",
")",
":",
"to_cram",
"=",
"[",
"]",
"finished",
"=",
"[",
"]",
"for",
"data",
"in",
"[",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"samples",
"]",
":",
"if",
"\"cram\"",
"in",
"dd",
".",
"get_ar... | Perform compression of output files for long term storage. | [
"Perform",
"compression",
"of",
"output",
"files",
"for",
"long",
"term",
"storage",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/archive.py#L20-L31 | train |
bcbio/bcbio-nextgen | bcbio/qc/samtools.py | run | def run(_, data, out_dir=None):
"""Run samtools stats with reports on mapped reads, duplicates and insert sizes.
"""
stats_file, idxstats_file = _get_stats_files(data, out_dir)
samtools = config_utils.get_program("samtools", data["config"])
bam_file = dd.get_align_bam(data) or dd.get_work_bam(data)
... | python | def run(_, data, out_dir=None):
"""Run samtools stats with reports on mapped reads, duplicates and insert sizes.
"""
stats_file, idxstats_file = _get_stats_files(data, out_dir)
samtools = config_utils.get_program("samtools", data["config"])
bam_file = dd.get_align_bam(data) or dd.get_work_bam(data)
... | [
"def",
"run",
"(",
"_",
",",
"data",
",",
"out_dir",
"=",
"None",
")",
":",
"stats_file",
",",
"idxstats_file",
"=",
"_get_stats_files",
"(",
"data",
",",
"out_dir",
")",
"samtools",
"=",
"config_utils",
".",
"get_program",
"(",
"\"samtools\"",
",",
"data"... | Run samtools stats with reports on mapped reads, duplicates and insert sizes. | [
"Run",
"samtools",
"stats",
"with",
"reports",
"on",
"mapped",
"reads",
"duplicates",
"and",
"insert",
"sizes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/samtools.py#L13-L34 | train |
bcbio/bcbio-nextgen | bcbio/qc/samtools.py | run_and_save | def run_and_save(data):
"""Run QC, saving file outputs in data dictionary.
"""
run(None, data)
stats_file, idxstats_file = _get_stats_files(data)
data = tz.update_in(data, ["depth", "samtools", "stats"], lambda x: stats_file)
data = tz.update_in(data, ["depth", "samtools", "idxstats"], lambda x:... | python | def run_and_save(data):
"""Run QC, saving file outputs in data dictionary.
"""
run(None, data)
stats_file, idxstats_file = _get_stats_files(data)
data = tz.update_in(data, ["depth", "samtools", "stats"], lambda x: stats_file)
data = tz.update_in(data, ["depth", "samtools", "idxstats"], lambda x:... | [
"def",
"run_and_save",
"(",
"data",
")",
":",
"run",
"(",
"None",
",",
"data",
")",
"stats_file",
",",
"idxstats_file",
"=",
"_get_stats_files",
"(",
"data",
")",
"data",
"=",
"tz",
".",
"update_in",
"(",
"data",
",",
"[",
"\"depth\"",
",",
"\"samtools\"... | Run QC, saving file outputs in data dictionary. | [
"Run",
"QC",
"saving",
"file",
"outputs",
"in",
"data",
"dictionary",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/samtools.py#L36-L43 | train |
bcbio/bcbio-nextgen | bcbio/qc/samtools.py | _get_stats_files | def _get_stats_files(data, out_dir=None):
"""Retrieve stats files from pre-existing dictionary or filesystem.
"""
if not out_dir:
out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data),
"qc", dd.get_sample_name(data), "samtools"))
stats_... | python | def _get_stats_files(data, out_dir=None):
"""Retrieve stats files from pre-existing dictionary or filesystem.
"""
if not out_dir:
out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data),
"qc", dd.get_sample_name(data), "samtools"))
stats_... | [
"def",
"_get_stats_files",
"(",
"data",
",",
"out_dir",
"=",
"None",
")",
":",
"if",
"not",
"out_dir",
":",
"out_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dd",
".",
"get_work_dir",
"(",
"data",
")",
",",
"\"q... | Retrieve stats files from pre-existing dictionary or filesystem. | [
"Retrieve",
"stats",
"files",
"from",
"pre",
"-",
"existing",
"dictionary",
"or",
"filesystem",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/samtools.py#L45-L57 | train |
bcbio/bcbio-nextgen | bcbio/provenance/do.py | _descr_str | def _descr_str(descr, data, region):
"""Add additional useful information from data to description string.
"""
if data:
name = dd.get_sample_name(data)
if name:
descr = "{0} : {1}".format(descr, name)
elif "work_bam" in data:
descr = "{0} : {1}".format(descr, ... | python | def _descr_str(descr, data, region):
"""Add additional useful information from data to description string.
"""
if data:
name = dd.get_sample_name(data)
if name:
descr = "{0} : {1}".format(descr, name)
elif "work_bam" in data:
descr = "{0} : {1}".format(descr, ... | [
"def",
"_descr_str",
"(",
"descr",
",",
"data",
",",
"region",
")",
":",
"if",
"data",
":",
"name",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"if",
"name",
":",
"descr",
"=",
"\"{0} : {1}\"",
".",
"format",
"(",
"descr",
",",
"name",
")",
... | Add additional useful information from data to description string. | [
"Add",
"additional",
"useful",
"information",
"from",
"data",
"to",
"description",
"string",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/do.py#L35-L46 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | get_indelcaller | def get_indelcaller(d_or_c):
"""Retrieve string for indelcaller to use, or empty string if not specified.
"""
config = d_or_c if isinstance(d_or_c, dict) and "config" in d_or_c else d_or_c
indelcaller = config["algorithm"].get("indelcaller", "")
if not indelcaller:
indelcaller = ""
if is... | python | def get_indelcaller(d_or_c):
"""Retrieve string for indelcaller to use, or empty string if not specified.
"""
config = d_or_c if isinstance(d_or_c, dict) and "config" in d_or_c else d_or_c
indelcaller = config["algorithm"].get("indelcaller", "")
if not indelcaller:
indelcaller = ""
if is... | [
"def",
"get_indelcaller",
"(",
"d_or_c",
")",
":",
"config",
"=",
"d_or_c",
"if",
"isinstance",
"(",
"d_or_c",
",",
"dict",
")",
"and",
"\"config\"",
"in",
"d_or_c",
"else",
"d_or_c",
"indelcaller",
"=",
"config",
"[",
"\"algorithm\"",
"]",
".",
"get",
"("... | Retrieve string for indelcaller to use, or empty string if not specified. | [
"Retrieve",
"string",
"for",
"indelcaller",
"to",
"use",
"or",
"empty",
"string",
"if",
"not",
"specified",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L140-L149 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | split_snps_indels | def split_snps_indels(orig_file, ref_file, config):
"""Split a variant call file into SNPs and INDELs for processing.
"""
base, ext = utils.splitext_plus(orig_file)
snp_file = "{base}-snp{ext}".format(base=base, ext=ext)
indel_file = "{base}-indel{ext}".format(base=base, ext=ext)
for out_file, s... | python | def split_snps_indels(orig_file, ref_file, config):
"""Split a variant call file into SNPs and INDELs for processing.
"""
base, ext = utils.splitext_plus(orig_file)
snp_file = "{base}-snp{ext}".format(base=base, ext=ext)
indel_file = "{base}-indel{ext}".format(base=base, ext=ext)
for out_file, s... | [
"def",
"split_snps_indels",
"(",
"orig_file",
",",
"ref_file",
",",
"config",
")",
":",
"base",
",",
"ext",
"=",
"utils",
".",
"splitext_plus",
"(",
"orig_file",
")",
"snp_file",
"=",
"\"{base}-snp{ext}\"",
".",
"format",
"(",
"base",
"=",
"base",
",",
"ex... | Split a variant call file into SNPs and INDELs for processing. | [
"Split",
"a",
"variant",
"call",
"file",
"into",
"SNPs",
"and",
"INDELs",
"for",
"processing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L183-L199 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | get_samples | def get_samples(in_file):
"""Retrieve samples present in a VCF file
"""
with utils.open_gzipsafe(in_file) as in_handle:
for line in in_handle:
if line.startswith("#CHROM"):
parts = line.strip().split("\t")
return parts[9:]
raise ValueError("Did not fin... | python | def get_samples(in_file):
"""Retrieve samples present in a VCF file
"""
with utils.open_gzipsafe(in_file) as in_handle:
for line in in_handle:
if line.startswith("#CHROM"):
parts = line.strip().split("\t")
return parts[9:]
raise ValueError("Did not fin... | [
"def",
"get_samples",
"(",
"in_file",
")",
":",
"with",
"utils",
".",
"open_gzipsafe",
"(",
"in_file",
")",
"as",
"in_handle",
":",
"for",
"line",
"in",
"in_handle",
":",
"if",
"line",
".",
"startswith",
"(",
"\"#CHROM\"",
")",
":",
"parts",
"=",
"line",... | Retrieve samples present in a VCF file | [
"Retrieve",
"samples",
"present",
"in",
"a",
"VCF",
"file"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L210-L218 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | _get_exclude_samples | def _get_exclude_samples(in_file, to_exclude):
"""Identify samples in the exclusion list which are actually in the VCF.
"""
include, exclude = [], []
to_exclude = set(to_exclude)
for s in get_samples(in_file):
if s in to_exclude:
exclude.append(s)
else:
includ... | python | def _get_exclude_samples(in_file, to_exclude):
"""Identify samples in the exclusion list which are actually in the VCF.
"""
include, exclude = [], []
to_exclude = set(to_exclude)
for s in get_samples(in_file):
if s in to_exclude:
exclude.append(s)
else:
includ... | [
"def",
"_get_exclude_samples",
"(",
"in_file",
",",
"to_exclude",
")",
":",
"include",
",",
"exclude",
"=",
"[",
"]",
",",
"[",
"]",
"to_exclude",
"=",
"set",
"(",
"to_exclude",
")",
"for",
"s",
"in",
"get_samples",
"(",
"in_file",
")",
":",
"if",
"s",... | Identify samples in the exclusion list which are actually in the VCF. | [
"Identify",
"samples",
"in",
"the",
"exclusion",
"list",
"which",
"are",
"actually",
"in",
"the",
"VCF",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L220-L230 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | exclude_samples | def exclude_samples(in_file, out_file, to_exclude, ref_file, config, filters=None):
"""Exclude specific samples from an input VCF file.
"""
include, exclude = _get_exclude_samples(in_file, to_exclude)
# can use the input sample, all exclusions already gone
if len(exclude) == 0:
out_file = in... | python | def exclude_samples(in_file, out_file, to_exclude, ref_file, config, filters=None):
"""Exclude specific samples from an input VCF file.
"""
include, exclude = _get_exclude_samples(in_file, to_exclude)
# can use the input sample, all exclusions already gone
if len(exclude) == 0:
out_file = in... | [
"def",
"exclude_samples",
"(",
"in_file",
",",
"out_file",
",",
"to_exclude",
",",
"ref_file",
",",
"config",
",",
"filters",
"=",
"None",
")",
":",
"include",
",",
"exclude",
"=",
"_get_exclude_samples",
"(",
"in_file",
",",
"to_exclude",
")",
"# can use the ... | Exclude specific samples from an input VCF file. | [
"Exclude",
"specific",
"samples",
"from",
"an",
"input",
"VCF",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L232-L247 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | select_sample | def select_sample(in_file, sample, out_file, config, filters=None):
"""Select a single sample from the supplied multisample VCF file.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
if len(get_samples(in_file)) == 1:
shutil.... | python | def select_sample(in_file, sample, out_file, config, filters=None):
"""Select a single sample from the supplied multisample VCF file.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
if len(get_samples(in_file)) == 1:
shutil.... | [
"def",
"select_sample",
"(",
"in_file",
",",
"sample",
",",
"out_file",
",",
"config",
",",
"filters",
"=",
"None",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"config",
",",
"out_file",
... | Select a single sample from the supplied multisample VCF file. | [
"Select",
"a",
"single",
"sample",
"from",
"the",
"supplied",
"multisample",
"VCF",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L249-L266 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | merge_variant_files | def merge_variant_files(orig_files, out_file, ref_file, config, region=None):
"""Combine multiple VCF files with different samples into a single output file.
Uses bcftools merge on bgzipped input files, handling both tricky merge and
concatenation of files. Does not correctly handle files with the same
... | python | def merge_variant_files(orig_files, out_file, ref_file, config, region=None):
"""Combine multiple VCF files with different samples into a single output file.
Uses bcftools merge on bgzipped input files, handling both tricky merge and
concatenation of files. Does not correctly handle files with the same
... | [
"def",
"merge_variant_files",
"(",
"orig_files",
",",
"out_file",
",",
"ref_file",
",",
"config",
",",
"region",
"=",
"None",
")",
":",
"in_pipeline",
"=",
"False",
"if",
"isinstance",
"(",
"orig_files",
",",
"dict",
")",
":",
"file_key",
"=",
"config",
"[... | Combine multiple VCF files with different samples into a single output file.
Uses bcftools merge on bgzipped input files, handling both tricky merge and
concatenation of files. Does not correctly handle files with the same
sample (use combine_variant_files instead). | [
"Combine",
"multiple",
"VCF",
"files",
"with",
"different",
"samples",
"into",
"a",
"single",
"output",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L288-L304 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | _do_merge | def _do_merge(orig_files, out_file, config, region):
"""Do the actual work of merging with bcftools merge.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
_check_samples_nodups(orig_files)
prep_files = run_multicore(p_bgzip_and_... | python | def _do_merge(orig_files, out_file, config, region):
"""Do the actual work of merging with bcftools merge.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
_check_samples_nodups(orig_files)
prep_files = run_multicore(p_bgzip_and_... | [
"def",
"_do_merge",
"(",
"orig_files",
",",
"out_file",
",",
"config",
",",
"region",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"config",
",",
"out_file",
")",
"as",
"tx_out_file",
":",
... | Do the actual work of merging with bcftools merge. | [
"Do",
"the",
"actual",
"work",
"of",
"merging",
"with",
"bcftools",
"merge",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L306-L324 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | _check_samples_nodups | def _check_samples_nodups(fnames):
"""Ensure a set of input VCFs do not have duplicate samples.
"""
counts = defaultdict(int)
for f in fnames:
for s in get_samples(f):
counts[s] += 1
duplicates = [s for s, c in counts.items() if c > 1]
if duplicates:
raise ValueError(... | python | def _check_samples_nodups(fnames):
"""Ensure a set of input VCFs do not have duplicate samples.
"""
counts = defaultdict(int)
for f in fnames:
for s in get_samples(f):
counts[s] += 1
duplicates = [s for s, c in counts.items() if c > 1]
if duplicates:
raise ValueError(... | [
"def",
"_check_samples_nodups",
"(",
"fnames",
")",
":",
"counts",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"f",
"in",
"fnames",
":",
"for",
"s",
"in",
"get_samples",
"(",
"f",
")",
":",
"counts",
"[",
"s",
"]",
"+=",
"1",
"duplicates",
"=",
"[",
... | Ensure a set of input VCFs do not have duplicate samples. | [
"Ensure",
"a",
"set",
"of",
"input",
"VCFs",
"do",
"not",
"have",
"duplicate",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L326-L335 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | _sort_by_region | def _sort_by_region(fnames, regions, ref_file, config):
"""Sort a set of regionally split files by region for ordered output.
"""
contig_order = {}
for i, sq in enumerate(ref.file_contigs(ref_file, config)):
contig_order[sq.name] = i
sitems = []
assert len(regions) == len(fnames), (regio... | python | def _sort_by_region(fnames, regions, ref_file, config):
"""Sort a set of regionally split files by region for ordered output.
"""
contig_order = {}
for i, sq in enumerate(ref.file_contigs(ref_file, config)):
contig_order[sq.name] = i
sitems = []
assert len(regions) == len(fnames), (regio... | [
"def",
"_sort_by_region",
"(",
"fnames",
",",
"regions",
",",
"ref_file",
",",
"config",
")",
":",
"contig_order",
"=",
"{",
"}",
"for",
"i",
",",
"sq",
"in",
"enumerate",
"(",
"ref",
".",
"file_contigs",
"(",
"ref_file",
",",
"config",
")",
")",
":",
... | Sort a set of regionally split files by region for ordered output. | [
"Sort",
"a",
"set",
"of",
"regionally",
"split",
"files",
"by",
"region",
"for",
"ordered",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L337-L359 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | concat_variant_files | def concat_variant_files(orig_files, out_file, regions, ref_file, config):
"""Concatenate multiple variant files from regions into a single output file.
Uses GATK4's GatherVcfs, falling back to bcftools concat --naive if it fails.
These both only combine samples and avoid parsing, allowing scaling to large... | python | def concat_variant_files(orig_files, out_file, regions, ref_file, config):
"""Concatenate multiple variant files from regions into a single output file.
Uses GATK4's GatherVcfs, falling back to bcftools concat --naive if it fails.
These both only combine samples and avoid parsing, allowing scaling to large... | [
"def",
"concat_variant_files",
"(",
"orig_files",
",",
"out_file",
",",
"regions",
",",
"ref_file",
",",
"config",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"input_file_list",
"=",
"_get_file_list",
"(",
"orig_files",
",",
... | Concatenate multiple variant files from regions into a single output file.
Uses GATK4's GatherVcfs, falling back to bcftools concat --naive if it fails.
These both only combine samples and avoid parsing, allowing scaling to large
file sizes. | [
"Concatenate",
"multiple",
"variant",
"files",
"from",
"regions",
"into",
"a",
"single",
"output",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L361-L381 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | _run_concat_variant_files_gatk4 | def _run_concat_variant_files_gatk4(input_file_list, out_file, config):
"""Use GATK4 GatherVcfs for concatenation of scattered VCFs.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
params = ["-T", "GatherVcfs", "-I", input_file_list, "-O", ... | python | def _run_concat_variant_files_gatk4(input_file_list, out_file, config):
"""Use GATK4 GatherVcfs for concatenation of scattered VCFs.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
params = ["-T", "GatherVcfs", "-I", input_file_list, "-O", ... | [
"def",
"_run_concat_variant_files_gatk4",
"(",
"input_file_list",
",",
"out_file",
",",
"config",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"config",
",",
"out_file",
")",
"as",
"tx_out_file",... | Use GATK4 GatherVcfs for concatenation of scattered VCFs. | [
"Use",
"GATK4",
"GatherVcfs",
"for",
"concatenation",
"of",
"scattered",
"VCFs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L383-L400 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | _get_file_list | def _get_file_list(orig_files, out_file, regions, ref_file, config):
"""Create file with region sorted list of non-empty VCFs for concatenating.
"""
sorted_files = _sort_by_region(orig_files, regions, ref_file, config)
exist_files = [(c, x) for c, x in sorted_files if os.path.exists(x) and vcf_has_varia... | python | def _get_file_list(orig_files, out_file, regions, ref_file, config):
"""Create file with region sorted list of non-empty VCFs for concatenating.
"""
sorted_files = _sort_by_region(orig_files, regions, ref_file, config)
exist_files = [(c, x) for c, x in sorted_files if os.path.exists(x) and vcf_has_varia... | [
"def",
"_get_file_list",
"(",
"orig_files",
",",
"out_file",
",",
"regions",
",",
"ref_file",
",",
"config",
")",
":",
"sorted_files",
"=",
"_sort_by_region",
"(",
"orig_files",
",",
"regions",
",",
"ref_file",
",",
"config",
")",
"exist_files",
"=",
"[",
"(... | Create file with region sorted list of non-empty VCFs for concatenating. | [
"Create",
"file",
"with",
"region",
"sorted",
"list",
"of",
"non",
"-",
"empty",
"VCFs",
"for",
"concatenating",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L402-L418 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | _fix_gatk_header | def _fix_gatk_header(exist_files, out_file, config):
"""Ensure consistent headers for VCF concatenation.
Fixes problems for genomes that start with chrM by reheadering the first file.
These files do haploid variant calling which lack the PID phasing key/value
pair in FORMAT, so initial chrM samples cau... | python | def _fix_gatk_header(exist_files, out_file, config):
"""Ensure consistent headers for VCF concatenation.
Fixes problems for genomes that start with chrM by reheadering the first file.
These files do haploid variant calling which lack the PID phasing key/value
pair in FORMAT, so initial chrM samples cau... | [
"def",
"_fix_gatk_header",
"(",
"exist_files",
",",
"out_file",
",",
"config",
")",
":",
"from",
"bcbio",
".",
"variation",
"import",
"ploidy",
"c",
",",
"base_file",
"=",
"exist_files",
"[",
"0",
"]",
"replace_file",
"=",
"base_file",
"items",
"=",
"[",
"... | Ensure consistent headers for VCF concatenation.
Fixes problems for genomes that start with chrM by reheadering the first file.
These files do haploid variant calling which lack the PID phasing key/value
pair in FORMAT, so initial chrM samples cause errors during concatenation
due to the lack of header... | [
"Ensure",
"consistent",
"headers",
"for",
"VCF",
"concatenation",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L420-L451 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | _run_concat_variant_files_bcftools | def _run_concat_variant_files_bcftools(in_list, out_file, config, naive=False):
"""Concatenate variant files using bcftools concat, potentially using the fast naive option.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
bcftools = config_u... | python | def _run_concat_variant_files_bcftools(in_list, out_file, config, naive=False):
"""Concatenate variant files using bcftools concat, potentially using the fast naive option.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
bcftools = config_u... | [
"def",
"_run_concat_variant_files_bcftools",
"(",
"in_list",
",",
"out_file",
",",
"config",
",",
"naive",
"=",
"False",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"config",
",",
"out_file",
... | Concatenate variant files using bcftools concat, potentially using the fast naive option. | [
"Concatenate",
"variant",
"files",
"using",
"bcftools",
"concat",
"potentially",
"using",
"the",
"fast",
"naive",
"option",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L465-L480 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | combine_variant_files | def combine_variant_files(orig_files, out_file, ref_file, config,
quiet_out=True, region=None):
"""Combine VCF files from the same sample into a single output file.
Handles cases where we split files into SNPs/Indels for processing then
need to merge back into a final file.
""... | python | def combine_variant_files(orig_files, out_file, ref_file, config,
quiet_out=True, region=None):
"""Combine VCF files from the same sample into a single output file.
Handles cases where we split files into SNPs/Indels for processing then
need to merge back into a final file.
""... | [
"def",
"combine_variant_files",
"(",
"orig_files",
",",
"out_file",
",",
"ref_file",
",",
"config",
",",
"quiet_out",
"=",
"True",
",",
"region",
"=",
"None",
")",
":",
"in_pipeline",
"=",
"False",
"if",
"isinstance",
"(",
"orig_files",
",",
"dict",
")",
"... | Combine VCF files from the same sample into a single output file.
Handles cases where we split files into SNPs/Indels for processing then
need to merge back into a final file. | [
"Combine",
"VCF",
"files",
"from",
"the",
"same",
"sample",
"into",
"a",
"single",
"output",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L482-L511 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | sort_by_ref | def sort_by_ref(vcf_file, data):
"""Sort a VCF file by genome reference and position, adding contig information.
"""
out_file = "%s-prep.vcf.gz" % utils.splitext_plus(vcf_file)[0]
if not utils.file_uptodate(out_file, vcf_file):
with file_transaction(data, out_file) as tx_out_file:
he... | python | def sort_by_ref(vcf_file, data):
"""Sort a VCF file by genome reference and position, adding contig information.
"""
out_file = "%s-prep.vcf.gz" % utils.splitext_plus(vcf_file)[0]
if not utils.file_uptodate(out_file, vcf_file):
with file_transaction(data, out_file) as tx_out_file:
he... | [
"def",
"sort_by_ref",
"(",
"vcf_file",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-prep.vcf.gz\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"vcf_file",
")",
"[",
"0",
"]",
"if",
"not",
"utils",
".",
"file_uptodate",
"(",
"out_file",
",",
"vcf_file",
")",... | Sort a VCF file by genome reference and position, adding contig information. | [
"Sort",
"a",
"VCF",
"file",
"by",
"genome",
"reference",
"and",
"position",
"adding",
"contig",
"information",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L513-L528 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | add_contig_to_header | def add_contig_to_header(line, ref_file):
"""Streaming target to add contigs to a VCF file header.
"""
if line.startswith("##fileformat=VCF"):
out = [line]
for region in ref.file_contigs(ref_file):
out.append("##contig=<ID=%s,length=%s>" % (region.name, region.size))
retu... | python | def add_contig_to_header(line, ref_file):
"""Streaming target to add contigs to a VCF file header.
"""
if line.startswith("##fileformat=VCF"):
out = [line]
for region in ref.file_contigs(ref_file):
out.append("##contig=<ID=%s,length=%s>" % (region.name, region.size))
retu... | [
"def",
"add_contig_to_header",
"(",
"line",
",",
"ref_file",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"\"##fileformat=VCF\"",
")",
":",
"out",
"=",
"[",
"line",
"]",
"for",
"region",
"in",
"ref",
".",
"file_contigs",
"(",
"ref_file",
")",
":",
"ou... | Streaming target to add contigs to a VCF file header. | [
"Streaming",
"target",
"to",
"add",
"contigs",
"to",
"a",
"VCF",
"file",
"header",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L539-L548 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | parallel_combine_variants | def parallel_combine_variants(orig_files, out_file, ref_file, config, run_parallel):
"""Combine variants in parallel by chromosome, concatenating final outputs.
"""
file_key = "vcf_files"
def split_by_region(data):
base, ext = utils.splitext_plus(os.path.basename(out_file))
args = []
... | python | def parallel_combine_variants(orig_files, out_file, ref_file, config, run_parallel):
"""Combine variants in parallel by chromosome, concatenating final outputs.
"""
file_key = "vcf_files"
def split_by_region(data):
base, ext = utils.splitext_plus(os.path.basename(out_file))
args = []
... | [
"def",
"parallel_combine_variants",
"(",
"orig_files",
",",
"out_file",
",",
"ref_file",
",",
"config",
",",
"run_parallel",
")",
":",
"file_key",
"=",
"\"vcf_files\"",
"def",
"split_by_region",
"(",
"data",
")",
":",
"base",
",",
"ext",
"=",
"utils",
".",
"... | Combine variants in parallel by chromosome, concatenating final outputs. | [
"Combine",
"variants",
"in",
"parallel",
"by",
"chromosome",
"concatenating",
"final",
"outputs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L552-L572 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | move_vcf | def move_vcf(orig_file, new_file):
"""Move a VCF file with associated index.
"""
for ext in ["", ".idx", ".tbi"]:
to_move = orig_file + ext
if os.path.exists(to_move):
shutil.move(to_move, new_file + ext) | python | def move_vcf(orig_file, new_file):
"""Move a VCF file with associated index.
"""
for ext in ["", ".idx", ".tbi"]:
to_move = orig_file + ext
if os.path.exists(to_move):
shutil.move(to_move, new_file + ext) | [
"def",
"move_vcf",
"(",
"orig_file",
",",
"new_file",
")",
":",
"for",
"ext",
"in",
"[",
"\"\"",
",",
"\".idx\"",
",",
"\".tbi\"",
"]",
":",
"to_move",
"=",
"orig_file",
"+",
"ext",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"to_move",
")",
":",
... | Move a VCF file with associated index. | [
"Move",
"a",
"VCF",
"file",
"with",
"associated",
"index",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L576-L582 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | bgzip_and_index | def bgzip_and_index(in_file, config=None, remove_orig=True, prep_cmd="", tabix_args=None, out_dir=None):
"""bgzip and tabix index an input file, handling VCF and BED.
"""
if config is None:
config = {}
out_file = in_file if in_file.endswith(".gz") else in_file + ".gz"
if out_dir:
rem... | python | def bgzip_and_index(in_file, config=None, remove_orig=True, prep_cmd="", tabix_args=None, out_dir=None):
"""bgzip and tabix index an input file, handling VCF and BED.
"""
if config is None:
config = {}
out_file = in_file if in_file.endswith(".gz") else in_file + ".gz"
if out_dir:
rem... | [
"def",
"bgzip_and_index",
"(",
"in_file",
",",
"config",
"=",
"None",
",",
"remove_orig",
"=",
"True",
",",
"prep_cmd",
"=",
"\"\"",
",",
"tabix_args",
"=",
"None",
",",
"out_dir",
"=",
"None",
")",
":",
"if",
"config",
"is",
"None",
":",
"config",
"="... | bgzip and tabix index an input file, handling VCF and BED. | [
"bgzip",
"and",
"tabix",
"index",
"an",
"input",
"file",
"handling",
"VCF",
"and",
"BED",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L584-L616 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | tabix_index | def tabix_index(in_file, config, preset=None, tabix_args=None):
"""Index a file using tabix.
"""
in_file = os.path.abspath(in_file)
out_file = in_file + ".tbi"
if not utils.file_exists(out_file) or not utils.file_uptodate(out_file, in_file):
# Remove old index files to prevent linking into t... | python | def tabix_index(in_file, config, preset=None, tabix_args=None):
"""Index a file using tabix.
"""
in_file = os.path.abspath(in_file)
out_file = in_file + ".tbi"
if not utils.file_exists(out_file) or not utils.file_uptodate(out_file, in_file):
# Remove old index files to prevent linking into t... | [
"def",
"tabix_index",
"(",
"in_file",
",",
"config",
",",
"preset",
"=",
"None",
",",
"tabix_args",
"=",
"None",
")",
":",
"in_file",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"in_file",
")",
"out_file",
"=",
"in_file",
"+",
"\".tbi\"",
"if",
"not",... | Index a file using tabix. | [
"Index",
"a",
"file",
"using",
"tabix",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L635-L653 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | is_gvcf_file | def is_gvcf_file(in_file):
"""Check if an input file is raw gVCF
"""
to_check = 100
n = 0
with utils.open_gzipsafe(in_file) as in_handle:
for line in in_handle:
if not line.startswith("##"):
if n > to_check:
break
n += 1
... | python | def is_gvcf_file(in_file):
"""Check if an input file is raw gVCF
"""
to_check = 100
n = 0
with utils.open_gzipsafe(in_file) as in_handle:
for line in in_handle:
if not line.startswith("##"):
if n > to_check:
break
n += 1
... | [
"def",
"is_gvcf_file",
"(",
"in_file",
")",
":",
"to_check",
"=",
"100",
"n",
"=",
"0",
"with",
"utils",
".",
"open_gzipsafe",
"(",
"in_file",
")",
"as",
"in_handle",
":",
"for",
"line",
"in",
"in_handle",
":",
"if",
"not",
"line",
".",
"startswith",
"... | Check if an input file is raw gVCF | [
"Check",
"if",
"an",
"input",
"file",
"is",
"raw",
"gVCF"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L655-L678 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | cyvcf_add_filter | def cyvcf_add_filter(rec, name):
"""Add a FILTER value to a cyvcf2 record
"""
if rec.FILTER:
filters = rec.FILTER.split(";")
else:
filters = []
if name not in filters:
filters.append(name)
rec.FILTER = filters
return rec | python | def cyvcf_add_filter(rec, name):
"""Add a FILTER value to a cyvcf2 record
"""
if rec.FILTER:
filters = rec.FILTER.split(";")
else:
filters = []
if name not in filters:
filters.append(name)
rec.FILTER = filters
return rec | [
"def",
"cyvcf_add_filter",
"(",
"rec",
",",
"name",
")",
":",
"if",
"rec",
".",
"FILTER",
":",
"filters",
"=",
"rec",
".",
"FILTER",
".",
"split",
"(",
"\";\"",
")",
"else",
":",
"filters",
"=",
"[",
"]",
"if",
"name",
"not",
"in",
"filters",
":",
... | Add a FILTER value to a cyvcf2 record | [
"Add",
"a",
"FILTER",
"value",
"to",
"a",
"cyvcf2",
"record"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L680-L690 | train |
bcbio/bcbio-nextgen | bcbio/variation/vcfutils.py | cyvcf_remove_filter | def cyvcf_remove_filter(rec, name):
"""Remove filter with the given name from a cyvcf2 record
"""
if rec.FILTER:
filters = rec.FILTER.split(";")
else:
filters = []
new_filters = [x for x in filters if not str(x) == name]
if len(new_filters) == 0:
new_filters = ["PASS"]
... | python | def cyvcf_remove_filter(rec, name):
"""Remove filter with the given name from a cyvcf2 record
"""
if rec.FILTER:
filters = rec.FILTER.split(";")
else:
filters = []
new_filters = [x for x in filters if not str(x) == name]
if len(new_filters) == 0:
new_filters = ["PASS"]
... | [
"def",
"cyvcf_remove_filter",
"(",
"rec",
",",
"name",
")",
":",
"if",
"rec",
".",
"FILTER",
":",
"filters",
"=",
"rec",
".",
"FILTER",
".",
"split",
"(",
"\";\"",
")",
"else",
":",
"filters",
"=",
"[",
"]",
"new_filters",
"=",
"[",
"x",
"for",
"x"... | Remove filter with the given name from a cyvcf2 record | [
"Remove",
"filter",
"with",
"the",
"given",
"name",
"from",
"a",
"cyvcf2",
"record"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vcfutils.py#L692-L703 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/alignment.py | organize_noalign | def organize_noalign(data):
"""CWL target to skip alignment and organize input data.
"""
data = utils.to_single_data(data[0])
work_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data), "align", dd.get_sample_name(data)))
work_bam = os.path.join(work_dir, "%s-input.bam" % dd.get_sample_name(da... | python | def organize_noalign(data):
"""CWL target to skip alignment and organize input data.
"""
data = utils.to_single_data(data[0])
work_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data), "align", dd.get_sample_name(data)))
work_bam = os.path.join(work_dir, "%s-input.bam" % dd.get_sample_name(da... | [
"def",
"organize_noalign",
"(",
"data",
")",
":",
"data",
"=",
"utils",
".",
"to_single_data",
"(",
"data",
"[",
"0",
"]",
")",
"work_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dd",
".",
"get_work_dir",
"(",
"... | CWL target to skip alignment and organize input data. | [
"CWL",
"target",
"to",
"skip",
"alignment",
"and",
"organize",
"input",
"data",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/alignment.py#L53-L69 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/alignment.py | align_to_sort_bam | def align_to_sort_bam(fastq1, fastq2, aligner, data):
"""Align to the named genome build, returning a sorted BAM file.
"""
names = data["rgnames"]
align_dir_parts = [data["dirs"]["work"], "align", names["sample"]]
if data.get("disambiguate"):
align_dir_parts.append(data["disambiguate"]["geno... | python | def align_to_sort_bam(fastq1, fastq2, aligner, data):
"""Align to the named genome build, returning a sorted BAM file.
"""
names = data["rgnames"]
align_dir_parts = [data["dirs"]["work"], "align", names["sample"]]
if data.get("disambiguate"):
align_dir_parts.append(data["disambiguate"]["geno... | [
"def",
"align_to_sort_bam",
"(",
"fastq1",
",",
"fastq2",
",",
"aligner",
",",
"data",
")",
":",
"names",
"=",
"data",
"[",
"\"rgnames\"",
"]",
"align_dir_parts",
"=",
"[",
"data",
"[",
"\"dirs\"",
"]",
"[",
"\"work\"",
"]",
",",
"\"align\"",
",",
"names... | Align to the named genome build, returning a sorted BAM file. | [
"Align",
"to",
"the",
"named",
"genome",
"build",
"returning",
"a",
"sorted",
"BAM",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/alignment.py#L71-L98 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/alignment.py | get_aligner_with_aliases | def get_aligner_with_aliases(aligner, data):
"""Retrieve aligner index retriever, including aliases for shared.
Handles tricky cases like gridss where we need bwa indices even with
no aligner specified since they're used internally within GRIDSS.
"""
aligner_aliases = {"sentieon-bwa": "bwa"}
fr... | python | def get_aligner_with_aliases(aligner, data):
"""Retrieve aligner index retriever, including aliases for shared.
Handles tricky cases like gridss where we need bwa indices even with
no aligner specified since they're used internally within GRIDSS.
"""
aligner_aliases = {"sentieon-bwa": "bwa"}
fr... | [
"def",
"get_aligner_with_aliases",
"(",
"aligner",
",",
"data",
")",
":",
"aligner_aliases",
"=",
"{",
"\"sentieon-bwa\"",
":",
"\"bwa\"",
"}",
"from",
"bcbio",
"import",
"structural",
"if",
"not",
"aligner",
"and",
"\"gridss\"",
"in",
"structural",
".",
"get_sv... | Retrieve aligner index retriever, including aliases for shared.
Handles tricky cases like gridss where we need bwa indices even with
no aligner specified since they're used internally within GRIDSS. | [
"Retrieve",
"aligner",
"index",
"retriever",
"including",
"aliases",
"for",
"shared",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/alignment.py#L100-L110 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/alignment.py | _get_aligner_index | def _get_aligner_index(aligner, data):
"""Handle multiple specifications of aligner indexes, returning value to pass to aligner.
Original bcbio case -- a list of indices.
CWL case: a single file with secondaryFiles staged in the same directory.
"""
aligner_indexes = tz.get_in(("reference", get_alig... | python | def _get_aligner_index(aligner, data):
"""Handle multiple specifications of aligner indexes, returning value to pass to aligner.
Original bcbio case -- a list of indices.
CWL case: a single file with secondaryFiles staged in the same directory.
"""
aligner_indexes = tz.get_in(("reference", get_alig... | [
"def",
"_get_aligner_index",
"(",
"aligner",
",",
"data",
")",
":",
"aligner_indexes",
"=",
"tz",
".",
"get_in",
"(",
"(",
"\"reference\"",
",",
"get_aligner_with_aliases",
"(",
"aligner",
",",
"data",
")",
",",
"\"indexes\"",
")",
",",
"data",
")",
"# stand... | Handle multiple specifications of aligner indexes, returning value to pass to aligner.
Original bcbio case -- a list of indices.
CWL case: a single file with secondaryFiles staged in the same directory. | [
"Handle",
"multiple",
"specifications",
"of",
"aligner",
"indexes",
"returning",
"value",
"to",
"pass",
"to",
"aligner",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/alignment.py#L115-L139 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/alignment.py | _align_from_fastq | def _align_from_fastq(fastq1, fastq2, aligner, align_ref, sam_ref, names,
align_dir, data):
"""Align from fastq inputs, producing sorted BAM output.
"""
config = data["config"]
align_fn = TOOLS[aligner].align_fn
out = align_fn(fastq1, fastq2, align_ref, names, align_dir, data)
... | python | def _align_from_fastq(fastq1, fastq2, aligner, align_ref, sam_ref, names,
align_dir, data):
"""Align from fastq inputs, producing sorted BAM output.
"""
config = data["config"]
align_fn = TOOLS[aligner].align_fn
out = align_fn(fastq1, fastq2, align_ref, names, align_dir, data)
... | [
"def",
"_align_from_fastq",
"(",
"fastq1",
",",
"fastq2",
",",
"aligner",
",",
"align_ref",
",",
"sam_ref",
",",
"names",
",",
"align_dir",
",",
"data",
")",
":",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"align_fn",
"=",
"TOOLS",
"[",
"aligner",
"]... | Align from fastq inputs, producing sorted BAM output. | [
"Align",
"from",
"fastq",
"inputs",
"producing",
"sorted",
"BAM",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/alignment.py#L155-L170 | train |
bcbio/bcbio-nextgen | bcbio/structural/gridss.py | _finalize_memory | def _finalize_memory(jvm_opts):
"""GRIDSS does not recommend setting memory between 32 and 48Gb.
https://github.com/PapenfussLab/gridss#memory-usage
"""
avoid_min = 32
avoid_max = 48
out_opts = []
for opt in jvm_opts:
if opt.startswith("-Xmx"):
spec = opt[4:]
... | python | def _finalize_memory(jvm_opts):
"""GRIDSS does not recommend setting memory between 32 and 48Gb.
https://github.com/PapenfussLab/gridss#memory-usage
"""
avoid_min = 32
avoid_max = 48
out_opts = []
for opt in jvm_opts:
if opt.startswith("-Xmx"):
spec = opt[4:]
... | [
"def",
"_finalize_memory",
"(",
"jvm_opts",
")",
":",
"avoid_min",
"=",
"32",
"avoid_max",
"=",
"48",
"out_opts",
"=",
"[",
"]",
"for",
"opt",
"in",
"jvm_opts",
":",
"if",
"opt",
".",
"startswith",
"(",
"\"-Xmx\"",
")",
":",
"spec",
"=",
"opt",
"[",
... | GRIDSS does not recommend setting memory between 32 and 48Gb.
https://github.com/PapenfussLab/gridss#memory-usage | [
"GRIDSS",
"does",
"not",
"recommend",
"setting",
"memory",
"between",
"32",
"and",
"48Gb",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/gridss.py#L70-L94 | train |
bcbio/bcbio-nextgen | bcbio/structural/gridss.py | _setup_reference_files | def _setup_reference_files(data, tx_out_dir):
"""Create a reference directory with fasta and bwa indices.
GRIDSS requires all files in a single directory, so setup with symlinks.
This needs bwa aligner indices available, which we ensure with `get_aligner_with_aliases`
during YAML sample setup.
"""
... | python | def _setup_reference_files(data, tx_out_dir):
"""Create a reference directory with fasta and bwa indices.
GRIDSS requires all files in a single directory, so setup with symlinks.
This needs bwa aligner indices available, which we ensure with `get_aligner_with_aliases`
during YAML sample setup.
"""
... | [
"def",
"_setup_reference_files",
"(",
"data",
",",
"tx_out_dir",
")",
":",
"aligner",
"=",
"dd",
".",
"get_aligner",
"(",
"data",
")",
"or",
"\"bwa\"",
"out_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"tx_out_dir",
... | Create a reference directory with fasta and bwa indices.
GRIDSS requires all files in a single directory, so setup with symlinks.
This needs bwa aligner indices available, which we ensure with `get_aligner_with_aliases`
during YAML sample setup. | [
"Create",
"a",
"reference",
"directory",
"with",
"fasta",
"and",
"bwa",
"indices",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/gridss.py#L96-L109 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _add_versions | def _add_versions(samples):
"""Add tool and data versions to the summary.
"""
samples[0]["versions"] = {"tools": programs.write_versions(samples[0]["dirs"], samples[0]["config"]),
"data": provenancedata.write_versions(samples[0]["dirs"], samples)}
return samples | python | def _add_versions(samples):
"""Add tool and data versions to the summary.
"""
samples[0]["versions"] = {"tools": programs.write_versions(samples[0]["dirs"], samples[0]["config"]),
"data": provenancedata.write_versions(samples[0]["dirs"], samples)}
return samples | [
"def",
"_add_versions",
"(",
"samples",
")",
":",
"samples",
"[",
"0",
"]",
"[",
"\"versions\"",
"]",
"=",
"{",
"\"tools\"",
":",
"programs",
".",
"write_versions",
"(",
"samples",
"[",
"0",
"]",
"[",
"\"dirs\"",
"]",
",",
"samples",
"[",
"0",
"]",
"... | Add tool and data versions to the summary. | [
"Add",
"tool",
"and",
"data",
"versions",
"to",
"the",
"summary",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L109-L114 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _summarize_inputs | def _summarize_inputs(samples, out_dir):
"""Summarize inputs for MultiQC reporting in display.
"""
logger.info("summarize target information")
if samples[0].get("analysis", "").lower() in ["variant", "variant2"]:
metrics_dir = utils.safe_makedir(os.path.join(out_dir, "report", "metrics"))
... | python | def _summarize_inputs(samples, out_dir):
"""Summarize inputs for MultiQC reporting in display.
"""
logger.info("summarize target information")
if samples[0].get("analysis", "").lower() in ["variant", "variant2"]:
metrics_dir = utils.safe_makedir(os.path.join(out_dir, "report", "metrics"))
... | [
"def",
"_summarize_inputs",
"(",
"samples",
",",
"out_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"summarize target information\"",
")",
"if",
"samples",
"[",
"0",
"]",
".",
"get",
"(",
"\"analysis\"",
",",
"\"\"",
")",
".",
"lower",
"(",
")",
"in",
"[... | Summarize inputs for MultiQC reporting in display. | [
"Summarize",
"inputs",
"for",
"MultiQC",
"reporting",
"in",
"display",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L116-L135 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _work_path_to_rel_final_path | def _work_path_to_rel_final_path(path, upload_path_mapping, upload_base_dir):
""" Check if `path` is a work-rooted path, and convert to a relative final-rooted path
"""
if not path or not isinstance(path, str):
return path
upload_path = None
# First, check in the mapping: if it's there is a... | python | def _work_path_to_rel_final_path(path, upload_path_mapping, upload_base_dir):
""" Check if `path` is a work-rooted path, and convert to a relative final-rooted path
"""
if not path or not isinstance(path, str):
return path
upload_path = None
# First, check in the mapping: if it's there is a... | [
"def",
"_work_path_to_rel_final_path",
"(",
"path",
",",
"upload_path_mapping",
",",
"upload_base_dir",
")",
":",
"if",
"not",
"path",
"or",
"not",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"return",
"path",
"upload_path",
"=",
"None",
"# First, check in ... | Check if `path` is a work-rooted path, and convert to a relative final-rooted path | [
"Check",
"if",
"path",
"is",
"a",
"work",
"-",
"rooted",
"path",
"and",
"convert",
"to",
"a",
"relative",
"final",
"-",
"rooted",
"path"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L195-L222 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _one_exists | def _one_exists(input_files):
"""
at least one file must exist for multiqc to run properly
"""
for f in input_files:
if os.path.exists(f):
return True
return False | python | def _one_exists(input_files):
"""
at least one file must exist for multiqc to run properly
"""
for f in input_files:
if os.path.exists(f):
return True
return False | [
"def",
"_one_exists",
"(",
"input_files",
")",
":",
"for",
"f",
"in",
"input_files",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"f",
")",
":",
"return",
"True",
"return",
"False"
] | at least one file must exist for multiqc to run properly | [
"at",
"least",
"one",
"file",
"must",
"exist",
"for",
"multiqc",
"to",
"run",
"properly"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L224-L231 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _get_input_files | def _get_input_files(samples, base_dir, tx_out_dir):
"""Retrieve input files, keyed by sample and QC method name.
Stages files into the work directory to ensure correct names for
MultiQC sample assessment when running with CWL.
"""
in_files = collections.defaultdict(list)
for data in samples:
... | python | def _get_input_files(samples, base_dir, tx_out_dir):
"""Retrieve input files, keyed by sample and QC method name.
Stages files into the work directory to ensure correct names for
MultiQC sample assessment when running with CWL.
"""
in_files = collections.defaultdict(list)
for data in samples:
... | [
"def",
"_get_input_files",
"(",
"samples",
",",
"base_dir",
",",
"tx_out_dir",
")",
":",
"in_files",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"data",
"in",
"samples",
":",
"sum_qc",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"summary\"",... | Retrieve input files, keyed by sample and QC method name.
Stages files into the work directory to ensure correct names for
MultiQC sample assessment when running with CWL. | [
"Retrieve",
"input",
"files",
"keyed",
"by",
"sample",
"and",
"QC",
"method",
"name",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L233-L276 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _group_by_sample_and_batch | def _group_by_sample_and_batch(samples):
"""Group samples split by QC method back one per sample-batch.
"""
out = collections.defaultdict(list)
for data in samples:
out[(dd.get_sample_name(data), dd.get_align_bam(data), tuple(_get_batches(data)))].append(data)
return [xs[0] for xs in out.val... | python | def _group_by_sample_and_batch(samples):
"""Group samples split by QC method back one per sample-batch.
"""
out = collections.defaultdict(list)
for data in samples:
out[(dd.get_sample_name(data), dd.get_align_bam(data), tuple(_get_batches(data)))].append(data)
return [xs[0] for xs in out.val... | [
"def",
"_group_by_sample_and_batch",
"(",
"samples",
")",
":",
"out",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"data",
"in",
"samples",
":",
"out",
"[",
"(",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
",",
"dd",
".",
"get_ali... | Group samples split by QC method back one per sample-batch. | [
"Group",
"samples",
"split",
"by",
"QC",
"method",
"back",
"one",
"per",
"sample",
"-",
"batch",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L287-L293 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _has_bcftools_germline_stats | def _has_bcftools_germline_stats(data):
"""Check for the presence of a germline stats file, CWL compatible.
"""
stats_file = tz.get_in(["summary", "qc"], data)
if isinstance(stats_file, dict):
stats_file = tz.get_in(["variants", "base"], stats_file)
if not stats_file:
stats_file = ""... | python | def _has_bcftools_germline_stats(data):
"""Check for the presence of a germline stats file, CWL compatible.
"""
stats_file = tz.get_in(["summary", "qc"], data)
if isinstance(stats_file, dict):
stats_file = tz.get_in(["variants", "base"], stats_file)
if not stats_file:
stats_file = ""... | [
"def",
"_has_bcftools_germline_stats",
"(",
"data",
")",
":",
"stats_file",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"summary\"",
",",
"\"qc\"",
"]",
",",
"data",
")",
"if",
"isinstance",
"(",
"stats_file",
",",
"dict",
")",
":",
"stats_file",
"=",
"tz",
".... | Check for the presence of a germline stats file, CWL compatible. | [
"Check",
"for",
"the",
"presence",
"of",
"a",
"germline",
"stats",
"file",
"CWL",
"compatible",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L397-L405 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _is_good_file_for_multiqc | def _is_good_file_for_multiqc(fpath):
"""Returns False if the file is binary or image."""
# Use mimetypes to exclude binary files where possible
(ftype, encoding) = mimetypes.guess_type(fpath)
if encoding is not None:
return False
if ftype is not None and ftype.startswith('image'):
r... | python | def _is_good_file_for_multiqc(fpath):
"""Returns False if the file is binary or image."""
# Use mimetypes to exclude binary files where possible
(ftype, encoding) = mimetypes.guess_type(fpath)
if encoding is not None:
return False
if ftype is not None and ftype.startswith('image'):
r... | [
"def",
"_is_good_file_for_multiqc",
"(",
"fpath",
")",
":",
"# Use mimetypes to exclude binary files where possible",
"(",
"ftype",
",",
"encoding",
")",
"=",
"mimetypes",
".",
"guess_type",
"(",
"fpath",
")",
"if",
"encoding",
"is",
"not",
"None",
":",
"return",
... | Returns False if the file is binary or image. | [
"Returns",
"False",
"if",
"the",
"file",
"is",
"binary",
"or",
"image",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L414-L422 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _parse_disambiguate | def _parse_disambiguate(disambiguatestatsfilename):
"""Parse disambiguation stats from given file.
"""
disambig_stats = [0, 0, 0]
with open(disambiguatestatsfilename, "r") as in_handle:
for i, line in enumerate(in_handle):
fields = line.strip().split("\t")
if i == 0:
... | python | def _parse_disambiguate(disambiguatestatsfilename):
"""Parse disambiguation stats from given file.
"""
disambig_stats = [0, 0, 0]
with open(disambiguatestatsfilename, "r") as in_handle:
for i, line in enumerate(in_handle):
fields = line.strip().split("\t")
if i == 0:
... | [
"def",
"_parse_disambiguate",
"(",
"disambiguatestatsfilename",
")",
":",
"disambig_stats",
"=",
"[",
"0",
",",
"0",
",",
"0",
"]",
"with",
"open",
"(",
"disambiguatestatsfilename",
",",
"\"r\"",
")",
"as",
"in_handle",
":",
"for",
"i",
",",
"line",
"in",
... | Parse disambiguation stats from given file. | [
"Parse",
"disambiguation",
"stats",
"from",
"given",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L424-L435 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _merge_metrics | def _merge_metrics(samples, out_dir):
"""Merge metrics from multiple QC steps
"""
logger.info("summarize metrics")
out_dir = utils.safe_makedir(os.path.join(out_dir, "report", "metrics"))
sample_metrics = collections.defaultdict(dict)
for s in samples:
s = _add_disambiguate(s)
m ... | python | def _merge_metrics(samples, out_dir):
"""Merge metrics from multiple QC steps
"""
logger.info("summarize metrics")
out_dir = utils.safe_makedir(os.path.join(out_dir, "report", "metrics"))
sample_metrics = collections.defaultdict(dict)
for s in samples:
s = _add_disambiguate(s)
m ... | [
"def",
"_merge_metrics",
"(",
"samples",
",",
"out_dir",
")",
":",
"logger",
".",
"info",
"(",
"\"summarize metrics\"",
")",
"out_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"\"report\"",
",",
"\"metri... | Merge metrics from multiple QC steps | [
"Merge",
"metrics",
"from",
"multiple",
"QC",
"steps"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L456-L484 | train |
bcbio/bcbio-nextgen | bcbio/qc/multiqc.py | _merge_fastqc | def _merge_fastqc(samples):
"""
merge all fastqc samples into one by module
"""
fastqc_list = collections.defaultdict(list)
seen = set()
for data in samples:
name = dd.get_sample_name(data)
if name in seen:
continue
seen.add(name)
fns = glob.glob(os.pa... | python | def _merge_fastqc(samples):
"""
merge all fastqc samples into one by module
"""
fastqc_list = collections.defaultdict(list)
seen = set()
for data in samples:
name = dd.get_sample_name(data)
if name in seen:
continue
seen.add(name)
fns = glob.glob(os.pa... | [
"def",
"_merge_fastqc",
"(",
"samples",
")",
":",
"fastqc_list",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"seen",
"=",
"set",
"(",
")",
"for",
"data",
"in",
"samples",
":",
"name",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"... | merge all fastqc samples into one by module | [
"merge",
"all",
"fastqc",
"samples",
"into",
"one",
"by",
"module"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/multiqc.py#L486-L511 | train |
bcbio/bcbio-nextgen | scripts/utils/hla_loh_comparison.py | _create_plot | def _create_plot(tumor, in_glob, out_ext, page=1):
"""Create an output plot for the given PDF in the images directory.
"""
out_dir = utils.safe_makedir("images")
out_name = os.path.join(out_dir, "%s-%s" % (tumor, out_ext))
in_file = glob.glob(in_glob)[0]
cmd = ["pdftoppm", in_file, out_name, "-p... | python | def _create_plot(tumor, in_glob, out_ext, page=1):
"""Create an output plot for the given PDF in the images directory.
"""
out_dir = utils.safe_makedir("images")
out_name = os.path.join(out_dir, "%s-%s" % (tumor, out_ext))
in_file = glob.glob(in_glob)[0]
cmd = ["pdftoppm", in_file, out_name, "-p... | [
"def",
"_create_plot",
"(",
"tumor",
",",
"in_glob",
",",
"out_ext",
",",
"page",
"=",
"1",
")",
":",
"out_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"\"images\"",
")",
"out_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"\"%s-%s\"... | Create an output plot for the given PDF in the images directory. | [
"Create",
"an",
"output",
"plot",
"for",
"the",
"given",
"PDF",
"in",
"the",
"images",
"directory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hla_loh_comparison.py#L64-L73 | train |
bcbio/bcbio-nextgen | scripts/utils/hla_loh_comparison.py | _get_cromwell_execution_dir | def _get_cromwell_execution_dir(base_dir, target_glob):
"""Retrieve the baseline directory with cromwell output files.
Handles Cromwell restarts where there are multiple work directories and
we traverse symlinks back to the original.
"""
cur_dir = glob.glob(os.path.join(base_dir, target_glob))[0]
... | python | def _get_cromwell_execution_dir(base_dir, target_glob):
"""Retrieve the baseline directory with cromwell output files.
Handles Cromwell restarts where there are multiple work directories and
we traverse symlinks back to the original.
"""
cur_dir = glob.glob(os.path.join(base_dir, target_glob))[0]
... | [
"def",
"_get_cromwell_execution_dir",
"(",
"base_dir",
",",
"target_glob",
")",
":",
"cur_dir",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"base_dir",
",",
"target_glob",
")",
")",
"[",
"0",
"]",
"if",
"os",
".",
"path",
".",
... | Retrieve the baseline directory with cromwell output files.
Handles Cromwell restarts where there are multiple work directories and
we traverse symlinks back to the original. | [
"Retrieve",
"the",
"baseline",
"directory",
"with",
"cromwell",
"output",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hla_loh_comparison.py#L232-L245 | train |
bcbio/bcbio-nextgen | scripts/utils/hla_loh_comparison.py | prep_bam_inputs | def prep_bam_inputs(out_dir, sample, call_file, bam_file):
"""Prepare expected input BAM files from pre-aligned.
"""
base = utils.splitext_plus(os.path.basename(bam_file))[0]
with open(call_file) as in_handle:
for cur_hla in (x.strip() for x in in_handle):
out_file = os.path.join(uti... | python | def prep_bam_inputs(out_dir, sample, call_file, bam_file):
"""Prepare expected input BAM files from pre-aligned.
"""
base = utils.splitext_plus(os.path.basename(bam_file))[0]
with open(call_file) as in_handle:
for cur_hla in (x.strip() for x in in_handle):
out_file = os.path.join(uti... | [
"def",
"prep_bam_inputs",
"(",
"out_dir",
",",
"sample",
",",
"call_file",
",",
"bam_file",
")",
":",
"base",
"=",
"utils",
".",
"splitext_plus",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"bam_file",
")",
")",
"[",
"0",
"]",
"with",
"open",
"(",
... | Prepare expected input BAM files from pre-aligned. | [
"Prepare",
"expected",
"input",
"BAM",
"files",
"from",
"pre",
"-",
"aligned",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hla_loh_comparison.py#L247-L257 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.