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/heterogeneity/bubbletree.py
sample_alt_and_depth
def sample_alt_and_depth(rec, sample): """Flexibly get ALT allele and depth counts, handling FreeBayes, MuTect and other cases. """ if sample and "AD" in sample: all_counts = [int(x) for x in sample["AD"]] alt_counts = sum(all_counts[1:]) depth = sum(all_counts) elif sample and "...
python
def sample_alt_and_depth(rec, sample): """Flexibly get ALT allele and depth counts, handling FreeBayes, MuTect and other cases. """ if sample and "AD" in sample: all_counts = [int(x) for x in sample["AD"]] alt_counts = sum(all_counts[1:]) depth = sum(all_counts) elif sample and "...
[ "def", "sample_alt_and_depth", "(", "rec", ",", "sample", ")", ":", "if", "sample", "and", "\"AD\"", "in", "sample", ":", "all_counts", "=", "[", "int", "(", "x", ")", "for", "x", "in", "sample", "[", "\"AD\"", "]", "]", "alt_counts", "=", "sum", "("...
Flexibly get ALT allele and depth counts, handling FreeBayes, MuTect and other cases.
[ "Flexibly", "get", "ALT", "allele", "and", "depth", "counts", "handling", "FreeBayes", "MuTect", "and", "other", "cases", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/bubbletree.py#L403-L425
train
bcbio/bcbio-nextgen
bcbio/bam/ref.py
fasta_idx
def fasta_idx(in_file, config=None): """Retrieve samtools style fasta index. """ fasta_index = in_file + ".fai" if not utils.file_exists(fasta_index): samtools = config_utils.get_program("samtools", config) if config else "samtools" cmd = "{samtools} faidx {in_file}" do.run(cmd.f...
python
def fasta_idx(in_file, config=None): """Retrieve samtools style fasta index. """ fasta_index = in_file + ".fai" if not utils.file_exists(fasta_index): samtools = config_utils.get_program("samtools", config) if config else "samtools" cmd = "{samtools} faidx {in_file}" do.run(cmd.f...
[ "def", "fasta_idx", "(", "in_file", ",", "config", "=", "None", ")", ":", "fasta_index", "=", "in_file", "+", "\".fai\"", "if", "not", "utils", ".", "file_exists", "(", "fasta_index", ")", ":", "samtools", "=", "config_utils", ".", "get_program", "(", "\"s...
Retrieve samtools style fasta index.
[ "Retrieve", "samtools", "style", "fasta", "index", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/ref.py#L9-L17
train
bcbio/bcbio-nextgen
bcbio/bam/ref.py
file_contigs
def file_contigs(ref_file, config=None): """Iterator of reference contigs and lengths from a reference file. """ ContigInfo = collections.namedtuple("ContigInfo", "name size") with open(fasta_idx(ref_file, config)) as in_handle: for line in (l for l in in_handle if l.strip()): name, ...
python
def file_contigs(ref_file, config=None): """Iterator of reference contigs and lengths from a reference file. """ ContigInfo = collections.namedtuple("ContigInfo", "name size") with open(fasta_idx(ref_file, config)) as in_handle: for line in (l for l in in_handle if l.strip()): name, ...
[ "def", "file_contigs", "(", "ref_file", ",", "config", "=", "None", ")", ":", "ContigInfo", "=", "collections", ".", "namedtuple", "(", "\"ContigInfo\"", ",", "\"name size\"", ")", "with", "open", "(", "fasta_idx", "(", "ref_file", ",", "config", ")", ")", ...
Iterator of reference contigs and lengths from a reference file.
[ "Iterator", "of", "reference", "contigs", "and", "lengths", "from", "a", "reference", "file", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/ref.py#L19-L26
train
bcbio/bcbio-nextgen
bcbio/variation/smcounter2.py
run
def run(align_bams, items, ref_file, assoc_files, region=None, out_file=None): """Run tumor only smCounter2 calling. """ paired = vcfutils.get_paired_bams(align_bams, items) assert paired and not paired.normal_bam, ("smCounter2 supports tumor-only variant calling: %s" % ...
python
def run(align_bams, items, ref_file, assoc_files, region=None, out_file=None): """Run tumor only smCounter2 calling. """ paired = vcfutils.get_paired_bams(align_bams, items) assert paired and not paired.normal_bam, ("smCounter2 supports tumor-only variant calling: %s" % ...
[ "def", "run", "(", "align_bams", ",", "items", ",", "ref_file", ",", "assoc_files", ",", "region", "=", "None", ",", "out_file", "=", "None", ")", ":", "paired", "=", "vcfutils", ".", "get_paired_bams", "(", "align_bams", ",", "items", ")", "assert", "pa...
Run tumor only smCounter2 calling.
[ "Run", "tumor", "only", "smCounter2", "calling", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/smcounter2.py#L17-L44
train
bcbio/bcbio-nextgen
bcbio/bam/readstats.py
number_of_mapped_reads
def number_of_mapped_reads(data, bam_file, keep_dups=True, bed_file=None, target_name=None): """Count mapped reads, allow adjustment for duplicates and BED regions. Since samtools view does not use indexes for BED files (https://github.com/samtools/samtools/issues/88) we loop over regions in a BED file...
python
def number_of_mapped_reads(data, bam_file, keep_dups=True, bed_file=None, target_name=None): """Count mapped reads, allow adjustment for duplicates and BED regions. Since samtools view does not use indexes for BED files (https://github.com/samtools/samtools/issues/88) we loop over regions in a BED file...
[ "def", "number_of_mapped_reads", "(", "data", ",", "bam_file", ",", "keep_dups", "=", "True", ",", "bed_file", "=", "None", ",", "target_name", "=", "None", ")", ":", "# Flag explainer https://broadinstitute.github.io/picard/explain-flags.html", "callable_flags", "=", "...
Count mapped reads, allow adjustment for duplicates and BED regions. Since samtools view does not use indexes for BED files (https://github.com/samtools/samtools/issues/88) we loop over regions in a BED file and add the counts together. Uses a global cache file to store counts, making it possible to p...
[ "Count", "mapped", "reads", "allow", "adjustment", "for", "duplicates", "and", "BED", "regions", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/readstats.py#L37-L102
train
bcbio/bcbio-nextgen
bcbio/bam/readstats.py
_simple_lock
def _simple_lock(f): """Simple file lock, times out after 20 second assuming lock is stale """ lock_file = f + ".lock" timeout = 20 curtime = 0 interval = 2 while os.path.exists(lock_file): time.sleep(interval) curtime += interval if curtime > timeout: os....
python
def _simple_lock(f): """Simple file lock, times out after 20 second assuming lock is stale """ lock_file = f + ".lock" timeout = 20 curtime = 0 interval = 2 while os.path.exists(lock_file): time.sleep(interval) curtime += interval if curtime > timeout: os....
[ "def", "_simple_lock", "(", "f", ")", ":", "lock_file", "=", "f", "+", "\".lock\"", "timeout", "=", "20", "curtime", "=", "0", "interval", "=", "2", "while", "os", ".", "path", ".", "exists", "(", "lock_file", ")", ":", "time", ".", "sleep", "(", "...
Simple file lock, times out after 20 second assuming lock is stale
[ "Simple", "file", "lock", "times", "out", "after", "20", "second", "assuming", "lock", "is", "stale" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/readstats.py#L105-L121
train
bcbio/bcbio-nextgen
bcbio/pipeline/region.py
get_max_counts
def get_max_counts(samples): """Retrieve number of regions that can be processed in parallel from current samples. """ counts = [] for data in (x[0] for x in samples): count = tz.get_in(["config", "algorithm", "callable_count"], data, 1) vcs = tz.get_in(["config", "algorithm", "variantca...
python
def get_max_counts(samples): """Retrieve number of regions that can be processed in parallel from current samples. """ counts = [] for data in (x[0] for x in samples): count = tz.get_in(["config", "algorithm", "callable_count"], data, 1) vcs = tz.get_in(["config", "algorithm", "variantca...
[ "def", "get_max_counts", "(", "samples", ")", ":", "counts", "=", "[", "]", "for", "data", "in", "(", "x", "[", "0", "]", "for", "x", "in", "samples", ")", ":", "count", "=", "tz", ".", "get_in", "(", "[", "\"config\"", ",", "\"algorithm\"", ",", ...
Retrieve number of regions that can be processed in parallel from current samples.
[ "Retrieve", "number", "of", "regions", "that", "can", "be", "processed", "in", "parallel", "from", "current", "samples", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L16-L28
train
bcbio/bcbio-nextgen
bcbio/pipeline/region.py
_split_by_regions
def _split_by_regions(dirname, out_ext, in_key): """Split a BAM file data analysis into chromosomal regions. """ def _do_work(data): # XXX Need to move retrieval of regions into preparation to avoid # need for files when running in non-shared filesystems regions = _get_parallel_regio...
python
def _split_by_regions(dirname, out_ext, in_key): """Split a BAM file data analysis into chromosomal regions. """ def _do_work(data): # XXX Need to move retrieval of regions into preparation to avoid # need for files when running in non-shared filesystems regions = _get_parallel_regio...
[ "def", "_split_by_regions", "(", "dirname", ",", "out_ext", ",", "in_key", ")", ":", "def", "_do_work", "(", "data", ")", ":", "# XXX Need to move retrieval of regions into preparation to avoid", "# need for files when running in non-shared filesystems", "regions", "=", "_get...
Split a BAM file data analysis into chromosomal regions.
[ "Split", "a", "BAM", "file", "data", "analysis", "into", "chromosomal", "regions", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L40-L65
train
bcbio/bcbio-nextgen
bcbio/pipeline/region.py
_get_parallel_regions
def _get_parallel_regions(data): """Retrieve regions to run in parallel, putting longest intervals first. """ callable_regions = tz.get_in(["config", "algorithm", "callable_regions"], data) if not callable_regions: raise ValueError("Did not find any callable regions for sample: %s\n" ...
python
def _get_parallel_regions(data): """Retrieve regions to run in parallel, putting longest intervals first. """ callable_regions = tz.get_in(["config", "algorithm", "callable_regions"], data) if not callable_regions: raise ValueError("Did not find any callable regions for sample: %s\n" ...
[ "def", "_get_parallel_regions", "(", "data", ")", ":", "callable_regions", "=", "tz", ".", "get_in", "(", "[", "\"config\"", ",", "\"algorithm\"", ",", "\"callable_regions\"", "]", ",", "data", ")", "if", "not", "callable_regions", ":", "raise", "ValueError", ...
Retrieve regions to run in parallel, putting longest intervals first.
[ "Retrieve", "regions", "to", "run", "in", "parallel", "putting", "longest", "intervals", "first", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L67-L79
train
bcbio/bcbio-nextgen
bcbio/pipeline/region.py
get_parallel_regions
def get_parallel_regions(batch): """CWL target to retrieve a list of callable regions for parallelization. """ samples = [utils.to_single_data(d) for d in batch] regions = _get_parallel_regions(samples[0]) return [{"region": "%s:%s-%s" % (c, s, e)} for c, s, e in regions]
python
def get_parallel_regions(batch): """CWL target to retrieve a list of callable regions for parallelization. """ samples = [utils.to_single_data(d) for d in batch] regions = _get_parallel_regions(samples[0]) return [{"region": "%s:%s-%s" % (c, s, e)} for c, s, e in regions]
[ "def", "get_parallel_regions", "(", "batch", ")", ":", "samples", "=", "[", "utils", ".", "to_single_data", "(", "d", ")", "for", "d", "in", "batch", "]", "regions", "=", "_get_parallel_regions", "(", "samples", "[", "0", "]", ")", "return", "[", "{", ...
CWL target to retrieve a list of callable regions for parallelization.
[ "CWL", "target", "to", "retrieve", "a", "list", "of", "callable", "regions", "for", "parallelization", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L81-L86
train
bcbio/bcbio-nextgen
bcbio/pipeline/region.py
get_parallel_regions_block
def get_parallel_regions_block(batch): """CWL target to retrieve block group of callable regions for parallelization. Uses blocking to handle multicore runs. """ samples = [utils.to_single_data(d) for d in batch] regions = _get_parallel_regions(samples[0]) out = [] # Currently don't have co...
python
def get_parallel_regions_block(batch): """CWL target to retrieve block group of callable regions for parallelization. Uses blocking to handle multicore runs. """ samples = [utils.to_single_data(d) for d in batch] regions = _get_parallel_regions(samples[0]) out = [] # Currently don't have co...
[ "def", "get_parallel_regions_block", "(", "batch", ")", ":", "samples", "=", "[", "utils", ".", "to_single_data", "(", "d", ")", "for", "d", "in", "batch", "]", "regions", "=", "_get_parallel_regions", "(", "samples", "[", "0", "]", ")", "out", "=", "[",...
CWL target to retrieve block group of callable regions for parallelization. Uses blocking to handle multicore runs.
[ "CWL", "target", "to", "retrieve", "block", "group", "of", "callable", "regions", "for", "parallelization", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L88-L100
train
bcbio/bcbio-nextgen
bcbio/pipeline/region.py
_add_combine_info
def _add_combine_info(output, combine_map, file_key): """Do not actually combine, but add details for later combining work. Each sample will contain information on the out file and additional files to merge, enabling other splits and recombines without losing information. """ files_per_output = col...
python
def _add_combine_info(output, combine_map, file_key): """Do not actually combine, but add details for later combining work. Each sample will contain information on the out file and additional files to merge, enabling other splits and recombines without losing information. """ files_per_output = col...
[ "def", "_add_combine_info", "(", "output", ",", "combine_map", ",", "file_key", ")", ":", "files_per_output", "=", "collections", ".", "defaultdict", "(", "list", ")", "for", "part_file", ",", "out_file", "in", "combine_map", ".", "items", "(", ")", ":", "fi...
Do not actually combine, but add details for later combining work. Each sample will contain information on the out file and additional files to merge, enabling other splits and recombines without losing information.
[ "Do", "not", "actually", "combine", "but", "add", "details", "for", "later", "combining", "work", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L102-L141
train
bcbio/bcbio-nextgen
bcbio/pipeline/region.py
parallel_prep_region
def parallel_prep_region(samples, run_parallel): """Perform full pre-variant calling BAM prep work on regions. """ file_key = "work_bam" split_fn = _split_by_regions("bamprep", "-prep.bam", file_key) # identify samples that do not need preparation -- no recalibration or realignment extras = [] ...
python
def parallel_prep_region(samples, run_parallel): """Perform full pre-variant calling BAM prep work on regions. """ file_key = "work_bam" split_fn = _split_by_regions("bamprep", "-prep.bam", file_key) # identify samples that do not need preparation -- no recalibration or realignment extras = [] ...
[ "def", "parallel_prep_region", "(", "samples", ",", "run_parallel", ")", ":", "file_key", "=", "\"work_bam\"", "split_fn", "=", "_split_by_regions", "(", "\"bamprep\"", ",", "\"-prep.bam\"", ",", "file_key", ")", "# identify samples that do not need preparation -- no recali...
Perform full pre-variant calling BAM prep work on regions.
[ "Perform", "full", "pre", "-", "variant", "calling", "BAM", "prep", "work", "on", "regions", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L143-L164
train
bcbio/bcbio-nextgen
bcbio/pipeline/region.py
delayed_bamprep_merge
def delayed_bamprep_merge(samples, run_parallel): """Perform a delayed merge on regional prepared BAM files. """ if any("combine" in data[0] for data in samples): return run_parallel("delayed_bam_merge", samples) else: return samples
python
def delayed_bamprep_merge(samples, run_parallel): """Perform a delayed merge on regional prepared BAM files. """ if any("combine" in data[0] for data in samples): return run_parallel("delayed_bam_merge", samples) else: return samples
[ "def", "delayed_bamprep_merge", "(", "samples", ",", "run_parallel", ")", ":", "if", "any", "(", "\"combine\"", "in", "data", "[", "0", "]", "for", "data", "in", "samples", ")", ":", "return", "run_parallel", "(", "\"delayed_bam_merge\"", ",", "samples", ")"...
Perform a delayed merge on regional prepared BAM files.
[ "Perform", "a", "delayed", "merge", "on", "regional", "prepared", "BAM", "files", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L166-L172
train
bcbio/bcbio-nextgen
bcbio/pipeline/region.py
clean_sample_data
def clean_sample_data(samples): """Clean unnecessary information from sample data, reducing size for message passing. """ out = [] for data in (utils.to_single_data(x) for x in samples): if "dirs" in data: data["dirs"] = {"work": data["dirs"]["work"], "galaxy": data["dirs"]["galaxy"]...
python
def clean_sample_data(samples): """Clean unnecessary information from sample data, reducing size for message passing. """ out = [] for data in (utils.to_single_data(x) for x in samples): if "dirs" in data: data["dirs"] = {"work": data["dirs"]["work"], "galaxy": data["dirs"]["galaxy"]...
[ "def", "clean_sample_data", "(", "samples", ")", ":", "out", "=", "[", "]", "for", "data", "in", "(", "utils", ".", "to_single_data", "(", "x", ")", "for", "x", "in", "samples", ")", ":", "if", "\"dirs\"", "in", "data", ":", "data", "[", "\"dirs\"", ...
Clean unnecessary information from sample data, reducing size for message passing.
[ "Clean", "unnecessary", "information", "from", "sample", "data", "reducing", "size", "for", "message", "passing", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/region.py#L176-L189
train
bcbio/bcbio-nextgen
bcbio/ngsalign/star.py
_add_sj_index_commands
def _add_sj_index_commands(fq1, ref_file, gtf_file): """ newer versions of STAR can generate splice junction databases on thephfly this is preferable since we can tailor it to the read lengths """ if _has_sj_index(ref_file): return "" else: rlength = fastq.estimate_maximum_read_l...
python
def _add_sj_index_commands(fq1, ref_file, gtf_file): """ newer versions of STAR can generate splice junction databases on thephfly this is preferable since we can tailor it to the read lengths """ if _has_sj_index(ref_file): return "" else: rlength = fastq.estimate_maximum_read_l...
[ "def", "_add_sj_index_commands", "(", "fq1", ",", "ref_file", ",", "gtf_file", ")", ":", "if", "_has_sj_index", "(", "ref_file", ")", ":", "return", "\"\"", "else", ":", "rlength", "=", "fastq", ".", "estimate_maximum_read_length", "(", "fq1", ")", "cmd", "=...
newer versions of STAR can generate splice junction databases on thephfly this is preferable since we can tailor it to the read lengths
[ "newer", "versions", "of", "STAR", "can", "generate", "splice", "junction", "databases", "on", "thephfly", "this", "is", "preferable", "since", "we", "can", "tailor", "it", "to", "the", "read", "lengths" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L119-L130
train
bcbio/bcbio-nextgen
bcbio/ngsalign/star.py
_has_sj_index
def _has_sj_index(ref_file): """this file won't exist if we can do on the fly splice junction indexing""" return (file_exists(os.path.join(ref_file, "sjdbInfo.txt")) and (file_exists(os.path.join(ref_file, "transcriptInfo.tab"))))
python
def _has_sj_index(ref_file): """this file won't exist if we can do on the fly splice junction indexing""" return (file_exists(os.path.join(ref_file, "sjdbInfo.txt")) and (file_exists(os.path.join(ref_file, "transcriptInfo.tab"))))
[ "def", "_has_sj_index", "(", "ref_file", ")", ":", "return", "(", "file_exists", "(", "os", ".", "path", ".", "join", "(", "ref_file", ",", "\"sjdbInfo.txt\"", ")", ")", "and", "(", "file_exists", "(", "os", ".", "path", ".", "join", "(", "ref_file", "...
this file won't exist if we can do on the fly splice junction indexing
[ "this", "file", "won", "t", "exist", "if", "we", "can", "do", "on", "the", "fly", "splice", "junction", "indexing" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L132-L135
train
bcbio/bcbio-nextgen
bcbio/ngsalign/star.py
remap_index_fn
def remap_index_fn(ref_file): """Map sequence references to equivalent star indexes """ return os.path.join(os.path.dirname(os.path.dirname(ref_file)), "star")
python
def remap_index_fn(ref_file): """Map sequence references to equivalent star indexes """ return os.path.join(os.path.dirname(os.path.dirname(ref_file)), "star")
[ "def", "remap_index_fn", "(", "ref_file", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "dirname", "(", "ref_file", ")", ")", ",", "\"star\"", ")" ]
Map sequence references to equivalent star indexes
[ "Map", "sequence", "references", "to", "equivalent", "star", "indexes" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L171-L174
train
bcbio/bcbio-nextgen
bcbio/ngsalign/star.py
index
def index(ref_file, out_dir, data): """Create a STAR index in the defined reference directory. """ (ref_dir, local_file) = os.path.split(ref_file) gtf_file = dd.get_gtf_file(data) if not utils.file_exists(gtf_file): raise ValueError("%s not found, could not create a star index." % (gtf_file)...
python
def index(ref_file, out_dir, data): """Create a STAR index in the defined reference directory. """ (ref_dir, local_file) = os.path.split(ref_file) gtf_file = dd.get_gtf_file(data) if not utils.file_exists(gtf_file): raise ValueError("%s not found, could not create a star index." % (gtf_file)...
[ "def", "index", "(", "ref_file", ",", "out_dir", ",", "data", ")", ":", "(", "ref_dir", ",", "local_file", ")", "=", "os", ".", "path", ".", "split", "(", "ref_file", ")", "gtf_file", "=", "dd", ".", "get_gtf_file", "(", "data", ")", "if", "not", "...
Create a STAR index in the defined reference directory.
[ "Create", "a", "STAR", "index", "in", "the", "defined", "reference", "directory", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L176-L193
train
bcbio/bcbio-nextgen
bcbio/ngsalign/star.py
get_splicejunction_file
def get_splicejunction_file(out_dir, data): """ locate the splicejunction file starting from the alignment directory """ samplename = dd.get_sample_name(data) sjfile = os.path.join(out_dir, os.pardir, "{0}SJ.out.tab").format(samplename) if file_exists(sjfile): return sjfile else: ...
python
def get_splicejunction_file(out_dir, data): """ locate the splicejunction file starting from the alignment directory """ samplename = dd.get_sample_name(data) sjfile = os.path.join(out_dir, os.pardir, "{0}SJ.out.tab").format(samplename) if file_exists(sjfile): return sjfile else: ...
[ "def", "get_splicejunction_file", "(", "out_dir", ",", "data", ")", ":", "samplename", "=", "dd", ".", "get_sample_name", "(", "data", ")", "sjfile", "=", "os", ".", "path", ".", "join", "(", "out_dir", ",", "os", ".", "pardir", ",", "\"{0}SJ.out.tab\"", ...
locate the splicejunction file starting from the alignment directory
[ "locate", "the", "splicejunction", "file", "starting", "from", "the", "alignment", "directory" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L207-L216
train
bcbio/bcbio-nextgen
bcbio/ngsalign/star.py
junction2bed
def junction2bed(junction_file): """ reformat the STAR junction file to BED3 format, one end of the splice junction per line """ base, _ = os.path.splitext(junction_file) out_file = base + "-minimized.bed" if file_exists(out_file): return out_file if not file_exists(junction_file): ...
python
def junction2bed(junction_file): """ reformat the STAR junction file to BED3 format, one end of the splice junction per line """ base, _ = os.path.splitext(junction_file) out_file = base + "-minimized.bed" if file_exists(out_file): return out_file if not file_exists(junction_file): ...
[ "def", "junction2bed", "(", "junction_file", ")", ":", "base", ",", "_", "=", "os", ".", "path", ".", "splitext", "(", "junction_file", ")", "out_file", "=", "base", "+", "\"-minimized.bed\"", "if", "file_exists", "(", "out_file", ")", ":", "return", "out_...
reformat the STAR junction file to BED3 format, one end of the splice junction per line
[ "reformat", "the", "STAR", "junction", "file", "to", "BED3", "format", "one", "end", "of", "the", "splice", "junction", "per", "line" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/ngsalign/star.py#L218-L242
train
bcbio/bcbio-nextgen
bcbio/hla/optitype.py
run
def run(data): """HLA typing with OptiType, parsing output from called genotype files. """ hlas = [] for hla_fq in tz.get_in(["hla", "fastq"], data, []): hla_type = re.search("[.-](?P<hlatype>HLA-[\w-]+).fq", hla_fq).group("hlatype") if hla_type in SUPPORTED_HLAS: if utils.fi...
python
def run(data): """HLA typing with OptiType, parsing output from called genotype files. """ hlas = [] for hla_fq in tz.get_in(["hla", "fastq"], data, []): hla_type = re.search("[.-](?P<hlatype>HLA-[\w-]+).fq", hla_fq).group("hlatype") if hla_type in SUPPORTED_HLAS: if utils.fi...
[ "def", "run", "(", "data", ")", ":", "hlas", "=", "[", "]", "for", "hla_fq", "in", "tz", ".", "get_in", "(", "[", "\"hla\"", ",", "\"fastq\"", "]", ",", "data", ",", "[", "]", ")", ":", "hla_type", "=", "re", ".", "search", "(", "\"[.-](?P<hlatyp...
HLA typing with OptiType, parsing output from called genotype files.
[ "HLA", "typing", "with", "OptiType", "parsing", "output", "from", "called", "genotype", "files", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/optitype.py#L23-L50
train
bcbio/bcbio-nextgen
bcbio/hla/optitype.py
combine_hla_fqs
def combine_hla_fqs(hlas, out_file, data): """OptiType performs best on a combination of all extracted HLAs. """ if not utils.file_exists(out_file): with file_transaction(data, out_file) as tx_out_file: with open(tx_out_file, "w") as out_handle: for hla_type, hla_fq in hl...
python
def combine_hla_fqs(hlas, out_file, data): """OptiType performs best on a combination of all extracted HLAs. """ if not utils.file_exists(out_file): with file_transaction(data, out_file) as tx_out_file: with open(tx_out_file, "w") as out_handle: for hla_type, hla_fq in hl...
[ "def", "combine_hla_fqs", "(", "hlas", ",", "out_file", ",", "data", ")", ":", "if", "not", "utils", ".", "file_exists", "(", "out_file", ")", ":", "with", "file_transaction", "(", "data", ",", "out_file", ")", "as", "tx_out_file", ":", "with", "open", "...
OptiType performs best on a combination of all extracted HLAs.
[ "OptiType", "performs", "best", "on", "a", "combination", "of", "all", "extracted", "HLAs", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/optitype.py#L52-L62
train
bcbio/bcbio-nextgen
bcbio/hla/optitype.py
_prepare_calls
def _prepare_calls(result_file, out_dir, data): """Write summary file of results of HLA typing by allele. """ sample = dd.get_sample_name(data) out_file = os.path.join(out_dir, "%s-optitype.csv" % (sample)) if not utils.file_uptodate(out_file, result_file): hla_truth = bwakit.get_hla_truthse...
python
def _prepare_calls(result_file, out_dir, data): """Write summary file of results of HLA typing by allele. """ sample = dd.get_sample_name(data) out_file = os.path.join(out_dir, "%s-optitype.csv" % (sample)) if not utils.file_uptodate(out_file, result_file): hla_truth = bwakit.get_hla_truthse...
[ "def", "_prepare_calls", "(", "result_file", ",", "out_dir", ",", "data", ")", ":", "sample", "=", "dd", ".", "get_sample_name", "(", "data", ")", "out_file", "=", "os", ".", "path", ".", "join", "(", "out_dir", ",", "\"%s-optitype.csv\"", "%", "(", "sam...
Write summary file of results of HLA typing by allele.
[ "Write", "summary", "file", "of", "results", "of", "HLA", "typing", "by", "allele", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/optitype.py#L64-L88
train
bcbio/bcbio-nextgen
bcbio/hla/optitype.py
_call_hla
def _call_hla(hla_fq, out_dir, data): """Run OptiType HLA calling for a specific fastq input. """ bin_dir = os.path.dirname(os.path.realpath(sys.executable)) out_dir = utils.safe_makedir(out_dir) with tx_tmpdir(data, os.path.dirname(out_dir)) as tx_out_dir: config_file = os.path.join(tx_out_...
python
def _call_hla(hla_fq, out_dir, data): """Run OptiType HLA calling for a specific fastq input. """ bin_dir = os.path.dirname(os.path.realpath(sys.executable)) out_dir = utils.safe_makedir(out_dir) with tx_tmpdir(data, os.path.dirname(out_dir)) as tx_out_dir: config_file = os.path.join(tx_out_...
[ "def", "_call_hla", "(", "hla_fq", ",", "out_dir", ",", "data", ")", ":", "bin_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "sys", ".", "executable", ")", ")", "out_dir", "=", "utils", ".", "safe_makedir...
Run OptiType HLA calling for a specific fastq input.
[ "Run", "OptiType", "HLA", "calling", "for", "a", "specific", "fastq", "input", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/hla/optitype.py#L108-L132
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/chromhacks.py
is_autosomal
def is_autosomal(chrom): """Keep chromosomes that are a digit 1-22, or chr prefixed digit chr1-chr22 """ try: int(chrom) return True except ValueError: try: int(str(chrom.lower().replace("chr", "").replace("_", "").replace("-", ""))) return True ex...
python
def is_autosomal(chrom): """Keep chromosomes that are a digit 1-22, or chr prefixed digit chr1-chr22 """ try: int(chrom) return True except ValueError: try: int(str(chrom.lower().replace("chr", "").replace("_", "").replace("-", ""))) return True ex...
[ "def", "is_autosomal", "(", "chrom", ")", ":", "try", ":", "int", "(", "chrom", ")", "return", "True", "except", "ValueError", ":", "try", ":", "int", "(", "str", "(", "chrom", ".", "lower", "(", ")", ".", "replace", "(", "\"chr\"", ",", "\"\"", ")...
Keep chromosomes that are a digit 1-22, or chr prefixed digit chr1-chr22
[ "Keep", "chromosomes", "that", "are", "a", "digit", "1", "-", "22", "or", "chr", "prefixed", "digit", "chr1", "-", "chr22" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/chromhacks.py#L11-L22
train
bcbio/bcbio-nextgen
bcbio/qc/variant.py
_bcftools_stats
def _bcftools_stats(data, out_dir, vcf_file_key=None, germline=False): """Run bcftools stats. """ vcinfo = get_active_vcinfo(data) if vcinfo: out_dir = utils.safe_makedir(out_dir) vcf_file = vcinfo[vcf_file_key or "vrn_file"] if dd.get_jointcaller(data) or "gvcf" in dd.get_tools_...
python
def _bcftools_stats(data, out_dir, vcf_file_key=None, germline=False): """Run bcftools stats. """ vcinfo = get_active_vcinfo(data) if vcinfo: out_dir = utils.safe_makedir(out_dir) vcf_file = vcinfo[vcf_file_key or "vrn_file"] if dd.get_jointcaller(data) or "gvcf" in dd.get_tools_...
[ "def", "_bcftools_stats", "(", "data", ",", "out_dir", ",", "vcf_file_key", "=", "None", ",", "germline", "=", "False", ")", ":", "vcinfo", "=", "get_active_vcinfo", "(", "data", ")", "if", "vcinfo", ":", "out_dir", "=", "utils", ".", "safe_makedir", "(", ...
Run bcftools stats.
[ "Run", "bcftools", "stats", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L50-L77
train
bcbio/bcbio-nextgen
bcbio/qc/variant.py
_add_filename_details
def _add_filename_details(full_f): """Add variant callers and germline information standard CWL filenames. This is an ugly way of working around not having metadata with calls. """ out = {"vrn_file": full_f} f = os.path.basename(full_f) for vc in list(genotype.get_variantcallers().keys()) + ["e...
python
def _add_filename_details(full_f): """Add variant callers and germline information standard CWL filenames. This is an ugly way of working around not having metadata with calls. """ out = {"vrn_file": full_f} f = os.path.basename(full_f) for vc in list(genotype.get_variantcallers().keys()) + ["e...
[ "def", "_add_filename_details", "(", "full_f", ")", ":", "out", "=", "{", "\"vrn_file\"", ":", "full_f", "}", "f", "=", "os", ".", "path", ".", "basename", "(", "full_f", ")", "for", "vc", "in", "list", "(", "genotype", ".", "get_variantcallers", "(", ...
Add variant callers and germline information standard CWL filenames. This is an ugly way of working around not having metadata with calls.
[ "Add", "variant", "callers", "and", "germline", "information", "standard", "CWL", "filenames", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L79-L91
train
bcbio/bcbio-nextgen
bcbio/qc/variant.py
_get_variants
def _get_variants(data): """Retrieve variants from CWL and standard inputs for organizing variants. """ active_vs = [] if "variants" in data: variants = data["variants"] # CWL based list of variants if isinstance(variants, dict) and "samples" in variants: variants = v...
python
def _get_variants(data): """Retrieve variants from CWL and standard inputs for organizing variants. """ active_vs = [] if "variants" in data: variants = data["variants"] # CWL based list of variants if isinstance(variants, dict) and "samples" in variants: variants = v...
[ "def", "_get_variants", "(", "data", ")", ":", "active_vs", "=", "[", "]", "if", "\"variants\"", "in", "data", ":", "variants", "=", "data", "[", "\"variants\"", "]", "# CWL based list of variants", "if", "isinstance", "(", "variants", ",", "dict", ")", "and...
Retrieve variants from CWL and standard inputs for organizing variants.
[ "Retrieve", "variants", "from", "CWL", "and", "standard", "inputs", "for", "organizing", "variants", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L93-L118
train
bcbio/bcbio-nextgen
bcbio/qc/variant.py
get_active_vcinfo
def get_active_vcinfo(data, use_ensemble=True): """Use first caller if ensemble is not active """ active_vs = _get_variants(data) if len(active_vs) > 0: e_active_vs = [] if use_ensemble: e_active_vs = [v for v in active_vs if v.get("variantcaller") == "ensemble"] if l...
python
def get_active_vcinfo(data, use_ensemble=True): """Use first caller if ensemble is not active """ active_vs = _get_variants(data) if len(active_vs) > 0: e_active_vs = [] if use_ensemble: e_active_vs = [v for v in active_vs if v.get("variantcaller") == "ensemble"] if l...
[ "def", "get_active_vcinfo", "(", "data", ",", "use_ensemble", "=", "True", ")", ":", "active_vs", "=", "_get_variants", "(", "data", ")", "if", "len", "(", "active_vs", ")", ">", "0", ":", "e_active_vs", "=", "[", "]", "if", "use_ensemble", ":", "e_activ...
Use first caller if ensemble is not active
[ "Use", "first", "caller", "if", "ensemble", "is", "not", "active" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L120-L131
train
bcbio/bcbio-nextgen
bcbio/qc/variant.py
extract_germline_vcinfo
def extract_germline_vcinfo(data, out_dir): """Extract germline VCFs from existing tumor inputs. """ supported_germline = set(["vardict", "octopus", "freebayes"]) if dd.get_phenotype(data) in ["tumor"]: for v in _get_variants(data): if v.get("variantcaller") in supported_germline: ...
python
def extract_germline_vcinfo(data, out_dir): """Extract germline VCFs from existing tumor inputs. """ supported_germline = set(["vardict", "octopus", "freebayes"]) if dd.get_phenotype(data) in ["tumor"]: for v in _get_variants(data): if v.get("variantcaller") in supported_germline: ...
[ "def", "extract_germline_vcinfo", "(", "data", ",", "out_dir", ")", ":", "supported_germline", "=", "set", "(", "[", "\"vardict\"", ",", "\"octopus\"", ",", "\"freebayes\"", "]", ")", "if", "dd", ".", "get_phenotype", "(", "data", ")", "in", "[", "\"tumor\""...
Extract germline VCFs from existing tumor inputs.
[ "Extract", "germline", "VCFs", "from", "existing", "tumor", "inputs", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/qc/variant.py#L133-L147
train
bcbio/bcbio-nextgen
bcbio/pipeline/merge.py
merge_bam_files
def merge_bam_files(bam_files, work_dir, data, out_file=None, batch=None): """Merge multiple BAM files from a sample into a single BAM for processing. Checks system open file limit and merges in batches if necessary to avoid file handle limits. """ out_file = _merge_outfile_fname(out_file, bam_file...
python
def merge_bam_files(bam_files, work_dir, data, out_file=None, batch=None): """Merge multiple BAM files from a sample into a single BAM for processing. Checks system open file limit and merges in batches if necessary to avoid file handle limits. """ out_file = _merge_outfile_fname(out_file, bam_file...
[ "def", "merge_bam_files", "(", "bam_files", ",", "work_dir", ",", "data", ",", "out_file", "=", "None", ",", "batch", "=", "None", ")", ":", "out_file", "=", "_merge_outfile_fname", "(", "out_file", ",", "bam_files", ",", "work_dir", ",", "batch", ")", "if...
Merge multiple BAM files from a sample into a single BAM for processing. Checks system open file limit and merges in batches if necessary to avoid file handle limits.
[ "Merge", "multiple", "BAM", "files", "from", "a", "sample", "into", "a", "single", "BAM", "for", "processing", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/merge.py#L39-L79
train
bcbio/bcbio-nextgen
bcbio/pipeline/merge.py
_create_merge_filelist
def _create_merge_filelist(bam_files, base_file, config): """Create list of input files for merge, ensuring all files are valid. """ bam_file_list = "%s.list" % os.path.splitext(base_file)[0] samtools = config_utils.get_program("samtools", config) with open(bam_file_list, "w") as out_handle: ...
python
def _create_merge_filelist(bam_files, base_file, config): """Create list of input files for merge, ensuring all files are valid. """ bam_file_list = "%s.list" % os.path.splitext(base_file)[0] samtools = config_utils.get_program("samtools", config) with open(bam_file_list, "w") as out_handle: ...
[ "def", "_create_merge_filelist", "(", "bam_files", ",", "base_file", ",", "config", ")", ":", "bam_file_list", "=", "\"%s.list\"", "%", "os", ".", "path", ".", "splitext", "(", "base_file", ")", "[", "0", "]", "samtools", "=", "config_utils", ".", "get_progr...
Create list of input files for merge, ensuring all files are valid.
[ "Create", "list", "of", "input", "files", "for", "merge", "ensuring", "all", "files", "are", "valid", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/merge.py#L81-L91
train
bcbio/bcbio-nextgen
bcbio/pipeline/merge.py
_merge_outfile_fname
def _merge_outfile_fname(out_file, bam_files, work_dir, batch): """Derive correct name of BAM file based on batching. """ if out_file is None: out_file = os.path.join(work_dir, os.path.basename(sorted(bam_files)[0])) if batch is not None: base, ext = os.path.splitext(out_file) ou...
python
def _merge_outfile_fname(out_file, bam_files, work_dir, batch): """Derive correct name of BAM file based on batching. """ if out_file is None: out_file = os.path.join(work_dir, os.path.basename(sorted(bam_files)[0])) if batch is not None: base, ext = os.path.splitext(out_file) ou...
[ "def", "_merge_outfile_fname", "(", "out_file", ",", "bam_files", ",", "work_dir", ",", "batch", ")", ":", "if", "out_file", "is", "None", ":", "out_file", "=", "os", ".", "path", ".", "join", "(", "work_dir", ",", "os", ".", "path", ".", "basename", "...
Derive correct name of BAM file based on batching.
[ "Derive", "correct", "name", "of", "BAM", "file", "based", "on", "batching", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/merge.py#L93-L101
train
bcbio/bcbio-nextgen
bcbio/pipeline/merge.py
_finalize_merge
def _finalize_merge(out_file, bam_files, config): """Handle indexes and cleanups of merged BAM and input files. """ # Ensure timestamps are up to date on output file and index # Works around issues on systems with inconsistent times for ext in ["", ".bai"]: if os.path.exists(out_file + ext):...
python
def _finalize_merge(out_file, bam_files, config): """Handle indexes and cleanups of merged BAM and input files. """ # Ensure timestamps are up to date on output file and index # Works around issues on systems with inconsistent times for ext in ["", ".bai"]: if os.path.exists(out_file + ext):...
[ "def", "_finalize_merge", "(", "out_file", ",", "bam_files", ",", "config", ")", ":", "# Ensure timestamps are up to date on output file and index", "# Works around issues on systems with inconsistent times", "for", "ext", "in", "[", "\"\"", ",", "\".bai\"", "]", ":", "if",...
Handle indexes and cleanups of merged BAM and input files.
[ "Handle", "indexes", "and", "cleanups", "of", "merged", "BAM", "and", "input", "files", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/merge.py#L103-L112
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_cwl_workflow_template
def _cwl_workflow_template(inputs, top_level=False): """Retrieve CWL inputs shared amongst different workflows. """ ready_inputs = [] for inp in inputs: cur_inp = copy.deepcopy(inp) for attr in ["source", "valueFrom", "wf_duplicate"]: cur_inp.pop(attr, None) if top_le...
python
def _cwl_workflow_template(inputs, top_level=False): """Retrieve CWL inputs shared amongst different workflows. """ ready_inputs = [] for inp in inputs: cur_inp = copy.deepcopy(inp) for attr in ["source", "valueFrom", "wf_duplicate"]: cur_inp.pop(attr, None) if top_le...
[ "def", "_cwl_workflow_template", "(", "inputs", ",", "top_level", "=", "False", ")", ":", "ready_inputs", "=", "[", "]", "for", "inp", "in", "inputs", ":", "cur_inp", "=", "copy", ".", "deepcopy", "(", "inp", ")", "for", "attr", "in", "[", "\"source\"", ...
Retrieve CWL inputs shared amongst different workflows.
[ "Retrieve", "CWL", "inputs", "shared", "amongst", "different", "workflows", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L42-L63
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_get_disk_estimates
def _get_disk_estimates(name, parallel, inputs, file_estimates, samples, disk, cur_remotes, no_files): """Retrieve disk usage estimates as CWL ResourceRequirement and hint. Disk specification for temporary files and outputs. Also optionally includes disk input estimates as a custom...
python
def _get_disk_estimates(name, parallel, inputs, file_estimates, samples, disk, cur_remotes, no_files): """Retrieve disk usage estimates as CWL ResourceRequirement and hint. Disk specification for temporary files and outputs. Also optionally includes disk input estimates as a custom...
[ "def", "_get_disk_estimates", "(", "name", ",", "parallel", ",", "inputs", ",", "file_estimates", ",", "samples", ",", "disk", ",", "cur_remotes", ",", "no_files", ")", ":", "tmp_disk", ",", "out_disk", ",", "in_disk", "=", "0", ",", "0", ",", "0", "if",...
Retrieve disk usage estimates as CWL ResourceRequirement and hint. Disk specification for temporary files and outputs. Also optionally includes disk input estimates as a custom hint for platforms which need to stage these and don't pre-estimate these when allocating machine sizes.
[ "Retrieve", "disk", "usage", "estimates", "as", "CWL", "ResourceRequirement", "and", "hint", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L65-L107
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_add_current_quay_tag
def _add_current_quay_tag(repo, container_tags): """Lookup the current quay tag for the repository, adding to repo string. Enables generation of CWL explicitly tied to revisions. """ if ':' in repo: return repo, container_tags try: latest_tag = container_tags[repo] except KeyErr...
python
def _add_current_quay_tag(repo, container_tags): """Lookup the current quay tag for the repository, adding to repo string. Enables generation of CWL explicitly tied to revisions. """ if ':' in repo: return repo, container_tags try: latest_tag = container_tags[repo] except KeyErr...
[ "def", "_add_current_quay_tag", "(", "repo", ",", "container_tags", ")", ":", "if", "':'", "in", "repo", ":", "return", "repo", ",", "container_tags", "try", ":", "latest_tag", "=", "container_tags", "[", "repo", "]", "except", "KeyError", ":", "repo_id", "=...
Lookup the current quay tag for the repository, adding to repo string. Enables generation of CWL explicitly tied to revisions.
[ "Lookup", "the", "current", "quay", "tag", "for", "the", "repository", "adding", "to", "repo", "string", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L109-L134
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_write_expressiontool
def _write_expressiontool(step_dir, name, inputs, outputs, expression, parallel): """Create an ExpressionTool output for the given inputs """ out_file = os.path.join(step_dir, "%s.cwl" % name) out = {"class": "ExpressionTool", "cwlVersion": "v1.0", "requirements": [{"class": "Inlin...
python
def _write_expressiontool(step_dir, name, inputs, outputs, expression, parallel): """Create an ExpressionTool output for the given inputs """ out_file = os.path.join(step_dir, "%s.cwl" % name) out = {"class": "ExpressionTool", "cwlVersion": "v1.0", "requirements": [{"class": "Inlin...
[ "def", "_write_expressiontool", "(", "step_dir", ",", "name", ",", "inputs", ",", "outputs", ",", "expression", ",", "parallel", ")", ":", "out_file", "=", "os", ".", "path", ".", "join", "(", "step_dir", ",", "\"%s.cwl\"", "%", "name", ")", "out", "=", ...
Create an ExpressionTool output for the given inputs
[ "Create", "an", "ExpressionTool", "output", "for", "the", "given", "inputs" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L208-L221
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_clean_record
def _clean_record(rec): """Remove secondary files from record fields, which are currently not supported. To be removed later when secondaryFiles added to records. """ if workflow.is_cwl_record(rec): def _clean_fields(d): if isinstance(d, dict): if "fields" in d: ...
python
def _clean_record(rec): """Remove secondary files from record fields, which are currently not supported. To be removed later when secondaryFiles added to records. """ if workflow.is_cwl_record(rec): def _clean_fields(d): if isinstance(d, dict): if "fields" in d: ...
[ "def", "_clean_record", "(", "rec", ")", ":", "if", "workflow", ".", "is_cwl_record", "(", "rec", ")", ":", "def", "_clean_fields", "(", "d", ")", ":", "if", "isinstance", "(", "d", ",", "dict", ")", ":", "if", "\"fields\"", "in", "d", ":", "out", ...
Remove secondary files from record fields, which are currently not supported. To be removed later when secondaryFiles added to records.
[ "Remove", "secondary", "files", "from", "record", "fields", "which", "are", "currently", "not", "supported", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L265-L290
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_get_record_fields
def _get_record_fields(d): """Get field names from a potentially nested record. """ if isinstance(d, dict): if "fields" in d: return d["fields"] else: for v in d.values(): fields = _get_record_fields(v) if fields: re...
python
def _get_record_fields(d): """Get field names from a potentially nested record. """ if isinstance(d, dict): if "fields" in d: return d["fields"] else: for v in d.values(): fields = _get_record_fields(v) if fields: re...
[ "def", "_get_record_fields", "(", "d", ")", ":", "if", "isinstance", "(", "d", ",", "dict", ")", ":", "if", "\"fields\"", "in", "d", ":", "return", "d", "[", "\"fields\"", "]", "else", ":", "for", "v", "in", "d", ".", "values", "(", ")", ":", "fi...
Get field names from a potentially nested record.
[ "Get", "field", "names", "from", "a", "potentially", "nested", "record", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L292-L302
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_get_sentinel_val
def _get_sentinel_val(v): """Retrieve expected sentinel value for an output, expanding records. """ out = workflow.get_base_id(v["id"]) if workflow.is_cwl_record(v): out += ":%s" % ";".join([x["name"] for x in _get_record_fields(v)]) return out
python
def _get_sentinel_val(v): """Retrieve expected sentinel value for an output, expanding records. """ out = workflow.get_base_id(v["id"]) if workflow.is_cwl_record(v): out += ":%s" % ";".join([x["name"] for x in _get_record_fields(v)]) return out
[ "def", "_get_sentinel_val", "(", "v", ")", ":", "out", "=", "workflow", ".", "get_base_id", "(", "v", "[", "\"id\"", "]", ")", "if", "workflow", ".", "is_cwl_record", "(", "v", ")", ":", "out", "+=", "\":%s\"", "%", "\";\"", ".", "join", "(", "[", ...
Retrieve expected sentinel value for an output, expanding records.
[ "Retrieve", "expected", "sentinel", "value", "for", "an", "output", "expanding", "records", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L304-L310
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_place_input_binding
def _place_input_binding(inp_tool, inp_binding, parallel): """Check nesting of variables to determine where to place the input binding. We want to allow having multiple files together (like fasta_indices), combined with the itemSeparator, but also support having multiple samples where we pass things in...
python
def _place_input_binding(inp_tool, inp_binding, parallel): """Check nesting of variables to determine where to place the input binding. We want to allow having multiple files together (like fasta_indices), combined with the itemSeparator, but also support having multiple samples where we pass things in...
[ "def", "_place_input_binding", "(", "inp_tool", ",", "inp_binding", ",", "parallel", ")", ":", "if", "(", "parallel", "in", "[", "\"multi-combined\"", ",", "\"multi-batch\"", ",", "\"batch-split\"", ",", "\"batch-parallel\"", ",", "\"batch-merge\"", ",", "\"batch-si...
Check nesting of variables to determine where to place the input binding. We want to allow having multiple files together (like fasta_indices), combined with the itemSeparator, but also support having multiple samples where we pass things independently.
[ "Check", "nesting", "of", "variables", "to", "determine", "where", "to", "place", "the", "input", "binding", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L312-L325
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_place_secondary_files
def _place_secondary_files(inp_tool, inp_binding=None): """Put secondaryFiles at the level of the File item to ensure indexes get passed. """ def _is_file(val): return (val == "File" or (isinstance(val, (list, tuple)) and ("File" in val or any(isinstance(x, dict) an...
python
def _place_secondary_files(inp_tool, inp_binding=None): """Put secondaryFiles at the level of the File item to ensure indexes get passed. """ def _is_file(val): return (val == "File" or (isinstance(val, (list, tuple)) and ("File" in val or any(isinstance(x, dict) an...
[ "def", "_place_secondary_files", "(", "inp_tool", ",", "inp_binding", "=", "None", ")", ":", "def", "_is_file", "(", "val", ")", ":", "return", "(", "val", "==", "\"File\"", "or", "(", "isinstance", "(", "val", ",", "(", "list", ",", "tuple", ")", ")",...
Put secondaryFiles at the level of the File item to ensure indexes get passed.
[ "Put", "secondaryFiles", "at", "the", "level", "of", "the", "File", "item", "to", "ensure", "indexes", "get", "passed", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L327-L347
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_do_scatter_var
def _do_scatter_var(v, parallel): """Logic for scattering a variable. """ # For batches, scatter records only at the top level (double nested) if parallel.startswith("batch") and workflow.is_cwl_record(v): return (tz.get_in(["type", "type"], v) == "array" and tz.get_in(["type", "...
python
def _do_scatter_var(v, parallel): """Logic for scattering a variable. """ # For batches, scatter records only at the top level (double nested) if parallel.startswith("batch") and workflow.is_cwl_record(v): return (tz.get_in(["type", "type"], v) == "array" and tz.get_in(["type", "...
[ "def", "_do_scatter_var", "(", "v", ",", "parallel", ")", ":", "# For batches, scatter records only at the top level (double nested)", "if", "parallel", ".", "startswith", "(", "\"batch\"", ")", "and", "workflow", ".", "is_cwl_record", "(", "v", ")", ":", "return", ...
Logic for scattering a variable.
[ "Logic", "for", "scattering", "a", "variable", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L352-L361
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_step_template
def _step_template(name, run_file, inputs, outputs, parallel, step_parallelism, scatter=None): """Templating function for writing a step to avoid repeating namespaces. """ scatter_inputs = [] sinputs = [] for inp in inputs: step_inp = {"id": workflow.get_base_id(inp["id"]), "source": inp["id...
python
def _step_template(name, run_file, inputs, outputs, parallel, step_parallelism, scatter=None): """Templating function for writing a step to avoid repeating namespaces. """ scatter_inputs = [] sinputs = [] for inp in inputs: step_inp = {"id": workflow.get_base_id(inp["id"]), "source": inp["id...
[ "def", "_step_template", "(", "name", ",", "run_file", ",", "inputs", ",", "outputs", ",", "parallel", ",", "step_parallelism", ",", "scatter", "=", "None", ")", ":", "scatter_inputs", "=", "[", "]", "sinputs", "=", "[", "]", "for", "inp", "in", "inputs"...
Templating function for writing a step to avoid repeating namespaces.
[ "Templating", "function", "for", "writing", "a", "step", "to", "avoid", "repeating", "namespaces", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L363-L393
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_get_cur_remotes
def _get_cur_remotes(path): """Retrieve remote references defined in the CWL. """ cur_remotes = set([]) if isinstance(path, (list, tuple)): for v in path: cur_remotes |= _get_cur_remotes(v) elif isinstance(path, dict): for v in path.values(): cur_remotes |= _g...
python
def _get_cur_remotes(path): """Retrieve remote references defined in the CWL. """ cur_remotes = set([]) if isinstance(path, (list, tuple)): for v in path: cur_remotes |= _get_cur_remotes(v) elif isinstance(path, dict): for v in path.values(): cur_remotes |= _g...
[ "def", "_get_cur_remotes", "(", "path", ")", ":", "cur_remotes", "=", "set", "(", "[", "]", ")", "if", "isinstance", "(", "path", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "v", "in", "path", ":", "cur_remotes", "|=", "_get_cur_remotes", "...
Retrieve remote references defined in the CWL.
[ "Retrieve", "remote", "references", "defined", "in", "the", "CWL", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L395-L408
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_flatten_samples
def _flatten_samples(samples, base_file, get_retriever): """Create a flattened JSON representation of data from the bcbio world map. """ flat_data = [] for data in samples: data["reference"] = _indexes_to_secondary_files(data["reference"], data["genome_build"]) cur_flat = {} for ...
python
def _flatten_samples(samples, base_file, get_retriever): """Create a flattened JSON representation of data from the bcbio world map. """ flat_data = [] for data in samples: data["reference"] = _indexes_to_secondary_files(data["reference"], data["genome_build"]) cur_flat = {} for ...
[ "def", "_flatten_samples", "(", "samples", ",", "base_file", ",", "get_retriever", ")", ":", "flat_data", "=", "[", "]", "for", "data", "in", "samples", ":", "data", "[", "\"reference\"", "]", "=", "_indexes_to_secondary_files", "(", "data", "[", "\"reference\...
Create a flattened JSON representation of data from the bcbio world map.
[ "Create", "a", "flattened", "JSON", "representation", "of", "data", "from", "the", "bcbio", "world", "map", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L478-L503
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_indexes_to_secondary_files
def _indexes_to_secondary_files(gresources, genome_build): """Convert a list of genome indexes into a single file plus secondary files. This ensures that all indices are staged together in a single directory. """ out = {} for refname, val in gresources.items(): if isinstance(val, dict) and ...
python
def _indexes_to_secondary_files(gresources, genome_build): """Convert a list of genome indexes into a single file plus secondary files. This ensures that all indices are staged together in a single directory. """ out = {} for refname, val in gresources.items(): if isinstance(val, dict) and ...
[ "def", "_indexes_to_secondary_files", "(", "gresources", ",", "genome_build", ")", ":", "out", "=", "{", "}", "for", "refname", ",", "val", "in", "gresources", ".", "items", "(", ")", ":", "if", "isinstance", "(", "val", ",", "dict", ")", "and", "\"index...
Convert a list of genome indexes into a single file plus secondary files. This ensures that all indices are staged together in a single directory.
[ "Convert", "a", "list", "of", "genome", "indexes", "into", "a", "single", "file", "plus", "secondary", "files", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L505-L530
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_add_suppl_info
def _add_suppl_info(inp, val): """Add supplementary information to inputs from file values. """ inp["type"] = _get_avro_type(val) secondary = _get_secondary_files(val) if secondary: inp["secondaryFiles"] = secondary return inp
python
def _add_suppl_info(inp, val): """Add supplementary information to inputs from file values. """ inp["type"] = _get_avro_type(val) secondary = _get_secondary_files(val) if secondary: inp["secondaryFiles"] = secondary return inp
[ "def", "_add_suppl_info", "(", "inp", ",", "val", ")", ":", "inp", "[", "\"type\"", "]", "=", "_get_avro_type", "(", "val", ")", "secondary", "=", "_get_secondary_files", "(", "val", ")", "if", "secondary", ":", "inp", "[", "\"secondaryFiles\"", "]", "=", ...
Add supplementary information to inputs from file values.
[ "Add", "supplementary", "information", "to", "inputs", "from", "file", "values", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L532-L539
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_get_secondary_files
def _get_secondary_files(val): """Retrieve associated secondary files. Normalizes input values into definitions of available secondary files. Requires indices to be present in all files, since declared CWL secondary files are not optional. So if we have a mix of BAM (bai) and fastq (gbi) we ignore ...
python
def _get_secondary_files(val): """Retrieve associated secondary files. Normalizes input values into definitions of available secondary files. Requires indices to be present in all files, since declared CWL secondary files are not optional. So if we have a mix of BAM (bai) and fastq (gbi) we ignore ...
[ "def", "_get_secondary_files", "(", "val", ")", ":", "out", "=", "[", "]", "if", "isinstance", "(", "val", ",", "(", "tuple", ",", "list", ")", ")", ":", "s_counts", "=", "collections", ".", "defaultdict", "(", "int", ")", "for", "x", "in", "val", ...
Retrieve associated secondary files. Normalizes input values into definitions of available secondary files. Requires indices to be present in all files, since declared CWL secondary files are not optional. So if we have a mix of BAM (bai) and fastq (gbi) we ignore the existing indices and will have to ...
[ "Retrieve", "associated", "secondary", "files", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L541-L564
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_get_relative_ext
def _get_relative_ext(of, sf): """Retrieve relative extension given the original and secondary files. """ def half_finished_trim(orig, prefix): return (os.path.basename(prefix).count(".") > 0 and os.path.basename(orig).count(".") == os.path.basename(prefix).count(".")) # Handle r...
python
def _get_relative_ext(of, sf): """Retrieve relative extension given the original and secondary files. """ def half_finished_trim(orig, prefix): return (os.path.basename(prefix).count(".") > 0 and os.path.basename(orig).count(".") == os.path.basename(prefix).count(".")) # Handle r...
[ "def", "_get_relative_ext", "(", "of", ",", "sf", ")", ":", "def", "half_finished_trim", "(", "orig", ",", "prefix", ")", ":", "return", "(", "os", ".", "path", ".", "basename", "(", "prefix", ")", ".", "count", "(", "\".\"", ")", ">", "0", "and", ...
Retrieve relative extension given the original and secondary files.
[ "Retrieve", "relative", "extension", "given", "the", "original", "and", "secondary", "files", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L566-L586
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_get_avro_type
def _get_avro_type(val): """Infer avro type for the current input. """ if isinstance(val, dict): assert val.get("class") == "File" or "File" in val.get("class") return "File" elif isinstance(val, (tuple, list)): types = [] for ctype in [_get_avro_type(v) for v in val]: ...
python
def _get_avro_type(val): """Infer avro type for the current input. """ if isinstance(val, dict): assert val.get("class") == "File" or "File" in val.get("class") return "File" elif isinstance(val, (tuple, list)): types = [] for ctype in [_get_avro_type(v) for v in val]: ...
[ "def", "_get_avro_type", "(", "val", ")", ":", "if", "isinstance", "(", "val", ",", "dict", ")", ":", "assert", "val", ".", "get", "(", "\"class\"", ")", "==", "\"File\"", "or", "\"File\"", "in", "val", ".", "get", "(", "\"class\"", ")", "return", "\...
Infer avro type for the current input.
[ "Infer", "avro", "type", "for", "the", "current", "input", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L588-L634
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_avoid_duplicate_arrays
def _avoid_duplicate_arrays(types): """Collapse arrays when we have multiple types. """ arrays = [t for t in types if isinstance(t, dict) and t["type"] == "array"] others = [t for t in types if not (isinstance(t, dict) and t["type"] == "array")] if arrays: items = set([]) for t in ar...
python
def _avoid_duplicate_arrays(types): """Collapse arrays when we have multiple types. """ arrays = [t for t in types if isinstance(t, dict) and t["type"] == "array"] others = [t for t in types if not (isinstance(t, dict) and t["type"] == "array")] if arrays: items = set([]) for t in ar...
[ "def", "_avoid_duplicate_arrays", "(", "types", ")", ":", "arrays", "=", "[", "t", "for", "t", "in", "types", "if", "isinstance", "(", "t", ",", "dict", ")", "and", "t", "[", "\"type\"", "]", "==", "\"array\"", "]", "others", "=", "[", "t", "for", ...
Collapse arrays when we have multiple types.
[ "Collapse", "arrays", "when", "we", "have", "multiple", "types", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L636-L653
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_samplejson_to_inputs
def _samplejson_to_inputs(svals): """Convert sample output into inputs for CWL configuration files, with types. """ out = [] for key, val in svals.items(): out.append(_add_suppl_info({"id": "%s" % key}, val)) return out
python
def _samplejson_to_inputs(svals): """Convert sample output into inputs for CWL configuration files, with types. """ out = [] for key, val in svals.items(): out.append(_add_suppl_info({"id": "%s" % key}, val)) return out
[ "def", "_samplejson_to_inputs", "(", "svals", ")", ":", "out", "=", "[", "]", "for", "key", ",", "val", "in", "svals", ".", "items", "(", ")", ":", "out", ".", "append", "(", "_add_suppl_info", "(", "{", "\"id\"", ":", "\"%s\"", "%", "key", "}", ",...
Convert sample output into inputs for CWL configuration files, with types.
[ "Convert", "sample", "output", "into", "inputs", "for", "CWL", "configuration", "files", "with", "types", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L655-L661
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_to_cwldata
def _to_cwldata(key, val, get_retriever): """Convert nested dictionary into CWL data, flatening and marking up files. Moves file objects to the top level, enabling insertion in CWL inputs/outputs. """ out = [] if isinstance(val, dict): if len(val) == 2 and "base" in val and "indexes" in val...
python
def _to_cwldata(key, val, get_retriever): """Convert nested dictionary into CWL data, flatening and marking up files. Moves file objects to the top level, enabling insertion in CWL inputs/outputs. """ out = [] if isinstance(val, dict): if len(val) == 2 and "base" in val and "indexes" in val...
[ "def", "_to_cwldata", "(", "key", ",", "val", ",", "get_retriever", ")", ":", "out", "=", "[", "]", "if", "isinstance", "(", "val", ",", "dict", ")", ":", "if", "len", "(", "val", ")", "==", "2", "and", "\"base\"", "in", "val", "and", "\"indexes\""...
Convert nested dictionary into CWL data, flatening and marking up files. Moves file objects to the top level, enabling insertion in CWL inputs/outputs.
[ "Convert", "nested", "dictionary", "into", "CWL", "data", "flatening", "and", "marking", "up", "files", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L663-L701
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_to_cwlfile_with_indexes
def _to_cwlfile_with_indexes(val, get_retriever): """Convert reads with ready to go indexes into the right CWL object. Identifies the top level directory and creates a tarball, avoiding trying to handle complex secondary setups which are not cross platform. Skips doing this for reference files and sta...
python
def _to_cwlfile_with_indexes(val, get_retriever): """Convert reads with ready to go indexes into the right CWL object. Identifies the top level directory and creates a tarball, avoiding trying to handle complex secondary setups which are not cross platform. Skips doing this for reference files and sta...
[ "def", "_to_cwlfile_with_indexes", "(", "val", ",", "get_retriever", ")", ":", "val", "[", "\"indexes\"", "]", "=", "_index_blacklist", "(", "val", "[", "\"indexes\"", "]", ")", "tval", "=", "{", "\"base\"", ":", "_remove_remote_prefix", "(", "val", "[", "\"...
Convert reads with ready to go indexes into the right CWL object. Identifies the top level directory and creates a tarball, avoiding trying to handle complex secondary setups which are not cross platform. Skips doing this for reference files and standard setups like bwa, which take up too much time an...
[ "Convert", "reads", "with", "ready", "to", "go", "indexes", "into", "the", "right", "CWL", "object", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L712-L734
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_add_secondary_if_exists
def _add_secondary_if_exists(secondary, out, get_retriever): """Add secondary files only if present locally or remotely. """ secondary = [_file_local_or_remote(y, get_retriever) for y in secondary] secondary = [z for z in secondary if z] if secondary: out["secondaryFiles"] = [{"class": "File...
python
def _add_secondary_if_exists(secondary, out, get_retriever): """Add secondary files only if present locally or remotely. """ secondary = [_file_local_or_remote(y, get_retriever) for y in secondary] secondary = [z for z in secondary if z] if secondary: out["secondaryFiles"] = [{"class": "File...
[ "def", "_add_secondary_if_exists", "(", "secondary", ",", "out", ",", "get_retriever", ")", ":", "secondary", "=", "[", "_file_local_or_remote", "(", "y", ",", "get_retriever", ")", "for", "y", "in", "secondary", "]", "secondary", "=", "[", "z", "for", "z", ...
Add secondary files only if present locally or remotely.
[ "Add", "secondary", "files", "only", "if", "present", "locally", "or", "remotely", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L736-L743
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_item_to_cwldata
def _item_to_cwldata(x, get_retriever, indexes=None): """"Markup an item with CWL specific metadata. """ if isinstance(x, (list, tuple)): return [_item_to_cwldata(subx, get_retriever) for subx in x] elif (x and isinstance(x, six.string_types) and (((os.path.isfile(x) or os.path.isdir(x...
python
def _item_to_cwldata(x, get_retriever, indexes=None): """"Markup an item with CWL specific metadata. """ if isinstance(x, (list, tuple)): return [_item_to_cwldata(subx, get_retriever) for subx in x] elif (x and isinstance(x, six.string_types) and (((os.path.isfile(x) or os.path.isdir(x...
[ "def", "_item_to_cwldata", "(", "x", ",", "get_retriever", ",", "indexes", "=", "None", ")", ":", "if", "isinstance", "(", "x", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "[", "_item_to_cwldata", "(", "subx", ",", "get_retriever", ")", "f...
Markup an item with CWL specific metadata.
[ "Markup", "an", "item", "with", "CWL", "specific", "metadata", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L745-L778
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_file_local_or_remote
def _file_local_or_remote(f, get_retriever): """Check for presence of a local or remote file. """ if os.path.exists(f): return f integration, config = get_retriever.integration_and_config(f) if integration: return integration.file_exists(f, config)
python
def _file_local_or_remote(f, get_retriever): """Check for presence of a local or remote file. """ if os.path.exists(f): return f integration, config = get_retriever.integration_and_config(f) if integration: return integration.file_exists(f, config)
[ "def", "_file_local_or_remote", "(", "f", ",", "get_retriever", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "f", ")", ":", "return", "f", "integration", ",", "config", "=", "get_retriever", ".", "integration_and_config", "(", "f", ")", "if", "...
Check for presence of a local or remote file.
[ "Check", "for", "presence", "of", "a", "local", "or", "remote", "file", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L780-L787
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
directory_tarball
def directory_tarball(dirname): """Create a tarball of a complex directory, avoiding complex secondaryFiles. Complex secondary files do not work on multiple platforms and are not portable to WDL, so for now we create a tarball that workers will unpack. """ assert os.path.isdir(dirname), dirname ...
python
def directory_tarball(dirname): """Create a tarball of a complex directory, avoiding complex secondaryFiles. Complex secondary files do not work on multiple platforms and are not portable to WDL, so for now we create a tarball that workers will unpack. """ assert os.path.isdir(dirname), dirname ...
[ "def", "directory_tarball", "(", "dirname", ")", ":", "assert", "os", ".", "path", ".", "isdir", "(", "dirname", ")", ",", "dirname", "base_dir", ",", "tarball_dir", "=", "os", ".", "path", ".", "split", "(", "dirname", ")", "while", "not", "os", ".", ...
Create a tarball of a complex directory, avoiding complex secondaryFiles. Complex secondary files do not work on multiple platforms and are not portable to WDL, so for now we create a tarball that workers will unpack.
[ "Create", "a", "tarball", "of", "a", "complex", "directory", "avoiding", "complex", "secondaryFiles", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L789-L809
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_calc_input_estimates
def _calc_input_estimates(keyvals, get_retriever): """Calculate estimations of input file sizes for disk usage approximation. These are current dominated by fastq/BAM sizes, so estimate based on that. """ out = {} for key, val in keyvals.items(): size = _calc_file_size(val, 0, get_retriever...
python
def _calc_input_estimates(keyvals, get_retriever): """Calculate estimations of input file sizes for disk usage approximation. These are current dominated by fastq/BAM sizes, so estimate based on that. """ out = {} for key, val in keyvals.items(): size = _calc_file_size(val, 0, get_retriever...
[ "def", "_calc_input_estimates", "(", "keyvals", ",", "get_retriever", ")", ":", "out", "=", "{", "}", "for", "key", ",", "val", "in", "keyvals", ".", "items", "(", ")", ":", "size", "=", "_calc_file_size", "(", "val", ",", "0", ",", "get_retriever", ")...
Calculate estimations of input file sizes for disk usage approximation. These are current dominated by fastq/BAM sizes, so estimate based on that.
[ "Calculate", "estimations", "of", "input", "file", "sizes", "for", "disk", "usage", "approximation", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L853-L863
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
_get_file_size
def _get_file_size(path, get_retriever): """Return file size in megabytes, including querying remote integrations """ integration, config = get_retriever.integration_and_config(path) if integration: return integration.file_size(path, config) elif os.path.exists(path): return os.path....
python
def _get_file_size(path, get_retriever): """Return file size in megabytes, including querying remote integrations """ integration, config = get_retriever.integration_and_config(path) if integration: return integration.file_size(path, config) elif os.path.exists(path): return os.path....
[ "def", "_get_file_size", "(", "path", ",", "get_retriever", ")", ":", "integration", ",", "config", "=", "get_retriever", ".", "integration_and_config", "(", "path", ")", "if", "integration", ":", "return", "integration", ".", "file_size", "(", "path", ",", "c...
Return file size in megabytes, including querying remote integrations
[ "Return", "file", "size", "in", "megabytes", "including", "querying", "remote", "integrations" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L896-L903
train
bcbio/bcbio-nextgen
bcbio/cwl/create.py
GetRetriever.integration_and_config
def integration_and_config(self, path): """Get a retriever and configuration for the given file path. """ if path.startswith(tuple(INTEGRATION_MAP.keys())): key = INTEGRATION_MAP[path.split(":")[0] + ":"] integration = self._integrations.get(key) config = {} ...
python
def integration_and_config(self, path): """Get a retriever and configuration for the given file path. """ if path.startswith(tuple(INTEGRATION_MAP.keys())): key = INTEGRATION_MAP[path.split(":")[0] + ":"] integration = self._integrations.get(key) config = {} ...
[ "def", "integration_and_config", "(", "self", ",", "path", ")", ":", "if", "path", ".", "startswith", "(", "tuple", "(", "INTEGRATION_MAP", ".", "keys", "(", ")", ")", ")", ":", "key", "=", "INTEGRATION_MAP", "[", "path", ".", "split", "(", "\":\"", ")...
Get a retriever and configuration for the given file path.
[ "Get", "a", "retriever", "and", "configuration", "for", "the", "given", "file", "path", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/cwl/create.py#L881-L894
train
bcbio/bcbio-nextgen
bcbio/rnaseq/singlecellexperiment.py
make_scrnaseq_object
def make_scrnaseq_object(samples): """ load the initial se.rda object using sinclecell-experiment """ local_sitelib = R_sitelib() counts_dir = os.path.dirname(dd.get_in_samples(samples, dd.get_combined_counts)) gtf_file = dd.get_in_samples(samples, dd.get_transcriptome_gtf) if not gtf_file: ...
python
def make_scrnaseq_object(samples): """ load the initial se.rda object using sinclecell-experiment """ local_sitelib = R_sitelib() counts_dir = os.path.dirname(dd.get_in_samples(samples, dd.get_combined_counts)) gtf_file = dd.get_in_samples(samples, dd.get_transcriptome_gtf) if not gtf_file: ...
[ "def", "make_scrnaseq_object", "(", "samples", ")", ":", "local_sitelib", "=", "R_sitelib", "(", ")", "counts_dir", "=", "os", ".", "path", ".", "dirname", "(", "dd", ".", "get_in_samples", "(", "samples", ",", "dd", ".", "get_combined_counts", ")", ")", "...
load the initial se.rda object using sinclecell-experiment
[ "load", "the", "initial", "se", ".", "rda", "object", "using", "sinclecell", "-", "experiment" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/singlecellexperiment.py#L13-L37
train
bcbio/bcbio-nextgen
bcbio/distributed/multi.py
runner
def runner(parallel, config): """Run functions, provided by string name, on multiple cores on the current machine. """ def run_parallel(fn_name, items): items = [x for x in items if x is not None] if len(items) == 0: return [] items = diagnostics.track_parallel(items, fn_...
python
def runner(parallel, config): """Run functions, provided by string name, on multiple cores on the current machine. """ def run_parallel(fn_name, items): items = [x for x in items if x is not None] if len(items) == 0: return [] items = diagnostics.track_parallel(items, fn_...
[ "def", "runner", "(", "parallel", ",", "config", ")", ":", "def", "run_parallel", "(", "fn_name", ",", "items", ")", ":", "items", "=", "[", "x", "for", "x", "in", "items", "if", "x", "is", "not", "None", "]", "if", "len", "(", "items", ")", "=="...
Run functions, provided by string name, on multiple cores on the current machine.
[ "Run", "functions", "provided", "by", "string", "name", "on", "multiple", "cores", "on", "the", "current", "machine", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/multi.py#L15-L29
train
bcbio/bcbio-nextgen
bcbio/distributed/multi.py
zeromq_aware_logging
def zeromq_aware_logging(f): """Ensure multiprocessing logging uses ZeroMQ queues. ZeroMQ and local stdout/stderr do not behave nicely when intertwined. This ensures the local logging uses existing ZeroMQ logging queues. """ @functools.wraps(f) def wrapper(*args, **kwargs): config = Non...
python
def zeromq_aware_logging(f): """Ensure multiprocessing logging uses ZeroMQ queues. ZeroMQ and local stdout/stderr do not behave nicely when intertwined. This ensures the local logging uses existing ZeroMQ logging queues. """ @functools.wraps(f) def wrapper(*args, **kwargs): config = Non...
[ "def", "zeromq_aware_logging", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "config", "=", "None", "for", "arg", "in", "args", ":", "if", "config_utils", "...
Ensure multiprocessing logging uses ZeroMQ queues. ZeroMQ and local stdout/stderr do not behave nicely when intertwined. This ensures the local logging uses existing ZeroMQ logging queues.
[ "Ensure", "multiprocessing", "logging", "uses", "ZeroMQ", "queues", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/multi.py#L39-L68
train
bcbio/bcbio-nextgen
bcbio/distributed/multi.py
run_multicore
def run_multicore(fn, items, config, parallel=None): """Run the function using multiple cores on the given items to process. """ if len(items) == 0: return [] if parallel is None or "num_jobs" not in parallel: if parallel is None: parallel = {"type": "local", "cores": config[...
python
def run_multicore(fn, items, config, parallel=None): """Run the function using multiple cores on the given items to process. """ if len(items) == 0: return [] if parallel is None or "num_jobs" not in parallel: if parallel is None: parallel = {"type": "local", "cores": config[...
[ "def", "run_multicore", "(", "fn", ",", "items", ",", "config", ",", "parallel", "=", "None", ")", ":", "if", "len", "(", "items", ")", "==", "0", ":", "return", "[", "]", "if", "parallel", "is", "None", "or", "\"num_jobs\"", "not", "in", "parallel",...
Run the function using multiple cores on the given items to process.
[ "Run", "the", "function", "using", "multiple", "cores", "on", "the", "given", "items", "to", "process", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/multi.py#L70-L89
train
bcbio/bcbio-nextgen
scripts/bcbio_fastq_umi_prep.py
_add_umis_with_fastp
def _add_umis_with_fastp(read_fq, umi_fq, out_fq, cores): """Add UMIs to reads from separate UMI file using fastp. """ with utils.open_gzipsafe(umi_fq) as in_handle: in_handle.readline() # name umi_size = len(in_handle.readline().strip()) cmd = ("fastp -Q -A -L -G -w 1 --in1 {read_fq} -...
python
def _add_umis_with_fastp(read_fq, umi_fq, out_fq, cores): """Add UMIs to reads from separate UMI file using fastp. """ with utils.open_gzipsafe(umi_fq) as in_handle: in_handle.readline() # name umi_size = len(in_handle.readline().strip()) cmd = ("fastp -Q -A -L -G -w 1 --in1 {read_fq} -...
[ "def", "_add_umis_with_fastp", "(", "read_fq", ",", "umi_fq", ",", "out_fq", ",", "cores", ")", ":", "with", "utils", ".", "open_gzipsafe", "(", "umi_fq", ")", "as", "in_handle", ":", "in_handle", ".", "readline", "(", ")", "# name", "umi_size", "=", "len"...
Add UMIs to reads from separate UMI file using fastp.
[ "Add", "UMIs", "to", "reads", "from", "separate", "UMI", "file", "using", "fastp", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/bcbio_fastq_umi_prep.py#L117-L127
train
bcbio/bcbio-nextgen
scripts/bcbio_fastq_umi_prep.py
_find_umi
def _find_umi(files): """Find UMI file using different naming schemes. R1/R2/R3 => R1/R3 with R2 UMI R1/R2/I1 => R1/R2 with I1 UMI """ base = os.path.basename(_commonprefix(files)) def _file_ext(f): exts = utils.splitext_plus(os.path.basename(f).replace(base, ""))[0].split("_") ...
python
def _find_umi(files): """Find UMI file using different naming schemes. R1/R2/R3 => R1/R3 with R2 UMI R1/R2/I1 => R1/R2 with I1 UMI """ base = os.path.basename(_commonprefix(files)) def _file_ext(f): exts = utils.splitext_plus(os.path.basename(f).replace(base, ""))[0].split("_") ...
[ "def", "_find_umi", "(", "files", ")", ":", "base", "=", "os", ".", "path", ".", "basename", "(", "_commonprefix", "(", "files", ")", ")", "def", "_file_ext", "(", "f", ")", ":", "exts", "=", "utils", ".", "splitext_plus", "(", "os", ".", "path", "...
Find UMI file using different naming schemes. R1/R2/R3 => R1/R3 with R2 UMI R1/R2/I1 => R1/R2 with I1 UMI
[ "Find", "UMI", "file", "using", "different", "naming", "schemes", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/bcbio_fastq_umi_prep.py#L176-L194
train
bcbio/bcbio-nextgen
scripts/bcbio_fastq_umi_prep.py
_commonprefix
def _commonprefix(files): """Retrieve a common prefix for files without extra _R1 _I1 extensions. Allows alternative naming schemes (R1/R2/R3) (R1/R2/I1). """ out = os.path.commonprefix(files) out = out.rstrip("_R") out = out.rstrip("_I") out = out.rstrip("_") return out
python
def _commonprefix(files): """Retrieve a common prefix for files without extra _R1 _I1 extensions. Allows alternative naming schemes (R1/R2/R3) (R1/R2/I1). """ out = os.path.commonprefix(files) out = out.rstrip("_R") out = out.rstrip("_I") out = out.rstrip("_") return out
[ "def", "_commonprefix", "(", "files", ")", ":", "out", "=", "os", ".", "path", ".", "commonprefix", "(", "files", ")", "out", "=", "out", ".", "rstrip", "(", "\"_R\"", ")", "out", "=", "out", ".", "rstrip", "(", "\"_I\"", ")", "out", "=", "out", ...
Retrieve a common prefix for files without extra _R1 _I1 extensions. Allows alternative naming schemes (R1/R2/R3) (R1/R2/I1).
[ "Retrieve", "a", "common", "prefix", "for", "files", "without", "extra", "_R1", "_I1", "extensions", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/bcbio_fastq_umi_prep.py#L196-L205
train
bcbio/bcbio-nextgen
bcbio/variation/vfilter.py
cutoff_w_expression
def cutoff_w_expression(vcf_file, expression, data, name="+", filterext="", extra_cmd="", limit_regions="variant_regions"): """Perform cutoff-based soft filtering using bcftools expressions like %QUAL < 20 || DP < 4. """ base, ext = utils.splitext_plus(vcf_file) out_file = "{base}-...
python
def cutoff_w_expression(vcf_file, expression, data, name="+", filterext="", extra_cmd="", limit_regions="variant_regions"): """Perform cutoff-based soft filtering using bcftools expressions like %QUAL < 20 || DP < 4. """ base, ext = utils.splitext_plus(vcf_file) out_file = "{base}-...
[ "def", "cutoff_w_expression", "(", "vcf_file", ",", "expression", ",", "data", ",", "name", "=", "\"+\"", ",", "filterext", "=", "\"\"", ",", "extra_cmd", "=", "\"\"", ",", "limit_regions", "=", "\"variant_regions\"", ")", ":", "base", ",", "ext", "=", "ut...
Perform cutoff-based soft filtering using bcftools expressions like %QUAL < 20 || DP < 4.
[ "Perform", "cutoff", "-", "based", "soft", "filtering", "using", "bcftools", "expressions", "like", "%QUAL", "<", "20", "||", "DP", "<", "4", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vfilter.py#L21-L45
train
bcbio/bcbio-nextgen
bcbio/variation/vfilter.py
_freebayes_custom
def _freebayes_custom(in_file, ref_file, data): """Custom FreeBayes filtering using bcbio.variation, tuned to human NA12878 results. Experimental: for testing new methods. """ if vcfutils.get_paired_phenotype(data): return None config = data["config"] bv_ver = programs.get_version("bcbi...
python
def _freebayes_custom(in_file, ref_file, data): """Custom FreeBayes filtering using bcbio.variation, tuned to human NA12878 results. Experimental: for testing new methods. """ if vcfutils.get_paired_phenotype(data): return None config = data["config"] bv_ver = programs.get_version("bcbi...
[ "def", "_freebayes_custom", "(", "in_file", ",", "ref_file", ",", "data", ")", ":", "if", "vcfutils", ".", "get_paired_phenotype", "(", "data", ")", ":", "return", "None", "config", "=", "data", "[", "\"config\"", "]", "bv_ver", "=", "programs", ".", "get_...
Custom FreeBayes filtering using bcbio.variation, tuned to human NA12878 results. Experimental: for testing new methods.
[ "Custom", "FreeBayes", "filtering", "using", "bcbio", ".", "variation", "tuned", "to", "human", "NA12878", "results", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vfilter.py#L56-L76
train
bcbio/bcbio-nextgen
bcbio/variation/vfilter.py
_freebayes_cutoff
def _freebayes_cutoff(in_file, data): """Perform filtering of FreeBayes results, flagging low confidence calls. Filters using cutoffs on low depth based on Meynert et al's work modeling sensitivity of homozygote and heterozygote calling on depth: http://www.ncbi.nlm.nih.gov/pubmed/23773188 and hi...
python
def _freebayes_cutoff(in_file, data): """Perform filtering of FreeBayes results, flagging low confidence calls. Filters using cutoffs on low depth based on Meynert et al's work modeling sensitivity of homozygote and heterozygote calling on depth: http://www.ncbi.nlm.nih.gov/pubmed/23773188 and hi...
[ "def", "_freebayes_cutoff", "(", "in_file", ",", "data", ")", ":", "if", "not", "vcfutils", ".", "vcf_has_variants", "(", "in_file", ")", ":", "base", ",", "ext", "=", "utils", ".", "splitext_plus", "(", "in_file", ")", "out_file", "=", "\"{base}-filter{ext}...
Perform filtering of FreeBayes results, flagging low confidence calls. Filters using cutoffs on low depth based on Meynert et al's work modeling sensitivity of homozygote and heterozygote calling on depth: http://www.ncbi.nlm.nih.gov/pubmed/23773188 and high depth heterozygote SNP filtering based on ...
[ "Perform", "filtering", "of", "FreeBayes", "results", "flagging", "low", "confidence", "calls", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vfilter.py#L78-L112
train
bcbio/bcbio-nextgen
bcbio/variation/vfilter.py
_calc_vcf_stats
def _calc_vcf_stats(in_file): """Calculate statistics on VCF for filtering, saving to a file for quick re-runs. """ out_file = "%s-stats.yaml" % utils.splitext_plus(in_file)[0] if not utils.file_exists(out_file): stats = {"avg_depth": _average_called_depth(in_file)} with open(out_file, "...
python
def _calc_vcf_stats(in_file): """Calculate statistics on VCF for filtering, saving to a file for quick re-runs. """ out_file = "%s-stats.yaml" % utils.splitext_plus(in_file)[0] if not utils.file_exists(out_file): stats = {"avg_depth": _average_called_depth(in_file)} with open(out_file, "...
[ "def", "_calc_vcf_stats", "(", "in_file", ")", ":", "out_file", "=", "\"%s-stats.yaml\"", "%", "utils", ".", "splitext_plus", "(", "in_file", ")", "[", "0", "]", "if", "not", "utils", ".", "file_exists", "(", "out_file", ")", ":", "stats", "=", "{", "\"a...
Calculate statistics on VCF for filtering, saving to a file for quick re-runs.
[ "Calculate", "statistics", "on", "VCF", "for", "filtering", "saving", "to", "a", "file", "for", "quick", "re", "-", "runs", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vfilter.py#L121-L133
train
bcbio/bcbio-nextgen
bcbio/variation/vfilter.py
_average_called_depth
def _average_called_depth(in_file): """Retrieve the average depth of called reads in the provided VCF. """ import cyvcf2 depths = [] for rec in cyvcf2.VCF(str(in_file)): d = rec.INFO.get("DP") if d is not None: depths.append(int(d)) if len(depths) > 0: return ...
python
def _average_called_depth(in_file): """Retrieve the average depth of called reads in the provided VCF. """ import cyvcf2 depths = [] for rec in cyvcf2.VCF(str(in_file)): d = rec.INFO.get("DP") if d is not None: depths.append(int(d)) if len(depths) > 0: return ...
[ "def", "_average_called_depth", "(", "in_file", ")", ":", "import", "cyvcf2", "depths", "=", "[", "]", "for", "rec", "in", "cyvcf2", ".", "VCF", "(", "str", "(", "in_file", ")", ")", ":", "d", "=", "rec", ".", "INFO", ".", "get", "(", "\"DP\"", ")"...
Retrieve the average depth of called reads in the provided VCF.
[ "Retrieve", "the", "average", "depth", "of", "called", "reads", "in", "the", "provided", "VCF", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vfilter.py#L135-L147
train
bcbio/bcbio-nextgen
bcbio/variation/vfilter.py
platypus
def platypus(in_file, data): """Filter Platypus calls, removing Q20 filter and replacing with depth and quality based filter. Platypus uses its own VCF nomenclature: TC == DP, FR == AF Platypus gVCF output appears to have an 0/1 index problem so the reference block regions are 1 base outside regions o...
python
def platypus(in_file, data): """Filter Platypus calls, removing Q20 filter and replacing with depth and quality based filter. Platypus uses its own VCF nomenclature: TC == DP, FR == AF Platypus gVCF output appears to have an 0/1 index problem so the reference block regions are 1 base outside regions o...
[ "def", "platypus", "(", "in_file", ",", "data", ")", ":", "filters", "=", "(", "'(FR[0] <= 0.5 && TC < 4 && %QUAL < 20) || '", "'(TC < 13 && %QUAL < 10) || '", "'(FR[0] > 0.5 && TC < 4 && %QUAL < 50)'", ")", "limit_regions", "=", "\"variant_regions\"", "if", "not", "vcfutils"...
Filter Platypus calls, removing Q20 filter and replacing with depth and quality based filter. Platypus uses its own VCF nomenclature: TC == DP, FR == AF Platypus gVCF output appears to have an 0/1 index problem so the reference block regions are 1 base outside regions of interest. We avoid limiting region...
[ "Filter", "Platypus", "calls", "removing", "Q20", "filter", "and", "replacing", "with", "depth", "and", "quality", "based", "filter", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vfilter.py#L149-L163
train
bcbio/bcbio-nextgen
bcbio/variation/vfilter.py
gatk_snp_cutoff
def gatk_snp_cutoff(in_file, data): """Perform cutoff-based soft filtering on GATK SNPs using best-practice recommendations. We have a more lenient mapping quality (MQ) filter compared to GATK defaults. The recommended filter (MQ < 40) is too stringent, so we adjust to 30: http://imgur.com/a/oHRVB ...
python
def gatk_snp_cutoff(in_file, data): """Perform cutoff-based soft filtering on GATK SNPs using best-practice recommendations. We have a more lenient mapping quality (MQ) filter compared to GATK defaults. The recommended filter (MQ < 40) is too stringent, so we adjust to 30: http://imgur.com/a/oHRVB ...
[ "def", "gatk_snp_cutoff", "(", "in_file", ",", "data", ")", ":", "filters", "=", "[", "\"MQRankSum < -12.5\"", ",", "\"ReadPosRankSum < -8.0\"", "]", "# GATK Haplotype caller (v2.2) appears to have much larger HaplotypeScores", "# resulting in excessive filtering, so avoid this metri...
Perform cutoff-based soft filtering on GATK SNPs using best-practice recommendations. We have a more lenient mapping quality (MQ) filter compared to GATK defaults. The recommended filter (MQ < 40) is too stringent, so we adjust to 30: http://imgur.com/a/oHRVB QD and FS are not calculated when generati...
[ "Perform", "cutoff", "-", "based", "soft", "filtering", "on", "GATK", "SNPs", "using", "best", "-", "practice", "recommendations", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/vfilter.py#L183-L214
train
bcbio/bcbio-nextgen
bcbio/bam/counts.py
random_regions
def random_regions(base, n, size): """Generate n random regions of 'size' in the provided base spread. """ spread = size // 2 base_info = collections.defaultdict(list) for space, start, end in base: base_info[space].append(start + spread) base_info[space].append(end - spread) reg...
python
def random_regions(base, n, size): """Generate n random regions of 'size' in the provided base spread. """ spread = size // 2 base_info = collections.defaultdict(list) for space, start, end in base: base_info[space].append(start + spread) base_info[space].append(end - spread) reg...
[ "def", "random_regions", "(", "base", ",", "n", ",", "size", ")", ":", "spread", "=", "size", "//", "2", "base_info", "=", "collections", ".", "defaultdict", "(", "list", ")", "for", "space", ",", "start", ",", "end", "in", "base", ":", "base_info", ...
Generate n random regions of 'size' in the provided base spread.
[ "Generate", "n", "random", "regions", "of", "size", "in", "the", "provided", "base", "spread", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/counts.py#L52-L65
train
bcbio/bcbio-nextgen
bcbio/bam/counts.py
NormalizedBam.all_regions
def all_regions(self): """Get a tuple of all chromosome, start and end regions. """ regions = [] for sq in self._bam.header["SQ"]: regions.append((sq["SN"], 1, int(sq["LN"]))) return regions
python
def all_regions(self): """Get a tuple of all chromosome, start and end regions. """ regions = [] for sq in self._bam.header["SQ"]: regions.append((sq["SN"], 1, int(sq["LN"]))) return regions
[ "def", "all_regions", "(", "self", ")", ":", "regions", "=", "[", "]", "for", "sq", "in", "self", ".", "_bam", ".", "header", "[", "\"SQ\"", "]", ":", "regions", ".", "append", "(", "(", "sq", "[", "\"SN\"", "]", ",", "1", ",", "int", "(", "sq"...
Get a tuple of all chromosome, start and end regions.
[ "Get", "a", "tuple", "of", "all", "chromosome", "start", "and", "end", "regions", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/counts.py#L25-L31
train
bcbio/bcbio-nextgen
bcbio/bam/counts.py
NormalizedBam.read_count
def read_count(self, space, start, end): """Retrieve the normalized read count in the provided region. """ read_counts = 0 for read in self._bam.fetch(space, start, end): read_counts += 1 return self._normalize(read_counts, self._total)
python
def read_count(self, space, start, end): """Retrieve the normalized read count in the provided region. """ read_counts = 0 for read in self._bam.fetch(space, start, end): read_counts += 1 return self._normalize(read_counts, self._total)
[ "def", "read_count", "(", "self", ",", "space", ",", "start", ",", "end", ")", ":", "read_counts", "=", "0", "for", "read", "in", "self", ".", "_bam", ".", "fetch", "(", "space", ",", "start", ",", "end", ")", ":", "read_counts", "+=", "1", "return...
Retrieve the normalized read count in the provided region.
[ "Retrieve", "the", "normalized", "read", "count", "in", "the", "provided", "region", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/counts.py#L33-L39
train
bcbio/bcbio-nextgen
bcbio/bam/counts.py
NormalizedBam.coverage_pileup
def coverage_pileup(self, space, start, end): """Retrieve pileup coverage across a specified region. """ return ((col.pos, self._normalize(col.n, self._total)) for col in self._bam.pileup(space, start, end))
python
def coverage_pileup(self, space, start, end): """Retrieve pileup coverage across a specified region. """ return ((col.pos, self._normalize(col.n, self._total)) for col in self._bam.pileup(space, start, end))
[ "def", "coverage_pileup", "(", "self", ",", "space", ",", "start", ",", "end", ")", ":", "return", "(", "(", "col", ".", "pos", ",", "self", ".", "_normalize", "(", "col", ".", "n", ",", "self", ".", "_total", ")", ")", "for", "col", "in", "self"...
Retrieve pileup coverage across a specified region.
[ "Retrieve", "pileup", "coverage", "across", "a", "specified", "region", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/counts.py#L41-L45
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/phylowgs.py
_prepare_summary
def _prepare_summary(evolve_file, ssm_file, cnv_file, work_dir, somatic_info): """Prepare a summary with gene-labelled heterogeneity from PhyloWGS predictions. """ out_file = os.path.join(work_dir, "%s-phylowgs.txt" % somatic_info.tumor_name) if not utils.file_uptodate(out_file, evolve_file): wi...
python
def _prepare_summary(evolve_file, ssm_file, cnv_file, work_dir, somatic_info): """Prepare a summary with gene-labelled heterogeneity from PhyloWGS predictions. """ out_file = os.path.join(work_dir, "%s-phylowgs.txt" % somatic_info.tumor_name) if not utils.file_uptodate(out_file, evolve_file): wi...
[ "def", "_prepare_summary", "(", "evolve_file", ",", "ssm_file", ",", "cnv_file", ",", "work_dir", ",", "somatic_info", ")", ":", "out_file", "=", "os", ".", "path", ".", "join", "(", "work_dir", ",", "\"%s-phylowgs.txt\"", "%", "somatic_info", ".", "tumor_name...
Prepare a summary with gene-labelled heterogeneity from PhyloWGS predictions.
[ "Prepare", "a", "summary", "with", "gene", "-", "labelled", "heterogeneity", "from", "PhyloWGS", "predictions", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/phylowgs.py#L39-L55
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/phylowgs.py
_gids_to_genes
def _gids_to_genes(gids, ssm_locs, cnv_ssms, data): """Convert support ids for SNPs and SSMs into associated genes. """ locs = collections.defaultdict(set) for gid in gids: cur_locs = [] try: cur_locs.append(ssm_locs[gid]) except KeyError: for ssm_loc in c...
python
def _gids_to_genes(gids, ssm_locs, cnv_ssms, data): """Convert support ids for SNPs and SSMs into associated genes. """ locs = collections.defaultdict(set) for gid in gids: cur_locs = [] try: cur_locs.append(ssm_locs[gid]) except KeyError: for ssm_loc in c...
[ "def", "_gids_to_genes", "(", "gids", ",", "ssm_locs", ",", "cnv_ssms", ",", "data", ")", ":", "locs", "=", "collections", ".", "defaultdict", "(", "set", ")", "for", "gid", "in", "gids", ":", "cur_locs", "=", "[", "]", "try", ":", "cur_locs", ".", "...
Convert support ids for SNPs and SSMs into associated genes.
[ "Convert", "support", "ids", "for", "SNPs", "and", "SSMs", "into", "associated", "genes", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/phylowgs.py#L57-L83
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/phylowgs.py
_evolve_reader
def _evolve_reader(in_file): """Generate a list of region IDs and trees from a top_k_trees evolve.py file. """ cur_id_list = None cur_tree = None with open(in_file) as in_handle: for line in in_handle: if line.startswith("id,"): if cur_id_list: ...
python
def _evolve_reader(in_file): """Generate a list of region IDs and trees from a top_k_trees evolve.py file. """ cur_id_list = None cur_tree = None with open(in_file) as in_handle: for line in in_handle: if line.startswith("id,"): if cur_id_list: ...
[ "def", "_evolve_reader", "(", "in_file", ")", ":", "cur_id_list", "=", "None", "cur_tree", "=", "None", "with", "open", "(", "in_file", ")", "as", "in_handle", ":", "for", "line", "in", "in_handle", ":", "if", "line", ".", "startswith", "(", "\"id,\"", "...
Generate a list of region IDs and trees from a top_k_trees evolve.py file.
[ "Generate", "a", "list", "of", "region", "IDs", "and", "trees", "from", "a", "top_k_trees", "evolve", ".", "py", "file", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/phylowgs.py#L85-L112
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/phylowgs.py
_read_cnv_ssms
def _read_cnv_ssms(in_file): """Map CNVs to associated SSMs """ out = {} with open(in_file) as in_handle: in_handle.readline() # header for line in in_handle: parts = line.strip().split() if len(parts) > 3: cnvid, _, _, ssms = parts ...
python
def _read_cnv_ssms(in_file): """Map CNVs to associated SSMs """ out = {} with open(in_file) as in_handle: in_handle.readline() # header for line in in_handle: parts = line.strip().split() if len(parts) > 3: cnvid, _, _, ssms = parts ...
[ "def", "_read_cnv_ssms", "(", "in_file", ")", ":", "out", "=", "{", "}", "with", "open", "(", "in_file", ")", "as", "in_handle", ":", "in_handle", ".", "readline", "(", ")", "# header", "for", "line", "in", "in_handle", ":", "parts", "=", "line", ".", ...
Map CNVs to associated SSMs
[ "Map", "CNVs", "to", "associated", "SSMs" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/phylowgs.py#L114-L125
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/phylowgs.py
_read_ssm_locs
def _read_ssm_locs(in_file): """Map SSMs to chromosomal locations. """ out = {} with open(in_file) as in_handle: in_handle.readline() # header for line in in_handle: sid, loc = line.split()[:2] chrom, pos = loc.split("_") out[sid] = (chrom, int(pos)) ...
python
def _read_ssm_locs(in_file): """Map SSMs to chromosomal locations. """ out = {} with open(in_file) as in_handle: in_handle.readline() # header for line in in_handle: sid, loc = line.split()[:2] chrom, pos = loc.split("_") out[sid] = (chrom, int(pos)) ...
[ "def", "_read_ssm_locs", "(", "in_file", ")", ":", "out", "=", "{", "}", "with", "open", "(", "in_file", ")", "as", "in_handle", ":", "in_handle", ".", "readline", "(", ")", "# header", "for", "line", "in", "in_handle", ":", "sid", ",", "loc", "=", "...
Map SSMs to chromosomal locations.
[ "Map", "SSMs", "to", "chromosomal", "locations", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/phylowgs.py#L127-L137
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/phylowgs.py
_run_evolve
def _run_evolve(ssm_file, cnv_file, work_dir, data): """Run evolve.py to infer subclonal composition. """ exe = os.path.join(os.path.dirname(sys.executable), "evolve.py") assert os.path.exists(exe), "Could not find evolve script for PhyloWGS runs." out_dir = os.path.join(work_dir, "evolve") out_...
python
def _run_evolve(ssm_file, cnv_file, work_dir, data): """Run evolve.py to infer subclonal composition. """ exe = os.path.join(os.path.dirname(sys.executable), "evolve.py") assert os.path.exists(exe), "Could not find evolve script for PhyloWGS runs." out_dir = os.path.join(work_dir, "evolve") out_...
[ "def", "_run_evolve", "(", "ssm_file", ",", "cnv_file", ",", "work_dir", ",", "data", ")", ":", "exe", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "sys", ".", "executable", ")", ",", "\"evolve.py\"", ")", "assert...
Run evolve.py to infer subclonal composition.
[ "Run", "evolve", ".", "py", "to", "infer", "subclonal", "composition", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/phylowgs.py#L139-L151
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/phylowgs.py
_prep_inputs
def _prep_inputs(vrn_info, cnv_info, somatic_info, work_dir, config): """Prepare inputs for running PhyloWGS from variant and CNV calls. """ exe = os.path.join(os.path.dirname(sys.executable), "create_phylowgs_inputs.py") assert os.path.exists(exe), "Could not find input prep script for PhyloWGS runs." ...
python
def _prep_inputs(vrn_info, cnv_info, somatic_info, work_dir, config): """Prepare inputs for running PhyloWGS from variant and CNV calls. """ exe = os.path.join(os.path.dirname(sys.executable), "create_phylowgs_inputs.py") assert os.path.exists(exe), "Could not find input prep script for PhyloWGS runs." ...
[ "def", "_prep_inputs", "(", "vrn_info", ",", "cnv_info", ",", "somatic_info", ",", "work_dir", ",", "config", ")", ":", "exe", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "sys", ".", "executable", ")", ",", "\"cr...
Prepare inputs for running PhyloWGS from variant and CNV calls.
[ "Prepare", "inputs", "for", "running", "PhyloWGS", "from", "variant", "and", "CNV", "calls", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/phylowgs.py#L153-L171
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/phylowgs.py
_prep_cnv_file
def _prep_cnv_file(in_file, work_dir, somatic_info): """Prepare Battenberg CNV file for ingest by PhyloWGS. The PhyloWGS preparation script does not handle 'chr' prefixed chromosomes (hg19 style) correctly. This converts them over to GRCh37 (no 'chr') style to match preparation work in _prep_vrn_file. ...
python
def _prep_cnv_file(in_file, work_dir, somatic_info): """Prepare Battenberg CNV file for ingest by PhyloWGS. The PhyloWGS preparation script does not handle 'chr' prefixed chromosomes (hg19 style) correctly. This converts them over to GRCh37 (no 'chr') style to match preparation work in _prep_vrn_file. ...
[ "def", "_prep_cnv_file", "(", "in_file", ",", "work_dir", ",", "somatic_info", ")", ":", "out_file", "=", "os", ".", "path", ".", "join", "(", "work_dir", ",", "\"%s-prep%s\"", "%", "utils", ".", "splitext_plus", "(", "os", ".", "path", ".", "basename", ...
Prepare Battenberg CNV file for ingest by PhyloWGS. The PhyloWGS preparation script does not handle 'chr' prefixed chromosomes (hg19 style) correctly. This converts them over to GRCh37 (no 'chr') style to match preparation work in _prep_vrn_file.
[ "Prepare", "Battenberg", "CNV", "file", "for", "ingest", "by", "PhyloWGS", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/phylowgs.py#L173-L190
train
bcbio/bcbio-nextgen
bcbio/heterogeneity/phylowgs.py
_prep_vrn_file
def _prep_vrn_file(in_file, vcaller, work_dir, somatic_info, ignore_file, config): """Create a variant file to feed into the PhyloWGS prep script, limiting records. Sorts by depth, adding top covered samples up to the sample_size supported by PhyloWGS. The logic is that the higher depth samples will have b...
python
def _prep_vrn_file(in_file, vcaller, work_dir, somatic_info, ignore_file, config): """Create a variant file to feed into the PhyloWGS prep script, limiting records. Sorts by depth, adding top covered samples up to the sample_size supported by PhyloWGS. The logic is that the higher depth samples will have b...
[ "def", "_prep_vrn_file", "(", "in_file", ",", "vcaller", ",", "work_dir", ",", "somatic_info", ",", "ignore_file", ",", "config", ")", ":", "if", "vcaller", ".", "startswith", "(", "\"vardict\"", ")", ":", "variant_type", "=", "\"vardict\"", "elif", "vcaller",...
Create a variant file to feed into the PhyloWGS prep script, limiting records. Sorts by depth, adding top covered samples up to the sample_size supported by PhyloWGS. The logic is that the higher depth samples will have better resolution for frequency differences. More complex implementations could try ...
[ "Create", "a", "variant", "file", "to", "feed", "into", "the", "PhyloWGS", "prep", "script", "limiting", "records", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/heterogeneity/phylowgs.py#L197-L243
train
bcbio/bcbio-nextgen
bcbio/srna/group.py
run_prepare
def run_prepare(*data): """ Run seqcluster prepare to merge all samples in one file """ out_dir = os.path.join(dd.get_work_dir(data[0][0]), "seqcluster", "prepare") out_dir = os.path.abspath(safe_makedir(out_dir)) prepare_dir = os.path.join(out_dir, "prepare") tools = dd.get_expression_calle...
python
def run_prepare(*data): """ Run seqcluster prepare to merge all samples in one file """ out_dir = os.path.join(dd.get_work_dir(data[0][0]), "seqcluster", "prepare") out_dir = os.path.abspath(safe_makedir(out_dir)) prepare_dir = os.path.join(out_dir, "prepare") tools = dd.get_expression_calle...
[ "def", "run_prepare", "(", "*", "data", ")", ":", "out_dir", "=", "os", ".", "path", ".", "join", "(", "dd", ".", "get_work_dir", "(", "data", "[", "0", "]", "[", "0", "]", ")", ",", "\"seqcluster\"", ",", "\"prepare\"", ")", "out_dir", "=", "os", ...
Run seqcluster prepare to merge all samples in one file
[ "Run", "seqcluster", "prepare", "to", "merge", "all", "samples", "in", "one", "file" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/srna/group.py#L24-L56
train
bcbio/bcbio-nextgen
bcbio/srna/group.py
run_align
def run_align(*data): """ Prepare data to run alignment step, only once for each project """ work_dir = dd.get_work_dir(data[0][0]) out_dir = op.join(work_dir, "seqcluster", "prepare") seq_out = op.join(out_dir, "seqs.fastq") bam_dir = op.join(work_dir, "align") new_bam_file = op.join(ba...
python
def run_align(*data): """ Prepare data to run alignment step, only once for each project """ work_dir = dd.get_work_dir(data[0][0]) out_dir = op.join(work_dir, "seqcluster", "prepare") seq_out = op.join(out_dir, "seqs.fastq") bam_dir = op.join(work_dir, "align") new_bam_file = op.join(ba...
[ "def", "run_align", "(", "*", "data", ")", ":", "work_dir", "=", "dd", ".", "get_work_dir", "(", "data", "[", "0", "]", "[", "0", "]", ")", "out_dir", "=", "op", ".", "join", "(", "work_dir", ",", "\"seqcluster\"", ",", "\"prepare\"", ")", "seq_out",...
Prepare data to run alignment step, only once for each project
[ "Prepare", "data", "to", "run", "alignment", "step", "only", "once", "for", "each", "project" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/srna/group.py#L58-L80
train
bcbio/bcbio-nextgen
bcbio/srna/group.py
run_cluster
def run_cluster(*data): """ Run seqcluster cluster to detect smallRNA clusters """ sample = data[0][0] tools = dd.get_expression_caller(data[0][0]) work_dir = dd.get_work_dir(sample) out_dir = op.join(work_dir, "seqcluster", "cluster") out_dir = op.abspath(safe_makedir(out_dir)) prep...
python
def run_cluster(*data): """ Run seqcluster cluster to detect smallRNA clusters """ sample = data[0][0] tools = dd.get_expression_caller(data[0][0]) work_dir = dd.get_work_dir(sample) out_dir = op.join(work_dir, "seqcluster", "cluster") out_dir = op.abspath(safe_makedir(out_dir)) prep...
[ "def", "run_cluster", "(", "*", "data", ")", ":", "sample", "=", "data", "[", "0", "]", "[", "0", "]", "tools", "=", "dd", ".", "get_expression_caller", "(", "data", "[", "0", "]", "[", "0", "]", ")", "work_dir", "=", "dd", ".", "get_work_dir", "...
Run seqcluster cluster to detect smallRNA clusters
[ "Run", "seqcluster", "cluster", "to", "detect", "smallRNA", "clusters" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/srna/group.py#L82-L114
train
bcbio/bcbio-nextgen
bcbio/srna/group.py
_cluster
def _cluster(bam_file, ma_file, out_dir, reference, annotation_file=None): """ Connect to seqcluster to run cluster with python directly """ seqcluster = op.join(get_bcbio_bin(), "seqcluster") # cl = ["cluster", "-o", out_dir, "-m", ma_file, "-a", bam_file, "-r", reference] if annotation_file: ...
python
def _cluster(bam_file, ma_file, out_dir, reference, annotation_file=None): """ Connect to seqcluster to run cluster with python directly """ seqcluster = op.join(get_bcbio_bin(), "seqcluster") # cl = ["cluster", "-o", out_dir, "-m", ma_file, "-a", bam_file, "-r", reference] if annotation_file: ...
[ "def", "_cluster", "(", "bam_file", ",", "ma_file", ",", "out_dir", ",", "reference", ",", "annotation_file", "=", "None", ")", ":", "seqcluster", "=", "op", ".", "join", "(", "get_bcbio_bin", "(", ")", ",", "\"seqcluster\"", ")", "# cl = [\"cluster\", \"-o\",...
Connect to seqcluster to run cluster with python directly
[ "Connect", "to", "seqcluster", "to", "run", "cluster", "with", "python", "directly" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/srna/group.py#L116-L133
train
bcbio/bcbio-nextgen
bcbio/srna/group.py
_report
def _report(data, reference): """ Run report of seqcluster to get browser options for results """ seqcluster = op.join(get_bcbio_bin(), "seqcluster") work_dir = dd.get_work_dir(data) out_dir = safe_makedir(os.path.join(work_dir, "seqcluster", "report")) out_file = op.join(out_dir, "seqcluste...
python
def _report(data, reference): """ Run report of seqcluster to get browser options for results """ seqcluster = op.join(get_bcbio_bin(), "seqcluster") work_dir = dd.get_work_dir(data) out_dir = safe_makedir(os.path.join(work_dir, "seqcluster", "report")) out_file = op.join(out_dir, "seqcluste...
[ "def", "_report", "(", "data", ",", "reference", ")", ":", "seqcluster", "=", "op", ".", "join", "(", "get_bcbio_bin", "(", ")", ",", "\"seqcluster\"", ")", "work_dir", "=", "dd", ".", "get_work_dir", "(", "data", ")", "out_dir", "=", "safe_makedir", "("...
Run report of seqcluster to get browser options for results
[ "Run", "report", "of", "seqcluster", "to", "get", "browser", "options", "for", "results" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/srna/group.py#L135-L147
train
bcbio/bcbio-nextgen
bcbio/srna/group.py
report
def report(data): """Create a Rmd report for small RNAseq analysis""" work_dir = dd.get_work_dir(data[0][0]) out_dir = op.join(work_dir, "report") safe_makedir(out_dir) summary_file = op.join(out_dir, "summary.csv") with file_transaction(summary_file) as out_tx: with open(out_tx, 'w') as...
python
def report(data): """Create a Rmd report for small RNAseq analysis""" work_dir = dd.get_work_dir(data[0][0]) out_dir = op.join(work_dir, "report") safe_makedir(out_dir) summary_file = op.join(out_dir, "summary.csv") with file_transaction(summary_file) as out_tx: with open(out_tx, 'w') as...
[ "def", "report", "(", "data", ")", ":", "work_dir", "=", "dd", ".", "get_work_dir", "(", "data", "[", "0", "]", "[", "0", "]", ")", "out_dir", "=", "op", ".", "join", "(", "work_dir", ",", "\"report\"", ")", "safe_makedir", "(", "out_dir", ")", "su...
Create a Rmd report for small RNAseq analysis
[ "Create", "a", "Rmd", "report", "for", "small", "RNAseq", "analysis" ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/srna/group.py#L149-L165
train
bcbio/bcbio-nextgen
bcbio/srna/group.py
_modify_report
def _modify_report(summary_path, out_dir): """Read Rmd template and dump with project path.""" summary_path = op.abspath(summary_path) template = op.normpath(op.join(op.dirname(op.realpath(template_seqcluster.__file__)), "report.rmd")) content = open(template).read() out_content = string.Template(co...
python
def _modify_report(summary_path, out_dir): """Read Rmd template and dump with project path.""" summary_path = op.abspath(summary_path) template = op.normpath(op.join(op.dirname(op.realpath(template_seqcluster.__file__)), "report.rmd")) content = open(template).read() out_content = string.Template(co...
[ "def", "_modify_report", "(", "summary_path", ",", "out_dir", ")", ":", "summary_path", "=", "op", ".", "abspath", "(", "summary_path", ")", "template", "=", "op", ".", "normpath", "(", "op", ".", "join", "(", "op", ".", "dirname", "(", "op", ".", "rea...
Read Rmd template and dump with project path.
[ "Read", "Rmd", "template", "and", "dump", "with", "project", "path", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/srna/group.py#L183-L192
train
bcbio/bcbio-nextgen
bcbio/srna/group.py
_make_isomir_counts
def _make_isomir_counts(data, srna_type="seqbuster", out_dir=None, stem=""): """ Parse miraligner files to create count matrix. """ work_dir = dd.get_work_dir(data[0][0]) if not out_dir: out_dir = op.join(work_dir, "mirbase") out_novel_isomir = append_stem(op.join(out_dir, "counts.tsv"),...
python
def _make_isomir_counts(data, srna_type="seqbuster", out_dir=None, stem=""): """ Parse miraligner files to create count matrix. """ work_dir = dd.get_work_dir(data[0][0]) if not out_dir: out_dir = op.join(work_dir, "mirbase") out_novel_isomir = append_stem(op.join(out_dir, "counts.tsv"),...
[ "def", "_make_isomir_counts", "(", "data", ",", "srna_type", "=", "\"seqbuster\"", ",", "out_dir", "=", "None", ",", "stem", "=", "\"\"", ")", ":", "work_dir", "=", "dd", ".", "get_work_dir", "(", "data", "[", "0", "]", "[", "0", "]", ")", "if", "not...
Parse miraligner files to create count matrix.
[ "Parse", "miraligner", "files", "to", "create", "count", "matrix", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/srna/group.py#L194-L221
train
bcbio/bcbio-nextgen
bcbio/bam/coverage.py
_split_regions
def _split_regions(chrom, start, end): """Split regions longer than 100kb into smaller sections. """ window_size = 1e5 if end - start < window_size * 5: return [(chrom, start, end)] else: out = [] for r in pybedtools.BedTool().window_maker(w=window_size, ...
python
def _split_regions(chrom, start, end): """Split regions longer than 100kb into smaller sections. """ window_size = 1e5 if end - start < window_size * 5: return [(chrom, start, end)] else: out = [] for r in pybedtools.BedTool().window_maker(w=window_size, ...
[ "def", "_split_regions", "(", "chrom", ",", "start", ",", "end", ")", ":", "window_size", "=", "1e5", "if", "end", "-", "start", "<", "window_size", "*", "5", ":", "return", "[", "(", "chrom", ",", "start", ",", "end", ")", "]", "else", ":", "out",...
Split regions longer than 100kb into smaller sections.
[ "Split", "regions", "longer", "than", "100kb", "into", "smaller", "sections", "." ]
6a9348c0054ccd5baffd22f1bb7d0422f6978b20
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/coverage.py#L96-L108
train