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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
224,100 | bcbio/bcbio-nextgen | bcbio/distributed/resources.py | _scale_cores_to_memory | def _scale_cores_to_memory(cores, mem_per_core, sysinfo, system_memory):
"""Scale multicore usage to avoid excessive memory usage based on system information.
"""
total_mem = "%.2f" % (cores * mem_per_core + system_memory)
if "cores" not in sysinfo:
return cores, total_mem, 1.0
total_mem = ... | python | def _scale_cores_to_memory(cores, mem_per_core, sysinfo, system_memory):
"""Scale multicore usage to avoid excessive memory usage based on system information.
"""
total_mem = "%.2f" % (cores * mem_per_core + system_memory)
if "cores" not in sysinfo:
return cores, total_mem, 1.0
total_mem = ... | [
"def",
"_scale_cores_to_memory",
"(",
"cores",
",",
"mem_per_core",
",",
"sysinfo",
",",
"system_memory",
")",
":",
"total_mem",
"=",
"\"%.2f\"",
"%",
"(",
"cores",
"*",
"mem_per_core",
"+",
"system_memory",
")",
"if",
"\"cores\"",
"not",
"in",
"sysinfo",
":",... | Scale multicore usage to avoid excessive memory usage based on system information. | [
"Scale",
"multicore",
"usage",
"to",
"avoid",
"excessive",
"memory",
"usage",
"based",
"on",
"system",
"information",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/resources.py#L100-L117 |
224,101 | bcbio/bcbio-nextgen | bcbio/distributed/resources.py | _scale_jobs_to_memory | def _scale_jobs_to_memory(jobs, mem_per_core, sysinfo):
"""When scheduling jobs with single cores, avoid overscheduling due to memory.
"""
if "cores" not in sysinfo:
return jobs, 1.0
sys_mem_per_core = float(sysinfo["memory"]) / float(sysinfo["cores"])
if sys_mem_per_core < mem_per_core:
... | python | def _scale_jobs_to_memory(jobs, mem_per_core, sysinfo):
"""When scheduling jobs with single cores, avoid overscheduling due to memory.
"""
if "cores" not in sysinfo:
return jobs, 1.0
sys_mem_per_core = float(sysinfo["memory"]) / float(sysinfo["cores"])
if sys_mem_per_core < mem_per_core:
... | [
"def",
"_scale_jobs_to_memory",
"(",
"jobs",
",",
"mem_per_core",
",",
"sysinfo",
")",
":",
"if",
"\"cores\"",
"not",
"in",
"sysinfo",
":",
"return",
"jobs",
",",
"1.0",
"sys_mem_per_core",
"=",
"float",
"(",
"sysinfo",
"[",
"\"memory\"",
"]",
")",
"/",
"f... | When scheduling jobs with single cores, avoid overscheduling due to memory. | [
"When",
"scheduling",
"jobs",
"with",
"single",
"cores",
"avoid",
"overscheduling",
"due",
"to",
"memory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/resources.py#L119-L130 |
224,102 | bcbio/bcbio-nextgen | bcbio/distributed/resources.py | calculate | def calculate(parallel, items, sysinfo, config, multiplier=1,
max_multicore=None):
"""Determine cores and workers to use for this stage based on used programs.
multiplier specifies the number of regions items will be split into during
processing.
max_multicore specifies an optional limit o... | python | def calculate(parallel, items, sysinfo, config, multiplier=1,
max_multicore=None):
"""Determine cores and workers to use for this stage based on used programs.
multiplier specifies the number of regions items will be split into during
processing.
max_multicore specifies an optional limit o... | [
"def",
"calculate",
"(",
"parallel",
",",
"items",
",",
"sysinfo",
",",
"config",
",",
"multiplier",
"=",
"1",
",",
"max_multicore",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"items",
")",
">",
"0",
",",
"\"Finding job resources but no items to process\"",
... | Determine cores and workers to use for this stage based on used programs.
multiplier specifies the number of regions items will be split into during
processing.
max_multicore specifies an optional limit on the maximum cores. Can use to
force single core processing during specific tasks.
sysinfo spec... | [
"Determine",
"cores",
"and",
"workers",
"to",
"use",
"for",
"this",
"stage",
"based",
"on",
"used",
"programs",
".",
"multiplier",
"specifies",
"the",
"number",
"of",
"regions",
"items",
"will",
"be",
"split",
"into",
"during",
"processing",
".",
"max_multicor... | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/resources.py#L159-L234 |
224,103 | bcbio/bcbio-nextgen | bcbio/ngsalign/hisat2.py | create_splicesites_file | def create_splicesites_file(gtf_file, align_dir, data):
"""
if not pre-created, make a splicesites file to use with hisat2
"""
out_file = os.path.join(align_dir, "ref-transcripts-splicesites.txt")
if file_exists(out_file):
return out_file
safe_makedir(align_dir)
hisat2_ss = config_ut... | python | def create_splicesites_file(gtf_file, align_dir, data):
"""
if not pre-created, make a splicesites file to use with hisat2
"""
out_file = os.path.join(align_dir, "ref-transcripts-splicesites.txt")
if file_exists(out_file):
return out_file
safe_makedir(align_dir)
hisat2_ss = config_ut... | [
"def",
"create_splicesites_file",
"(",
"gtf_file",
",",
"align_dir",
",",
"data",
")",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"align_dir",
",",
"\"ref-transcripts-splicesites.txt\"",
")",
"if",
"file_exists",
"(",
"out_file",
")",
":",
"ret... | if not pre-created, make a splicesites file to use with hisat2 | [
"if",
"not",
"pre",
"-",
"created",
"make",
"a",
"splicesites",
"file",
"to",
"use",
"with",
"hisat2"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/hisat2.py#L63-L76 |
224,104 | bcbio/bcbio-nextgen | bcbio/ngsalign/hisat2.py | get_splicejunction_file | def get_splicejunction_file(align_dir, data):
"""
locate the splice junction file from hisat2. hisat2 outputs a novel
splicesites file to go along with the provided file, if available.
this combines the two together and outputs a combined file of all
of the known and novel splice junctions
"""
... | python | def get_splicejunction_file(align_dir, data):
"""
locate the splice junction file from hisat2. hisat2 outputs a novel
splicesites file to go along with the provided file, if available.
this combines the two together and outputs a combined file of all
of the known and novel splice junctions
"""
... | [
"def",
"get_splicejunction_file",
"(",
"align_dir",
",",
"data",
")",
":",
"samplename",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"align_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"dd",
".",
"get_work_bam",
"(",
"data",
")",
")",
"kno... | locate the splice junction file from hisat2. hisat2 outputs a novel
splicesites file to go along with the provided file, if available.
this combines the two together and outputs a combined file of all
of the known and novel splice junctions | [
"locate",
"the",
"splice",
"junction",
"file",
"from",
"hisat2",
".",
"hisat2",
"outputs",
"a",
"novel",
"splicesites",
"file",
"to",
"go",
"along",
"with",
"the",
"provided",
"file",
"if",
"available",
".",
"this",
"combines",
"the",
"two",
"together",
"and... | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/hisat2.py#L127-L146 |
224,105 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | write_info | def write_info(dirs, parallel, config):
"""Write cluster or local filesystem resources, spinning up cluster if not present.
"""
if parallel["type"] in ["ipython"] and not parallel.get("run_local"):
out_file = _get_cache_file(dirs, parallel)
if not utils.file_exists(out_file):
sys... | python | def write_info(dirs, parallel, config):
"""Write cluster or local filesystem resources, spinning up cluster if not present.
"""
if parallel["type"] in ["ipython"] and not parallel.get("run_local"):
out_file = _get_cache_file(dirs, parallel)
if not utils.file_exists(out_file):
sys... | [
"def",
"write_info",
"(",
"dirs",
",",
"parallel",
",",
"config",
")",
":",
"if",
"parallel",
"[",
"\"type\"",
"]",
"in",
"[",
"\"ipython\"",
"]",
"and",
"not",
"parallel",
".",
"get",
"(",
"\"run_local\"",
")",
":",
"out_file",
"=",
"_get_cache_file",
"... | Write cluster or local filesystem resources, spinning up cluster if not present. | [
"Write",
"cluster",
"or",
"local",
"filesystem",
"resources",
"spinning",
"up",
"cluster",
"if",
"not",
"present",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L25-L34 |
224,106 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | _get_machine_info | def _get_machine_info(parallel, sys_config, dirs, config):
"""Get machine resource information from the job scheduler via either the command line or the queue.
"""
if parallel.get("queue") and parallel.get("scheduler"):
# dictionary as switch statement; can add new scheduler implementation functions... | python | def _get_machine_info(parallel, sys_config, dirs, config):
"""Get machine resource information from the job scheduler via either the command line or the queue.
"""
if parallel.get("queue") and parallel.get("scheduler"):
# dictionary as switch statement; can add new scheduler implementation functions... | [
"def",
"_get_machine_info",
"(",
"parallel",
",",
"sys_config",
",",
"dirs",
",",
"config",
")",
":",
"if",
"parallel",
".",
"get",
"(",
"\"queue\"",
")",
"and",
"parallel",
".",
"get",
"(",
"\"scheduler\"",
")",
":",
"# dictionary as switch statement; can add n... | Get machine resource information from the job scheduler via either the command line or the queue. | [
"Get",
"machine",
"resource",
"information",
"from",
"the",
"job",
"scheduler",
"via",
"either",
"the",
"command",
"line",
"or",
"the",
"queue",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L36-L59 |
224,107 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | _slurm_info | def _slurm_info(queue):
"""Returns machine information for a slurm job scheduler.
"""
cl = "sinfo -h -p {} --format '%c %m %D'".format(queue)
num_cpus, mem, num_nodes = subprocess.check_output(shlex.split(cl)).decode().split()
# if the queue contains multiple memory configurations, the minimum value... | python | def _slurm_info(queue):
"""Returns machine information for a slurm job scheduler.
"""
cl = "sinfo -h -p {} --format '%c %m %D'".format(queue)
num_cpus, mem, num_nodes = subprocess.check_output(shlex.split(cl)).decode().split()
# if the queue contains multiple memory configurations, the minimum value... | [
"def",
"_slurm_info",
"(",
"queue",
")",
":",
"cl",
"=",
"\"sinfo -h -p {} --format '%c %m %D'\"",
".",
"format",
"(",
"queue",
")",
"num_cpus",
",",
"mem",
",",
"num_nodes",
"=",
"subprocess",
".",
"check_output",
"(",
"shlex",
".",
"split",
"(",
"cl",
")",... | Returns machine information for a slurm job scheduler. | [
"Returns",
"machine",
"information",
"for",
"a",
"slurm",
"job",
"scheduler",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L61-L75 |
224,108 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | _torque_info | def _torque_info(queue):
"""Return machine information for a torque job scheduler using pbsnodes.
To identify which host to use it tries to parse available hosts
from qstat -Qf `acl_hosts`. If found, it uses these and gets the
first node from pbsnodes matching to the list. If no attached
hosts are ... | python | def _torque_info(queue):
"""Return machine information for a torque job scheduler using pbsnodes.
To identify which host to use it tries to parse available hosts
from qstat -Qf `acl_hosts`. If found, it uses these and gets the
first node from pbsnodes matching to the list. If no attached
hosts are ... | [
"def",
"_torque_info",
"(",
"queue",
")",
":",
"nodes",
"=",
"_torque_queue_nodes",
"(",
"queue",
")",
"pbs_out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"pbsnodes\"",
"]",
")",
".",
"decode",
"(",
")",
"info",
"=",
"{",
"}",
"for",
"i",
",... | Return machine information for a torque job scheduler using pbsnodes.
To identify which host to use it tries to parse available hosts
from qstat -Qf `acl_hosts`. If found, it uses these and gets the
first node from pbsnodes matching to the list. If no attached
hosts are available, it uses the first hos... | [
"Return",
"machine",
"information",
"for",
"a",
"torque",
"job",
"scheduler",
"using",
"pbsnodes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L77-L99 |
224,109 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | _torque_queue_nodes | def _torque_queue_nodes(queue):
"""Retrieve the nodes available for a queue.
Parses out nodes from `acl_hosts` in qstat -Qf and extracts the
initial names of nodes used in pbsnodes.
"""
qstat_out = subprocess.check_output(["qstat", "-Qf", queue]).decode()
hosts = []
in_hosts = False
for... | python | def _torque_queue_nodes(queue):
"""Retrieve the nodes available for a queue.
Parses out nodes from `acl_hosts` in qstat -Qf and extracts the
initial names of nodes used in pbsnodes.
"""
qstat_out = subprocess.check_output(["qstat", "-Qf", queue]).decode()
hosts = []
in_hosts = False
for... | [
"def",
"_torque_queue_nodes",
"(",
"queue",
")",
":",
"qstat_out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"qstat\"",
",",
"\"-Qf\"",
",",
"queue",
"]",
")",
".",
"decode",
"(",
")",
"hosts",
"=",
"[",
"]",
"in_hosts",
"=",
"False",
"for",
... | Retrieve the nodes available for a queue.
Parses out nodes from `acl_hosts` in qstat -Qf and extracts the
initial names of nodes used in pbsnodes. | [
"Retrieve",
"the",
"nodes",
"available",
"for",
"a",
"queue",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L101-L119 |
224,110 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | _sge_info | def _sge_info(queue):
"""Returns machine information for an sge job scheduler.
"""
qhost_out = subprocess.check_output(["qhost", "-q", "-xml"]).decode()
qstat_queue = ["-q", queue] if queue and "," not in queue else []
qstat_out = subprocess.check_output(["qstat", "-f", "-xml"] + qstat_queue).decode... | python | def _sge_info(queue):
"""Returns machine information for an sge job scheduler.
"""
qhost_out = subprocess.check_output(["qhost", "-q", "-xml"]).decode()
qstat_queue = ["-q", queue] if queue and "," not in queue else []
qstat_out = subprocess.check_output(["qstat", "-f", "-xml"] + qstat_queue).decode... | [
"def",
"_sge_info",
"(",
"queue",
")",
":",
"qhost_out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"qhost\"",
",",
"\"-q\"",
",",
"\"-xml\"",
"]",
")",
".",
"decode",
"(",
")",
"qstat_queue",
"=",
"[",
"\"-q\"",
",",
"queue",
"]",
"if",
"queu... | Returns machine information for an sge job scheduler. | [
"Returns",
"machine",
"information",
"for",
"an",
"sge",
"job",
"scheduler",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L128-L144 |
224,111 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | _sge_get_slots | def _sge_get_slots(xmlstring):
""" Get slot information from qstat
"""
rootxml = ET.fromstring(xmlstring)
my_machine_dict = {}
for queue_list in rootxml.iter("Queue-List"):
# find all hosts supporting queues
my_hostname = queue_list.find("name").text.rsplit("@")[-1]
my_slots ... | python | def _sge_get_slots(xmlstring):
""" Get slot information from qstat
"""
rootxml = ET.fromstring(xmlstring)
my_machine_dict = {}
for queue_list in rootxml.iter("Queue-List"):
# find all hosts supporting queues
my_hostname = queue_list.find("name").text.rsplit("@")[-1]
my_slots ... | [
"def",
"_sge_get_slots",
"(",
"xmlstring",
")",
":",
"rootxml",
"=",
"ET",
".",
"fromstring",
"(",
"xmlstring",
")",
"my_machine_dict",
"=",
"{",
"}",
"for",
"queue_list",
"in",
"rootxml",
".",
"iter",
"(",
"\"Queue-List\"",
")",
":",
"# find all hosts support... | Get slot information from qstat | [
"Get",
"slot",
"information",
"from",
"qstat"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L146-L157 |
224,112 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | _sge_get_mem | def _sge_get_mem(xmlstring, queue_name):
""" Get memory information from qhost
"""
rootxml = ET.fromstring(xmlstring)
my_machine_dict = {}
# on some machines rootxml.tag looks like "{...}qhost" where the "{...}" gets prepended to all attributes
rootTag = rootxml.tag.rstrip("qhost")
for host ... | python | def _sge_get_mem(xmlstring, queue_name):
""" Get memory information from qhost
"""
rootxml = ET.fromstring(xmlstring)
my_machine_dict = {}
# on some machines rootxml.tag looks like "{...}qhost" where the "{...}" gets prepended to all attributes
rootTag = rootxml.tag.rstrip("qhost")
for host ... | [
"def",
"_sge_get_mem",
"(",
"xmlstring",
",",
"queue_name",
")",
":",
"rootxml",
"=",
"ET",
".",
"fromstring",
"(",
"xmlstring",
")",
"my_machine_dict",
"=",
"{",
"}",
"# on some machines rootxml.tag looks like \"{...}qhost\" where the \"{...}\" gets prepended to all attribut... | Get memory information from qhost | [
"Get",
"memory",
"information",
"from",
"qhost"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L159-L186 |
224,113 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | get_info | def get_info(dirs, parallel, resources=None):
"""Retrieve cluster or local filesystem resources from pre-retrieved information.
"""
# Allow custom specification of cores/memory in resources
if resources and isinstance(resources, dict) and "machine" in resources:
minfo = resources["machine"]
... | python | def get_info(dirs, parallel, resources=None):
"""Retrieve cluster or local filesystem resources from pre-retrieved information.
"""
# Allow custom specification of cores/memory in resources
if resources and isinstance(resources, dict) and "machine" in resources:
minfo = resources["machine"]
... | [
"def",
"get_info",
"(",
"dirs",
",",
"parallel",
",",
"resources",
"=",
"None",
")",
":",
"# Allow custom specification of cores/memory in resources",
"if",
"resources",
"and",
"isinstance",
"(",
"resources",
",",
"dict",
")",
"and",
"\"machine\"",
"in",
"resources"... | Retrieve cluster or local filesystem resources from pre-retrieved information. | [
"Retrieve",
"cluster",
"or",
"local",
"filesystem",
"resources",
"from",
"pre",
"-",
"retrieved",
"information",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L194-L212 |
224,114 | bcbio/bcbio-nextgen | bcbio/provenance/system.py | machine_info | def machine_info():
"""Retrieve core and memory information for the current machine.
"""
import psutil
BYTES_IN_GIG = 1073741824.0
free_bytes = psutil.virtual_memory().total
return [{"memory": float("%.1f" % (free_bytes / BYTES_IN_GIG)), "cores": multiprocessing.cpu_count(),
"name":... | python | def machine_info():
"""Retrieve core and memory information for the current machine.
"""
import psutil
BYTES_IN_GIG = 1073741824.0
free_bytes = psutil.virtual_memory().total
return [{"memory": float("%.1f" % (free_bytes / BYTES_IN_GIG)), "cores": multiprocessing.cpu_count(),
"name":... | [
"def",
"machine_info",
"(",
")",
":",
"import",
"psutil",
"BYTES_IN_GIG",
"=",
"1073741824.0",
"free_bytes",
"=",
"psutil",
".",
"virtual_memory",
"(",
")",
".",
"total",
"return",
"[",
"{",
"\"memory\"",
":",
"float",
"(",
"\"%.1f\"",
"%",
"(",
"free_bytes"... | Retrieve core and memory information for the current machine. | [
"Retrieve",
"core",
"and",
"memory",
"information",
"for",
"the",
"current",
"machine",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/system.py#L214-L221 |
224,115 | bcbio/bcbio-nextgen | bcbio/rnaseq/dexseq.py | run_count | def run_count(bam_file, dexseq_gff, stranded, out_file, data):
"""
run dexseq_count on a BAM file
"""
assert file_exists(bam_file), "%s does not exist." % bam_file
sort_order = bam._get_sort_order(bam_file, {})
assert sort_order, "Cannot determine sort order of %s." % bam_file
strand_flag = ... | python | def run_count(bam_file, dexseq_gff, stranded, out_file, data):
"""
run dexseq_count on a BAM file
"""
assert file_exists(bam_file), "%s does not exist." % bam_file
sort_order = bam._get_sort_order(bam_file, {})
assert sort_order, "Cannot determine sort order of %s." % bam_file
strand_flag = ... | [
"def",
"run_count",
"(",
"bam_file",
",",
"dexseq_gff",
",",
"stranded",
",",
"out_file",
",",
"data",
")",
":",
"assert",
"file_exists",
"(",
"bam_file",
")",
",",
"\"%s does not exist.\"",
"%",
"bam_file",
"sort_order",
"=",
"bam",
".",
"_get_sort_order",
"(... | run dexseq_count on a BAM file | [
"run",
"dexseq_count",
"on",
"a",
"BAM",
"file"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/dexseq.py#L27-L65 |
224,116 | bcbio/bcbio-nextgen | bcbio/bam/trim.py | _trim_adapters | def _trim_adapters(fastq_files, out_dir, data):
"""
for small insert sizes, the read length can be longer than the insert
resulting in the reverse complement of the 3' adapter being sequenced.
this takes adapter sequences and trims the only the reverse complement
of the adapter
MYSEQUENCEAAAARE... | python | def _trim_adapters(fastq_files, out_dir, data):
"""
for small insert sizes, the read length can be longer than the insert
resulting in the reverse complement of the 3' adapter being sequenced.
this takes adapter sequences and trims the only the reverse complement
of the adapter
MYSEQUENCEAAAARE... | [
"def",
"_trim_adapters",
"(",
"fastq_files",
",",
"out_dir",
",",
"data",
")",
":",
"to_trim",
"=",
"_get_sequences_to_trim",
"(",
"data",
"[",
"\"config\"",
"]",
",",
"SUPPORTED_ADAPTERS",
")",
"if",
"dd",
".",
"get_trim_reads",
"(",
"data",
")",
"==",
"\"f... | for small insert sizes, the read length can be longer than the insert
resulting in the reverse complement of the 3' adapter being sequenced.
this takes adapter sequences and trims the only the reverse complement
of the adapter
MYSEQUENCEAAAARETPADA -> MYSEQUENCEAAAA (no polyA trim) | [
"for",
"small",
"insert",
"sizes",
"the",
"read",
"length",
"can",
"be",
"longer",
"than",
"the",
"insert",
"resulting",
"in",
"the",
"reverse",
"complement",
"of",
"the",
"3",
"adapter",
"being",
"sequenced",
".",
"this",
"takes",
"adapter",
"sequences",
"a... | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/trim.py#L36-L59 |
224,117 | bcbio/bcbio-nextgen | bcbio/bam/trim.py | _cutadapt_trim | def _cutadapt_trim(fastq_files, quality_format, adapters, out_files, log_file, data):
"""Trimming with cutadapt.
"""
if all([utils.file_exists(x) for x in out_files]):
return out_files
cmd = _cutadapt_trim_cmd(fastq_files, quality_format, adapters, out_files, data)
if len(fastq_files) == 1:
... | python | def _cutadapt_trim(fastq_files, quality_format, adapters, out_files, log_file, data):
"""Trimming with cutadapt.
"""
if all([utils.file_exists(x) for x in out_files]):
return out_files
cmd = _cutadapt_trim_cmd(fastq_files, quality_format, adapters, out_files, data)
if len(fastq_files) == 1:
... | [
"def",
"_cutadapt_trim",
"(",
"fastq_files",
",",
"quality_format",
",",
"adapters",
",",
"out_files",
",",
"log_file",
",",
"data",
")",
":",
"if",
"all",
"(",
"[",
"utils",
".",
"file_exists",
"(",
"x",
")",
"for",
"x",
"in",
"out_files",
"]",
")",
"... | Trimming with cutadapt. | [
"Trimming",
"with",
"cutadapt",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/trim.py#L192-L214 |
224,118 | bcbio/bcbio-nextgen | bcbio/bam/trim.py | _cutadapt_trim_cmd | def _cutadapt_trim_cmd(fastq_files, quality_format, adapters, out_files, data):
"""Trimming with cutadapt, using version installed with bcbio-nextgen.
"""
if all([utils.file_exists(x) for x in out_files]):
return out_files
if quality_format == "illumina":
quality_base = "64"
else:
... | python | def _cutadapt_trim_cmd(fastq_files, quality_format, adapters, out_files, data):
"""Trimming with cutadapt, using version installed with bcbio-nextgen.
"""
if all([utils.file_exists(x) for x in out_files]):
return out_files
if quality_format == "illumina":
quality_base = "64"
else:
... | [
"def",
"_cutadapt_trim_cmd",
"(",
"fastq_files",
",",
"quality_format",
",",
"adapters",
",",
"out_files",
",",
"data",
")",
":",
"if",
"all",
"(",
"[",
"utils",
".",
"file_exists",
"(",
"x",
")",
"for",
"x",
"in",
"out_files",
"]",
")",
":",
"return",
... | Trimming with cutadapt, using version installed with bcbio-nextgen. | [
"Trimming",
"with",
"cutadapt",
"using",
"version",
"installed",
"with",
"bcbio",
"-",
"nextgen",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/trim.py#L216-L244 |
224,119 | bcbio/bcbio-nextgen | bcbio/bam/trim.py | _cutadapt_se_cmd | def _cutadapt_se_cmd(fastq_files, out_files, base_cmd, data):
"""
this has to use the -o option, not redirect to stdout in order for
gzipping to be supported
"""
min_length = dd.get_min_read_length(data)
cmd = base_cmd + " --minimum-length={min_length} ".format(**locals())
fq1 = objectstore.... | python | def _cutadapt_se_cmd(fastq_files, out_files, base_cmd, data):
"""
this has to use the -o option, not redirect to stdout in order for
gzipping to be supported
"""
min_length = dd.get_min_read_length(data)
cmd = base_cmd + " --minimum-length={min_length} ".format(**locals())
fq1 = objectstore.... | [
"def",
"_cutadapt_se_cmd",
"(",
"fastq_files",
",",
"out_files",
",",
"base_cmd",
",",
"data",
")",
":",
"min_length",
"=",
"dd",
".",
"get_min_read_length",
"(",
"data",
")",
"cmd",
"=",
"base_cmd",
"+",
"\" --minimum-length={min_length} \"",
".",
"format",
"("... | this has to use the -o option, not redirect to stdout in order for
gzipping to be supported | [
"this",
"has",
"to",
"use",
"the",
"-",
"o",
"option",
"not",
"redirect",
"to",
"stdout",
"in",
"order",
"for",
"gzipping",
"to",
"be",
"supported"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/trim.py#L246-L257 |
224,120 | bcbio/bcbio-nextgen | bcbio/bam/trim.py | _cutadapt_pe_cmd | def _cutadapt_pe_cmd(fastq_files, out_files, quality_format, base_cmd, data):
"""
run cutadapt in paired end mode
"""
fq1, fq2 = [objectstore.cl_input(x) for x in fastq_files]
of1, of2 = out_files
base_cmd += " --minimum-length={min_length} ".format(min_length=dd.get_min_read_length(data))
f... | python | def _cutadapt_pe_cmd(fastq_files, out_files, quality_format, base_cmd, data):
"""
run cutadapt in paired end mode
"""
fq1, fq2 = [objectstore.cl_input(x) for x in fastq_files]
of1, of2 = out_files
base_cmd += " --minimum-length={min_length} ".format(min_length=dd.get_min_read_length(data))
f... | [
"def",
"_cutadapt_pe_cmd",
"(",
"fastq_files",
",",
"out_files",
",",
"quality_format",
",",
"base_cmd",
",",
"data",
")",
":",
"fq1",
",",
"fq2",
"=",
"[",
"objectstore",
".",
"cl_input",
"(",
"x",
")",
"for",
"x",
"in",
"fastq_files",
"]",
"of1",
",",
... | run cutadapt in paired end mode | [
"run",
"cutadapt",
"in",
"paired",
"end",
"mode"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/trim.py#L259-L267 |
224,121 | bcbio/bcbio-nextgen | bcbio/variation/realign.py | gatk_realigner_targets | def gatk_realigner_targets(runner, align_bam, ref_file, config, dbsnp=None,
region=None, out_file=None, deep_coverage=False,
variant_regions=None, known_vrns=None):
"""Generate a list of interval regions for realignment around indels.
"""
if not known_vr... | python | def gatk_realigner_targets(runner, align_bam, ref_file, config, dbsnp=None,
region=None, out_file=None, deep_coverage=False,
variant_regions=None, known_vrns=None):
"""Generate a list of interval regions for realignment around indels.
"""
if not known_vr... | [
"def",
"gatk_realigner_targets",
"(",
"runner",
",",
"align_bam",
",",
"ref_file",
",",
"config",
",",
"dbsnp",
"=",
"None",
",",
"region",
"=",
"None",
",",
"out_file",
"=",
"None",
",",
"deep_coverage",
"=",
"False",
",",
"variant_regions",
"=",
"None",
... | Generate a list of interval regions for realignment around indels. | [
"Generate",
"a",
"list",
"of",
"interval",
"regions",
"for",
"realignment",
"around",
"indels",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/realign.py#L15-L47 |
224,122 | bcbio/bcbio-nextgen | bcbio/variation/realign.py | gatk_indel_realignment_cl | def gatk_indel_realignment_cl(runner, align_bam, ref_file, intervals,
tmp_dir, region=None, deep_coverage=False,
known_vrns=None):
"""Prepare input arguments for GATK indel realignment.
"""
if not known_vrns:
known_vrns = {}
params = ["... | python | def gatk_indel_realignment_cl(runner, align_bam, ref_file, intervals,
tmp_dir, region=None, deep_coverage=False,
known_vrns=None):
"""Prepare input arguments for GATK indel realignment.
"""
if not known_vrns:
known_vrns = {}
params = ["... | [
"def",
"gatk_indel_realignment_cl",
"(",
"runner",
",",
"align_bam",
",",
"ref_file",
",",
"intervals",
",",
"tmp_dir",
",",
"region",
"=",
"None",
",",
"deep_coverage",
"=",
"False",
",",
"known_vrns",
"=",
"None",
")",
":",
"if",
"not",
"known_vrns",
":",
... | Prepare input arguments for GATK indel realignment. | [
"Prepare",
"input",
"arguments",
"for",
"GATK",
"indel",
"realignment",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/realign.py#L49-L70 |
224,123 | bcbio/bcbio-nextgen | bcbio/variation/realign.py | has_aligned_reads | def has_aligned_reads(align_bam, region=None):
"""Check if the aligned BAM file has any reads in the region.
region can be a chromosome string ("chr22"),
a tuple region (("chr22", 1, 100)) or a file of regions.
"""
import pybedtools
if region is not None:
if isinstance(region, six.strin... | python | def has_aligned_reads(align_bam, region=None):
"""Check if the aligned BAM file has any reads in the region.
region can be a chromosome string ("chr22"),
a tuple region (("chr22", 1, 100)) or a file of regions.
"""
import pybedtools
if region is not None:
if isinstance(region, six.strin... | [
"def",
"has_aligned_reads",
"(",
"align_bam",
",",
"region",
"=",
"None",
")",
":",
"import",
"pybedtools",
"if",
"region",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"region",
",",
"six",
".",
"string_types",
")",
"and",
"os",
".",
"path",
".",
... | Check if the aligned BAM file has any reads in the region.
region can be a chromosome string ("chr22"),
a tuple region (("chr22", 1, 100)) or a file of regions. | [
"Check",
"if",
"the",
"aligned",
"BAM",
"file",
"has",
"any",
"reads",
"in",
"the",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/realign.py#L74-L99 |
224,124 | bcbio/bcbio-nextgen | bcbio/cwl/defs.py | s | def s(name, parallel, inputs, outputs, image, programs=None, disk=None, cores=None, unlist=None,
no_files=False):
"""Represent a step in a workflow.
name -- The run function name, which must match a definition in distributed/multitasks
inputs -- List of input keys required for the function. Each key ... | python | def s(name, parallel, inputs, outputs, image, programs=None, disk=None, cores=None, unlist=None,
no_files=False):
"""Represent a step in a workflow.
name -- The run function name, which must match a definition in distributed/multitasks
inputs -- List of input keys required for the function. Each key ... | [
"def",
"s",
"(",
"name",
",",
"parallel",
",",
"inputs",
",",
"outputs",
",",
"image",
",",
"programs",
"=",
"None",
",",
"disk",
"=",
"None",
",",
"cores",
"=",
"None",
",",
"unlist",
"=",
"None",
",",
"no_files",
"=",
"False",
")",
":",
"Step",
... | Represent a step in a workflow.
name -- The run function name, which must match a definition in distributed/multitasks
inputs -- List of input keys required for the function. Each key is of the type:
["toplevel", "sublevel"] -- an argument you could pass to toolz.get_in.
outputs -- List of outputs wi... | [
"Represent",
"a",
"step",
"in",
"a",
"workflow",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/defs.py#L17-L54 |
224,125 | bcbio/bcbio-nextgen | bcbio/cwl/defs.py | w | def w(name, parallel, workflow, internal):
"""A workflow, allowing specification of sub-workflows for nested parallelization.
name and parallel are documented under the Step (s) function.
workflow -- a list of Step tuples defining the sub-workflow
internal -- variables used in the sub-workflow but not ... | python | def w(name, parallel, workflow, internal):
"""A workflow, allowing specification of sub-workflows for nested parallelization.
name and parallel are documented under the Step (s) function.
workflow -- a list of Step tuples defining the sub-workflow
internal -- variables used in the sub-workflow but not ... | [
"def",
"w",
"(",
"name",
",",
"parallel",
",",
"workflow",
",",
"internal",
")",
":",
"Workflow",
"=",
"collections",
".",
"namedtuple",
"(",
"\"Workflow\"",
",",
"\"name parallel workflow internal\"",
")",
"return",
"Workflow",
"(",
"name",
",",
"parallel",
"... | A workflow, allowing specification of sub-workflows for nested parallelization.
name and parallel are documented under the Step (s) function.
workflow -- a list of Step tuples defining the sub-workflow
internal -- variables used in the sub-workflow but not exposed to subsequent steps | [
"A",
"workflow",
"allowing",
"specification",
"of",
"sub",
"-",
"workflows",
"for",
"nested",
"parallelization",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/defs.py#L56-L64 |
224,126 | bcbio/bcbio-nextgen | bcbio/cwl/defs.py | et | def et(name, parallel, inputs, outputs, expression):
"""Represent an ExpressionTool that reorders inputs using javascript.
"""
ExpressionTool = collections.namedtuple("ExpressionTool", "name inputs outputs expression parallel")
return ExpressionTool(name, inputs, outputs, expression, parallel) | python | def et(name, parallel, inputs, outputs, expression):
"""Represent an ExpressionTool that reorders inputs using javascript.
"""
ExpressionTool = collections.namedtuple("ExpressionTool", "name inputs outputs expression parallel")
return ExpressionTool(name, inputs, outputs, expression, parallel) | [
"def",
"et",
"(",
"name",
",",
"parallel",
",",
"inputs",
",",
"outputs",
",",
"expression",
")",
":",
"ExpressionTool",
"=",
"collections",
".",
"namedtuple",
"(",
"\"ExpressionTool\"",
",",
"\"name inputs outputs expression parallel\"",
")",
"return",
"ExpressionT... | Represent an ExpressionTool that reorders inputs using javascript. | [
"Represent",
"an",
"ExpressionTool",
"that",
"reorders",
"inputs",
"using",
"javascript",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/defs.py#L66-L70 |
224,127 | bcbio/bcbio-nextgen | bcbio/cwl/defs.py | cwlout | def cwlout(key, valtype=None, extensions=None, fields=None, exclude=None):
"""Definition of an output variable, defining the type and associated secondary files.
"""
out = {"id": key}
if valtype:
out["type"] = valtype
if fields:
out["fields"] = fields
if extensions:
out["... | python | def cwlout(key, valtype=None, extensions=None, fields=None, exclude=None):
"""Definition of an output variable, defining the type and associated secondary files.
"""
out = {"id": key}
if valtype:
out["type"] = valtype
if fields:
out["fields"] = fields
if extensions:
out["... | [
"def",
"cwlout",
"(",
"key",
",",
"valtype",
"=",
"None",
",",
"extensions",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
"None",
")",
":",
"out",
"=",
"{",
"\"id\"",
":",
"key",
"}",
"if",
"valtype",
":",
"out",
"[",
"\"type\"",
... | Definition of an output variable, defining the type and associated secondary files. | [
"Definition",
"of",
"an",
"output",
"variable",
"defining",
"the",
"type",
"and",
"associated",
"secondary",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/defs.py#L72-L84 |
224,128 | bcbio/bcbio-nextgen | bcbio/cwl/defs.py | _variant_hla | def _variant_hla(checkpoints):
"""Add hla analysis to workflow, if configured.
"""
if not checkpoints.get("hla"):
return [], []
hla = [s("hla_to_rec", "multi-batch",
[["hla", "fastq"],
["config", "algorithm", "hlacaller"]],
[cwlout("hla_rec", "record")],... | python | def _variant_hla(checkpoints):
"""Add hla analysis to workflow, if configured.
"""
if not checkpoints.get("hla"):
return [], []
hla = [s("hla_to_rec", "multi-batch",
[["hla", "fastq"],
["config", "algorithm", "hlacaller"]],
[cwlout("hla_rec", "record")],... | [
"def",
"_variant_hla",
"(",
"checkpoints",
")",
":",
"if",
"not",
"checkpoints",
".",
"get",
"(",
"\"hla\"",
")",
":",
"return",
"[",
"]",
",",
"[",
"]",
"hla",
"=",
"[",
"s",
"(",
"\"hla_to_rec\"",
",",
"\"multi-batch\"",
",",
"[",
"[",
"\"hla\"",
"... | Add hla analysis to workflow, if configured. | [
"Add",
"hla",
"analysis",
"to",
"workflow",
"if",
"configured",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/defs.py#L128-L143 |
224,129 | bcbio/bcbio-nextgen | bcbio/cwl/defs.py | variant | def variant(samples):
"""Variant calling workflow definition for CWL generation.
"""
checkpoints = _variant_checkpoints(samples)
if checkpoints["align"]:
align_wf = _alignment(checkpoints)
alignin = [["files"], ["analysis"],
["config", "algorithm", "align_split_size"],... | python | def variant(samples):
"""Variant calling workflow definition for CWL generation.
"""
checkpoints = _variant_checkpoints(samples)
if checkpoints["align"]:
align_wf = _alignment(checkpoints)
alignin = [["files"], ["analysis"],
["config", "algorithm", "align_split_size"],... | [
"def",
"variant",
"(",
"samples",
")",
":",
"checkpoints",
"=",
"_variant_checkpoints",
"(",
"samples",
")",
"if",
"checkpoints",
"[",
"\"align\"",
"]",
":",
"align_wf",
"=",
"_alignment",
"(",
"checkpoints",
")",
"alignin",
"=",
"[",
"[",
"\"files\"",
"]",
... | Variant calling workflow definition for CWL generation. | [
"Variant",
"calling",
"workflow",
"definition",
"for",
"CWL",
"generation",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/defs.py#L414-L461 |
224,130 | bcbio/bcbio-nextgen | bcbio/structural/plot.py | breakpoints_by_caller | def breakpoints_by_caller(bed_files):
"""
given a list of BED files of the form
chrom start end caller
return a BedTool of breakpoints as each line with
the fourth column the caller with evidence for the breakpoint
chr1 1 10 caller1 -> chr1 1 1 caller1
chr1 1 20 caller2 chr1 1 1 caller2
... | python | def breakpoints_by_caller(bed_files):
"""
given a list of BED files of the form
chrom start end caller
return a BedTool of breakpoints as each line with
the fourth column the caller with evidence for the breakpoint
chr1 1 10 caller1 -> chr1 1 1 caller1
chr1 1 20 caller2 chr1 1 1 caller2
... | [
"def",
"breakpoints_by_caller",
"(",
"bed_files",
")",
":",
"merged",
"=",
"concat",
"(",
"bed_files",
")",
"if",
"not",
"merged",
":",
"return",
"[",
"]",
"grouped_start",
"=",
"merged",
".",
"groupby",
"(",
"g",
"=",
"[",
"1",
",",
"2",
",",
"2",
"... | given a list of BED files of the form
chrom start end caller
return a BedTool of breakpoints as each line with
the fourth column the caller with evidence for the breakpoint
chr1 1 10 caller1 -> chr1 1 1 caller1
chr1 1 20 caller2 chr1 1 1 caller2
chr1 10 10 caller1
... | [
"given",
"a",
"list",
"of",
"BED",
"files",
"of",
"the",
"form",
"chrom",
"start",
"end",
"caller",
"return",
"a",
"BedTool",
"of",
"breakpoints",
"as",
"each",
"line",
"with",
"the",
"fourth",
"column",
"the",
"caller",
"with",
"evidence",
"for",
"the",
... | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/plot.py#L17-L37 |
224,131 | bcbio/bcbio-nextgen | bcbio/structural/plot.py | _get_sv_callers | def _get_sv_callers(items):
"""
return a sorted list of all of the structural variant callers run
"""
callers = []
for data in items:
for sv in data.get("sv", []):
callers.append(sv["variantcaller"])
return list(set([x for x in callers if x != "sv-ensemble"])).sort() | python | def _get_sv_callers(items):
"""
return a sorted list of all of the structural variant callers run
"""
callers = []
for data in items:
for sv in data.get("sv", []):
callers.append(sv["variantcaller"])
return list(set([x for x in callers if x != "sv-ensemble"])).sort() | [
"def",
"_get_sv_callers",
"(",
"items",
")",
":",
"callers",
"=",
"[",
"]",
"for",
"data",
"in",
"items",
":",
"for",
"sv",
"in",
"data",
".",
"get",
"(",
"\"sv\"",
",",
"[",
"]",
")",
":",
"callers",
".",
"append",
"(",
"sv",
"[",
"\"variantcaller... | return a sorted list of all of the structural variant callers run | [
"return",
"a",
"sorted",
"list",
"of",
"all",
"of",
"the",
"structural",
"variant",
"callers",
"run"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/plot.py#L39-L47 |
224,132 | bcbio/bcbio-nextgen | bcbio/structural/plot.py | _prioritize_plot_regions | def _prioritize_plot_regions(region_bt, data, out_dir=None):
"""Avoid plotting large numbers of regions due to speed issues. Prioritize most interesting.
XXX For now, just removes larger regions and avoid plotting thousands of regions.
Longer term we'll insert biology-based prioritization.
"""
max_... | python | def _prioritize_plot_regions(region_bt, data, out_dir=None):
"""Avoid plotting large numbers of regions due to speed issues. Prioritize most interesting.
XXX For now, just removes larger regions and avoid plotting thousands of regions.
Longer term we'll insert biology-based prioritization.
"""
max_... | [
"def",
"_prioritize_plot_regions",
"(",
"region_bt",
",",
"data",
",",
"out_dir",
"=",
"None",
")",
":",
"max_plots",
"=",
"1000",
"max_size",
"=",
"100",
"*",
"1000",
"# 100kb",
"out_file",
"=",
"\"%s-priority%s\"",
"%",
"utils",
".",
"splitext_plus",
"(",
... | Avoid plotting large numbers of regions due to speed issues. Prioritize most interesting.
XXX For now, just removes larger regions and avoid plotting thousands of regions.
Longer term we'll insert biology-based prioritization. | [
"Avoid",
"plotting",
"large",
"numbers",
"of",
"regions",
"due",
"to",
"speed",
"issues",
".",
"Prioritize",
"most",
"interesting",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/plot.py#L76-L96 |
224,133 | bcbio/bcbio-nextgen | bcbio/structural/plot.py | by_regions | def by_regions(items):
"""Plot for a union set of combined ensemble regions across all of the data
items.
"""
work_dir = os.path.join(dd.get_work_dir(items[0]), "structural", "coverage")
safe_makedir(work_dir)
out_file = os.path.join(work_dir, "%s-coverage.pdf" % (dd.get_sample_name(items[0])... | python | def by_regions(items):
"""Plot for a union set of combined ensemble regions across all of the data
items.
"""
work_dir = os.path.join(dd.get_work_dir(items[0]), "structural", "coverage")
safe_makedir(work_dir)
out_file = os.path.join(work_dir, "%s-coverage.pdf" % (dd.get_sample_name(items[0])... | [
"def",
"by_regions",
"(",
"items",
")",
":",
"work_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dd",
".",
"get_work_dir",
"(",
"items",
"[",
"0",
"]",
")",
",",
"\"structural\"",
",",
"\"coverage\"",
")",
"safe_makedir",
"(",
"work_dir",
")",
"out_... | Plot for a union set of combined ensemble regions across all of the data
items. | [
"Plot",
"for",
"a",
"union",
"set",
"of",
"combined",
"ensemble",
"regions",
"across",
"all",
"of",
"the",
"data",
"items",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/plot.py#L98-L116 |
224,134 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | finalize_sv | def finalize_sv(orig_vcf, data, items):
"""Finalize structural variants, adding effects and splitting if needed.
"""
paired = vcfutils.get_paired(items)
# For paired/somatic, attach combined calls to tumor sample
if paired:
sample_vcf = orig_vcf if paired.tumor_name == dd.get_sample_name(dat... | python | def finalize_sv(orig_vcf, data, items):
"""Finalize structural variants, adding effects and splitting if needed.
"""
paired = vcfutils.get_paired(items)
# For paired/somatic, attach combined calls to tumor sample
if paired:
sample_vcf = orig_vcf if paired.tumor_name == dd.get_sample_name(dat... | [
"def",
"finalize_sv",
"(",
"orig_vcf",
",",
"data",
",",
"items",
")",
":",
"paired",
"=",
"vcfutils",
".",
"get_paired",
"(",
"items",
")",
"# For paired/somatic, attach combined calls to tumor sample",
"if",
"paired",
":",
"sample_vcf",
"=",
"orig_vcf",
"if",
"p... | Finalize structural variants, adding effects and splitting if needed. | [
"Finalize",
"structural",
"variants",
"adding",
"effects",
"and",
"splitting",
"if",
"needed",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L25-L39 |
224,135 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | _get_sv_exclude_file | def _get_sv_exclude_file(items):
"""Retrieve SV file of regions to exclude.
"""
sv_bed = utils.get_in(items[0], ("genome_resources", "variation", "sv_repeat"))
if sv_bed and os.path.exists(sv_bed):
return sv_bed | python | def _get_sv_exclude_file(items):
"""Retrieve SV file of regions to exclude.
"""
sv_bed = utils.get_in(items[0], ("genome_resources", "variation", "sv_repeat"))
if sv_bed and os.path.exists(sv_bed):
return sv_bed | [
"def",
"_get_sv_exclude_file",
"(",
"items",
")",
":",
"sv_bed",
"=",
"utils",
".",
"get_in",
"(",
"items",
"[",
"0",
"]",
",",
"(",
"\"genome_resources\"",
",",
"\"variation\"",
",",
"\"sv_repeat\"",
")",
")",
"if",
"sv_bed",
"and",
"os",
".",
"path",
"... | Retrieve SV file of regions to exclude. | [
"Retrieve",
"SV",
"file",
"of",
"regions",
"to",
"exclude",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L86-L91 |
224,136 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | _get_variant_regions | def _get_variant_regions(items):
"""Retrieve variant regions defined in any of the input items.
"""
return list(filter(lambda x: x is not None,
[tz.get_in(("config", "algorithm", "variant_regions"), data)
for data in items
if tz.get_in([... | python | def _get_variant_regions(items):
"""Retrieve variant regions defined in any of the input items.
"""
return list(filter(lambda x: x is not None,
[tz.get_in(("config", "algorithm", "variant_regions"), data)
for data in items
if tz.get_in([... | [
"def",
"_get_variant_regions",
"(",
"items",
")",
":",
"return",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
"is",
"not",
"None",
",",
"[",
"tz",
".",
"get_in",
"(",
"(",
"\"config\"",
",",
"\"algorithm\"",
",",
"\"variant_regions\"",
")",
",",
... | Retrieve variant regions defined in any of the input items. | [
"Retrieve",
"variant",
"regions",
"defined",
"in",
"any",
"of",
"the",
"input",
"items",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L93-L99 |
224,137 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | prepare_exclude_file | def prepare_exclude_file(items, base_file, chrom=None):
"""Prepare a BED file for exclusion.
Excludes high depth and centromere regions which contribute to long run times and
false positive structural variant calls.
"""
items = shared.add_highdepth_genome_exclusion(items)
out_file = "%s-exclude... | python | def prepare_exclude_file(items, base_file, chrom=None):
"""Prepare a BED file for exclusion.
Excludes high depth and centromere regions which contribute to long run times and
false positive structural variant calls.
"""
items = shared.add_highdepth_genome_exclusion(items)
out_file = "%s-exclude... | [
"def",
"prepare_exclude_file",
"(",
"items",
",",
"base_file",
",",
"chrom",
"=",
"None",
")",
":",
"items",
"=",
"shared",
".",
"add_highdepth_genome_exclusion",
"(",
"items",
")",
"out_file",
"=",
"\"%s-exclude%s.bed\"",
"%",
"(",
"utils",
".",
"splitext_plus"... | Prepare a BED file for exclusion.
Excludes high depth and centromere regions which contribute to long run times and
false positive structural variant calls. | [
"Prepare",
"a",
"BED",
"file",
"for",
"exclusion",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L112-L137 |
224,138 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | exclude_by_ends | def exclude_by_ends(in_file, exclude_file, data, in_params=None):
"""Exclude calls based on overlap of the ends with exclusion regions.
Removes structural variants with either end being in a repeat: a large
source of false positives.
Parameters tuned based on removal of LCR overlapping false positives... | python | def exclude_by_ends(in_file, exclude_file, data, in_params=None):
"""Exclude calls based on overlap of the ends with exclusion regions.
Removes structural variants with either end being in a repeat: a large
source of false positives.
Parameters tuned based on removal of LCR overlapping false positives... | [
"def",
"exclude_by_ends",
"(",
"in_file",
",",
"exclude_file",
",",
"data",
",",
"in_params",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"end_buffer\"",
":",
"50",
",",
"\"rpt_pct\"",
":",
"0.9",
",",
"\"total_rpt_pct\"",
":",
"0.2",
",",
"\"sv_pct\"",
"... | Exclude calls based on overlap of the ends with exclusion regions.
Removes structural variants with either end being in a repeat: a large
source of false positives.
Parameters tuned based on removal of LCR overlapping false positives in DREAM
synthetic 3 data. | [
"Exclude",
"calls",
"based",
"on",
"overlap",
"of",
"the",
"ends",
"with",
"exclusion",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L139-L174 |
224,139 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | _find_to_filter | def _find_to_filter(in_file, exclude_file, params, to_exclude):
"""Identify regions in the end file that overlap the exclusion file.
We look for ends with a large percentage in a repeat or where the end contains
an entire repeat.
"""
for feat in pybedtools.BedTool(in_file).intersect(pybedtools.BedT... | python | def _find_to_filter(in_file, exclude_file, params, to_exclude):
"""Identify regions in the end file that overlap the exclusion file.
We look for ends with a large percentage in a repeat or where the end contains
an entire repeat.
"""
for feat in pybedtools.BedTool(in_file).intersect(pybedtools.BedT... | [
"def",
"_find_to_filter",
"(",
"in_file",
",",
"exclude_file",
",",
"params",
",",
"to_exclude",
")",
":",
"for",
"feat",
"in",
"pybedtools",
".",
"BedTool",
"(",
"in_file",
")",
".",
"intersect",
"(",
"pybedtools",
".",
"BedTool",
"(",
"exclude_file",
")",
... | Identify regions in the end file that overlap the exclusion file.
We look for ends with a large percentage in a repeat or where the end contains
an entire repeat. | [
"Identify",
"regions",
"in",
"the",
"end",
"file",
"that",
"overlap",
"the",
"exclusion",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L176-L190 |
224,140 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | get_sv_chroms | def get_sv_chroms(items, exclude_file):
"""Retrieve chromosomes to process on, avoiding extra skipped chromosomes.
"""
exclude_regions = {}
for region in pybedtools.BedTool(exclude_file):
if int(region.start) == 0:
exclude_regions[region.chrom] = int(region.end)
out = []
with... | python | def get_sv_chroms(items, exclude_file):
"""Retrieve chromosomes to process on, avoiding extra skipped chromosomes.
"""
exclude_regions = {}
for region in pybedtools.BedTool(exclude_file):
if int(region.start) == 0:
exclude_regions[region.chrom] = int(region.end)
out = []
with... | [
"def",
"get_sv_chroms",
"(",
"items",
",",
"exclude_file",
")",
":",
"exclude_regions",
"=",
"{",
"}",
"for",
"region",
"in",
"pybedtools",
".",
"BedTool",
"(",
"exclude_file",
")",
":",
"if",
"int",
"(",
"region",
".",
"start",
")",
"==",
"0",
":",
"e... | Retrieve chromosomes to process on, avoiding extra skipped chromosomes. | [
"Retrieve",
"chromosomes",
"to",
"process",
"on",
"avoiding",
"extra",
"skipped",
"chromosomes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L209-L222 |
224,141 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | _extract_split_and_discordants | def _extract_split_and_discordants(in_bam, work_dir, data):
"""Retrieve split-read alignments from input BAM file.
"""
sr_file = os.path.join(work_dir, "%s-sr.bam" % os.path.splitext(os.path.basename(in_bam))[0])
disc_file = os.path.join(work_dir, "%s-disc.bam" % os.path.splitext(os.path.basename(in_bam... | python | def _extract_split_and_discordants(in_bam, work_dir, data):
"""Retrieve split-read alignments from input BAM file.
"""
sr_file = os.path.join(work_dir, "%s-sr.bam" % os.path.splitext(os.path.basename(in_bam))[0])
disc_file = os.path.join(work_dir, "%s-disc.bam" % os.path.splitext(os.path.basename(in_bam... | [
"def",
"_extract_split_and_discordants",
"(",
"in_bam",
",",
"work_dir",
",",
"data",
")",
":",
"sr_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"\"%s-sr.bam\"",
"%",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
... | Retrieve split-read alignments from input BAM file. | [
"Retrieve",
"split",
"-",
"read",
"alignments",
"from",
"input",
"BAM",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L226-L241 |
224,142 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | find_existing_split_discordants | def find_existing_split_discordants(data):
"""Check for pre-calculated split reads and discordants done as part of alignment streaming.
"""
in_bam = dd.get_align_bam(data)
sr_file = "%s-sr.bam" % os.path.splitext(in_bam)[0]
disc_file = "%s-disc.bam" % os.path.splitext(in_bam)[0]
if utils.file_ex... | python | def find_existing_split_discordants(data):
"""Check for pre-calculated split reads and discordants done as part of alignment streaming.
"""
in_bam = dd.get_align_bam(data)
sr_file = "%s-sr.bam" % os.path.splitext(in_bam)[0]
disc_file = "%s-disc.bam" % os.path.splitext(in_bam)[0]
if utils.file_ex... | [
"def",
"find_existing_split_discordants",
"(",
"data",
")",
":",
"in_bam",
"=",
"dd",
".",
"get_align_bam",
"(",
"data",
")",
"sr_file",
"=",
"\"%s-sr.bam\"",
"%",
"os",
".",
"path",
".",
"splitext",
"(",
"in_bam",
")",
"[",
"0",
"]",
"disc_file",
"=",
"... | Check for pre-calculated split reads and discordants done as part of alignment streaming. | [
"Check",
"for",
"pre",
"-",
"calculated",
"split",
"reads",
"and",
"discordants",
"done",
"as",
"part",
"of",
"alignment",
"streaming",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L243-L257 |
224,143 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | get_split_discordants | def get_split_discordants(data, work_dir):
"""Retrieve split and discordant reads, potentially calculating with extract_sv_reads as needed.
"""
align_bam = dd.get_align_bam(data)
sr_bam, disc_bam = find_existing_split_discordants(data)
if not sr_bam:
work_dir = (work_dir if not os.access(os.... | python | def get_split_discordants(data, work_dir):
"""Retrieve split and discordant reads, potentially calculating with extract_sv_reads as needed.
"""
align_bam = dd.get_align_bam(data)
sr_bam, disc_bam = find_existing_split_discordants(data)
if not sr_bam:
work_dir = (work_dir if not os.access(os.... | [
"def",
"get_split_discordants",
"(",
"data",
",",
"work_dir",
")",
":",
"align_bam",
"=",
"dd",
".",
"get_align_bam",
"(",
"data",
")",
"sr_bam",
",",
"disc_bam",
"=",
"find_existing_split_discordants",
"(",
"data",
")",
"if",
"not",
"sr_bam",
":",
"work_dir",... | Retrieve split and discordant reads, potentially calculating with extract_sv_reads as needed. | [
"Retrieve",
"split",
"and",
"discordant",
"reads",
"potentially",
"calculating",
"with",
"extract_sv_reads",
"as",
"needed",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L259-L268 |
224,144 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | get_cur_batch | def get_cur_batch(items):
"""Retrieve name of the batch shared between all items in a group.
"""
batches = []
for data in items:
batch = tz.get_in(["metadata", "batch"], data, [])
batches.append(set(batch) if isinstance(batch, (list, tuple)) else set([batch]))
combo_batches = reduce(... | python | def get_cur_batch(items):
"""Retrieve name of the batch shared between all items in a group.
"""
batches = []
for data in items:
batch = tz.get_in(["metadata", "batch"], data, [])
batches.append(set(batch) if isinstance(batch, (list, tuple)) else set([batch]))
combo_batches = reduce(... | [
"def",
"get_cur_batch",
"(",
"items",
")",
":",
"batches",
"=",
"[",
"]",
"for",
"data",
"in",
"items",
":",
"batch",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"metadata\"",
",",
"\"batch\"",
"]",
",",
"data",
",",
"[",
"]",
")",
"batches",
".",
"appen... | Retrieve name of the batch shared between all items in a group. | [
"Retrieve",
"name",
"of",
"the",
"batch",
"shared",
"between",
"all",
"items",
"in",
"a",
"group",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L270-L283 |
224,145 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | calc_paired_insert_stats | def calc_paired_insert_stats(in_bam, nsample=1000000):
"""Retrieve statistics for paired end read insert distances.
"""
dists = []
n = 0
with pysam.Samfile(in_bam, "rb") as in_pysam:
for read in in_pysam:
if read.is_proper_pair and read.is_read1:
n += 1
... | python | def calc_paired_insert_stats(in_bam, nsample=1000000):
"""Retrieve statistics for paired end read insert distances.
"""
dists = []
n = 0
with pysam.Samfile(in_bam, "rb") as in_pysam:
for read in in_pysam:
if read.is_proper_pair and read.is_read1:
n += 1
... | [
"def",
"calc_paired_insert_stats",
"(",
"in_bam",
",",
"nsample",
"=",
"1000000",
")",
":",
"dists",
"=",
"[",
"]",
"n",
"=",
"0",
"with",
"pysam",
".",
"Samfile",
"(",
"in_bam",
",",
"\"rb\"",
")",
"as",
"in_pysam",
":",
"for",
"read",
"in",
"in_pysam... | Retrieve statistics for paired end read insert distances. | [
"Retrieve",
"statistics",
"for",
"paired",
"end",
"read",
"insert",
"distances",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L307-L319 |
224,146 | bcbio/bcbio-nextgen | bcbio/structural/shared.py | calc_paired_insert_stats_save | def calc_paired_insert_stats_save(in_bam, stat_file, nsample=1000000):
"""Calculate paired stats, saving to a file for re-runs.
"""
if utils.file_exists(stat_file):
with open(stat_file) as in_handle:
return yaml.safe_load(in_handle)
else:
stats = calc_paired_insert_stats(in_b... | python | def calc_paired_insert_stats_save(in_bam, stat_file, nsample=1000000):
"""Calculate paired stats, saving to a file for re-runs.
"""
if utils.file_exists(stat_file):
with open(stat_file) as in_handle:
return yaml.safe_load(in_handle)
else:
stats = calc_paired_insert_stats(in_b... | [
"def",
"calc_paired_insert_stats_save",
"(",
"in_bam",
",",
"stat_file",
",",
"nsample",
"=",
"1000000",
")",
":",
"if",
"utils",
".",
"file_exists",
"(",
"stat_file",
")",
":",
"with",
"open",
"(",
"stat_file",
")",
"as",
"in_handle",
":",
"return",
"yaml",... | Calculate paired stats, saving to a file for re-runs. | [
"Calculate",
"paired",
"stats",
"saving",
"to",
"a",
"file",
"for",
"re",
"-",
"runs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/shared.py#L321-L331 |
224,147 | bcbio/bcbio-nextgen | scripts/utils/upload_to_synapse.py | _accumulate_remotes | def _accumulate_remotes(synapse_parent_id, syn):
"""Retrieve references to all remote directories and files.
"""
remotes = {}
s_base_folder = syn.get(synapse_parent_id)
for (s_dirpath, s_dirpath_id), _, s_filenames in synapseutils.walk(syn, synapse_parent_id):
remotes[s_dirpath] = s_dirpath_... | python | def _accumulate_remotes(synapse_parent_id, syn):
"""Retrieve references to all remote directories and files.
"""
remotes = {}
s_base_folder = syn.get(synapse_parent_id)
for (s_dirpath, s_dirpath_id), _, s_filenames in synapseutils.walk(syn, synapse_parent_id):
remotes[s_dirpath] = s_dirpath_... | [
"def",
"_accumulate_remotes",
"(",
"synapse_parent_id",
",",
"syn",
")",
":",
"remotes",
"=",
"{",
"}",
"s_base_folder",
"=",
"syn",
".",
"get",
"(",
"synapse_parent_id",
")",
"for",
"(",
"s_dirpath",
",",
"s_dirpath_id",
")",
",",
"_",
",",
"s_filenames",
... | Retrieve references to all remote directories and files. | [
"Retrieve",
"references",
"to",
"all",
"remote",
"directories",
"and",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/upload_to_synapse.py#L38-L48 |
224,148 | bcbio/bcbio-nextgen | scripts/utils/upload_to_synapse.py | _remote_folder | def _remote_folder(dirpath, remotes, syn):
"""Retrieve the remote folder for files, creating if necessary.
"""
if dirpath in remotes:
return remotes[dirpath], remotes
else:
parent_dir, cur_dir = os.path.split(dirpath)
parent_folder, remotes = _remote_folder(parent_dir, remotes, s... | python | def _remote_folder(dirpath, remotes, syn):
"""Retrieve the remote folder for files, creating if necessary.
"""
if dirpath in remotes:
return remotes[dirpath], remotes
else:
parent_dir, cur_dir = os.path.split(dirpath)
parent_folder, remotes = _remote_folder(parent_dir, remotes, s... | [
"def",
"_remote_folder",
"(",
"dirpath",
",",
"remotes",
",",
"syn",
")",
":",
"if",
"dirpath",
"in",
"remotes",
":",
"return",
"remotes",
"[",
"dirpath",
"]",
",",
"remotes",
"else",
":",
"parent_dir",
",",
"cur_dir",
"=",
"os",
".",
"path",
".",
"spl... | Retrieve the remote folder for files, creating if necessary. | [
"Retrieve",
"the",
"remote",
"folder",
"for",
"files",
"creating",
"if",
"necessary",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/upload_to_synapse.py#L50-L60 |
224,149 | bcbio/bcbio-nextgen | bcbio/structural/wham.py | run | def run(items, background=None):
"""Detect copy number variations from batched set of samples using WHAM.
"""
if not background: background = []
background_bams = []
paired = vcfutils.get_paired_bams([x["align_bam"] for x in items], items)
if paired:
inputs = [paired.tumor_data]
... | python | def run(items, background=None):
"""Detect copy number variations from batched set of samples using WHAM.
"""
if not background: background = []
background_bams = []
paired = vcfutils.get_paired_bams([x["align_bam"] for x in items], items)
if paired:
inputs = [paired.tumor_data]
... | [
"def",
"run",
"(",
"items",
",",
"background",
"=",
"None",
")",
":",
"if",
"not",
"background",
":",
"background",
"=",
"[",
"]",
"background_bams",
"=",
"[",
"]",
"paired",
"=",
"vcfutils",
".",
"get_paired_bams",
"(",
"[",
"x",
"[",
"\"align_bam\"",
... | Detect copy number variations from batched set of samples using WHAM. | [
"Detect",
"copy",
"number",
"variations",
"from",
"batched",
"set",
"of",
"samples",
"using",
"WHAM",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/wham.py#L19-L42 |
224,150 | bcbio/bcbio-nextgen | bcbio/structural/wham.py | _run_wham | def _run_wham(inputs, background_bams):
"""Run WHAM on a defined set of inputs and targets.
"""
out_file = os.path.join(_sv_workdir(inputs[0]), "%s-wham.vcf.gz" % dd.get_sample_name(inputs[0]))
if not utils.file_exists(out_file):
with file_transaction(inputs[0], out_file) as tx_out_file:
... | python | def _run_wham(inputs, background_bams):
"""Run WHAM on a defined set of inputs and targets.
"""
out_file = os.path.join(_sv_workdir(inputs[0]), "%s-wham.vcf.gz" % dd.get_sample_name(inputs[0]))
if not utils.file_exists(out_file):
with file_transaction(inputs[0], out_file) as tx_out_file:
... | [
"def",
"_run_wham",
"(",
"inputs",
",",
"background_bams",
")",
":",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"_sv_workdir",
"(",
"inputs",
"[",
"0",
"]",
")",
",",
"\"%s-wham.vcf.gz\"",
"%",
"dd",
".",
"get_sample_name",
"(",
"inputs",
"[",... | Run WHAM on a defined set of inputs and targets. | [
"Run",
"WHAM",
"on",
"a",
"defined",
"set",
"of",
"inputs",
"and",
"targets",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/wham.py#L48-L62 |
224,151 | bcbio/bcbio-nextgen | bcbio/structural/wham.py | filter_by_background | def filter_by_background(in_vcf, full_vcf, background, data):
"""Filter SV calls also present in background samples.
Skips filtering of inversions, which are not characterized differently
between cases and controls in test datasets.
"""
Filter = collections.namedtuple('Filter', ['id', 'desc'])
... | python | def filter_by_background(in_vcf, full_vcf, background, data):
"""Filter SV calls also present in background samples.
Skips filtering of inversions, which are not characterized differently
between cases and controls in test datasets.
"""
Filter = collections.namedtuple('Filter', ['id', 'desc'])
... | [
"def",
"filter_by_background",
"(",
"in_vcf",
",",
"full_vcf",
",",
"background",
",",
"data",
")",
":",
"Filter",
"=",
"collections",
".",
"namedtuple",
"(",
"'Filter'",
",",
"[",
"'id'",
",",
"'desc'",
"]",
")",
"back_filter",
"=",
"Filter",
"(",
"id",
... | Filter SV calls also present in background samples.
Skips filtering of inversions, which are not characterized differently
between cases and controls in test datasets. | [
"Filter",
"SV",
"calls",
"also",
"present",
"in",
"background",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/wham.py#L64-L87 |
224,152 | bcbio/bcbio-nextgen | bcbio/variation/gatkjoint.py | run_region | def run_region(data, region, vrn_files, out_file):
"""Perform variant calling on gVCF inputs in a specific genomic region.
"""
broad_runner = broad.runner_from_config(data["config"])
if broad_runner.gatk_type() == "gatk4":
genomics_db = _run_genomicsdb_import(vrn_files, region, out_file, data)
... | python | def run_region(data, region, vrn_files, out_file):
"""Perform variant calling on gVCF inputs in a specific genomic region.
"""
broad_runner = broad.runner_from_config(data["config"])
if broad_runner.gatk_type() == "gatk4":
genomics_db = _run_genomicsdb_import(vrn_files, region, out_file, data)
... | [
"def",
"run_region",
"(",
"data",
",",
"region",
",",
"vrn_files",
",",
"out_file",
")",
":",
"broad_runner",
"=",
"broad",
".",
"runner_from_config",
"(",
"data",
"[",
"\"config\"",
"]",
")",
"if",
"broad_runner",
".",
"gatk_type",
"(",
")",
"==",
"\"gatk... | Perform variant calling on gVCF inputs in a specific genomic region. | [
"Perform",
"variant",
"calling",
"on",
"gVCF",
"inputs",
"in",
"a",
"specific",
"genomic",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkjoint.py#L18-L27 |
224,153 | bcbio/bcbio-nextgen | bcbio/variation/gatkjoint.py | _incomplete_genomicsdb | def _incomplete_genomicsdb(dbdir):
"""Check if a GenomicsDB output is incomplete and we should regenerate.
Works around current inability to move GenomicsDB outputs and support
transactional directories.
"""
for test_file in ["callset.json", "vidmap.json", "genomicsdb_array/genomicsdb_meta.json"]:
... | python | def _incomplete_genomicsdb(dbdir):
"""Check if a GenomicsDB output is incomplete and we should regenerate.
Works around current inability to move GenomicsDB outputs and support
transactional directories.
"""
for test_file in ["callset.json", "vidmap.json", "genomicsdb_array/genomicsdb_meta.json"]:
... | [
"def",
"_incomplete_genomicsdb",
"(",
"dbdir",
")",
":",
"for",
"test_file",
"in",
"[",
"\"callset.json\"",
",",
"\"vidmap.json\"",
",",
"\"genomicsdb_array/genomicsdb_meta.json\"",
"]",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",... | Check if a GenomicsDB output is incomplete and we should regenerate.
Works around current inability to move GenomicsDB outputs and support
transactional directories. | [
"Check",
"if",
"a",
"GenomicsDB",
"output",
"is",
"incomplete",
"and",
"we",
"should",
"regenerate",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkjoint.py#L64-L73 |
224,154 | bcbio/bcbio-nextgen | bcbio/variation/gatkjoint.py | _run_genotype_gvcfs_gatk3 | def _run_genotype_gvcfs_gatk3(data, region, vrn_files, ref_file, out_file):
"""Performs genotyping of gVCFs into final VCF files.
"""
if not utils.file_exists(out_file):
broad_runner = broad.runner_from_config(data["config"])
with file_transaction(data, out_file) as tx_out_file:
... | python | def _run_genotype_gvcfs_gatk3(data, region, vrn_files, ref_file, out_file):
"""Performs genotyping of gVCFs into final VCF files.
"""
if not utils.file_exists(out_file):
broad_runner = broad.runner_from_config(data["config"])
with file_transaction(data, out_file) as tx_out_file:
... | [
"def",
"_run_genotype_gvcfs_gatk3",
"(",
"data",
",",
"region",
",",
"vrn_files",
",",
"ref_file",
",",
"out_file",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"broad_runner",
"=",
"broad",
".",
"runner_from_config",
"(",
"... | Performs genotyping of gVCFs into final VCF files. | [
"Performs",
"genotyping",
"of",
"gVCFs",
"into",
"final",
"VCF",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkjoint.py#L102-L133 |
224,155 | bcbio/bcbio-nextgen | bcbio/variation/gatkjoint.py | _batch_gvcfs | def _batch_gvcfs(data, region, vrn_files, ref_file, out_file=None):
"""Perform batching of gVCF files if above recommended input count.
"""
if out_file is None:
out_file = vrn_files[0]
# group to get below the maximum batch size, using 200 as the baseline
max_batch = int(dd.get_joint_group_s... | python | def _batch_gvcfs(data, region, vrn_files, ref_file, out_file=None):
"""Perform batching of gVCF files if above recommended input count.
"""
if out_file is None:
out_file = vrn_files[0]
# group to get below the maximum batch size, using 200 as the baseline
max_batch = int(dd.get_joint_group_s... | [
"def",
"_batch_gvcfs",
"(",
"data",
",",
"region",
",",
"vrn_files",
",",
"ref_file",
",",
"out_file",
"=",
"None",
")",
":",
"if",
"out_file",
"is",
"None",
":",
"out_file",
"=",
"vrn_files",
"[",
"0",
"]",
"# group to get below the maximum batch size, using 20... | Perform batching of gVCF files if above recommended input count. | [
"Perform",
"batching",
"of",
"gVCF",
"files",
"if",
"above",
"recommended",
"input",
"count",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkjoint.py#L137-L153 |
224,156 | bcbio/bcbio-nextgen | bcbio/qc/preseq.py | _get_preseq_params | def _get_preseq_params(data, preseq_cmd, read_count):
""" Get parameters through resources.
If "step" or "extrap" limit are not provided, then calculate optimal values based on read count.
"""
defaults = {
'seg_len': 100000, # maximum segment length when merging paired end bam reads
... | python | def _get_preseq_params(data, preseq_cmd, read_count):
""" Get parameters through resources.
If "step" or "extrap" limit are not provided, then calculate optimal values based on read count.
"""
defaults = {
'seg_len': 100000, # maximum segment length when merging paired end bam reads
... | [
"def",
"_get_preseq_params",
"(",
"data",
",",
"preseq_cmd",
",",
"read_count",
")",
":",
"defaults",
"=",
"{",
"'seg_len'",
":",
"100000",
",",
"# maximum segment length when merging paired end bam reads",
"'steps'",
":",
"300",
",",
"# number of points on the plot",
"... | Get parameters through resources.
If "step" or "extrap" limit are not provided, then calculate optimal values based on read count. | [
"Get",
"parameters",
"through",
"resources",
".",
"If",
"step",
"or",
"extrap",
"limit",
"are",
"not",
"provided",
"then",
"calculate",
"optimal",
"values",
"based",
"on",
"read",
"count",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/preseq.py#L51-L114 |
224,157 | bcbio/bcbio-nextgen | bcbio/variation/germline.py | split_somatic | def split_somatic(items):
"""Split somatic batches, adding a germline target.
Enables separate germline calling of samples using shared alignments.
"""
items = [_clean_flat_variantcaller(x) for x in items]
somatic_groups, somatic, non_somatic = vcfutils.somatic_batches(items)
# extract germline... | python | def split_somatic(items):
"""Split somatic batches, adding a germline target.
Enables separate germline calling of samples using shared alignments.
"""
items = [_clean_flat_variantcaller(x) for x in items]
somatic_groups, somatic, non_somatic = vcfutils.somatic_batches(items)
# extract germline... | [
"def",
"split_somatic",
"(",
"items",
")",
":",
"items",
"=",
"[",
"_clean_flat_variantcaller",
"(",
"x",
")",
"for",
"x",
"in",
"items",
"]",
"somatic_groups",
",",
"somatic",
",",
"non_somatic",
"=",
"vcfutils",
".",
"somatic_batches",
"(",
"items",
")",
... | Split somatic batches, adding a germline target.
Enables separate germline calling of samples using shared alignments. | [
"Split",
"somatic",
"batches",
"adding",
"a",
"germline",
"target",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L19-L50 |
224,158 | bcbio/bcbio-nextgen | bcbio/variation/germline.py | _clean_flat_variantcaller | def _clean_flat_variantcaller(data):
"""Convert flattened dictionary from CWL representation into dictionary.
CWL flattens somatic/germline tags into a set of strings, which we
reconstitute as a dictionary.
"""
vc = dd.get_variantcaller(data)
if isinstance(vc, (list, tuple)) and all([x.count(":... | python | def _clean_flat_variantcaller(data):
"""Convert flattened dictionary from CWL representation into dictionary.
CWL flattens somatic/germline tags into a set of strings, which we
reconstitute as a dictionary.
"""
vc = dd.get_variantcaller(data)
if isinstance(vc, (list, tuple)) and all([x.count(":... | [
"def",
"_clean_flat_variantcaller",
"(",
"data",
")",
":",
"vc",
"=",
"dd",
".",
"get_variantcaller",
"(",
"data",
")",
"if",
"isinstance",
"(",
"vc",
",",
"(",
"list",
",",
"tuple",
")",
")",
"and",
"all",
"(",
"[",
"x",
".",
"count",
"(",
"\":\"",
... | Convert flattened dictionary from CWL representation into dictionary.
CWL flattens somatic/germline tags into a set of strings, which we
reconstitute as a dictionary. | [
"Convert",
"flattened",
"dictionary",
"from",
"CWL",
"representation",
"into",
"dictionary",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L52-L68 |
224,159 | bcbio/bcbio-nextgen | bcbio/variation/germline.py | remove_align_qc_tools | def remove_align_qc_tools(data):
"""Remove alignment based QC tools we don't need for data replicates.
When we do multiple variant calling on a sample file (somatic/germline),
avoid re-running QC.
"""
align_qc = set(["qsignature", "coverage", "picard", "samtools", "fastqc"])
data["config"]["alg... | python | def remove_align_qc_tools(data):
"""Remove alignment based QC tools we don't need for data replicates.
When we do multiple variant calling on a sample file (somatic/germline),
avoid re-running QC.
"""
align_qc = set(["qsignature", "coverage", "picard", "samtools", "fastqc"])
data["config"]["alg... | [
"def",
"remove_align_qc_tools",
"(",
"data",
")",
":",
"align_qc",
"=",
"set",
"(",
"[",
"\"qsignature\"",
",",
"\"coverage\"",
",",
"\"picard\"",
",",
"\"samtools\"",
",",
"\"fastqc\"",
"]",
")",
"data",
"[",
"\"config\"",
"]",
"[",
"\"algorithm\"",
"]",
"[... | Remove alignment based QC tools we don't need for data replicates.
When we do multiple variant calling on a sample file (somatic/germline),
avoid re-running QC. | [
"Remove",
"alignment",
"based",
"QC",
"tools",
"we",
"don",
"t",
"need",
"for",
"data",
"replicates",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L70-L79 |
224,160 | bcbio/bcbio-nextgen | bcbio/variation/germline.py | extract | def extract(data, items, out_dir=None):
"""Extract germline calls for the given sample, if tumor only.
"""
if vcfutils.get_paired_phenotype(data):
if len(items) == 1:
germline_vcf = _remove_prioritization(data["vrn_file"], data, out_dir)
germline_vcf = vcfutils.bgzip_and_inde... | python | def extract(data, items, out_dir=None):
"""Extract germline calls for the given sample, if tumor only.
"""
if vcfutils.get_paired_phenotype(data):
if len(items) == 1:
germline_vcf = _remove_prioritization(data["vrn_file"], data, out_dir)
germline_vcf = vcfutils.bgzip_and_inde... | [
"def",
"extract",
"(",
"data",
",",
"items",
",",
"out_dir",
"=",
"None",
")",
":",
"if",
"vcfutils",
".",
"get_paired_phenotype",
"(",
"data",
")",
":",
"if",
"len",
"(",
"items",
")",
"==",
"1",
":",
"germline_vcf",
"=",
"_remove_prioritization",
"(",
... | Extract germline calls for the given sample, if tumor only. | [
"Extract",
"germline",
"calls",
"for",
"the",
"given",
"sample",
"if",
"tumor",
"only",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L81-L89 |
224,161 | bcbio/bcbio-nextgen | bcbio/variation/germline.py | fix_germline_samplename | def fix_germline_samplename(in_file, sample_name, data):
"""Replace germline sample names, originally from normal BAM file.
"""
out_file = "%s-fixnames%s" % utils.splitext_plus(in_file)
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
sample_f... | python | def fix_germline_samplename(in_file, sample_name, data):
"""Replace germline sample names, originally from normal BAM file.
"""
out_file = "%s-fixnames%s" % utils.splitext_plus(in_file)
if not utils.file_exists(out_file):
with file_transaction(data, out_file) as tx_out_file:
sample_f... | [
"def",
"fix_germline_samplename",
"(",
"in_file",
",",
"sample_name",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-fixnames%s\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"... | Replace germline sample names, originally from normal BAM file. | [
"Replace",
"germline",
"sample",
"names",
"originally",
"from",
"normal",
"BAM",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L133-L144 |
224,162 | bcbio/bcbio-nextgen | bcbio/variation/germline.py | _remove_prioritization | def _remove_prioritization(in_file, data, out_dir=None):
"""Remove tumor-only prioritization and return non-filtered calls.
"""
out_file = "%s-germline.vcf" % utils.splitext_plus(in_file)[0]
if out_dir:
out_file = os.path.join(out_dir, os.path.basename(out_file))
if not utils.file_uptodate(o... | python | def _remove_prioritization(in_file, data, out_dir=None):
"""Remove tumor-only prioritization and return non-filtered calls.
"""
out_file = "%s-germline.vcf" % utils.splitext_plus(in_file)[0]
if out_dir:
out_file = os.path.join(out_dir, os.path.basename(out_file))
if not utils.file_uptodate(o... | [
"def",
"_remove_prioritization",
"(",
"in_file",
",",
"data",
",",
"out_dir",
"=",
"None",
")",
":",
"out_file",
"=",
"\"%s-germline.vcf\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"if",
"out_dir",
":",
"out_file",
"=",
"os"... | Remove tumor-only prioritization and return non-filtered calls. | [
"Remove",
"tumor",
"-",
"only",
"prioritization",
"and",
"return",
"non",
"-",
"filtered",
"calls",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L146-L163 |
224,163 | bcbio/bcbio-nextgen | bcbio/variation/germline.py | _extract_germline | def _extract_germline(in_file, data):
"""Extract germline calls non-somatic, non-filtered calls.
"""
out_file = "%s-germline.vcf" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file) and not utils.file_uptodate(out_file + ".gz", in_file):
with file_transaction(data, ou... | python | def _extract_germline(in_file, data):
"""Extract germline calls non-somatic, non-filtered calls.
"""
out_file = "%s-germline.vcf" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file) and not utils.file_uptodate(out_file + ".gz", in_file):
with file_transaction(data, ou... | [
"def",
"_extract_germline",
"(",
"in_file",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-germline.vcf\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"if",
"not",
"utils",
".",
"file_uptodate",
"(",
"out_file",
",",
"in_file",
... | Extract germline calls non-somatic, non-filtered calls. | [
"Extract",
"germline",
"calls",
"non",
"-",
"somatic",
"non",
"-",
"filtered",
"calls",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L169-L184 |
224,164 | bcbio/bcbio-nextgen | bcbio/variation/germline.py | _is_somatic | def _is_somatic(rec):
"""Handle somatic classifications from MuTect, MuTect2, VarDict and VarScan
"""
if _has_somatic_flag(rec):
return True
if _is_mutect2_somatic(rec):
return True
ss_flag = rec.INFO.get("SS")
if ss_flag is not None:
if str(ss_flag) == "2":
r... | python | def _is_somatic(rec):
"""Handle somatic classifications from MuTect, MuTect2, VarDict and VarScan
"""
if _has_somatic_flag(rec):
return True
if _is_mutect2_somatic(rec):
return True
ss_flag = rec.INFO.get("SS")
if ss_flag is not None:
if str(ss_flag) == "2":
r... | [
"def",
"_is_somatic",
"(",
"rec",
")",
":",
"if",
"_has_somatic_flag",
"(",
"rec",
")",
":",
"return",
"True",
"if",
"_is_mutect2_somatic",
"(",
"rec",
")",
":",
"return",
"True",
"ss_flag",
"=",
"rec",
".",
"INFO",
".",
"get",
"(",
"\"SS\"",
")",
"if"... | Handle somatic classifications from MuTect, MuTect2, VarDict and VarScan | [
"Handle",
"somatic",
"classifications",
"from",
"MuTect",
"MuTect2",
"VarDict",
"and",
"VarScan"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L210-L228 |
224,165 | bcbio/bcbio-nextgen | bcbio/variation/germline.py | _is_germline | def _is_germline(rec):
"""Handle somatic INFO classifications from MuTect, MuTect2, VarDict, VarScan and Octopus.
"""
if _has_somatic_flag(rec):
return False
if _is_mutect2_somatic(rec):
return False
ss_flag = rec.INFO.get("SS")
if ss_flag is not None:
if str(ss_flag) == ... | python | def _is_germline(rec):
"""Handle somatic INFO classifications from MuTect, MuTect2, VarDict, VarScan and Octopus.
"""
if _has_somatic_flag(rec):
return False
if _is_mutect2_somatic(rec):
return False
ss_flag = rec.INFO.get("SS")
if ss_flag is not None:
if str(ss_flag) == ... | [
"def",
"_is_germline",
"(",
"rec",
")",
":",
"if",
"_has_somatic_flag",
"(",
"rec",
")",
":",
"return",
"False",
"if",
"_is_mutect2_somatic",
"(",
"rec",
")",
":",
"return",
"False",
"ss_flag",
"=",
"rec",
".",
"INFO",
".",
"get",
"(",
"\"SS\"",
")",
"... | Handle somatic INFO classifications from MuTect, MuTect2, VarDict, VarScan and Octopus. | [
"Handle",
"somatic",
"INFO",
"classifications",
"from",
"MuTect",
"MuTect2",
"VarDict",
"VarScan",
"and",
"Octopus",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/germline.py#L242-L262 |
224,166 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | get_sort_cmd | def get_sort_cmd(tmp_dir=None):
"""Retrieve GNU coreutils sort command, using version-sort if available.
Recent versions of sort have alpha-numeric sorting, which provides
more natural sorting of chromosomes (chr1, chr2) instead of (chr1, chr10).
This also fixes versions of sort, like 8.22 in CentOS 7.... | python | def get_sort_cmd(tmp_dir=None):
"""Retrieve GNU coreutils sort command, using version-sort if available.
Recent versions of sort have alpha-numeric sorting, which provides
more natural sorting of chromosomes (chr1, chr2) instead of (chr1, chr10).
This also fixes versions of sort, like 8.22 in CentOS 7.... | [
"def",
"get_sort_cmd",
"(",
"tmp_dir",
"=",
"None",
")",
":",
"has_versionsort",
"=",
"subprocess",
".",
"check_output",
"(",
"\"sort --help | grep version-sort; exit 0\"",
",",
"shell",
"=",
"True",
")",
".",
"strip",
"(",
")",
"if",
"has_versionsort",
":",
"cm... | Retrieve GNU coreutils sort command, using version-sort if available.
Recent versions of sort have alpha-numeric sorting, which provides
more natural sorting of chromosomes (chr1, chr2) instead of (chr1, chr10).
This also fixes versions of sort, like 8.22 in CentOS 7.1, that have broken
sorting without... | [
"Retrieve",
"GNU",
"coreutils",
"sort",
"command",
"using",
"version",
"-",
"sort",
"if",
"available",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L18-L36 |
224,167 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | check_bed_contigs | def check_bed_contigs(in_file, data):
"""Ensure BED file contigs match the reference genome.
"""
if not dd.get_ref_file(data):
return
contigs = set([])
with utils.open_gzipsafe(in_file) as in_handle:
for line in in_handle:
if not line.startswith(("#", "track", "browser", ... | python | def check_bed_contigs(in_file, data):
"""Ensure BED file contigs match the reference genome.
"""
if not dd.get_ref_file(data):
return
contigs = set([])
with utils.open_gzipsafe(in_file) as in_handle:
for line in in_handle:
if not line.startswith(("#", "track", "browser", ... | [
"def",
"check_bed_contigs",
"(",
"in_file",
",",
"data",
")",
":",
"if",
"not",
"dd",
".",
"get_ref_file",
"(",
"data",
")",
":",
"return",
"contigs",
"=",
"set",
"(",
"[",
"]",
")",
"with",
"utils",
".",
"open_gzipsafe",
"(",
"in_file",
")",
"as",
"... | Ensure BED file contigs match the reference genome. | [
"Ensure",
"BED",
"file",
"contigs",
"match",
"the",
"reference",
"genome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L38-L52 |
224,168 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | check_bed_coords | def check_bed_coords(in_file, data):
"""Ensure BED file coordinates match reference genome.
Catches errors like using a hg38 BED file for an hg19 genome run.
"""
if dd.get_ref_file(data):
contig_sizes = {}
for contig in ref.file_contigs(dd.get_ref_file(data)):
contig_sizes[c... | python | def check_bed_coords(in_file, data):
"""Ensure BED file coordinates match reference genome.
Catches errors like using a hg38 BED file for an hg19 genome run.
"""
if dd.get_ref_file(data):
contig_sizes = {}
for contig in ref.file_contigs(dd.get_ref_file(data)):
contig_sizes[c... | [
"def",
"check_bed_coords",
"(",
"in_file",
",",
"data",
")",
":",
"if",
"dd",
".",
"get_ref_file",
"(",
"data",
")",
":",
"contig_sizes",
"=",
"{",
"}",
"for",
"contig",
"in",
"ref",
".",
"file_contigs",
"(",
"dd",
".",
"get_ref_file",
"(",
"data",
")"... | Ensure BED file coordinates match reference genome.
Catches errors like using a hg38 BED file for an hg19 genome run. | [
"Ensure",
"BED",
"file",
"coordinates",
"match",
"reference",
"genome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L54-L77 |
224,169 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | clean_file | def clean_file(in_file, data, prefix="", bedprep_dir=None, simple=None):
"""Prepare a clean sorted input BED file without headers
"""
# Remove non-ascii characters. Used in coverage analysis, to support JSON code in one column
# and be happy with sambamba:
simple = "iconv -c -f utf-8 -t ascii | se... | python | def clean_file(in_file, data, prefix="", bedprep_dir=None, simple=None):
"""Prepare a clean sorted input BED file without headers
"""
# Remove non-ascii characters. Used in coverage analysis, to support JSON code in one column
# and be happy with sambamba:
simple = "iconv -c -f utf-8 -t ascii | se... | [
"def",
"clean_file",
"(",
"in_file",
",",
"data",
",",
"prefix",
"=",
"\"\"",
",",
"bedprep_dir",
"=",
"None",
",",
"simple",
"=",
"None",
")",
":",
"# Remove non-ascii characters. Used in coverage analysis, to support JSON code in one column",
"# and be happy with sambam... | Prepare a clean sorted input BED file without headers | [
"Prepare",
"a",
"clean",
"sorted",
"input",
"BED",
"file",
"without",
"headers"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L79-L108 |
224,170 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | remove_bad | def remove_bad():
"""Remove non-increasing BED lines which will cause variant callers to choke.
Also fixes space separated BED inputs.
"""
for line in sys.stdin:
parts = line.strip().split("\t")
if len(parts) == 1 and len(line.strip().split()) > 1:
parts = line.strip().split... | python | def remove_bad():
"""Remove non-increasing BED lines which will cause variant callers to choke.
Also fixes space separated BED inputs.
"""
for line in sys.stdin:
parts = line.strip().split("\t")
if len(parts) == 1 and len(line.strip().split()) > 1:
parts = line.strip().split... | [
"def",
"remove_bad",
"(",
")",
":",
"for",
"line",
"in",
"sys",
".",
"stdin",
":",
"parts",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"\"\\t\"",
")",
"if",
"len",
"(",
"parts",
")",
"==",
"1",
"and",
"len",
"(",
"line",
".",
"stri... | Remove non-increasing BED lines which will cause variant callers to choke.
Also fixes space separated BED inputs. | [
"Remove",
"non",
"-",
"increasing",
"BED",
"lines",
"which",
"will",
"cause",
"variant",
"callers",
"to",
"choke",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L134-L144 |
224,171 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | merge_overlaps | def merge_overlaps(in_file, data, distance=None, out_dir=None):
"""Merge bed file intervals to avoid overlapping regions. Output is always a 3 column file.
Overlapping regions (1:1-100, 1:90-100) cause issues with callers like FreeBayes
that don't collapse BEDs prior to using them.
"""
config = dat... | python | def merge_overlaps(in_file, data, distance=None, out_dir=None):
"""Merge bed file intervals to avoid overlapping regions. Output is always a 3 column file.
Overlapping regions (1:1-100, 1:90-100) cause issues with callers like FreeBayes
that don't collapse BEDs prior to using them.
"""
config = dat... | [
"def",
"merge_overlaps",
"(",
"in_file",
",",
"data",
",",
"distance",
"=",
"None",
",",
"out_dir",
"=",
"None",
")",
":",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"if",
"in_file",
":",
"bedtools",
"=",
"config_utils",
".",
"get_program",
"(",
"\"b... | Merge bed file intervals to avoid overlapping regions. Output is always a 3 column file.
Overlapping regions (1:1-100, 1:90-100) cause issues with callers like FreeBayes
that don't collapse BEDs prior to using them. | [
"Merge",
"bed",
"file",
"intervals",
"to",
"avoid",
"overlapping",
"regions",
".",
"Output",
"is",
"always",
"a",
"3",
"column",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L146-L170 |
224,172 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | population_variant_regions | def population_variant_regions(items, merged=False):
"""Retrieve the variant region BED file from a population of items.
If tumor/normal, return the tumor BED file. If a population, return
the BED file covering the most bases.
"""
def _get_variant_regions(data):
out = dd.get_variant_regions... | python | def population_variant_regions(items, merged=False):
"""Retrieve the variant region BED file from a population of items.
If tumor/normal, return the tumor BED file. If a population, return
the BED file covering the most bases.
"""
def _get_variant_regions(data):
out = dd.get_variant_regions... | [
"def",
"population_variant_regions",
"(",
"items",
",",
"merged",
"=",
"False",
")",
":",
"def",
"_get_variant_regions",
"(",
"data",
")",
":",
"out",
"=",
"dd",
".",
"get_variant_regions",
"(",
"data",
")",
"or",
"dd",
".",
"get_sample_callable",
"(",
"data... | Retrieve the variant region BED file from a population of items.
If tumor/normal, return the tumor BED file. If a population, return
the BED file covering the most bases. | [
"Retrieve",
"the",
"variant",
"region",
"BED",
"file",
"from",
"a",
"population",
"of",
"items",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L172-L203 |
224,173 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | combine | def combine(in_files, out_file, config):
"""Combine multiple BED files into a single output.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
with open(tx_out_file, "w") as out_handle:
for in_file in in_files:
... | python | def combine(in_files, out_file, config):
"""Combine multiple BED files into a single output.
"""
if not utils.file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
with open(tx_out_file, "w") as out_handle:
for in_file in in_files:
... | [
"def",
"combine",
"(",
"in_files",
",",
"out_file",
",",
"config",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"with",
"file_transaction",
"(",
"config",
",",
"out_file",
")",
"as",
"tx_out_file",
":",
"with",
"open",
"... | Combine multiple BED files into a single output. | [
"Combine",
"multiple",
"BED",
"files",
"into",
"a",
"single",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L205-L214 |
224,174 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | intersect_two | def intersect_two(f1, f2, work_dir, data):
"""Intersect two regions, handling cases where either file is not present.
"""
bedtools = config_utils.get_program("bedtools", data, default="bedtools")
f1_exists = f1 and utils.file_exists(f1)
f2_exists = f2 and utils.file_exists(f2)
if not f1_exists a... | python | def intersect_two(f1, f2, work_dir, data):
"""Intersect two regions, handling cases where either file is not present.
"""
bedtools = config_utils.get_program("bedtools", data, default="bedtools")
f1_exists = f1 and utils.file_exists(f1)
f2_exists = f2 and utils.file_exists(f2)
if not f1_exists a... | [
"def",
"intersect_two",
"(",
"f1",
",",
"f2",
",",
"work_dir",
",",
"data",
")",
":",
"bedtools",
"=",
"config_utils",
".",
"get_program",
"(",
"\"bedtools\"",
",",
"data",
",",
"default",
"=",
"\"bedtools\"",
")",
"f1_exists",
"=",
"f1",
"and",
"utils",
... | Intersect two regions, handling cases where either file is not present. | [
"Intersect",
"two",
"regions",
"handling",
"cases",
"where",
"either",
"file",
"is",
"not",
"present",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L216-L234 |
224,175 | bcbio/bcbio-nextgen | bcbio/variation/bedutils.py | subset_to_genome | def subset_to_genome(in_file, out_file, data):
"""Subset a BED file to only contain contigs present in the reference genome.
"""
if not utils.file_uptodate(out_file, in_file):
contigs = set([x.name for x in ref.file_contigs(dd.get_ref_file(data))])
with utils.open_gzipsafe(in_file) as in_han... | python | def subset_to_genome(in_file, out_file, data):
"""Subset a BED file to only contain contigs present in the reference genome.
"""
if not utils.file_uptodate(out_file, in_file):
contigs = set([x.name for x in ref.file_contigs(dd.get_ref_file(data))])
with utils.open_gzipsafe(in_file) as in_han... | [
"def",
"subset_to_genome",
"(",
"in_file",
",",
"out_file",
",",
"data",
")",
":",
"if",
"not",
"utils",
".",
"file_uptodate",
"(",
"out_file",
",",
"in_file",
")",
":",
"contigs",
"=",
"set",
"(",
"[",
"x",
".",
"name",
"for",
"x",
"in",
"ref",
".",... | Subset a BED file to only contain contigs present in the reference genome. | [
"Subset",
"a",
"BED",
"file",
"to",
"only",
"contain",
"contigs",
"present",
"in",
"the",
"reference",
"genome",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/bedutils.py#L247-L259 |
224,176 | bcbio/bcbio-nextgen | bcbio/variation/octopus.py | run | def run(align_bams, items, ref_file, assoc_files, region, out_file):
"""Run octopus variant calling, handling both somatic and germline calling.
"""
if not utils.file_exists(out_file):
paired = vcfutils.get_paired_bams(align_bams, items)
vrs = bedutils.population_variant_regions(items)
... | python | def run(align_bams, items, ref_file, assoc_files, region, out_file):
"""Run octopus variant calling, handling both somatic and germline calling.
"""
if not utils.file_exists(out_file):
paired = vcfutils.get_paired_bams(align_bams, items)
vrs = bedutils.population_variant_regions(items)
... | [
"def",
"run",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"assoc_files",
",",
"region",
",",
"out_file",
")",
":",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"paired",
"=",
"vcfutils",
".",
"get_paired_bams",
"(",
"al... | Run octopus variant calling, handling both somatic and germline calling. | [
"Run",
"octopus",
"variant",
"calling",
"handling",
"both",
"somatic",
"and",
"germline",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L17-L29 |
224,177 | bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _produce_compatible_vcf | def _produce_compatible_vcf(out_file, data, is_somatic):
"""Create a compatible VCF that downstream tools can deal with.
- htsjdk and thus GATK and Picard do not support VCF4.3:
https://github.com/broadinstitute/gatk/issues/2092
- Use octopus legacy format to avoid incompatibilities.
https://gi... | python | def _produce_compatible_vcf(out_file, data, is_somatic):
"""Create a compatible VCF that downstream tools can deal with.
- htsjdk and thus GATK and Picard do not support VCF4.3:
https://github.com/broadinstitute/gatk/issues/2092
- Use octopus legacy format to avoid incompatibilities.
https://gi... | [
"def",
"_produce_compatible_vcf",
"(",
"out_file",
",",
"data",
",",
"is_somatic",
")",
":",
"base",
",",
"ext",
"=",
"utils",
".",
"splitext_plus",
"(",
"out_file",
")",
"legacy_file",
"=",
"\"%s.legacy%s\"",
"%",
"(",
"base",
",",
"ext",
")",
"if",
"is_s... | Create a compatible VCF that downstream tools can deal with.
- htsjdk and thus GATK and Picard do not support VCF4.3:
https://github.com/broadinstitute/gatk/issues/2092
- Use octopus legacy format to avoid incompatibilities.
https://github.com/luntergroup/octopus#output-format
- Fixes `##contig... | [
"Create",
"a",
"compatible",
"VCF",
"that",
"downstream",
"tools",
"can",
"deal",
"with",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L31-L55 |
224,178 | bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _covert_to_diploid | def _covert_to_diploid(in_file, data):
"""Converts non-diploid somatic outputs into diploid.
https://github.com/luntergroup/octopus/wiki/Case-study:-Tumour-only-UMI#evaluate-variant-calls
"""
sample = dd.get_sample_name(data)
out_file = "%s-diploid.vcf" % utils.splitext_plus(in_file)[0]
in_vcf ... | python | def _covert_to_diploid(in_file, data):
"""Converts non-diploid somatic outputs into diploid.
https://github.com/luntergroup/octopus/wiki/Case-study:-Tumour-only-UMI#evaluate-variant-calls
"""
sample = dd.get_sample_name(data)
out_file = "%s-diploid.vcf" % utils.splitext_plus(in_file)[0]
in_vcf ... | [
"def",
"_covert_to_diploid",
"(",
"in_file",
",",
"data",
")",
":",
"sample",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"out_file",
"=",
"\"%s-diploid.vcf\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"in_vcf",
"=",... | Converts non-diploid somatic outputs into diploid.
https://github.com/luntergroup/octopus/wiki/Case-study:-Tumour-only-UMI#evaluate-variant-calls | [
"Converts",
"non",
"-",
"diploid",
"somatic",
"outputs",
"into",
"diploid",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L57-L81 |
224,179 | bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _run_germline | def _run_germline(align_bams, items, ref_file, target, out_file):
"""Run germline calling, handling populations.
TODO:
- We could better handle trio calling with ped inputs as octopus
has special support.
"""
align_bams = " ".join(align_bams)
cores = dd.get_num_cores(items[0])
cmd... | python | def _run_germline(align_bams, items, ref_file, target, out_file):
"""Run germline calling, handling populations.
TODO:
- We could better handle trio calling with ped inputs as octopus
has special support.
"""
align_bams = " ".join(align_bams)
cores = dd.get_num_cores(items[0])
cmd... | [
"def",
"_run_germline",
"(",
"align_bams",
",",
"items",
",",
"ref_file",
",",
"target",
",",
"out_file",
")",
":",
"align_bams",
"=",
"\" \"",
".",
"join",
"(",
"align_bams",
")",
"cores",
"=",
"dd",
".",
"get_num_cores",
"(",
"items",
"[",
"0",
"]",
... | Run germline calling, handling populations.
TODO:
- We could better handle trio calling with ped inputs as octopus
has special support. | [
"Run",
"germline",
"calling",
"handling",
"populations",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L83-L100 |
224,180 | bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _run_somatic | def _run_somatic(paired, ref_file, target, out_file):
"""Run somatic calling with octopus, handling both paired and tumor-only cases.
Tweaks for low frequency, tumor only and UMI calling documented in:
https://github.com/luntergroup/octopus/blob/develop/configs/UMI.config
"""
align_bams = paired.tu... | python | def _run_somatic(paired, ref_file, target, out_file):
"""Run somatic calling with octopus, handling both paired and tumor-only cases.
Tweaks for low frequency, tumor only and UMI calling documented in:
https://github.com/luntergroup/octopus/blob/develop/configs/UMI.config
"""
align_bams = paired.tu... | [
"def",
"_run_somatic",
"(",
"paired",
",",
"ref_file",
",",
"target",
",",
"out_file",
")",
":",
"align_bams",
"=",
"paired",
".",
"tumor_bam",
"if",
"paired",
".",
"normal_bam",
":",
"align_bams",
"+=",
"\" %s --normal-sample %s\"",
"%",
"(",
"paired",
".",
... | Run somatic calling with octopus, handling both paired and tumor-only cases.
Tweaks for low frequency, tumor only and UMI calling documented in:
https://github.com/luntergroup/octopus/blob/develop/configs/UMI.config | [
"Run",
"somatic",
"calling",
"with",
"octopus",
"handling",
"both",
"paired",
"and",
"tumor",
"-",
"only",
"cases",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L102-L135 |
224,181 | bcbio/bcbio-nextgen | bcbio/variation/octopus.py | _is_umi_consensus_bam | def _is_umi_consensus_bam(in_file):
"""Check if input BAM file generated by fgbio consensus calls on UMIs.
Identify these by lack of duplicated reads.
This is useful for pre-aligned consensus BAMs feeding into octopus.
"""
cmd = "samtools view -h %s | head -500000 | samtools view -c -f 1024"
co... | python | def _is_umi_consensus_bam(in_file):
"""Check if input BAM file generated by fgbio consensus calls on UMIs.
Identify these by lack of duplicated reads.
This is useful for pre-aligned consensus BAMs feeding into octopus.
"""
cmd = "samtools view -h %s | head -500000 | samtools view -c -f 1024"
co... | [
"def",
"_is_umi_consensus_bam",
"(",
"in_file",
")",
":",
"cmd",
"=",
"\"samtools view -h %s | head -500000 | samtools view -c -f 1024\"",
"count",
"=",
"subprocess",
".",
"check_output",
"(",
"cmd",
"%",
"in_file",
",",
"shell",
"=",
"True",
")",
"return",
"int",
"... | Check if input BAM file generated by fgbio consensus calls on UMIs.
Identify these by lack of duplicated reads.
This is useful for pre-aligned consensus BAMs feeding into octopus. | [
"Check",
"if",
"input",
"BAM",
"file",
"generated",
"by",
"fgbio",
"consensus",
"calls",
"on",
"UMIs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/octopus.py#L137-L145 |
224,182 | bcbio/bcbio-nextgen | bcbio/upload/s3.py | update_file | def update_file(finfo, sample_info, config):
"""Update the file to an Amazon S3 bucket, using server side encryption.
"""
ffinal = filesystem.update_file(finfo, sample_info, config, pass_uptodate=True)
if os.path.isdir(ffinal):
to_transfer = []
for path, dirs, files in os.walk(ffinal):
... | python | def update_file(finfo, sample_info, config):
"""Update the file to an Amazon S3 bucket, using server side encryption.
"""
ffinal = filesystem.update_file(finfo, sample_info, config, pass_uptodate=True)
if os.path.isdir(ffinal):
to_transfer = []
for path, dirs, files in os.walk(ffinal):
... | [
"def",
"update_file",
"(",
"finfo",
",",
"sample_info",
",",
"config",
")",
":",
"ffinal",
"=",
"filesystem",
".",
"update_file",
"(",
"finfo",
",",
"sample_info",
",",
"config",
",",
"pass_uptodate",
"=",
"True",
")",
"if",
"os",
".",
"path",
".",
"isdi... | Update the file to an Amazon S3 bucket, using server side encryption. | [
"Update",
"the",
"file",
"to",
"an",
"Amazon",
"S3",
"bucket",
"using",
"server",
"side",
"encryption",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/s3.py#L20-L49 |
224,183 | bcbio/bcbio-nextgen | bcbio/upload/s3.py | _upload_file_aws_cli | def _upload_file_aws_cli(local_fname, bucket, keyname, config=None, mditems=None):
"""Streaming upload via the standard AWS command line interface.
"""
s3_fname = "s3://%s/%s" % (bucket, keyname)
args = ["--sse", "--expected-size", str(os.path.getsize(local_fname))]
if config:
if config.get(... | python | def _upload_file_aws_cli(local_fname, bucket, keyname, config=None, mditems=None):
"""Streaming upload via the standard AWS command line interface.
"""
s3_fname = "s3://%s/%s" % (bucket, keyname)
args = ["--sse", "--expected-size", str(os.path.getsize(local_fname))]
if config:
if config.get(... | [
"def",
"_upload_file_aws_cli",
"(",
"local_fname",
",",
"bucket",
",",
"keyname",
",",
"config",
"=",
"None",
",",
"mditems",
"=",
"None",
")",
":",
"s3_fname",
"=",
"\"s3://%s/%s\"",
"%",
"(",
"bucket",
",",
"keyname",
")",
"args",
"=",
"[",
"\"--sse\"",
... | Streaming upload via the standard AWS command line interface. | [
"Streaming",
"upload",
"via",
"the",
"standard",
"AWS",
"command",
"line",
"interface",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/s3.py#L69-L81 |
224,184 | bcbio/bcbio-nextgen | bcbio/upload/s3.py | upload_file_boto | def upload_file_boto(fname, remote_fname, mditems=None):
"""Upload a file using boto instead of external tools.
"""
r_fname = objectstore.parse_remote(remote_fname)
conn = objectstore.connect(remote_fname)
bucket = conn.lookup(r_fname.bucket)
if not bucket:
bucket = conn.create_bucket(r_... | python | def upload_file_boto(fname, remote_fname, mditems=None):
"""Upload a file using boto instead of external tools.
"""
r_fname = objectstore.parse_remote(remote_fname)
conn = objectstore.connect(remote_fname)
bucket = conn.lookup(r_fname.bucket)
if not bucket:
bucket = conn.create_bucket(r_... | [
"def",
"upload_file_boto",
"(",
"fname",
",",
"remote_fname",
",",
"mditems",
"=",
"None",
")",
":",
"r_fname",
"=",
"objectstore",
".",
"parse_remote",
"(",
"remote_fname",
")",
"conn",
"=",
"objectstore",
".",
"connect",
"(",
"remote_fname",
")",
"bucket",
... | Upload a file using boto instead of external tools. | [
"Upload",
"a",
"file",
"using",
"boto",
"instead",
"of",
"external",
"tools",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/s3.py#L83-L98 |
224,185 | bcbio/bcbio-nextgen | bcbio/qc/chipseq.py | run | def run(bam_file, sample, out_dir):
"""Standard QC metrics for chipseq"""
out = {}
# if "rchipqc" in dd.get_tools_on(sample):
# out = chipqc(bam_file, sample, out_dir)
peaks = sample.get("peaks_files", {}).get("main")
if peaks:
out.update(_reads_in_peaks(bam_file, peaks, sample))
... | python | def run(bam_file, sample, out_dir):
"""Standard QC metrics for chipseq"""
out = {}
# if "rchipqc" in dd.get_tools_on(sample):
# out = chipqc(bam_file, sample, out_dir)
peaks = sample.get("peaks_files", {}).get("main")
if peaks:
out.update(_reads_in_peaks(bam_file, peaks, sample))
... | [
"def",
"run",
"(",
"bam_file",
",",
"sample",
",",
"out_dir",
")",
":",
"out",
"=",
"{",
"}",
"# if \"rchipqc\" in dd.get_tools_on(sample):",
"# out = chipqc(bam_file, sample, out_dir)",
"peaks",
"=",
"sample",
".",
"get",
"(",
"\"peaks_files\"",
",",
"{",
"}",
... | Standard QC metrics for chipseq | [
"Standard",
"QC",
"metrics",
"for",
"chipseq"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/chipseq.py#L16-L25 |
224,186 | bcbio/bcbio-nextgen | bcbio/qc/chipseq.py | _reads_in_peaks | def _reads_in_peaks(bam_file, peaks_file, sample):
"""Calculate number of reads in peaks"""
if not peaks_file:
return {}
rip = number_of_mapped_reads(sample, bam_file, bed_file = peaks_file)
return {"metrics": {"RiP": rip}} | python | def _reads_in_peaks(bam_file, peaks_file, sample):
"""Calculate number of reads in peaks"""
if not peaks_file:
return {}
rip = number_of_mapped_reads(sample, bam_file, bed_file = peaks_file)
return {"metrics": {"RiP": rip}} | [
"def",
"_reads_in_peaks",
"(",
"bam_file",
",",
"peaks_file",
",",
"sample",
")",
":",
"if",
"not",
"peaks_file",
":",
"return",
"{",
"}",
"rip",
"=",
"number_of_mapped_reads",
"(",
"sample",
",",
"bam_file",
",",
"bed_file",
"=",
"peaks_file",
")",
"return"... | Calculate number of reads in peaks | [
"Calculate",
"number",
"of",
"reads",
"in",
"peaks"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/chipseq.py#L27-L32 |
224,187 | bcbio/bcbio-nextgen | bcbio/qc/chipseq.py | chipqc | def chipqc(bam_file, sample, out_dir):
"""Attempt code to run ChIPQC bioconductor packate in one sample"""
sample_name = dd.get_sample_name(sample)
logger.warning("ChIPQC is unstable right now, if it breaks, turn off the tool.")
if utils.file_exists(out_dir):
return _get_output(out_dir)
with... | python | def chipqc(bam_file, sample, out_dir):
"""Attempt code to run ChIPQC bioconductor packate in one sample"""
sample_name = dd.get_sample_name(sample)
logger.warning("ChIPQC is unstable right now, if it breaks, turn off the tool.")
if utils.file_exists(out_dir):
return _get_output(out_dir)
with... | [
"def",
"chipqc",
"(",
"bam_file",
",",
"sample",
",",
"out_dir",
")",
":",
"sample_name",
"=",
"dd",
".",
"get_sample_name",
"(",
"sample",
")",
"logger",
".",
"warning",
"(",
"\"ChIPQC is unstable right now, if it breaks, turn off the tool.\"",
")",
"if",
"utils",
... | Attempt code to run ChIPQC bioconductor packate in one sample | [
"Attempt",
"code",
"to",
"run",
"ChIPQC",
"bioconductor",
"packate",
"in",
"one",
"sample"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/chipseq.py#L34-L47 |
224,188 | bcbio/bcbio-nextgen | bcbio/qc/chipseq.py | _sample_template | def _sample_template(sample, out_dir):
"""R code to get QC for one sample"""
bam_fn = dd.get_work_bam(sample)
genome = dd.get_genome_build(sample)
if genome in supported:
peaks = sample.get("peaks_files", []).get("main")
if peaks:
r_code = ("library(ChIPQC);\n"
... | python | def _sample_template(sample, out_dir):
"""R code to get QC for one sample"""
bam_fn = dd.get_work_bam(sample)
genome = dd.get_genome_build(sample)
if genome in supported:
peaks = sample.get("peaks_files", []).get("main")
if peaks:
r_code = ("library(ChIPQC);\n"
... | [
"def",
"_sample_template",
"(",
"sample",
",",
"out_dir",
")",
":",
"bam_fn",
"=",
"dd",
".",
"get_work_bam",
"(",
"sample",
")",
"genome",
"=",
"dd",
".",
"get_genome_build",
"(",
"sample",
")",
"if",
"genome",
"in",
"supported",
":",
"peaks",
"=",
"sam... | R code to get QC for one sample | [
"R",
"code",
"to",
"get",
"QC",
"for",
"one",
"sample"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/chipseq.py#L56-L72 |
224,189 | bcbio/bcbio-nextgen | bcbio/rnaseq/featureCounts.py | _change_sample_name | def _change_sample_name(in_file, sample_name, data=None):
"""Fix name in feature counts log file to get the same
name in multiqc report.
"""
out_file = append_stem(in_file, "_fixed")
with file_transaction(data, out_file) as tx_out:
with open(tx_out, "w") as out_handle:
with op... | python | def _change_sample_name(in_file, sample_name, data=None):
"""Fix name in feature counts log file to get the same
name in multiqc report.
"""
out_file = append_stem(in_file, "_fixed")
with file_transaction(data, out_file) as tx_out:
with open(tx_out, "w") as out_handle:
with op... | [
"def",
"_change_sample_name",
"(",
"in_file",
",",
"sample_name",
",",
"data",
"=",
"None",
")",
":",
"out_file",
"=",
"append_stem",
"(",
"in_file",
",",
"\"_fixed\"",
")",
"with",
"file_transaction",
"(",
"data",
",",
"out_file",
")",
"as",
"tx_out",
":",
... | Fix name in feature counts log file to get the same
name in multiqc report. | [
"Fix",
"name",
"in",
"feature",
"counts",
"log",
"file",
"to",
"get",
"the",
"same",
"name",
"in",
"multiqc",
"report",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/featureCounts.py#L57-L69 |
224,190 | bcbio/bcbio-nextgen | bcbio/rnaseq/featureCounts.py | _format_count_file | def _format_count_file(count_file, data):
"""
this cuts the count file produced from featureCounts down to
a two column file of gene ids and number of reads mapping to
each gene
"""
COUNT_COLUMN = 5
out_file = os.path.splitext(count_file)[0] + ".fixed.counts"
if file_exists(out_file):
... | python | def _format_count_file(count_file, data):
"""
this cuts the count file produced from featureCounts down to
a two column file of gene ids and number of reads mapping to
each gene
"""
COUNT_COLUMN = 5
out_file = os.path.splitext(count_file)[0] + ".fixed.counts"
if file_exists(out_file):
... | [
"def",
"_format_count_file",
"(",
"count_file",
",",
"data",
")",
":",
"COUNT_COLUMN",
"=",
"5",
"out_file",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"count_file",
")",
"[",
"0",
"]",
"+",
"\".fixed.counts\"",
"if",
"file_exists",
"(",
"out_file",
")"... | this cuts the count file produced from featureCounts down to
a two column file of gene ids and number of reads mapping to
each gene | [
"this",
"cuts",
"the",
"count",
"file",
"produced",
"from",
"featureCounts",
"down",
"to",
"a",
"two",
"column",
"file",
"of",
"gene",
"ids",
"and",
"number",
"of",
"reads",
"mapping",
"to",
"each",
"gene"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/featureCounts.py#L71-L86 |
224,191 | bcbio/bcbio-nextgen | bcbio/variation/peddy.py | run_qc | def run_qc(_, data, out_dir):
"""Run quality control in QC environment on a single sample.
Enables peddy integration with CWL runs.
"""
if cwlutils.is_cwl_run(data):
qc_data = run_peddy([data], out_dir)
if tz.get_in(["summary", "qc", "peddy"], qc_data):
return tz.get_in(["su... | python | def run_qc(_, data, out_dir):
"""Run quality control in QC environment on a single sample.
Enables peddy integration with CWL runs.
"""
if cwlutils.is_cwl_run(data):
qc_data = run_peddy([data], out_dir)
if tz.get_in(["summary", "qc", "peddy"], qc_data):
return tz.get_in(["su... | [
"def",
"run_qc",
"(",
"_",
",",
"data",
",",
"out_dir",
")",
":",
"if",
"cwlutils",
".",
"is_cwl_run",
"(",
"data",
")",
":",
"qc_data",
"=",
"run_peddy",
"(",
"[",
"data",
"]",
",",
"out_dir",
")",
"if",
"tz",
".",
"get_in",
"(",
"[",
"\"summary\"... | Run quality control in QC environment on a single sample.
Enables peddy integration with CWL runs. | [
"Run",
"quality",
"control",
"in",
"QC",
"environment",
"on",
"a",
"single",
"sample",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/peddy.py#L35-L43 |
224,192 | bcbio/bcbio-nextgen | bcbio/chipseq/macs2.py | run | def run(name, chip_bam, input_bam, genome_build, out_dir, method, resources, data):
"""
Run macs2 for chip and input samples avoiding
errors due to samples.
"""
# output file name need to have the caller name
config = dd.get_config(data)
out_file = os.path.join(out_dir, name + "_peaks_macs2.... | python | def run(name, chip_bam, input_bam, genome_build, out_dir, method, resources, data):
"""
Run macs2 for chip and input samples avoiding
errors due to samples.
"""
# output file name need to have the caller name
config = dd.get_config(data)
out_file = os.path.join(out_dir, name + "_peaks_macs2.... | [
"def",
"run",
"(",
"name",
",",
"chip_bam",
",",
"input_bam",
",",
"genome_build",
",",
"out_dir",
",",
"method",
",",
"resources",
",",
"data",
")",
":",
"# output file name need to have the caller name",
"config",
"=",
"dd",
".",
"get_config",
"(",
"data",
"... | Run macs2 for chip and input samples avoiding
errors due to samples. | [
"Run",
"macs2",
"for",
"chip",
"and",
"input",
"samples",
"avoiding",
"errors",
"due",
"to",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/macs2.py#L11-L41 |
224,193 | bcbio/bcbio-nextgen | bcbio/chipseq/macs2.py | _macs2_cmd | def _macs2_cmd(method="chip"):
"""Main command for macs2 tool."""
if method.lower() == "chip":
cmd = ("{macs2} callpeak -t {chip_bam} -c {input_bam} {paired} "
" {genome_size} -n {name} -B {options}")
elif method.lower() == "atac":
cmd = ("{macs2} callpeak -t {chip_bam} --nom... | python | def _macs2_cmd(method="chip"):
"""Main command for macs2 tool."""
if method.lower() == "chip":
cmd = ("{macs2} callpeak -t {chip_bam} -c {input_bam} {paired} "
" {genome_size} -n {name} -B {options}")
elif method.lower() == "atac":
cmd = ("{macs2} callpeak -t {chip_bam} --nom... | [
"def",
"_macs2_cmd",
"(",
"method",
"=",
"\"chip\"",
")",
":",
"if",
"method",
".",
"lower",
"(",
")",
"==",
"\"chip\"",
":",
"cmd",
"=",
"(",
"\"{macs2} callpeak -t {chip_bam} -c {input_bam} {paired} \"",
"\" {genome_size} -n {name} -B {options}\"",
")",
"elif",
"met... | Main command for macs2 tool. | [
"Main",
"command",
"for",
"macs2",
"tool",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/macs2.py#L60-L71 |
224,194 | bcbio/bcbio-nextgen | bcbio/pipeline/archive.py | to_cram | def to_cram(data):
"""Convert BAM archive files into indexed CRAM.
"""
data = utils.to_single_data(data)
cram_file = cram.compress(dd.get_work_bam(data) or dd.get_align_bam(data), data)
out_key = "archive_bam" if cwlutils.is_cwl_run(data) else "work_bam"
data[out_key] = cram_file
return [[da... | python | def to_cram(data):
"""Convert BAM archive files into indexed CRAM.
"""
data = utils.to_single_data(data)
cram_file = cram.compress(dd.get_work_bam(data) or dd.get_align_bam(data), data)
out_key = "archive_bam" if cwlutils.is_cwl_run(data) else "work_bam"
data[out_key] = cram_file
return [[da... | [
"def",
"to_cram",
"(",
"data",
")",
":",
"data",
"=",
"utils",
".",
"to_single_data",
"(",
"data",
")",
"cram_file",
"=",
"cram",
".",
"compress",
"(",
"dd",
".",
"get_work_bam",
"(",
"data",
")",
"or",
"dd",
".",
"get_align_bam",
"(",
"data",
")",
"... | Convert BAM archive files into indexed CRAM. | [
"Convert",
"BAM",
"archive",
"files",
"into",
"indexed",
"CRAM",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/archive.py#L11-L18 |
224,195 | bcbio/bcbio-nextgen | bcbio/pipeline/archive.py | compress | def compress(samples, run_parallel):
"""Perform compression of output files for long term storage.
"""
to_cram = []
finished = []
for data in [x[0] for x in samples]:
if "cram" in dd.get_archive(data) or "cram-lossless" in dd.get_archive(data):
to_cram.append([data])
else... | python | def compress(samples, run_parallel):
"""Perform compression of output files for long term storage.
"""
to_cram = []
finished = []
for data in [x[0] for x in samples]:
if "cram" in dd.get_archive(data) or "cram-lossless" in dd.get_archive(data):
to_cram.append([data])
else... | [
"def",
"compress",
"(",
"samples",
",",
"run_parallel",
")",
":",
"to_cram",
"=",
"[",
"]",
"finished",
"=",
"[",
"]",
"for",
"data",
"in",
"[",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"samples",
"]",
":",
"if",
"\"cram\"",
"in",
"dd",
".",
"get_ar... | Perform compression of output files for long term storage. | [
"Perform",
"compression",
"of",
"output",
"files",
"for",
"long",
"term",
"storage",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/archive.py#L20-L31 |
224,196 | bcbio/bcbio-nextgen | bcbio/qc/samtools.py | run | def run(_, data, out_dir=None):
"""Run samtools stats with reports on mapped reads, duplicates and insert sizes.
"""
stats_file, idxstats_file = _get_stats_files(data, out_dir)
samtools = config_utils.get_program("samtools", data["config"])
bam_file = dd.get_align_bam(data) or dd.get_work_bam(data)
... | python | def run(_, data, out_dir=None):
"""Run samtools stats with reports on mapped reads, duplicates and insert sizes.
"""
stats_file, idxstats_file = _get_stats_files(data, out_dir)
samtools = config_utils.get_program("samtools", data["config"])
bam_file = dd.get_align_bam(data) or dd.get_work_bam(data)
... | [
"def",
"run",
"(",
"_",
",",
"data",
",",
"out_dir",
"=",
"None",
")",
":",
"stats_file",
",",
"idxstats_file",
"=",
"_get_stats_files",
"(",
"data",
",",
"out_dir",
")",
"samtools",
"=",
"config_utils",
".",
"get_program",
"(",
"\"samtools\"",
",",
"data"... | Run samtools stats with reports on mapped reads, duplicates and insert sizes. | [
"Run",
"samtools",
"stats",
"with",
"reports",
"on",
"mapped",
"reads",
"duplicates",
"and",
"insert",
"sizes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/samtools.py#L13-L34 |
224,197 | bcbio/bcbio-nextgen | bcbio/qc/samtools.py | run_and_save | def run_and_save(data):
"""Run QC, saving file outputs in data dictionary.
"""
run(None, data)
stats_file, idxstats_file = _get_stats_files(data)
data = tz.update_in(data, ["depth", "samtools", "stats"], lambda x: stats_file)
data = tz.update_in(data, ["depth", "samtools", "idxstats"], lambda x:... | python | def run_and_save(data):
"""Run QC, saving file outputs in data dictionary.
"""
run(None, data)
stats_file, idxstats_file = _get_stats_files(data)
data = tz.update_in(data, ["depth", "samtools", "stats"], lambda x: stats_file)
data = tz.update_in(data, ["depth", "samtools", "idxstats"], lambda x:... | [
"def",
"run_and_save",
"(",
"data",
")",
":",
"run",
"(",
"None",
",",
"data",
")",
"stats_file",
",",
"idxstats_file",
"=",
"_get_stats_files",
"(",
"data",
")",
"data",
"=",
"tz",
".",
"update_in",
"(",
"data",
",",
"[",
"\"depth\"",
",",
"\"samtools\"... | Run QC, saving file outputs in data dictionary. | [
"Run",
"QC",
"saving",
"file",
"outputs",
"in",
"data",
"dictionary",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/samtools.py#L36-L43 |
224,198 | bcbio/bcbio-nextgen | bcbio/qc/samtools.py | _get_stats_files | def _get_stats_files(data, out_dir=None):
"""Retrieve stats files from pre-existing dictionary or filesystem.
"""
if not out_dir:
out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data),
"qc", dd.get_sample_name(data), "samtools"))
stats_... | python | def _get_stats_files(data, out_dir=None):
"""Retrieve stats files from pre-existing dictionary or filesystem.
"""
if not out_dir:
out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data),
"qc", dd.get_sample_name(data), "samtools"))
stats_... | [
"def",
"_get_stats_files",
"(",
"data",
",",
"out_dir",
"=",
"None",
")",
":",
"if",
"not",
"out_dir",
":",
"out_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dd",
".",
"get_work_dir",
"(",
"data",
")",
",",
"\"q... | Retrieve stats files from pre-existing dictionary or filesystem. | [
"Retrieve",
"stats",
"files",
"from",
"pre",
"-",
"existing",
"dictionary",
"or",
"filesystem",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/samtools.py#L45-L57 |
224,199 | bcbio/bcbio-nextgen | bcbio/provenance/do.py | _descr_str | def _descr_str(descr, data, region):
"""Add additional useful information from data to description string.
"""
if data:
name = dd.get_sample_name(data)
if name:
descr = "{0} : {1}".format(descr, name)
elif "work_bam" in data:
descr = "{0} : {1}".format(descr, ... | python | def _descr_str(descr, data, region):
"""Add additional useful information from data to description string.
"""
if data:
name = dd.get_sample_name(data)
if name:
descr = "{0} : {1}".format(descr, name)
elif "work_bam" in data:
descr = "{0} : {1}".format(descr, ... | [
"def",
"_descr_str",
"(",
"descr",
",",
"data",
",",
"region",
")",
":",
"if",
"data",
":",
"name",
"=",
"dd",
".",
"get_sample_name",
"(",
"data",
")",
"if",
"name",
":",
"descr",
"=",
"\"{0} : {1}\"",
".",
"format",
"(",
"descr",
",",
"name",
")",
... | Add additional useful information from data to description string. | [
"Add",
"additional",
"useful",
"information",
"from",
"data",
"to",
"description",
"string",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/provenance/do.py#L35-L46 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.