repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _bgzip_from_cram | def _bgzip_from_cram(cram_file, dirs, data):
"""Create bgzipped fastq files from an input CRAM file in regions of interest.
Returns a list with a single file, for single end CRAM files, or two
files for paired end input.
"""
import pybedtools
region_file = (tz.get_in(["config", "algorithm", "va... | python | def _bgzip_from_cram(cram_file, dirs, data):
"""Create bgzipped fastq files from an input CRAM file in regions of interest.
Returns a list with a single file, for single end CRAM files, or two
files for paired end input.
"""
import pybedtools
region_file = (tz.get_in(["config", "algorithm", "va... | [
"def",
"_bgzip_from_cram",
"(",
"cram_file",
",",
"dirs",
",",
"data",
")",
":",
"import",
"pybedtools",
"region_file",
"=",
"(",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
",",
"\"algorithm\"",
",",
"\"variant_regions\"",
"]",
",",
"data",
")",
"if",
"t... | Create bgzipped fastq files from an input CRAM file in regions of interest.
Returns a list with a single file, for single end CRAM files, or two
files for paired end input. | [
"Create",
"bgzipped",
"fastq",
"files",
"from",
"an",
"input",
"CRAM",
"file",
"in",
"regions",
"of",
"interest",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L402-L439 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _bgzip_from_cram_sambamba | def _bgzip_from_cram_sambamba(cram_file, dirs, data):
"""Use sambamba to extract from CRAM via regions.
"""
raise NotImplementedError("sambamba doesn't yet support retrieval from CRAM by BED file")
region_file = (tz.get_in(["config", "algorithm", "variant_regions"], data)
if tz.get_in... | python | def _bgzip_from_cram_sambamba(cram_file, dirs, data):
"""Use sambamba to extract from CRAM via regions.
"""
raise NotImplementedError("sambamba doesn't yet support retrieval from CRAM by BED file")
region_file = (tz.get_in(["config", "algorithm", "variant_regions"], data)
if tz.get_in... | [
"def",
"_bgzip_from_cram_sambamba",
"(",
"cram_file",
",",
"dirs",
",",
"data",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"sambamba doesn't yet support retrieval from CRAM by BED file\"",
")",
"region_file",
"=",
"(",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
... | Use sambamba to extract from CRAM via regions. | [
"Use",
"sambamba",
"to",
"extract",
"from",
"CRAM",
"via",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L441-L457 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _cram_to_fastq_regions | def _cram_to_fastq_regions(regions, cram_file, dirs, data):
"""Convert CRAM files to fastq, potentially within sub regions.
Returns multiple fastq files that can be merged back together.
"""
base_name = utils.splitext_plus(os.path.basename(cram_file))[0]
work_dir = utils.safe_makedir(os.path.join(d... | python | def _cram_to_fastq_regions(regions, cram_file, dirs, data):
"""Convert CRAM files to fastq, potentially within sub regions.
Returns multiple fastq files that can be merged back together.
"""
base_name = utils.splitext_plus(os.path.basename(cram_file))[0]
work_dir = utils.safe_makedir(os.path.join(d... | [
"def",
"_cram_to_fastq_regions",
"(",
"regions",
",",
"cram_file",
",",
"dirs",
",",
"data",
")",
":",
"base_name",
"=",
"utils",
".",
"splitext_plus",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"cram_file",
")",
")",
"[",
"0",
"]",
"work_dir",
"=",
... | Convert CRAM files to fastq, potentially within sub regions.
Returns multiple fastq files that can be merged back together. | [
"Convert",
"CRAM",
"files",
"to",
"fastq",
"potentially",
"within",
"sub",
"regions",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L482-L498 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _cram_to_fastq_region | def _cram_to_fastq_region(cram_file, work_dir, base_name, region, data):
"""Convert CRAM to fastq in a specified region.
"""
ref_file = tz.get_in(["reference", "fasta", "base"], data)
resources = config_utils.get_resources("bamtofastq", data["config"])
cores = tz.get_in(["config", "algorithm", "num_... | python | def _cram_to_fastq_region(cram_file, work_dir, base_name, region, data):
"""Convert CRAM to fastq in a specified region.
"""
ref_file = tz.get_in(["reference", "fasta", "base"], data)
resources = config_utils.get_resources("bamtofastq", data["config"])
cores = tz.get_in(["config", "algorithm", "num_... | [
"def",
"_cram_to_fastq_region",
"(",
"cram_file",
",",
"work_dir",
",",
"base_name",
",",
"region",
",",
"data",
")",
":",
"ref_file",
"=",
"tz",
".",
"get_in",
"(",
"[",
"\"reference\"",
",",
"\"fasta\"",
",",
"\"base\"",
"]",
",",
"data",
")",
"resources... | Convert CRAM to fastq in a specified region. | [
"Convert",
"CRAM",
"to",
"fastq",
"in",
"a",
"specified",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L502-L525 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _bgzip_from_bam | def _bgzip_from_bam(bam_file, dirs, data, is_retry=False, output_infix=''):
"""Create bgzipped fastq files from an input BAM file.
"""
# tools
config = data["config"]
bamtofastq = config_utils.get_program("bamtofastq", config)
resources = config_utils.get_resources("bamtofastq", config)
core... | python | def _bgzip_from_bam(bam_file, dirs, data, is_retry=False, output_infix=''):
"""Create bgzipped fastq files from an input BAM file.
"""
# tools
config = data["config"]
bamtofastq = config_utils.get_program("bamtofastq", config)
resources = config_utils.get_resources("bamtofastq", config)
core... | [
"def",
"_bgzip_from_bam",
"(",
"bam_file",
",",
"dirs",
",",
"data",
",",
"is_retry",
"=",
"False",
",",
"output_infix",
"=",
"''",
")",
":",
"# tools",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"bamtofastq",
"=",
"config_utils",
".",
"get_program",
"... | Create bgzipped fastq files from an input BAM file. | [
"Create",
"bgzipped",
"fastq",
"files",
"from",
"an",
"input",
"BAM",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L532-L586 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _grabix_index | def _grabix_index(data):
"""Create grabix index of bgzip input file.
grabix does not allow specification of output file, so symlink the original
file into a transactional directory.
"""
in_file = data["bgzip_file"]
config = data["config"]
grabix = config_utils.get_program("grabix", config)
... | python | def _grabix_index(data):
"""Create grabix index of bgzip input file.
grabix does not allow specification of output file, so symlink the original
file into a transactional directory.
"""
in_file = data["bgzip_file"]
config = data["config"]
grabix = config_utils.get_program("grabix", config)
... | [
"def",
"_grabix_index",
"(",
"data",
")",
":",
"in_file",
"=",
"data",
"[",
"\"bgzip_file\"",
"]",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"grabix",
"=",
"config_utils",
".",
"get_program",
"(",
"\"grabix\"",
",",
"config",
")",
"gbi_file",
"=",
"_g... | Create grabix index of bgzip input file.
grabix does not allow specification of output file, so symlink the original
file into a transactional directory. | [
"Create",
"grabix",
"index",
"of",
"bgzip",
"input",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L590-L611 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _is_partial_index | def _is_partial_index(gbi_file):
"""Check for truncated output since grabix doesn't write to a transactional directory.
"""
with open(gbi_file) as in_handle:
for i, _ in enumerate(in_handle):
if i > 2:
return False
return True | python | def _is_partial_index(gbi_file):
"""Check for truncated output since grabix doesn't write to a transactional directory.
"""
with open(gbi_file) as in_handle:
for i, _ in enumerate(in_handle):
if i > 2:
return False
return True | [
"def",
"_is_partial_index",
"(",
"gbi_file",
")",
":",
"with",
"open",
"(",
"gbi_file",
")",
"as",
"in_handle",
":",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"in_handle",
")",
":",
"if",
"i",
">",
"2",
":",
"return",
"False",
"return",
"True"
] | Check for truncated output since grabix doesn't write to a transactional directory. | [
"Check",
"for",
"truncated",
"output",
"since",
"grabix",
"doesn",
"t",
"write",
"to",
"a",
"transactional",
"directory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L613-L620 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _bgzip_file | def _bgzip_file(finput, config, work_dir, needs_bgzip, needs_gunzip, needs_convert, data):
"""Handle bgzip of input file, potentially gunzipping an existing file.
Handles cases where finput might be multiple files and need to be concatenated.
"""
if isinstance(finput, six.string_types):
in_file... | python | def _bgzip_file(finput, config, work_dir, needs_bgzip, needs_gunzip, needs_convert, data):
"""Handle bgzip of input file, potentially gunzipping an existing file.
Handles cases where finput might be multiple files and need to be concatenated.
"""
if isinstance(finput, six.string_types):
in_file... | [
"def",
"_bgzip_file",
"(",
"finput",
",",
"config",
",",
"work_dir",
",",
"needs_bgzip",
",",
"needs_gunzip",
",",
"needs_convert",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"finput",
",",
"six",
".",
"string_types",
")",
":",
"in_file",
"=",
"finput... | Handle bgzip of input file, potentially gunzipping an existing file.
Handles cases where finput might be multiple files and need to be concatenated. | [
"Handle",
"bgzip",
"of",
"input",
"file",
"potentially",
"gunzipping",
"an",
"existing",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L659-L697 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/alignprep.py | _check_gzipped_input | def _check_gzipped_input(in_file, data):
"""Determine if a gzipped input file is blocked gzip or standard.
"""
grabix = config_utils.get_program("grabix", data["config"])
is_bgzip = subprocess.check_output([grabix, "check", in_file])
if is_bgzip.strip() == "yes":
return False, False
else... | python | def _check_gzipped_input(in_file, data):
"""Determine if a gzipped input file is blocked gzip or standard.
"""
grabix = config_utils.get_program("grabix", data["config"])
is_bgzip = subprocess.check_output([grabix, "check", in_file])
if is_bgzip.strip() == "yes":
return False, False
else... | [
"def",
"_check_gzipped_input",
"(",
"in_file",
",",
"data",
")",
":",
"grabix",
"=",
"config_utils",
".",
"get_program",
"(",
"\"grabix\"",
",",
"data",
"[",
"\"config\"",
"]",
")",
"is_bgzip",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"grabix",
",",... | Determine if a gzipped input file is blocked gzip or standard. | [
"Determine",
"if",
"a",
"gzipped",
"input",
"file",
"is",
"blocked",
"gzip",
"or",
"standard",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/alignprep.py#L715-L723 | train |
bcbio/bcbio-nextgen | bcbio/qc/fastqc.py | run | def run(bam_file, data, fastqc_out):
"""Run fastqc, generating report in specified directory and parsing metrics.
Downsamples to 10 million reads to avoid excessive processing times with large
files, unless we're running a Standard/smallRNA-seq/QC pipeline.
Handles fastqc 0.11+, which use a single HTM... | python | def run(bam_file, data, fastqc_out):
"""Run fastqc, generating report in specified directory and parsing metrics.
Downsamples to 10 million reads to avoid excessive processing times with large
files, unless we're running a Standard/smallRNA-seq/QC pipeline.
Handles fastqc 0.11+, which use a single HTM... | [
"def",
"run",
"(",
"bam_file",
",",
"data",
",",
"fastqc_out",
")",
":",
"sentry_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"fastqc_out",
",",
"\"fastqc_report.html\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"sentry_file",
")",
... | Run fastqc, generating report in specified directory and parsing metrics.
Downsamples to 10 million reads to avoid excessive processing times with large
files, unless we're running a Standard/smallRNA-seq/QC pipeline.
Handles fastqc 0.11+, which use a single HTML file and older versions that use
a dir... | [
"Run",
"fastqc",
"generating",
"report",
"in",
"specified",
"directory",
"and",
"parsing",
"metrics",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/fastqc.py#L21-L70 | train |
bcbio/bcbio-nextgen | bcbio/qc/fastqc.py | FastQCParser._get_module | def _get_module(self, parser, module):
"""
Get module using fadapa package
"""
dt = []
lines = parser.clean_data(module)
header = lines[0]
for data in lines[1:]:
if data[0].startswith("#"): # some modules have two headers
header = data... | python | def _get_module(self, parser, module):
"""
Get module using fadapa package
"""
dt = []
lines = parser.clean_data(module)
header = lines[0]
for data in lines[1:]:
if data[0].startswith("#"): # some modules have two headers
header = data... | [
"def",
"_get_module",
"(",
"self",
",",
"parser",
",",
"module",
")",
":",
"dt",
"=",
"[",
"]",
"lines",
"=",
"parser",
".",
"clean_data",
"(",
"module",
")",
"header",
"=",
"lines",
"[",
"0",
"]",
"for",
"data",
"in",
"lines",
"[",
"1",
":",
"]"... | Get module using fadapa package | [
"Get",
"module",
"using",
"fadapa",
"package"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/fastqc.py#L113-L133 | train |
bcbio/bcbio-nextgen | bcbio/server/background.py | GenericSubprocess.start | def start(self):
"""Spawn the task.
Throws RuntimeError if the task was already started."""
if not self.pipe is None:
raise RuntimeError("Cannot start task twice")
self.ioloop = tornado.ioloop.IOLoop.instance()
if self.timeout > 0:
self.expiration = self... | python | def start(self):
"""Spawn the task.
Throws RuntimeError if the task was already started."""
if not self.pipe is None:
raise RuntimeError("Cannot start task twice")
self.ioloop = tornado.ioloop.IOLoop.instance()
if self.timeout > 0:
self.expiration = self... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"pipe",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot start task twice\"",
")",
"self",
".",
"ioloop",
"=",
"tornado",
".",
"ioloop",
".",
"IOLoop",
".",
"instance",
"(",
")",
... | Spawn the task.
Throws RuntimeError if the task was already started. | [
"Spawn",
"the",
"task",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/server/background.py#L32-L51 | train |
bcbio/bcbio-nextgen | bcbio/workflow/xprize.py | get_fc_date | def get_fc_date(out_config_file):
"""Retrieve flowcell date, reusing older dates if refreshing a present workflow.
"""
if os.path.exists(out_config_file):
with open(out_config_file) as in_handle:
old_config = yaml.safe_load(in_handle)
fc_date = old_config["fc_date"]
else:... | python | def get_fc_date(out_config_file):
"""Retrieve flowcell date, reusing older dates if refreshing a present workflow.
"""
if os.path.exists(out_config_file):
with open(out_config_file) as in_handle:
old_config = yaml.safe_load(in_handle)
fc_date = old_config["fc_date"]
else:... | [
"def",
"get_fc_date",
"(",
"out_config_file",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"out_config_file",
")",
":",
"with",
"open",
"(",
"out_config_file",
")",
"as",
"in_handle",
":",
"old_config",
"=",
"yaml",
".",
"safe_load",
"(",
"in_han... | Retrieve flowcell date, reusing older dates if refreshing a present workflow. | [
"Retrieve",
"flowcell",
"date",
"reusing",
"older",
"dates",
"if",
"refreshing",
"a",
"present",
"workflow",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/workflow/xprize.py#L32-L41 | train |
bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | draw_quality_plot | def draw_quality_plot(db_file, plot_file, position_select, title):
"""Draw a plot of remapped qualities using ggplot2.
Remapping information is pulled from the sqlite3 database using sqldf
according to the position select attribute, which is a selection phrase like
'> 50' or '=28'.
plyr is used to... | python | def draw_quality_plot(db_file, plot_file, position_select, title):
"""Draw a plot of remapped qualities using ggplot2.
Remapping information is pulled from the sqlite3 database using sqldf
according to the position select attribute, which is a selection phrase like
'> 50' or '=28'.
plyr is used to... | [
"def",
"draw_quality_plot",
"(",
"db_file",
",",
"plot_file",
",",
"position_select",
",",
"title",
")",
":",
"robjects",
".",
"r",
".",
"assign",
"(",
"'db.file'",
",",
"db_file",
")",
"robjects",
".",
"r",
".",
"assign",
"(",
"'plot.file'",
",",
"plot_fi... | Draw a plot of remapped qualities using ggplot2.
Remapping information is pulled from the sqlite3 database using sqldf
according to the position select attribute, which is a selection phrase like
'> 50' or '=28'.
plyr is used to summarize data by the original and remapped score for all
selected po... | [
"Draw",
"a",
"plot",
"of",
"remapped",
"qualities",
"using",
"ggplot2",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L112-L143 | train |
bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | _positions_to_examine | def _positions_to_examine(db_file):
"""Determine how to sub-divide recalibration analysis based on read length.
"""
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
cursor.execute("""SELECT MAX(position) FROM data""")
position = cursor.fetchone()[0]
if position is not None:
pos... | python | def _positions_to_examine(db_file):
"""Determine how to sub-divide recalibration analysis based on read length.
"""
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
cursor.execute("""SELECT MAX(position) FROM data""")
position = cursor.fetchone()[0]
if position is not None:
pos... | [
"def",
"_positions_to_examine",
"(",
"db_file",
")",
":",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
"db_file",
")",
"cursor",
"=",
"conn",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"\"\"\"SELECT MAX(position) FROM data\"\"\"",
")",
"position",
... | Determine how to sub-divide recalibration analysis based on read length. | [
"Determine",
"how",
"to",
"sub",
"-",
"divide",
"recalibration",
"analysis",
"based",
"on",
"read",
"length",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L145-L162 | train |
bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | _organize_by_position | def _organize_by_position(orig_file, cmp_file, chunk_size):
"""Read two CSV files of qualities, organizing values by position.
"""
with open(orig_file) as in_handle:
reader1 = csv.reader(in_handle)
positions = len(next(reader1)) - 1
for positions in _chunks(range(positions), chunk_size):... | python | def _organize_by_position(orig_file, cmp_file, chunk_size):
"""Read two CSV files of qualities, organizing values by position.
"""
with open(orig_file) as in_handle:
reader1 = csv.reader(in_handle)
positions = len(next(reader1)) - 1
for positions in _chunks(range(positions), chunk_size):... | [
"def",
"_organize_by_position",
"(",
"orig_file",
",",
"cmp_file",
",",
"chunk_size",
")",
":",
"with",
"open",
"(",
"orig_file",
")",
"as",
"in_handle",
":",
"reader1",
"=",
"csv",
".",
"reader",
"(",
"in_handle",
")",
"positions",
"=",
"len",
"(",
"next"... | Read two CSV files of qualities, organizing values by position. | [
"Read",
"two",
"CSV",
"files",
"of",
"qualities",
"organizing",
"values",
"by",
"position",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L183-L196 | train |
bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | _counts_at_position | def _counts_at_position(positions, orig_reader, cmp_reader):
"""Combine orignal and new qualities at each position, generating counts.
"""
pos_counts = collections.defaultdict(lambda:
collections.defaultdict(lambda:
collections.defaultdict(int)))
for orig_parts in orig_... | python | def _counts_at_position(positions, orig_reader, cmp_reader):
"""Combine orignal and new qualities at each position, generating counts.
"""
pos_counts = collections.defaultdict(lambda:
collections.defaultdict(lambda:
collections.defaultdict(int)))
for orig_parts in orig_... | [
"def",
"_counts_at_position",
"(",
"positions",
",",
"orig_reader",
",",
"cmp_reader",
")",
":",
"pos_counts",
"=",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"collections",
".",
"defaultdict",
"... | Combine orignal and new qualities at each position, generating counts. | [
"Combine",
"orignal",
"and",
"new",
"qualities",
"at",
"each",
"position",
"generating",
"counts",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L206-L222 | train |
bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | sort_csv | def sort_csv(in_file):
"""Sort a CSV file by read name, allowing direct comparison.
"""
out_file = "%s.sort" % in_file
if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
cl = ["sort", "-k", "1,1", in_file]
with open(out_file, "w") as out_handle:
child = subp... | python | def sort_csv(in_file):
"""Sort a CSV file by read name, allowing direct comparison.
"""
out_file = "%s.sort" % in_file
if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
cl = ["sort", "-k", "1,1", in_file]
with open(out_file, "w") as out_handle:
child = subp... | [
"def",
"sort_csv",
"(",
"in_file",
")",
":",
"out_file",
"=",
"\"%s.sort\"",
"%",
"in_file",
"if",
"not",
"(",
"os",
".",
"path",
".",
"exists",
"(",
"out_file",
")",
"and",
"os",
".",
"path",
".",
"getsize",
"(",
"out_file",
")",
">",
"0",
")",
":... | Sort a CSV file by read name, allowing direct comparison. | [
"Sort",
"a",
"CSV",
"file",
"by",
"read",
"name",
"allowing",
"direct",
"comparison",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L224-L233 | train |
bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | fastq_to_csv | def fastq_to_csv(in_file, fastq_format, work_dir):
"""Convert a fastq file into a CSV of phred quality scores.
"""
out_file = "%s.csv" % (os.path.splitext(os.path.basename(in_file))[0])
out_file = os.path.join(work_dir, out_file)
if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
... | python | def fastq_to_csv(in_file, fastq_format, work_dir):
"""Convert a fastq file into a CSV of phred quality scores.
"""
out_file = "%s.csv" % (os.path.splitext(os.path.basename(in_file))[0])
out_file = os.path.join(work_dir, out_file)
if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
... | [
"def",
"fastq_to_csv",
"(",
"in_file",
",",
"fastq_format",
",",
"work_dir",
")",
":",
"out_file",
"=",
"\"%s.csv\"",
"%",
"(",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"in_file",
")",
")",
"[",
"0",
"]",
")",... | Convert a fastq file into a CSV of phred quality scores. | [
"Convert",
"a",
"fastq",
"file",
"into",
"a",
"CSV",
"of",
"phred",
"quality",
"scores",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L235-L246 | train |
bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | bam_to_fastq | def bam_to_fastq(bam_file, is_paired):
"""Convert a BAM file to fastq files.
"""
out_files, out_handles = _get_fastq_handles(bam_file,
is_paired)
if len(out_handles) > 0:
in_bam = pysam.Samfile(bam_file, mode='rb')
for read in in_bam:
num = 1 if (not read.is_paire... | python | def bam_to_fastq(bam_file, is_paired):
"""Convert a BAM file to fastq files.
"""
out_files, out_handles = _get_fastq_handles(bam_file,
is_paired)
if len(out_handles) > 0:
in_bam = pysam.Samfile(bam_file, mode='rb')
for read in in_bam:
num = 1 if (not read.is_paire... | [
"def",
"bam_to_fastq",
"(",
"bam_file",
",",
"is_paired",
")",
":",
"out_files",
",",
"out_handles",
"=",
"_get_fastq_handles",
"(",
"bam_file",
",",
"is_paired",
")",
"if",
"len",
"(",
"out_handles",
")",
">",
"0",
":",
"in_bam",
"=",
"pysam",
".",
"Samfi... | Convert a BAM file to fastq files. | [
"Convert",
"a",
"BAM",
"file",
"to",
"fastq",
"files",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L248-L267 | train |
bcbio/bcbio-nextgen | scripts/utils/analyze_quality_recal.py | run_latex_report | def run_latex_report(base, report_dir, section_info):
"""Generate a pdf report with plots using latex.
"""
out_name = "%s_recal_plots.tex" % base
out = os.path.join(report_dir, out_name)
with open(out, "w") as out_handle:
out_tmpl = Template(out_template)
out_handle.write(out_tmpl.re... | python | def run_latex_report(base, report_dir, section_info):
"""Generate a pdf report with plots using latex.
"""
out_name = "%s_recal_plots.tex" % base
out = os.path.join(report_dir, out_name)
with open(out, "w") as out_handle:
out_tmpl = Template(out_template)
out_handle.write(out_tmpl.re... | [
"def",
"run_latex_report",
"(",
"base",
",",
"report_dir",
",",
"section_info",
")",
":",
"out_name",
"=",
"\"%s_recal_plots.tex\"",
"%",
"base",
"out",
"=",
"os",
".",
"path",
".",
"join",
"(",
"report_dir",
",",
"out_name",
")",
"with",
"open",
"(",
"out... | Generate a pdf report with plots using latex. | [
"Generate",
"a",
"pdf",
"report",
"with",
"plots",
"using",
"latex",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/analyze_quality_recal.py#L301-L316 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | bam_needs_processing | def bam_needs_processing(data):
"""Check if a work input needs processing for parallelization.
"""
return ((data.get("work_bam") or data.get("align_bam")) and
(any(tz.get_in(["config", "algorithm", x], data) for x in
["variantcaller", "mark_duplicates", "recalibrate", "realign",... | python | def bam_needs_processing(data):
"""Check if a work input needs processing for parallelization.
"""
return ((data.get("work_bam") or data.get("align_bam")) and
(any(tz.get_in(["config", "algorithm", x], data) for x in
["variantcaller", "mark_duplicates", "recalibrate", "realign",... | [
"def",
"bam_needs_processing",
"(",
"data",
")",
":",
"return",
"(",
"(",
"data",
".",
"get",
"(",
"\"work_bam\"",
")",
"or",
"data",
".",
"get",
"(",
"\"align_bam\"",
")",
")",
"and",
"(",
"any",
"(",
"tz",
".",
"get_in",
"(",
"[",
"\"config\"",
","... | Check if a work input needs processing for parallelization. | [
"Check",
"if",
"a",
"work",
"input",
"needs",
"processing",
"for",
"parallelization",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L30-L37 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | get_batch_for_key | def get_batch_for_key(data):
"""Retrieve batch information useful as a unique key for the sample.
"""
batches = _get_batches(data, require_bam=False)
if len(batches) == 1:
return batches[0]
else:
return tuple(batches) | python | def get_batch_for_key(data):
"""Retrieve batch information useful as a unique key for the sample.
"""
batches = _get_batches(data, require_bam=False)
if len(batches) == 1:
return batches[0]
else:
return tuple(batches) | [
"def",
"get_batch_for_key",
"(",
"data",
")",
":",
"batches",
"=",
"_get_batches",
"(",
"data",
",",
"require_bam",
"=",
"False",
")",
"if",
"len",
"(",
"batches",
")",
"==",
"1",
":",
"return",
"batches",
"[",
"0",
"]",
"else",
":",
"return",
"tuple",... | Retrieve batch information useful as a unique key for the sample. | [
"Retrieve",
"batch",
"information",
"useful",
"as",
"a",
"unique",
"key",
"for",
"the",
"sample",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L39-L46 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | _find_all_groups | def _find_all_groups(items, require_bam=True):
"""Find all groups
"""
all_groups = []
for data in items:
batches = _get_batches(data, require_bam)
all_groups.append(batches)
return all_groups | python | def _find_all_groups(items, require_bam=True):
"""Find all groups
"""
all_groups = []
for data in items:
batches = _get_batches(data, require_bam)
all_groups.append(batches)
return all_groups | [
"def",
"_find_all_groups",
"(",
"items",
",",
"require_bam",
"=",
"True",
")",
":",
"all_groups",
"=",
"[",
"]",
"for",
"data",
"in",
"items",
":",
"batches",
"=",
"_get_batches",
"(",
"data",
",",
"require_bam",
")",
"all_groups",
".",
"append",
"(",
"b... | Find all groups | [
"Find",
"all",
"groups"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L57-L64 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | _get_representative_batch | def _get_representative_batch(merged):
"""Prepare dictionary matching batch items to a representative within a group.
"""
out = {}
for mgroup in merged:
mgroup = sorted(list(mgroup))
for x in mgroup:
out[x] = mgroup[0]
return out | python | def _get_representative_batch(merged):
"""Prepare dictionary matching batch items to a representative within a group.
"""
out = {}
for mgroup in merged:
mgroup = sorted(list(mgroup))
for x in mgroup:
out[x] = mgroup[0]
return out | [
"def",
"_get_representative_batch",
"(",
"merged",
")",
":",
"out",
"=",
"{",
"}",
"for",
"mgroup",
"in",
"merged",
":",
"mgroup",
"=",
"sorted",
"(",
"list",
"(",
"mgroup",
")",
")",
"for",
"x",
"in",
"mgroup",
":",
"out",
"[",
"x",
"]",
"=",
"mgr... | Prepare dictionary matching batch items to a representative within a group. | [
"Prepare",
"dictionary",
"matching",
"batch",
"items",
"to",
"a",
"representative",
"within",
"a",
"group",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L90-L98 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | _group_batches_shared | def _group_batches_shared(xs, caller_batch_fn, prep_data_fn):
"""Shared functionality for grouping by batches for variant calling and joint calling.
"""
singles = []
batch_groups = collections.defaultdict(list)
for args in xs:
data = utils.to_single_data(args)
caller, batch = caller_... | python | def _group_batches_shared(xs, caller_batch_fn, prep_data_fn):
"""Shared functionality for grouping by batches for variant calling and joint calling.
"""
singles = []
batch_groups = collections.defaultdict(list)
for args in xs:
data = utils.to_single_data(args)
caller, batch = caller_... | [
"def",
"_group_batches_shared",
"(",
"xs",
",",
"caller_batch_fn",
",",
"prep_data_fn",
")",
":",
"singles",
"=",
"[",
"]",
"batch_groups",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"args",
"in",
"xs",
":",
"data",
"=",
"utils",
".",... | Shared functionality for grouping by batches for variant calling and joint calling. | [
"Shared",
"functionality",
"for",
"grouping",
"by",
"batches",
"for",
"variant",
"calling",
"and",
"joint",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L106-L133 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | group_batches | def group_batches(xs):
"""Group samples into batches for simultaneous variant calling.
Identify all samples to call together: those in the same batch
and variant caller.
Pull together all BAM files from this batch and process together,
Provide details to pull these finalized files back into individ... | python | def group_batches(xs):
"""Group samples into batches for simultaneous variant calling.
Identify all samples to call together: those in the same batch
and variant caller.
Pull together all BAM files from this batch and process together,
Provide details to pull these finalized files back into individ... | [
"def",
"group_batches",
"(",
"xs",
")",
":",
"def",
"_caller_batches",
"(",
"data",
")",
":",
"caller",
"=",
"tz",
".",
"get_in",
"(",
"(",
"\"config\"",
",",
"\"algorithm\"",
",",
"\"variantcaller\"",
")",
",",
"data",
")",
"jointcaller",
"=",
"tz",
"."... | Group samples into batches for simultaneous variant calling.
Identify all samples to call together: those in the same batch
and variant caller.
Pull together all BAM files from this batch and process together,
Provide details to pull these finalized files back into individual
expected files.
On... | [
"Group",
"samples",
"into",
"batches",
"for",
"simultaneous",
"variant",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L135-L153 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | _collapse_subitems | def _collapse_subitems(base, items):
"""Collapse full data representations relative to a standard base.
"""
out = []
for d in items:
newd = _diff_dict(base, d)
out.append(newd)
return out | python | def _collapse_subitems(base, items):
"""Collapse full data representations relative to a standard base.
"""
out = []
for d in items:
newd = _diff_dict(base, d)
out.append(newd)
return out | [
"def",
"_collapse_subitems",
"(",
"base",
",",
"items",
")",
":",
"out",
"=",
"[",
"]",
"for",
"d",
"in",
"items",
":",
"newd",
"=",
"_diff_dict",
"(",
"base",
",",
"d",
")",
"out",
".",
"append",
"(",
"newd",
")",
"return",
"out"
] | Collapse full data representations relative to a standard base. | [
"Collapse",
"full",
"data",
"representations",
"relative",
"to",
"a",
"standard",
"base",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L173-L180 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | _pick_lead_item | def _pick_lead_item(items):
"""Pick single representative sample for batch calling to attach calls to.
For cancer samples, attach to tumor.
"""
if vcfutils.is_paired_analysis([dd.get_align_bam(x) for x in items], items):
for data in items:
if vcfutils.get_paired_phenotype(data) == "... | python | def _pick_lead_item(items):
"""Pick single representative sample for batch calling to attach calls to.
For cancer samples, attach to tumor.
"""
if vcfutils.is_paired_analysis([dd.get_align_bam(x) for x in items], items):
for data in items:
if vcfutils.get_paired_phenotype(data) == "... | [
"def",
"_pick_lead_item",
"(",
"items",
")",
":",
"if",
"vcfutils",
".",
"is_paired_analysis",
"(",
"[",
"dd",
".",
"get_align_bam",
"(",
"x",
")",
"for",
"x",
"in",
"items",
"]",
",",
"items",
")",
":",
"for",
"data",
"in",
"items",
":",
"if",
"vcfu... | Pick single representative sample for batch calling to attach calls to.
For cancer samples, attach to tumor. | [
"Pick",
"single",
"representative",
"sample",
"for",
"batch",
"calling",
"to",
"attach",
"calls",
"to",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L198-L209 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | get_orig_items | def get_orig_items(base):
"""Retrieve original items from a diffed set of nested samples.
"""
assert "group_orig" in base
out = []
for data_diff in base["group_orig"]:
new = utils.deepish_copy(base)
new.pop("group_orig")
out.append(_patch_dict(data_diff, new))
return out | python | def get_orig_items(base):
"""Retrieve original items from a diffed set of nested samples.
"""
assert "group_orig" in base
out = []
for data_diff in base["group_orig"]:
new = utils.deepish_copy(base)
new.pop("group_orig")
out.append(_patch_dict(data_diff, new))
return out | [
"def",
"get_orig_items",
"(",
"base",
")",
":",
"assert",
"\"group_orig\"",
"in",
"base",
"out",
"=",
"[",
"]",
"for",
"data_diff",
"in",
"base",
"[",
"\"group_orig\"",
"]",
":",
"new",
"=",
"utils",
".",
"deepish_copy",
"(",
"base",
")",
"new",
".",
"... | Retrieve original items from a diffed set of nested samples. | [
"Retrieve",
"original",
"items",
"from",
"a",
"diffed",
"set",
"of",
"nested",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L211-L220 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | _patch_dict | def _patch_dict(diff, base):
"""Patch a dictionary, substituting in changed items from the nested diff.
"""
for k, v in diff.items():
if isinstance(v, dict):
base[k] = _patch_dict(v, base.get(k, {}))
elif not v:
base.pop(k, None)
else:
base[k] = v
... | python | def _patch_dict(diff, base):
"""Patch a dictionary, substituting in changed items from the nested diff.
"""
for k, v in diff.items():
if isinstance(v, dict):
base[k] = _patch_dict(v, base.get(k, {}))
elif not v:
base.pop(k, None)
else:
base[k] = v
... | [
"def",
"_patch_dict",
"(",
"diff",
",",
"base",
")",
":",
"for",
"k",
",",
"v",
"in",
"diff",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
"base",
"[",
"k",
"]",
"=",
"_patch_dict",
"(",
"v",
",",
"base",
... | Patch a dictionary, substituting in changed items from the nested diff. | [
"Patch",
"a",
"dictionary",
"substituting",
"in",
"changed",
"items",
"from",
"the",
"nested",
"diff",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L222-L232 | train |
bcbio/bcbio-nextgen | bcbio/variation/multi.py | split_variants_by_sample | def split_variants_by_sample(data):
"""Split a multi-sample call file into inputs for individual samples.
For tumor/normal paired analyses, do not split the final file and attach
it to the tumor input.
"""
# not split, do nothing
if "group_orig" not in data:
return [[data]]
# cancer... | python | def split_variants_by_sample(data):
"""Split a multi-sample call file into inputs for individual samples.
For tumor/normal paired analyses, do not split the final file and attach
it to the tumor input.
"""
# not split, do nothing
if "group_orig" not in data:
return [[data]]
# cancer... | [
"def",
"split_variants_by_sample",
"(",
"data",
")",
":",
"# not split, do nothing",
"if",
"\"group_orig\"",
"not",
"in",
"data",
":",
"return",
"[",
"[",
"data",
"]",
"]",
"# cancer tumor/normal",
"elif",
"(",
"vcfutils",
".",
"get_paired_phenotype",
"(",
"data",... | Split a multi-sample call file into inputs for individual samples.
For tumor/normal paired analyses, do not split the final file and attach
it to the tumor input. | [
"Split",
"a",
"multi",
"-",
"sample",
"call",
"file",
"into",
"inputs",
"for",
"individual",
"samples",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/multi.py#L236-L269 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | run | def run(call_file, ref_file, vrn_files, data):
"""Run filtering on the input call file, handling SNPs and indels separately.
"""
algs = [data["config"]["algorithm"]] * len(data.get("vrn_files", [1]))
if includes_missingalt(data):
logger.info("Removing variants with missing alts from %s." % call_... | python | def run(call_file, ref_file, vrn_files, data):
"""Run filtering on the input call file, handling SNPs and indels separately.
"""
algs = [data["config"]["algorithm"]] * len(data.get("vrn_files", [1]))
if includes_missingalt(data):
logger.info("Removing variants with missing alts from %s." % call_... | [
"def",
"run",
"(",
"call_file",
",",
"ref_file",
",",
"vrn_files",
",",
"data",
")",
":",
"algs",
"=",
"[",
"data",
"[",
"\"config\"",
"]",
"[",
"\"algorithm\"",
"]",
"]",
"*",
"len",
"(",
"data",
".",
"get",
"(",
"\"vrn_files\"",
",",
"[",
"1",
"]... | Run filtering on the input call file, handling SNPs and indels separately. | [
"Run",
"filtering",
"on",
"the",
"input",
"call",
"file",
"handling",
"SNPs",
"and",
"indels",
"separately",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L15-L41 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _cnn_filter | def _cnn_filter(in_file, vrn_files, data):
"""Perform CNN filtering on input VCF using pre-trained models.
"""
#tensor_type = "reference" # 1D, reference sequence
tensor_type = "read_tensor" # 2D, reads, flags, mapping quality
score_file = _cnn_score_variants(in_file, tensor_type, data)
return... | python | def _cnn_filter(in_file, vrn_files, data):
"""Perform CNN filtering on input VCF using pre-trained models.
"""
#tensor_type = "reference" # 1D, reference sequence
tensor_type = "read_tensor" # 2D, reads, flags, mapping quality
score_file = _cnn_score_variants(in_file, tensor_type, data)
return... | [
"def",
"_cnn_filter",
"(",
"in_file",
",",
"vrn_files",
",",
"data",
")",
":",
"#tensor_type = \"reference\" # 1D, reference sequence",
"tensor_type",
"=",
"\"read_tensor\"",
"# 2D, reads, flags, mapping quality",
"score_file",
"=",
"_cnn_score_variants",
"(",
"in_file",
","... | Perform CNN filtering on input VCF using pre-trained models. | [
"Perform",
"CNN",
"filtering",
"on",
"input",
"VCF",
"using",
"pre",
"-",
"trained",
"models",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L45-L51 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _cnn_tranch_filtering | def _cnn_tranch_filtering(in_file, vrn_files, tensor_type, data):
"""Filter CNN scored VCFs in tranches using standard SNP and Indel truth sets.
"""
out_file = "%s-filter.vcf.gz" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file):
runner = broad.runner_from_config(da... | python | def _cnn_tranch_filtering(in_file, vrn_files, tensor_type, data):
"""Filter CNN scored VCFs in tranches using standard SNP and Indel truth sets.
"""
out_file = "%s-filter.vcf.gz" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file):
runner = broad.runner_from_config(da... | [
"def",
"_cnn_tranch_filtering",
"(",
"in_file",
",",
"vrn_files",
",",
"tensor_type",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-filter.vcf.gz\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"if",
"not",
"utils",
".",
"file_upt... | Filter CNN scored VCFs in tranches using standard SNP and Indel truth sets. | [
"Filter",
"CNN",
"scored",
"VCFs",
"in",
"tranches",
"using",
"standard",
"SNP",
"and",
"Indel",
"truth",
"sets",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L53-L74 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _cnn_score_variants | def _cnn_score_variants(in_file, tensor_type, data):
"""Score variants with pre-trained CNN models.
"""
out_file = "%s-cnnscore.vcf.gz" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file):
runner = broad.runner_from_config(data["config"])
gatk_type = runner.ga... | python | def _cnn_score_variants(in_file, tensor_type, data):
"""Score variants with pre-trained CNN models.
"""
out_file = "%s-cnnscore.vcf.gz" % utils.splitext_plus(in_file)[0]
if not utils.file_uptodate(out_file, in_file):
runner = broad.runner_from_config(data["config"])
gatk_type = runner.ga... | [
"def",
"_cnn_score_variants",
"(",
"in_file",
",",
"tensor_type",
",",
"data",
")",
":",
"out_file",
"=",
"\"%s-cnnscore.vcf.gz\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
"if",
"not",
"utils",
".",
"file_uptodate",
"(",
"out_... | Score variants with pre-trained CNN models. | [
"Score",
"variants",
"with",
"pre",
"-",
"trained",
"CNN",
"models",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L76-L89 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _apply_vqsr | def _apply_vqsr(in_file, ref_file, recal_file, tranch_file,
sensitivity_cutoff, filter_type, data):
"""Apply VQSR based on the specified tranche, returning a filtered VCF file.
"""
base, ext = utils.splitext_plus(in_file)
out_file = "{base}-{filter}filter{ext}".format(base=base, ext=ext,... | python | def _apply_vqsr(in_file, ref_file, recal_file, tranch_file,
sensitivity_cutoff, filter_type, data):
"""Apply VQSR based on the specified tranche, returning a filtered VCF file.
"""
base, ext = utils.splitext_plus(in_file)
out_file = "{base}-{filter}filter{ext}".format(base=base, ext=ext,... | [
"def",
"_apply_vqsr",
"(",
"in_file",
",",
"ref_file",
",",
"recal_file",
",",
"tranch_file",
",",
"sensitivity_cutoff",
",",
"filter_type",
",",
"data",
")",
":",
"base",
",",
"ext",
"=",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"out_file",
"=",
... | Apply VQSR based on the specified tranche, returning a filtered VCF file. | [
"Apply",
"VQSR",
"based",
"on",
"the",
"specified",
"tranche",
"returning",
"a",
"filtered",
"VCF",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L93-L127 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _get_training_data | def _get_training_data(vrn_files):
"""Retrieve training data, returning an empty set of information if not available.
"""
out = {"SNP": [], "INDEL": []}
# SNPs
for name, train_info in [("train_hapmap", "known=false,training=true,truth=true,prior=15.0"),
("train_omni", "k... | python | def _get_training_data(vrn_files):
"""Retrieve training data, returning an empty set of information if not available.
"""
out = {"SNP": [], "INDEL": []}
# SNPs
for name, train_info in [("train_hapmap", "known=false,training=true,truth=true,prior=15.0"),
("train_omni", "k... | [
"def",
"_get_training_data",
"(",
"vrn_files",
")",
":",
"out",
"=",
"{",
"\"SNP\"",
":",
"[",
"]",
",",
"\"INDEL\"",
":",
"[",
"]",
"}",
"# SNPs",
"for",
"name",
",",
"train_info",
"in",
"[",
"(",
"\"train_hapmap\"",
",",
"\"known=false,training=true,truth=... | Retrieve training data, returning an empty set of information if not available. | [
"Retrieve",
"training",
"data",
"returning",
"an",
"empty",
"set",
"of",
"information",
"if",
"not",
"available",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L129-L148 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _get_vqsr_training | def _get_vqsr_training(filter_type, vrn_files, gatk_type):
"""Return parameters for VQSR training, handling SNPs and Indels.
"""
params = []
for name, train_info, fname in _get_training_data(vrn_files)[filter_type]:
if gatk_type == "gatk4":
params.extend(["--resource:%s,%s" % (name, ... | python | def _get_vqsr_training(filter_type, vrn_files, gatk_type):
"""Return parameters for VQSR training, handling SNPs and Indels.
"""
params = []
for name, train_info, fname in _get_training_data(vrn_files)[filter_type]:
if gatk_type == "gatk4":
params.extend(["--resource:%s,%s" % (name, ... | [
"def",
"_get_vqsr_training",
"(",
"filter_type",
",",
"vrn_files",
",",
"gatk_type",
")",
":",
"params",
"=",
"[",
"]",
"for",
"name",
",",
"train_info",
",",
"fname",
"in",
"_get_training_data",
"(",
"vrn_files",
")",
"[",
"filter_type",
"]",
":",
"if",
"... | Return parameters for VQSR training, handling SNPs and Indels. | [
"Return",
"parameters",
"for",
"VQSR",
"training",
"handling",
"SNPs",
"and",
"Indels",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L153-L166 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _get_vqsr_annotations | def _get_vqsr_annotations(filter_type, data):
"""Retrieve appropriate annotations to use for VQSR based on filter type.
Issues reported with MQ and bwa-mem quality distribution, results in intermittent
failures to use VQSR:
http://gatkforums.broadinstitute.org/discussion/4425/variant-recalibration-fail... | python | def _get_vqsr_annotations(filter_type, data):
"""Retrieve appropriate annotations to use for VQSR based on filter type.
Issues reported with MQ and bwa-mem quality distribution, results in intermittent
failures to use VQSR:
http://gatkforums.broadinstitute.org/discussion/4425/variant-recalibration-fail... | [
"def",
"_get_vqsr_annotations",
"(",
"filter_type",
",",
"data",
")",
":",
"if",
"filter_type",
"==",
"\"SNP\"",
":",
"# MQ, MQRankSum",
"anns",
"=",
"[",
"\"QD\"",
",",
"\"FS\"",
",",
"\"ReadPosRankSum\"",
",",
"\"SOR\"",
"]",
"else",
":",
"assert",
"filter_t... | Retrieve appropriate annotations to use for VQSR based on filter type.
Issues reported with MQ and bwa-mem quality distribution, results in intermittent
failures to use VQSR:
http://gatkforums.broadinstitute.org/discussion/4425/variant-recalibration-failing
http://gatkforums.broadinstitute.org/discussi... | [
"Retrieve",
"appropriate",
"annotations",
"to",
"use",
"for",
"VQSR",
"based",
"on",
"filter",
"type",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L168-L185 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _run_vqsr | def _run_vqsr(in_file, ref_file, vrn_files, sensitivity_cutoff, filter_type, data):
"""Run variant quality score recalibration.
"""
cutoffs = ["100.0", "99.99", "99.98", "99.97", "99.96", "99.95", "99.94", "99.93", "99.92", "99.91",
"99.9", "99.8", "99.7", "99.6", "99.5", "99.0", "98.0", "90.... | python | def _run_vqsr(in_file, ref_file, vrn_files, sensitivity_cutoff, filter_type, data):
"""Run variant quality score recalibration.
"""
cutoffs = ["100.0", "99.99", "99.98", "99.97", "99.96", "99.95", "99.94", "99.93", "99.92", "99.91",
"99.9", "99.8", "99.7", "99.6", "99.5", "99.0", "98.0", "90.... | [
"def",
"_run_vqsr",
"(",
"in_file",
",",
"ref_file",
",",
"vrn_files",
",",
"sensitivity_cutoff",
",",
"filter_type",
",",
"data",
")",
":",
"cutoffs",
"=",
"[",
"\"100.0\"",
",",
"\"99.99\"",
",",
"\"99.98\"",
",",
"\"99.97\"",
",",
"\"99.96\"",
",",
"\"99.... | Run variant quality score recalibration. | [
"Run",
"variant",
"quality",
"score",
"recalibration",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L187-L230 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _already_cutoff_filtered | def _already_cutoff_filtered(in_file, filter_type):
"""Check if we have a pre-existing cutoff-based filter file from previous VQSR failure.
"""
filter_file = "%s-filter%s.vcf.gz" % (utils.splitext_plus(in_file)[0], filter_type)
return utils.file_exists(filter_file) | python | def _already_cutoff_filtered(in_file, filter_type):
"""Check if we have a pre-existing cutoff-based filter file from previous VQSR failure.
"""
filter_file = "%s-filter%s.vcf.gz" % (utils.splitext_plus(in_file)[0], filter_type)
return utils.file_exists(filter_file) | [
"def",
"_already_cutoff_filtered",
"(",
"in_file",
",",
"filter_type",
")",
":",
"filter_file",
"=",
"\"%s-filter%s.vcf.gz\"",
"%",
"(",
"utils",
".",
"splitext_plus",
"(",
"in_file",
")",
"[",
"0",
"]",
",",
"filter_type",
")",
"return",
"utils",
".",
"file_e... | Check if we have a pre-existing cutoff-based filter file from previous VQSR failure. | [
"Check",
"if",
"we",
"have",
"a",
"pre",
"-",
"existing",
"cutoff",
"-",
"based",
"filter",
"file",
"from",
"previous",
"VQSR",
"failure",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L234-L238 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | _variant_filtration | def _variant_filtration(in_file, ref_file, vrn_files, data, filter_type,
hard_filter_fn):
"""Filter SNP and indel variant calls using GATK best practice recommendations.
Use cutoff-based soft filters if configuration indicates too little data or
already finished a cutoff-based filte... | python | def _variant_filtration(in_file, ref_file, vrn_files, data, filter_type,
hard_filter_fn):
"""Filter SNP and indel variant calls using GATK best practice recommendations.
Use cutoff-based soft filters if configuration indicates too little data or
already finished a cutoff-based filte... | [
"def",
"_variant_filtration",
"(",
"in_file",
",",
"ref_file",
",",
"vrn_files",
",",
"data",
",",
"filter_type",
",",
"hard_filter_fn",
")",
":",
"# Algorithms multiplied by number of input files to check for large enough sample sizes",
"algs",
"=",
"[",
"data",
"[",
"\"... | Filter SNP and indel variant calls using GATK best practice recommendations.
Use cutoff-based soft filters if configuration indicates too little data or
already finished a cutoff-based filtering step, otherwise try VQSR. | [
"Filter",
"SNP",
"and",
"indel",
"variant",
"calls",
"using",
"GATK",
"best",
"practice",
"recommendations",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L240-L265 | train |
bcbio/bcbio-nextgen | bcbio/variation/gatkfilter.py | gatk_remove_missingalt | def gatk_remove_missingalt(in_file, data):
"""
GATK 4.1.0.0 outputs variants that have missing ALTs, which breaks downstream
tools, this filters those out.
"""
base = in_file.split('.vcf.gz')[0]
out_file = "%s-nomissingalt%s" % (base, '.vcf.gz')
if utils.file_exists(out_file):
return... | python | def gatk_remove_missingalt(in_file, data):
"""
GATK 4.1.0.0 outputs variants that have missing ALTs, which breaks downstream
tools, this filters those out.
"""
base = in_file.split('.vcf.gz')[0]
out_file = "%s-nomissingalt%s" % (base, '.vcf.gz')
if utils.file_exists(out_file):
return... | [
"def",
"gatk_remove_missingalt",
"(",
"in_file",
",",
"data",
")",
":",
"base",
"=",
"in_file",
".",
"split",
"(",
"'.vcf.gz'",
")",
"[",
"0",
"]",
"out_file",
"=",
"\"%s-nomissingalt%s\"",
"%",
"(",
"base",
",",
"'.vcf.gz'",
")",
"if",
"utils",
".",
"fi... | GATK 4.1.0.0 outputs variants that have missing ALTs, which breaks downstream
tools, this filters those out. | [
"GATK",
"4",
".",
"1",
".",
"0",
".",
"0",
"outputs",
"variants",
"that",
"have",
"missing",
"ALTs",
"which",
"breaks",
"downstream",
"tools",
"this",
"filters",
"those",
"out",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/gatkfilter.py#L276-L292 | train |
bcbio/bcbio-nextgen | bcbio/rnaseq/cufflinks.py | strand_unknown | def strand_unknown(db, transcript):
"""
for unstranded data with novel transcripts single exon genes
will have no strand information. single exon novel genes are also
a source of noise in the Cufflinks assembly so this removes them
"""
features = list(db.children(transcript))
strand = featur... | python | def strand_unknown(db, transcript):
"""
for unstranded data with novel transcripts single exon genes
will have no strand information. single exon novel genes are also
a source of noise in the Cufflinks assembly so this removes them
"""
features = list(db.children(transcript))
strand = featur... | [
"def",
"strand_unknown",
"(",
"db",
",",
"transcript",
")",
":",
"features",
"=",
"list",
"(",
"db",
".",
"children",
"(",
"transcript",
")",
")",
"strand",
"=",
"features",
"[",
"0",
"]",
".",
"strand",
"if",
"strand",
"==",
"\".\"",
":",
"return",
... | for unstranded data with novel transcripts single exon genes
will have no strand information. single exon novel genes are also
a source of noise in the Cufflinks assembly so this removes them | [
"for",
"unstranded",
"data",
"with",
"novel",
"transcripts",
"single",
"exon",
"genes",
"will",
"have",
"no",
"strand",
"information",
".",
"single",
"exon",
"novel",
"genes",
"are",
"also",
"a",
"source",
"of",
"noise",
"in",
"the",
"Cufflinks",
"assembly",
... | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/cufflinks.py#L156-L167 | train |
bcbio/bcbio-nextgen | bcbio/rnaseq/cufflinks.py | fix_cufflinks_attributes | def fix_cufflinks_attributes(ref_gtf, merged_gtf, data, out_file=None):
"""
replace the cufflinks gene_id and transcript_id with the
gene_id and transcript_id from ref_gtf, where available
"""
base, ext = os.path.splitext(merged_gtf)
fixed = out_file if out_file else base + ".clean.fixed" + ext... | python | def fix_cufflinks_attributes(ref_gtf, merged_gtf, data, out_file=None):
"""
replace the cufflinks gene_id and transcript_id with the
gene_id and transcript_id from ref_gtf, where available
"""
base, ext = os.path.splitext(merged_gtf)
fixed = out_file if out_file else base + ".clean.fixed" + ext... | [
"def",
"fix_cufflinks_attributes",
"(",
"ref_gtf",
",",
"merged_gtf",
",",
"data",
",",
"out_file",
"=",
"None",
")",
":",
"base",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"merged_gtf",
")",
"fixed",
"=",
"out_file",
"if",
"out_file",
"e... | replace the cufflinks gene_id and transcript_id with the
gene_id and transcript_id from ref_gtf, where available | [
"replace",
"the",
"cufflinks",
"gene_id",
"and",
"transcript_id",
"with",
"the",
"gene_id",
"and",
"transcript_id",
"from",
"ref_gtf",
"where",
"available"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/cufflinks.py#L179-L234 | train |
bcbio/bcbio-nextgen | bcbio/rnaseq/cufflinks.py | merge | def merge(assembled_gtfs, ref_file, gtf_file, num_cores, data):
"""
run cuffmerge on a set of assembled GTF files
"""
assembled_file = tempfile.NamedTemporaryFile(delete=False).name
with open(assembled_file, "w") as temp_handle:
for assembled in assembled_gtfs:
temp_handle.write(... | python | def merge(assembled_gtfs, ref_file, gtf_file, num_cores, data):
"""
run cuffmerge on a set of assembled GTF files
"""
assembled_file = tempfile.NamedTemporaryFile(delete=False).name
with open(assembled_file, "w") as temp_handle:
for assembled in assembled_gtfs:
temp_handle.write(... | [
"def",
"merge",
"(",
"assembled_gtfs",
",",
"ref_file",
",",
"gtf_file",
",",
"num_cores",
",",
"data",
")",
":",
"assembled_file",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"delete",
"=",
"False",
")",
".",
"name",
"with",
"open",
"(",
"assembled_fil... | run cuffmerge on a set of assembled GTF files | [
"run",
"cuffmerge",
"on",
"a",
"set",
"of",
"assembled",
"GTF",
"files"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/cufflinks.py#L237-L265 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _vcf_info | def _vcf_info(start, end, mate_id, info=None):
"""Return breakend information line with mate and imprecise location.
"""
out = "SVTYPE=BND;MATEID={mate};IMPRECISE;CIPOS=0,{size}".format(
mate=mate_id, size=end-start)
if info is not None:
extra_info = ";".join("{0}={1}".format(k, v) for k... | python | def _vcf_info(start, end, mate_id, info=None):
"""Return breakend information line with mate and imprecise location.
"""
out = "SVTYPE=BND;MATEID={mate};IMPRECISE;CIPOS=0,{size}".format(
mate=mate_id, size=end-start)
if info is not None:
extra_info = ";".join("{0}={1}".format(k, v) for k... | [
"def",
"_vcf_info",
"(",
"start",
",",
"end",
",",
"mate_id",
",",
"info",
"=",
"None",
")",
":",
"out",
"=",
"\"SVTYPE=BND;MATEID={mate};IMPRECISE;CIPOS=0,{size}\"",
".",
"format",
"(",
"mate",
"=",
"mate_id",
",",
"size",
"=",
"end",
"-",
"start",
")",
"... | Return breakend information line with mate and imprecise location. | [
"Return",
"breakend",
"information",
"line",
"with",
"mate",
"and",
"imprecise",
"location",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L47-L55 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _vcf_alt | def _vcf_alt(base, other_chr, other_pos, isrc, is_first):
"""Create ALT allele line in VCF 4.1 format associating with other paired end.
"""
if is_first:
pipe = "[" if isrc else "]"
out_str = "{base}{pipe}{chr}:{pos}{pipe}"
else:
pipe = "]" if isrc else "["
out_str = "{pi... | python | def _vcf_alt(base, other_chr, other_pos, isrc, is_first):
"""Create ALT allele line in VCF 4.1 format associating with other paired end.
"""
if is_first:
pipe = "[" if isrc else "]"
out_str = "{base}{pipe}{chr}:{pos}{pipe}"
else:
pipe = "]" if isrc else "["
out_str = "{pi... | [
"def",
"_vcf_alt",
"(",
"base",
",",
"other_chr",
",",
"other_pos",
",",
"isrc",
",",
"is_first",
")",
":",
"if",
"is_first",
":",
"pipe",
"=",
"\"[\"",
"if",
"isrc",
"else",
"\"]\"",
"out_str",
"=",
"\"{base}{pipe}{chr}:{pos}{pipe}\"",
"else",
":",
"pipe",
... | Create ALT allele line in VCF 4.1 format associating with other paired end. | [
"Create",
"ALT",
"allele",
"line",
"in",
"VCF",
"4",
".",
"1",
"format",
"associating",
"with",
"other",
"paired",
"end",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L57-L67 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _breakend_orientation | def _breakend_orientation(strand1, strand2):
"""Convert BEDPE strand representation of breakpoints into VCF.
| strand1 | strand2 | VCF |
+----------+----------+--------------+
| + | - | t[p[ ]p]t |
| + | + | t]p] t]p] |
| - | - | [p[t [... | python | def _breakend_orientation(strand1, strand2):
"""Convert BEDPE strand representation of breakpoints into VCF.
| strand1 | strand2 | VCF |
+----------+----------+--------------+
| + | - | t[p[ ]p]t |
| + | + | t]p] t]p] |
| - | - | [p[t [... | [
"def",
"_breakend_orientation",
"(",
"strand1",
",",
"strand2",
")",
":",
"EndOrientation",
"=",
"namedtuple",
"(",
"\"EndOrientation\"",
",",
"[",
"\"is_first1\"",
",",
"\"is_rc1\"",
",",
"\"is_first2\"",
",",
"\"is_rc2\"",
"]",
")",
"if",
"strand1",
"==",
"\"+... | Convert BEDPE strand representation of breakpoints into VCF.
| strand1 | strand2 | VCF |
+----------+----------+--------------+
| + | - | t[p[ ]p]t |
| + | + | t]p] t]p] |
| - | - | [p[t [p[t |
| - | + | ]p]t t[p[ | | [
"Convert",
"BEDPE",
"strand",
"representation",
"of",
"breakpoints",
"into",
"VCF",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L69-L91 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | build_vcf_parts | def build_vcf_parts(feature, genome_2bit, info=None):
"""Convert BedPe feature information into VCF part representation.
Each feature will have two VCF lines for each side of the breakpoint.
"""
base1 = genome_2bit[feature.chrom1].get(
feature.start1, feature.start1 + 1).upper()
id1 = "hydr... | python | def build_vcf_parts(feature, genome_2bit, info=None):
"""Convert BedPe feature information into VCF part representation.
Each feature will have two VCF lines for each side of the breakpoint.
"""
base1 = genome_2bit[feature.chrom1].get(
feature.start1, feature.start1 + 1).upper()
id1 = "hydr... | [
"def",
"build_vcf_parts",
"(",
"feature",
",",
"genome_2bit",
",",
"info",
"=",
"None",
")",
":",
"base1",
"=",
"genome_2bit",
"[",
"feature",
".",
"chrom1",
"]",
".",
"get",
"(",
"feature",
".",
"start1",
",",
"feature",
".",
"start1",
"+",
"1",
")",
... | Convert BedPe feature information into VCF part representation.
Each feature will have two VCF lines for each side of the breakpoint. | [
"Convert",
"BedPe",
"feature",
"information",
"into",
"VCF",
"part",
"representation",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L95-L114 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | build_vcf_deletion | def build_vcf_deletion(x, genome_2bit):
"""Provide representation of deletion from BedPE breakpoints.
"""
base1 = genome_2bit[x.chrom1].get(x.start1, x.start1 + 1).upper()
id1 = "hydra{0}".format(x.name)
return VcfLine(x.chrom1, x.start1, id1, base1, "<DEL>",
_vcf_single_end_info(... | python | def build_vcf_deletion(x, genome_2bit):
"""Provide representation of deletion from BedPE breakpoints.
"""
base1 = genome_2bit[x.chrom1].get(x.start1, x.start1 + 1).upper()
id1 = "hydra{0}".format(x.name)
return VcfLine(x.chrom1, x.start1, id1, base1, "<DEL>",
_vcf_single_end_info(... | [
"def",
"build_vcf_deletion",
"(",
"x",
",",
"genome_2bit",
")",
":",
"base1",
"=",
"genome_2bit",
"[",
"x",
".",
"chrom1",
"]",
".",
"get",
"(",
"x",
".",
"start1",
",",
"x",
".",
"start1",
"+",
"1",
")",
".",
"upper",
"(",
")",
"id1",
"=",
"\"hy... | Provide representation of deletion from BedPE breakpoints. | [
"Provide",
"representation",
"of",
"deletion",
"from",
"BedPE",
"breakpoints",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L136-L142 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | build_vcf_inversion | def build_vcf_inversion(x1, x2, genome_2bit):
"""Provide representation of inversion from BedPE breakpoints.
"""
id1 = "hydra{0}".format(x1.name)
start_coords = sorted([x1.start1, x1.end1, x2.start1, x2.end1])
end_coords = sorted([x1.start2, x1.end2, x2.start2, x2.start2])
start_pos = (start_coo... | python | def build_vcf_inversion(x1, x2, genome_2bit):
"""Provide representation of inversion from BedPE breakpoints.
"""
id1 = "hydra{0}".format(x1.name)
start_coords = sorted([x1.start1, x1.end1, x2.start1, x2.end1])
end_coords = sorted([x1.start2, x1.end2, x2.start2, x2.start2])
start_pos = (start_coo... | [
"def",
"build_vcf_inversion",
"(",
"x1",
",",
"x2",
",",
"genome_2bit",
")",
":",
"id1",
"=",
"\"hydra{0}\"",
".",
"format",
"(",
"x1",
".",
"name",
")",
"start_coords",
"=",
"sorted",
"(",
"[",
"x1",
".",
"start1",
",",
"x1",
".",
"end1",
",",
"x2",... | Provide representation of inversion from BedPE breakpoints. | [
"Provide",
"representation",
"of",
"inversion",
"from",
"BedPE",
"breakpoints",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L166-L182 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | hydra_parser | def hydra_parser(in_file, options=None):
"""Parse hydra input file into namedtuple of values.
"""
if options is None: options = {}
BedPe = namedtuple('BedPe', ["chrom1", "start1", "end1",
"chrom2", "start2", "end2",
"name", "strand1", "st... | python | def hydra_parser(in_file, options=None):
"""Parse hydra input file into namedtuple of values.
"""
if options is None: options = {}
BedPe = namedtuple('BedPe', ["chrom1", "start1", "end1",
"chrom2", "start2", "end2",
"name", "strand1", "st... | [
"def",
"hydra_parser",
"(",
"in_file",
",",
"options",
"=",
"None",
")",
":",
"if",
"options",
"is",
"None",
":",
"options",
"=",
"{",
"}",
"BedPe",
"=",
"namedtuple",
"(",
"'BedPe'",
",",
"[",
"\"chrom1\"",
",",
"\"start1\"",
",",
"\"end1\"",
",",
"\"... | Parse hydra input file into namedtuple of values. | [
"Parse",
"hydra",
"input",
"file",
"into",
"namedtuple",
"of",
"values",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L198-L214 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _cluster_by | def _cluster_by(end_iter, attr1, attr2, cluster_distance):
"""Cluster breakends by specified attributes.
"""
ClusterInfo = namedtuple("ClusterInfo", ["chroms", "clusters", "lookup"])
chr_clusters = {}
chroms = []
brends_by_id = {}
for brend in end_iter:
if not chr_clusters.has_key(br... | python | def _cluster_by(end_iter, attr1, attr2, cluster_distance):
"""Cluster breakends by specified attributes.
"""
ClusterInfo = namedtuple("ClusterInfo", ["chroms", "clusters", "lookup"])
chr_clusters = {}
chroms = []
brends_by_id = {}
for brend in end_iter:
if not chr_clusters.has_key(br... | [
"def",
"_cluster_by",
"(",
"end_iter",
",",
"attr1",
",",
"attr2",
",",
"cluster_distance",
")",
":",
"ClusterInfo",
"=",
"namedtuple",
"(",
"\"ClusterInfo\"",
",",
"[",
"\"chroms\"",
",",
"\"clusters\"",
",",
"\"lookup\"",
"]",
")",
"chr_clusters",
"=",
"{",
... | Cluster breakends by specified attributes. | [
"Cluster",
"breakends",
"by",
"specified",
"attributes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L216-L231 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _calculate_cluster_distance | def _calculate_cluster_distance(end_iter):
"""Compute allowed distance for clustering based on end confidence intervals.
"""
out = []
sizes = []
for x in end_iter:
out.append(x)
sizes.append(x.end1 - x.start1)
sizes.append(x.end2 - x.start2)
distance = sum(sizes) // len(s... | python | def _calculate_cluster_distance(end_iter):
"""Compute allowed distance for clustering based on end confidence intervals.
"""
out = []
sizes = []
for x in end_iter:
out.append(x)
sizes.append(x.end1 - x.start1)
sizes.append(x.end2 - x.start2)
distance = sum(sizes) // len(s... | [
"def",
"_calculate_cluster_distance",
"(",
"end_iter",
")",
":",
"out",
"=",
"[",
"]",
"sizes",
"=",
"[",
"]",
"for",
"x",
"in",
"end_iter",
":",
"out",
".",
"append",
"(",
"x",
")",
"sizes",
".",
"append",
"(",
"x",
".",
"end1",
"-",
"x",
".",
"... | Compute allowed distance for clustering based on end confidence intervals. | [
"Compute",
"allowed",
"distance",
"for",
"clustering",
"based",
"on",
"end",
"confidence",
"intervals",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L233-L243 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | group_hydra_breakends | def group_hydra_breakends(end_iter):
"""Group together hydra breakends with overlapping ends.
This provides a way to identify inversions, translocations
and insertions present in hydra break point ends. We cluster together the
endpoints and return together any items with closely oriented pairs.
Thi... | python | def group_hydra_breakends(end_iter):
"""Group together hydra breakends with overlapping ends.
This provides a way to identify inversions, translocations
and insertions present in hydra break point ends. We cluster together the
endpoints and return together any items with closely oriented pairs.
Thi... | [
"def",
"group_hydra_breakends",
"(",
"end_iter",
")",
":",
"cluster_distance",
",",
"all_ends",
"=",
"_calculate_cluster_distance",
"(",
"end_iter",
")",
"first_cluster",
"=",
"_cluster_by",
"(",
"all_ends",
",",
"\"start1\"",
",",
"\"end1\"",
",",
"cluster_distance",... | Group together hydra breakends with overlapping ends.
This provides a way to identify inversions, translocations
and insertions present in hydra break point ends. We cluster together the
endpoints and return together any items with closely oriented pairs.
This helps in describing more complex rearrange... | [
"Group",
"together",
"hydra",
"breakends",
"with",
"overlapping",
"ends",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L245-L264 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _write_vcf_header | def _write_vcf_header(out_handle):
"""Write VCF header information for Hydra structural variant.
"""
def w(line):
out_handle.write("{0}\n".format(line))
w('##fileformat=VCFv4.1')
w('##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation">')
w('##INFO=<ID=END,... | python | def _write_vcf_header(out_handle):
"""Write VCF header information for Hydra structural variant.
"""
def w(line):
out_handle.write("{0}\n".format(line))
w('##fileformat=VCFv4.1')
w('##INFO=<ID=IMPRECISE,Number=0,Type=Flag,Description="Imprecise structural variation">')
w('##INFO=<ID=END,... | [
"def",
"_write_vcf_header",
"(",
"out_handle",
")",
":",
"def",
"w",
"(",
"line",
")",
":",
"out_handle",
".",
"write",
"(",
"\"{0}\\n\"",
".",
"format",
"(",
"line",
")",
")",
"w",
"(",
"'##fileformat=VCFv4.1'",
")",
"w",
"(",
"'##INFO=<ID=IMPRECISE,Number=... | Write VCF header information for Hydra structural variant. | [
"Write",
"VCF",
"header",
"information",
"for",
"Hydra",
"structural",
"variant",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L268-L291 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _write_vcf_breakend | def _write_vcf_breakend(brend, out_handle):
"""Write out a single VCF line with breakpoint information.
"""
out_handle.write("{0}\n".format("\t".join(str(x) for x in
[brend.chrom, brend.pos + 1, brend.id, brend.ref, brend.alt,
".", "PASS", brend.info]))) | python | def _write_vcf_breakend(brend, out_handle):
"""Write out a single VCF line with breakpoint information.
"""
out_handle.write("{0}\n".format("\t".join(str(x) for x in
[brend.chrom, brend.pos + 1, brend.id, brend.ref, brend.alt,
".", "PASS", brend.info]))) | [
"def",
"_write_vcf_breakend",
"(",
"brend",
",",
"out_handle",
")",
":",
"out_handle",
".",
"write",
"(",
"\"{0}\\n\"",
".",
"format",
"(",
"\"\\t\"",
".",
"join",
"(",
"str",
"(",
"x",
")",
"for",
"x",
"in",
"[",
"brend",
".",
"chrom",
",",
"brend",
... | Write out a single VCF line with breakpoint information. | [
"Write",
"out",
"a",
"single",
"VCF",
"line",
"with",
"breakpoint",
"information",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L293-L298 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | _get_vcf_breakends | def _get_vcf_breakends(hydra_file, genome_2bit, options=None):
"""Parse BEDPE input, yielding VCF ready breakends.
"""
if options is None: options = {}
for features in group_hydra_breakends(hydra_parser(hydra_file, options)):
if len(features) == 1 and is_deletion(features[0], options):
... | python | def _get_vcf_breakends(hydra_file, genome_2bit, options=None):
"""Parse BEDPE input, yielding VCF ready breakends.
"""
if options is None: options = {}
for features in group_hydra_breakends(hydra_parser(hydra_file, options)):
if len(features) == 1 and is_deletion(features[0], options):
... | [
"def",
"_get_vcf_breakends",
"(",
"hydra_file",
",",
"genome_2bit",
",",
"options",
"=",
"None",
")",
":",
"if",
"options",
"is",
"None",
":",
"options",
"=",
"{",
"}",
"for",
"features",
"in",
"group_hydra_breakends",
"(",
"hydra_parser",
"(",
"hydra_file",
... | Parse BEDPE input, yielding VCF ready breakends. | [
"Parse",
"BEDPE",
"input",
"yielding",
"VCF",
"ready",
"breakends",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L300-L319 | train |
bcbio/bcbio-nextgen | scripts/utils/hydra_to_vcf.py | hydra_to_vcf_writer | def hydra_to_vcf_writer(hydra_file, genome_2bit, options, out_handle):
"""Write hydra output as sorted VCF file.
Requires loading the hydra file into memory to perform sorting
on output VCF. Could generalize this to no sorting or by-chromosome
approach if this proves too memory intensive.
"""
_... | python | def hydra_to_vcf_writer(hydra_file, genome_2bit, options, out_handle):
"""Write hydra output as sorted VCF file.
Requires loading the hydra file into memory to perform sorting
on output VCF. Could generalize this to no sorting or by-chromosome
approach if this proves too memory intensive.
"""
_... | [
"def",
"hydra_to_vcf_writer",
"(",
"hydra_file",
",",
"genome_2bit",
",",
"options",
",",
"out_handle",
")",
":",
"_write_vcf_header",
"(",
"out_handle",
")",
"brends",
"=",
"list",
"(",
"_get_vcf_breakends",
"(",
"hydra_file",
",",
"genome_2bit",
",",
"options",
... | Write hydra output as sorted VCF file.
Requires loading the hydra file into memory to perform sorting
on output VCF. Could generalize this to no sorting or by-chromosome
approach if this proves too memory intensive. | [
"Write",
"hydra",
"output",
"as",
"sorted",
"VCF",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hydra_to_vcf.py#L321-L332 | train |
bcbio/bcbio-nextgen | bcbio/rnaseq/kallisto.py | kallisto_table | def kallisto_table(kallisto_dir, index):
"""
convert kallisto output to a count table where the rows are
equivalence classes and the columns are cells
"""
quant_dir = os.path.join(kallisto_dir, "quant")
out_file = os.path.join(quant_dir, "matrix.csv")
if file_exists(out_file):
return... | python | def kallisto_table(kallisto_dir, index):
"""
convert kallisto output to a count table where the rows are
equivalence classes and the columns are cells
"""
quant_dir = os.path.join(kallisto_dir, "quant")
out_file = os.path.join(quant_dir, "matrix.csv")
if file_exists(out_file):
return... | [
"def",
"kallisto_table",
"(",
"kallisto_dir",
",",
"index",
")",
":",
"quant_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"kallisto_dir",
",",
"\"quant\"",
")",
"out_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"quant_dir",
",",
"\"matrix.csv\"",
... | convert kallisto output to a count table where the rows are
equivalence classes and the columns are cells | [
"convert",
"kallisto",
"output",
"to",
"a",
"count",
"table",
"where",
"the",
"rows",
"are",
"equivalence",
"classes",
"and",
"the",
"columns",
"are",
"cells"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/kallisto.py#L127-L149 | train |
bcbio/bcbio-nextgen | bcbio/rnaseq/kallisto.py | get_ec_names | def get_ec_names(ecfile, fasta_names):
"""
convert equivalence classes to their set of transcripts
"""
df = pd.read_table(ecfile, header=None, names=["ec", "transcripts"])
transcript_groups = [x.split(",") for x in df["transcripts"]]
transcripts = []
for group in transcript_groups:
t... | python | def get_ec_names(ecfile, fasta_names):
"""
convert equivalence classes to their set of transcripts
"""
df = pd.read_table(ecfile, header=None, names=["ec", "transcripts"])
transcript_groups = [x.split(",") for x in df["transcripts"]]
transcripts = []
for group in transcript_groups:
t... | [
"def",
"get_ec_names",
"(",
"ecfile",
",",
"fasta_names",
")",
":",
"df",
"=",
"pd",
".",
"read_table",
"(",
"ecfile",
",",
"header",
"=",
"None",
",",
"names",
"=",
"[",
"\"ec\"",
",",
"\"transcripts\"",
"]",
")",
"transcript_groups",
"=",
"[",
"x",
"... | convert equivalence classes to their set of transcripts | [
"convert",
"equivalence",
"classes",
"to",
"their",
"set",
"of",
"transcripts"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/kallisto.py#L151-L160 | train |
bcbio/bcbio-nextgen | bcbio/illumina/flowcell.py | parse_dirname | def parse_dirname(fc_dir):
"""Parse the flow cell ID and date from a flow cell directory.
"""
(_, fc_dir) = os.path.split(fc_dir)
parts = fc_dir.split("_")
name = None
date = None
for p in parts:
if p.endswith(("XX", "xx", "XY", "X2")):
name = p
elif len(p) == 6:
... | python | def parse_dirname(fc_dir):
"""Parse the flow cell ID and date from a flow cell directory.
"""
(_, fc_dir) = os.path.split(fc_dir)
parts = fc_dir.split("_")
name = None
date = None
for p in parts:
if p.endswith(("XX", "xx", "XY", "X2")):
name = p
elif len(p) == 6:
... | [
"def",
"parse_dirname",
"(",
"fc_dir",
")",
":",
"(",
"_",
",",
"fc_dir",
")",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fc_dir",
")",
"parts",
"=",
"fc_dir",
".",
"split",
"(",
"\"_\"",
")",
"name",
"=",
"None",
"date",
"=",
"None",
"for",
"p"... | Parse the flow cell ID and date from a flow cell directory. | [
"Parse",
"the",
"flow",
"cell",
"ID",
"and",
"date",
"from",
"a",
"flow",
"cell",
"directory",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/flowcell.py#L8-L26 | train |
bcbio/bcbio-nextgen | bcbio/illumina/flowcell.py | get_qseq_dir | def get_qseq_dir(fc_dir):
"""Retrieve the qseq directory within Solexa flowcell output.
"""
machine_bc = os.path.join(fc_dir, "Data", "Intensities", "BaseCalls")
if os.path.exists(machine_bc):
return machine_bc
# otherwise assume we are in the qseq directory
# XXX What other cases can we... | python | def get_qseq_dir(fc_dir):
"""Retrieve the qseq directory within Solexa flowcell output.
"""
machine_bc = os.path.join(fc_dir, "Data", "Intensities", "BaseCalls")
if os.path.exists(machine_bc):
return machine_bc
# otherwise assume we are in the qseq directory
# XXX What other cases can we... | [
"def",
"get_qseq_dir",
"(",
"fc_dir",
")",
":",
"machine_bc",
"=",
"os",
".",
"path",
".",
"join",
"(",
"fc_dir",
",",
"\"Data\"",
",",
"\"Intensities\"",
",",
"\"BaseCalls\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"machine_bc",
")",
":",
"... | Retrieve the qseq directory within Solexa flowcell output. | [
"Retrieve",
"the",
"qseq",
"directory",
"within",
"Solexa",
"flowcell",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/flowcell.py#L28-L37 | train |
bcbio/bcbio-nextgen | bcbio/illumina/flowcell.py | get_fastq_dir | def get_fastq_dir(fc_dir):
"""Retrieve the fastq directory within Solexa flowcell output.
"""
full_goat_bc = glob.glob(os.path.join(fc_dir, "Data", "*Firecrest*", "Bustard*"))
bustard_bc = glob.glob(os.path.join(fc_dir, "Data", "Intensities", "*Bustard*"))
machine_bc = os.path.join(fc_dir, "Data", "... | python | def get_fastq_dir(fc_dir):
"""Retrieve the fastq directory within Solexa flowcell output.
"""
full_goat_bc = glob.glob(os.path.join(fc_dir, "Data", "*Firecrest*", "Bustard*"))
bustard_bc = glob.glob(os.path.join(fc_dir, "Data", "Intensities", "*Bustard*"))
machine_bc = os.path.join(fc_dir, "Data", "... | [
"def",
"get_fastq_dir",
"(",
"fc_dir",
")",
":",
"full_goat_bc",
"=",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(",
"fc_dir",
",",
"\"Data\"",
",",
"\"*Firecrest*\"",
",",
"\"Bustard*\"",
")",
")",
"bustard_bc",
"=",
"glob",
".",
"glob",... | Retrieve the fastq directory within Solexa flowcell output. | [
"Retrieve",
"the",
"fastq",
"directory",
"within",
"Solexa",
"flowcell",
"output",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/flowcell.py#L39-L54 | train |
bcbio/bcbio-nextgen | bcbio/illumina/flowcell.py | GalaxySqnLimsApi.run_details | def run_details(self, run):
"""Retrieve sequencing run details as a dictionary.
"""
run_data = dict(run=run)
req = urllib.request.Request("%s/nglims/api_run_details" % self._base_url,
urllib.parse.urlencode(run_data))
response = urllib.request.urlopen(req)
... | python | def run_details(self, run):
"""Retrieve sequencing run details as a dictionary.
"""
run_data = dict(run=run)
req = urllib.request.Request("%s/nglims/api_run_details" % self._base_url,
urllib.parse.urlencode(run_data))
response = urllib.request.urlopen(req)
... | [
"def",
"run_details",
"(",
"self",
",",
"run",
")",
":",
"run_data",
"=",
"dict",
"(",
"run",
"=",
"run",
")",
"req",
"=",
"urllib",
".",
"request",
".",
"Request",
"(",
"\"%s/nglims/api_run_details\"",
"%",
"self",
".",
"_base_url",
",",
"urllib",
".",
... | Retrieve sequencing run details as a dictionary. | [
"Retrieve",
"sequencing",
"run",
"details",
"as",
"a",
"dictionary",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/illumina/flowcell.py#L70-L81 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/mosaik.py | _mosaik_args_from_config | def _mosaik_args_from_config(config):
"""Configurable high level options for mosaik.
"""
multi_mappers = config["algorithm"].get("multiple_mappers", True)
multi_flags = ["-m", "all"] if multi_mappers else ["-m", "unique"]
error_flags = ["-mm", "2"]
num_cores = config["algorithm"].get("num_cores"... | python | def _mosaik_args_from_config(config):
"""Configurable high level options for mosaik.
"""
multi_mappers = config["algorithm"].get("multiple_mappers", True)
multi_flags = ["-m", "all"] if multi_mappers else ["-m", "unique"]
error_flags = ["-mm", "2"]
num_cores = config["algorithm"].get("num_cores"... | [
"def",
"_mosaik_args_from_config",
"(",
"config",
")",
":",
"multi_mappers",
"=",
"config",
"[",
"\"algorithm\"",
"]",
".",
"get",
"(",
"\"multiple_mappers\"",
",",
"True",
")",
"multi_flags",
"=",
"[",
"\"-m\"",
",",
"\"all\"",
"]",
"if",
"multi_mappers",
"el... | Configurable high level options for mosaik. | [
"Configurable",
"high",
"level",
"options",
"for",
"mosaik",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/mosaik.py#L14-L22 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/mosaik.py | _convert_fastq | def _convert_fastq(fastq_file, pair_file, rg_name, out_file, config):
"""Convert fastq inputs into internal Mosaik representation.
"""
out_file = "{0}-fq.mkb".format(os.path.splitext(out_file)[0])
if not file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
c... | python | def _convert_fastq(fastq_file, pair_file, rg_name, out_file, config):
"""Convert fastq inputs into internal Mosaik representation.
"""
out_file = "{0}-fq.mkb".format(os.path.splitext(out_file)[0])
if not file_exists(out_file):
with file_transaction(config, out_file) as tx_out_file:
c... | [
"def",
"_convert_fastq",
"(",
"fastq_file",
",",
"pair_file",
",",
"rg_name",
",",
"out_file",
",",
"config",
")",
":",
"out_file",
"=",
"\"{0}-fq.mkb\"",
".",
"format",
"(",
"os",
".",
"path",
".",
"splitext",
"(",
"out_file",
")",
"[",
"0",
"]",
")",
... | Convert fastq inputs into internal Mosaik representation. | [
"Convert",
"fastq",
"inputs",
"into",
"internal",
"Mosaik",
"representation",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/mosaik.py#L24-L41 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/mosaik.py | _get_mosaik_nn_args | def _get_mosaik_nn_args(out_file):
"""Retrieve default neural network files from GitHub to pass to Mosaik.
"""
base_nn_url = "https://raw.github.com/wanpinglee/MOSAIK/master/src/networkFile/"
out = []
for arg, fname in [("-annse", "2.1.26.se.100.005.ann"),
("-annpe", "2.1.26.p... | python | def _get_mosaik_nn_args(out_file):
"""Retrieve default neural network files from GitHub to pass to Mosaik.
"""
base_nn_url = "https://raw.github.com/wanpinglee/MOSAIK/master/src/networkFile/"
out = []
for arg, fname in [("-annse", "2.1.26.se.100.005.ann"),
("-annpe", "2.1.26.p... | [
"def",
"_get_mosaik_nn_args",
"(",
"out_file",
")",
":",
"base_nn_url",
"=",
"\"https://raw.github.com/wanpinglee/MOSAIK/master/src/networkFile/\"",
"out",
"=",
"[",
"]",
"for",
"arg",
",",
"fname",
"in",
"[",
"(",
"\"-annse\"",
",",
"\"2.1.26.se.100.005.ann\"",
")",
... | Retrieve default neural network files from GitHub to pass to Mosaik. | [
"Retrieve",
"default",
"neural",
"network",
"files",
"from",
"GitHub",
"to",
"pass",
"to",
"Mosaik",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/mosaik.py#L43-L54 | train |
bcbio/bcbio-nextgen | bcbio/ngsalign/mosaik.py | align | def align(fastq_file, pair_file, ref_file, names, align_dir, data,
extra_args=None):
"""Alignment with MosaikAligner.
"""
config = data["config"]
rg_name = names.get("rg", None) if names else None
out_file = os.path.join(align_dir, "%s-align.bam" % names["lane"])
if not file_exists(out... | python | def align(fastq_file, pair_file, ref_file, names, align_dir, data,
extra_args=None):
"""Alignment with MosaikAligner.
"""
config = data["config"]
rg_name = names.get("rg", None) if names else None
out_file = os.path.join(align_dir, "%s-align.bam" % names["lane"])
if not file_exists(out... | [
"def",
"align",
"(",
"fastq_file",
",",
"pair_file",
",",
"ref_file",
",",
"names",
",",
"align_dir",
",",
"data",
",",
"extra_args",
"=",
"None",
")",
":",
"config",
"=",
"data",
"[",
"\"config\"",
"]",
"rg_name",
"=",
"names",
".",
"get",
"(",
"\"rg\... | Alignment with MosaikAligner. | [
"Alignment",
"with",
"MosaikAligner",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/mosaik.py#L56-L87 | train |
bcbio/bcbio-nextgen | bcbio/graph/graph.py | get_bcbio_timings | def get_bcbio_timings(path):
"""Fetch timing information from a bcbio log file."""
with open(path, 'r') as file_handle:
steps = {}
for line in file_handle:
matches = re.search(r'^\[([^\]]+)\] ([^:]+: .*)', line)
if not matches:
continue
tstamp... | python | def get_bcbio_timings(path):
"""Fetch timing information from a bcbio log file."""
with open(path, 'r') as file_handle:
steps = {}
for line in file_handle:
matches = re.search(r'^\[([^\]]+)\] ([^:]+: .*)', line)
if not matches:
continue
tstamp... | [
"def",
"get_bcbio_timings",
"(",
"path",
")",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"file_handle",
":",
"steps",
"=",
"{",
"}",
"for",
"line",
"in",
"file_handle",
":",
"matches",
"=",
"re",
".",
"search",
"(",
"r'^\\[([^\\]]+)\\] ([^:... | Fetch timing information from a bcbio log file. | [
"Fetch",
"timing",
"information",
"from",
"a",
"bcbio",
"log",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/graph/graph.py#L54-L76 | train |
bcbio/bcbio-nextgen | bcbio/graph/graph.py | this_and_prev | def this_and_prev(iterable):
"""Walk an iterable, returning the current and previous items
as a two-tuple."""
try:
item = next(iterable)
while True:
next_item = next(iterable)
yield item, next_item
item = next_item
except StopIteration:
return | python | def this_and_prev(iterable):
"""Walk an iterable, returning the current and previous items
as a two-tuple."""
try:
item = next(iterable)
while True:
next_item = next(iterable)
yield item, next_item
item = next_item
except StopIteration:
return | [
"def",
"this_and_prev",
"(",
"iterable",
")",
":",
"try",
":",
"item",
"=",
"next",
"(",
"iterable",
")",
"while",
"True",
":",
"next_item",
"=",
"next",
"(",
"iterable",
")",
"yield",
"item",
",",
"next_item",
"item",
"=",
"next_item",
"except",
"StopIt... | Walk an iterable, returning the current and previous items
as a two-tuple. | [
"Walk",
"an",
"iterable",
"returning",
"the",
"current",
"and",
"previous",
"items",
"as",
"a",
"two",
"-",
"tuple",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/graph/graph.py#L89-L99 | train |
bcbio/bcbio-nextgen | bcbio/graph/graph.py | remove_outliers | def remove_outliers(series, stddev):
"""Remove the outliers from a series."""
return series[(series - series.mean()).abs() < stddev * series.std()] | python | def remove_outliers(series, stddev):
"""Remove the outliers from a series."""
return series[(series - series.mean()).abs() < stddev * series.std()] | [
"def",
"remove_outliers",
"(",
"series",
",",
"stddev",
")",
":",
"return",
"series",
"[",
"(",
"series",
"-",
"series",
".",
"mean",
"(",
")",
")",
".",
"abs",
"(",
")",
"<",
"stddev",
"*",
"series",
".",
"std",
"(",
")",
"]"
] | Remove the outliers from a series. | [
"Remove",
"the",
"outliers",
"from",
"a",
"series",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/graph/graph.py#L135-L137 | train |
bcbio/bcbio-nextgen | bcbio/graph/graph.py | prep_for_graph | def prep_for_graph(data_frame, series=None, delta_series=None, smoothing=None,
outlier_stddev=None):
"""Prepare a dataframe for graphing by calculating deltas for
series that need them, resampling, and removing outliers.
"""
series = series or []
delta_series = delta_series or []
... | python | def prep_for_graph(data_frame, series=None, delta_series=None, smoothing=None,
outlier_stddev=None):
"""Prepare a dataframe for graphing by calculating deltas for
series that need them, resampling, and removing outliers.
"""
series = series or []
delta_series = delta_series or []
... | [
"def",
"prep_for_graph",
"(",
"data_frame",
",",
"series",
"=",
"None",
",",
"delta_series",
"=",
"None",
",",
"smoothing",
"=",
"None",
",",
"outlier_stddev",
"=",
"None",
")",
":",
"series",
"=",
"series",
"or",
"[",
"]",
"delta_series",
"=",
"delta_seri... | Prepare a dataframe for graphing by calculating deltas for
series that need them, resampling, and removing outliers. | [
"Prepare",
"a",
"dataframe",
"for",
"graphing",
"by",
"calculating",
"deltas",
"for",
"series",
"that",
"need",
"them",
"resampling",
"and",
"removing",
"outliers",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/graph/graph.py#L140-L155 | train |
bcbio/bcbio-nextgen | bcbio/graph/graph.py | add_common_plot_features | def add_common_plot_features(plot, steps):
"""Add plot features common to all plots, such as bcbio step
information.
"""
_setup_matplotlib()
plot.yaxis.set_tick_params(labelright=True)
plot.set_xlabel('')
ymax = plot.get_ylim()[1]
ticks = {}
for tstamp, step in steps.items():
... | python | def add_common_plot_features(plot, steps):
"""Add plot features common to all plots, such as bcbio step
information.
"""
_setup_matplotlib()
plot.yaxis.set_tick_params(labelright=True)
plot.set_xlabel('')
ymax = plot.get_ylim()[1]
ticks = {}
for tstamp, step in steps.items():
... | [
"def",
"add_common_plot_features",
"(",
"plot",
",",
"steps",
")",
":",
"_setup_matplotlib",
"(",
")",
"plot",
".",
"yaxis",
".",
"set_tick_params",
"(",
"labelright",
"=",
"True",
")",
"plot",
".",
"set_xlabel",
"(",
"''",
")",
"ymax",
"=",
"plot",
".",
... | Add plot features common to all plots, such as bcbio step
information. | [
"Add",
"plot",
"features",
"common",
"to",
"all",
"plots",
"such",
"as",
"bcbio",
"step",
"information",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/graph/graph.py#L158-L183 | train |
bcbio/bcbio-nextgen | bcbio/graph/graph.py | log_time_frame | def log_time_frame(bcbio_log):
"""The bcbio running time frame.
:return: an instance of :class collections.namedtuple:
with the following fields: start and end
"""
output = collections.namedtuple("Time", ["start", "end", "steps"])
bcbio_timings = get_bcbio_timings(bcbio_log)
... | python | def log_time_frame(bcbio_log):
"""The bcbio running time frame.
:return: an instance of :class collections.namedtuple:
with the following fields: start and end
"""
output = collections.namedtuple("Time", ["start", "end", "steps"])
bcbio_timings = get_bcbio_timings(bcbio_log)
... | [
"def",
"log_time_frame",
"(",
"bcbio_log",
")",
":",
"output",
"=",
"collections",
".",
"namedtuple",
"(",
"\"Time\"",
",",
"[",
"\"start\"",
",",
"\"end\"",
",",
"\"steps\"",
"]",
")",
"bcbio_timings",
"=",
"get_bcbio_timings",
"(",
"bcbio_log",
")",
"return"... | The bcbio running time frame.
:return: an instance of :class collections.namedtuple:
with the following fields: start and end | [
"The",
"bcbio",
"running",
"time",
"frame",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/graph/graph.py#L298-L306 | train |
bcbio/bcbio-nextgen | bcbio/graph/graph.py | resource_usage | def resource_usage(bcbio_log, cluster, rawdir, verbose):
"""Generate system statistics from bcbio runs.
Parse the obtained files and put the information in
a :class pandas.DataFrame:.
:param bcbio_log: local path to bcbio log file written by the run
:param cluster:
:param rawdir: direct... | python | def resource_usage(bcbio_log, cluster, rawdir, verbose):
"""Generate system statistics from bcbio runs.
Parse the obtained files and put the information in
a :class pandas.DataFrame:.
:param bcbio_log: local path to bcbio log file written by the run
:param cluster:
:param rawdir: direct... | [
"def",
"resource_usage",
"(",
"bcbio_log",
",",
"cluster",
",",
"rawdir",
",",
"verbose",
")",
":",
"data_frames",
"=",
"{",
"}",
"hardware_info",
"=",
"{",
"}",
"time_frame",
"=",
"log_time_frame",
"(",
"bcbio_log",
")",
"for",
"collectl_file",
"in",
"sorte... | Generate system statistics from bcbio runs.
Parse the obtained files and put the information in
a :class pandas.DataFrame:.
:param bcbio_log: local path to bcbio log file written by the run
:param cluster:
:param rawdir: directory to put raw data files
:param verbose: increase verbo... | [
"Generate",
"system",
"statistics",
"from",
"bcbio",
"runs",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/graph/graph.py#L319-L362 | train |
bcbio/bcbio-nextgen | bcbio/graph/graph.py | generate_graphs | def generate_graphs(data_frames, hardware_info, steps, outdir,
verbose=False):
"""Generate all graphs for a bcbio run."""
_setup_matplotlib()
# Hash of hosts containing (data, hardware, steps) tuple
collectl_info = collections.defaultdict(dict)
for host, data_frame in data_frame... | python | def generate_graphs(data_frames, hardware_info, steps, outdir,
verbose=False):
"""Generate all graphs for a bcbio run."""
_setup_matplotlib()
# Hash of hosts containing (data, hardware, steps) tuple
collectl_info = collections.defaultdict(dict)
for host, data_frame in data_frame... | [
"def",
"generate_graphs",
"(",
"data_frames",
",",
"hardware_info",
",",
"steps",
",",
"outdir",
",",
"verbose",
"=",
"False",
")",
":",
"_setup_matplotlib",
"(",
")",
"# Hash of hosts containing (data, hardware, steps) tuple",
"collectl_info",
"=",
"collections",
".",
... | Generate all graphs for a bcbio run. | [
"Generate",
"all",
"graphs",
"for",
"a",
"bcbio",
"run",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/graph/graph.py#L365-L428 | train |
bcbio/bcbio-nextgen | bcbio/variation/ploidy.py | get_ploidy | def get_ploidy(items, region=None):
"""Retrieve ploidy of a region, handling special cases.
"""
chrom = chromosome_special_cases(region[0] if isinstance(region, (list, tuple))
else None)
ploidy = _configured_ploidy(items)
sexes = _configured_genders(items)
if... | python | def get_ploidy(items, region=None):
"""Retrieve ploidy of a region, handling special cases.
"""
chrom = chromosome_special_cases(region[0] if isinstance(region, (list, tuple))
else None)
ploidy = _configured_ploidy(items)
sexes = _configured_genders(items)
if... | [
"def",
"get_ploidy",
"(",
"items",
",",
"region",
"=",
"None",
")",
":",
"chrom",
"=",
"chromosome_special_cases",
"(",
"region",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"region",
",",
"(",
"list",
",",
"tuple",
")",
")",
"else",
"None",
")",
"ploidy",... | Retrieve ploidy of a region, handling special cases. | [
"Retrieve",
"ploidy",
"of",
"a",
"region",
"handling",
"special",
"cases",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/ploidy.py#L43-L66 | train |
bcbio/bcbio-nextgen | bcbio/variation/ploidy.py | filter_vcf_by_sex | def filter_vcf_by_sex(vcf_file, items):
"""Post-filter a single sample VCF, handling sex chromosomes.
Removes Y chromosomes from batches with all female samples.
"""
out_file = "%s-ploidyfix%s" % utils.splitext_plus(vcf_file)
if not utils.file_exists(out_file):
genders = list(_configured_ge... | python | def filter_vcf_by_sex(vcf_file, items):
"""Post-filter a single sample VCF, handling sex chromosomes.
Removes Y chromosomes from batches with all female samples.
"""
out_file = "%s-ploidyfix%s" % utils.splitext_plus(vcf_file)
if not utils.file_exists(out_file):
genders = list(_configured_ge... | [
"def",
"filter_vcf_by_sex",
"(",
"vcf_file",
",",
"items",
")",
":",
"out_file",
"=",
"\"%s-ploidyfix%s\"",
"%",
"utils",
".",
"splitext_plus",
"(",
"vcf_file",
")",
"if",
"not",
"utils",
".",
"file_exists",
"(",
"out_file",
")",
":",
"genders",
"=",
"list",... | Post-filter a single sample VCF, handling sex chromosomes.
Removes Y chromosomes from batches with all female samples. | [
"Post",
"-",
"filter",
"a",
"single",
"sample",
"VCF",
"handling",
"sex",
"chromosomes",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/ploidy.py#L68-L94 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | variant_filtration | def variant_filtration(call_file, ref_file, vrn_files, data, items):
"""Filter variant calls using Variant Quality Score Recalibration.
Newer GATK with Haplotype calling has combined SNP/indel filtering.
"""
caller = data["config"]["algorithm"].get("variantcaller")
if "gvcf" not in dd.get_tools_on(... | python | def variant_filtration(call_file, ref_file, vrn_files, data, items):
"""Filter variant calls using Variant Quality Score Recalibration.
Newer GATK with Haplotype calling has combined SNP/indel filtering.
"""
caller = data["config"]["algorithm"].get("variantcaller")
if "gvcf" not in dd.get_tools_on(... | [
"def",
"variant_filtration",
"(",
"call_file",
",",
"ref_file",
",",
"vrn_files",
",",
"data",
",",
"items",
")",
":",
"caller",
"=",
"data",
"[",
"\"config\"",
"]",
"[",
"\"algorithm\"",
"]",
".",
"get",
"(",
"\"variantcaller\"",
")",
"if",
"\"gvcf\"",
"n... | Filter variant calls using Variant Quality Score Recalibration.
Newer GATK with Haplotype calling has combined SNP/indel filtering. | [
"Filter",
"variant",
"calls",
"using",
"Variant",
"Quality",
"Score",
"Recalibration",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L23-L45 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | _split_by_ready_regions | def _split_by_ready_regions(ext, file_key, dir_ext_fn):
"""Organize splits based on regions generated by parallel_prep_region.
Sort splits so largest regions analyzed first, avoiding potentially lagging runs
at end.
"""
def _sort_by_size(region_w_bams):
region, _ = region_w_bams
_, ... | python | def _split_by_ready_regions(ext, file_key, dir_ext_fn):
"""Organize splits based on regions generated by parallel_prep_region.
Sort splits so largest regions analyzed first, avoiding potentially lagging runs
at end.
"""
def _sort_by_size(region_w_bams):
region, _ = region_w_bams
_, ... | [
"def",
"_split_by_ready_regions",
"(",
"ext",
",",
"file_key",
",",
"dir_ext_fn",
")",
":",
"def",
"_sort_by_size",
"(",
"region_w_bams",
")",
":",
"region",
",",
"_",
"=",
"region_w_bams",
"_",
",",
"start",
",",
"end",
"=",
"region",
"return",
"end",
"-"... | Organize splits based on regions generated by parallel_prep_region.
Sort splits so largest regions analyzed first, avoiding potentially lagging runs
at end. | [
"Organize",
"splits",
"based",
"on",
"regions",
"generated",
"by",
"parallel_prep_region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L116-L154 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | _collapse_by_bam_variantcaller | def _collapse_by_bam_variantcaller(samples):
"""Collapse regions to a single representative by BAM input, variant caller and batch.
"""
by_bam = collections.OrderedDict()
for data in (x[0] for x in samples):
work_bam = utils.get_in(data, ("combine", "work_bam", "out"), data.get("align_bam"))
... | python | def _collapse_by_bam_variantcaller(samples):
"""Collapse regions to a single representative by BAM input, variant caller and batch.
"""
by_bam = collections.OrderedDict()
for data in (x[0] for x in samples):
work_bam = utils.get_in(data, ("combine", "work_bam", "out"), data.get("align_bam"))
... | [
"def",
"_collapse_by_bam_variantcaller",
"(",
"samples",
")",
":",
"by_bam",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"for",
"data",
"in",
"(",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"samples",
")",
":",
"work_bam",
"=",
"utils",
".",
"get_in",
... | Collapse regions to a single representative by BAM input, variant caller and batch. | [
"Collapse",
"regions",
"to",
"a",
"single",
"representative",
"by",
"BAM",
"input",
"variant",
"caller",
"and",
"batch",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L156-L178 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | _dup_samples_by_variantcaller | def _dup_samples_by_variantcaller(samples, require_bam=True):
"""Prepare samples by variant callers, duplicating any with multiple callers.
"""
samples = [utils.to_single_data(x) for x in samples]
samples = germline.split_somatic(samples)
to_process = []
extras = []
for data in samples:
... | python | def _dup_samples_by_variantcaller(samples, require_bam=True):
"""Prepare samples by variant callers, duplicating any with multiple callers.
"""
samples = [utils.to_single_data(x) for x in samples]
samples = germline.split_somatic(samples)
to_process = []
extras = []
for data in samples:
... | [
"def",
"_dup_samples_by_variantcaller",
"(",
"samples",
",",
"require_bam",
"=",
"True",
")",
":",
"samples",
"=",
"[",
"utils",
".",
"to_single_data",
"(",
"x",
")",
"for",
"x",
"in",
"samples",
"]",
"samples",
"=",
"germline",
".",
"split_somatic",
"(",
... | Prepare samples by variant callers, duplicating any with multiple callers. | [
"Prepare",
"samples",
"by",
"variant",
"callers",
"duplicating",
"any",
"with",
"multiple",
"callers",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L180-L197 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | parallel_variantcall_region | def parallel_variantcall_region(samples, run_parallel):
"""Perform variant calling and post-analysis on samples by region.
"""
to_process, extras = _dup_samples_by_variantcaller(samples)
split_fn = _split_by_ready_regions(".vcf.gz", "work_bam", get_variantcaller)
samples = _collapse_by_bam_variantca... | python | def parallel_variantcall_region(samples, run_parallel):
"""Perform variant calling and post-analysis on samples by region.
"""
to_process, extras = _dup_samples_by_variantcaller(samples)
split_fn = _split_by_ready_regions(".vcf.gz", "work_bam", get_variantcaller)
samples = _collapse_by_bam_variantca... | [
"def",
"parallel_variantcall_region",
"(",
"samples",
",",
"run_parallel",
")",
":",
"to_process",
",",
"extras",
"=",
"_dup_samples_by_variantcaller",
"(",
"samples",
")",
"split_fn",
"=",
"_split_by_ready_regions",
"(",
"\".vcf.gz\"",
",",
"\"work_bam\"",
",",
"get_... | Perform variant calling and post-analysis on samples by region. | [
"Perform",
"variant",
"calling",
"and",
"post",
"-",
"analysis",
"on",
"samples",
"by",
"region",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L199-L209 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | vc_output_record | def vc_output_record(samples):
"""Prepare output record from variant calling to feed into downstream analysis.
Prep work handles reformatting so we return generated dictionaries.
For any shared keys that are calculated only once for a batch, like variant calls
for the batch, we assign to every sample.... | python | def vc_output_record(samples):
"""Prepare output record from variant calling to feed into downstream analysis.
Prep work handles reformatting so we return generated dictionaries.
For any shared keys that are calculated only once for a batch, like variant calls
for the batch, we assign to every sample.... | [
"def",
"vc_output_record",
"(",
"samples",
")",
":",
"shared_keys",
"=",
"[",
"[",
"\"vrn_file\"",
"]",
",",
"[",
"\"validate\"",
",",
"\"summary\"",
"]",
",",
"[",
"\"validate\"",
",",
"\"tp\"",
"]",
",",
"[",
"\"validate\"",
",",
"\"fp\"",
"]",
",",
"[... | Prepare output record from variant calling to feed into downstream analysis.
Prep work handles reformatting so we return generated dictionaries.
For any shared keys that are calculated only once for a batch, like variant calls
for the batch, we assign to every sample. | [
"Prepare",
"output",
"record",
"from",
"variant",
"calling",
"to",
"feed",
"into",
"downstream",
"analysis",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L212-L236 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | batch_for_variantcall | def batch_for_variantcall(samples):
"""Prepare a set of samples for parallel variant calling.
CWL input target that groups samples into batches and variant callers
for parallel processing.
If doing joint calling, with `tools_on: [gvcf]`, split the sample into
individuals instead of combining into ... | python | def batch_for_variantcall(samples):
"""Prepare a set of samples for parallel variant calling.
CWL input target that groups samples into batches and variant callers
for parallel processing.
If doing joint calling, with `tools_on: [gvcf]`, split the sample into
individuals instead of combining into ... | [
"def",
"batch_for_variantcall",
"(",
"samples",
")",
":",
"sample_order",
"=",
"[",
"dd",
".",
"get_sample_name",
"(",
"utils",
".",
"to_single_data",
"(",
"x",
")",
")",
"for",
"x",
"in",
"samples",
"]",
"to_process",
",",
"extras",
"=",
"_dup_samples_by_va... | Prepare a set of samples for parallel variant calling.
CWL input target that groups samples into batches and variant callers
for parallel processing.
If doing joint calling, with `tools_on: [gvcf]`, split the sample into
individuals instead of combining into a batch. | [
"Prepare",
"a",
"set",
"of",
"samples",
"for",
"parallel",
"variant",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L241-L272 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | _handle_precalled | def _handle_precalled(data):
"""Copy in external pre-called variants fed into analysis.
Symlinks for non-CWL runs where we want to ensure VCF present
in a local directory.
"""
if data.get("vrn_file") and not cwlutils.is_cwl_run(data):
vrn_file = data["vrn_file"]
if isinstance(vrn_fi... | python | def _handle_precalled(data):
"""Copy in external pre-called variants fed into analysis.
Symlinks for non-CWL runs where we want to ensure VCF present
in a local directory.
"""
if data.get("vrn_file") and not cwlutils.is_cwl_run(data):
vrn_file = data["vrn_file"]
if isinstance(vrn_fi... | [
"def",
"_handle_precalled",
"(",
"data",
")",
":",
"if",
"data",
".",
"get",
"(",
"\"vrn_file\"",
")",
"and",
"not",
"cwlutils",
".",
"is_cwl_run",
"(",
"data",
")",
":",
"vrn_file",
"=",
"data",
"[",
"\"vrn_file\"",
"]",
"if",
"isinstance",
"(",
"vrn_fi... | Copy in external pre-called variants fed into analysis.
Symlinks for non-CWL runs where we want to ensure VCF present
in a local directory. | [
"Copy",
"in",
"external",
"pre",
"-",
"called",
"variants",
"fed",
"into",
"analysis",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L274-L291 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | handle_multiple_callers | def handle_multiple_callers(data, key, default=None, require_bam=True):
"""Split samples that potentially require multiple variant calling approaches.
"""
callers = get_variantcaller(data, key, default, require_bam=require_bam)
if isinstance(callers, six.string_types):
return [data]
elif not... | python | def handle_multiple_callers(data, key, default=None, require_bam=True):
"""Split samples that potentially require multiple variant calling approaches.
"""
callers = get_variantcaller(data, key, default, require_bam=require_bam)
if isinstance(callers, six.string_types):
return [data]
elif not... | [
"def",
"handle_multiple_callers",
"(",
"data",
",",
"key",
",",
"default",
"=",
"None",
",",
"require_bam",
"=",
"True",
")",
":",
"callers",
"=",
"get_variantcaller",
"(",
"data",
",",
"key",
",",
"default",
",",
"require_bam",
"=",
"require_bam",
")",
"i... | Split samples that potentially require multiple variant calling approaches. | [
"Split",
"samples",
"that",
"potentially",
"require",
"multiple",
"variant",
"calling",
"approaches",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L293-L322 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | variantcall_sample | def variantcall_sample(data, region=None, align_bams=None, out_file=None):
"""Parallel entry point for doing genotyping of a region of a sample.
"""
if out_file is None or not os.path.exists(out_file) or not os.path.lexists(out_file):
utils.safe_makedir(os.path.dirname(out_file))
ref_file = ... | python | def variantcall_sample(data, region=None, align_bams=None, out_file=None):
"""Parallel entry point for doing genotyping of a region of a sample.
"""
if out_file is None or not os.path.exists(out_file) or not os.path.lexists(out_file):
utils.safe_makedir(os.path.dirname(out_file))
ref_file = ... | [
"def",
"variantcall_sample",
"(",
"data",
",",
"region",
"=",
"None",
",",
"align_bams",
"=",
"None",
",",
"out_file",
"=",
"None",
")",
":",
"if",
"out_file",
"is",
"None",
"or",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"out_file",
")",
"or",
"... | Parallel entry point for doing genotyping of a region of a sample. | [
"Parallel",
"entry",
"point",
"for",
"doing",
"genotyping",
"of",
"a",
"region",
"of",
"a",
"sample",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L359-L381 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | _get_batch_name | def _get_batch_name(items, skip_jointcheck=False):
"""Retrieve the shared batch name for a group of items.
"""
batch_names = collections.defaultdict(int)
has_joint = any([is_joint(d) for d in items])
for data in items:
if has_joint and not skip_jointcheck:
batches = dd.get_sample... | python | def _get_batch_name(items, skip_jointcheck=False):
"""Retrieve the shared batch name for a group of items.
"""
batch_names = collections.defaultdict(int)
has_joint = any([is_joint(d) for d in items])
for data in items:
if has_joint and not skip_jointcheck:
batches = dd.get_sample... | [
"def",
"_get_batch_name",
"(",
"items",
",",
"skip_jointcheck",
"=",
"False",
")",
":",
"batch_names",
"=",
"collections",
".",
"defaultdict",
"(",
"int",
")",
"has_joint",
"=",
"any",
"(",
"[",
"is_joint",
"(",
"d",
")",
"for",
"d",
"in",
"items",
"]",
... | Retrieve the shared batch name for a group of items. | [
"Retrieve",
"the",
"shared",
"batch",
"name",
"for",
"a",
"group",
"of",
"items",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L410-L424 | train |
bcbio/bcbio-nextgen | bcbio/variation/genotype.py | _run_variantcall_batch_multicore | def _run_variantcall_batch_multicore(items, regions, final_file):
"""Run variant calling on a batch of items using multiple cores.
"""
batch_name = _get_batch_name(items)
variantcaller = _get_batch_variantcaller(items)
work_bams = [dd.get_work_bam(d) or dd.get_align_bam(d) for d in items]
def sp... | python | def _run_variantcall_batch_multicore(items, regions, final_file):
"""Run variant calling on a batch of items using multiple cores.
"""
batch_name = _get_batch_name(items)
variantcaller = _get_batch_variantcaller(items)
work_bams = [dd.get_work_bam(d) or dd.get_align_bam(d) for d in items]
def sp... | [
"def",
"_run_variantcall_batch_multicore",
"(",
"items",
",",
"regions",
",",
"final_file",
")",
":",
"batch_name",
"=",
"_get_batch_name",
"(",
"items",
")",
"variantcaller",
"=",
"_get_batch_variantcaller",
"(",
"items",
")",
"work_bams",
"=",
"[",
"dd",
".",
... | Run variant calling on a batch of items using multiple cores. | [
"Run",
"variant",
"calling",
"on",
"a",
"batch",
"of",
"items",
"using",
"multiple",
"cores",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L462-L486 | train |
bcbio/bcbio-nextgen | bcbio/distributed/ipython.py | create | def create(parallel, dirs, config):
"""Create a cluster based on the provided parallel arguments.
Returns an IPython view on the cluster, enabling processing on jobs.
Adds a mincores specification if he have machines with a larger
number of cores to allow jobs to be batched together for shared
mem... | python | def create(parallel, dirs, config):
"""Create a cluster based on the provided parallel arguments.
Returns an IPython view on the cluster, enabling processing on jobs.
Adds a mincores specification if he have machines with a larger
number of cores to allow jobs to be batched together for shared
mem... | [
"def",
"create",
"(",
"parallel",
",",
"dirs",
",",
"config",
")",
":",
"profile_dir",
"=",
"utils",
".",
"safe_makedir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dirs",
"[",
"\"work\"",
"]",
",",
"get_log_dir",
"(",
"config",
")",
",",
"\"ipython\""... | Create a cluster based on the provided parallel arguments.
Returns an IPython view on the cluster, enabling processing on jobs.
Adds a mincores specification if he have machines with a larger
number of cores to allow jobs to be batched together for shared
memory usage. | [
"Create",
"a",
"cluster",
"based",
"on",
"the",
"provided",
"parallel",
"arguments",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/ipython.py#L33-L65 | train |
bcbio/bcbio-nextgen | bcbio/distributed/ipython.py | per_machine_target_cores | def per_machine_target_cores(cores, num_jobs):
"""Select target cores on larger machines to leave room for batch script and controller.
On resource constrained environments, we want to pack all bcbio submissions onto a specific
number of machines. This gives up some cores to enable sharing cores with the c... | python | def per_machine_target_cores(cores, num_jobs):
"""Select target cores on larger machines to leave room for batch script and controller.
On resource constrained environments, we want to pack all bcbio submissions onto a specific
number of machines. This gives up some cores to enable sharing cores with the c... | [
"def",
"per_machine_target_cores",
"(",
"cores",
",",
"num_jobs",
")",
":",
"if",
"cores",
">=",
"32",
"and",
"num_jobs",
"==",
"1",
":",
"cores",
"=",
"cores",
"-",
"2",
"elif",
"cores",
">=",
"16",
"and",
"num_jobs",
"in",
"[",
"1",
",",
"2",
"]",
... | Select target cores on larger machines to leave room for batch script and controller.
On resource constrained environments, we want to pack all bcbio submissions onto a specific
number of machines. This gives up some cores to enable sharing cores with the controller
and batch script on larger machines. | [
"Select",
"target",
"cores",
"on",
"larger",
"machines",
"to",
"leave",
"room",
"for",
"batch",
"script",
"and",
"controller",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/ipython.py#L67-L78 | train |
bcbio/bcbio-nextgen | bcbio/distributed/ipython.py | _get_common_cores | def _get_common_cores(resources):
"""Retrieve the most common configured number of cores in the input file.
"""
all_cores = []
for vs in resources.values():
cores = vs.get("cores")
if cores:
all_cores.append(int(vs["cores"]))
return collections.Counter(all_cores).most_com... | python | def _get_common_cores(resources):
"""Retrieve the most common configured number of cores in the input file.
"""
all_cores = []
for vs in resources.values():
cores = vs.get("cores")
if cores:
all_cores.append(int(vs["cores"]))
return collections.Counter(all_cores).most_com... | [
"def",
"_get_common_cores",
"(",
"resources",
")",
":",
"all_cores",
"=",
"[",
"]",
"for",
"vs",
"in",
"resources",
".",
"values",
"(",
")",
":",
"cores",
"=",
"vs",
".",
"get",
"(",
"\"cores\"",
")",
"if",
"cores",
":",
"all_cores",
".",
"append",
"... | Retrieve the most common configured number of cores in the input file. | [
"Retrieve",
"the",
"most",
"common",
"configured",
"number",
"of",
"cores",
"in",
"the",
"input",
"file",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/ipython.py#L80-L88 | train |
bcbio/bcbio-nextgen | bcbio/distributed/ipython.py | zip_args | def zip_args(args, config=None):
"""Compress arguments using msgpack.
"""
if msgpack:
return [msgpack.packb(x, use_single_float=True, use_bin_type=True) for x in args]
else:
return args | python | def zip_args(args, config=None):
"""Compress arguments using msgpack.
"""
if msgpack:
return [msgpack.packb(x, use_single_float=True, use_bin_type=True) for x in args]
else:
return args | [
"def",
"zip_args",
"(",
"args",
",",
"config",
"=",
"None",
")",
":",
"if",
"msgpack",
":",
"return",
"[",
"msgpack",
".",
"packb",
"(",
"x",
",",
"use_single_float",
"=",
"True",
",",
"use_bin_type",
"=",
"True",
")",
"for",
"x",
"in",
"args",
"]",
... | Compress arguments using msgpack. | [
"Compress",
"arguments",
"using",
"msgpack",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/ipython.py#L103-L109 | train |
bcbio/bcbio-nextgen | bcbio/distributed/ipython.py | runner | def runner(view, parallel, dirs, config):
"""Run a task on an ipython parallel cluster, allowing alternative queue types.
view provides map-style access to an existing Ipython cluster.
"""
def run(fn_name, items):
setpath.prepend_bcbiopath()
out = []
fn, fn_name = (fn_name, fn_n... | python | def runner(view, parallel, dirs, config):
"""Run a task on an ipython parallel cluster, allowing alternative queue types.
view provides map-style access to an existing Ipython cluster.
"""
def run(fn_name, items):
setpath.prepend_bcbiopath()
out = []
fn, fn_name = (fn_name, fn_n... | [
"def",
"runner",
"(",
"view",
",",
"parallel",
",",
"dirs",
",",
"config",
")",
":",
"def",
"run",
"(",
"fn_name",
",",
"items",
")",
":",
"setpath",
".",
"prepend_bcbiopath",
"(",
")",
"out",
"=",
"[",
"]",
"fn",
",",
"fn_name",
"=",
"(",
"fn_name... | Run a task on an ipython parallel cluster, allowing alternative queue types.
view provides map-style access to an existing Ipython cluster. | [
"Run",
"a",
"task",
"on",
"an",
"ipython",
"parallel",
"cluster",
"allowing",
"alternative",
"queue",
"types",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/ipython.py#L119-L141 | train |
bcbio/bcbio-nextgen | bcbio/chipseq/peaks.py | peakcall_prepare | def peakcall_prepare(data, run_parallel):
"""Entry point for doing peak calling"""
caller_fns = get_callers()
to_process = []
for sample in data:
mimic = copy.copy(sample[0])
callers = dd.get_peakcaller(sample[0])
if not isinstance(callers, list):
callers = [callers]
... | python | def peakcall_prepare(data, run_parallel):
"""Entry point for doing peak calling"""
caller_fns = get_callers()
to_process = []
for sample in data:
mimic = copy.copy(sample[0])
callers = dd.get_peakcaller(sample[0])
if not isinstance(callers, list):
callers = [callers]
... | [
"def",
"peakcall_prepare",
"(",
"data",
",",
"run_parallel",
")",
":",
"caller_fns",
"=",
"get_callers",
"(",
")",
"to_process",
"=",
"[",
"]",
"for",
"sample",
"in",
"data",
":",
"mimic",
"=",
"copy",
".",
"copy",
"(",
"sample",
"[",
"0",
"]",
")",
... | Entry point for doing peak calling | [
"Entry",
"point",
"for",
"doing",
"peak",
"calling"
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/peaks.py#L22-L43 | train |
bcbio/bcbio-nextgen | bcbio/chipseq/peaks.py | calling | def calling(data):
"""Main function to parallelize peak calling."""
chip_bam = data.get("work_bam")
input_bam = data.get("work_bam_input", None)
caller_fn = get_callers()[data["peak_fn"]]
name = dd.get_sample_name(data)
out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data), data["peak_... | python | def calling(data):
"""Main function to parallelize peak calling."""
chip_bam = data.get("work_bam")
input_bam = data.get("work_bam_input", None)
caller_fn = get_callers()[data["peak_fn"]]
name = dd.get_sample_name(data)
out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data), data["peak_... | [
"def",
"calling",
"(",
"data",
")",
":",
"chip_bam",
"=",
"data",
".",
"get",
"(",
"\"work_bam\"",
")",
"input_bam",
"=",
"data",
".",
"get",
"(",
"\"work_bam_input\"",
",",
"None",
")",
"caller_fn",
"=",
"get_callers",
"(",
")",
"[",
"data",
"[",
"\"p... | Main function to parallelize peak calling. | [
"Main",
"function",
"to",
"parallelize",
"peak",
"calling",
"."
] | 6a9348c0054ccd5baffd22f1bb7d0422f6978b20 | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/chipseq/peaks.py#L45-L59 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.