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/pipeline/run_info.py | _fill_prioritization_targets | def _fill_prioritization_targets(data):
"""Fill in globally installed files for prioritization.
"""
ref_file = dd.get_ref_file(data)
for target in ["svprioritize", "coverage"]:
val = tz.get_in(["config", "algorithm", target], data)
if val and not os.path.exists(val) and not objectstore.i... | python | def _fill_prioritization_targets(data):
"""Fill in globally installed files for prioritization.
"""
ref_file = dd.get_ref_file(data)
for target in ["svprioritize", "coverage"]:
val = tz.get_in(["config", "algorithm", target], data)
if val and not os.path.exists(val) and not objectstore.i... | [
"def",
"_fill_prioritization_targets",
"(",
"data",
")",
":",
"ref_file",
"=",
"dd",
".",
"get_ref_file",
"(",
"data",
")",
"for",
"target",
"in",
"[",
"\"svprioritize\"",
",",
"\"coverage\"",
"]",
":",
"val",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"config\... | Fill in globally installed files for prioritization. | [
"Fill",
"in",
"globally",
"installed",
"files",
"for",
"prioritization",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L276-L315 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _clean_algorithm | def _clean_algorithm(data):
"""Clean algorithm keys, handling items that can be specified as lists or single items.
"""
# convert single items to lists
for key in ["variantcaller", "jointcaller", "svcaller"]:
val = tz.get_in(["algorithm", key], data)
if val:
if not isinstance... | python | def _clean_algorithm(data):
"""Clean algorithm keys, handling items that can be specified as lists or single items.
"""
# convert single items to lists
for key in ["variantcaller", "jointcaller", "svcaller"]:
val = tz.get_in(["algorithm", key], data)
if val:
if not isinstance... | [
"def",
"_clean_algorithm",
"(",
"data",
")",
":",
"# convert single items to lists",
"for",
"key",
"in",
"[",
"\"variantcaller\"",
",",
"\"jointcaller\"",
",",
"\"svcaller\"",
"]",
":",
"val",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"algorithm\"",
",",
"key",
"]... | Clean algorithm keys, handling items that can be specified as lists or single items. | [
"Clean",
"algorithm",
"keys",
"handling",
"items",
"that",
"can",
"be",
"specified",
"as",
"lists",
"or",
"single",
"items",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L336-L351 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _organize_tools_on | def _organize_tools_on(data, is_cwl):
"""Ensure tools_on inputs match items specified elsewhere.
"""
# want tools_on: [gvcf] if joint calling specified in CWL
if is_cwl:
if tz.get_in(["algorithm", "jointcaller"], data):
val = tz.get_in(["algorithm", "tools_on"], data)
if ... | python | def _organize_tools_on(data, is_cwl):
"""Ensure tools_on inputs match items specified elsewhere.
"""
# want tools_on: [gvcf] if joint calling specified in CWL
if is_cwl:
if tz.get_in(["algorithm", "jointcaller"], data):
val = tz.get_in(["algorithm", "tools_on"], data)
if ... | [
"def",
"_organize_tools_on",
"(",
"data",
",",
"is_cwl",
")",
":",
"# want tools_on: [gvcf] if joint calling specified in CWL",
"if",
"is_cwl",
":",
"if",
"tz",
".",
"get_in",
"(",
"[",
"\"algorithm\"",
",",
"\"jointcaller\"",
"]",
",",
"data",
")",
":",
"val",
... | Ensure tools_on inputs match items specified elsewhere. | [
"Ensure",
"tools_on",
"inputs",
"match",
"items",
"specified",
"elsewhere",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L353-L367 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _clean_background | def _clean_background(data):
"""Clean up background specification, remaining back compatible.
"""
allowed_keys = set(["variant", "cnv_reference"])
val = tz.get_in(["algorithm", "background"], data)
errors = []
if val:
out = {}
# old style specification, single string for variant
... | python | def _clean_background(data):
"""Clean up background specification, remaining back compatible.
"""
allowed_keys = set(["variant", "cnv_reference"])
val = tz.get_in(["algorithm", "background"], data)
errors = []
if val:
out = {}
# old style specification, single string for variant
... | [
"def",
"_clean_background",
"(",
"data",
")",
":",
"allowed_keys",
"=",
"set",
"(",
"[",
"\"variant\"",
",",
"\"cnv_reference\"",
"]",
")",
"val",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"algorithm\"",
",",
"\"background\"",
"]",
",",
"data",
")",
"errors",
... | Clean up background specification, remaining back compatible. | [
"Clean",
"up",
"background",
"specification",
"remaining",
"back",
"compatible",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L369-L400 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _clean_characters | def _clean_characters(x):
"""Clean problem characters in sample lane or descriptions.
"""
if not isinstance(x, six.string_types):
x = str(x)
else:
if not all(ord(char) < 128 for char in x):
msg = "Found unicode character in input YAML (%s)" % (x)
raise ValueError(... | python | def _clean_characters(x):
"""Clean problem characters in sample lane or descriptions.
"""
if not isinstance(x, six.string_types):
x = str(x)
else:
if not all(ord(char) < 128 for char in x):
msg = "Found unicode character in input YAML (%s)" % (x)
raise ValueError(... | [
"def",
"_clean_characters",
"(",
"x",
")",
":",
"if",
"not",
"isinstance",
"(",
"x",
",",
"six",
".",
"string_types",
")",
":",
"x",
"=",
"str",
"(",
"x",
")",
"else",
":",
"if",
"not",
"all",
"(",
"ord",
"(",
"char",
")",
"<",
"128",
"for",
"c... | Clean problem characters in sample lane or descriptions. | [
"Clean",
"problem",
"characters",
"in",
"sample",
"lane",
"or",
"descriptions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L402-L413 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | prep_rg_names | def prep_rg_names(item, config, fc_name, fc_date):
"""Generate read group names from item inputs.
"""
if fc_name and fc_date:
lane_name = "%s_%s_%s" % (item["lane"], fc_date, fc_name)
else:
lane_name = item["description"]
return {"rg": item["description"],
"sample": item[... | python | def prep_rg_names(item, config, fc_name, fc_date):
"""Generate read group names from item inputs.
"""
if fc_name and fc_date:
lane_name = "%s_%s_%s" % (item["lane"], fc_date, fc_name)
else:
lane_name = item["description"]
return {"rg": item["description"],
"sample": item[... | [
"def",
"prep_rg_names",
"(",
"item",
",",
"config",
",",
"fc_name",
",",
"fc_date",
")",
":",
"if",
"fc_name",
"and",
"fc_date",
":",
"lane_name",
"=",
"\"%s_%s_%s\"",
"%",
"(",
"item",
"[",
"\"lane\"",
"]",
",",
"fc_date",
",",
"fc_name",
")",
"else",
... | Generate read group names from item inputs. | [
"Generate",
"read",
"group",
"names",
"from",
"item",
"inputs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L415-L428 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_for_duplicates | def _check_for_duplicates(xs, attr, check_fn=None):
"""Identify and raise errors on duplicate items.
"""
dups = []
for key, vals in itertools.groupby(x[attr] for x in xs):
if len(list(vals)) > 1:
dups.append(key)
if len(dups) > 0:
psamples = []
for x in xs:
... | python | def _check_for_duplicates(xs, attr, check_fn=None):
"""Identify and raise errors on duplicate items.
"""
dups = []
for key, vals in itertools.groupby(x[attr] for x in xs):
if len(list(vals)) > 1:
dups.append(key)
if len(dups) > 0:
psamples = []
for x in xs:
... | [
"def",
"_check_for_duplicates",
"(",
"xs",
",",
"attr",
",",
"check_fn",
"=",
"None",
")",
":",
"dups",
"=",
"[",
"]",
"for",
"key",
",",
"vals",
"in",
"itertools",
".",
"groupby",
"(",
"x",
"[",
"attr",
"]",
"for",
"x",
"in",
"xs",
")",
":",
"if... | Identify and raise errors on duplicate items. | [
"Identify",
"and",
"raise",
"errors",
"on",
"duplicate",
"items",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L432-L450 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_for_batch_clashes | def _check_for_batch_clashes(xs):
"""Check that batch names do not overlap with sample names.
"""
names = set([x["description"] for x in xs])
dups = set([])
for x in xs:
batches = tz.get_in(("metadata", "batch"), x)
if batches:
if not isinstance(batches, (list, tuple)):
... | python | def _check_for_batch_clashes(xs):
"""Check that batch names do not overlap with sample names.
"""
names = set([x["description"] for x in xs])
dups = set([])
for x in xs:
batches = tz.get_in(("metadata", "batch"), x)
if batches:
if not isinstance(batches, (list, tuple)):
... | [
"def",
"_check_for_batch_clashes",
"(",
"xs",
")",
":",
"names",
"=",
"set",
"(",
"[",
"x",
"[",
"\"description\"",
"]",
"for",
"x",
"in",
"xs",
"]",
")",
"dups",
"=",
"set",
"(",
"[",
"]",
")",
"for",
"x",
"in",
"xs",
":",
"batches",
"=",
"tz",
... | Check that batch names do not overlap with sample names. | [
"Check",
"that",
"batch",
"names",
"do",
"not",
"overlap",
"with",
"sample",
"names",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L452-L467 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_for_problem_somatic_batches | def _check_for_problem_somatic_batches(items, config):
"""Identify problem batch setups for somatic calling.
We do not support multiple tumors in a single batch and VarDict(Java) does not
handle pooled calling, only tumor/normal.
"""
to_check = []
for data in items:
data = copy.deepcopy... | python | def _check_for_problem_somatic_batches(items, config):
"""Identify problem batch setups for somatic calling.
We do not support multiple tumors in a single batch and VarDict(Java) does not
handle pooled calling, only tumor/normal.
"""
to_check = []
for data in items:
data = copy.deepcopy... | [
"def",
"_check_for_problem_somatic_batches",
"(",
"items",
",",
"config",
")",
":",
"to_check",
"=",
"[",
"]",
"for",
"data",
"in",
"items",
":",
"data",
"=",
"copy",
".",
"deepcopy",
"(",
"data",
")",
"data",
"[",
"\"config\"",
"]",
"=",
"config_utils",
... | Identify problem batch setups for somatic calling.
We do not support multiple tumors in a single batch and VarDict(Java) does not
handle pooled calling, only tumor/normal. | [
"Identify",
"problem",
"batch",
"setups",
"for",
"somatic",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L469-L497 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_for_misplaced | def _check_for_misplaced(xs, subkey, other_keys):
"""Ensure configuration keys are not incorrectly nested under other keys.
"""
problems = []
for x in xs:
check_dict = x.get(subkey, {})
for to_check in other_keys:
if to_check in check_dict:
problems.append((x[... | python | def _check_for_misplaced(xs, subkey, other_keys):
"""Ensure configuration keys are not incorrectly nested under other keys.
"""
problems = []
for x in xs:
check_dict = x.get(subkey, {})
for to_check in other_keys:
if to_check in check_dict:
problems.append((x[... | [
"def",
"_check_for_misplaced",
"(",
"xs",
",",
"subkey",
",",
"other_keys",
")",
":",
"problems",
"=",
"[",
"]",
"for",
"x",
"in",
"xs",
":",
"check_dict",
"=",
"x",
".",
"get",
"(",
"subkey",
",",
"{",
"}",
")",
"for",
"to_check",
"in",
"other_keys"... | Ensure configuration keys are not incorrectly nested under other keys. | [
"Ensure",
"configuration",
"keys",
"are",
"not",
"incorrectly",
"nested",
"under",
"other",
"keys",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L499-L512 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_for_degenerate_interesting_groups | def _check_for_degenerate_interesting_groups(items):
""" Make sure interesting_groups specify existing metadata and that
the interesting_group is not all of the same for all of the samples
"""
igkey = ("algorithm", "bcbiornaseq", "interesting_groups")
interesting_groups = tz.get_in(igkey, items[0], ... | python | def _check_for_degenerate_interesting_groups(items):
""" Make sure interesting_groups specify existing metadata and that
the interesting_group is not all of the same for all of the samples
"""
igkey = ("algorithm", "bcbiornaseq", "interesting_groups")
interesting_groups = tz.get_in(igkey, items[0], ... | [
"def",
"_check_for_degenerate_interesting_groups",
"(",
"items",
")",
":",
"igkey",
"=",
"(",
"\"algorithm\"",
",",
"\"bcbiornaseq\"",
",",
"\"interesting_groups\"",
")",
"interesting_groups",
"=",
"tz",
".",
"get_in",
"(",
"igkey",
",",
"items",
"[",
"0",
"]",
... | Make sure interesting_groups specify existing metadata and that
the interesting_group is not all of the same for all of the samples | [
"Make",
"sure",
"interesting_groups",
"specify",
"existing",
"metadata",
"and",
"that",
"the",
"interesting_group",
"is",
"not",
"all",
"of",
"the",
"same",
"for",
"all",
"of",
"the",
"samples"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L514-L529 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_algorithm_keys | def _check_algorithm_keys(item):
"""Check for unexpected keys in the algorithm section.
Needs to be manually updated when introducing new keys, but avoids silent bugs
with typos in key names.
"""
problem_keys = [k for k in item["algorithm"].keys() if k not in ALGORITHM_KEYS]
if len(problem_keys... | python | def _check_algorithm_keys(item):
"""Check for unexpected keys in the algorithm section.
Needs to be manually updated when introducing new keys, but avoids silent bugs
with typos in key names.
"""
problem_keys = [k for k in item["algorithm"].keys() if k not in ALGORITHM_KEYS]
if len(problem_keys... | [
"def",
"_check_algorithm_keys",
"(",
"item",
")",
":",
"problem_keys",
"=",
"[",
"k",
"for",
"k",
"in",
"item",
"[",
"\"algorithm\"",
"]",
".",
"keys",
"(",
")",
"if",
"k",
"not",
"in",
"ALGORITHM_KEYS",
"]",
"if",
"len",
"(",
"problem_keys",
")",
">",... | Check for unexpected keys in the algorithm section.
Needs to be manually updated when introducing new keys, but avoids silent bugs
with typos in key names. | [
"Check",
"for",
"unexpected",
"keys",
"in",
"the",
"algorithm",
"section",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L575-L585 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_algorithm_values | def _check_algorithm_values(item):
"""Check for misplaced inputs in the algorithms.
- Identify incorrect boolean values where a choice is required.
"""
problems = []
for k, v in item.get("algorithm", {}).items():
if v is True and k not in ALG_ALLOW_BOOLEANS:
problems.append("%s ... | python | def _check_algorithm_values(item):
"""Check for misplaced inputs in the algorithms.
- Identify incorrect boolean values where a choice is required.
"""
problems = []
for k, v in item.get("algorithm", {}).items():
if v is True and k not in ALG_ALLOW_BOOLEANS:
problems.append("%s ... | [
"def",
"_check_algorithm_values",
"(",
"item",
")",
":",
"problems",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"item",
".",
"get",
"(",
"\"algorithm\"",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
":",
"if",
"v",
"is",
"True",
"and",
"k",
"not",... | Check for misplaced inputs in the algorithms.
- Identify incorrect boolean values where a choice is required. | [
"Check",
"for",
"misplaced",
"inputs",
"in",
"the",
"algorithms",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L587-L601 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_toplevel_misplaced | def _check_toplevel_misplaced(item):
"""Check for algorithm keys accidentally placed at the top level.
"""
problem_keys = [k for k in item.keys() if k in ALGORITHM_KEYS]
if len(problem_keys) > 0:
raise ValueError("Unexpected configuration keywords found in top level of %s: %s\n"
... | python | def _check_toplevel_misplaced(item):
"""Check for algorithm keys accidentally placed at the top level.
"""
problem_keys = [k for k in item.keys() if k in ALGORITHM_KEYS]
if len(problem_keys) > 0:
raise ValueError("Unexpected configuration keywords found in top level of %s: %s\n"
... | [
"def",
"_check_toplevel_misplaced",
"(",
"item",
")",
":",
"problem_keys",
"=",
"[",
"k",
"for",
"k",
"in",
"item",
".",
"keys",
"(",
")",
"if",
"k",
"in",
"ALGORITHM_KEYS",
"]",
"if",
"len",
"(",
"problem_keys",
")",
">",
"0",
":",
"raise",
"ValueErro... | Check for algorithm keys accidentally placed at the top level. | [
"Check",
"for",
"algorithm",
"keys",
"accidentally",
"placed",
"at",
"the",
"top",
"level",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L604-L615 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_quality_format | def _check_quality_format(items):
"""
Check if quality_format="standard" and fastq_format is not sanger
"""
SAMPLE_FORMAT = {"illumina_1.3+": "illumina",
"illumina_1.5+": "illumina",
"illumina_1.8+": "standard",
"solexa": "solexa",
... | python | def _check_quality_format(items):
"""
Check if quality_format="standard" and fastq_format is not sanger
"""
SAMPLE_FORMAT = {"illumina_1.3+": "illumina",
"illumina_1.5+": "illumina",
"illumina_1.8+": "standard",
"solexa": "solexa",
... | [
"def",
"_check_quality_format",
"(",
"items",
")",
":",
"SAMPLE_FORMAT",
"=",
"{",
"\"illumina_1.3+\"",
":",
"\"illumina\"",
",",
"\"illumina_1.5+\"",
":",
"\"illumina\"",
",",
"\"illumina_1.8+\"",
":",
"\"standard\"",
",",
"\"solexa\"",
":",
"\"solexa\"",
",",
"\"s... | Check if quality_format="standard" and fastq_format is not sanger | [
"Check",
"if",
"quality_format",
"=",
"standard",
"and",
"fastq_format",
"is",
"not",
"sanger"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L648-L677 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_aligner | def _check_aligner(item):
"""Ensure specified aligner is valid choice.
"""
allowed = set(list(alignment.TOOLS.keys()) + [None, False])
if item["algorithm"].get("aligner") not in allowed:
raise ValueError("Unexpected algorithm 'aligner' parameter: %s\n"
"Supported options... | python | def _check_aligner(item):
"""Ensure specified aligner is valid choice.
"""
allowed = set(list(alignment.TOOLS.keys()) + [None, False])
if item["algorithm"].get("aligner") not in allowed:
raise ValueError("Unexpected algorithm 'aligner' parameter: %s\n"
"Supported options... | [
"def",
"_check_aligner",
"(",
"item",
")",
":",
"allowed",
"=",
"set",
"(",
"list",
"(",
"alignment",
".",
"TOOLS",
".",
"keys",
"(",
")",
")",
"+",
"[",
"None",
",",
"False",
"]",
")",
"if",
"item",
"[",
"\"algorithm\"",
"]",
".",
"get",
"(",
"\... | Ensure specified aligner is valid choice. | [
"Ensure",
"specified",
"aligner",
"is",
"valid",
"choice",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L680-L687 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_variantcaller | def _check_variantcaller(item):
"""Ensure specified variantcaller is a valid choice.
"""
allowed = set(list(genotype.get_variantcallers().keys()) + [None, False])
vcs = item["algorithm"].get("variantcaller")
if not isinstance(vcs, dict):
vcs = {"variantcaller": vcs}
for vc_set in vcs.val... | python | def _check_variantcaller(item):
"""Ensure specified variantcaller is a valid choice.
"""
allowed = set(list(genotype.get_variantcallers().keys()) + [None, False])
vcs = item["algorithm"].get("variantcaller")
if not isinstance(vcs, dict):
vcs = {"variantcaller": vcs}
for vc_set in vcs.val... | [
"def",
"_check_variantcaller",
"(",
"item",
")",
":",
"allowed",
"=",
"set",
"(",
"list",
"(",
"genotype",
".",
"get_variantcallers",
"(",
")",
".",
"keys",
"(",
")",
")",
"+",
"[",
"None",
",",
"False",
"]",
")",
"vcs",
"=",
"item",
"[",
"\"algorith... | Ensure specified variantcaller is a valid choice. | [
"Ensure",
"specified",
"variantcaller",
"is",
"a",
"valid",
"choice",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L689-L708 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_svcaller | def _check_svcaller(item):
"""Ensure the provide structural variant caller is valid.
"""
allowed = set(reduce(operator.add, [list(d.keys()) for d in structural._CALLERS.values()]) + [None, False])
svs = item["algorithm"].get("svcaller")
if not isinstance(svs, (list, tuple)):
svs = [svs]
... | python | def _check_svcaller(item):
"""Ensure the provide structural variant caller is valid.
"""
allowed = set(reduce(operator.add, [list(d.keys()) for d in structural._CALLERS.values()]) + [None, False])
svs = item["algorithm"].get("svcaller")
if not isinstance(svs, (list, tuple)):
svs = [svs]
... | [
"def",
"_check_svcaller",
"(",
"item",
")",
":",
"allowed",
"=",
"set",
"(",
"reduce",
"(",
"operator",
".",
"add",
",",
"[",
"list",
"(",
"d",
".",
"keys",
"(",
")",
")",
"for",
"d",
"in",
"structural",
".",
"_CALLERS",
".",
"values",
"(",
")",
... | Ensure the provide structural variant caller is valid. | [
"Ensure",
"the",
"provide",
"structural",
"variant",
"caller",
"is",
"valid",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L710-L721 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_hetcaller | def _check_hetcaller(item):
"""Ensure upstream SV callers requires to heterogeneity analysis are available.
"""
svs = _get_as_list(item, "svcaller")
hets = _get_as_list(item, "hetcaller")
if hets or any([x in svs for x in ["titancna", "purecn"]]):
if not any([x in svs for x in ["cnvkit", "ga... | python | def _check_hetcaller(item):
"""Ensure upstream SV callers requires to heterogeneity analysis are available.
"""
svs = _get_as_list(item, "svcaller")
hets = _get_as_list(item, "hetcaller")
if hets or any([x in svs for x in ["titancna", "purecn"]]):
if not any([x in svs for x in ["cnvkit", "ga... | [
"def",
"_check_hetcaller",
"(",
"item",
")",
":",
"svs",
"=",
"_get_as_list",
"(",
"item",
",",
"\"svcaller\"",
")",
"hets",
"=",
"_get_as_list",
"(",
"item",
",",
"\"hetcaller\"",
")",
"if",
"hets",
"or",
"any",
"(",
"[",
"x",
"in",
"svs",
"for",
"x",... | Ensure upstream SV callers requires to heterogeneity analysis are available. | [
"Ensure",
"upstream",
"SV",
"callers",
"requires",
"to",
"heterogeneity",
"analysis",
"are",
"available",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L731-L739 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_jointcaller | def _check_jointcaller(data):
"""Ensure specified jointcaller is valid.
"""
allowed = set(joint.get_callers() + [None, False])
cs = data["algorithm"].get("jointcaller", [])
if not isinstance(cs, (tuple, list)):
cs = [cs]
problem = [x for x in cs if x not in allowed]
if len(problem) >... | python | def _check_jointcaller(data):
"""Ensure specified jointcaller is valid.
"""
allowed = set(joint.get_callers() + [None, False])
cs = data["algorithm"].get("jointcaller", [])
if not isinstance(cs, (tuple, list)):
cs = [cs]
problem = [x for x in cs if x not in allowed]
if len(problem) >... | [
"def",
"_check_jointcaller",
"(",
"data",
")",
":",
"allowed",
"=",
"set",
"(",
"joint",
".",
"get_callers",
"(",
")",
"+",
"[",
"None",
",",
"False",
"]",
")",
"cs",
"=",
"data",
"[",
"\"algorithm\"",
"]",
".",
"get",
"(",
"\"jointcaller\"",
",",
"[... | Ensure specified jointcaller is valid. | [
"Ensure",
"specified",
"jointcaller",
"is",
"valid",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L741-L751 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_realign | def _check_realign(data):
"""Check for realignment, which is not supported in GATK4
"""
if "gatk4" not in data["algorithm"].get("tools_off", []) and not "gatk4" == data["algorithm"].get("tools_off"):
if data["algorithm"].get("realign"):
raise ValueError("In sample %s, realign specified b... | python | def _check_realign(data):
"""Check for realignment, which is not supported in GATK4
"""
if "gatk4" not in data["algorithm"].get("tools_off", []) and not "gatk4" == data["algorithm"].get("tools_off"):
if data["algorithm"].get("realign"):
raise ValueError("In sample %s, realign specified b... | [
"def",
"_check_realign",
"(",
"data",
")",
":",
"if",
"\"gatk4\"",
"not",
"in",
"data",
"[",
"\"algorithm\"",
"]",
".",
"get",
"(",
"\"tools_off\"",
",",
"[",
"]",
")",
"and",
"not",
"\"gatk4\"",
"==",
"data",
"[",
"\"algorithm\"",
"]",
".",
"get",
"("... | Check for realignment, which is not supported in GATK4 | [
"Check",
"for",
"realignment",
"which",
"is",
"not",
"supported",
"in",
"GATK4"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L767-L774 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_trim | def _check_trim(data):
"""Check for valid values for trim_reads.
"""
trim = data["algorithm"].get("trim_reads")
if trim:
if trim == "fastp" and data["algorithm"].get("align_split_size") is not False:
raise ValueError("In sample %s, `trim_reads: fastp` currently requires `align_split_... | python | def _check_trim(data):
"""Check for valid values for trim_reads.
"""
trim = data["algorithm"].get("trim_reads")
if trim:
if trim == "fastp" and data["algorithm"].get("align_split_size") is not False:
raise ValueError("In sample %s, `trim_reads: fastp` currently requires `align_split_... | [
"def",
"_check_trim",
"(",
"data",
")",
":",
"trim",
"=",
"data",
"[",
"\"algorithm\"",
"]",
".",
"get",
"(",
"\"trim_reads\"",
")",
"if",
"trim",
":",
"if",
"trim",
"==",
"\"fastp\"",
"and",
"data",
"[",
"\"algorithm\"",
"]",
".",
"get",
"(",
"\"align... | Check for valid values for trim_reads. | [
"Check",
"for",
"valid",
"values",
"for",
"trim_reads",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L776-L783 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _check_sample_config | def _check_sample_config(items, in_file, config):
"""Identify common problems in input sample configuration files.
"""
logger.info("Checking sample YAML configuration: %s" % in_file)
_check_quality_format(items)
_check_for_duplicates(items, "lane")
_check_for_duplicates(items, "description")
... | python | def _check_sample_config(items, in_file, config):
"""Identify common problems in input sample configuration files.
"""
logger.info("Checking sample YAML configuration: %s" % in_file)
_check_quality_format(items)
_check_for_duplicates(items, "lane")
_check_for_duplicates(items, "description")
... | [
"def",
"_check_sample_config",
"(",
"items",
",",
"in_file",
",",
"config",
")",
":",
"logger",
".",
"info",
"(",
"\"Checking sample YAML configuration: %s\"",
"%",
"in_file",
")",
"_check_quality_format",
"(",
"items",
")",
"_check_for_duplicates",
"(",
"items",
",... | Identify common problems in input sample configuration files. | [
"Identify",
"common",
"problems",
"in",
"input",
"sample",
"configuration",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L786-L811 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _file_to_abs | def _file_to_abs(x, dnames, makedir=False):
"""Make a file absolute using the supplied base directory choices.
"""
if x is None or os.path.isabs(x):
return x
elif isinstance(x, six.string_types) and objectstore.is_remote(x):
return x
elif isinstance(x, six.string_types) and x.lower()... | python | def _file_to_abs(x, dnames, makedir=False):
"""Make a file absolute using the supplied base directory choices.
"""
if x is None or os.path.isabs(x):
return x
elif isinstance(x, six.string_types) and objectstore.is_remote(x):
return x
elif isinstance(x, six.string_types) and x.lower()... | [
"def",
"_file_to_abs",
"(",
"x",
",",
"dnames",
",",
"makedir",
"=",
"False",
")",
":",
"if",
"x",
"is",
"None",
"or",
"os",
".",
"path",
".",
"isabs",
"(",
"x",
")",
":",
"return",
"x",
"elif",
"isinstance",
"(",
"x",
",",
"six",
".",
"string_ty... | Make a file absolute using the supplied base directory choices. | [
"Make",
"a",
"file",
"absolute",
"using",
"the",
"supplied",
"base",
"directory",
"choices",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L815-L833 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _normalize_files | def _normalize_files(item, fc_dir=None):
"""Ensure the files argument is a list of absolute file names.
Handles BAM, single and paired end fastq, as well as split inputs.
"""
files = item.get("files")
if files:
if isinstance(files, six.string_types):
files = [files]
fastq... | python | def _normalize_files(item, fc_dir=None):
"""Ensure the files argument is a list of absolute file names.
Handles BAM, single and paired end fastq, as well as split inputs.
"""
files = item.get("files")
if files:
if isinstance(files, six.string_types):
files = [files]
fastq... | [
"def",
"_normalize_files",
"(",
"item",
",",
"fc_dir",
"=",
"None",
")",
":",
"files",
"=",
"item",
".",
"get",
"(",
"\"files\"",
")",
"if",
"files",
":",
"if",
"isinstance",
"(",
"files",
",",
"six",
".",
"string_types",
")",
":",
"files",
"=",
"[",... | Ensure the files argument is a list of absolute file names.
Handles BAM, single and paired end fastq, as well as split inputs. | [
"Ensure",
"the",
"files",
"argument",
"is",
"a",
"list",
"of",
"absolute",
"file",
"names",
".",
"Handles",
"BAM",
"single",
"and",
"paired",
"end",
"fastq",
"as",
"well",
"as",
"split",
"inputs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L835-L848 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _sanity_check_files | def _sanity_check_files(item, files):
"""Ensure input files correspond with supported approaches.
Handles BAM, fastqs, plus split fastqs.
"""
msg = None
file_types = set([("bam" if x.endswith(".bam") else "fastq") for x in files if x])
if len(file_types) > 1:
msg = "Found multiple file ... | python | def _sanity_check_files(item, files):
"""Ensure input files correspond with supported approaches.
Handles BAM, fastqs, plus split fastqs.
"""
msg = None
file_types = set([("bam" if x.endswith(".bam") else "fastq") for x in files if x])
if len(file_types) > 1:
msg = "Found multiple file ... | [
"def",
"_sanity_check_files",
"(",
"item",
",",
"files",
")",
":",
"msg",
"=",
"None",
"file_types",
"=",
"set",
"(",
"[",
"(",
"\"bam\"",
"if",
"x",
".",
"endswith",
"(",
"\".bam\"",
")",
"else",
"\"fastq\"",
")",
"for",
"x",
"in",
"files",
"if",
"x... | Ensure input files correspond with supported approaches.
Handles BAM, fastqs, plus split fastqs. | [
"Ensure",
"input",
"files",
"correspond",
"with",
"supported",
"approaches",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L850-L871 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | add_metadata_defaults | def add_metadata_defaults(md):
"""Central location for defaults for algorithm inputs.
"""
defaults = {"batch": None,
"phenotype": ""}
for k, v in defaults.items():
if k not in md:
md[k] = v
return md | python | def add_metadata_defaults(md):
"""Central location for defaults for algorithm inputs.
"""
defaults = {"batch": None,
"phenotype": ""}
for k, v in defaults.items():
if k not in md:
md[k] = v
return md | [
"def",
"add_metadata_defaults",
"(",
"md",
")",
":",
"defaults",
"=",
"{",
"\"batch\"",
":",
"None",
",",
"\"phenotype\"",
":",
"\"\"",
"}",
"for",
"k",
",",
"v",
"in",
"defaults",
".",
"items",
"(",
")",
":",
"if",
"k",
"not",
"in",
"md",
":",
"md... | Central location for defaults for algorithm inputs. | [
"Central",
"location",
"for",
"defaults",
"for",
"algorithm",
"inputs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L1031-L1039 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _add_algorithm_defaults | def _add_algorithm_defaults(algorithm, analysis, is_cwl):
"""Central location specifying defaults for algorithm inputs.
Converts allowed multiple inputs into lists if specified as a single item.
Converts required single items into string if specified as a list
"""
if not algorithm:
algorith... | python | def _add_algorithm_defaults(algorithm, analysis, is_cwl):
"""Central location specifying defaults for algorithm inputs.
Converts allowed multiple inputs into lists if specified as a single item.
Converts required single items into string if specified as a list
"""
if not algorithm:
algorith... | [
"def",
"_add_algorithm_defaults",
"(",
"algorithm",
",",
"analysis",
",",
"is_cwl",
")",
":",
"if",
"not",
"algorithm",
":",
"algorithm",
"=",
"{",
"}",
"defaults",
"=",
"{",
"\"archive\"",
":",
"None",
",",
"\"tools_off\"",
":",
"[",
"]",
",",
"\"tools_on... | Central location specifying defaults for algorithm inputs.
Converts allowed multiple inputs into lists if specified as a single item.
Converts required single items into string if specified as a list | [
"Central",
"location",
"specifying",
"defaults",
"for",
"algorithm",
"inputs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L1055-L1116 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | _replace_global_vars | def _replace_global_vars(xs, global_vars):
"""Replace globally shared names from input header with value.
The value of the `algorithm` item may be a pointer to a real
file specified in the `global` section. If found, replace with
the full value.
"""
if isinstance(xs, (list, tuple)):
ret... | python | def _replace_global_vars(xs, global_vars):
"""Replace globally shared names from input header with value.
The value of the `algorithm` item may be a pointer to a real
file specified in the `global` section. If found, replace with
the full value.
"""
if isinstance(xs, (list, tuple)):
ret... | [
"def",
"_replace_global_vars",
"(",
"xs",
",",
"global_vars",
")",
":",
"if",
"isinstance",
"(",
"xs",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"[",
"_replace_global_vars",
"(",
"x",
")",
"for",
"x",
"in",
"xs",
"]",
"elif",
"isinstance... | Replace globally shared names from input header with value.
The value of the `algorithm` item may be a pointer to a real
file specified in the `global` section. If found, replace with
the full value. | [
"Replace",
"globally",
"shared",
"names",
"from",
"input",
"header",
"with",
"value",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L1118-L1135 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/run_info.py | prep_system | def prep_system(run_info_yaml, bcbio_system=None):
"""Prepare system configuration information from an input configuration file.
This does the work of parsing the system input file and setting up directories
for use in 'organize'.
"""
work_dir = os.getcwd()
config, config_file = config_utils.lo... | python | def prep_system(run_info_yaml, bcbio_system=None):
"""Prepare system configuration information from an input configuration file.
This does the work of parsing the system input file and setting up directories
for use in 'organize'.
"""
work_dir = os.getcwd()
config, config_file = config_utils.lo... | [
"def",
"prep_system",
"(",
"run_info_yaml",
",",
"bcbio_system",
"=",
"None",
")",
":",
"work_dir",
"=",
"os",
".",
"getcwd",
"(",
")",
"config",
",",
"config_file",
"=",
"config_utils",
".",
"load_system_config",
"(",
"bcbio_system",
",",
"work_dir",
")",
"... | Prepare system configuration information from an input configuration file.
This does the work of parsing the system input file and setting up directories
for use in 'organize'. | [
"Prepare",
"system",
"configuration",
"information",
"from",
"an",
"input",
"configuration",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/run_info.py#L1150-L1160 | train |
bcbio/bcbio-nextgen | bcbio/variation/platypus.py | run | def run(align_bams, items, ref_file, assoc_files, region, out_file):
"""Run platypus variant calling, germline whole genome or exome.
"""
assert out_file.endswith(".vcf.gz")
if not utils.file_exists(out_file):
with file_transaction(items[0], out_file) as tx_out_file:
for align_bam in... | python | def run(align_bams, items, ref_file, assoc_files, region, out_file):
"""Run platypus variant calling, germline whole genome or exome.
"""
assert out_file.endswith(".vcf.gz")
if not utils.file_exists(out_file):
with file_transaction(items[0], out_file) as tx_out_file:
for align_bam in... | [
"def",
"run",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"assoc_files",
",",
"region",
",",
"out_file",
")",
":",
"assert",
"out_file",
".",
"endswith",
"(",
"\".vcf.gz\"",
")",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
... | Run platypus variant calling, germline whole genome or exome. | [
"Run",
"platypus",
"variant",
"calling",
"germline",
"whole",
"genome",
"or",
"exome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/platypus.py#L19-L62 | train |
bcbio/bcbio-nextgen | bcbio/qc/srna.py | run | def run(bam_file, data, out_dir):
"""Create several log files"""
m = {"base": None, "secondary": []}
m.update(_mirbase_stats(data, out_dir))
m["secondary"].append(_seqcluster_stats(data, out_dir)) | python | def run(bam_file, data, out_dir):
"""Create several log files"""
m = {"base": None, "secondary": []}
m.update(_mirbase_stats(data, out_dir))
m["secondary"].append(_seqcluster_stats(data, out_dir)) | [
"def",
"run",
"(",
"bam_file",
",",
"data",
",",
"out_dir",
")",
":",
"m",
"=",
"{",
"\"base\"",
":",
"None",
",",
"\"secondary\"",
":",
"[",
"]",
"}",
"m",
".",
"update",
"(",
"_mirbase_stats",
"(",
"data",
",",
"out_dir",
")",
")",
"m",
"[",
"\... | Create several log files | [
"Create",
"several",
"log",
"files"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/srna.py#L14-L18 | train |
bcbio/bcbio-nextgen | bcbio/qc/srna.py | _mirbase_stats | def _mirbase_stats(data, out_dir):
"""Create stats from miraligner"""
utils.safe_makedir(out_dir)
out_file = os.path.join(out_dir, "%s_bcbio_mirbase.txt" % dd.get_sample_name(data))
out_file_novel = os.path.join(out_dir, "%s_bcbio_mirdeeep2.txt" % dd.get_sample_name(data))
mirbase_fn = data.get("seq... | python | def _mirbase_stats(data, out_dir):
"""Create stats from miraligner"""
utils.safe_makedir(out_dir)
out_file = os.path.join(out_dir, "%s_bcbio_mirbase.txt" % dd.get_sample_name(data))
out_file_novel = os.path.join(out_dir, "%s_bcbio_mirdeeep2.txt" % dd.get_sample_name(data))
mirbase_fn = data.get("seq... | [
"def",
"_mirbase_stats",
"(",
"data",
",",
"out_dir",
")",
":",
"utils",
".",
"safe_makedir",
"(",
"out_dir",
")",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"out_dir",
",",
"\"%s_bcbio_mirbase.txt\"",
"%",
"dd",
".",
"get_sample_name",
"(",
"da... | Create stats from miraligner | [
"Create",
"stats",
"from",
"miraligner"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/srna.py#L20-L31 | train |
bcbio/bcbio-nextgen | bcbio/qc/srna.py | _seqcluster_stats | def _seqcluster_stats(data, out_dir):
"""Parse seqcluster output"""
name = dd.get_sample_name(data)
fn = data.get("seqcluster", {}).get("stat_file", None)
if not fn:
return None
out_file = os.path.join(out_dir, "%s.txt" % name)
df = pd.read_csv(fn, sep="\t", names = ["reads", "sample", "... | python | def _seqcluster_stats(data, out_dir):
"""Parse seqcluster output"""
name = dd.get_sample_name(data)
fn = data.get("seqcluster", {}).get("stat_file", None)
if not fn:
return None
out_file = os.path.join(out_dir, "%s.txt" % name)
df = pd.read_csv(fn, sep="\t", names = ["reads", "sample", "... | [
"def",
"_seqcluster_stats",
"(",
"data",
",",
"out_dir",
")",
":",
"name",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"fn",
"=",
"data",
".",
"get",
"(",
"\"seqcluster\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"stat_file\"",
",",
"None",
"... | Parse seqcluster output | [
"Parse",
"seqcluster",
"output"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/srna.py#L61-L71 | train |
bcbio/bcbio-nextgen | bcbio/illumina/samplesheet.py | from_flowcell | def from_flowcell(run_folder, lane_details, out_dir=None):
"""Convert a flowcell into a samplesheet for demultiplexing.
"""
fcid = os.path.basename(run_folder)
if out_dir is None:
out_dir = run_folder
out_file = os.path.join(out_dir, "%s.csv" % fcid)
with open(out_file, "w") as out_handl... | python | def from_flowcell(run_folder, lane_details, out_dir=None):
"""Convert a flowcell into a samplesheet for demultiplexing.
"""
fcid = os.path.basename(run_folder)
if out_dir is None:
out_dir = run_folder
out_file = os.path.join(out_dir, "%s.csv" % fcid)
with open(out_file, "w") as out_handl... | [
"def",
"from_flowcell",
"(",
"run_folder",
",",
"lane_details",
",",
"out_dir",
"=",
"None",
")",
":",
"fcid",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"run_folder",
")",
"if",
"out_dir",
"is",
"None",
":",
"out_dir",
"=",
"run_folder",
"out_file",
... | Convert a flowcell into a samplesheet for demultiplexing. | [
"Convert",
"a",
"flowcell",
"into",
"a",
"samplesheet",
"for",
"demultiplexing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/samplesheet.py#L20-L33 | train |
bcbio/bcbio-nextgen | bcbio/illumina/samplesheet.py | _lane_detail_to_ss | def _lane_detail_to_ss(fcid, ldetail):
"""Convert information about a lane into Illumina samplesheet output.
"""
return [fcid, ldetail["lane"], ldetail["name"], ldetail["genome_build"],
ldetail["bc_index"], ldetail["description"].encode("ascii", "ignore"), "N", "", "",
ldetail["proje... | python | def _lane_detail_to_ss(fcid, ldetail):
"""Convert information about a lane into Illumina samplesheet output.
"""
return [fcid, ldetail["lane"], ldetail["name"], ldetail["genome_build"],
ldetail["bc_index"], ldetail["description"].encode("ascii", "ignore"), "N", "", "",
ldetail["proje... | [
"def",
"_lane_detail_to_ss",
"(",
"fcid",
",",
"ldetail",
")",
":",
"return",
"[",
"fcid",
",",
"ldetail",
"[",
"\"lane\"",
"]",
",",
"ldetail",
"[",
"\"name\"",
"]",
",",
"ldetail",
"[",
"\"genome_build\"",
"]",
",",
"ldetail",
"[",
"\"bc_index\"",
"]",
... | Convert information about a lane into Illumina samplesheet output. | [
"Convert",
"information",
"about",
"a",
"lane",
"into",
"Illumina",
"samplesheet",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/samplesheet.py#L35-L40 | train |
bcbio/bcbio-nextgen | bcbio/illumina/samplesheet.py | _organize_lanes | def _organize_lanes(info_iter, barcode_ids):
"""Organize flat lane information into nested YAML structure.
"""
all_lanes = []
for (fcid, lane, sampleref), info in itertools.groupby(info_iter, lambda x: (x[0], x[1], x[1])):
info = list(info)
cur_lane = dict(flowcell_id=fcid, lane=lane, ge... | python | def _organize_lanes(info_iter, barcode_ids):
"""Organize flat lane information into nested YAML structure.
"""
all_lanes = []
for (fcid, lane, sampleref), info in itertools.groupby(info_iter, lambda x: (x[0], x[1], x[1])):
info = list(info)
cur_lane = dict(flowcell_id=fcid, lane=lane, ge... | [
"def",
"_organize_lanes",
"(",
"info_iter",
",",
"barcode_ids",
")",
":",
"all_lanes",
"=",
"[",
"]",
"for",
"(",
"fcid",
",",
"lane",
",",
"sampleref",
")",
",",
"info",
"in",
"itertools",
".",
"groupby",
"(",
"info_iter",
",",
"lambda",
"x",
":",
"("... | Organize flat lane information into nested YAML structure. | [
"Organize",
"flat",
"lane",
"information",
"into",
"nested",
"YAML",
"structure",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/samplesheet.py#L44-L64 | train |
bcbio/bcbio-nextgen | bcbio/illumina/samplesheet.py | _generate_barcode_ids | def _generate_barcode_ids(info_iter):
"""Create unique barcode IDs assigned to sequences
"""
bc_type = "SampleSheet"
barcodes = list(set([x[-1] for x in info_iter]))
barcodes.sort()
barcode_ids = {}
for i, bc in enumerate(barcodes):
barcode_ids[bc] = (bc_type, i+1)
return barcode... | python | def _generate_barcode_ids(info_iter):
"""Create unique barcode IDs assigned to sequences
"""
bc_type = "SampleSheet"
barcodes = list(set([x[-1] for x in info_iter]))
barcodes.sort()
barcode_ids = {}
for i, bc in enumerate(barcodes):
barcode_ids[bc] = (bc_type, i+1)
return barcode... | [
"def",
"_generate_barcode_ids",
"(",
"info_iter",
")",
":",
"bc_type",
"=",
"\"SampleSheet\"",
"barcodes",
"=",
"list",
"(",
"set",
"(",
"[",
"x",
"[",
"-",
"1",
"]",
"for",
"x",
"in",
"info_iter",
"]",
")",
")",
"barcodes",
".",
"sort",
"(",
")",
"b... | Create unique barcode IDs assigned to sequences | [
"Create",
"unique",
"barcode",
"IDs",
"assigned",
"to",
"sequences"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/samplesheet.py#L70-L79 | train |
bcbio/bcbio-nextgen | bcbio/illumina/samplesheet.py | _read_input_csv | def _read_input_csv(in_file):
"""Parse useful details from SampleSheet CSV file.
"""
with io.open(in_file, newline=None) as in_handle:
reader = csv.reader(in_handle)
next(reader) # header
for line in reader:
if line: # empty lines
(fc_id, lane, sample_id, ... | python | def _read_input_csv(in_file):
"""Parse useful details from SampleSheet CSV file.
"""
with io.open(in_file, newline=None) as in_handle:
reader = csv.reader(in_handle)
next(reader) # header
for line in reader:
if line: # empty lines
(fc_id, lane, sample_id, ... | [
"def",
"_read_input_csv",
"(",
"in_file",
")",
":",
"with",
"io",
".",
"open",
"(",
"in_file",
",",
"newline",
"=",
"None",
")",
"as",
"in_handle",
":",
"reader",
"=",
"csv",
".",
"reader",
"(",
"in_handle",
")",
"next",
"(",
"reader",
")",
"# header",... | Parse useful details from SampleSheet CSV file. | [
"Parse",
"useful",
"details",
"from",
"SampleSheet",
"CSV",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/samplesheet.py#L81-L90 | train |
bcbio/bcbio-nextgen | bcbio/illumina/samplesheet.py | _get_flowcell_id | def _get_flowcell_id(in_file, require_single=True):
"""Retrieve the unique flowcell id represented in the SampleSheet.
"""
fc_ids = set([x[0] for x in _read_input_csv(in_file)])
if require_single and len(fc_ids) > 1:
raise ValueError("There are several FCIDs in the same samplesheet file: %s" % i... | python | def _get_flowcell_id(in_file, require_single=True):
"""Retrieve the unique flowcell id represented in the SampleSheet.
"""
fc_ids = set([x[0] for x in _read_input_csv(in_file)])
if require_single and len(fc_ids) > 1:
raise ValueError("There are several FCIDs in the same samplesheet file: %s" % i... | [
"def",
"_get_flowcell_id",
"(",
"in_file",
",",
"require_single",
"=",
"True",
")",
":",
"fc_ids",
"=",
"set",
"(",
"[",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"_read_input_csv",
"(",
"in_file",
")",
"]",
")",
"if",
"require_single",
"and",
"len",
"(",
... | Retrieve the unique flowcell id represented in the SampleSheet. | [
"Retrieve",
"the",
"unique",
"flowcell",
"id",
"represented",
"in",
"the",
"SampleSheet",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/samplesheet.py#L92-L99 | train |
bcbio/bcbio-nextgen | bcbio/illumina/samplesheet.py | csv2yaml | def csv2yaml(in_file, out_file=None):
"""Convert a CSV SampleSheet to YAML run_info format.
"""
if out_file is None:
out_file = "%s.yaml" % os.path.splitext(in_file)[0]
barcode_ids = _generate_barcode_ids(_read_input_csv(in_file))
lanes = _organize_lanes(_read_input_csv(in_file), barcode_ids... | python | def csv2yaml(in_file, out_file=None):
"""Convert a CSV SampleSheet to YAML run_info format.
"""
if out_file is None:
out_file = "%s.yaml" % os.path.splitext(in_file)[0]
barcode_ids = _generate_barcode_ids(_read_input_csv(in_file))
lanes = _organize_lanes(_read_input_csv(in_file), barcode_ids... | [
"def",
"csv2yaml",
"(",
"in_file",
",",
"out_file",
"=",
"None",
")",
":",
"if",
"out_file",
"is",
"None",
":",
"out_file",
"=",
"\"%s.yaml\"",
"%",
"os",
".",
"path",
".",
"splitext",
"(",
"in_file",
")",
"[",
"0",
"]",
"barcode_ids",
"=",
"_generate_... | Convert a CSV SampleSheet to YAML run_info format. | [
"Convert",
"a",
"CSV",
"SampleSheet",
"to",
"YAML",
"run_info",
"format",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/samplesheet.py#L101-L110 | train |
bcbio/bcbio-nextgen | bcbio/illumina/samplesheet.py | run_has_samplesheet | def run_has_samplesheet(fc_dir, config, require_single=True):
"""Checks if there's a suitable SampleSheet.csv present for the run
"""
fc_name, _ = flowcell.parse_dirname(fc_dir)
sheet_dirs = config.get("samplesheet_directories", [])
fcid_sheet = {}
for ss_dir in (s for s in sheet_dirs if os.path... | python | def run_has_samplesheet(fc_dir, config, require_single=True):
"""Checks if there's a suitable SampleSheet.csv present for the run
"""
fc_name, _ = flowcell.parse_dirname(fc_dir)
sheet_dirs = config.get("samplesheet_directories", [])
fcid_sheet = {}
for ss_dir in (s for s in sheet_dirs if os.path... | [
"def",
"run_has_samplesheet",
"(",
"fc_dir",
",",
"config",
",",
"require_single",
"=",
"True",
")",
":",
"fc_name",
",",
"_",
"=",
"flowcell",
".",
"parse_dirname",
"(",
"fc_dir",
")",
"sheet_dirs",
"=",
"config",
".",
"get",
"(",
"\"samplesheet_directories\"... | Checks if there's a suitable SampleSheet.csv present for the run | [
"Checks",
"if",
"there",
"s",
"a",
"suitable",
"SampleSheet",
".",
"csv",
"present",
"for",
"the",
"run"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/samplesheet.py#L112-L133 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | combine_bam | def combine_bam(in_files, out_file, config):
"""Parallel target to combine multiple BAM files.
"""
runner = broad.runner_from_path("picard", config)
runner.run_fn("picard_merge", in_files, out_file)
for in_file in in_files:
save_diskspace(in_file, "Merged into {0}".format(out_file), config)
... | python | def combine_bam(in_files, out_file, config):
"""Parallel target to combine multiple BAM files.
"""
runner = broad.runner_from_path("picard", config)
runner.run_fn("picard_merge", in_files, out_file)
for in_file in in_files:
save_diskspace(in_file, "Merged into {0}".format(out_file), config)
... | [
"def",
"combine_bam",
"(",
"in_files",
",",
"out_file",
",",
"config",
")",
":",
"runner",
"=",
"broad",
".",
"runner_from_path",
"(",
"\"picard\"",
",",
"config",
")",
"runner",
".",
"run_fn",
"(",
"\"picard_merge\"",
",",
"in_files",
",",
"out_file",
")",
... | Parallel target to combine multiple BAM files. | [
"Parallel",
"target",
"to",
"combine",
"multiple",
"BAM",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L25-L33 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | write_nochr_reads | def write_nochr_reads(in_file, out_file, config):
"""Write a BAM file of reads that are not mapped on a reference chromosome.
This is useful for maintaining non-mapped reads in parallel processes
that split processing by chromosome.
"""
if not file_exists(out_file):
with file_transaction(co... | python | def write_nochr_reads(in_file, out_file, config):
"""Write a BAM file of reads that are not mapped on a reference chromosome.
This is useful for maintaining non-mapped reads in parallel processes
that split processing by chromosome.
"""
if not file_exists(out_file):
with file_transaction(co... | [
"def",
"write_nochr_reads",
"(",
"in_file",
",",
"out_file",
",",
"config",
")",
":",
"if",
"not",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"config",
",",
"out_file",
")",
"as",
"tx_out_file",
":",
"samtools",
"=",
"config_u... | Write a BAM file of reads that are not mapped on a reference chromosome.
This is useful for maintaining non-mapped reads in parallel processes
that split processing by chromosome. | [
"Write",
"a",
"BAM",
"file",
"of",
"reads",
"that",
"are",
"not",
"mapped",
"on",
"a",
"reference",
"chromosome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L57-L68 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | write_noanalysis_reads | def write_noanalysis_reads(in_file, region_file, out_file, config):
"""Write a BAM file of reads in the specified region file that are not analyzed.
We want to get only reads not in analysis regions but also make use of
the BAM index to perform well on large files. The tricky part is avoiding
command l... | python | def write_noanalysis_reads(in_file, region_file, out_file, config):
"""Write a BAM file of reads in the specified region file that are not analyzed.
We want to get only reads not in analysis regions but also make use of
the BAM index to perform well on large files. The tricky part is avoiding
command l... | [
"def",
"write_noanalysis_reads",
"(",
"in_file",
",",
"region_file",
",",
"out_file",
",",
"config",
")",
":",
"if",
"not",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"config",
",",
"out_file",
")",
"as",
"tx_out_file",
":",
"... | Write a BAM file of reads in the specified region file that are not analyzed.
We want to get only reads not in analysis regions but also make use of
the BAM index to perform well on large files. The tricky part is avoiding
command line limits. There is a nice discussion on SeqAnswers:
http://seqanswers... | [
"Write",
"a",
"BAM",
"file",
"of",
"reads",
"in",
"the",
"specified",
"region",
"file",
"that",
"are",
"not",
"analyzed",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L70-L88 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | subset_bam_by_region | def subset_bam_by_region(in_file, region, config, out_file_base=None):
"""Subset BAM files based on specified chromosome region.
"""
if out_file_base is not None:
base, ext = os.path.splitext(out_file_base)
else:
base, ext = os.path.splitext(in_file)
out_file = "%s-subset%s%s" % (bas... | python | def subset_bam_by_region(in_file, region, config, out_file_base=None):
"""Subset BAM files based on specified chromosome region.
"""
if out_file_base is not None:
base, ext = os.path.splitext(out_file_base)
else:
base, ext = os.path.splitext(in_file)
out_file = "%s-subset%s%s" % (bas... | [
"def",
"subset_bam_by_region",
"(",
"in_file",
",",
"region",
",",
"config",
",",
"out_file_base",
"=",
"None",
")",
":",
"if",
"out_file_base",
"is",
"not",
"None",
":",
"base",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"out_file_base",
... | Subset BAM files based on specified chromosome region. | [
"Subset",
"BAM",
"files",
"based",
"on",
"specified",
"chromosome",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L90-L109 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | subset_bed_by_chrom | def subset_bed_by_chrom(in_file, chrom, data, out_dir=None):
"""Subset a BED file to only have items from the specified chromosome.
"""
if out_dir is None:
out_dir = os.path.dirname(in_file)
base, ext = os.path.splitext(os.path.basename(in_file))
out_file = os.path.join(out_dir, "%s-%s%s" % ... | python | def subset_bed_by_chrom(in_file, chrom, data, out_dir=None):
"""Subset a BED file to only have items from the specified chromosome.
"""
if out_dir is None:
out_dir = os.path.dirname(in_file)
base, ext = os.path.splitext(os.path.basename(in_file))
out_file = os.path.join(out_dir, "%s-%s%s" % ... | [
"def",
"subset_bed_by_chrom",
"(",
"in_file",
",",
"chrom",
",",
"data",
",",
"out_dir",
"=",
"None",
")",
":",
"if",
"out_dir",
"is",
"None",
":",
"out_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"in_file",
")",
"base",
",",
"ext",
"=",
"os",... | Subset a BED file to only have items from the specified chromosome. | [
"Subset",
"a",
"BED",
"file",
"to",
"only",
"have",
"items",
"from",
"the",
"specified",
"chromosome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L111-L121 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | remove_lcr_regions | def remove_lcr_regions(orig_bed, items):
"""If configured and available, update a BED file to remove low complexity regions.
"""
lcr_bed = tz.get_in(["genome_resources", "variation", "lcr"], items[0])
if lcr_bed and os.path.exists(lcr_bed) and "lcr" in get_exclude_regions(items):
return _remove_... | python | def remove_lcr_regions(orig_bed, items):
"""If configured and available, update a BED file to remove low complexity regions.
"""
lcr_bed = tz.get_in(["genome_resources", "variation", "lcr"], items[0])
if lcr_bed and os.path.exists(lcr_bed) and "lcr" in get_exclude_regions(items):
return _remove_... | [
"def",
"remove_lcr_regions",
"(",
"orig_bed",
",",
"items",
")",
":",
"lcr_bed",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"genome_resources\"",
",",
"\"variation\"",
",",
"\"lcr\"",
"]",
",",
"items",
"[",
"0",
"]",
")",
"if",
"lcr_bed",
"and",
"os",
".",
... | If configured and available, update a BED file to remove low complexity regions. | [
"If",
"configured",
"and",
"available",
"update",
"a",
"BED",
"file",
"to",
"remove",
"low",
"complexity",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L143-L150 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | remove_polyx_regions | def remove_polyx_regions(in_file, items):
"""Remove polyX stretches, contributing to long variant runtimes.
"""
ex_bed = tz.get_in(["genome_resources", "variation", "polyx"], items[0])
if ex_bed and os.path.exists(ex_bed):
return _remove_regions(in_file, [ex_bed], "nopolyx", items[0])
else:
... | python | def remove_polyx_regions(in_file, items):
"""Remove polyX stretches, contributing to long variant runtimes.
"""
ex_bed = tz.get_in(["genome_resources", "variation", "polyx"], items[0])
if ex_bed and os.path.exists(ex_bed):
return _remove_regions(in_file, [ex_bed], "nopolyx", items[0])
else:
... | [
"def",
"remove_polyx_regions",
"(",
"in_file",
",",
"items",
")",
":",
"ex_bed",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"genome_resources\"",
",",
"\"variation\"",
",",
"\"polyx\"",
"]",
",",
"items",
"[",
"0",
"]",
")",
"if",
"ex_bed",
"and",
"os",
".",
... | Remove polyX stretches, contributing to long variant runtimes. | [
"Remove",
"polyX",
"stretches",
"contributing",
"to",
"long",
"variant",
"runtimes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L152-L159 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | add_highdepth_genome_exclusion | def add_highdepth_genome_exclusion(items):
"""Add exclusions to input items to avoid slow runtimes on whole genomes.
"""
out = []
for d in items:
d = utils.deepish_copy(d)
if dd.get_coverage_interval(d) == "genome":
e = dd.get_exclude_regions(d)
if "highdepth" not... | python | def add_highdepth_genome_exclusion(items):
"""Add exclusions to input items to avoid slow runtimes on whole genomes.
"""
out = []
for d in items:
d = utils.deepish_copy(d)
if dd.get_coverage_interval(d) == "genome":
e = dd.get_exclude_regions(d)
if "highdepth" not... | [
"def",
"add_highdepth_genome_exclusion",
"(",
"items",
")",
":",
"out",
"=",
"[",
"]",
"for",
"d",
"in",
"items",
":",
"d",
"=",
"utils",
".",
"deepish_copy",
"(",
"d",
")",
"if",
"dd",
".",
"get_coverage_interval",
"(",
"d",
")",
"==",
"\"genome\"",
"... | Add exclusions to input items to avoid slow runtimes on whole genomes. | [
"Add",
"exclusions",
"to",
"input",
"items",
"to",
"avoid",
"slow",
"runtimes",
"on",
"whole",
"genomes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L161-L173 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | remove_highdepth_regions | def remove_highdepth_regions(in_file, items):
"""Remove high depth regions from a BED file for analyzing a set of calls.
Tries to avoid spurious errors and slow run times in collapsed repeat regions.
Also adds ENCODE blacklist regions which capture additional collapsed repeats
around centromeres.
... | python | def remove_highdepth_regions(in_file, items):
"""Remove high depth regions from a BED file for analyzing a set of calls.
Tries to avoid spurious errors and slow run times in collapsed repeat regions.
Also adds ENCODE blacklist regions which capture additional collapsed repeats
around centromeres.
... | [
"def",
"remove_highdepth_regions",
"(",
"in_file",
",",
"items",
")",
":",
"encode_bed",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"genome_resources\"",
",",
"\"variation\"",
",",
"\"encode_blacklist\"",
"]",
",",
"items",
"[",
"0",
"]",
")",
"if",
"encode_bed",
... | Remove high depth regions from a BED file for analyzing a set of calls.
Tries to avoid spurious errors and slow run times in collapsed repeat regions.
Also adds ENCODE blacklist regions which capture additional collapsed repeats
around centromeres. | [
"Remove",
"high",
"depth",
"regions",
"from",
"a",
"BED",
"file",
"for",
"analyzing",
"a",
"set",
"of",
"calls",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L175-L187 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | _remove_regions | def _remove_regions(in_file, remove_beds, ext, data):
"""Subtract a list of BED files from an input BED.
General approach handling none, one and more remove_beds.
"""
from bcbio.variation import bedutils
out_file = "%s-%s.bed" % (utils.splitext_plus(in_file)[0], ext)
if not utils.file_uptodate(... | python | def _remove_regions(in_file, remove_beds, ext, data):
"""Subtract a list of BED files from an input BED.
General approach handling none, one and more remove_beds.
"""
from bcbio.variation import bedutils
out_file = "%s-%s.bed" % (utils.splitext_plus(in_file)[0], ext)
if not utils.file_uptodate(... | [
"def",
"_remove_regions",
"(",
"in_file",
",",
"remove_beds",
",",
"ext",
",",
"data",
")",
":",
"from",
"bcbio",
".",
"variation",
"import",
"bedutils",
"out_file",
"=",
"\"%s-%s.bed\"",
"%",
"(",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"... | Subtract a list of BED files from an input BED.
General approach handling none, one and more remove_beds. | [
"Subtract",
"a",
"list",
"of",
"BED",
"files",
"from",
"an",
"input",
"BED",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L189-L218 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | get_exclude_regions | def get_exclude_regions(items):
"""Retrieve regions to exclude from a set of items.
Includes back compatibility for older custom ways of specifying different
exclusions.
"""
def _get_sample_excludes(d):
excludes = dd.get_exclude_regions(d)
# back compatible
if tz.get_in(("co... | python | def get_exclude_regions(items):
"""Retrieve regions to exclude from a set of items.
Includes back compatibility for older custom ways of specifying different
exclusions.
"""
def _get_sample_excludes(d):
excludes = dd.get_exclude_regions(d)
# back compatible
if tz.get_in(("co... | [
"def",
"get_exclude_regions",
"(",
"items",
")",
":",
"def",
"_get_sample_excludes",
"(",
"d",
")",
":",
"excludes",
"=",
"dd",
".",
"get_exclude_regions",
"(",
"d",
")",
"# back compatible",
"if",
"tz",
".",
"get_in",
"(",
"(",
"\"config\"",
",",
"\"algorit... | Retrieve regions to exclude from a set of items.
Includes back compatibility for older custom ways of specifying different
exclusions. | [
"Retrieve",
"regions",
"to",
"exclude",
"from",
"a",
"set",
"of",
"items",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L231-L244 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | to_multiregion | def to_multiregion(region):
"""Convert a single region or multiple region specification into multiregion list.
If a single region (chrom, start, end), returns [(chrom, start, end)]
otherwise returns multiregion.
"""
assert isinstance(region, (list, tuple)), region
if isinstance(region[0], (list... | python | def to_multiregion(region):
"""Convert a single region or multiple region specification into multiregion list.
If a single region (chrom, start, end), returns [(chrom, start, end)]
otherwise returns multiregion.
"""
assert isinstance(region, (list, tuple)), region
if isinstance(region[0], (list... | [
"def",
"to_multiregion",
"(",
"region",
")",
":",
"assert",
"isinstance",
"(",
"region",
",",
"(",
"list",
",",
"tuple",
")",
")",
",",
"region",
"if",
"isinstance",
"(",
"region",
"[",
"0",
"]",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"retu... | Convert a single region or multiple region specification into multiregion list.
If a single region (chrom, start, end), returns [(chrom, start, end)]
otherwise returns multiregion. | [
"Convert",
"a",
"single",
"region",
"or",
"multiple",
"region",
"specification",
"into",
"multiregion",
"list",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L261-L272 | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | subset_variant_regions | def subset_variant_regions(variant_regions, region, out_file, items=None, do_merge=True, data=None):
"""Return BED file subset by a specified chromosome region.
variant_regions is a BED file, region is a chromosome name or tuple
of (name, start, end) for a genomic region.
"""
if region is None:
... | python | def subset_variant_regions(variant_regions, region, out_file, items=None, do_merge=True, data=None):
"""Return BED file subset by a specified chromosome region.
variant_regions is a BED file, region is a chromosome name or tuple
of (name, start, end) for a genomic region.
"""
if region is None:
... | [
"def",
"subset_variant_regions",
"(",
"variant_regions",
",",
"region",
",",
"out_file",
",",
"items",
"=",
"None",
",",
"do_merge",
"=",
"True",
",",
"data",
"=",
"None",
")",
":",
"if",
"region",
"is",
"None",
":",
"return",
"variant_regions",
"elif",
"v... | Return BED file subset by a specified chromosome region.
variant_regions is a BED file, region is a chromosome name or tuple
of (name, start, end) for a genomic region. | [
"Return",
"BED",
"file",
"subset",
"by",
"a",
"specified",
"chromosome",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L275-L302 | train |
bcbio/bcbio-nextgen | bcbio/structural/delly.py | _delly_exclude_file | def _delly_exclude_file(items, base_file, chrom):
"""Prepare a delly-specific exclude file eliminating chromosomes.
Delly wants excluded chromosomes listed as just the chromosome, with no coordinates.
"""
base_exclude = sshared.prepare_exclude_file(items, base_file, chrom)
out_file = "%s-delly%s" % ... | python | def _delly_exclude_file(items, base_file, chrom):
"""Prepare a delly-specific exclude file eliminating chromosomes.
Delly wants excluded chromosomes listed as just the chromosome, with no coordinates.
"""
base_exclude = sshared.prepare_exclude_file(items, base_file, chrom)
out_file = "%s-delly%s" % ... | [
"def",
"_delly_exclude_file",
"(",
"items",
",",
"base_file",
",",
"chrom",
")",
":",
"base_exclude",
"=",
"sshared",
".",
"prepare_exclude_file",
"(",
"items",
",",
"base_file",
",",
"chrom",
")",
"out_file",
"=",
"\"%s-delly%s\"",
"%",
"utils",
".",
"splitex... | Prepare a delly-specific exclude file eliminating chromosomes.
Delly wants excluded chromosomes listed as just the chromosome, with no coordinates. | [
"Prepare",
"a",
"delly",
"-",
"specific",
"exclude",
"file",
"eliminating",
"chromosomes",
".",
"Delly",
"wants",
"excluded",
"chromosomes",
"listed",
"as",
"just",
"the",
"chromosome",
"with",
"no",
"coordinates",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/delly.py#L24-L39 | train |
bcbio/bcbio-nextgen | bcbio/structural/delly.py | _run_delly | def _run_delly(bam_files, chrom, ref_file, work_dir, items):
"""Run delly, calling structural variations for the specified type.
"""
batch = sshared.get_cur_batch(items)
ext = "-%s-svs" % batch if batch else "-svs"
out_file = os.path.join(work_dir, "%s%s-%s.bcf"
% (os.pat... | python | def _run_delly(bam_files, chrom, ref_file, work_dir, items):
"""Run delly, calling structural variations for the specified type.
"""
batch = sshared.get_cur_batch(items)
ext = "-%s-svs" % batch if batch else "-svs"
out_file = os.path.join(work_dir, "%s%s-%s.bcf"
% (os.pat... | [
"def",
"_run_delly",
"(",
"bam_files",
",",
"chrom",
",",
"ref_file",
",",
"work_dir",
",",
"items",
")",
":",
"batch",
"=",
"sshared",
".",
"get_cur_batch",
"(",
"items",
")",
"ext",
"=",
"\"-%s-svs\"",
"%",
"batch",
"if",
"batch",
"else",
"\"-svs\"",
"... | Run delly, calling structural variations for the specified type. | [
"Run",
"delly",
"calling",
"structural",
"variations",
"for",
"the",
"specified",
"type",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/delly.py#L43-L68 | train |
bcbio/bcbio-nextgen | bcbio/structural/delly.py | _bgzip_and_clean | def _bgzip_and_clean(bcf_file, items):
"""Create a clean bgzipped VCF output file from bcf for downstream processing.
Also corrects problems with missing likelihoods: https://github.com/dellytools/delly/issues/37
GATK does not like missing GLs like '.,.,.'. This converts them to the recognized '.'
"""
... | python | def _bgzip_and_clean(bcf_file, items):
"""Create a clean bgzipped VCF output file from bcf for downstream processing.
Also corrects problems with missing likelihoods: https://github.com/dellytools/delly/issues/37
GATK does not like missing GLs like '.,.,.'. This converts them to the recognized '.'
"""
... | [
"def",
"_bgzip_and_clean",
"(",
"bcf_file",
",",
"items",
")",
":",
"out_file",
"=",
"\"%s.vcf.gz\"",
"%",
"(",
"utils",
".",
"splitext_plus",
"(",
"bcf_file",
")",
"[",
"0",
"]",
")",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
... | Create a clean bgzipped VCF output file from bcf for downstream processing.
Also corrects problems with missing likelihoods: https://github.com/dellytools/delly/issues/37
GATK does not like missing GLs like '.,.,.'. This converts them to the recognized '.' | [
"Create",
"a",
"clean",
"bgzipped",
"VCF",
"output",
"file",
"from",
"bcf",
"for",
"downstream",
"processing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/delly.py#L70-L84 | train |
bcbio/bcbio-nextgen | bcbio/structural/delly.py | _prep_subsampled_bams | def _prep_subsampled_bams(data, work_dir):
"""Prepare a subsampled BAM file with discordants from samblaster and minimal correct pairs.
This attempts to minimize run times by pre-extracting useful reads mixed
with subsampled normal pairs to estimate paired end distributions:
https://groups.google.com/... | python | def _prep_subsampled_bams(data, work_dir):
"""Prepare a subsampled BAM file with discordants from samblaster and minimal correct pairs.
This attempts to minimize run times by pre-extracting useful reads mixed
with subsampled normal pairs to estimate paired end distributions:
https://groups.google.com/... | [
"def",
"_prep_subsampled_bams",
"(",
"data",
",",
"work_dir",
")",
":",
"sr_bam",
",",
"disc_bam",
"=",
"sshared",
".",
"get_split_discordants",
"(",
"data",
",",
"work_dir",
")",
"ds_bam",
"=",
"bam",
".",
"downsample",
"(",
"dd",
".",
"get_align_bam",
"(",... | Prepare a subsampled BAM file with discordants from samblaster and minimal correct pairs.
This attempts to minimize run times by pre-extracting useful reads mixed
with subsampled normal pairs to estimate paired end distributions:
https://groups.google.com/d/msg/delly-users/xmia4lwOd1Q/uaajoBkahAIJ
Su... | [
"Prepare",
"a",
"subsampled",
"BAM",
"file",
"with",
"discordants",
"from",
"samblaster",
"and",
"minimal",
"correct",
"pairs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/delly.py#L88-L112 | train |
bcbio/bcbio-nextgen | bcbio/structural/delly.py | run | def run(items):
"""Perform detection of structural variations with delly.
Performs post-call filtering with a custom filter tuned based
on NA12878 Moleculo and PacBio data, using calls prepared by
@ryanlayer and @cc2qe
Filters using the high quality variant pairs (DV) compared with
high qualit... | python | def run(items):
"""Perform detection of structural variations with delly.
Performs post-call filtering with a custom filter tuned based
on NA12878 Moleculo and PacBio data, using calls prepared by
@ryanlayer and @cc2qe
Filters using the high quality variant pairs (DV) compared with
high qualit... | [
"def",
"run",
"(",
"items",
")",
":",
"work_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"items",
"[",
"0",
"]",
"[",
"\"dirs\"",
"]",
"[",
"\"work\"",
"]",
",",
"\"structural\"",
",",
"dd",
".",
"get_sample_name... | Perform detection of structural variations with delly.
Performs post-call filtering with a custom filter tuned based
on NA12878 Moleculo and PacBio data, using calls prepared by
@ryanlayer and @cc2qe
Filters using the high quality variant pairs (DV) compared with
high quality reference pairs (DR). | [
"Perform",
"detection",
"of",
"structural",
"variations",
"with",
"delly",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/delly.py#L143-L185 | train |
bcbio/bcbio-nextgen | bcbio/rnaseq/oncofuse.py | _disambiguate_star_fusion_junctions | def _disambiguate_star_fusion_junctions(star_junction_file, contamination_bam, disambig_out_file, data):
""" Disambiguate detected fusions based on alignments to another species.
"""
out_file = disambig_out_file
fusiondict = {}
with open(star_junction_file, "r") as in_handle:
for my_line in ... | python | def _disambiguate_star_fusion_junctions(star_junction_file, contamination_bam, disambig_out_file, data):
""" Disambiguate detected fusions based on alignments to another species.
"""
out_file = disambig_out_file
fusiondict = {}
with open(star_junction_file, "r") as in_handle:
for my_line in ... | [
"def",
"_disambiguate_star_fusion_junctions",
"(",
"star_junction_file",
",",
"contamination_bam",
",",
"disambig_out_file",
",",
"data",
")",
":",
"out_file",
"=",
"disambig_out_file",
"fusiondict",
"=",
"{",
"}",
"with",
"open",
"(",
"star_junction_file",
",",
"\"r\... | Disambiguate detected fusions based on alignments to another species. | [
"Disambiguate",
"detected",
"fusions",
"based",
"on",
"alignments",
"to",
"another",
"species",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/oncofuse.py#L167-L189 | train |
dylanaraps/pywal | pywal/wallpaper.py | get_desktop_env | def get_desktop_env():
"""Identify the current running desktop environment."""
desktop = os.environ.get("XDG_CURRENT_DESKTOP")
if desktop:
return desktop
desktop = os.environ.get("DESKTOP_SESSION")
if desktop:
return desktop
desktop = os.environ.get("GNOME_DESKTOP_SESSION_ID")
... | python | def get_desktop_env():
"""Identify the current running desktop environment."""
desktop = os.environ.get("XDG_CURRENT_DESKTOP")
if desktop:
return desktop
desktop = os.environ.get("DESKTOP_SESSION")
if desktop:
return desktop
desktop = os.environ.get("GNOME_DESKTOP_SESSION_ID")
... | [
"def",
"get_desktop_env",
"(",
")",
":",
"desktop",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"XDG_CURRENT_DESKTOP\"",
")",
"if",
"desktop",
":",
"return",
"desktop",
"desktop",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"DESKTOP_SESSION\"",
")",
"i... | Identify the current running desktop environment. | [
"Identify",
"the",
"current",
"running",
"desktop",
"environment",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/wallpaper.py#L13-L39 | train |
dylanaraps/pywal | pywal/wallpaper.py | set_wm_wallpaper | def set_wm_wallpaper(img):
"""Set the wallpaper for non desktop environments."""
if shutil.which("feh"):
util.disown(["feh", "--bg-fill", img])
elif shutil.which("nitrogen"):
util.disown(["nitrogen", "--set-zoom-fill", img])
elif shutil.which("bgs"):
util.disown(["bgs", "-z", i... | python | def set_wm_wallpaper(img):
"""Set the wallpaper for non desktop environments."""
if shutil.which("feh"):
util.disown(["feh", "--bg-fill", img])
elif shutil.which("nitrogen"):
util.disown(["nitrogen", "--set-zoom-fill", img])
elif shutil.which("bgs"):
util.disown(["bgs", "-z", i... | [
"def",
"set_wm_wallpaper",
"(",
"img",
")",
":",
"if",
"shutil",
".",
"which",
"(",
"\"feh\"",
")",
":",
"util",
".",
"disown",
"(",
"[",
"\"feh\"",
",",
"\"--bg-fill\"",
",",
"img",
"]",
")",
"elif",
"shutil",
".",
"which",
"(",
"\"nitrogen\"",
")",
... | Set the wallpaper for non desktop environments. | [
"Set",
"the",
"wallpaper",
"for",
"non",
"desktop",
"environments",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/wallpaper.py#L48-L70 | train |
dylanaraps/pywal | pywal/wallpaper.py | set_desktop_wallpaper | def set_desktop_wallpaper(desktop, img):
"""Set the wallpaper for the desktop environment."""
desktop = str(desktop).lower()
if "xfce" in desktop or "xubuntu" in desktop:
# XFCE requires two commands since they differ between versions.
xfconf("/backdrop/screen0/monitor0/image-path", img)
... | python | def set_desktop_wallpaper(desktop, img):
"""Set the wallpaper for the desktop environment."""
desktop = str(desktop).lower()
if "xfce" in desktop or "xubuntu" in desktop:
# XFCE requires two commands since they differ between versions.
xfconf("/backdrop/screen0/monitor0/image-path", img)
... | [
"def",
"set_desktop_wallpaper",
"(",
"desktop",
",",
"img",
")",
":",
"desktop",
"=",
"str",
"(",
"desktop",
")",
".",
"lower",
"(",
")",
"if",
"\"xfce\"",
"in",
"desktop",
"or",
"\"xubuntu\"",
"in",
"desktop",
":",
"# XFCE requires two commands since they diffe... | Set the wallpaper for the desktop environment. | [
"Set",
"the",
"wallpaper",
"for",
"the",
"desktop",
"environment",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/wallpaper.py#L73-L105 | train |
dylanaraps/pywal | pywal/wallpaper.py | set_mac_wallpaper | def set_mac_wallpaper(img):
"""Set the wallpaper on macOS."""
db_file = "Library/Application Support/Dock/desktoppicture.db"
db_path = os.path.join(HOME, db_file)
img_dir, _ = os.path.split(img)
# Clear the existing picture data and write the image paths
sql = "delete from data; "
sql += "i... | python | def set_mac_wallpaper(img):
"""Set the wallpaper on macOS."""
db_file = "Library/Application Support/Dock/desktoppicture.db"
db_path = os.path.join(HOME, db_file)
img_dir, _ = os.path.split(img)
# Clear the existing picture data and write the image paths
sql = "delete from data; "
sql += "i... | [
"def",
"set_mac_wallpaper",
"(",
"img",
")",
":",
"db_file",
"=",
"\"Library/Application Support/Dock/desktoppicture.db\"",
"db_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"HOME",
",",
"db_file",
")",
"img_dir",
",",
"_",
"=",
"os",
".",
"path",
".",
"s... | Set the wallpaper on macOS. | [
"Set",
"the",
"wallpaper",
"on",
"macOS",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/wallpaper.py#L108-L129 | train |
dylanaraps/pywal | pywal/wallpaper.py | set_win_wallpaper | def set_win_wallpaper(img):
"""Set the wallpaper on Windows."""
# There's a different command depending on the architecture
# of Windows. We check the PROGRAMFILES envar since using
# platform is unreliable.
if "x86" in os.environ["PROGRAMFILES"]:
ctypes.windll.user32.SystemParametersInfoW(2... | python | def set_win_wallpaper(img):
"""Set the wallpaper on Windows."""
# There's a different command depending on the architecture
# of Windows. We check the PROGRAMFILES envar since using
# platform is unreliable.
if "x86" in os.environ["PROGRAMFILES"]:
ctypes.windll.user32.SystemParametersInfoW(2... | [
"def",
"set_win_wallpaper",
"(",
"img",
")",
":",
"# There's a different command depending on the architecture",
"# of Windows. We check the PROGRAMFILES envar since using",
"# platform is unreliable.",
"if",
"\"x86\"",
"in",
"os",
".",
"environ",
"[",
"\"PROGRAMFILES\"",
"]",
":... | Set the wallpaper on Windows. | [
"Set",
"the",
"wallpaper",
"on",
"Windows",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/wallpaper.py#L132-L140 | train |
dylanaraps/pywal | pywal/wallpaper.py | change | def change(img):
"""Set the wallpaper."""
if not os.path.isfile(img):
return
desktop = get_desktop_env()
if OS == "Darwin":
set_mac_wallpaper(img)
elif OS == "Windows":
set_win_wallpaper(img)
else:
set_desktop_wallpaper(desktop, img)
logging.info("Set the... | python | def change(img):
"""Set the wallpaper."""
if not os.path.isfile(img):
return
desktop = get_desktop_env()
if OS == "Darwin":
set_mac_wallpaper(img)
elif OS == "Windows":
set_win_wallpaper(img)
else:
set_desktop_wallpaper(desktop, img)
logging.info("Set the... | [
"def",
"change",
"(",
"img",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"img",
")",
":",
"return",
"desktop",
"=",
"get_desktop_env",
"(",
")",
"if",
"OS",
"==",
"\"Darwin\"",
":",
"set_mac_wallpaper",
"(",
"img",
")",
"elif",
"OS"... | Set the wallpaper. | [
"Set",
"the",
"wallpaper",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/wallpaper.py#L143-L159 | train |
dylanaraps/pywal | pywal/wallpaper.py | get | def get(cache_dir=CACHE_DIR):
"""Get the current wallpaper."""
current_wall = os.path.join(cache_dir, "wal")
if os.path.isfile(current_wall):
return util.read_file(current_wall)[0]
return "None" | python | def get(cache_dir=CACHE_DIR):
"""Get the current wallpaper."""
current_wall = os.path.join(cache_dir, "wal")
if os.path.isfile(current_wall):
return util.read_file(current_wall)[0]
return "None" | [
"def",
"get",
"(",
"cache_dir",
"=",
"CACHE_DIR",
")",
":",
"current_wall",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cache_dir",
",",
"\"wal\"",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"current_wall",
")",
":",
"return",
"util",
".",
"rea... | Get the current wallpaper. | [
"Get",
"the",
"current",
"wallpaper",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/wallpaper.py#L162-L169 | train |
dylanaraps/pywal | pywal/util.py | save_file_json | def save_file_json(data, export_file):
"""Write data to a json file."""
create_dir(os.path.dirname(export_file))
with open(export_file, "w") as file:
json.dump(data, file, indent=4) | python | def save_file_json(data, export_file):
"""Write data to a json file."""
create_dir(os.path.dirname(export_file))
with open(export_file, "w") as file:
json.dump(data, file, indent=4) | [
"def",
"save_file_json",
"(",
"data",
",",
"export_file",
")",
":",
"create_dir",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"export_file",
")",
")",
"with",
"open",
"(",
"export_file",
",",
"\"w\"",
")",
"as",
"file",
":",
"json",
".",
"dump",
"(",
... | Write data to a json file. | [
"Write",
"data",
"to",
"a",
"json",
"file",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/util.py#L90-L95 | train |
dylanaraps/pywal | pywal/util.py | setup_logging | def setup_logging():
"""Logging config."""
logging.basicConfig(format=("[%(levelname)s\033[0m] "
"\033[1;31m%(module)s\033[0m: "
"%(message)s"),
level=logging.INFO,
stream=sys.stdout)
logging.addL... | python | def setup_logging():
"""Logging config."""
logging.basicConfig(format=("[%(levelname)s\033[0m] "
"\033[1;31m%(module)s\033[0m: "
"%(message)s"),
level=logging.INFO,
stream=sys.stdout)
logging.addL... | [
"def",
"setup_logging",
"(",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"(",
"\"[%(levelname)s\\033[0m] \"",
"\"\\033[1;31m%(module)s\\033[0m: \"",
"\"%(message)s\"",
")",
",",
"level",
"=",
"logging",
".",
"INFO",
",",
"stream",
"=",
"sys",
".",... | Logging config. | [
"Logging",
"config",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/util.py#L103-L112 | train |
dylanaraps/pywal | pywal/util.py | darken_color | def darken_color(color, amount):
"""Darken a hex color."""
color = [int(col * (1 - amount)) for col in hex_to_rgb(color)]
return rgb_to_hex(color) | python | def darken_color(color, amount):
"""Darken a hex color."""
color = [int(col * (1 - amount)) for col in hex_to_rgb(color)]
return rgb_to_hex(color) | [
"def",
"darken_color",
"(",
"color",
",",
"amount",
")",
":",
"color",
"=",
"[",
"int",
"(",
"col",
"*",
"(",
"1",
"-",
"amount",
")",
")",
"for",
"col",
"in",
"hex_to_rgb",
"(",
"color",
")",
"]",
"return",
"rgb_to_hex",
"(",
"color",
")"
] | Darken a hex color. | [
"Darken",
"a",
"hex",
"color",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/util.py#L131-L134 | train |
dylanaraps/pywal | pywal/util.py | lighten_color | def lighten_color(color, amount):
"""Lighten a hex color."""
color = [int(col + (255 - col) * amount) for col in hex_to_rgb(color)]
return rgb_to_hex(color) | python | def lighten_color(color, amount):
"""Lighten a hex color."""
color = [int(col + (255 - col) * amount) for col in hex_to_rgb(color)]
return rgb_to_hex(color) | [
"def",
"lighten_color",
"(",
"color",
",",
"amount",
")",
":",
"color",
"=",
"[",
"int",
"(",
"col",
"+",
"(",
"255",
"-",
"col",
")",
"*",
"amount",
")",
"for",
"col",
"in",
"hex_to_rgb",
"(",
"color",
")",
"]",
"return",
"rgb_to_hex",
"(",
"color... | Lighten a hex color. | [
"Lighten",
"a",
"hex",
"color",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/util.py#L137-L140 | train |
dylanaraps/pywal | pywal/util.py | blend_color | def blend_color(color, color2):
"""Blend two colors together."""
r1, g1, b1 = hex_to_rgb(color)
r2, g2, b2 = hex_to_rgb(color2)
r3 = int(0.5 * r1 + 0.5 * r2)
g3 = int(0.5 * g1 + 0.5 * g2)
b3 = int(0.5 * b1 + 0.5 * b2)
return rgb_to_hex((r3, g3, b3)) | python | def blend_color(color, color2):
"""Blend two colors together."""
r1, g1, b1 = hex_to_rgb(color)
r2, g2, b2 = hex_to_rgb(color2)
r3 = int(0.5 * r1 + 0.5 * r2)
g3 = int(0.5 * g1 + 0.5 * g2)
b3 = int(0.5 * b1 + 0.5 * b2)
return rgb_to_hex((r3, g3, b3)) | [
"def",
"blend_color",
"(",
"color",
",",
"color2",
")",
":",
"r1",
",",
"g1",
",",
"b1",
"=",
"hex_to_rgb",
"(",
"color",
")",
"r2",
",",
"g2",
",",
"b2",
"=",
"hex_to_rgb",
"(",
"color2",
")",
"r3",
"=",
"int",
"(",
"0.5",
"*",
"r1",
"+",
"0.5... | Blend two colors together. | [
"Blend",
"two",
"colors",
"together",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/util.py#L143-L152 | train |
dylanaraps/pywal | pywal/util.py | saturate_color | def saturate_color(color, amount):
"""Saturate a hex color."""
r, g, b = hex_to_rgb(color)
r, g, b = [x/255.0 for x in (r, g, b)]
h, l, s = colorsys.rgb_to_hls(r, g, b)
s = amount
r, g, b = colorsys.hls_to_rgb(h, l, s)
r, g, b = [x*255.0 for x in (r, g, b)]
return rgb_to_hex((int(r), in... | python | def saturate_color(color, amount):
"""Saturate a hex color."""
r, g, b = hex_to_rgb(color)
r, g, b = [x/255.0 for x in (r, g, b)]
h, l, s = colorsys.rgb_to_hls(r, g, b)
s = amount
r, g, b = colorsys.hls_to_rgb(h, l, s)
r, g, b = [x*255.0 for x in (r, g, b)]
return rgb_to_hex((int(r), in... | [
"def",
"saturate_color",
"(",
"color",
",",
"amount",
")",
":",
"r",
",",
"g",
",",
"b",
"=",
"hex_to_rgb",
"(",
"color",
")",
"r",
",",
"g",
",",
"b",
"=",
"[",
"x",
"/",
"255.0",
"for",
"x",
"in",
"(",
"r",
",",
"g",
",",
"b",
")",
"]",
... | Saturate a hex color. | [
"Saturate",
"a",
"hex",
"color",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/util.py#L155-L164 | train |
dylanaraps/pywal | pywal/util.py | disown | def disown(cmd):
"""Call a system command in the background,
disown it and hide it's output."""
subprocess.Popen(cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) | python | def disown(cmd):
"""Call a system command in the background,
disown it and hide it's output."""
subprocess.Popen(cmd,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL) | [
"def",
"disown",
"(",
"cmd",
")",
":",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
".",
"DEVNULL",
",",
"stderr",
"=",
"subprocess",
".",
"DEVNULL",
")"
] | Call a system command in the background,
disown it and hide it's output. | [
"Call",
"a",
"system",
"command",
"in",
"the",
"background",
"disown",
"it",
"and",
"hide",
"it",
"s",
"output",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/util.py#L172-L177 | train |
dylanaraps/pywal | pywal/util.py | get_pid | def get_pid(name):
"""Check if process is running by name."""
if not shutil.which("pidof"):
return False
try:
subprocess.check_output(["pidof", "-s", name])
except subprocess.CalledProcessError:
return False
return True | python | def get_pid(name):
"""Check if process is running by name."""
if not shutil.which("pidof"):
return False
try:
subprocess.check_output(["pidof", "-s", name])
except subprocess.CalledProcessError:
return False
return True | [
"def",
"get_pid",
"(",
"name",
")",
":",
"if",
"not",
"shutil",
".",
"which",
"(",
"\"pidof\"",
")",
":",
"return",
"False",
"try",
":",
"subprocess",
".",
"check_output",
"(",
"[",
"\"pidof\"",
",",
"\"-s\"",
",",
"name",
"]",
")",
"except",
"subproce... | Check if process is running by name. | [
"Check",
"if",
"process",
"is",
"running",
"by",
"name",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/util.py#L180-L190 | train |
dylanaraps/pywal | pywal/image.py | get_image_dir | def get_image_dir(img_dir):
"""Get all images in a directory."""
current_wall = wallpaper.get()
current_wall = os.path.basename(current_wall)
file_types = (".png", ".jpg", ".jpeg", ".jpe", ".gif")
return [img.name for img in os.scandir(img_dir)
if img.name.lower().endswith(file_types)]... | python | def get_image_dir(img_dir):
"""Get all images in a directory."""
current_wall = wallpaper.get()
current_wall = os.path.basename(current_wall)
file_types = (".png", ".jpg", ".jpeg", ".jpe", ".gif")
return [img.name for img in os.scandir(img_dir)
if img.name.lower().endswith(file_types)]... | [
"def",
"get_image_dir",
"(",
"img_dir",
")",
":",
"current_wall",
"=",
"wallpaper",
".",
"get",
"(",
")",
"current_wall",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"current_wall",
")",
"file_types",
"=",
"(",
"\".png\"",
",",
"\".jpg\"",
",",
"\".jpeg\... | Get all images in a directory. | [
"Get",
"all",
"images",
"in",
"a",
"directory",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/image.py#L15-L23 | train |
dylanaraps/pywal | pywal/image.py | get_random_image | def get_random_image(img_dir):
"""Pick a random image file from a directory."""
images, current_wall = get_image_dir(img_dir)
if len(images) > 2 and current_wall in images:
images.remove(current_wall)
elif not images:
logging.error("No images found in directory.")
sys.exit(1)
... | python | def get_random_image(img_dir):
"""Pick a random image file from a directory."""
images, current_wall = get_image_dir(img_dir)
if len(images) > 2 and current_wall in images:
images.remove(current_wall)
elif not images:
logging.error("No images found in directory.")
sys.exit(1)
... | [
"def",
"get_random_image",
"(",
"img_dir",
")",
":",
"images",
",",
"current_wall",
"=",
"get_image_dir",
"(",
"img_dir",
")",
"if",
"len",
"(",
"images",
")",
">",
"2",
"and",
"current_wall",
"in",
"images",
":",
"images",
".",
"remove",
"(",
"current_wal... | Pick a random image file from a directory. | [
"Pick",
"a",
"random",
"image",
"file",
"from",
"a",
"directory",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/image.py#L26-L38 | train |
dylanaraps/pywal | pywal/image.py | get_next_image | def get_next_image(img_dir):
"""Get the next image in a dir."""
images, current_wall = get_image_dir(img_dir)
images.sort(key=lambda img: [int(x) if x.isdigit() else x
for x in re.split('([0-9]+)', img)])
try:
next_index = images.index(current_wall) + 1
exc... | python | def get_next_image(img_dir):
"""Get the next image in a dir."""
images, current_wall = get_image_dir(img_dir)
images.sort(key=lambda img: [int(x) if x.isdigit() else x
for x in re.split('([0-9]+)', img)])
try:
next_index = images.index(current_wall) + 1
exc... | [
"def",
"get_next_image",
"(",
"img_dir",
")",
":",
"images",
",",
"current_wall",
"=",
"get_image_dir",
"(",
"img_dir",
")",
"images",
".",
"sort",
"(",
"key",
"=",
"lambda",
"img",
":",
"[",
"int",
"(",
"x",
")",
"if",
"x",
".",
"isdigit",
"(",
")",... | Get the next image in a dir. | [
"Get",
"the",
"next",
"image",
"in",
"a",
"dir",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/image.py#L41-L59 | train |
dylanaraps/pywal | pywal/image.py | get | def get(img, cache_dir=CACHE_DIR, iterative=False):
"""Validate image input."""
if os.path.isfile(img):
wal_img = img
elif os.path.isdir(img):
if iterative:
wal_img = get_next_image(img)
else:
wal_img = get_random_image(img)
else:
logging.error(... | python | def get(img, cache_dir=CACHE_DIR, iterative=False):
"""Validate image input."""
if os.path.isfile(img):
wal_img = img
elif os.path.isdir(img):
if iterative:
wal_img = get_next_image(img)
else:
wal_img = get_random_image(img)
else:
logging.error(... | [
"def",
"get",
"(",
"img",
",",
"cache_dir",
"=",
"CACHE_DIR",
",",
"iterative",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"img",
")",
":",
"wal_img",
"=",
"img",
"elif",
"os",
".",
"path",
".",
"isdir",
"(",
"img",
")",... | Validate image input. | [
"Validate",
"image",
"input",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/image.py#L62-L84 | train |
dylanaraps/pywal | pywal/scripts/gtk_reload.py | gtk_reload | def gtk_reload():
"""Reload GTK2 themes."""
events = gtk.gdk.Event(gtk.gdk.CLIENT_EVENT)
data = gtk.gdk.atom_intern("_GTK_READ_RCFILES", False)
events.data_format = 8
events.send_event = True
events.message_type = data
events.send_clientmessage_toall() | python | def gtk_reload():
"""Reload GTK2 themes."""
events = gtk.gdk.Event(gtk.gdk.CLIENT_EVENT)
data = gtk.gdk.atom_intern("_GTK_READ_RCFILES", False)
events.data_format = 8
events.send_event = True
events.message_type = data
events.send_clientmessage_toall() | [
"def",
"gtk_reload",
"(",
")",
":",
"events",
"=",
"gtk",
".",
"gdk",
".",
"Event",
"(",
"gtk",
".",
"gdk",
".",
"CLIENT_EVENT",
")",
"data",
"=",
"gtk",
".",
"gdk",
".",
"atom_intern",
"(",
"\"_GTK_READ_RCFILES\"",
",",
"False",
")",
"events",
".",
... | Reload GTK2 themes. | [
"Reload",
"GTK2",
"themes",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/scripts/gtk_reload.py#L17-L24 | train |
dylanaraps/pywal | pywal/colors.py | list_backends | def list_backends():
"""List color backends."""
return [b.name.replace(".py", "") for b in
os.scandir(os.path.join(MODULE_DIR, "backends"))
if "__" not in b.name] | python | def list_backends():
"""List color backends."""
return [b.name.replace(".py", "") for b in
os.scandir(os.path.join(MODULE_DIR, "backends"))
if "__" not in b.name] | [
"def",
"list_backends",
"(",
")",
":",
"return",
"[",
"b",
".",
"name",
".",
"replace",
"(",
"\".py\"",
",",
"\"\"",
")",
"for",
"b",
"in",
"os",
".",
"scandir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"MODULE_DIR",
",",
"\"backends\"",
")",
")",... | List color backends. | [
"List",
"color",
"backends",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/colors.py#L15-L19 | train |
dylanaraps/pywal | pywal/colors.py | colors_to_dict | def colors_to_dict(colors, img):
"""Convert list of colors to pywal format."""
return {
"wallpaper": img,
"alpha": util.Color.alpha_num,
"special": {
"background": colors[0],
"foreground": colors[15],
"cursor": colors[15]
},
"colors":... | python | def colors_to_dict(colors, img):
"""Convert list of colors to pywal format."""
return {
"wallpaper": img,
"alpha": util.Color.alpha_num,
"special": {
"background": colors[0],
"foreground": colors[15],
"cursor": colors[15]
},
"colors":... | [
"def",
"colors_to_dict",
"(",
"colors",
",",
"img",
")",
":",
"return",
"{",
"\"wallpaper\"",
":",
"img",
",",
"\"alpha\"",
":",
"util",
".",
"Color",
".",
"alpha_num",
",",
"\"special\"",
":",
"{",
"\"background\"",
":",
"colors",
"[",
"0",
"]",
",",
... | Convert list of colors to pywal format. | [
"Convert",
"list",
"of",
"colors",
"to",
"pywal",
"format",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/colors.py#L22-L52 | train |
dylanaraps/pywal | pywal/colors.py | generic_adjust | def generic_adjust(colors, light):
"""Generic color adjustment for themers."""
if light:
for color in colors:
color = util.saturate_color(color, 0.60)
color = util.darken_color(color, 0.5)
colors[0] = util.lighten_color(colors[0], 0.95)
colors[7] = util.darken_co... | python | def generic_adjust(colors, light):
"""Generic color adjustment for themers."""
if light:
for color in colors:
color = util.saturate_color(color, 0.60)
color = util.darken_color(color, 0.5)
colors[0] = util.lighten_color(colors[0], 0.95)
colors[7] = util.darken_co... | [
"def",
"generic_adjust",
"(",
"colors",
",",
"light",
")",
":",
"if",
"light",
":",
"for",
"color",
"in",
"colors",
":",
"color",
"=",
"util",
".",
"saturate_color",
"(",
"color",
",",
"0.60",
")",
"color",
"=",
"util",
".",
"darken_color",
"(",
"color... | Generic color adjustment for themers. | [
"Generic",
"color",
"adjustment",
"for",
"themers",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/colors.py#L55-L73 | train |
dylanaraps/pywal | pywal/colors.py | saturate_colors | def saturate_colors(colors, amount):
"""Saturate all colors."""
if amount and float(amount) <= 1.0:
for i, _ in enumerate(colors):
if i not in [0, 7, 8, 15]:
colors[i] = util.saturate_color(colors[i], float(amount))
return colors | python | def saturate_colors(colors, amount):
"""Saturate all colors."""
if amount and float(amount) <= 1.0:
for i, _ in enumerate(colors):
if i not in [0, 7, 8, 15]:
colors[i] = util.saturate_color(colors[i], float(amount))
return colors | [
"def",
"saturate_colors",
"(",
"colors",
",",
"amount",
")",
":",
"if",
"amount",
"and",
"float",
"(",
"amount",
")",
"<=",
"1.0",
":",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"colors",
")",
":",
"if",
"i",
"not",
"in",
"[",
"0",
",",
"7",
... | Saturate all colors. | [
"Saturate",
"all",
"colors",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/colors.py#L76-L83 | train |
dylanaraps/pywal | pywal/colors.py | get_backend | def get_backend(backend):
"""Figure out which backend to use."""
if backend == "random":
backends = list_backends()
random.shuffle(backends)
return backends[0]
return backend | python | def get_backend(backend):
"""Figure out which backend to use."""
if backend == "random":
backends = list_backends()
random.shuffle(backends)
return backends[0]
return backend | [
"def",
"get_backend",
"(",
"backend",
")",
":",
"if",
"backend",
"==",
"\"random\"",
":",
"backends",
"=",
"list_backends",
"(",
")",
"random",
".",
"shuffle",
"(",
"backends",
")",
"return",
"backends",
"[",
"0",
"]",
"return",
"backend"
] | Figure out which backend to use. | [
"Figure",
"out",
"which",
"backend",
"to",
"use",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/colors.py#L97-L104 | train |
dylanaraps/pywal | pywal/colors.py | palette | def palette():
"""Generate a palette from the colors."""
for i in range(0, 16):
if i % 8 == 0:
print()
if i > 7:
i = "8;5;%s" % i
print("\033[4%sm%s\033[0m" % (i, " " * (80 // 20)), end="")
print("\n") | python | def palette():
"""Generate a palette from the colors."""
for i in range(0, 16):
if i % 8 == 0:
print()
if i > 7:
i = "8;5;%s" % i
print("\033[4%sm%s\033[0m" % (i, " " * (80 // 20)), end="")
print("\n") | [
"def",
"palette",
"(",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"16",
")",
":",
"if",
"i",
"%",
"8",
"==",
"0",
":",
"print",
"(",
")",
"if",
"i",
">",
"7",
":",
"i",
"=",
"\"8;5;%s\"",
"%",
"i",
"print",
"(",
"\"\\033[4%sm%s\\033[... | Generate a palette from the colors. | [
"Generate",
"a",
"palette",
"from",
"the",
"colors",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/colors.py#L107-L118 | train |
dylanaraps/pywal | pywal/backends/colorthief.py | gen_colors | def gen_colors(img):
"""Loop until 16 colors are generated."""
color_cmd = ColorThief(img).get_palette
for i in range(0, 10, 1):
raw_colors = color_cmd(color_count=8 + i)
if len(raw_colors) >= 8:
break
elif i == 10:
logging.error("ColorThief couldn't genera... | python | def gen_colors(img):
"""Loop until 16 colors are generated."""
color_cmd = ColorThief(img).get_palette
for i in range(0, 10, 1):
raw_colors = color_cmd(color_count=8 + i)
if len(raw_colors) >= 8:
break
elif i == 10:
logging.error("ColorThief couldn't genera... | [
"def",
"gen_colors",
"(",
"img",
")",
":",
"color_cmd",
"=",
"ColorThief",
"(",
"img",
")",
".",
"get_palette",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"10",
",",
"1",
")",
":",
"raw_colors",
"=",
"color_cmd",
"(",
"color_count",
"=",
"8",
"+",
"... | Loop until 16 colors are generated. | [
"Loop",
"until",
"16",
"colors",
"are",
"generated",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/backends/colorthief.py#L18-L36 | train |
dylanaraps/pywal | pywal/theme.py | list_out | def list_out():
"""List all themes in a pretty format."""
dark_themes = [theme.name.replace(".json", "")
for theme in list_themes()]
ligh_themes = [theme.name.replace(".json", "")
for theme in list_themes(dark=False)]
user_themes = [theme.name.replace(".json", "")
... | python | def list_out():
"""List all themes in a pretty format."""
dark_themes = [theme.name.replace(".json", "")
for theme in list_themes()]
ligh_themes = [theme.name.replace(".json", "")
for theme in list_themes(dark=False)]
user_themes = [theme.name.replace(".json", "")
... | [
"def",
"list_out",
"(",
")",
":",
"dark_themes",
"=",
"[",
"theme",
".",
"name",
".",
"replace",
"(",
"\".json\"",
",",
"\"\"",
")",
"for",
"theme",
"in",
"list_themes",
"(",
")",
"]",
"ligh_themes",
"=",
"[",
"theme",
".",
"name",
".",
"replace",
"(... | List all themes in a pretty format. | [
"List",
"all",
"themes",
"in",
"a",
"pretty",
"format",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/theme.py#L13-L35 | train |
dylanaraps/pywal | pywal/theme.py | list_themes | def list_themes(dark=True):
"""List all installed theme files."""
dark = "dark" if dark else "light"
themes = os.scandir(os.path.join(MODULE_DIR, "colorschemes", dark))
return [t for t in themes if os.path.isfile(t.path)] | python | def list_themes(dark=True):
"""List all installed theme files."""
dark = "dark" if dark else "light"
themes = os.scandir(os.path.join(MODULE_DIR, "colorschemes", dark))
return [t for t in themes if os.path.isfile(t.path)] | [
"def",
"list_themes",
"(",
"dark",
"=",
"True",
")",
":",
"dark",
"=",
"\"dark\"",
"if",
"dark",
"else",
"\"light\"",
"themes",
"=",
"os",
".",
"scandir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"MODULE_DIR",
",",
"\"colorschemes\"",
",",
"dark",
")"... | List all installed theme files. | [
"List",
"all",
"installed",
"theme",
"files",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/theme.py#L38-L42 | train |
dylanaraps/pywal | pywal/theme.py | list_themes_user | def list_themes_user():
"""List user theme files."""
themes = [*os.scandir(os.path.join(CONF_DIR, "colorschemes/dark/")),
*os.scandir(os.path.join(CONF_DIR, "colorschemes/light/"))]
return [t for t in themes if os.path.isfile(t.path)] | python | def list_themes_user():
"""List user theme files."""
themes = [*os.scandir(os.path.join(CONF_DIR, "colorschemes/dark/")),
*os.scandir(os.path.join(CONF_DIR, "colorschemes/light/"))]
return [t for t in themes if os.path.isfile(t.path)] | [
"def",
"list_themes_user",
"(",
")",
":",
"themes",
"=",
"[",
"*",
"os",
".",
"scandir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"CONF_DIR",
",",
"\"colorschemes/dark/\"",
")",
")",
",",
"*",
"os",
".",
"scandir",
"(",
"os",
".",
"path",
".",
"jo... | List user theme files. | [
"List",
"user",
"theme",
"files",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/theme.py#L45-L49 | train |
dylanaraps/pywal | pywal/theme.py | terminal_sexy_to_wal | def terminal_sexy_to_wal(data):
"""Convert terminal.sexy json schema to wal."""
data["colors"] = {}
data["special"] = {
"foreground": data["foreground"],
"background": data["background"],
"cursor": data["color"][9]
}
for i, color in enumerate(data["color"]):
data["co... | python | def terminal_sexy_to_wal(data):
"""Convert terminal.sexy json schema to wal."""
data["colors"] = {}
data["special"] = {
"foreground": data["foreground"],
"background": data["background"],
"cursor": data["color"][9]
}
for i, color in enumerate(data["color"]):
data["co... | [
"def",
"terminal_sexy_to_wal",
"(",
"data",
")",
":",
"data",
"[",
"\"colors\"",
"]",
"=",
"{",
"}",
"data",
"[",
"\"special\"",
"]",
"=",
"{",
"\"foreground\"",
":",
"data",
"[",
"\"foreground\"",
"]",
",",
"\"background\"",
":",
"data",
"[",
"\"backgroun... | Convert terminal.sexy json schema to wal. | [
"Convert",
"terminal",
".",
"sexy",
"json",
"schema",
"to",
"wal",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/theme.py#L52-L64 | train |
dylanaraps/pywal | pywal/theme.py | parse | def parse(theme_file):
"""Parse the theme file."""
data = util.read_file_json(theme_file)
if "wallpaper" not in data:
data["wallpaper"] = "None"
if "alpha" not in data:
data["alpha"] = util.Color.alpha_num
# Terminal.sexy format.
if "color" in data:
data = terminal_sex... | python | def parse(theme_file):
"""Parse the theme file."""
data = util.read_file_json(theme_file)
if "wallpaper" not in data:
data["wallpaper"] = "None"
if "alpha" not in data:
data["alpha"] = util.Color.alpha_num
# Terminal.sexy format.
if "color" in data:
data = terminal_sex... | [
"def",
"parse",
"(",
"theme_file",
")",
":",
"data",
"=",
"util",
".",
"read_file_json",
"(",
"theme_file",
")",
"if",
"\"wallpaper\"",
"not",
"in",
"data",
":",
"data",
"[",
"\"wallpaper\"",
"]",
"=",
"\"None\"",
"if",
"\"alpha\"",
"not",
"in",
"data",
... | Parse the theme file. | [
"Parse",
"the",
"theme",
"file",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/theme.py#L67-L81 | train |
dylanaraps/pywal | pywal/theme.py | get_random_theme | def get_random_theme(dark=True):
"""Get a random theme file."""
themes = [theme.path for theme in list_themes(dark)]
random.shuffle(themes)
return themes[0] | python | def get_random_theme(dark=True):
"""Get a random theme file."""
themes = [theme.path for theme in list_themes(dark)]
random.shuffle(themes)
return themes[0] | [
"def",
"get_random_theme",
"(",
"dark",
"=",
"True",
")",
":",
"themes",
"=",
"[",
"theme",
".",
"path",
"for",
"theme",
"in",
"list_themes",
"(",
"dark",
")",
"]",
"random",
".",
"shuffle",
"(",
"themes",
")",
"return",
"themes",
"[",
"0",
"]"
] | Get a random theme file. | [
"Get",
"a",
"random",
"theme",
"file",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/theme.py#L84-L88 | train |
dylanaraps/pywal | pywal/theme.py | file | def file(input_file, light=False):
"""Import colorscheme from json file."""
util.create_dir(os.path.join(CONF_DIR, "colorschemes/light/"))
util.create_dir(os.path.join(CONF_DIR, "colorschemes/dark/"))
theme_name = ".".join((input_file, "json"))
bri = "light" if light else "dark"
user_theme_fil... | python | def file(input_file, light=False):
"""Import colorscheme from json file."""
util.create_dir(os.path.join(CONF_DIR, "colorschemes/light/"))
util.create_dir(os.path.join(CONF_DIR, "colorschemes/dark/"))
theme_name = ".".join((input_file, "json"))
bri = "light" if light else "dark"
user_theme_fil... | [
"def",
"file",
"(",
"input_file",
",",
"light",
"=",
"False",
")",
":",
"util",
".",
"create_dir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"CONF_DIR",
",",
"\"colorschemes/light/\"",
")",
")",
"util",
".",
"create_dir",
"(",
"os",
".",
"path",
".",
... | Import colorscheme from json file. | [
"Import",
"colorscheme",
"from",
"json",
"file",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/theme.py#L91-L124 | train |
dylanaraps/pywal | pywal/backends/wal.py | imagemagick | def imagemagick(color_count, img, magick_command):
"""Call Imagemagick to generate a scheme."""
flags = ["-resize", "25%", "-colors", str(color_count),
"-unique-colors", "txt:-"]
img += "[0]"
return subprocess.check_output([*magick_command, img, *flags]).splitlines() | python | def imagemagick(color_count, img, magick_command):
"""Call Imagemagick to generate a scheme."""
flags = ["-resize", "25%", "-colors", str(color_count),
"-unique-colors", "txt:-"]
img += "[0]"
return subprocess.check_output([*magick_command, img, *flags]).splitlines() | [
"def",
"imagemagick",
"(",
"color_count",
",",
"img",
",",
"magick_command",
")",
":",
"flags",
"=",
"[",
"\"-resize\"",
",",
"\"25%\"",
",",
"\"-colors\"",
",",
"str",
"(",
"color_count",
")",
",",
"\"-unique-colors\"",
",",
"\"txt:-\"",
"]",
"img",
"+=",
... | Call Imagemagick to generate a scheme. | [
"Call",
"Imagemagick",
"to",
"generate",
"a",
"scheme",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/backends/wal.py#L13-L19 | train |
dylanaraps/pywal | pywal/backends/wal.py | has_im | def has_im():
"""Check to see if the user has im installed."""
if shutil.which("magick"):
return ["magick", "convert"]
if shutil.which("convert"):
return ["convert"]
logging.error("Imagemagick wasn't found on your system.")
logging.error("Try another backend. (wal --backend)")
... | python | def has_im():
"""Check to see if the user has im installed."""
if shutil.which("magick"):
return ["magick", "convert"]
if shutil.which("convert"):
return ["convert"]
logging.error("Imagemagick wasn't found on your system.")
logging.error("Try another backend. (wal --backend)")
... | [
"def",
"has_im",
"(",
")",
":",
"if",
"shutil",
".",
"which",
"(",
"\"magick\"",
")",
":",
"return",
"[",
"\"magick\"",
",",
"\"convert\"",
"]",
"if",
"shutil",
".",
"which",
"(",
"\"convert\"",
")",
":",
"return",
"[",
"\"convert\"",
"]",
"logging",
"... | Check to see if the user has im installed. | [
"Check",
"to",
"see",
"if",
"the",
"user",
"has",
"im",
"installed",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/backends/wal.py#L22-L32 | train |
dylanaraps/pywal | pywal/backends/wal.py | gen_colors | def gen_colors(img):
"""Format the output from imagemagick into a list
of hex colors."""
magick_command = has_im()
for i in range(0, 20, 1):
raw_colors = imagemagick(16 + i, img, magick_command)
if len(raw_colors) > 16:
break
elif i == 19:
logging.er... | python | def gen_colors(img):
"""Format the output from imagemagick into a list
of hex colors."""
magick_command = has_im()
for i in range(0, 20, 1):
raw_colors = imagemagick(16 + i, img, magick_command)
if len(raw_colors) > 16:
break
elif i == 19:
logging.er... | [
"def",
"gen_colors",
"(",
"img",
")",
":",
"magick_command",
"=",
"has_im",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"20",
",",
"1",
")",
":",
"raw_colors",
"=",
"imagemagick",
"(",
"16",
"+",
"i",
",",
"img",
",",
"magick_command",
")",... | Format the output from imagemagick into a list
of hex colors. | [
"Format",
"the",
"output",
"from",
"imagemagick",
"into",
"a",
"list",
"of",
"hex",
"colors",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/backends/wal.py#L35-L54 | train |
dylanaraps/pywal | pywal/backends/wal.py | adjust | def adjust(colors, light):
"""Adjust the generated colors and store them in a dict that
we will later save in json format."""
raw_colors = colors[:1] + colors[8:16] + colors[8:-1]
# Manually adjust colors.
if light:
for color in raw_colors:
color = util.saturate_color(color, ... | python | def adjust(colors, light):
"""Adjust the generated colors and store them in a dict that
we will later save in json format."""
raw_colors = colors[:1] + colors[8:16] + colors[8:-1]
# Manually adjust colors.
if light:
for color in raw_colors:
color = util.saturate_color(color, ... | [
"def",
"adjust",
"(",
"colors",
",",
"light",
")",
":",
"raw_colors",
"=",
"colors",
"[",
":",
"1",
"]",
"+",
"colors",
"[",
"8",
":",
"16",
"]",
"+",
"colors",
"[",
"8",
":",
"-",
"1",
"]",
"# Manually adjust colors.",
"if",
"light",
":",
"for",
... | Adjust the generated colors and store them in a dict that
we will later save in json format. | [
"Adjust",
"the",
"generated",
"colors",
"and",
"store",
"them",
"in",
"a",
"dict",
"that",
"we",
"will",
"later",
"save",
"in",
"json",
"format",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/backends/wal.py#L57-L81 | train |
dylanaraps/pywal | pywal/__main__.py | parse_args_exit | def parse_args_exit(parser):
"""Process args that exit."""
args = parser.parse_args()
if len(sys.argv) <= 1:
parser.print_help()
sys.exit(1)
if args.v:
parser.exit(0, "wal %s\n" % __version__)
if args.preview:
print("Current colorscheme:", sep='')
colors.pa... | python | def parse_args_exit(parser):
"""Process args that exit."""
args = parser.parse_args()
if len(sys.argv) <= 1:
parser.print_help()
sys.exit(1)
if args.v:
parser.exit(0, "wal %s\n" % __version__)
if args.preview:
print("Current colorscheme:", sep='')
colors.pa... | [
"def",
"parse_args_exit",
"(",
"parser",
")",
":",
"args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"if",
"len",
"(",
"sys",
".",
"argv",
")",
"<=",
"1",
":",
"parser",
".",
"print_help",
"(",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"if",
"arg... | Process args that exit. | [
"Process",
"args",
"that",
"exit",
"."
] | c823e3c9dbd0100ca09caf824e77d296685a1c1e | https://github.com/dylanaraps/pywal/blob/c823e3c9dbd0100ca09caf824e77d296685a1c1e/pywal/__main__.py#L105-L147 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.