id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
223,700 | bcbio/bcbio-nextgen | bcbio/utils.py | reservoir_sample | def reservoir_sample(stream, num_items, item_parser=lambda x: x):
"""
samples num_items from the stream keeping each with equal probability
"""
kept = []
for index, item in enumerate(stream):
if index < num_items:
kept.append(item_parser(item))
else:
r = rando... | python | def reservoir_sample(stream, num_items, item_parser=lambda x: x):
"""
samples num_items from the stream keeping each with equal probability
"""
kept = []
for index, item in enumerate(stream):
if index < num_items:
kept.append(item_parser(item))
else:
r = rando... | [
"def",
"reservoir_sample",
"(",
"stream",
",",
"num_items",
",",
"item_parser",
"=",
"lambda",
"x",
":",
"x",
")",
":",
"kept",
"=",
"[",
"]",
"for",
"index",
",",
"item",
"in",
"enumerate",
"(",
"stream",
")",
":",
"if",
"index",
"<",
"num_items",
"... | samples num_items from the stream keeping each with equal probability | [
"samples",
"num_items",
"from",
"the",
"stream",
"keeping",
"each",
"with",
"equal",
"probability"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L663-L675 |
223,701 | bcbio/bcbio-nextgen | bcbio/utils.py | dictapply | def dictapply(d, fn):
"""
apply a function to all non-dict values in a dictionary
"""
for k, v in d.items():
if isinstance(v, dict):
v = dictapply(v, fn)
else:
d[k] = fn(v)
return d | python | def dictapply(d, fn):
"""
apply a function to all non-dict values in a dictionary
"""
for k, v in d.items():
if isinstance(v, dict):
v = dictapply(v, fn)
else:
d[k] = fn(v)
return d | [
"def",
"dictapply",
"(",
"d",
",",
"fn",
")",
":",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
"v",
"=",
"dictapply",
"(",
"v",
",",
"fn",
")",
"else",
":",
"d",
"[",
... | apply a function to all non-dict values in a dictionary | [
"apply",
"a",
"function",
"to",
"all",
"non",
"-",
"dict",
"values",
"in",
"a",
"dictionary"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L681-L690 |
223,702 | bcbio/bcbio-nextgen | bcbio/utils.py | Rscript_cmd | def Rscript_cmd():
"""Retrieve path to locally installed Rscript or first in PATH.
Prefers Rscript version installed via conda to a system version.
"""
rscript = which(os.path.join(get_bcbio_bin(), "Rscript"))
if rscript:
return rscript
else:
return which("Rscript") | python | def Rscript_cmd():
"""Retrieve path to locally installed Rscript or first in PATH.
Prefers Rscript version installed via conda to a system version.
"""
rscript = which(os.path.join(get_bcbio_bin(), "Rscript"))
if rscript:
return rscript
else:
return which("Rscript") | [
"def",
"Rscript_cmd",
"(",
")",
":",
"rscript",
"=",
"which",
"(",
"os",
".",
"path",
".",
"join",
"(",
"get_bcbio_bin",
"(",
")",
",",
"\"Rscript\"",
")",
")",
"if",
"rscript",
":",
"return",
"rscript",
"else",
":",
"return",
"which",
"(",
"\"Rscript\... | Retrieve path to locally installed Rscript or first in PATH.
Prefers Rscript version installed via conda to a system version. | [
"Retrieve",
"path",
"to",
"locally",
"installed",
"Rscript",
"or",
"first",
"in",
"PATH",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L692-L701 |
223,703 | bcbio/bcbio-nextgen | bcbio/utils.py | R_package_resource | def R_package_resource(package, resource):
"""
return a path to an R package resource, if it is available
"""
package_path = R_package_path(package)
if not package_path:
return None
package_resource = os.path.join(package_path, resource)
if not file_exists(package_resource):
... | python | def R_package_resource(package, resource):
"""
return a path to an R package resource, if it is available
"""
package_path = R_package_path(package)
if not package_path:
return None
package_resource = os.path.join(package_path, resource)
if not file_exists(package_resource):
... | [
"def",
"R_package_resource",
"(",
"package",
",",
"resource",
")",
":",
"package_path",
"=",
"R_package_path",
"(",
"package",
")",
"if",
"not",
"package_path",
":",
"return",
"None",
"package_resource",
"=",
"os",
".",
"path",
".",
"join",
"(",
"package_path"... | return a path to an R package resource, if it is available | [
"return",
"a",
"path",
"to",
"an",
"R",
"package",
"resource",
"if",
"it",
"is",
"available"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L727-L738 |
223,704 | bcbio/bcbio-nextgen | bcbio/utils.py | get_java_binpath | def get_java_binpath(cmd=None):
"""Retrieve path for java to use, handling custom BCBIO_JAVA_HOME
Defaults to the dirname of cmd, or local anaconda directory
"""
if os.environ.get("BCBIO_JAVA_HOME"):
test_cmd = os.path.join(os.environ["BCBIO_JAVA_HOME"], "bin", "java")
if os.path.exists... | python | def get_java_binpath(cmd=None):
"""Retrieve path for java to use, handling custom BCBIO_JAVA_HOME
Defaults to the dirname of cmd, or local anaconda directory
"""
if os.environ.get("BCBIO_JAVA_HOME"):
test_cmd = os.path.join(os.environ["BCBIO_JAVA_HOME"], "bin", "java")
if os.path.exists... | [
"def",
"get_java_binpath",
"(",
"cmd",
"=",
"None",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"\"BCBIO_JAVA_HOME\"",
")",
":",
"test_cmd",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
"[",
"\"BCBIO_JAVA_HOME\"",
"]",
","... | Retrieve path for java to use, handling custom BCBIO_JAVA_HOME
Defaults to the dirname of cmd, or local anaconda directory | [
"Retrieve",
"path",
"for",
"java",
"to",
"use",
"handling",
"custom",
"BCBIO_JAVA_HOME"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L740-L751 |
223,705 | bcbio/bcbio-nextgen | bcbio/utils.py | clear_java_home | def clear_java_home():
"""Clear JAVA_HOME environment or reset to BCBIO_JAVA_HOME.
Avoids accidental java injection but respects custom BCBIO_JAVA_HOME
command.
"""
if os.environ.get("BCBIO_JAVA_HOME"):
test_cmd = os.path.join(os.environ["BCBIO_JAVA_HOME"], "bin", "java")
if os.path... | python | def clear_java_home():
"""Clear JAVA_HOME environment or reset to BCBIO_JAVA_HOME.
Avoids accidental java injection but respects custom BCBIO_JAVA_HOME
command.
"""
if os.environ.get("BCBIO_JAVA_HOME"):
test_cmd = os.path.join(os.environ["BCBIO_JAVA_HOME"], "bin", "java")
if os.path... | [
"def",
"clear_java_home",
"(",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"\"BCBIO_JAVA_HOME\"",
")",
":",
"test_cmd",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
"[",
"\"BCBIO_JAVA_HOME\"",
"]",
",",
"\"bin\"",
",",
"\"... | Clear JAVA_HOME environment or reset to BCBIO_JAVA_HOME.
Avoids accidental java injection but respects custom BCBIO_JAVA_HOME
command. | [
"Clear",
"JAVA_HOME",
"environment",
"or",
"reset",
"to",
"BCBIO_JAVA_HOME",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L753-L763 |
223,706 | bcbio/bcbio-nextgen | bcbio/utils.py | perl_cmd | def perl_cmd():
"""Retrieve path to locally installed conda Perl or first in PATH.
"""
perl = which(os.path.join(get_bcbio_bin(), "perl"))
if perl:
return perl
else:
return which("perl") | python | def perl_cmd():
"""Retrieve path to locally installed conda Perl or first in PATH.
"""
perl = which(os.path.join(get_bcbio_bin(), "perl"))
if perl:
return perl
else:
return which("perl") | [
"def",
"perl_cmd",
"(",
")",
":",
"perl",
"=",
"which",
"(",
"os",
".",
"path",
".",
"join",
"(",
"get_bcbio_bin",
"(",
")",
",",
"\"perl\"",
")",
")",
"if",
"perl",
":",
"return",
"perl",
"else",
":",
"return",
"which",
"(",
"\"perl\"",
")"
] | Retrieve path to locally installed conda Perl or first in PATH. | [
"Retrieve",
"path",
"to",
"locally",
"installed",
"conda",
"Perl",
"or",
"first",
"in",
"PATH",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L773-L780 |
223,707 | bcbio/bcbio-nextgen | bcbio/utils.py | get_perl_exports | def get_perl_exports(tmpdir=None):
"""Environmental exports to use conda installed perl.
"""
perl_path = os.path.dirname(perl_cmd())
out = "unset PERL5LIB && export PATH=%s:\"$PATH\"" % (perl_path)
if tmpdir:
out += " && export TMPDIR=%s" % (tmpdir)
return out | python | def get_perl_exports(tmpdir=None):
"""Environmental exports to use conda installed perl.
"""
perl_path = os.path.dirname(perl_cmd())
out = "unset PERL5LIB && export PATH=%s:\"$PATH\"" % (perl_path)
if tmpdir:
out += " && export TMPDIR=%s" % (tmpdir)
return out | [
"def",
"get_perl_exports",
"(",
"tmpdir",
"=",
"None",
")",
":",
"perl_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"perl_cmd",
"(",
")",
")",
"out",
"=",
"\"unset PERL5LIB && export PATH=%s:\\\"$PATH\\\"\"",
"%",
"(",
"perl_path",
")",
"if",
"tmpdir",
... | Environmental exports to use conda installed perl. | [
"Environmental",
"exports",
"to",
"use",
"conda",
"installed",
"perl",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L782-L789 |
223,708 | bcbio/bcbio-nextgen | bcbio/utils.py | get_all_conda_bins | def get_all_conda_bins():
"""Retrieve all possible conda bin directories, including environments.
"""
bcbio_bin = get_bcbio_bin()
conda_dir = os.path.dirname(bcbio_bin)
if os.path.join("anaconda", "envs") in conda_dir:
conda_dir = os.path.join(conda_dir[:conda_dir.rfind(os.path.join("anacond... | python | def get_all_conda_bins():
"""Retrieve all possible conda bin directories, including environments.
"""
bcbio_bin = get_bcbio_bin()
conda_dir = os.path.dirname(bcbio_bin)
if os.path.join("anaconda", "envs") in conda_dir:
conda_dir = os.path.join(conda_dir[:conda_dir.rfind(os.path.join("anacond... | [
"def",
"get_all_conda_bins",
"(",
")",
":",
"bcbio_bin",
"=",
"get_bcbio_bin",
"(",
")",
"conda_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"bcbio_bin",
")",
"if",
"os",
".",
"path",
".",
"join",
"(",
"\"anaconda\"",
",",
"\"envs\"",
")",
"in",
... | Retrieve all possible conda bin directories, including environments. | [
"Retrieve",
"all",
"possible",
"conda",
"bin",
"directories",
"including",
"environments",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L809-L816 |
223,709 | bcbio/bcbio-nextgen | bcbio/utils.py | get_program_python | def get_program_python(cmd):
"""Get the full path to a python version linked to the command.
Allows finding python based programs in python 2 versus python 3
environments.
"""
full_cmd = os.path.realpath(which(cmd))
cmd_python = os.path.join(os.path.dirname(full_cmd), "python")
env_python =... | python | def get_program_python(cmd):
"""Get the full path to a python version linked to the command.
Allows finding python based programs in python 2 versus python 3
environments.
"""
full_cmd = os.path.realpath(which(cmd))
cmd_python = os.path.join(os.path.dirname(full_cmd), "python")
env_python =... | [
"def",
"get_program_python",
"(",
"cmd",
")",
":",
"full_cmd",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"which",
"(",
"cmd",
")",
")",
"cmd_python",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"full_cmd",
... | Get the full path to a python version linked to the command.
Allows finding python based programs in python 2 versus python 3
environments. | [
"Get",
"the",
"full",
"path",
"to",
"a",
"python",
"version",
"linked",
"to",
"the",
"command",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L818-L835 |
223,710 | bcbio/bcbio-nextgen | bcbio/utils.py | local_path_export | def local_path_export(at_start=True, env_cmd=None):
"""Retrieve paths to local install, also including environment paths if env_cmd included.
"""
paths = [get_bcbio_bin()]
if env_cmd:
env_path = os.path.dirname(get_program_python(env_cmd))
if env_path not in paths:
paths.inse... | python | def local_path_export(at_start=True, env_cmd=None):
"""Retrieve paths to local install, also including environment paths if env_cmd included.
"""
paths = [get_bcbio_bin()]
if env_cmd:
env_path = os.path.dirname(get_program_python(env_cmd))
if env_path not in paths:
paths.inse... | [
"def",
"local_path_export",
"(",
"at_start",
"=",
"True",
",",
"env_cmd",
"=",
"None",
")",
":",
"paths",
"=",
"[",
"get_bcbio_bin",
"(",
")",
"]",
"if",
"env_cmd",
":",
"env_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"get_program_python",
"(",
... | Retrieve paths to local install, also including environment paths if env_cmd included. | [
"Retrieve",
"paths",
"to",
"local",
"install",
"also",
"including",
"environment",
"paths",
"if",
"env_cmd",
"included",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L837-L848 |
223,711 | bcbio/bcbio-nextgen | bcbio/utils.py | rbind | def rbind(dfs):
"""
acts like rbind for pandas dataframes
"""
if len(dfs) == 1:
return dfs[0]
df = dfs[0]
for d in dfs[1:]:
df = df.append(d)
return df | python | def rbind(dfs):
"""
acts like rbind for pandas dataframes
"""
if len(dfs) == 1:
return dfs[0]
df = dfs[0]
for d in dfs[1:]:
df = df.append(d)
return df | [
"def",
"rbind",
"(",
"dfs",
")",
":",
"if",
"len",
"(",
"dfs",
")",
"==",
"1",
":",
"return",
"dfs",
"[",
"0",
"]",
"df",
"=",
"dfs",
"[",
"0",
"]",
"for",
"d",
"in",
"dfs",
"[",
"1",
":",
"]",
":",
"df",
"=",
"df",
".",
"append",
"(",
... | acts like rbind for pandas dataframes | [
"acts",
"like",
"rbind",
"for",
"pandas",
"dataframes"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L902-L911 |
223,712 | bcbio/bcbio-nextgen | bcbio/utils.py | sort_filenames | def sort_filenames(filenames):
"""
sort a list of files by filename only, ignoring the directory names
"""
basenames = [os.path.basename(x) for x in filenames]
indexes = [i[0] for i in sorted(enumerate(basenames), key=lambda x:x[1])]
return [filenames[x] for x in indexes] | python | def sort_filenames(filenames):
"""
sort a list of files by filename only, ignoring the directory names
"""
basenames = [os.path.basename(x) for x in filenames]
indexes = [i[0] for i in sorted(enumerate(basenames), key=lambda x:x[1])]
return [filenames[x] for x in indexes] | [
"def",
"sort_filenames",
"(",
"filenames",
")",
":",
"basenames",
"=",
"[",
"os",
".",
"path",
".",
"basename",
"(",
"x",
")",
"for",
"x",
"in",
"filenames",
"]",
"indexes",
"=",
"[",
"i",
"[",
"0",
"]",
"for",
"i",
"in",
"sorted",
"(",
"enumerate"... | sort a list of files by filename only, ignoring the directory names | [
"sort",
"a",
"list",
"of",
"files",
"by",
"filename",
"only",
"ignoring",
"the",
"directory",
"names"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L936-L942 |
223,713 | bcbio/bcbio-nextgen | bcbio/utils.py | walk_json | def walk_json(d, func):
""" Walk over a parsed JSON nested structure `d`, apply `func` to each leaf element and replace it with result
"""
if isinstance(d, Mapping):
return OrderedDict((k, walk_json(v, func)) for k, v in d.items())
elif isinstance(d, list):
return [walk_json(v, func) for... | python | def walk_json(d, func):
""" Walk over a parsed JSON nested structure `d`, apply `func` to each leaf element and replace it with result
"""
if isinstance(d, Mapping):
return OrderedDict((k, walk_json(v, func)) for k, v in d.items())
elif isinstance(d, list):
return [walk_json(v, func) for... | [
"def",
"walk_json",
"(",
"d",
",",
"func",
")",
":",
"if",
"isinstance",
"(",
"d",
",",
"Mapping",
")",
":",
"return",
"OrderedDict",
"(",
"(",
"k",
",",
"walk_json",
"(",
"v",
",",
"func",
")",
")",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items... | Walk over a parsed JSON nested structure `d`, apply `func` to each leaf element and replace it with result | [
"Walk",
"over",
"a",
"parsed",
"JSON",
"nested",
"structure",
"d",
"apply",
"func",
"to",
"each",
"leaf",
"element",
"and",
"replace",
"it",
"with",
"result"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/utils.py#L989-L997 |
223,714 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | _link_bam_file | def _link_bam_file(in_file, new_dir, data):
"""Provide symlinks of BAM file and existing indexes if needed.
"""
new_dir = utils.safe_makedir(new_dir)
out_file = os.path.join(new_dir, os.path.basename(in_file))
if not utils.file_exists(out_file):
out_file = os.path.join(new_dir, "%s-prealign.... | python | def _link_bam_file(in_file, new_dir, data):
"""Provide symlinks of BAM file and existing indexes if needed.
"""
new_dir = utils.safe_makedir(new_dir)
out_file = os.path.join(new_dir, os.path.basename(in_file))
if not utils.file_exists(out_file):
out_file = os.path.join(new_dir, "%s-prealign.... | [
"def",
"_link_bam_file",
"(",
"in_file",
",",
"new_dir",
",",
"data",
")",
":",
"new_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"new_dir",
")",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"new_dir",
",",
"os",
".",
"path",
".",
"basename",... | Provide symlinks of BAM file and existing indexes if needed. | [
"Provide",
"symlinks",
"of",
"BAM",
"file",
"and",
"existing",
"indexes",
"if",
"needed",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L69-L84 |
223,715 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | _add_supplemental_bams | def _add_supplemental_bams(data):
"""Add supplemental files produced by alignment, useful for structural
variant calling.
"""
file_key = "work_bam"
if data.get(file_key):
for supext in ["disc", "sr"]:
base, ext = os.path.splitext(data[file_key])
test_file = "%s-%s%s" ... | python | def _add_supplemental_bams(data):
"""Add supplemental files produced by alignment, useful for structural
variant calling.
"""
file_key = "work_bam"
if data.get(file_key):
for supext in ["disc", "sr"]:
base, ext = os.path.splitext(data[file_key])
test_file = "%s-%s%s" ... | [
"def",
"_add_supplemental_bams",
"(",
"data",
")",
":",
"file_key",
"=",
"\"work_bam\"",
"if",
"data",
".",
"get",
"(",
"file_key",
")",
":",
"for",
"supext",
"in",
"[",
"\"disc\"",
",",
"\"sr\"",
"]",
":",
"base",
",",
"ext",
"=",
"os",
".",
"path",
... | Add supplemental files produced by alignment, useful for structural
variant calling. | [
"Add",
"supplemental",
"files",
"produced",
"by",
"alignment",
"useful",
"for",
"structural",
"variant",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L86-L100 |
223,716 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | _add_hla_files | def _add_hla_files(data):
"""Add extracted fastq files of HLA alleles for typing.
"""
if "hla" not in data:
data["hla"] = {}
align_file = dd.get_align_bam(data)
hla_dir = os.path.join(os.path.dirname(align_file), "hla")
if not os.path.exists(hla_dir):
hla_files = None
else:
... | python | def _add_hla_files(data):
"""Add extracted fastq files of HLA alleles for typing.
"""
if "hla" not in data:
data["hla"] = {}
align_file = dd.get_align_bam(data)
hla_dir = os.path.join(os.path.dirname(align_file), "hla")
if not os.path.exists(hla_dir):
hla_files = None
else:
... | [
"def",
"_add_hla_files",
"(",
"data",
")",
":",
"if",
"\"hla\"",
"not",
"in",
"data",
":",
"data",
"[",
"\"hla\"",
"]",
"=",
"{",
"}",
"align_file",
"=",
"dd",
".",
"get_align_bam",
"(",
"data",
")",
"hla_dir",
"=",
"os",
".",
"path",
".",
"join",
... | Add extracted fastq files of HLA alleles for typing. | [
"Add",
"extracted",
"fastq",
"files",
"of",
"HLA",
"alleles",
"for",
"typing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L102-L114 |
223,717 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | prep_samples | def prep_samples(*items):
"""Handle any global preparatory steps for samples with potentially shared data.
Avoids race conditions in postprocess alignment when performing prep tasks
on shared files between multiple similar samples.
Cleans input BED files to avoid issues with overlapping input segments... | python | def prep_samples(*items):
"""Handle any global preparatory steps for samples with potentially shared data.
Avoids race conditions in postprocess alignment when performing prep tasks
on shared files between multiple similar samples.
Cleans input BED files to avoid issues with overlapping input segments... | [
"def",
"prep_samples",
"(",
"*",
"items",
")",
":",
"out",
"=",
"[",
"]",
"for",
"data",
"in",
"(",
"utils",
".",
"to_single_data",
"(",
"x",
")",
"for",
"x",
"in",
"items",
")",
":",
"data",
"=",
"cwlutils",
".",
"normalize_missing",
"(",
"data",
... | Handle any global preparatory steps for samples with potentially shared data.
Avoids race conditions in postprocess alignment when performing prep tasks
on shared files between multiple similar samples.
Cleans input BED files to avoid issues with overlapping input segments. | [
"Handle",
"any",
"global",
"preparatory",
"steps",
"for",
"samples",
"with",
"potentially",
"shared",
"data",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L192-L206 |
223,718 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | clean_inputs | def clean_inputs(data):
"""Clean BED input files to avoid overlapping segments that cause downstream issues.
Per-merges inputs to avoid needing to call multiple times during later parallel steps.
"""
if not utils.get_in(data, ("config", "algorithm", "variant_regions_orig")):
data["config"]["alg... | python | def clean_inputs(data):
"""Clean BED input files to avoid overlapping segments that cause downstream issues.
Per-merges inputs to avoid needing to call multiple times during later parallel steps.
"""
if not utils.get_in(data, ("config", "algorithm", "variant_regions_orig")):
data["config"]["alg... | [
"def",
"clean_inputs",
"(",
"data",
")",
":",
"if",
"not",
"utils",
".",
"get_in",
"(",
"data",
",",
"(",
"\"config\"",
",",
"\"algorithm\"",
",",
"\"variant_regions_orig\"",
")",
")",
":",
"data",
"[",
"\"config\"",
"]",
"[",
"\"algorithm\"",
"]",
"[",
... | Clean BED input files to avoid overlapping segments that cause downstream issues.
Per-merges inputs to avoid needing to call multiple times during later parallel steps. | [
"Clean",
"BED",
"input",
"files",
"to",
"avoid",
"overlapping",
"segments",
"that",
"cause",
"downstream",
"issues",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L208-L236 |
223,719 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | postprocess_alignment | def postprocess_alignment(data):
"""Perform post-processing steps required on full BAM files.
Prepares list of callable genome regions allowing subsequent parallelization.
"""
data = cwlutils.normalize_missing(utils.to_single_data(data))
data = cwlutils.unpack_tarballs(data, data)
bam_file = dat... | python | def postprocess_alignment(data):
"""Perform post-processing steps required on full BAM files.
Prepares list of callable genome regions allowing subsequent parallelization.
"""
data = cwlutils.normalize_missing(utils.to_single_data(data))
data = cwlutils.unpack_tarballs(data, data)
bam_file = dat... | [
"def",
"postprocess_alignment",
"(",
"data",
")",
":",
"data",
"=",
"cwlutils",
".",
"normalize_missing",
"(",
"utils",
".",
"to_single_data",
"(",
"data",
")",
")",
"data",
"=",
"cwlutils",
".",
"unpack_tarballs",
"(",
"data",
",",
"data",
")",
"bam_file",
... | Perform post-processing steps required on full BAM files.
Prepares list of callable genome regions allowing subsequent parallelization. | [
"Perform",
"post",
"-",
"processing",
"steps",
"required",
"on",
"full",
"BAM",
"files",
".",
"Prepares",
"list",
"of",
"callable",
"genome",
"regions",
"allowing",
"subsequent",
"parallelization",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L238-L270 |
223,720 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | _merge_out_from_infiles | def _merge_out_from_infiles(in_files):
"""Generate output merged file name from set of input files.
Handles non-shared filesystems where we don't know output path when setting
up split parts.
"""
fname = os.path.commonprefix([os.path.basename(f) for f in in_files])
while fname.endswith(("-", "_... | python | def _merge_out_from_infiles(in_files):
"""Generate output merged file name from set of input files.
Handles non-shared filesystems where we don't know output path when setting
up split parts.
"""
fname = os.path.commonprefix([os.path.basename(f) for f in in_files])
while fname.endswith(("-", "_... | [
"def",
"_merge_out_from_infiles",
"(",
"in_files",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"commonprefix",
"(",
"[",
"os",
".",
"path",
".",
"basename",
"(",
"f",
")",
"for",
"f",
"in",
"in_files",
"]",
")",
"while",
"fname",
".",
"endswith",
... | Generate output merged file name from set of input files.
Handles non-shared filesystems where we don't know output path when setting
up split parts. | [
"Generate",
"output",
"merged",
"file",
"name",
"from",
"set",
"of",
"input",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L272-L285 |
223,721 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | delayed_bam_merge | def delayed_bam_merge(data):
"""Perform a merge on previously prepped files, delayed in processing.
Handles merging of associated split read and discordant files if present.
"""
if data.get("combine"):
assert len(data["combine"].keys()) == 1
file_key = list(data["combine"].keys())[0]
... | python | def delayed_bam_merge(data):
"""Perform a merge on previously prepped files, delayed in processing.
Handles merging of associated split read and discordant files if present.
"""
if data.get("combine"):
assert len(data["combine"].keys()) == 1
file_key = list(data["combine"].keys())[0]
... | [
"def",
"delayed_bam_merge",
"(",
"data",
")",
":",
"if",
"data",
".",
"get",
"(",
"\"combine\"",
")",
":",
"assert",
"len",
"(",
"data",
"[",
"\"combine\"",
"]",
".",
"keys",
"(",
")",
")",
"==",
"1",
"file_key",
"=",
"list",
"(",
"data",
"[",
"\"c... | Perform a merge on previously prepped files, delayed in processing.
Handles merging of associated split read and discordant files if present. | [
"Perform",
"a",
"merge",
"on",
"previously",
"prepped",
"files",
"delayed",
"in",
"processing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L287-L330 |
223,722 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | merge_split_alignments | def merge_split_alignments(data):
"""Merge split BAM inputs generated by common workflow language runs.
"""
data = utils.to_single_data(data)
data = _merge_align_bams(data)
data = _merge_hla_fastq_inputs(data)
return [[data]] | python | def merge_split_alignments(data):
"""Merge split BAM inputs generated by common workflow language runs.
"""
data = utils.to_single_data(data)
data = _merge_align_bams(data)
data = _merge_hla_fastq_inputs(data)
return [[data]] | [
"def",
"merge_split_alignments",
"(",
"data",
")",
":",
"data",
"=",
"utils",
".",
"to_single_data",
"(",
"data",
")",
"data",
"=",
"_merge_align_bams",
"(",
"data",
")",
"data",
"=",
"_merge_hla_fastq_inputs",
"(",
"data",
")",
"return",
"[",
"[",
"data",
... | Merge split BAM inputs generated by common workflow language runs. | [
"Merge",
"split",
"BAM",
"inputs",
"generated",
"by",
"common",
"workflow",
"language",
"runs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L332-L338 |
223,723 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | _merge_align_bams | def _merge_align_bams(data):
"""Merge multiple alignment BAMs, including split and discordant reads.
"""
for key in (["work_bam"], ["work_bam_plus", "disc"], ["work_bam_plus", "sr"], ["umi_bam"]):
in_files = tz.get_in(key, data, [])
if not isinstance(in_files, (list, tuple)):
in_... | python | def _merge_align_bams(data):
"""Merge multiple alignment BAMs, including split and discordant reads.
"""
for key in (["work_bam"], ["work_bam_plus", "disc"], ["work_bam_plus", "sr"], ["umi_bam"]):
in_files = tz.get_in(key, data, [])
if not isinstance(in_files, (list, tuple)):
in_... | [
"def",
"_merge_align_bams",
"(",
"data",
")",
":",
"for",
"key",
"in",
"(",
"[",
"\"work_bam\"",
"]",
",",
"[",
"\"work_bam_plus\"",
",",
"\"disc\"",
"]",
",",
"[",
"\"work_bam_plus\"",
",",
"\"sr\"",
"]",
",",
"[",
"\"umi_bam\"",
"]",
")",
":",
"in_file... | Merge multiple alignment BAMs, including split and discordant reads. | [
"Merge",
"multiple",
"alignment",
"BAMs",
"including",
"split",
"and",
"discordant",
"reads",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L340-L359 |
223,724 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | _merge_hla_fastq_inputs | def _merge_hla_fastq_inputs(data):
"""Merge HLA inputs from a split initial alignment.
"""
hla_key = ["hla", "fastq"]
hla_sample_files = [x for x in (tz.get_in(hla_key, data) or []) if x and x != "None"]
merged_hlas = None
if hla_sample_files:
out_files = collections.defaultdict(list)
... | python | def _merge_hla_fastq_inputs(data):
"""Merge HLA inputs from a split initial alignment.
"""
hla_key = ["hla", "fastq"]
hla_sample_files = [x for x in (tz.get_in(hla_key, data) or []) if x and x != "None"]
merged_hlas = None
if hla_sample_files:
out_files = collections.defaultdict(list)
... | [
"def",
"_merge_hla_fastq_inputs",
"(",
"data",
")",
":",
"hla_key",
"=",
"[",
"\"hla\"",
",",
"\"fastq\"",
"]",
"hla_sample_files",
"=",
"[",
"x",
"for",
"x",
"in",
"(",
"tz",
".",
"get_in",
"(",
"hla_key",
",",
"data",
")",
"or",
"[",
"]",
")",
"if"... | Merge HLA inputs from a split initial alignment. | [
"Merge",
"HLA",
"inputs",
"from",
"a",
"split",
"initial",
"alignment",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L361-L383 |
223,725 | bcbio/bcbio-nextgen | bcbio/pipeline/sample.py | prepare_bcbio_samples | def prepare_bcbio_samples(sample):
"""
Function that will use specific function to merge input files
"""
logger.info("Preparing %s files %s to merge into %s." % (sample['name'], sample['files'], sample['out_file']))
if sample['fn'] == "fq_merge":
out_file = fq_merge(sample['files'], sample['... | python | def prepare_bcbio_samples(sample):
"""
Function that will use specific function to merge input files
"""
logger.info("Preparing %s files %s to merge into %s." % (sample['name'], sample['files'], sample['out_file']))
if sample['fn'] == "fq_merge":
out_file = fq_merge(sample['files'], sample['... | [
"def",
"prepare_bcbio_samples",
"(",
"sample",
")",
":",
"logger",
".",
"info",
"(",
"\"Preparing %s files %s to merge into %s.\"",
"%",
"(",
"sample",
"[",
"'name'",
"]",
",",
"sample",
"[",
"'files'",
"]",
",",
"sample",
"[",
"'out_file'",
"]",
")",
")",
"... | Function that will use specific function to merge input files | [
"Function",
"that",
"will",
"use",
"specific",
"function",
"to",
"merge",
"input",
"files"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/sample.py#L385-L399 |
223,726 | bcbio/bcbio-nextgen | bcbio/heterogeneity/__init__.py | _get_calls | def _get_calls(data, cnv_only=False):
"""Retrieve calls, organized by name, to use for heterogeneity analysis.
"""
cnvs_supported = set(["cnvkit", "battenberg"])
out = {}
for sv in data.get("sv", []):
if not cnv_only or sv["variantcaller"] in cnvs_supported:
out[sv["variantcaller... | python | def _get_calls(data, cnv_only=False):
"""Retrieve calls, organized by name, to use for heterogeneity analysis.
"""
cnvs_supported = set(["cnvkit", "battenberg"])
out = {}
for sv in data.get("sv", []):
if not cnv_only or sv["variantcaller"] in cnvs_supported:
out[sv["variantcaller... | [
"def",
"_get_calls",
"(",
"data",
",",
"cnv_only",
"=",
"False",
")",
":",
"cnvs_supported",
"=",
"set",
"(",
"[",
"\"cnvkit\"",
",",
"\"battenberg\"",
"]",
")",
"out",
"=",
"{",
"}",
"for",
"sv",
"in",
"data",
".",
"get",
"(",
"\"sv\"",
",",
"[",
... | Retrieve calls, organized by name, to use for heterogeneity analysis. | [
"Retrieve",
"calls",
"organized",
"by",
"name",
"to",
"use",
"for",
"heterogeneity",
"analysis",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/__init__.py#L17-L25 |
223,727 | bcbio/bcbio-nextgen | bcbio/heterogeneity/__init__.py | get_variants | def get_variants(data, include_germline=False):
"""Retrieve set of variant calls to use for heterogeneity analysis.
"""
data = utils.deepish_copy(data)
supported = ["precalled", "vardict", "vardict-java", "vardict-perl",
"freebayes", "octopus", "strelka2"]
# Right now mutect2 and mu... | python | def get_variants(data, include_germline=False):
"""Retrieve set of variant calls to use for heterogeneity analysis.
"""
data = utils.deepish_copy(data)
supported = ["precalled", "vardict", "vardict-java", "vardict-perl",
"freebayes", "octopus", "strelka2"]
# Right now mutect2 and mu... | [
"def",
"get_variants",
"(",
"data",
",",
"include_germline",
"=",
"False",
")",
":",
"data",
"=",
"utils",
".",
"deepish_copy",
"(",
"data",
")",
"supported",
"=",
"[",
"\"precalled\"",
",",
"\"vardict\"",
",",
"\"vardict-java\"",
",",
"\"vardict-perl\"",
",",... | Retrieve set of variant calls to use for heterogeneity analysis. | [
"Retrieve",
"set",
"of",
"variant",
"calls",
"to",
"use",
"for",
"heterogeneity",
"analysis",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/__init__.py#L27-L57 |
223,728 | bcbio/bcbio-nextgen | bcbio/heterogeneity/__init__.py | _ready_for_het_analysis | def _ready_for_het_analysis(items):
"""Check if a sample has input information for heterogeneity analysis.
We currently require a tumor/normal sample containing both CNV and variant calls.
"""
paired = vcfutils.get_paired_bams([dd.get_align_bam(d) for d in items], items)
has_het = any(dd.get_hetcal... | python | def _ready_for_het_analysis(items):
"""Check if a sample has input information for heterogeneity analysis.
We currently require a tumor/normal sample containing both CNV and variant calls.
"""
paired = vcfutils.get_paired_bams([dd.get_align_bam(d) for d in items], items)
has_het = any(dd.get_hetcal... | [
"def",
"_ready_for_het_analysis",
"(",
"items",
")",
":",
"paired",
"=",
"vcfutils",
".",
"get_paired_bams",
"(",
"[",
"dd",
".",
"get_align_bam",
"(",
"d",
")",
"for",
"d",
"in",
"items",
"]",
",",
"items",
")",
"has_het",
"=",
"any",
"(",
"dd",
".",
... | Check if a sample has input information for heterogeneity analysis.
We currently require a tumor/normal sample containing both CNV and variant calls. | [
"Check",
"if",
"a",
"sample",
"has",
"input",
"information",
"for",
"heterogeneity",
"analysis",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/__init__.py#L59-L67 |
223,729 | bcbio/bcbio-nextgen | bcbio/heterogeneity/__init__.py | run | def run(items, run_parallel):
"""Top level entry point for calculating heterogeneity, handles organization and job distribution.
"""
to_process = []
extras = []
for batch, cur_items in _group_by_batches(items).items():
if _ready_for_het_analysis(cur_items):
to_process.append((bat... | python | def run(items, run_parallel):
"""Top level entry point for calculating heterogeneity, handles organization and job distribution.
"""
to_process = []
extras = []
for batch, cur_items in _group_by_batches(items).items():
if _ready_for_het_analysis(cur_items):
to_process.append((bat... | [
"def",
"run",
"(",
"items",
",",
"run_parallel",
")",
":",
"to_process",
"=",
"[",
"]",
"extras",
"=",
"[",
"]",
"for",
"batch",
",",
"cur_items",
"in",
"_group_by_batches",
"(",
"items",
")",
".",
"items",
"(",
")",
":",
"if",
"_ready_for_het_analysis",... | Top level entry point for calculating heterogeneity, handles organization and job distribution. | [
"Top",
"level",
"entry",
"point",
"for",
"calculating",
"heterogeneity",
"handles",
"organization",
"and",
"job",
"distribution",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/__init__.py#L122-L134 |
223,730 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | create_inputs | def create_inputs(data):
"""Index input reads and prepare groups of reads to process concurrently.
Allows parallelization of alignment beyond processors available on a single
machine. Prepares a bgzip and grabix indexed file for retrieving sections
of files.
"""
from bcbio.pipeline import sampl... | python | def create_inputs(data):
"""Index input reads and prepare groups of reads to process concurrently.
Allows parallelization of alignment beyond processors available on a single
machine. Prepares a bgzip and grabix indexed file for retrieving sections
of files.
"""
from bcbio.pipeline import sampl... | [
"def",
"create_inputs",
"(",
"data",
")",
":",
"from",
"bcbio",
".",
"pipeline",
"import",
"sample",
"data",
"=",
"cwlutils",
".",
"normalize_missing",
"(",
"data",
")",
"aligner",
"=",
"tz",
".",
"get_in",
"(",
"(",
"\"config\"",
",",
"\"algorithm\"",
","... | Index input reads and prepare groups of reads to process concurrently.
Allows parallelization of alignment beyond processors available on a single
machine. Prepares a bgzip and grabix indexed file for retrieving sections
of files. | [
"Index",
"input",
"reads",
"and",
"prepare",
"groups",
"of",
"reads",
"to",
"process",
"concurrently",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L25-L62 |
223,731 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _set_align_split_size | def _set_align_split_size(data):
"""Set useful align_split_size, generating an estimate if it doesn't exist.
We try to split on larger inputs and avoid too many pieces, aiming for size
chunks of 5Gb or at most 50 maximum splits.
The size estimate used in calculations is 20 million reads for ~5Gb.
... | python | def _set_align_split_size(data):
"""Set useful align_split_size, generating an estimate if it doesn't exist.
We try to split on larger inputs and avoid too many pieces, aiming for size
chunks of 5Gb or at most 50 maximum splits.
The size estimate used in calculations is 20 million reads for ~5Gb.
... | [
"def",
"_set_align_split_size",
"(",
"data",
")",
":",
"if",
"cwlutils",
".",
"is_cwl_run",
"(",
"data",
")",
":",
"target_size",
"=",
"20",
"# Gb",
"target_size_reads",
"=",
"80",
"# million reads",
"else",
":",
"target_size",
"=",
"5",
"# Gb",
"target_size_r... | Set useful align_split_size, generating an estimate if it doesn't exist.
We try to split on larger inputs and avoid too many pieces, aiming for size
chunks of 5Gb or at most 50 maximum splits.
The size estimate used in calculations is 20 million reads for ~5Gb.
For UMI calculations we skip splitting ... | [
"Set",
"useful",
"align_split_size",
"generating",
"an",
"estimate",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L64-L101 |
223,732 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _pick_align_split_size | def _pick_align_split_size(total_size, target_size, target_size_reads, max_splits):
"""Do the work of picking an alignment split size for the given criteria.
"""
# Too many pieces, increase our target size to get max_splits pieces
if total_size // target_size > max_splits:
piece_size = total_siz... | python | def _pick_align_split_size(total_size, target_size, target_size_reads, max_splits):
"""Do the work of picking an alignment split size for the given criteria.
"""
# Too many pieces, increase our target size to get max_splits pieces
if total_size // target_size > max_splits:
piece_size = total_siz... | [
"def",
"_pick_align_split_size",
"(",
"total_size",
",",
"target_size",
",",
"target_size_reads",
",",
"max_splits",
")",
":",
"# Too many pieces, increase our target size to get max_splits pieces",
"if",
"total_size",
"//",
"target_size",
">",
"max_splits",
":",
"piece_size"... | Do the work of picking an alignment split size for the given criteria. | [
"Do",
"the",
"work",
"of",
"picking",
"an",
"alignment",
"split",
"size",
"for",
"the",
"given",
"criteria",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L103-L111 |
223,733 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | split_namedpipe_cls | def split_namedpipe_cls(pair1_file, pair2_file, data):
"""Create a commandline suitable for use as a named pipe with reads in a given region.
"""
if "align_split" in data:
start, end = [int(x) for x in data["align_split"].split("-")]
else:
start, end = None, None
if pair1_file.endswi... | python | def split_namedpipe_cls(pair1_file, pair2_file, data):
"""Create a commandline suitable for use as a named pipe with reads in a given region.
"""
if "align_split" in data:
start, end = [int(x) for x in data["align_split"].split("-")]
else:
start, end = None, None
if pair1_file.endswi... | [
"def",
"split_namedpipe_cls",
"(",
"pair1_file",
",",
"pair2_file",
",",
"data",
")",
":",
"if",
"\"align_split\"",
"in",
"data",
":",
"start",
",",
"end",
"=",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"data",
"[",
"\"align_split\"",
"]",
".",
"spl... | Create a commandline suitable for use as a named pipe with reads in a given region. | [
"Create",
"a",
"commandline",
"suitable",
"for",
"use",
"as",
"a",
"named",
"pipe",
"with",
"reads",
"in",
"a",
"given",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L113-L131 |
223,734 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _seqtk_fastq_prep_cl | def _seqtk_fastq_prep_cl(data, in_file=None, read_num=0):
"""Provide a commandline for prep of fastq inputs with seqtk.
Handles fast conversion of fastq quality scores and trimming.
"""
needs_convert = dd.get_quality_format(data).lower() == "illumina"
trim_ends = dd.get_trim_ends(data)
seqtk = ... | python | def _seqtk_fastq_prep_cl(data, in_file=None, read_num=0):
"""Provide a commandline for prep of fastq inputs with seqtk.
Handles fast conversion of fastq quality scores and trimming.
"""
needs_convert = dd.get_quality_format(data).lower() == "illumina"
trim_ends = dd.get_trim_ends(data)
seqtk = ... | [
"def",
"_seqtk_fastq_prep_cl",
"(",
"data",
",",
"in_file",
"=",
"None",
",",
"read_num",
"=",
"0",
")",
":",
"needs_convert",
"=",
"dd",
".",
"get_quality_format",
"(",
"data",
")",
".",
"lower",
"(",
")",
"==",
"\"illumina\"",
"trim_ends",
"=",
"dd",
"... | Provide a commandline for prep of fastq inputs with seqtk.
Handles fast conversion of fastq quality scores and trimming. | [
"Provide",
"a",
"commandline",
"for",
"prep",
"of",
"fastq",
"inputs",
"with",
"seqtk",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L133-L154 |
223,735 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | fastq_convert_pipe_cl | def fastq_convert_pipe_cl(in_file, data):
"""Create an anonymous pipe converting Illumina 1.3-1.7 to Sanger.
Uses seqtk: https://github.com/lh3/seqt
"""
cmd = _seqtk_fastq_prep_cl(data, in_file)
if not cmd:
cat_cmd = "zcat" if in_file.endswith(".gz") else "cat"
cmd = cat_cmd + " " +... | python | def fastq_convert_pipe_cl(in_file, data):
"""Create an anonymous pipe converting Illumina 1.3-1.7 to Sanger.
Uses seqtk: https://github.com/lh3/seqt
"""
cmd = _seqtk_fastq_prep_cl(data, in_file)
if not cmd:
cat_cmd = "zcat" if in_file.endswith(".gz") else "cat"
cmd = cat_cmd + " " +... | [
"def",
"fastq_convert_pipe_cl",
"(",
"in_file",
",",
"data",
")",
":",
"cmd",
"=",
"_seqtk_fastq_prep_cl",
"(",
"data",
",",
"in_file",
")",
"if",
"not",
"cmd",
":",
"cat_cmd",
"=",
"\"zcat\"",
"if",
"in_file",
".",
"endswith",
"(",
"\".gz\"",
")",
"else",... | Create an anonymous pipe converting Illumina 1.3-1.7 to Sanger.
Uses seqtk: https://github.com/lh3/seqt | [
"Create",
"an",
"anonymous",
"pipe",
"converting",
"Illumina",
"1",
".",
"3",
"-",
"1",
".",
"7",
"to",
"Sanger",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L156-L165 |
223,736 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | parallel_multiplier | def parallel_multiplier(items):
"""Determine if we will be parallelizing items during processing.
"""
multiplier = 1
for data in (x[0] for x in items):
if (tz.get_in(["config", "algorithm", "align_split_size"], data) is not False and
tz.get_in(["algorithm", "align_split_size"], dat... | python | def parallel_multiplier(items):
"""Determine if we will be parallelizing items during processing.
"""
multiplier = 1
for data in (x[0] for x in items):
if (tz.get_in(["config", "algorithm", "align_split_size"], data) is not False and
tz.get_in(["algorithm", "align_split_size"], dat... | [
"def",
"parallel_multiplier",
"(",
"items",
")",
":",
"multiplier",
"=",
"1",
"for",
"data",
"in",
"(",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"items",
")",
":",
"if",
"(",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
",",
"\"algorithm\"",
",",
"\"a... | Determine if we will be parallelizing items during processing. | [
"Determine",
"if",
"we",
"will",
"be",
"parallelizing",
"items",
"during",
"processing",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L169-L177 |
223,737 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | setup_combine | def setup_combine(final_file, data):
"""Setup the data and outputs to allow merging data back together.
"""
if "align_split" not in data:
return final_file, data
align_dir = os.path.dirname(final_file)
base, ext = os.path.splitext(os.path.basename(final_file))
start, end = [int(x) for x ... | python | def setup_combine(final_file, data):
"""Setup the data and outputs to allow merging data back together.
"""
if "align_split" not in data:
return final_file, data
align_dir = os.path.dirname(final_file)
base, ext = os.path.splitext(os.path.basename(final_file))
start, end = [int(x) for x ... | [
"def",
"setup_combine",
"(",
"final_file",
",",
"data",
")",
":",
"if",
"\"align_split\"",
"not",
"in",
"data",
":",
"return",
"final_file",
",",
"data",
"align_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"final_file",
")",
"base",
",",
"ext",
"="... | Setup the data and outputs to allow merging data back together. | [
"Setup",
"the",
"data",
"and",
"outputs",
"to",
"allow",
"merging",
"data",
"back",
"together",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L181-L192 |
223,738 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | merge_split_alignments | def merge_split_alignments(samples, run_parallel):
"""Manage merging split alignments back into a final working BAM file.
Perform de-duplication on the final merged file.
"""
ready = []
file_key = "work_bam"
to_merge = collections.defaultdict(list)
for data in (xs[0] for xs in samples):
... | python | def merge_split_alignments(samples, run_parallel):
"""Manage merging split alignments back into a final working BAM file.
Perform de-duplication on the final merged file.
"""
ready = []
file_key = "work_bam"
to_merge = collections.defaultdict(list)
for data in (xs[0] for xs in samples):
... | [
"def",
"merge_split_alignments",
"(",
"samples",
",",
"run_parallel",
")",
":",
"ready",
"=",
"[",
"]",
"file_key",
"=",
"\"work_bam\"",
"to_merge",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"data",
"in",
"(",
"xs",
"[",
"0",
"]",
... | Manage merging split alignments back into a final working BAM file.
Perform de-duplication on the final merged file. | [
"Manage",
"merging",
"split",
"alignments",
"back",
"into",
"a",
"final",
"working",
"BAM",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L194-L252 |
223,739 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _save_fastq_space | def _save_fastq_space(items):
"""Potentially save fastq space prior to merging, since alignments done.
"""
to_cleanup = {}
for data in (utils.to_single_data(x) for x in items):
for fname in data.get("files", []):
if os.path.realpath(fname).startswith(dd.get_work_dir(data)):
... | python | def _save_fastq_space(items):
"""Potentially save fastq space prior to merging, since alignments done.
"""
to_cleanup = {}
for data in (utils.to_single_data(x) for x in items):
for fname in data.get("files", []):
if os.path.realpath(fname).startswith(dd.get_work_dir(data)):
... | [
"def",
"_save_fastq_space",
"(",
"items",
")",
":",
"to_cleanup",
"=",
"{",
"}",
"for",
"data",
"in",
"(",
"utils",
".",
"to_single_data",
"(",
"x",
")",
"for",
"x",
"in",
"items",
")",
":",
"for",
"fname",
"in",
"data",
".",
"get",
"(",
"\"files\"",... | Potentially save fastq space prior to merging, since alignments done. | [
"Potentially",
"save",
"fastq",
"space",
"prior",
"to",
"merging",
"since",
"alignments",
"done",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L254-L263 |
223,740 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | total_reads_from_grabix | def total_reads_from_grabix(in_file):
"""Retrieve total reads in a fastq file from grabix index.
"""
gbi_file = _get_grabix_index(in_file)
if gbi_file:
with open(gbi_file) as in_handle:
next(in_handle) # throw away
num_lines = int(next(in_handle).strip())
assert ... | python | def total_reads_from_grabix(in_file):
"""Retrieve total reads in a fastq file from grabix index.
"""
gbi_file = _get_grabix_index(in_file)
if gbi_file:
with open(gbi_file) as in_handle:
next(in_handle) # throw away
num_lines = int(next(in_handle).strip())
assert ... | [
"def",
"total_reads_from_grabix",
"(",
"in_file",
")",
":",
"gbi_file",
"=",
"_get_grabix_index",
"(",
"in_file",
")",
"if",
"gbi_file",
":",
"with",
"open",
"(",
"gbi_file",
")",
"as",
"in_handle",
":",
"next",
"(",
"in_handle",
")",
"# throw away",
"num_line... | Retrieve total reads in a fastq file from grabix index. | [
"Retrieve",
"total",
"reads",
"in",
"a",
"fastq",
"file",
"from",
"grabix",
"index",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L281-L292 |
223,741 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _find_read_splits | def _find_read_splits(in_file, split_size):
"""Determine sections of fastq files to process in splits.
Assumes a 4 line order to input files (name, read, name, quality).
grabix is 1-based inclusive, so return coordinates in that format.
"""
num_lines = total_reads_from_grabix(in_file) * 4
asser... | python | def _find_read_splits(in_file, split_size):
"""Determine sections of fastq files to process in splits.
Assumes a 4 line order to input files (name, read, name, quality).
grabix is 1-based inclusive, so return coordinates in that format.
"""
num_lines = total_reads_from_grabix(in_file) * 4
asser... | [
"def",
"_find_read_splits",
"(",
"in_file",
",",
"split_size",
")",
":",
"num_lines",
"=",
"total_reads_from_grabix",
"(",
"in_file",
")",
"*",
"4",
"assert",
"num_lines",
"and",
"num_lines",
">",
"0",
",",
"\"Did not find grabix index reads: %s %s\"",
"%",
"(",
"... | Determine sections of fastq files to process in splits.
Assumes a 4 line order to input files (name, read, name, quality).
grabix is 1-based inclusive, so return coordinates in that format. | [
"Determine",
"sections",
"of",
"fastq",
"files",
"to",
"process",
"in",
"splits",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L294-L309 |
223,742 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _ready_gzip_fastq | def _ready_gzip_fastq(in_files, data, require_bgzip=False):
"""Check if we have gzipped fastq and don't need format conversion or splitting.
Avoid forcing bgzip if we don't need indexed files.
"""
all_gzipped = all([not x or x.endswith(".gz") for x in in_files])
if require_bgzip and all_gzipped:
... | python | def _ready_gzip_fastq(in_files, data, require_bgzip=False):
"""Check if we have gzipped fastq and don't need format conversion or splitting.
Avoid forcing bgzip if we don't need indexed files.
"""
all_gzipped = all([not x or x.endswith(".gz") for x in in_files])
if require_bgzip and all_gzipped:
... | [
"def",
"_ready_gzip_fastq",
"(",
"in_files",
",",
"data",
",",
"require_bgzip",
"=",
"False",
")",
":",
"all_gzipped",
"=",
"all",
"(",
"[",
"not",
"x",
"or",
"x",
".",
"endswith",
"(",
"\".gz\"",
")",
"for",
"x",
"in",
"in_files",
"]",
")",
"if",
"r... | Check if we have gzipped fastq and don't need format conversion or splitting.
Avoid forcing bgzip if we don't need indexed files. | [
"Check",
"if",
"we",
"have",
"gzipped",
"fastq",
"and",
"don",
"t",
"need",
"format",
"conversion",
"or",
"splitting",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L319-L331 |
223,743 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | prep_fastq_inputs | def prep_fastq_inputs(in_files, data):
"""Prepare bgzipped fastq inputs
"""
if len(in_files) == 1 and _is_bam_input(in_files):
out = _bgzip_from_bam(in_files[0], data["dirs"], data)
elif len(in_files) == 1 and _is_cram_input(in_files):
out = _bgzip_from_cram(in_files[0], data["dirs"], da... | python | def prep_fastq_inputs(in_files, data):
"""Prepare bgzipped fastq inputs
"""
if len(in_files) == 1 and _is_bam_input(in_files):
out = _bgzip_from_bam(in_files[0], data["dirs"], data)
elif len(in_files) == 1 and _is_cram_input(in_files):
out = _bgzip_from_cram(in_files[0], data["dirs"], da... | [
"def",
"prep_fastq_inputs",
"(",
"in_files",
",",
"data",
")",
":",
"if",
"len",
"(",
"in_files",
")",
"==",
"1",
"and",
"_is_bam_input",
"(",
"in_files",
")",
":",
"out",
"=",
"_bgzip_from_bam",
"(",
"in_files",
"[",
"0",
"]",
",",
"data",
"[",
"\"dir... | Prepare bgzipped fastq inputs | [
"Prepare",
"bgzipped",
"fastq",
"inputs"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L333-L359 |
223,744 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _symlink_or_copy_grabix | def _symlink_or_copy_grabix(in_file, out_file, data):
"""We cannot symlink in CWL, but may be able to use inputs or copy
"""
if cwlutils.is_cwl_run(data):
# Has grabix indexes, we're okay to go
if utils.file_exists(in_file + ".gbi"):
out_file = in_file
else:
u... | python | def _symlink_or_copy_grabix(in_file, out_file, data):
"""We cannot symlink in CWL, but may be able to use inputs or copy
"""
if cwlutils.is_cwl_run(data):
# Has grabix indexes, we're okay to go
if utils.file_exists(in_file + ".gbi"):
out_file = in_file
else:
u... | [
"def",
"_symlink_or_copy_grabix",
"(",
"in_file",
",",
"out_file",
",",
"data",
")",
":",
"if",
"cwlutils",
".",
"is_cwl_run",
"(",
"data",
")",
":",
"# Has grabix indexes, we're okay to go",
"if",
"utils",
".",
"file_exists",
"(",
"in_file",
"+",
"\".gbi\"",
")... | We cannot symlink in CWL, but may be able to use inputs or copy | [
"We",
"cannot",
"symlink",
"in",
"CWL",
"but",
"may",
"be",
"able",
"to",
"use",
"inputs",
"or",
"copy"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L372-L383 |
223,745 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _prep_grabix_indexes | def _prep_grabix_indexes(in_files, data):
"""Parallel preparation of grabix indexes for files.
"""
# if we have gzipped but not bgzipped, add a fake index for CWL support
# Also skips bgzip indexing if we don't need alignment splitting
if _ready_gzip_fastq(in_files, data) and (not _ready_gzip_fastq(... | python | def _prep_grabix_indexes(in_files, data):
"""Parallel preparation of grabix indexes for files.
"""
# if we have gzipped but not bgzipped, add a fake index for CWL support
# Also skips bgzip indexing if we don't need alignment splitting
if _ready_gzip_fastq(in_files, data) and (not _ready_gzip_fastq(... | [
"def",
"_prep_grabix_indexes",
"(",
"in_files",
",",
"data",
")",
":",
"# if we have gzipped but not bgzipped, add a fake index for CWL support",
"# Also skips bgzip indexing if we don't need alignment splitting",
"if",
"_ready_gzip_fastq",
"(",
"in_files",
",",
"data",
")",
"and",... | Parallel preparation of grabix indexes for files. | [
"Parallel",
"preparation",
"of",
"grabix",
"indexes",
"for",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L385-L400 |
223,746 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _bgzip_from_cram | def _bgzip_from_cram(cram_file, dirs, data):
"""Create bgzipped fastq files from an input CRAM file in regions of interest.
Returns a list with a single file, for single end CRAM files, or two
files for paired end input.
"""
import pybedtools
region_file = (tz.get_in(["config", "algorithm", "va... | python | def _bgzip_from_cram(cram_file, dirs, data):
"""Create bgzipped fastq files from an input CRAM file in regions of interest.
Returns a list with a single file, for single end CRAM files, or two
files for paired end input.
"""
import pybedtools
region_file = (tz.get_in(["config", "algorithm", "va... | [
"def",
"_bgzip_from_cram",
"(",
"cram_file",
",",
"dirs",
",",
"data",
")",
":",
"import",
"pybedtools",
"region_file",
"=",
"(",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
",",
"\"algorithm\"",
",",
"\"variant_regions\"",
"]",
",",
"data",
")",
"if",
"t... | Create bgzipped fastq files from an input CRAM file in regions of interest.
Returns a list with a single file, for single end CRAM files, or two
files for paired end input. | [
"Create",
"bgzipped",
"fastq",
"files",
"from",
"an",
"input",
"CRAM",
"file",
"in",
"regions",
"of",
"interest",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L402-L439 |
223,747 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _bgzip_from_cram_sambamba | def _bgzip_from_cram_sambamba(cram_file, dirs, data):
"""Use sambamba to extract from CRAM via regions.
"""
raise NotImplementedError("sambamba doesn't yet support retrieval from CRAM by BED file")
region_file = (tz.get_in(["config", "algorithm", "variant_regions"], data)
if tz.get_in... | python | def _bgzip_from_cram_sambamba(cram_file, dirs, data):
"""Use sambamba to extract from CRAM via regions.
"""
raise NotImplementedError("sambamba doesn't yet support retrieval from CRAM by BED file")
region_file = (tz.get_in(["config", "algorithm", "variant_regions"], data)
if tz.get_in... | [
"def",
"_bgzip_from_cram_sambamba",
"(",
"cram_file",
",",
"dirs",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"sambamba doesn't yet support retrieval from CRAM by BED file\"",
")",
"region_file",
"=",
"(",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
... | Use sambamba to extract from CRAM via regions. | [
"Use",
"sambamba",
"to",
"extract",
"from",
"CRAM",
"via",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L441-L457 |
223,748 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _cram_to_fastq_regions | def _cram_to_fastq_regions(regions, cram_file, dirs, data):
"""Convert CRAM files to fastq, potentially within sub regions.
Returns multiple fastq files that can be merged back together.
"""
base_name = utils.splitext_plus(os.path.basename(cram_file))[0]
work_dir = utils.safe_makedir(os.path.join(d... | python | def _cram_to_fastq_regions(regions, cram_file, dirs, data):
"""Convert CRAM files to fastq, potentially within sub regions.
Returns multiple fastq files that can be merged back together.
"""
base_name = utils.splitext_plus(os.path.basename(cram_file))[0]
work_dir = utils.safe_makedir(os.path.join(d... | [
"def",
"_cram_to_fastq_regions",
"(",
"regions",
",",
"cram_file",
",",
"dirs",
",",
"data",
")",
":",
"base_name",
"=",
"utils",
".",
"splitext_plus",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"cram_file",
")",
")",
"[",
"0",
"]",
"work_dir",
"=",
... | Convert CRAM files to fastq, potentially within sub regions.
Returns multiple fastq files that can be merged back together. | [
"Convert",
"CRAM",
"files",
"to",
"fastq",
"potentially",
"within",
"sub",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L482-L498 |
223,749 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _cram_to_fastq_region | def _cram_to_fastq_region(cram_file, work_dir, base_name, region, data):
"""Convert CRAM to fastq in a specified region.
"""
ref_file = tz.get_in(["reference", "fasta", "base"], data)
resources = config_utils.get_resources("bamtofastq", data["config"])
cores = tz.get_in(["config", "algorithm", "num_... | python | def _cram_to_fastq_region(cram_file, work_dir, base_name, region, data):
"""Convert CRAM to fastq in a specified region.
"""
ref_file = tz.get_in(["reference", "fasta", "base"], data)
resources = config_utils.get_resources("bamtofastq", data["config"])
cores = tz.get_in(["config", "algorithm", "num_... | [
"def",
"_cram_to_fastq_region",
"(",
"cram_file",
",",
"work_dir",
",",
"base_name",
",",
"region",
",",
"data",
")",
":",
"ref_file",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"reference\"",
",",
"\"fasta\"",
",",
"\"base\"",
"]",
",",
"data",
")",
"resources... | Convert CRAM to fastq in a specified region. | [
"Convert",
"CRAM",
"to",
"fastq",
"in",
"a",
"specified",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L502-L525 |
223,750 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _bgzip_from_bam | def _bgzip_from_bam(bam_file, dirs, data, is_retry=False, output_infix=''):
"""Create bgzipped fastq files from an input BAM file.
"""
# tools
config = data["config"]
bamtofastq = config_utils.get_program("bamtofastq", config)
resources = config_utils.get_resources("bamtofastq", config)
core... | python | def _bgzip_from_bam(bam_file, dirs, data, is_retry=False, output_infix=''):
"""Create bgzipped fastq files from an input BAM file.
"""
# tools
config = data["config"]
bamtofastq = config_utils.get_program("bamtofastq", config)
resources = config_utils.get_resources("bamtofastq", config)
core... | [
"def",
"_bgzip_from_bam",
"(",
"bam_file",
",",
"dirs",
",",
"data",
",",
"is_retry",
"=",
"False",
",",
"output_infix",
"=",
"''",
")",
":",
"# tools",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"bamtofastq",
"=",
"config_utils",
".",
"get_program",
"... | Create bgzipped fastq files from an input BAM file. | [
"Create",
"bgzipped",
"fastq",
"files",
"from",
"an",
"input",
"BAM",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L532-L586 |
223,751 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _grabix_index | def _grabix_index(data):
"""Create grabix index of bgzip input file.
grabix does not allow specification of output file, so symlink the original
file into a transactional directory.
"""
in_file = data["bgzip_file"]
config = data["config"]
grabix = config_utils.get_program("grabix", config)
... | python | def _grabix_index(data):
"""Create grabix index of bgzip input file.
grabix does not allow specification of output file, so symlink the original
file into a transactional directory.
"""
in_file = data["bgzip_file"]
config = data["config"]
grabix = config_utils.get_program("grabix", config)
... | [
"def",
"_grabix_index",
"(",
"data",
")",
":",
"in_file",
"=",
"data",
"[",
"\"bgzip_file\"",
"]",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"grabix",
"=",
"config_utils",
".",
"get_program",
"(",
"\"grabix\"",
",",
"config",
")",
"gbi_file",
"=",
"_g... | Create grabix index of bgzip input file.
grabix does not allow specification of output file, so symlink the original
file into a transactional directory. | [
"Create",
"grabix",
"index",
"of",
"bgzip",
"input",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L590-L611 |
223,752 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _is_partial_index | def _is_partial_index(gbi_file):
"""Check for truncated output since grabix doesn't write to a transactional directory.
"""
with open(gbi_file) as in_handle:
for i, _ in enumerate(in_handle):
if i > 2:
return False
return True | python | def _is_partial_index(gbi_file):
"""Check for truncated output since grabix doesn't write to a transactional directory.
"""
with open(gbi_file) as in_handle:
for i, _ in enumerate(in_handle):
if i > 2:
return False
return True | [
"def",
"_is_partial_index",
"(",
"gbi_file",
")",
":",
"with",
"open",
"(",
"gbi_file",
")",
"as",
"in_handle",
":",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"in_handle",
")",
":",
"if",
"i",
">",
"2",
":",
"return",
"False",
"return",
"True"
] | Check for truncated output since grabix doesn't write to a transactional directory. | [
"Check",
"for",
"truncated",
"output",
"since",
"grabix",
"doesn",
"t",
"write",
"to",
"a",
"transactional",
"directory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L613-L620 |
223,753 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _bgzip_file | def _bgzip_file(finput, config, work_dir, needs_bgzip, needs_gunzip, needs_convert, data):
"""Handle bgzip of input file, potentially gunzipping an existing file.
Handles cases where finput might be multiple files and need to be concatenated.
"""
if isinstance(finput, six.string_types):
in_file... | python | def _bgzip_file(finput, config, work_dir, needs_bgzip, needs_gunzip, needs_convert, data):
"""Handle bgzip of input file, potentially gunzipping an existing file.
Handles cases where finput might be multiple files and need to be concatenated.
"""
if isinstance(finput, six.string_types):
in_file... | [
"def",
"_bgzip_file",
"(",
"finput",
",",
"config",
",",
"work_dir",
",",
"needs_bgzip",
",",
"needs_gunzip",
",",
"needs_convert",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"finput",
",",
"six",
".",
"string_types",
")",
":",
"in_file",
"=",
"finput... | Handle bgzip of input file, potentially gunzipping an existing file.
Handles cases where finput might be multiple files and need to be concatenated. | [
"Handle",
"bgzip",
"of",
"input",
"file",
"potentially",
"gunzipping",
"an",
"existing",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L659-L697 |
223,754 | bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _check_gzipped_input | def _check_gzipped_input(in_file, data):
"""Determine if a gzipped input file is blocked gzip or standard.
"""
grabix = config_utils.get_program("grabix", data["config"])
is_bgzip = subprocess.check_output([grabix, "check", in_file])
if is_bgzip.strip() == "yes":
return False, False
else... | python | def _check_gzipped_input(in_file, data):
"""Determine if a gzipped input file is blocked gzip or standard.
"""
grabix = config_utils.get_program("grabix", data["config"])
is_bgzip = subprocess.check_output([grabix, "check", in_file])
if is_bgzip.strip() == "yes":
return False, False
else... | [
"def",
"_check_gzipped_input",
"(",
"in_file",
",",
"data",
")",
":",
"grabix",
"=",
"config_utils",
".",
"get_program",
"(",
"\"grabix\"",
",",
"data",
"[",
"\"config\"",
"]",
")",
"is_bgzip",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"grabix",
",",... | Determine if a gzipped input file is blocked gzip or standard. | [
"Determine",
"if",
"a",
"gzipped",
"input",
"file",
"is",
"blocked",
"gzip",
"or",
"standard",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L715-L723 |
223,755 | bcbio/bcbio-nextgen | bcbio/qc/fastqc.py | run | def run(bam_file, data, fastqc_out):
"""Run fastqc, generating report in specified directory and parsing metrics.
Downsamples to 10 million reads to avoid excessive processing times with large
files, unless we're running a Standard/smallRNA-seq/QC pipeline.
Handles fastqc 0.11+, which use a single HTM... | python | def run(bam_file, data, fastqc_out):
"""Run fastqc, generating report in specified directory and parsing metrics.
Downsamples to 10 million reads to avoid excessive processing times with large
files, unless we're running a Standard/smallRNA-seq/QC pipeline.
Handles fastqc 0.11+, which use a single HTM... | [
"def",
"run",
"(",
"bam_file",
",",
"data",
",",
"fastqc_out",
")",
":",
"sentry_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"fastqc_out",
",",
"\"fastqc_report.html\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"sentry_file",
")",
... | Run fastqc, generating report in specified directory and parsing metrics.
Downsamples to 10 million reads to avoid excessive processing times with large
files, unless we're running a Standard/smallRNA-seq/QC pipeline.
Handles fastqc 0.11+, which use a single HTML file and older versions that use
a dir... | [
"Run",
"fastqc",
"generating",
"report",
"in",
"specified",
"directory",
"and",
"parsing",
"metrics",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/fastqc.py#L21-L70 |
223,756 | bcbio/bcbio-nextgen | bcbio/qc/fastqc.py | FastQCParser._get_module | def _get_module(self, parser, module):
"""
Get module using fadapa package
"""
dt = []
lines = parser.clean_data(module)
header = lines[0]
for data in lines[1:]:
if data[0].startswith("#"): # some modules have two headers
header = data... | python | def _get_module(self, parser, module):
"""
Get module using fadapa package
"""
dt = []
lines = parser.clean_data(module)
header = lines[0]
for data in lines[1:]:
if data[0].startswith("#"): # some modules have two headers
header = data... | [
"def",
"_get_module",
"(",
"self",
",",
"parser",
",",
"module",
")",
":",
"dt",
"=",
"[",
"]",
"lines",
"=",
"parser",
".",
"clean_data",
"(",
"module",
")",
"header",
"=",
"lines",
"[",
"0",
"]",
"for",
"data",
"in",
"lines",
"[",
"1",
":",
"]"... | Get module using fadapa package | [
"Get",
"module",
"using",
"fadapa",
"package"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/fastqc.py#L113-L133 |
223,757 | bcbio/bcbio-nextgen | bcbio/server/background.py | GenericSubprocess.start | def start(self):
"""Spawn the task.
Throws RuntimeError if the task was already started."""
if not self.pipe is None:
raise RuntimeError("Cannot start task twice")
self.ioloop = tornado.ioloop.IOLoop.instance()
if self.timeout > 0:
self.expiration = self... | python | def start(self):
"""Spawn the task.
Throws RuntimeError if the task was already started."""
if not self.pipe is None:
raise RuntimeError("Cannot start task twice")
self.ioloop = tornado.ioloop.IOLoop.instance()
if self.timeout > 0:
self.expiration = self... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"pipe",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot start task twice\"",
")",
"self",
".",
"ioloop",
"=",
"tornado",
".",
"ioloop",
".",
"IOLoop",
".",
"instance",
"(",
")",
... | Spawn the task.
Throws RuntimeError if the task was already started. | [
"Spawn",
"the",
"task",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/server/background.py#L32-L51 |
223,758 | bcbio/bcbio-nextgen | bcbio/workflow/xprize.py | get_fc_date | def get_fc_date(out_config_file):
"""Retrieve flowcell date, reusing older dates if refreshing a present workflow.
"""
if os.path.exists(out_config_file):
with open(out_config_file) as in_handle:
old_config = yaml.safe_load(in_handle)
fc_date = old_config["fc_date"]
else:... | python | def get_fc_date(out_config_file):
"""Retrieve flowcell date, reusing older dates if refreshing a present workflow.
"""
if os.path.exists(out_config_file):
with open(out_config_file) as in_handle:
old_config = yaml.safe_load(in_handle)
fc_date = old_config["fc_date"]
else:... | [
"def",
"get_fc_date",
"(",
"out_config_file",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"out_config_file",
")",
":",
"with",
"open",
"(",
"out_config_file",
")",
"as",
"in_handle",
":",
"old_config",
"=",
"yaml",
".",
"safe_load",
"(",
"in_han... | Retrieve flowcell date, reusing older dates if refreshing a present workflow. | [
"Retrieve",
"flowcell",
"date",
"reusing",
"older",
"dates",
"if",
"refreshing",
"a",
"present",
"workflow",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/workflow/xprize.py#L32-L41 |
223,759 | bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | draw_quality_plot | def draw_quality_plot(db_file, plot_file, position_select, title):
"""Draw a plot of remapped qualities using ggplot2.
Remapping information is pulled from the sqlite3 database using sqldf
according to the position select attribute, which is a selection phrase like
'> 50' or '=28'.
plyr is used to... | python | def draw_quality_plot(db_file, plot_file, position_select, title):
"""Draw a plot of remapped qualities using ggplot2.
Remapping information is pulled from the sqlite3 database using sqldf
according to the position select attribute, which is a selection phrase like
'> 50' or '=28'.
plyr is used to... | [
"def",
"draw_quality_plot",
"(",
"db_file",
",",
"plot_file",
",",
"position_select",
",",
"title",
")",
":",
"robjects",
".",
"r",
".",
"assign",
"(",
"'db.file'",
",",
"db_file",
")",
"robjects",
".",
"r",
".",
"assign",
"(",
"'plot.file'",
",",
"plot_fi... | Draw a plot of remapped qualities using ggplot2.
Remapping information is pulled from the sqlite3 database using sqldf
according to the position select attribute, which is a selection phrase like
'> 50' or '=28'.
plyr is used to summarize data by the original and remapped score for all
selected po... | [
"Draw",
"a",
"plot",
"of",
"remapped",
"qualities",
"using",
"ggplot2",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L112-L143 |
223,760 | bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | _positions_to_examine | def _positions_to_examine(db_file):
"""Determine how to sub-divide recalibration analysis based on read length.
"""
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
cursor.execute("""SELECT MAX(position) FROM data""")
position = cursor.fetchone()[0]
if position is not None:
pos... | python | def _positions_to_examine(db_file):
"""Determine how to sub-divide recalibration analysis based on read length.
"""
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
cursor.execute("""SELECT MAX(position) FROM data""")
position = cursor.fetchone()[0]
if position is not None:
pos... | [
"def",
"_positions_to_examine",
"(",
"db_file",
")",
":",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
"db_file",
")",
"cursor",
"=",
"conn",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"\"\"\"SELECT MAX(position) FROM data\"\"\"",
")",
"position",
... | Determine how to sub-divide recalibration analysis based on read length. | [
"Determine",
"how",
"to",
"sub",
"-",
"divide",
"recalibration",
"analysis",
"based",
"on",
"read",
"length",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L145-L162 |
223,761 | bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | _organize_by_position | def _organize_by_position(orig_file, cmp_file, chunk_size):
"""Read two CSV files of qualities, organizing values by position.
"""
with open(orig_file) as in_handle:
reader1 = csv.reader(in_handle)
positions = len(next(reader1)) - 1
for positions in _chunks(range(positions), chunk_size):... | python | def _organize_by_position(orig_file, cmp_file, chunk_size):
"""Read two CSV files of qualities, organizing values by position.
"""
with open(orig_file) as in_handle:
reader1 = csv.reader(in_handle)
positions = len(next(reader1)) - 1
for positions in _chunks(range(positions), chunk_size):... | [
"def",
"_organize_by_position",
"(",
"orig_file",
",",
"cmp_file",
",",
"chunk_size",
")",
":",
"with",
"open",
"(",
"orig_file",
")",
"as",
"in_handle",
":",
"reader1",
"=",
"csv",
".",
"reader",
"(",
"in_handle",
")",
"positions",
"=",
"len",
"(",
"next"... | Read two CSV files of qualities, organizing values by position. | [
"Read",
"two",
"CSV",
"files",
"of",
"qualities",
"organizing",
"values",
"by",
"position",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L183-L196 |
223,762 | bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | _counts_at_position | def _counts_at_position(positions, orig_reader, cmp_reader):
"""Combine orignal and new qualities at each position, generating counts.
"""
pos_counts = collections.defaultdict(lambda:
collections.defaultdict(lambda:
collections.defaultdict(int)))
for orig_parts in orig_... | python | def _counts_at_position(positions, orig_reader, cmp_reader):
"""Combine orignal and new qualities at each position, generating counts.
"""
pos_counts = collections.defaultdict(lambda:
collections.defaultdict(lambda:
collections.defaultdict(int)))
for orig_parts in orig_... | [
"def",
"_counts_at_position",
"(",
"positions",
",",
"orig_reader",
",",
"cmp_reader",
")",
":",
"pos_counts",
"=",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"collections",
".",
"defaultdict",
"... | Combine orignal and new qualities at each position, generating counts. | [
"Combine",
"orignal",
"and",
"new",
"qualities",
"at",
"each",
"position",
"generating",
"counts",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L206-L222 |
223,763 | bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | sort_csv | def sort_csv(in_file):
"""Sort a CSV file by read name, allowing direct comparison.
"""
out_file = "%s.sort" % in_file
if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
cl = ["sort", "-k", "1,1", in_file]
with open(out_file, "w") as out_handle:
child = subp... | python | def sort_csv(in_file):
"""Sort a CSV file by read name, allowing direct comparison.
"""
out_file = "%s.sort" % in_file
if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
cl = ["sort", "-k", "1,1", in_file]
with open(out_file, "w") as out_handle:
child = subp... | [
"def",
"sort_csv",
"(",
"in_file",
")",
":",
"out_file",
"=",
"\"%s.sort\"",
"%",
"in_file",
"if",
"not",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"out_file",
")",
"and",
"os",
".",
"path",
".",
"getsize",
"(",
"out_file",
")",
">",
"0",
")",
":... | Sort a CSV file by read name, allowing direct comparison. | [
"Sort",
"a",
"CSV",
"file",
"by",
"read",
"name",
"allowing",
"direct",
"comparison",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L224-L233 |
223,764 | bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | fastq_to_csv | def fastq_to_csv(in_file, fastq_format, work_dir):
"""Convert a fastq file into a CSV of phred quality scores.
"""
out_file = "%s.csv" % (os.path.splitext(os.path.basename(in_file))[0])
out_file = os.path.join(work_dir, out_file)
if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
... | python | def fastq_to_csv(in_file, fastq_format, work_dir):
"""Convert a fastq file into a CSV of phred quality scores.
"""
out_file = "%s.csv" % (os.path.splitext(os.path.basename(in_file))[0])
out_file = os.path.join(work_dir, out_file)
if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
... | [
"def",
"fastq_to_csv",
"(",
"in_file",
",",
"fastq_format",
",",
"work_dir",
")",
":",
"out_file",
"=",
"\"%s.csv\"",
"%",
"(",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"in_file",
")",
")",
"[",
"0",
"]",
")",... | Convert a fastq file into a CSV of phred quality scores. | [
"Convert",
"a",
"fastq",
"file",
"into",
"a",
"CSV",
"of",
"phred",
"quality",
"scores",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L235-L246 |
223,765 | bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | bam_to_fastq | def bam_to_fastq(bam_file, is_paired):
"""Convert a BAM file to fastq files.
"""
out_files, out_handles = _get_fastq_handles(bam_file,
is_paired)
if len(out_handles) > 0:
in_bam = pysam.Samfile(bam_file, mode='rb')
for read in in_bam:
num = 1 if (not read.is_paire... | python | def bam_to_fastq(bam_file, is_paired):
"""Convert a BAM file to fastq files.
"""
out_files, out_handles = _get_fastq_handles(bam_file,
is_paired)
if len(out_handles) > 0:
in_bam = pysam.Samfile(bam_file, mode='rb')
for read in in_bam:
num = 1 if (not read.is_paire... | [
"def",
"bam_to_fastq",
"(",
"bam_file",
",",
"is_paired",
")",
":",
"out_files",
",",
"out_handles",
"=",
"_get_fastq_handles",
"(",
"bam_file",
",",
"is_paired",
")",
"if",
"len",
"(",
"out_handles",
")",
">",
"0",
":",
"in_bam",
"=",
"pysam",
".",
"Samfi... | Convert a BAM file to fastq files. | [
"Convert",
"a",
"BAM",
"file",
"to",
"fastq",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L248-L267 |
223,766 | bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | run_latex_report | def run_latex_report(base, report_dir, section_info):
"""Generate a pdf report with plots using latex.
"""
out_name = "%s_recal_plots.tex" % base
out = os.path.join(report_dir, out_name)
with open(out, "w") as out_handle:
out_tmpl = Template(out_template)
out_handle.write(out_tmpl.re... | python | def run_latex_report(base, report_dir, section_info):
"""Generate a pdf report with plots using latex.
"""
out_name = "%s_recal_plots.tex" % base
out = os.path.join(report_dir, out_name)
with open(out, "w") as out_handle:
out_tmpl = Template(out_template)
out_handle.write(out_tmpl.re... | [
"def",
"run_latex_report",
"(",
"base",
",",
"report_dir",
",",
"section_info",
")",
":",
"out_name",
"=",
"\"%s_recal_plots.tex\"",
"%",
"base",
"out",
"=",
"os",
".",
"path",
".",
"join",
"(",
"report_dir",
",",
"out_name",
")",
"with",
"open",
"(",
"out... | Generate a pdf report with plots using latex. | [
"Generate",
"a",
"pdf",
"report",
"with",
"plots",
"using",
"latex",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L301-L316 |
223,767 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | bam_needs_processing | def bam_needs_processing(data):
"""Check if a work input needs processing for parallelization.
"""
return ((data.get("work_bam") or data.get("align_bam")) and
(any(tz.get_in(["config", "algorithm", x], data) for x in
["variantcaller", "mark_duplicates", "recalibrate", "realign",... | python | def bam_needs_processing(data):
"""Check if a work input needs processing for parallelization.
"""
return ((data.get("work_bam") or data.get("align_bam")) and
(any(tz.get_in(["config", "algorithm", x], data) for x in
["variantcaller", "mark_duplicates", "recalibrate", "realign",... | [
"def",
"bam_needs_processing",
"(",
"data",
")",
":",
"return",
"(",
"(",
"data",
".",
"get",
"(",
"\"work_bam\"",
")",
"or",
"data",
".",
"get",
"(",
"\"align_bam\"",
")",
")",
"and",
"(",
"any",
"(",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
","... | Check if a work input needs processing for parallelization. | [
"Check",
"if",
"a",
"work",
"input",
"needs",
"processing",
"for",
"parallelization",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L30-L37 |
223,768 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | get_batch_for_key | def get_batch_for_key(data):
"""Retrieve batch information useful as a unique key for the sample.
"""
batches = _get_batches(data, require_bam=False)
if len(batches) == 1:
return batches[0]
else:
return tuple(batches) | python | def get_batch_for_key(data):
"""Retrieve batch information useful as a unique key for the sample.
"""
batches = _get_batches(data, require_bam=False)
if len(batches) == 1:
return batches[0]
else:
return tuple(batches) | [
"def",
"get_batch_for_key",
"(",
"data",
")",
":",
"batches",
"=",
"_get_batches",
"(",
"data",
",",
"require_bam",
"=",
"False",
")",
"if",
"len",
"(",
"batches",
")",
"==",
"1",
":",
"return",
"batches",
"[",
"0",
"]",
"else",
":",
"return",
"tuple",... | Retrieve batch information useful as a unique key for the sample. | [
"Retrieve",
"batch",
"information",
"useful",
"as",
"a",
"unique",
"key",
"for",
"the",
"sample",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L39-L46 |
223,769 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | _find_all_groups | def _find_all_groups(items, require_bam=True):
"""Find all groups
"""
all_groups = []
for data in items:
batches = _get_batches(data, require_bam)
all_groups.append(batches)
return all_groups | python | def _find_all_groups(items, require_bam=True):
"""Find all groups
"""
all_groups = []
for data in items:
batches = _get_batches(data, require_bam)
all_groups.append(batches)
return all_groups | [
"def",
"_find_all_groups",
"(",
"items",
",",
"require_bam",
"=",
"True",
")",
":",
"all_groups",
"=",
"[",
"]",
"for",
"data",
"in",
"items",
":",
"batches",
"=",
"_get_batches",
"(",
"data",
",",
"require_bam",
")",
"all_groups",
".",
"append",
"(",
"b... | Find all groups | [
"Find",
"all",
"groups"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L57-L64 |
223,770 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | _get_representative_batch | def _get_representative_batch(merged):
"""Prepare dictionary matching batch items to a representative within a group.
"""
out = {}
for mgroup in merged:
mgroup = sorted(list(mgroup))
for x in mgroup:
out[x] = mgroup[0]
return out | python | def _get_representative_batch(merged):
"""Prepare dictionary matching batch items to a representative within a group.
"""
out = {}
for mgroup in merged:
mgroup = sorted(list(mgroup))
for x in mgroup:
out[x] = mgroup[0]
return out | [
"def",
"_get_representative_batch",
"(",
"merged",
")",
":",
"out",
"=",
"{",
"}",
"for",
"mgroup",
"in",
"merged",
":",
"mgroup",
"=",
"sorted",
"(",
"list",
"(",
"mgroup",
")",
")",
"for",
"x",
"in",
"mgroup",
":",
"out",
"[",
"x",
"]",
"=",
"mgr... | Prepare dictionary matching batch items to a representative within a group. | [
"Prepare",
"dictionary",
"matching",
"batch",
"items",
"to",
"a",
"representative",
"within",
"a",
"group",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L90-L98 |
223,771 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | _group_batches_shared | def _group_batches_shared(xs, caller_batch_fn, prep_data_fn):
"""Shared functionality for grouping by batches for variant calling and joint calling.
"""
singles = []
batch_groups = collections.defaultdict(list)
for args in xs:
data = utils.to_single_data(args)
caller, batch = caller_... | python | def _group_batches_shared(xs, caller_batch_fn, prep_data_fn):
"""Shared functionality for grouping by batches for variant calling and joint calling.
"""
singles = []
batch_groups = collections.defaultdict(list)
for args in xs:
data = utils.to_single_data(args)
caller, batch = caller_... | [
"def",
"_group_batches_shared",
"(",
"xs",
",",
"caller_batch_fn",
",",
"prep_data_fn",
")",
":",
"singles",
"=",
"[",
"]",
"batch_groups",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"args",
"in",
"xs",
":",
"data",
"=",
"utils",
".",... | Shared functionality for grouping by batches for variant calling and joint calling. | [
"Shared",
"functionality",
"for",
"grouping",
"by",
"batches",
"for",
"variant",
"calling",
"and",
"joint",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L106-L133 |
223,772 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | group_batches | def group_batches(xs):
"""Group samples into batches for simultaneous variant calling.
Identify all samples to call together: those in the same batch
and variant caller.
Pull together all BAM files from this batch and process together,
Provide details to pull these finalized files back into individ... | python | def group_batches(xs):
"""Group samples into batches for simultaneous variant calling.
Identify all samples to call together: those in the same batch
and variant caller.
Pull together all BAM files from this batch and process together,
Provide details to pull these finalized files back into individ... | [
"def",
"group_batches",
"(",
"xs",
")",
":",
"def",
"_caller_batches",
"(",
"data",
")",
":",
"caller",
"=",
"tz",
".",
"get_in",
"(",
"(",
"\"config\"",
",",
"\"algorithm\"",
",",
"\"variantcaller\"",
")",
",",
"data",
")",
"jointcaller",
"=",
"tz",
"."... | Group samples into batches for simultaneous variant calling.
Identify all samples to call together: those in the same batch
and variant caller.
Pull together all BAM files from this batch and process together,
Provide details to pull these finalized files back into individual
expected files.
On... | [
"Group",
"samples",
"into",
"batches",
"for",
"simultaneous",
"variant",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L135-L153 |
223,773 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | _collapse_subitems | def _collapse_subitems(base, items):
"""Collapse full data representations relative to a standard base.
"""
out = []
for d in items:
newd = _diff_dict(base, d)
out.append(newd)
return out | python | def _collapse_subitems(base, items):
"""Collapse full data representations relative to a standard base.
"""
out = []
for d in items:
newd = _diff_dict(base, d)
out.append(newd)
return out | [
"def",
"_collapse_subitems",
"(",
"base",
",",
"items",
")",
":",
"out",
"=",
"[",
"]",
"for",
"d",
"in",
"items",
":",
"newd",
"=",
"_diff_dict",
"(",
"base",
",",
"d",
")",
"out",
".",
"append",
"(",
"newd",
")",
"return",
"out"
] | Collapse full data representations relative to a standard base. | [
"Collapse",
"full",
"data",
"representations",
"relative",
"to",
"a",
"standard",
"base",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L173-L180 |
223,774 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | _pick_lead_item | def _pick_lead_item(items):
"""Pick single representative sample for batch calling to attach calls to.
For cancer samples, attach to tumor.
"""
if vcfutils.is_paired_analysis([dd.get_align_bam(x) for x in items], items):
for data in items:
if vcfutils.get_paired_phenotype(data) == "... | python | def _pick_lead_item(items):
"""Pick single representative sample for batch calling to attach calls to.
For cancer samples, attach to tumor.
"""
if vcfutils.is_paired_analysis([dd.get_align_bam(x) for x in items], items):
for data in items:
if vcfutils.get_paired_phenotype(data) == "... | [
"def",
"_pick_lead_item",
"(",
"items",
")",
":",
"if",
"vcfutils",
".",
"is_paired_analysis",
"(",
"[",
"dd",
".",
"get_align_bam",
"(",
"x",
")",
"for",
"x",
"in",
"items",
"]",
",",
"items",
")",
":",
"for",
"data",
"in",
"items",
":",
"if",
"vcfu... | Pick single representative sample for batch calling to attach calls to.
For cancer samples, attach to tumor. | [
"Pick",
"single",
"representative",
"sample",
"for",
"batch",
"calling",
"to",
"attach",
"calls",
"to",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L198-L209 |
223,775 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | get_orig_items | def get_orig_items(base):
"""Retrieve original items from a diffed set of nested samples.
"""
assert "group_orig" in base
out = []
for data_diff in base["group_orig"]:
new = utils.deepish_copy(base)
new.pop("group_orig")
out.append(_patch_dict(data_diff, new))
return out | python | def get_orig_items(base):
"""Retrieve original items from a diffed set of nested samples.
"""
assert "group_orig" in base
out = []
for data_diff in base["group_orig"]:
new = utils.deepish_copy(base)
new.pop("group_orig")
out.append(_patch_dict(data_diff, new))
return out | [
"def",
"get_orig_items",
"(",
"base",
")",
":",
"assert",
"\"group_orig\"",
"in",
"base",
"out",
"=",
"[",
"]",
"for",
"data_diff",
"in",
"base",
"[",
"\"group_orig\"",
"]",
":",
"new",
"=",
"utils",
".",
"deepish_copy",
"(",
"base",
")",
"new",
".",
"... | Retrieve original items from a diffed set of nested samples. | [
"Retrieve",
"original",
"items",
"from",
"a",
"diffed",
"set",
"of",
"nested",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L211-L220 |
223,776 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | _patch_dict | def _patch_dict(diff, base):
"""Patch a dictionary, substituting in changed items from the nested diff.
"""
for k, v in diff.items():
if isinstance(v, dict):
base[k] = _patch_dict(v, base.get(k, {}))
elif not v:
base.pop(k, None)
else:
base[k] = v
... | python | def _patch_dict(diff, base):
"""Patch a dictionary, substituting in changed items from the nested diff.
"""
for k, v in diff.items():
if isinstance(v, dict):
base[k] = _patch_dict(v, base.get(k, {}))
elif not v:
base.pop(k, None)
else:
base[k] = v
... | [
"def",
"_patch_dict",
"(",
"diff",
",",
"base",
")",
":",
"for",
"k",
",",
"v",
"in",
"diff",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
"base",
"[",
"k",
"]",
"=",
"_patch_dict",
"(",
"v",
",",
"base",
... | Patch a dictionary, substituting in changed items from the nested diff. | [
"Patch",
"a",
"dictionary",
"substituting",
"in",
"changed",
"items",
"from",
"the",
"nested",
"diff",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L222-L232 |
223,777 | bcbio/bcbio-nextgen | bcbio/variation/multi.py | split_variants_by_sample | def split_variants_by_sample(data):
"""Split a multi-sample call file into inputs for individual samples.
For tumor/normal paired analyses, do not split the final file and attach
it to the tumor input.
"""
# not split, do nothing
if "group_orig" not in data:
return [[data]]
# cancer... | python | def split_variants_by_sample(data):
"""Split a multi-sample call file into inputs for individual samples.
For tumor/normal paired analyses, do not split the final file and attach
it to the tumor input.
"""
# not split, do nothing
if "group_orig" not in data:
return [[data]]
# cancer... | [
"def",
"split_variants_by_sample",
"(",
"data",
")",
":",
"# not split, do nothing",
"if",
"\"group_orig\"",
"not",
"in",
"data",
":",
"return",
"[",
"[",
"data",
"]",
"]",
"# cancer tumor/normal",
"elif",
"(",
"vcfutils",
".",
"get_paired_phenotype",
"(",
"data",... | Split a multi-sample call file into inputs for individual samples.
For tumor/normal paired analyses, do not split the final file and attach
it to the tumor input. | [
"Split",
"a",
"multi",
"-",
"sample",
"call",
"file",
"into",
"inputs",
"for",
"individual",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L236-L269 |
223,778 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | run | def run(call_file, ref_file, vrn_files, data):
"""Run filtering on the input call file, handling SNPs and indels separately.
"""
algs = [data["config"]["algorithm"]] * len(data.get("vrn_files", [1]))
if includes_missingalt(data):
logger.info("Removing variants with missing alts from %s." % call_... | python | def run(call_file, ref_file, vrn_files, data):
"""Run filtering on the input call file, handling SNPs and indels separately.
"""
algs = [data["config"]["algorithm"]] * len(data.get("vrn_files", [1]))
if includes_missingalt(data):
logger.info("Removing variants with missing alts from %s." % call_... | [
"def",
"run",
"(",
"call_file",
",",
"ref_file",
",",
"vrn_files",
",",
"data",
")",
":",
"algs",
"=",
"[",
"data",
"[",
"\"config\"",
"]",
"[",
"\"algorithm\"",
"]",
"]",
"*",
"len",
"(",
"data",
".",
"get",
"(",
"\"vrn_files\"",
",",
"[",
"1",
"]... | Run filtering on the input call file, handling SNPs and indels separately. | [
"Run",
"filtering",
"on",
"the",
"input",
"call",
"file",
"handling",
"SNPs",
"and",
"indels",
"separately",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L15-L41 |
223,779 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _cnn_filter | def _cnn_filter(in_file, vrn_files, data):
"""Perform CNN filtering on input VCF using pre-trained models.
"""
#tensor_type = "reference" # 1D, reference sequence
tensor_type = "read_tensor" # 2D, reads, flags, mapping quality
score_file = _cnn_score_variants(in_file, tensor_type, data)
return... | python | def _cnn_filter(in_file, vrn_files, data):
"""Perform CNN filtering on input VCF using pre-trained models.
"""
#tensor_type = "reference" # 1D, reference sequence
tensor_type = "read_tensor" # 2D, reads, flags, mapping quality
score_file = _cnn_score_variants(in_file, tensor_type, data)
return... | [
"def",
"_cnn_filter",
"(",
"in_file",
",",
"vrn_files",
",",
"data",
")",
":",
"#tensor_type = \"reference\" # 1D, reference sequence",
"tensor_type",
"=",
"\"read_tensor\"",
"# 2D, reads, flags, mapping quality",
"score_file",
"=",
"_cnn_score_variants",
"(",
"in_file",
","... | Perform CNN filtering on input VCF using pre-trained models. | [
"Perform",
"CNN",
"filtering",
"on",
"input",
"VCF",
"using",
"pre",
"-",
"trained",
"models",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L45-L51 |
223,780 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _cnn_tranch_filtering | def _cnn_tranch_filtering(in_file, vrn_files, tensor_type, data):
"""Filter CNN scored VCFs in tranches using standard SNP and Indel truth sets.
"""
out_file = "%s-filter.vcf.gz" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file):
runner = broad.runner_from_config(da... | python | def _cnn_tranch_filtering(in_file, vrn_files, tensor_type, data):
"""Filter CNN scored VCFs in tranches using standard SNP and Indel truth sets.
"""
out_file = "%s-filter.vcf.gz" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file):
runner = broad.runner_from_config(da... | [
"def",
"_cnn_tranch_filtering",
"(",
"in_file",
",",
"vrn_files",
",",
"tensor_type",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-filter.vcf.gz\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"if",
"not",
"utils",
".",
"file_upt... | Filter CNN scored VCFs in tranches using standard SNP and Indel truth sets. | [
"Filter",
"CNN",
"scored",
"VCFs",
"in",
"tranches",
"using",
"standard",
"SNP",
"and",
"Indel",
"truth",
"sets",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L53-L74 |
223,781 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _cnn_score_variants | def _cnn_score_variants(in_file, tensor_type, data):
"""Score variants with pre-trained CNN models.
"""
out_file = "%s-cnnscore.vcf.gz" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file):
runner = broad.runner_from_config(data["config"])
gatk_type = runner.ga... | python | def _cnn_score_variants(in_file, tensor_type, data):
"""Score variants with pre-trained CNN models.
"""
out_file = "%s-cnnscore.vcf.gz" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file):
runner = broad.runner_from_config(data["config"])
gatk_type = runner.ga... | [
"def",
"_cnn_score_variants",
"(",
"in_file",
",",
"tensor_type",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-cnnscore.vcf.gz\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"if",
"not",
"utils",
".",
"file_uptodate",
"(",
"out_... | Score variants with pre-trained CNN models. | [
"Score",
"variants",
"with",
"pre",
"-",
"trained",
"CNN",
"models",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L76-L89 |
223,782 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _apply_vqsr | def _apply_vqsr(in_file, ref_file, recal_file, tranch_file,
sensitivity_cutoff, filter_type, data):
"""Apply VQSR based on the specified tranche, returning a filtered VCF file.
"""
base, ext = utils.splitext_plus(in_file)
out_file = "{base}-{filter}filter{ext}".format(base=base, ext=ext,... | python | def _apply_vqsr(in_file, ref_file, recal_file, tranch_file,
sensitivity_cutoff, filter_type, data):
"""Apply VQSR based on the specified tranche, returning a filtered VCF file.
"""
base, ext = utils.splitext_plus(in_file)
out_file = "{base}-{filter}filter{ext}".format(base=base, ext=ext,... | [
"def",
"_apply_vqsr",
"(",
"in_file",
",",
"ref_file",
",",
"recal_file",
",",
"tranch_file",
",",
"sensitivity_cutoff",
",",
"filter_type",
",",
"data",
")",
":",
"base",
",",
"ext",
"=",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"out_file",
"=",
... | Apply VQSR based on the specified tranche, returning a filtered VCF file. | [
"Apply",
"VQSR",
"based",
"on",
"the",
"specified",
"tranche",
"returning",
"a",
"filtered",
"VCF",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L93-L127 |
223,783 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _get_training_data | def _get_training_data(vrn_files):
"""Retrieve training data, returning an empty set of information if not available.
"""
out = {"SNP": [], "INDEL": []}
# SNPs
for name, train_info in [("train_hapmap", "known=false,training=true,truth=true,prior=15.0"),
("train_omni", "k... | python | def _get_training_data(vrn_files):
"""Retrieve training data, returning an empty set of information if not available.
"""
out = {"SNP": [], "INDEL": []}
# SNPs
for name, train_info in [("train_hapmap", "known=false,training=true,truth=true,prior=15.0"),
("train_omni", "k... | [
"def",
"_get_training_data",
"(",
"vrn_files",
")",
":",
"out",
"=",
"{",
"\"SNP\"",
":",
"[",
"]",
",",
"\"INDEL\"",
":",
"[",
"]",
"}",
"# SNPs",
"for",
"name",
",",
"train_info",
"in",
"[",
"(",
"\"train_hapmap\"",
",",
"\"known=false,training=true,truth=... | Retrieve training data, returning an empty set of information if not available. | [
"Retrieve",
"training",
"data",
"returning",
"an",
"empty",
"set",
"of",
"information",
"if",
"not",
"available",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L129-L148 |
223,784 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _get_vqsr_training | def _get_vqsr_training(filter_type, vrn_files, gatk_type):
"""Return parameters for VQSR training, handling SNPs and Indels.
"""
params = []
for name, train_info, fname in _get_training_data(vrn_files)[filter_type]:
if gatk_type == "gatk4":
params.extend(["--resource:%s,%s" % (name, ... | python | def _get_vqsr_training(filter_type, vrn_files, gatk_type):
"""Return parameters for VQSR training, handling SNPs and Indels.
"""
params = []
for name, train_info, fname in _get_training_data(vrn_files)[filter_type]:
if gatk_type == "gatk4":
params.extend(["--resource:%s,%s" % (name, ... | [
"def",
"_get_vqsr_training",
"(",
"filter_type",
",",
"vrn_files",
",",
"gatk_type",
")",
":",
"params",
"=",
"[",
"]",
"for",
"name",
",",
"train_info",
",",
"fname",
"in",
"_get_training_data",
"(",
"vrn_files",
")",
"[",
"filter_type",
"]",
":",
"if",
"... | Return parameters for VQSR training, handling SNPs and Indels. | [
"Return",
"parameters",
"for",
"VQSR",
"training",
"handling",
"SNPs",
"and",
"Indels",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L153-L166 |
223,785 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _get_vqsr_annotations | def _get_vqsr_annotations(filter_type, data):
"""Retrieve appropriate annotations to use for VQSR based on filter type.
Issues reported with MQ and bwa-mem quality distribution, results in intermittent
failures to use VQSR:
http://gatkforums.broadinstitute.org/discussion/4425/variant-recalibration-fail... | python | def _get_vqsr_annotations(filter_type, data):
"""Retrieve appropriate annotations to use for VQSR based on filter type.
Issues reported with MQ and bwa-mem quality distribution, results in intermittent
failures to use VQSR:
http://gatkforums.broadinstitute.org/discussion/4425/variant-recalibration-fail... | [
"def",
"_get_vqsr_annotations",
"(",
"filter_type",
",",
"data",
")",
":",
"if",
"filter_type",
"==",
"\"SNP\"",
":",
"# MQ, MQRankSum",
"anns",
"=",
"[",
"\"QD\"",
",",
"\"FS\"",
",",
"\"ReadPosRankSum\"",
",",
"\"SOR\"",
"]",
"else",
":",
"assert",
"filter_t... | Retrieve appropriate annotations to use for VQSR based on filter type.
Issues reported with MQ and bwa-mem quality distribution, results in intermittent
failures to use VQSR:
http://gatkforums.broadinstitute.org/discussion/4425/variant-recalibration-failing
http://gatkforums.broadinstitute.org/discussi... | [
"Retrieve",
"appropriate",
"annotations",
"to",
"use",
"for",
"VQSR",
"based",
"on",
"filter",
"type",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L168-L185 |
223,786 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _run_vqsr | def _run_vqsr(in_file, ref_file, vrn_files, sensitivity_cutoff, filter_type, data):
"""Run variant quality score recalibration.
"""
cutoffs = ["100.0", "99.99", "99.98", "99.97", "99.96", "99.95", "99.94", "99.93", "99.92", "99.91",
"99.9", "99.8", "99.7", "99.6", "99.5", "99.0", "98.0", "90.... | python | def _run_vqsr(in_file, ref_file, vrn_files, sensitivity_cutoff, filter_type, data):
"""Run variant quality score recalibration.
"""
cutoffs = ["100.0", "99.99", "99.98", "99.97", "99.96", "99.95", "99.94", "99.93", "99.92", "99.91",
"99.9", "99.8", "99.7", "99.6", "99.5", "99.0", "98.0", "90.... | [
"def",
"_run_vqsr",
"(",
"in_file",
",",
"ref_file",
",",
"vrn_files",
",",
"sensitivity_cutoff",
",",
"filter_type",
",",
"data",
")",
":",
"cutoffs",
"=",
"[",
"\"100.0\"",
",",
"\"99.99\"",
",",
"\"99.98\"",
",",
"\"99.97\"",
",",
"\"99.96\"",
",",
"\"99.... | Run variant quality score recalibration. | [
"Run",
"variant",
"quality",
"score",
"recalibration",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L187-L230 |
223,787 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _already_cutoff_filtered | def _already_cutoff_filtered(in_file, filter_type):
"""Check if we have a pre-existing cutoff-based filter file from previous VQSR failure.
"""
filter_file = "%s-filter%s.vcf.gz" % (utils.splitext_plus(in_file)[0], filter_type)
return utils.file_exists(filter_file) | python | def _already_cutoff_filtered(in_file, filter_type):
"""Check if we have a pre-existing cutoff-based filter file from previous VQSR failure.
"""
filter_file = "%s-filter%s.vcf.gz" % (utils.splitext_plus(in_file)[0], filter_type)
return utils.file_exists(filter_file) | [
"def",
"_already_cutoff_filtered",
"(",
"in_file",
",",
"filter_type",
")",
":",
"filter_file",
"=",
"\"%s-filter%s.vcf.gz\"",
"%",
"(",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
",",
"filter_type",
")",
"return",
"utils",
".",
"file_e... | Check if we have a pre-existing cutoff-based filter file from previous VQSR failure. | [
"Check",
"if",
"we",
"have",
"a",
"pre",
"-",
"existing",
"cutoff",
"-",
"based",
"filter",
"file",
"from",
"previous",
"VQSR",
"failure",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L234-L238 |
223,788 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _variant_filtration | def _variant_filtration(in_file, ref_file, vrn_files, data, filter_type,
hard_filter_fn):
"""Filter SNP and indel variant calls using GATK best practice recommendations.
Use cutoff-based soft filters if configuration indicates too little data or
already finished a cutoff-based filte... | python | def _variant_filtration(in_file, ref_file, vrn_files, data, filter_type,
hard_filter_fn):
"""Filter SNP and indel variant calls using GATK best practice recommendations.
Use cutoff-based soft filters if configuration indicates too little data or
already finished a cutoff-based filte... | [
"def",
"_variant_filtration",
"(",
"in_file",
",",
"ref_file",
",",
"vrn_files",
",",
"data",
",",
"filter_type",
",",
"hard_filter_fn",
")",
":",
"# Algorithms multiplied by number of input files to check for large enough sample sizes",
"algs",
"=",
"[",
"data",
"[",
"\"... | Filter SNP and indel variant calls using GATK best practice recommendations.
Use cutoff-based soft filters if configuration indicates too little data or
already finished a cutoff-based filtering step, otherwise try VQSR. | [
"Filter",
"SNP",
"and",
"indel",
"variant",
"calls",
"using",
"GATK",
"best",
"practice",
"recommendations",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L240-L265 |
223,789 | bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | gatk_remove_missingalt | def gatk_remove_missingalt(in_file, data):
"""
GATK 4.1.0.0 outputs variants that have missing ALTs, which breaks downstream
tools, this filters those out.
"""
base = in_file.split('.vcf.gz')[0]
out_file = "%s-nomissingalt%s" % (base, '.vcf.gz')
if utils.file_exists(out_file):
return... | python | def gatk_remove_missingalt(in_file, data):
"""
GATK 4.1.0.0 outputs variants that have missing ALTs, which breaks downstream
tools, this filters those out.
"""
base = in_file.split('.vcf.gz')[0]
out_file = "%s-nomissingalt%s" % (base, '.vcf.gz')
if utils.file_exists(out_file):
return... | [
"def",
"gatk_remove_missingalt",
"(",
"in_file",
",",
"data",
")",
":",
"base",
"=",
"in_file",
".",
"split",
"(",
"'.vcf.gz'",
")",
"[",
"0",
"]",
"out_file",
"=",
"\"%s-nomissingalt%s\"",
"%",
"(",
"base",
",",
"'.vcf.gz'",
")",
"if",
"utils",
".",
"fi... | GATK 4.1.0.0 outputs variants that have missing ALTs, which breaks downstream
tools, this filters those out. | [
"GATK",
"4",
".",
"1",
".",
"0",
".",
"0",
"outputs",
"variants",
"that",
"have",
"missing",
"ALTs",
"which",
"breaks",
"downstream",
"tools",
"this",
"filters",
"those",
"out",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L276-L292 |
223,790 | bcbio/bcbio-nextgen | bcbio/rnaseq/cufflinks.py | strand_unknown | def strand_unknown(db, transcript):
"""
for unstranded data with novel transcripts single exon genes
will have no strand information. single exon novel genes are also
a source of noise in the Cufflinks assembly so this removes them
"""
features = list(db.children(transcript))
strand = featur... | python | def strand_unknown(db, transcript):
"""
for unstranded data with novel transcripts single exon genes
will have no strand information. single exon novel genes are also
a source of noise in the Cufflinks assembly so this removes them
"""
features = list(db.children(transcript))
strand = featur... | [
"def",
"strand_unknown",
"(",
"db",
",",
"transcript",
")",
":",
"features",
"=",
"list",
"(",
"db",
".",
"children",
"(",
"transcript",
")",
")",
"strand",
"=",
"features",
"[",
"0",
"]",
".",
"strand",
"if",
"strand",
"==",
"\".\"",
":",
"return",
... | for unstranded data with novel transcripts single exon genes
will have no strand information. single exon novel genes are also
a source of noise in the Cufflinks assembly so this removes them | [
"for",
"unstranded",
"data",
"with",
"novel",
"transcripts",
"single",
"exon",
"genes",
"will",
"have",
"no",
"strand",
"information",
".",
"single",
"exon",
"novel",
"genes",
"are",
"also",
"a",
"source",
"of",
"noise",
"in",
"the",
"Cufflinks",
"assembly",
... | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/cufflinks.py#L156-L167 |
223,791 | bcbio/bcbio-nextgen | bcbio/rnaseq/cufflinks.py | fix_cufflinks_attributes | def fix_cufflinks_attributes(ref_gtf, merged_gtf, data, out_file=None):
"""
replace the cufflinks gene_id and transcript_id with the
gene_id and transcript_id from ref_gtf, where available
"""
base, ext = os.path.splitext(merged_gtf)
fixed = out_file if out_file else base + ".clean.fixed" + ext... | python | def fix_cufflinks_attributes(ref_gtf, merged_gtf, data, out_file=None):
"""
replace the cufflinks gene_id and transcript_id with the
gene_id and transcript_id from ref_gtf, where available
"""
base, ext = os.path.splitext(merged_gtf)
fixed = out_file if out_file else base + ".clean.fixed" + ext... | [
"def",
"fix_cufflinks_attributes",
"(",
"ref_gtf",
",",
"merged_gtf",
",",
"data",
",",
"out_file",
"=",
"None",
")",
":",
"base",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"merged_gtf",
")",
"fixed",
"=",
"out_file",
"if",
"out_file",
"e... | replace the cufflinks gene_id and transcript_id with the
gene_id and transcript_id from ref_gtf, where available | [
"replace",
"the",
"cufflinks",
"gene_id",
"and",
"transcript_id",
"with",
"the",
"gene_id",
"and",
"transcript_id",
"from",
"ref_gtf",
"where",
"available"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/cufflinks.py#L179-L234 |
223,792 | bcbio/bcbio-nextgen | bcbio/rnaseq/cufflinks.py | merge | def merge(assembled_gtfs, ref_file, gtf_file, num_cores, data):
"""
run cuffmerge on a set of assembled GTF files
"""
assembled_file = tempfile.NamedTemporaryFile(delete=False).name
with open(assembled_file, "w") as temp_handle:
for assembled in assembled_gtfs:
temp_handle.write(... | python | def merge(assembled_gtfs, ref_file, gtf_file, num_cores, data):
"""
run cuffmerge on a set of assembled GTF files
"""
assembled_file = tempfile.NamedTemporaryFile(delete=False).name
with open(assembled_file, "w") as temp_handle:
for assembled in assembled_gtfs:
temp_handle.write(... | [
"def",
"merge",
"(",
"assembled_gtfs",
",",
"ref_file",
",",
"gtf_file",
",",
"num_cores",
",",
"data",
")",
":",
"assembled_file",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
")",
".",
"name",
"with",
"open",
"(",
"assembled_fil... | run cuffmerge on a set of assembled GTF files | [
"run",
"cuffmerge",
"on",
"a",
"set",
"of",
"assembled",
"GTF",
"files"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/cufflinks.py#L237-L265 |
223,793 | bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _vcf_info | def _vcf_info(start, end, mate_id, info=None):
"""Return breakend information line with mate and imprecise location.
"""
out = "SVTYPE=BND;MATEID={mate};IMPRECISE;CIPOS=0,{size}".format(
mate=mate_id, size=end-start)
if info is not None:
extra_info = ";".join("{0}={1}".format(k, v) for k... | python | def _vcf_info(start, end, mate_id, info=None):
"""Return breakend information line with mate and imprecise location.
"""
out = "SVTYPE=BND;MATEID={mate};IMPRECISE;CIPOS=0,{size}".format(
mate=mate_id, size=end-start)
if info is not None:
extra_info = ";".join("{0}={1}".format(k, v) for k... | [
"def",
"_vcf_info",
"(",
"start",
",",
"end",
",",
"mate_id",
",",
"info",
"=",
"None",
")",
":",
"out",
"=",
"\"SVTYPE=BND;MATEID={mate};IMPRECISE;CIPOS=0,{size}\"",
".",
"format",
"(",
"mate",
"=",
"mate_id",
",",
"size",
"=",
"end",
"-",
"start",
")",
"... | Return breakend information line with mate and imprecise location. | [
"Return",
"breakend",
"information",
"line",
"with",
"mate",
"and",
"imprecise",
"location",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L47-L55 |
223,794 | bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _vcf_alt | def _vcf_alt(base, other_chr, other_pos, isrc, is_first):
"""Create ALT allele line in VCF 4.1 format associating with other paired end.
"""
if is_first:
pipe = "[" if isrc else "]"
out_str = "{base}{pipe}{chr}:{pos}{pipe}"
else:
pipe = "]" if isrc else "["
out_str = "{pi... | python | def _vcf_alt(base, other_chr, other_pos, isrc, is_first):
"""Create ALT allele line in VCF 4.1 format associating with other paired end.
"""
if is_first:
pipe = "[" if isrc else "]"
out_str = "{base}{pipe}{chr}:{pos}{pipe}"
else:
pipe = "]" if isrc else "["
out_str = "{pi... | [
"def",
"_vcf_alt",
"(",
"base",
",",
"other_chr",
",",
"other_pos",
",",
"isrc",
",",
"is_first",
")",
":",
"if",
"is_first",
":",
"pipe",
"=",
"\"[\"",
"if",
"isrc",
"else",
"\"]\"",
"out_str",
"=",
"\"{base}{pipe}{chr}:{pos}{pipe}\"",
"else",
":",
"pipe",
... | Create ALT allele line in VCF 4.1 format associating with other paired end. | [
"Create",
"ALT",
"allele",
"line",
"in",
"VCF",
"4",
".",
"1",
"format",
"associating",
"with",
"other",
"paired",
"end",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L57-L67 |
223,795 | bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _breakend_orientation | def _breakend_orientation(strand1, strand2):
"""Convert BEDPE strand representation of breakpoints into VCF.
| strand1 | strand2 | VCF |
+----------+----------+--------------+
| + | - | t[p[ ]p]t |
| + | + | t]p] t]p] |
| - | - | [p[t [... | python | def _breakend_orientation(strand1, strand2):
"""Convert BEDPE strand representation of breakpoints into VCF.
| strand1 | strand2 | VCF |
+----------+----------+--------------+
| + | - | t[p[ ]p]t |
| + | + | t]p] t]p] |
| - | - | [p[t [... | [
"def",
"_breakend_orientation",
"(",
"strand1",
",",
"strand2",
")",
":",
"EndOrientation",
"=",
"namedtuple",
"(",
"\"EndOrientation\"",
",",
"[",
"\"is_first1\"",
",",
"\"is_rc1\"",
",",
"\"is_first2\"",
",",
"\"is_rc2\"",
"]",
")",
"if",
"strand1",
"==",
"\"+... | Convert BEDPE strand representation of breakpoints into VCF.
| strand1 | strand2 | VCF |
+----------+----------+--------------+
| + | - | t[p[ ]p]t |
| + | + | t]p] t]p] |
| - | - | [p[t [p[t |
| - | + | ]p]t t[p[ | | [
"Convert",
"BEDPE",
"strand",
"representation",
"of",
"breakpoints",
"into",
"VCF",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L69-L91 |
223,796 | bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | build_vcf_parts | def build_vcf_parts(feature, genome_2bit, info=None):
"""Convert BedPe feature information into VCF part representation.
Each feature will have two VCF lines for each side of the breakpoint.
"""
base1 = genome_2bit[feature.chrom1].get(
feature.start1, feature.start1 + 1).upper()
id1 = "hydr... | python | def build_vcf_parts(feature, genome_2bit, info=None):
"""Convert BedPe feature information into VCF part representation.
Each feature will have two VCF lines for each side of the breakpoint.
"""
base1 = genome_2bit[feature.chrom1].get(
feature.start1, feature.start1 + 1).upper()
id1 = "hydr... | [
"def",
"build_vcf_parts",
"(",
"feature",
",",
"genome_2bit",
",",
"info",
"=",
"None",
")",
":",
"base1",
"=",
"genome_2bit",
"[",
"feature",
".",
"chrom1",
"]",
".",
"get",
"(",
"feature",
".",
"start1",
",",
"feature",
".",
"start1",
"+",
"1",
")",
... | Convert BedPe feature information into VCF part representation.
Each feature will have two VCF lines for each side of the breakpoint. | [
"Convert",
"BedPe",
"feature",
"information",
"into",
"VCF",
"part",
"representation",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L95-L114 |
223,797 | bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | build_vcf_deletion | def build_vcf_deletion(x, genome_2bit):
"""Provide representation of deletion from BedPE breakpoints.
"""
base1 = genome_2bit[x.chrom1].get(x.start1, x.start1 + 1).upper()
id1 = "hydra{0}".format(x.name)
return VcfLine(x.chrom1, x.start1, id1, base1, "<DEL>",
_vcf_single_end_info(... | python | def build_vcf_deletion(x, genome_2bit):
"""Provide representation of deletion from BedPE breakpoints.
"""
base1 = genome_2bit[x.chrom1].get(x.start1, x.start1 + 1).upper()
id1 = "hydra{0}".format(x.name)
return VcfLine(x.chrom1, x.start1, id1, base1, "<DEL>",
_vcf_single_end_info(... | [
"def",
"build_vcf_deletion",
"(",
"x",
",",
"genome_2bit",
")",
":",
"base1",
"=",
"genome_2bit",
"[",
"x",
".",
"chrom1",
"]",
".",
"get",
"(",
"x",
".",
"start1",
",",
"x",
".",
"start1",
"+",
"1",
")",
".",
"upper",
"(",
")",
"id1",
"=",
"\"hy... | Provide representation of deletion from BedPE breakpoints. | [
"Provide",
"representation",
"of",
"deletion",
"from",
"BedPE",
"breakpoints",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L136-L142 |
223,798 | bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | build_vcf_inversion | def build_vcf_inversion(x1, x2, genome_2bit):
"""Provide representation of inversion from BedPE breakpoints.
"""
id1 = "hydra{0}".format(x1.name)
start_coords = sorted([x1.start1, x1.end1, x2.start1, x2.end1])
end_coords = sorted([x1.start2, x1.end2, x2.start2, x2.start2])
start_pos = (start_coo... | python | def build_vcf_inversion(x1, x2, genome_2bit):
"""Provide representation of inversion from BedPE breakpoints.
"""
id1 = "hydra{0}".format(x1.name)
start_coords = sorted([x1.start1, x1.end1, x2.start1, x2.end1])
end_coords = sorted([x1.start2, x1.end2, x2.start2, x2.start2])
start_pos = (start_coo... | [
"def",
"build_vcf_inversion",
"(",
"x1",
",",
"x2",
",",
"genome_2bit",
")",
":",
"id1",
"=",
"\"hydra{0}\"",
".",
"format",
"(",
"x1",
".",
"name",
")",
"start_coords",
"=",
"sorted",
"(",
"[",
"x1",
".",
"start1",
",",
"x1",
".",
"end1",
",",
"x2",... | Provide representation of inversion from BedPE breakpoints. | [
"Provide",
"representation",
"of",
"inversion",
"from",
"BedPE",
"breakpoints",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L166-L182 |
223,799 | bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | hydra_parser | def hydra_parser(in_file, options=None):
"""Parse hydra input file into namedtuple of values.
"""
if options is None: options = {}
BedPe = namedtuple('BedPe', ["chrom1", "start1", "end1",
"chrom2", "start2", "end2",
"name", "strand1", "st... | python | def hydra_parser(in_file, options=None):
"""Parse hydra input file into namedtuple of values.
"""
if options is None: options = {}
BedPe = namedtuple('BedPe', ["chrom1", "start1", "end1",
"chrom2", "start2", "end2",
"name", "strand1", "st... | [
"def",
"hydra_parser",
"(",
"in_file",
",",
"options",
"=",
"None",
")",
":",
"if",
"options",
"is",
"None",
":",
"options",
"=",
"{",
"}",
"BedPe",
"=",
"namedtuple",
"(",
"'BedPe'",
",",
"[",
"\"chrom1\"",
",",
"\"start1\"",
",",
"\"end1\"",
",",
"\"... | Parse hydra input file into namedtuple of values. | [
"Parse",
"hydra",
"input",
"file",
"into",
"namedtuple",
"of",
"values",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L198-L214 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.