repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
lpantano/seqcluster
seqcluster/make_clusters.py
_total_counts
def _total_counts(seqs, seqL, aligned=False): """ Counts total seqs after each step """ total = Counter() if isinstance(seqs, list): if not aligned: l = len([total.update(seqL[s].freq) for s in seqs]) else: l = len([total.update(seqL[s].freq) for s in seqs if ...
python
def _total_counts(seqs, seqL, aligned=False): """ Counts total seqs after each step """ total = Counter() if isinstance(seqs, list): if not aligned: l = len([total.update(seqL[s].freq) for s in seqs]) else: l = len([total.update(seqL[s].freq) for s in seqs if ...
[ "def", "_total_counts", "(", "seqs", ",", "seqL", ",", "aligned", "=", "False", ")", ":", "total", "=", "Counter", "(", ")", "if", "isinstance", "(", "seqs", ",", "list", ")", ":", "if", "not", "aligned", ":", "l", "=", "len", "(", "[", "total", ...
Counts total seqs after each step
[ "Counts", "total", "seqs", "after", "each", "step" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/make_clusters.py#L148-L161
lpantano/seqcluster
seqcluster/make_clusters.py
_get_annotation
def _get_annotation(c, loci): """get annotation of transcriptional units""" data_ann_temp = {} data_ann = [] counts = Counter() for lid in c.loci2seq: # original Py 2.7 code #for dbi in loci[lid].db_ann.keys(): # data_ann_temp[dbi] = {dbi: map(lambda (x): loci[lid].db_ann[...
python
def _get_annotation(c, loci): """get annotation of transcriptional units""" data_ann_temp = {} data_ann = [] counts = Counter() for lid in c.loci2seq: # original Py 2.7 code #for dbi in loci[lid].db_ann.keys(): # data_ann_temp[dbi] = {dbi: map(lambda (x): loci[lid].db_ann[...
[ "def", "_get_annotation", "(", "c", ",", "loci", ")", ":", "data_ann_temp", "=", "{", "}", "data_ann", "=", "[", "]", "counts", "=", "Counter", "(", ")", "for", "lid", "in", "c", ".", "loci2seq", ":", "# original Py 2.7 code", "#for dbi in loci[lid].db_ann.k...
get annotation of transcriptional units
[ "get", "annotation", "of", "transcriptional", "units" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/make_clusters.py#L174-L196
lpantano/seqcluster
seqcluster/make_clusters.py
_sum_by_samples
def _sum_by_samples(seqs_freq, samples_order): """ Sum sequences of a metacluster by samples. """ n = len(seqs_freq[seqs_freq.keys()[0]].freq.keys()) y = np.array([0] * n) for s in seqs_freq: x = seqs_freq[s].freq exp = [seqs_freq[s].freq[sam] for sam in samples_order] y ...
python
def _sum_by_samples(seqs_freq, samples_order): """ Sum sequences of a metacluster by samples. """ n = len(seqs_freq[seqs_freq.keys()[0]].freq.keys()) y = np.array([0] * n) for s in seqs_freq: x = seqs_freq[s].freq exp = [seqs_freq[s].freq[sam] for sam in samples_order] y ...
[ "def", "_sum_by_samples", "(", "seqs_freq", ",", "samples_order", ")", ":", "n", "=", "len", "(", "seqs_freq", "[", "seqs_freq", ".", "keys", "(", ")", "[", "0", "]", "]", ".", "freq", ".", "keys", "(", ")", ")", "y", "=", "np", ".", "array", "("...
Sum sequences of a metacluster by samples.
[ "Sum", "sequences", "of", "a", "metacluster", "by", "samples", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/make_clusters.py#L212-L222
lpantano/seqcluster
seqcluster/make_clusters.py
_annotate
def _annotate(args, setclus): """annotate transcriptional units with gtf/bed files provided by -b/g option""" logger.info("Creating bed file") bedfile = generate_position_bed(setclus) a = pybedtools.BedTool(bedfile, from_string=True) beds = [] logger.info("Annotating clusters") if hasatt...
python
def _annotate(args, setclus): """annotate transcriptional units with gtf/bed files provided by -b/g option""" logger.info("Creating bed file") bedfile = generate_position_bed(setclus) a = pybedtools.BedTool(bedfile, from_string=True) beds = [] logger.info("Annotating clusters") if hasatt...
[ "def", "_annotate", "(", "args", ",", "setclus", ")", ":", "logger", ".", "info", "(", "\"Creating bed file\"", ")", "bedfile", "=", "generate_position_bed", "(", "setclus", ")", "a", "=", "pybedtools", ".", "BedTool", "(", "bedfile", ",", "from_string", "="...
annotate transcriptional units with gtf/bed files provided by -b/g option
[ "annotate", "transcriptional", "units", "with", "gtf", "/", "bed", "files", "provided", "by", "-", "b", "/", "g", "option" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/make_clusters.py#L225-L241
lpantano/seqcluster
seqcluster/make_clusters.py
_clean_alignment
def _clean_alignment(args): """ Prepare alignment for cluster detection. """ logger.info("Clean bam file with highly repetitive reads with low counts. sum(counts)/n_hits > 1%") bam_file, seq_obj = clean_bam_file(args.afile, args.mask) logger.info("Using %s file" % bam_file) detect_complexity...
python
def _clean_alignment(args): """ Prepare alignment for cluster detection. """ logger.info("Clean bam file with highly repetitive reads with low counts. sum(counts)/n_hits > 1%") bam_file, seq_obj = clean_bam_file(args.afile, args.mask) logger.info("Using %s file" % bam_file) detect_complexity...
[ "def", "_clean_alignment", "(", "args", ")", ":", "logger", ".", "info", "(", "\"Clean bam file with highly repetitive reads with low counts. sum(counts)/n_hits > 1%\"", ")", "bam_file", ",", "seq_obj", "=", "clean_bam_file", "(", "args", ".", "afile", ",", "args", ".",...
Prepare alignment for cluster detection.
[ "Prepare", "alignment", "for", "cluster", "detection", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/make_clusters.py#L244-L252
lpantano/seqcluster
seqcluster/make_clusters.py
_create_clusters
def _create_clusters(seqL, bam_file, args): """ Cluster sequences and create metaclusters with multi-mappers. """ clus_obj = [] cluster_file = op.join(args.out, "cluster.bed") if not os.path.exists(op.join(args.out, 'list_obj.pk')): if not file_exists(cluster_file): logge...
python
def _create_clusters(seqL, bam_file, args): """ Cluster sequences and create metaclusters with multi-mappers. """ clus_obj = [] cluster_file = op.join(args.out, "cluster.bed") if not os.path.exists(op.join(args.out, 'list_obj.pk')): if not file_exists(cluster_file): logge...
[ "def", "_create_clusters", "(", "seqL", ",", "bam_file", ",", "args", ")", ":", "clus_obj", "=", "[", "]", "cluster_file", "=", "op", ".", "join", "(", "args", ".", "out", ",", "\"cluster.bed\"", ")", "if", "not", "os", ".", "path", ".", "exists", "(...
Cluster sequences and create metaclusters with multi-mappers.
[ "Cluster", "sequences", "and", "create", "metaclusters", "with", "multi", "-", "mappers", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/make_clusters.py#L255-L284
lpantano/seqcluster
seqcluster/make_clusters.py
_cleaning
def _cleaning(clusL, path): """ Load saved cluster and jump to next step """ backup = op.join(path, "list_obj_red.pk") if not op.exists(backup): clus_obj = reduceloci(clusL, path) with open(backup, 'wb') as output: pickle.dump(clus_obj, output, pickle.HIGHEST_PROTOCOL) ...
python
def _cleaning(clusL, path): """ Load saved cluster and jump to next step """ backup = op.join(path, "list_obj_red.pk") if not op.exists(backup): clus_obj = reduceloci(clusL, path) with open(backup, 'wb') as output: pickle.dump(clus_obj, output, pickle.HIGHEST_PROTOCOL) ...
[ "def", "_cleaning", "(", "clusL", ",", "path", ")", ":", "backup", "=", "op", ".", "join", "(", "path", ",", "\"list_obj_red.pk\"", ")", "if", "not", "op", ".", "exists", "(", "backup", ")", ":", "clus_obj", "=", "reduceloci", "(", "clusL", ",", "pat...
Load saved cluster and jump to next step
[ "Load", "saved", "cluster", "and", "jump", "to", "next", "step" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/make_clusters.py#L287-L301
lpantano/seqcluster
seqcluster/explore_cluster.py
explore
def explore(args): """Create mapping of sequences of two clusters """ logger.info("reading sequeces") data = load_data(args.json) logger.info("get sequences from json") #get_sequences_from_cluster() c1, c2 = args.names.split(",") seqs, names = get_sequences_from_cluster(c1, c2, data[0]) ...
python
def explore(args): """Create mapping of sequences of two clusters """ logger.info("reading sequeces") data = load_data(args.json) logger.info("get sequences from json") #get_sequences_from_cluster() c1, c2 = args.names.split(",") seqs, names = get_sequences_from_cluster(c1, c2, data[0]) ...
[ "def", "explore", "(", "args", ")", ":", "logger", ".", "info", "(", "\"reading sequeces\"", ")", "data", "=", "load_data", "(", "args", ".", "json", ")", "logger", ".", "info", "(", "\"get sequences from json\"", ")", "#get_sequences_from_cluster()", "c1", ",...
Create mapping of sequences of two clusters
[ "Create", "mapping", "of", "sequences", "of", "two", "clusters" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/explore_cluster.py#L13-L30
lpantano/seqcluster
seqcluster/prepare_data.py
prepare
def prepare(args): """ Read all seq.fa files and create a matrix and unique fasta files. The information is :param args: options parsed from command line :param con: logging messages going to console :param log: logging messages going to console and file :returns: files - matrix and fasta ...
python
def prepare(args): """ Read all seq.fa files and create a matrix and unique fasta files. The information is :param args: options parsed from command line :param con: logging messages going to console :param log: logging messages going to console and file :returns: files - matrix and fasta ...
[ "def", "prepare", "(", "args", ")", ":", "try", ":", "f", "=", "open", "(", "args", ".", "config", ",", "'r'", ")", "seq_out", "=", "open", "(", "op", ".", "join", "(", "args", ".", "out", ",", "\"seqs.fastq\"", ")", ",", "'w'", ")", "ma_out", ...
Read all seq.fa files and create a matrix and unique fasta files. The information is :param args: options parsed from command line :param con: logging messages going to console :param log: logging messages going to console and file :returns: files - matrix and fasta files that should be used with ...
[ "Read", "all", "seq", ".", "fa", "files", "and", "create", "a", "matrix", "and", "unique", "fasta", "files", ".", "The", "information", "is" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/prepare_data.py#L18-L42
lpantano/seqcluster
seqcluster/prepare_data.py
_read_fasta_files
def _read_fasta_files(f, args): """ read fasta files of each sample and generate a seq_obj with the information of each unique sequence in each sample :param f: file containing the path for each fasta file and the name of the sample. Two column format with `tab` as field separator :returns: * ...
python
def _read_fasta_files(f, args): """ read fasta files of each sample and generate a seq_obj with the information of each unique sequence in each sample :param f: file containing the path for each fasta file and the name of the sample. Two column format with `tab` as field separator :returns: * ...
[ "def", "_read_fasta_files", "(", "f", ",", "args", ")", ":", "seq_l", "=", "{", "}", "sample_l", "=", "[", "]", "idx", "=", "1", "for", "line1", "in", "f", ":", "line1", "=", "line1", ".", "strip", "(", ")", "cols", "=", "line1", ".", "split", ...
read fasta files of each sample and generate a seq_obj with the information of each unique sequence in each sample :param f: file containing the path for each fasta file and the name of the sample. Two column format with `tab` as field separator :returns: * :code:`seq_l`: is a list of seq_obj obje...
[ "read", "fasta", "files", "of", "each", "sample", "and", "generate", "a", "seq_obj", "with", "the", "information", "of", "each", "unique", "sequence", "in", "each", "sample" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/prepare_data.py#L45-L77
lpantano/seqcluster
seqcluster/prepare_data.py
_read_fastq_files
def _read_fastq_files(f, args): """ read fasta files of each sample and generate a seq_obj with the information of each unique sequence in each sample :param f: file containing the path for each fasta file and the name of the sample. Two column format with `tab` as field separator :returns: * ...
python
def _read_fastq_files(f, args): """ read fasta files of each sample and generate a seq_obj with the information of each unique sequence in each sample :param f: file containing the path for each fasta file and the name of the sample. Two column format with `tab` as field separator :returns: * ...
[ "def", "_read_fastq_files", "(", "f", ",", "args", ")", ":", "seq_l", "=", "{", "}", "sample_l", "=", "[", "]", "idx", "=", "1", "p", "=", "re", ".", "compile", "(", "\"^[ATCGNU]+$\"", ")", "with", "open", "(", "op", ".", "join", "(", "args", "."...
read fasta files of each sample and generate a seq_obj with the information of each unique sequence in each sample :param f: file containing the path for each fasta file and the name of the sample. Two column format with `tab` as field separator :returns: * :code:`seq_l`: is a list of seq_obj obje...
[ "read", "fasta", "files", "of", "each", "sample", "and", "generate", "a", "seq_obj", "with", "the", "information", "of", "each", "unique", "sequence", "in", "each", "sample" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/prepare_data.py#L80-L135
lpantano/seqcluster
seqcluster/prepare_data.py
_create_matrix_uniq_seq
def _create_matrix_uniq_seq(sample_l, seq_l, maout, out, min_shared): """ create matrix counts for each different sequence in all the fasta files :param sample_l: :code:`list_s` is the output of :code:`_read_fasta_files` :param seq_l: :code:`seq_s` is the output of :code:`_read_fasta_files` :param maou...
python
def _create_matrix_uniq_seq(sample_l, seq_l, maout, out, min_shared): """ create matrix counts for each different sequence in all the fasta files :param sample_l: :code:`list_s` is the output of :code:`_read_fasta_files` :param seq_l: :code:`seq_s` is the output of :code:`_read_fasta_files` :param maou...
[ "def", "_create_matrix_uniq_seq", "(", "sample_l", ",", "seq_l", ",", "maout", ",", "out", ",", "min_shared", ")", ":", "skip", "=", "0", "if", "int", "(", "min_shared", ")", ">", "len", "(", "sample_l", ")", ":", "min_shared", "=", "len", "(", "sample...
create matrix counts for each different sequence in all the fasta files :param sample_l: :code:`list_s` is the output of :code:`_read_fasta_files` :param seq_l: :code:`seq_s` is the output of :code:`_read_fasta_files` :param maout: is a file handler to write the matrix count information :param out: is ...
[ "create", "matrix", "counts", "for", "each", "different", "sequence", "in", "all", "the", "fasta", "files" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/prepare_data.py#L138-L169
lpantano/seqcluster
seqcluster/function/predictions.py
run_coral
def run_coral(clus_obj, out_dir, args): """ Run some CoRaL modules to predict small RNA function """ if not args.bed: raise ValueError("This module needs the bed file output from cluster subcmd.") workdir = op.abspath(op.join(args.out, 'coral')) safe_dirs(workdir) bam_in = op.abspath...
python
def run_coral(clus_obj, out_dir, args): """ Run some CoRaL modules to predict small RNA function """ if not args.bed: raise ValueError("This module needs the bed file output from cluster subcmd.") workdir = op.abspath(op.join(args.out, 'coral')) safe_dirs(workdir) bam_in = op.abspath...
[ "def", "run_coral", "(", "clus_obj", ",", "out_dir", ",", "args", ")", ":", "if", "not", "args", ".", "bed", ":", "raise", "ValueError", "(", "\"This module needs the bed file output from cluster subcmd.\"", ")", "workdir", "=", "op", ".", "abspath", "(", "op", ...
Run some CoRaL modules to predict small RNA function
[ "Run", "some", "CoRaL", "modules", "to", "predict", "small", "RNA", "function" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/predictions.py#L17-L34
lpantano/seqcluster
seqcluster/function/predictions.py
is_tRNA
def is_tRNA(clus_obj, out_dir, args): """ Iterates through cluster precursors to predict sRNA types """ ref = os.path.abspath(args.reference) utils.safe_dirs(out_dir) for nc in clus_obj[0]: c = clus_obj[0][nc] loci = c['loci'] out_fa = "cluster_" + nc if loci[0][3...
python
def is_tRNA(clus_obj, out_dir, args): """ Iterates through cluster precursors to predict sRNA types """ ref = os.path.abspath(args.reference) utils.safe_dirs(out_dir) for nc in clus_obj[0]: c = clus_obj[0][nc] loci = c['loci'] out_fa = "cluster_" + nc if loci[0][3...
[ "def", "is_tRNA", "(", "clus_obj", ",", "out_dir", ",", "args", ")", ":", "ref", "=", "os", ".", "path", ".", "abspath", "(", "args", ".", "reference", ")", "utils", ".", "safe_dirs", "(", "out_dir", ")", "for", "nc", "in", "clus_obj", "[", "0", "]...
Iterates through cluster precursors to predict sRNA types
[ "Iterates", "through", "cluster", "precursors", "to", "predict", "sRNA", "types" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/predictions.py#L37-L63
lpantano/seqcluster
seqcluster/function/predictions.py
_read_tRNA_scan
def _read_tRNA_scan(summary_file): """ Parse output from tRNA_Scan """ score = 0 if os.path.getsize(summary_file) == 0: return 0 with open(summary_file) as in_handle: # header = in_handle.next().strip().split() for line in in_handle: if not line.startswith("--...
python
def _read_tRNA_scan(summary_file): """ Parse output from tRNA_Scan """ score = 0 if os.path.getsize(summary_file) == 0: return 0 with open(summary_file) as in_handle: # header = in_handle.next().strip().split() for line in in_handle: if not line.startswith("--...
[ "def", "_read_tRNA_scan", "(", "summary_file", ")", ":", "score", "=", "0", "if", "os", ".", "path", ".", "getsize", "(", "summary_file", ")", "==", "0", ":", "return", "0", "with", "open", "(", "summary_file", ")", "as", "in_handle", ":", "# header = in...
Parse output from tRNA_Scan
[ "Parse", "output", "from", "tRNA_Scan" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/predictions.py#L66-L79
lpantano/seqcluster
seqcluster/function/predictions.py
_run_tRNA_scan
def _run_tRNA_scan(fasta_file): """ Run tRNA-scan-SE to predict tRNA """ out_file = fasta_file + "_trnascan" se_file = fasta_file + "_second_str" cmd = "tRNAscan-SE -q -o {out_file} -f {se_file} {fasta_file}" run(cmd.format(**locals())) return out_file, se_file
python
def _run_tRNA_scan(fasta_file): """ Run tRNA-scan-SE to predict tRNA """ out_file = fasta_file + "_trnascan" se_file = fasta_file + "_second_str" cmd = "tRNAscan-SE -q -o {out_file} -f {se_file} {fasta_file}" run(cmd.format(**locals())) return out_file, se_file
[ "def", "_run_tRNA_scan", "(", "fasta_file", ")", ":", "out_file", "=", "fasta_file", "+", "\"_trnascan\"", "se_file", "=", "fasta_file", "+", "\"_second_str\"", "cmd", "=", "\"tRNAscan-SE -q -o {out_file} -f {se_file} {fasta_file}\"", "run", "(", "cmd", ".", "format", ...
Run tRNA-scan-SE to predict tRNA
[ "Run", "tRNA", "-", "scan", "-", "SE", "to", "predict", "tRNA" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/predictions.py#L82-L90
lpantano/seqcluster
seqcluster/seqbuster/snps.py
_parse_mut
def _parse_mut(mut): """ Parse mutation field to get position and nts. """ multiplier = 1 if mut.startswith("-"): mut = mut[1:] multiplier = -1 nt = mut.strip('0123456789') pos = int(mut[:-2]) * multiplier return nt, pos
python
def _parse_mut(mut): """ Parse mutation field to get position and nts. """ multiplier = 1 if mut.startswith("-"): mut = mut[1:] multiplier = -1 nt = mut.strip('0123456789') pos = int(mut[:-2]) * multiplier return nt, pos
[ "def", "_parse_mut", "(", "mut", ")", ":", "multiplier", "=", "1", "if", "mut", ".", "startswith", "(", "\"-\"", ")", ":", "mut", "=", "mut", "[", "1", ":", "]", "multiplier", "=", "-", "1", "nt", "=", "mut", ".", "strip", "(", "'0123456789'", ")...
Parse mutation field to get position and nts.
[ "Parse", "mutation", "field", "to", "get", "position", "and", "nts", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/seqbuster/snps.py#L10-L20
lpantano/seqcluster
seqcluster/seqbuster/snps.py
_get_reference_position
def _get_reference_position(isomir): """ Liftover from isomir to reference mature """ mut = isomir.split(":")[1] if mut == "0": return mut nt, pos = _parse_mut(mut) trim5 = isomir.split(":")[-2] off = -1 * len(trim5) if trim5.islower(): off = len(trim5) if trim5 =...
python
def _get_reference_position(isomir): """ Liftover from isomir to reference mature """ mut = isomir.split(":")[1] if mut == "0": return mut nt, pos = _parse_mut(mut) trim5 = isomir.split(":")[-2] off = -1 * len(trim5) if trim5.islower(): off = len(trim5) if trim5 =...
[ "def", "_get_reference_position", "(", "isomir", ")", ":", "mut", "=", "isomir", ".", "split", "(", "\":\"", ")", "[", "1", "]", "if", "mut", "==", "\"0\"", ":", "return", "mut", "nt", ",", "pos", "=", "_parse_mut", "(", "mut", ")", "trim5", "=", "...
Liftover from isomir to reference mature
[ "Liftover", "from", "isomir", "to", "reference", "mature" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/seqbuster/snps.py#L22-L38
lpantano/seqcluster
seqcluster/seqbuster/snps.py
_get_pct
def _get_pct(isomirs, mirna): """ Get pct of variants respect to the reference using reads and different sequences """ pass_pos = [] for isomir in isomirs.iterrows(): mir = isomir[1]["chrom"] mut = isomir[1]["sv"] mut_counts = isomir[1]["counts"] total = mirna.loc...
python
def _get_pct(isomirs, mirna): """ Get pct of variants respect to the reference using reads and different sequences """ pass_pos = [] for isomir in isomirs.iterrows(): mir = isomir[1]["chrom"] mut = isomir[1]["sv"] mut_counts = isomir[1]["counts"] total = mirna.loc...
[ "def", "_get_pct", "(", "isomirs", ",", "mirna", ")", ":", "pass_pos", "=", "[", "]", "for", "isomir", "in", "isomirs", ".", "iterrows", "(", ")", ":", "mir", "=", "isomir", "[", "1", "]", "[", "\"chrom\"", "]", "mut", "=", "isomir", "[", "1", "]...
Get pct of variants respect to the reference using reads and different sequences
[ "Get", "pct", "of", "variants", "respect", "to", "the", "reference", "using", "reads", "and", "different", "sequences" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/seqbuster/snps.py#L40-L56
lpantano/seqcluster
seqcluster/seqbuster/snps.py
_print_header
def _print_header(data): """ Create vcf header to make a valid vcf. """ print("##fileformat=VCFv4.2", file=STDOUT, end="") print("##source=seqbuster2.3", file=STDOUT, end="") print("##reference=mirbase", file=STDOUT, end="") for pos in data: print("##contig=<ID=%s>" % pos["chrom"...
python
def _print_header(data): """ Create vcf header to make a valid vcf. """ print("##fileformat=VCFv4.2", file=STDOUT, end="") print("##source=seqbuster2.3", file=STDOUT, end="") print("##reference=mirbase", file=STDOUT, end="") for pos in data: print("##contig=<ID=%s>" % pos["chrom"...
[ "def", "_print_header", "(", "data", ")", ":", "print", "(", "\"##fileformat=VCFv4.2\"", ",", "file", "=", "STDOUT", ",", "end", "=", "\"\"", ")", "print", "(", "\"##source=seqbuster2.3\"", ",", "file", "=", "STDOUT", ",", "end", "=", "\"\"", ")", "print",...
Create vcf header to make a valid vcf.
[ "Create", "vcf", "header", "to", "make", "a", "valid", "vcf", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/seqbuster/snps.py#L64-L78
lpantano/seqcluster
seqcluster/seqbuster/snps.py
print_vcf
def print_vcf(data): """Print vcf line following rules.""" id_name = "." qual = "." chrom = data['chrom'] pos = data['pre_pos'] nt_ref = data['nt'][1] nt_snp = data['nt'][0] flt = "PASS" info = "ID=%s" % data['mature'] frmt = "GT:NR:NS" gntp = "%s:%s:%s" % (_genotype(data), d...
python
def print_vcf(data): """Print vcf line following rules.""" id_name = "." qual = "." chrom = data['chrom'] pos = data['pre_pos'] nt_ref = data['nt'][1] nt_snp = data['nt'][0] flt = "PASS" info = "ID=%s" % data['mature'] frmt = "GT:NR:NS" gntp = "%s:%s:%s" % (_genotype(data), d...
[ "def", "print_vcf", "(", "data", ")", ":", "id_name", "=", "\".\"", "qual", "=", "\".\"", "chrom", "=", "data", "[", "'chrom'", "]", "pos", "=", "data", "[", "'pre_pos'", "]", "nt_ref", "=", "data", "[", "'nt'", "]", "[", "1", "]", "nt_snp", "=", ...
Print vcf line following rules.
[ "Print", "vcf", "line", "following", "rules", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/seqbuster/snps.py#L80-L92
lpantano/seqcluster
seqcluster/seqbuster/snps.py
liftover
def liftover(pass_pos, matures): """Make position at precursor scale""" fixed_pos = [] _print_header(pass_pos) for pos in pass_pos: mir = pos["mature"] db_pos = matures[pos["chrom"]] mut = _parse_mut(pos["sv"]) print([db_pos[mir], mut, pos["sv"]]) pos['pre_pos'] =...
python
def liftover(pass_pos, matures): """Make position at precursor scale""" fixed_pos = [] _print_header(pass_pos) for pos in pass_pos: mir = pos["mature"] db_pos = matures[pos["chrom"]] mut = _parse_mut(pos["sv"]) print([db_pos[mir], mut, pos["sv"]]) pos['pre_pos'] =...
[ "def", "liftover", "(", "pass_pos", ",", "matures", ")", ":", "fixed_pos", "=", "[", "]", "_print_header", "(", "pass_pos", ")", "for", "pos", "in", "pass_pos", ":", "mir", "=", "pos", "[", "\"mature\"", "]", "db_pos", "=", "matures", "[", "pos", "[", ...
Make position at precursor scale
[ "Make", "position", "at", "precursor", "scale" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/seqbuster/snps.py#L99-L112
lpantano/seqcluster
seqcluster/seqbuster/snps.py
create_vcf
def create_vcf(isomirs, matures, gtf, vcf_file=None): """ Create vcf file of changes for all samples. PASS will be ones with > 3 isomiRs supporting the position and > 30% of reads, otherwise LOW """ global STDOUT isomirs['sv'] = [_get_reference_position(m) for m in isomirs["isomir"]] ...
python
def create_vcf(isomirs, matures, gtf, vcf_file=None): """ Create vcf file of changes for all samples. PASS will be ones with > 3 isomiRs supporting the position and > 30% of reads, otherwise LOW """ global STDOUT isomirs['sv'] = [_get_reference_position(m) for m in isomirs["isomir"]] ...
[ "def", "create_vcf", "(", "isomirs", ",", "matures", ",", "gtf", ",", "vcf_file", "=", "None", ")", ":", "global", "STDOUT", "isomirs", "[", "'sv'", "]", "=", "[", "_get_reference_position", "(", "m", ")", "for", "m", "in", "isomirs", "[", "\"isomir\"", ...
Create vcf file of changes for all samples. PASS will be ones with > 3 isomiRs supporting the position and > 30% of reads, otherwise LOW
[ "Create", "vcf", "file", "of", "changes", "for", "all", "samples", ".", "PASS", "will", "be", "ones", "with", ">", "3", "isomiRs", "supporting", "the", "position", "and", ">", "30%", "of", "reads", "otherwise", "LOW" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/seqbuster/snps.py#L114-L135
lpantano/seqcluster
seqcluster/seqbuster/snps.py
liftover_to_genome
def liftover_to_genome(pass_pos, gtf): """Liftover from precursor to genome""" fixed_pos = [] for pos in pass_pos: if pos["chrom"] not in gtf: continue db_pos = gtf[pos["chrom"]][0] mut = _parse_mut(pos["sv"]) print([db_pos, pos]) if db_pos[3] == "+": ...
python
def liftover_to_genome(pass_pos, gtf): """Liftover from precursor to genome""" fixed_pos = [] for pos in pass_pos: if pos["chrom"] not in gtf: continue db_pos = gtf[pos["chrom"]][0] mut = _parse_mut(pos["sv"]) print([db_pos, pos]) if db_pos[3] == "+": ...
[ "def", "liftover_to_genome", "(", "pass_pos", ",", "gtf", ")", ":", "fixed_pos", "=", "[", "]", "for", "pos", "in", "pass_pos", ":", "if", "pos", "[", "\"chrom\"", "]", "not", "in", "gtf", ":", "continue", "db_pos", "=", "gtf", "[", "pos", "[", "\"ch...
Liftover from precursor to genome
[ "Liftover", "from", "precursor", "to", "genome" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/seqbuster/snps.py#L137-L157
lpantano/seqcluster
seqcluster/detect/metacluster.py
_get_seqs_from_cluster
def _get_seqs_from_cluster(seqs, seen): """ Returns the sequences that are already part of the cluster :param seqs: list of sequences ids :param clus_id: dict of sequences ids that are part of a cluster :returns: * :code:`already_in`list of cluster id that contained some of the sequences ...
python
def _get_seqs_from_cluster(seqs, seen): """ Returns the sequences that are already part of the cluster :param seqs: list of sequences ids :param clus_id: dict of sequences ids that are part of a cluster :returns: * :code:`already_in`list of cluster id that contained some of the sequences ...
[ "def", "_get_seqs_from_cluster", "(", "seqs", ",", "seen", ")", ":", "already_in", "=", "set", "(", ")", "not_in", "=", "[", "]", "already_in", "=", "map", "(", "seen", ".", "get", ",", "seqs", ")", "# if isinstance(already_in, list):", "already_in", "=", ...
Returns the sequences that are already part of the cluster :param seqs: list of sequences ids :param clus_id: dict of sequences ids that are part of a cluster :returns: * :code:`already_in`list of cluster id that contained some of the sequences * :code:`not_in`list of sequences that don't ...
[ "Returns", "the", "sequences", "that", "are", "already", "part", "of", "the", "cluster" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L28-L51
lpantano/seqcluster
seqcluster/detect/metacluster.py
reduceloci
def reduceloci(clus_obj, path): """reduce number of loci a cluster has :param clus_obj: cluster object object :param path: output path """ filtered = {} n_cluster = 0 large = 0 current = clus_obj.clusid logger.info("Number of loci: %s" % len(clus_obj.loci.keys())) bar = Progress...
python
def reduceloci(clus_obj, path): """reduce number of loci a cluster has :param clus_obj: cluster object object :param path: output path """ filtered = {} n_cluster = 0 large = 0 current = clus_obj.clusid logger.info("Number of loci: %s" % len(clus_obj.loci.keys())) bar = Progress...
[ "def", "reduceloci", "(", "clus_obj", ",", "path", ")", ":", "filtered", "=", "{", "}", "n_cluster", "=", "0", "large", "=", "0", "current", "=", "clus_obj", ".", "clusid", "logger", ".", "info", "(", "\"Number of loci: %s\"", "%", "len", "(", "clus_obj"...
reduce number of loci a cluster has :param clus_obj: cluster object object :param path: output path
[ "reduce", "number", "of", "loci", "a", "cluster", "has", ":", "param", "clus_obj", ":", "cluster", "object", "object", ":", "param", "path", ":", "output", "path" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L54-L90
lpantano/seqcluster
seqcluster/detect/metacluster.py
_write_cluster
def _write_cluster(metacluster, cluster, loci, idx, path): """ For complex meta-clusters, write all the loci for further debug """ out_file = op.join(path, 'log', str(idx) + '.bed') with utils.safe_run(out_file): with open(out_file, 'w') as out_handle: for idc in metacluster: ...
python
def _write_cluster(metacluster, cluster, loci, idx, path): """ For complex meta-clusters, write all the loci for further debug """ out_file = op.join(path, 'log', str(idx) + '.bed') with utils.safe_run(out_file): with open(out_file, 'w') as out_handle: for idc in metacluster: ...
[ "def", "_write_cluster", "(", "metacluster", ",", "cluster", ",", "loci", ",", "idx", ",", "path", ")", ":", "out_file", "=", "op", ".", "join", "(", "path", ",", "'log'", ",", "str", "(", "idx", ")", "+", "'.bed'", ")", "with", "utils", ".", "safe...
For complex meta-clusters, write all the loci for further debug
[ "For", "complex", "meta", "-", "clusters", "write", "all", "the", "loci", "for", "further", "debug" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L93-L103
lpantano/seqcluster
seqcluster/detect/metacluster.py
_iter_loci
def _iter_loci(meta, clusters, s2p, filtered, n_cluster): """ Go through all locus and decide if they are part of the same TU or not. :param idx: int cluster id :param s2p: dict with [loci].coverage[start] = # of sequences there :param filtered: dict with clusters object :param n_cluster: i...
python
def _iter_loci(meta, clusters, s2p, filtered, n_cluster): """ Go through all locus and decide if they are part of the same TU or not. :param idx: int cluster id :param s2p: dict with [loci].coverage[start] = # of sequences there :param filtered: dict with clusters object :param n_cluster: i...
[ "def", "_iter_loci", "(", "meta", ",", "clusters", ",", "s2p", ",", "filtered", ",", "n_cluster", ")", ":", "global", "CONFLICT", "loci", "=", "dict", "(", "zip", "(", "meta", ",", "[", "clusters", "[", "idc", "]", "for", "idc", "in", "meta", "]", ...
Go through all locus and decide if they are part of the same TU or not. :param idx: int cluster id :param s2p: dict with [loci].coverage[start] = # of sequences there :param filtered: dict with clusters object :param n_cluster: int cluster id :return: * filtered: dict of cluster object...
[ "Go", "through", "all", "locus", "and", "decide", "if", "they", "are", "part", "of", "the", "same", "TU", "or", "not", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L120-L177
lpantano/seqcluster
seqcluster/detect/metacluster.py
_convert_to_clusters
def _convert_to_clusters(c): """Return 1 cluster per loci""" new_dict = {} n_cluster = 0 logger.debug("_convert_to_cluster: loci %s" % c.loci2seq.keys()) for idl in c.loci2seq: n_cluster += 1 new_c = cluster(n_cluster) #new_c.id_prev = c.id new_c.loci2seq[idl] = c.loc...
python
def _convert_to_clusters(c): """Return 1 cluster per loci""" new_dict = {} n_cluster = 0 logger.debug("_convert_to_cluster: loci %s" % c.loci2seq.keys()) for idl in c.loci2seq: n_cluster += 1 new_c = cluster(n_cluster) #new_c.id_prev = c.id new_c.loci2seq[idl] = c.loc...
[ "def", "_convert_to_clusters", "(", "c", ")", ":", "new_dict", "=", "{", "}", "n_cluster", "=", "0", "logger", ".", "debug", "(", "\"_convert_to_cluster: loci %s\"", "%", "c", ".", "loci2seq", ".", "keys", "(", ")", ")", "for", "idl", "in", "c", ".", "...
Return 1 cluster per loci
[ "Return", "1", "cluster", "per", "loci" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L187-L199
lpantano/seqcluster
seqcluster/detect/metacluster.py
_calculate_similarity
def _calculate_similarity(c): """Get a similarity matrix of % of shared sequence :param c: cluster object :return ma: similarity matrix """ ma = {} for idc in c: set1 = _get_seqs(c[idc]) [ma.update({(idc, idc2): _common(set1, _get_seqs(c[idc2]), idc, idc2)}) for idc2 in c if id...
python
def _calculate_similarity(c): """Get a similarity matrix of % of shared sequence :param c: cluster object :return ma: similarity matrix """ ma = {} for idc in c: set1 = _get_seqs(c[idc]) [ma.update({(idc, idc2): _common(set1, _get_seqs(c[idc2]), idc, idc2)}) for idc2 in c if id...
[ "def", "_calculate_similarity", "(", "c", ")", ":", "ma", "=", "{", "}", "for", "idc", "in", "c", ":", "set1", "=", "_get_seqs", "(", "c", "[", "idc", "]", ")", "[", "ma", ".", "update", "(", "{", "(", "idc", ",", "idc2", ")", ":", "_common", ...
Get a similarity matrix of % of shared sequence :param c: cluster object :return ma: similarity matrix
[ "Get", "a", "similarity", "matrix", "of", "%", "of", "shared", "sequence" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L202-L214
lpantano/seqcluster
seqcluster/detect/metacluster.py
_get_seqs
def _get_seqs(list_idl): """get all sequences in a cluster knowing loci""" seqs = set() for idl in list_idl.loci2seq: # logger.debug("_get_seqs_: loci %s" % idl) [seqs.add(s) for s in list_idl.loci2seq[idl]] # logger.debug("_get_seqs_: %s" % len(seqs)) return seqs
python
def _get_seqs(list_idl): """get all sequences in a cluster knowing loci""" seqs = set() for idl in list_idl.loci2seq: # logger.debug("_get_seqs_: loci %s" % idl) [seqs.add(s) for s in list_idl.loci2seq[idl]] # logger.debug("_get_seqs_: %s" % len(seqs)) return seqs
[ "def", "_get_seqs", "(", "list_idl", ")", ":", "seqs", "=", "set", "(", ")", "for", "idl", "in", "list_idl", ".", "loci2seq", ":", "# logger.debug(\"_get_seqs_: loci %s\" % idl)", "[", "seqs", ".", "add", "(", "s", ")", "for", "s", "in", "list_idl", ".", ...
get all sequences in a cluster knowing loci
[ "get", "all", "sequences", "in", "a", "cluster", "knowing", "loci" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L217-L224
lpantano/seqcluster
seqcluster/detect/metacluster.py
_common
def _common(s1, s2, i1, i2): """calculate the common % percentage of sequences""" c = len(set(s1).intersection(s2)) t = min(len(s1), len(s2)) pct = 1.0 * c / t * t is_gt = up_threshold(pct, t * 1.0, parameters.similar) logger.debug("_common: pct %s of clusters:%s %s = %s" % (1.0 * c / t, i1, i2,...
python
def _common(s1, s2, i1, i2): """calculate the common % percentage of sequences""" c = len(set(s1).intersection(s2)) t = min(len(s1), len(s2)) pct = 1.0 * c / t * t is_gt = up_threshold(pct, t * 1.0, parameters.similar) logger.debug("_common: pct %s of clusters:%s %s = %s" % (1.0 * c / t, i1, i2,...
[ "def", "_common", "(", "s1", ",", "s2", ",", "i1", ",", "i2", ")", ":", "c", "=", "len", "(", "set", "(", "s1", ")", ".", "intersection", "(", "s2", ")", ")", "t", "=", "min", "(", "len", "(", "s1", ")", ",", "len", "(", "s2", ")", ")", ...
calculate the common % percentage of sequences
[ "calculate", "the", "common", "%", "percentage", "of", "sequences" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L227-L236
lpantano/seqcluster
seqcluster/detect/metacluster.py
_is_consistent
def _is_consistent(pairs, common, clus_seen, loci_similarity): """ Check if loci shared that match sequences with all clusters seen until now. """ all_true1 = all([all([common and loci_similarity[(p, c)] > parameters.similar for p in pairs if (p, c) in loci_similarity]) for c in clus_seen]) all...
python
def _is_consistent(pairs, common, clus_seen, loci_similarity): """ Check if loci shared that match sequences with all clusters seen until now. """ all_true1 = all([all([common and loci_similarity[(p, c)] > parameters.similar for p in pairs if (p, c) in loci_similarity]) for c in clus_seen]) all...
[ "def", "_is_consistent", "(", "pairs", ",", "common", ",", "clus_seen", ",", "loci_similarity", ")", ":", "all_true1", "=", "all", "(", "[", "all", "(", "[", "common", "and", "loci_similarity", "[", "(", "p", ",", "c", ")", "]", ">", "parameters", ".",...
Check if loci shared that match sequences with all clusters seen until now.
[ "Check", "if", "loci", "shared", "that", "match", "sequences", "with", "all", "clusters", "seen", "until", "now", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L239-L246
lpantano/seqcluster
seqcluster/detect/metacluster.py
_merge_similar
def _merge_similar(loci, loci_similarity): """ Internal function to reduce loci complexity :param loci: class cluster :param locilen_sorted: list of loci sorted by size :return c: updated class cluster """ n_cluster = 0 internal_cluster = {} clus_seen = {} loci_sorted = so...
python
def _merge_similar(loci, loci_similarity): """ Internal function to reduce loci complexity :param loci: class cluster :param locilen_sorted: list of loci sorted by size :return c: updated class cluster """ n_cluster = 0 internal_cluster = {} clus_seen = {} loci_sorted = so...
[ "def", "_merge_similar", "(", "loci", ",", "loci_similarity", ")", ":", "n_cluster", "=", "0", "internal_cluster", "=", "{", "}", "clus_seen", "=", "{", "}", "loci_sorted", "=", "sorted", "(", "loci_similarity", ".", "iteritems", "(", ")", ",", "key", "=",...
Internal function to reduce loci complexity :param loci: class cluster :param locilen_sorted: list of loci sorted by size :return c: updated class cluster
[ "Internal", "function", "to", "reduce", "loci", "complexity" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L249-L297
lpantano/seqcluster
seqcluster/detect/metacluster.py
_merge_cluster
def _merge_cluster(old, new): """merge one cluster to another""" logger.debug("_merge_cluster: %s to %s" % (old.id, new.id)) logger.debug("_merge_cluster: add idls %s" % old.loci2seq.keys()) for idl in old.loci2seq: # if idl in new.loci2seq: # new.loci2seq[idl] = list(set(new.loci2seq...
python
def _merge_cluster(old, new): """merge one cluster to another""" logger.debug("_merge_cluster: %s to %s" % (old.id, new.id)) logger.debug("_merge_cluster: add idls %s" % old.loci2seq.keys()) for idl in old.loci2seq: # if idl in new.loci2seq: # new.loci2seq[idl] = list(set(new.loci2seq...
[ "def", "_merge_cluster", "(", "old", ",", "new", ")", ":", "logger", ".", "debug", "(", "\"_merge_cluster: %s to %s\"", "%", "(", "old", ".", "id", ",", "new", ".", "id", ")", ")", "logger", ".", "debug", "(", "\"_merge_cluster: add idls %s\"", "%", "old",...
merge one cluster to another
[ "merge", "one", "cluster", "to", "another" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L300-L309
lpantano/seqcluster
seqcluster/detect/metacluster.py
_solve_conflict
def _solve_conflict(list_c, s2p, n_cluster): """ Make sure sequences are counts once. Resolve by most-vote or exclussion :params list_c: dict of objects cluster :param s2p: dict of [loci].coverage = # num of seqs :param n_cluster: number of clusters return dict: new set of clusters """...
python
def _solve_conflict(list_c, s2p, n_cluster): """ Make sure sequences are counts once. Resolve by most-vote or exclussion :params list_c: dict of objects cluster :param s2p: dict of [loci].coverage = # num of seqs :param n_cluster: number of clusters return dict: new set of clusters """...
[ "def", "_solve_conflict", "(", "list_c", ",", "s2p", ",", "n_cluster", ")", ":", "logger", ".", "debug", "(", "\"_solve_conflict: count once\"", ")", "if", "parameters", ".", "decision_cluster", "==", "\"bayes\"", ":", "return", "decide_by_bayes", "(", "list_c", ...
Make sure sequences are counts once. Resolve by most-vote or exclussion :params list_c: dict of objects cluster :param s2p: dict of [loci].coverage = # num of seqs :param n_cluster: number of clusters return dict: new set of clusters
[ "Make", "sure", "sequences", "are", "counts", "once", ".", "Resolve", "by", "most", "-", "vote", "or", "exclussion" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L312-L345
lpantano/seqcluster
seqcluster/detect/metacluster.py
_split_cluster
def _split_cluster(c, pairs, n): """split cluster by exclussion""" old = c[p[0]] new = c[p[1]] new_c = cluster(n) common = set(_get_seqs(old)).intersection(_get_seqs(new)) for idl in old.loci2seq: in_common = list(set(common).intersection(old.loci2seq[idl])) if len(in_common) > 0...
python
def _split_cluster(c, pairs, n): """split cluster by exclussion""" old = c[p[0]] new = c[p[1]] new_c = cluster(n) common = set(_get_seqs(old)).intersection(_get_seqs(new)) for idl in old.loci2seq: in_common = list(set(common).intersection(old.loci2seq[idl])) if len(in_common) > 0...
[ "def", "_split_cluster", "(", "c", ",", "pairs", ",", "n", ")", ":", "old", "=", "c", "[", "p", "[", "0", "]", "]", "new", "=", "c", "[", "p", "[", "1", "]", "]", "new_c", "=", "cluster", "(", "n", ")", "common", "=", "set", "(", "_get_seqs...
split cluster by exclussion
[ "split", "cluster", "by", "exclussion" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L348-L375
lpantano/seqcluster
seqcluster/detect/metacluster.py
_split_cluster_by_most_vote
def _split_cluster_by_most_vote(c, p): """split cluster by most-vote strategy""" old, new = c[p[0]], c[p[1]] old_size = _get_seqs(old) new_size = _get_seqs(new) logger.debug("_most_vote: size of %s with %s - %s with %s" % (old.id, len(old_size), new.id, len(new_size))) if len(old_size) > len(new...
python
def _split_cluster_by_most_vote(c, p): """split cluster by most-vote strategy""" old, new = c[p[0]], c[p[1]] old_size = _get_seqs(old) new_size = _get_seqs(new) logger.debug("_most_vote: size of %s with %s - %s with %s" % (old.id, len(old_size), new.id, len(new_size))) if len(old_size) > len(new...
[ "def", "_split_cluster_by_most_vote", "(", "c", ",", "p", ")", ":", "old", ",", "new", "=", "c", "[", "p", "[", "0", "]", "]", ",", "c", "[", "p", "[", "1", "]", "]", "old_size", "=", "_get_seqs", "(", "old", ")", "new_size", "=", "_get_seqs", ...
split cluster by most-vote strategy
[ "split", "cluster", "by", "most", "-", "vote", "strategy" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L378-L399
lpantano/seqcluster
seqcluster/detect/metacluster.py
_clean_cluster
def _clean_cluster(list_c): """ Remove cluster with less than 10 sequences and loci with size smaller than 60% """ global REMOVED init = len(list_c) list_c = {k: v for k, v in list_c.iteritems() if len(_get_seqs(v)) > parameters.min_seqs} logger.debug("_clean_cluster: number of clusters ...
python
def _clean_cluster(list_c): """ Remove cluster with less than 10 sequences and loci with size smaller than 60% """ global REMOVED init = len(list_c) list_c = {k: v for k, v in list_c.iteritems() if len(_get_seqs(v)) > parameters.min_seqs} logger.debug("_clean_cluster: number of clusters ...
[ "def", "_clean_cluster", "(", "list_c", ")", ":", "global", "REMOVED", "init", "=", "len", "(", "list_c", ")", "list_c", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "list_c", ".", "iteritems", "(", ")", "if", "len", "(", "_get_seqs", "(", ...
Remove cluster with less than 10 sequences and loci with size smaller than 60%
[ "Remove", "cluster", "with", "less", "than", "10", "sequences", "and", "loci", "with", "size", "smaller", "than", "60%" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L414-L426
lpantano/seqcluster
seqcluster/detect/metacluster.py
_select_loci
def _select_loci(c): """Select only loci with most abundant sequences""" loci_len = {k: len(v) for k, v in c.loci2seq.iteritems()} logger.debug("_select_loci: number of loci %s" % len(c.loci2seq.keys())) loci_len_sort = sorted(loci_len.iteritems(), key=operator.itemgetter(1), reverse=True) max_size ...
python
def _select_loci(c): """Select only loci with most abundant sequences""" loci_len = {k: len(v) for k, v in c.loci2seq.iteritems()} logger.debug("_select_loci: number of loci %s" % len(c.loci2seq.keys())) loci_len_sort = sorted(loci_len.iteritems(), key=operator.itemgetter(1), reverse=True) max_size ...
[ "def", "_select_loci", "(", "c", ")", ":", "loci_len", "=", "{", "k", ":", "len", "(", "v", ")", "for", "k", ",", "v", "in", "c", ".", "loci2seq", ".", "iteritems", "(", ")", "}", "logger", ".", "debug", "(", "\"_select_loci: number of loci %s\"", "%...
Select only loci with most abundant sequences
[ "Select", "only", "loci", "with", "most", "abundant", "sequences" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L429-L441
lpantano/seqcluster
seqcluster/detect/metacluster.py
_solve_loci_deprecated
def _solve_loci_deprecated(c, locilen_sorted, seen_seqs, filtered, maxseq, n_cluster): """internal function to reduce loci complexity The function will read the all loci in a cluster of sequences and will determine if all loci are part of the same transcriptional unit(TU) by most-vote locus or by e...
python
def _solve_loci_deprecated(c, locilen_sorted, seen_seqs, filtered, maxseq, n_cluster): """internal function to reduce loci complexity The function will read the all loci in a cluster of sequences and will determine if all loci are part of the same transcriptional unit(TU) by most-vote locus or by e...
[ "def", "_solve_loci_deprecated", "(", "c", ",", "locilen_sorted", ",", "seen_seqs", ",", "filtered", ",", "maxseq", ",", "n_cluster", ")", ":", "first_run", "=", "0", "seen_seqs", "=", "list", "(", ")", "n_cluster", "+=", "1", "logger", ".", "debug", "(", ...
internal function to reduce loci complexity The function will read the all loci in a cluster of sequences and will determine if all loci are part of the same transcriptional unit(TU) by most-vote locus or by exclusion of common sequence that are the minority of two loci. :param c: class cluste...
[ "internal", "function", "to", "reduce", "loci", "complexity" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/metacluster.py#L454-L499
lpantano/seqcluster
seqcluster/db/__init__.py
_get_description
def _get_description(string): """ Parse annotation to get nice description """ ann = set() if not string: return "This cluster is inter-genic." for item in string: for db in item: ann = ann.union(set(item[db])) return "annotated as: %s ..." % ",".join(list(ann)[:3...
python
def _get_description(string): """ Parse annotation to get nice description """ ann = set() if not string: return "This cluster is inter-genic." for item in string: for db in item: ann = ann.union(set(item[db])) return "annotated as: %s ..." % ",".join(list(ann)[:3...
[ "def", "_get_description", "(", "string", ")", ":", "ann", "=", "set", "(", ")", "if", "not", "string", ":", "return", "\"This cluster is inter-genic.\"", "for", "item", "in", "string", ":", "for", "db", "in", "item", ":", "ann", "=", "ann", ".", "union"...
Parse annotation to get nice description
[ "Parse", "annotation", "to", "get", "nice", "description" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/db/__init__.py#L20-L30
lpantano/seqcluster
seqcluster/db/__init__.py
_set_format
def _set_format(profile): """ Prepare dict to list of y values with same x """ x = set() for sample in profile: x = x.union(set(profile[sample].keys())) if not x: return '' end, start = max(x), min(x) x = range(start, end, 4) scaled_profile = defaultdict(list) for...
python
def _set_format(profile): """ Prepare dict to list of y values with same x """ x = set() for sample in profile: x = x.union(set(profile[sample].keys())) if not x: return '' end, start = max(x), min(x) x = range(start, end, 4) scaled_profile = defaultdict(list) for...
[ "def", "_set_format", "(", "profile", ")", ":", "x", "=", "set", "(", ")", "for", "sample", "in", "profile", ":", "x", "=", "x", ".", "union", "(", "set", "(", "profile", "[", "sample", "]", ".", "keys", "(", ")", ")", ")", "if", "not", "x", ...
Prepare dict to list of y values with same x
[ "Prepare", "dict", "to", "list", "of", "y", "values", "with", "same", "x" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/db/__init__.py#L57-L76
lpantano/seqcluster
seqcluster/db/__init__.py
_insert_data
def _insert_data(con, data): """ insert line for each cluster """ with con: cur = con.cursor() cur.execute("DROP TABLE IF EXISTS clusters;") cur.execute("CREATE TABLE clusters(Id INT, Description TEXT, Locus TEXT, Annotation TEXT, Sequences TEXT, Profile TXT, Precursor TXT)") ...
python
def _insert_data(con, data): """ insert line for each cluster """ with con: cur = con.cursor() cur.execute("DROP TABLE IF EXISTS clusters;") cur.execute("CREATE TABLE clusters(Id INT, Description TEXT, Locus TEXT, Annotation TEXT, Sequences TEXT, Profile TXT, Precursor TXT)") ...
[ "def", "_insert_data", "(", "con", ",", "data", ")", ":", "with", "con", ":", "cur", "=", "con", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "\"DROP TABLE IF EXISTS clusters;\"", ")", "cur", ".", "execute", "(", "\"CREATE TABLE clusters(Id INT, Descri...
insert line for each cluster
[ "insert", "line", "for", "each", "cluster" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/db/__init__.py#L78-L96
lpantano/seqcluster
seqcluster/libs/inputs.py
parse_align_file
def parse_align_file(file_in): """ Parse sam files with aligned sequences """ loc_id = 1 bedfile_clusters = "" bamfile = pybedtools.BedTool(file_in) bed = pybedtools.BedTool.bam_to_bed(bamfile) for c, start, end, name, q, strand in bed: loc_id += 1 bedfile_clusters += "%s...
python
def parse_align_file(file_in): """ Parse sam files with aligned sequences """ loc_id = 1 bedfile_clusters = "" bamfile = pybedtools.BedTool(file_in) bed = pybedtools.BedTool.bam_to_bed(bamfile) for c, start, end, name, q, strand in bed: loc_id += 1 bedfile_clusters += "%s...
[ "def", "parse_align_file", "(", "file_in", ")", ":", "loc_id", "=", "1", "bedfile_clusters", "=", "\"\"", "bamfile", "=", "pybedtools", ".", "BedTool", "(", "file_in", ")", "bed", "=", "pybedtools", ".", "BedTool", ".", "bam_to_bed", "(", "bamfile", ")", "...
Parse sam files with aligned sequences
[ "Parse", "sam", "files", "with", "aligned", "sequences" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/inputs.py#L12-L24
lpantano/seqcluster
seqcluster/libs/inputs.py
parse_ma_file
def parse_ma_file(seq_obj, in_file): """ read seqs.ma file and create dict with sequence object """ name = "" index = 1 total = defaultdict(int) with open(in_file) as handle_in: line = handle_in.readline().strip() cols = line.split("\t") samples = cols[2:] ...
python
def parse_ma_file(seq_obj, in_file): """ read seqs.ma file and create dict with sequence object """ name = "" index = 1 total = defaultdict(int) with open(in_file) as handle_in: line = handle_in.readline().strip() cols = line.split("\t") samples = cols[2:] ...
[ "def", "parse_ma_file", "(", "seq_obj", ",", "in_file", ")", ":", "name", "=", "\"\"", "index", "=", "1", "total", "=", "defaultdict", "(", "int", ")", "with", "open", "(", "in_file", ")", "as", "handle_in", ":", "line", "=", "handle_in", ".", "readlin...
read seqs.ma file and create dict with sequence object
[ "read", "seqs", ".", "ma", "file", "and", "create", "dict", "with", "sequence", "object" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/inputs.py#L27-L55
lpantano/seqcluster
seqcluster/libs/annotation.py
read_gtf_line
def read_gtf_line(cols, field="name"): """parse gtf line to get class/name information""" field = field.lower() try: group = cols[2] attrs = cols[8].split(";") name = [attr.strip().split(" ")[1] for attr in attrs if attr.strip().split(" ")[0].lower().endswith(field)] if not n...
python
def read_gtf_line(cols, field="name"): """parse gtf line to get class/name information""" field = field.lower() try: group = cols[2] attrs = cols[8].split(";") name = [attr.strip().split(" ")[1] for attr in attrs if attr.strip().split(" ")[0].lower().endswith(field)] if not n...
[ "def", "read_gtf_line", "(", "cols", ",", "field", "=", "\"name\"", ")", ":", "field", "=", "field", ".", "lower", "(", ")", "try", ":", "group", "=", "cols", "[", "2", "]", "attrs", "=", "cols", "[", "8", "]", ".", "split", "(", "\";\"", ")", ...
parse gtf line to get class/name information
[ "parse", "gtf", "line", "to", "get", "class", "/", "name", "information" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/annotation.py#L9-L36
lpantano/seqcluster
seqcluster/libs/annotation.py
_position_in_feature
def _position_in_feature(pos_a, pos_b): """return distance to 3' and 5' end of the feature""" strd = "-" if pos_a[2] in pos_b[2]: strd = "+" if pos_a[2] in "+" and pos_b[2] in "+": lento5 = pos_a[0] - pos_b[1] + 1 lento3 = pos_a[1] - pos_b[1] + 1 if pos_a[2] in "+" and pos_b[...
python
def _position_in_feature(pos_a, pos_b): """return distance to 3' and 5' end of the feature""" strd = "-" if pos_a[2] in pos_b[2]: strd = "+" if pos_a[2] in "+" and pos_b[2] in "+": lento5 = pos_a[0] - pos_b[1] + 1 lento3 = pos_a[1] - pos_b[1] + 1 if pos_a[2] in "+" and pos_b[...
[ "def", "_position_in_feature", "(", "pos_a", ",", "pos_b", ")", ":", "strd", "=", "\"-\"", "if", "pos_a", "[", "2", "]", "in", "pos_b", "[", "2", "]", ":", "strd", "=", "\"+\"", "if", "pos_a", "[", "2", "]", "in", "\"+\"", "and", "pos_b", "[", "2...
return distance to 3' and 5' end of the feature
[ "return", "distance", "to", "3", "and", "5", "end", "of", "the", "feature" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/annotation.py#L39-L59
lpantano/seqcluster
seqcluster/libs/annotation.py
anncluster
def anncluster(c, clus_obj, db, type_ann, feature_id="name"): """intersect transcription position with annotation files""" id_sa, id_ea, id_id, id_idl, id_sta = 1, 2, 3, 4, 5 if type_ann == "bed": id_sb = 7 id_eb = 8 id_stb = 11 id_tag = 9 ida = 0 clus_id = clus_obj.c...
python
def anncluster(c, clus_obj, db, type_ann, feature_id="name"): """intersect transcription position with annotation files""" id_sa, id_ea, id_id, id_idl, id_sta = 1, 2, 3, 4, 5 if type_ann == "bed": id_sb = 7 id_eb = 8 id_stb = 11 id_tag = 9 ida = 0 clus_id = clus_obj.c...
[ "def", "anncluster", "(", "c", ",", "clus_obj", ",", "db", ",", "type_ann", ",", "feature_id", "=", "\"name\"", ")", ":", "id_sa", ",", "id_ea", ",", "id_id", ",", "id_idl", ",", "id_sta", "=", "1", ",", "2", ",", "3", ",", "4", ",", "5", "if", ...
intersect transcription position with annotation files
[ "intersect", "transcription", "position", "with", "annotation", "files" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/annotation.py#L62-L104
lpantano/seqcluster
seqcluster/detect/cluster.py
detect_complexity
def detect_complexity(bam_in, genome, out): """ genome coverage of small RNA """ if not genome: logger.info("No genome given. skipping.") return None out_file = op.join(out, op.basename(bam_in) + "_cov.tsv") if file_exists(out_file): return None fai = genome + ".fai" ...
python
def detect_complexity(bam_in, genome, out): """ genome coverage of small RNA """ if not genome: logger.info("No genome given. skipping.") return None out_file = op.join(out, op.basename(bam_in) + "_cov.tsv") if file_exists(out_file): return None fai = genome + ".fai" ...
[ "def", "detect_complexity", "(", "bam_in", ",", "genome", ",", "out", ")", ":", "if", "not", "genome", ":", "logger", ".", "info", "(", "\"No genome given. skipping.\"", ")", "return", "None", "out_file", "=", "op", ".", "join", "(", "out", ",", "op", "....
genome coverage of small RNA
[ "genome", "coverage", "of", "small", "RNA" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/cluster.py#L19-L36
lpantano/seqcluster
seqcluster/detect/cluster.py
clean_bam_file
def clean_bam_file(bam_in, mask=None): """ Remove from alignment reads with low counts and highly # of hits """ seq_obj = defaultdict(int) if mask: mask_file = op.splitext(bam_in)[0] + "_mask.bam" if not file_exists(mask_file): pybedtools.BedTool(bam_file).intersect(b=mas...
python
def clean_bam_file(bam_in, mask=None): """ Remove from alignment reads with low counts and highly # of hits """ seq_obj = defaultdict(int) if mask: mask_file = op.splitext(bam_in)[0] + "_mask.bam" if not file_exists(mask_file): pybedtools.BedTool(bam_file).intersect(b=mas...
[ "def", "clean_bam_file", "(", "bam_in", ",", "mask", "=", "None", ")", ":", "seq_obj", "=", "defaultdict", "(", "int", ")", "if", "mask", ":", "mask_file", "=", "op", ".", "splitext", "(", "bam_in", ")", "[", "0", "]", "+", "\"_mask.bam\"", "if", "no...
Remove from alignment reads with low counts and highly # of hits
[ "Remove", "from", "alignment", "reads", "with", "low", "counts", "and", "highly", "#", "of", "hits" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/cluster.py#L38-L71
lpantano/seqcluster
seqcluster/detect/cluster.py
detect_clusters
def detect_clusters(c, current_seq, MIN_SEQ, non_un_gl=False): """ Parse the merge file of sequences position to create clusters that will have all sequences that shared any position on the genome :param c: file from bedtools with merge sequence positions :param current_seq: list of sequences :...
python
def detect_clusters(c, current_seq, MIN_SEQ, non_un_gl=False): """ Parse the merge file of sequences position to create clusters that will have all sequences that shared any position on the genome :param c: file from bedtools with merge sequence positions :param current_seq: list of sequences :...
[ "def", "detect_clusters", "(", "c", ",", "current_seq", ",", "MIN_SEQ", ",", "non_un_gl", "=", "False", ")", ":", "current_loci", "=", "{", "}", "current_clus", "=", "{", "}", "# sequence2clusters = [set()] * (max(current_seq.keys()) + 2)", "sequence2clusters", "=", ...
Parse the merge file of sequences position to create clusters that will have all sequences that shared any position on the genome :param c: file from bedtools with merge sequence positions :param current_seq: list of sequences :param MIN_SEQ: int cutoff to keep the cluster or not. 10 as default :r...
[ "Parse", "the", "merge", "file", "of", "sequences", "position", "to", "create", "clusters", "that", "will", "have", "all", "sequences", "that", "shared", "any", "position", "on", "the", "genome" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/cluster.py#L73-L133
lpantano/seqcluster
seqcluster/detect/cluster.py
_find_metaclusters
def _find_metaclusters(clus_obj, sequence2clusters, current_seq, min_seqs): """ Mask under same id all clusters that share sequences :param clus_obj: cluster object coming from detect_cluster :param min_seqs: int cutoff to keep the cluster or not. 10 as default :return: updated clus_obj and dict wi...
python
def _find_metaclusters(clus_obj, sequence2clusters, current_seq, min_seqs): """ Mask under same id all clusters that share sequences :param clus_obj: cluster object coming from detect_cluster :param min_seqs: int cutoff to keep the cluster or not. 10 as default :return: updated clus_obj and dict wi...
[ "def", "_find_metaclusters", "(", "clus_obj", ",", "sequence2clusters", ",", "current_seq", ",", "min_seqs", ")", ":", "seen", "=", "defaultdict", "(", "int", ")", "metacluster", "=", "defaultdict", "(", "set", ")", "c_index", "=", "len", "(", "sequence2cluste...
Mask under same id all clusters that share sequences :param clus_obj: cluster object coming from detect_cluster :param min_seqs: int cutoff to keep the cluster or not. 10 as default :return: updated clus_obj and dict with seq_id: cluster_id
[ "Mask", "under", "same", "id", "all", "clusters", "that", "share", "sequences", ":", "param", "clus_obj", ":", "cluster", "object", "coming", "from", "detect_cluster", ":", "param", "min_seqs", ":", "int", "cutoff", "to", "keep", "the", "cluster", "or", "not...
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/cluster.py#L142-L179
lpantano/seqcluster
seqcluster/detect/cluster.py
_find_families_deprecated
def _find_families_deprecated(clus_obj, min_seqs): """ Mask under same id all clusters that share sequences :param clus_obj: cluster object coming from detect_cluster :param min_seqs: int cutoff to keep the cluster or not. 10 as default :return: updated clus_obj and dict with seq_id: cluster_id ...
python
def _find_families_deprecated(clus_obj, min_seqs): """ Mask under same id all clusters that share sequences :param clus_obj: cluster object coming from detect_cluster :param min_seqs: int cutoff to keep the cluster or not. 10 as default :return: updated clus_obj and dict with seq_id: cluster_id ...
[ "def", "_find_families_deprecated", "(", "clus_obj", ",", "min_seqs", ")", ":", "logger", ".", "info", "(", "\"Creating meta-clusters based on shared sequences.\"", ")", "seen", "=", "defaultdict", "(", ")", "metacluster", "=", "defaultdict", "(", "list", ")", "c_in...
Mask under same id all clusters that share sequences :param clus_obj: cluster object coming from detect_cluster :param min_seqs: int cutoff to keep the cluster or not. 10 as default :return: updated clus_obj and dict with seq_id: cluster_id
[ "Mask", "under", "same", "id", "all", "clusters", "that", "share", "sequences", ":", "param", "clus_obj", ":", "cluster", "object", "coming", "from", "detect_cluster", ":", "param", "min_seqs", ":", "int", "cutoff", "to", "keep", "the", "cluster", "or", "not...
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/cluster.py#L181-L233
lpantano/seqcluster
seqcluster/detect/cluster.py
peak_calling
def peak_calling(clus_obj): """ Run peak calling inside each cluster """ new_cluster = {} for cid in clus_obj.clus: cluster = clus_obj.clus[cid] cluster.update() logger.debug("peak calling for %s" % cid) bigger = cluster.locimaxid if bigger in clus_obj.loci: ...
python
def peak_calling(clus_obj): """ Run peak calling inside each cluster """ new_cluster = {} for cid in clus_obj.clus: cluster = clus_obj.clus[cid] cluster.update() logger.debug("peak calling for %s" % cid) bigger = cluster.locimaxid if bigger in clus_obj.loci: ...
[ "def", "peak_calling", "(", "clus_obj", ")", ":", "new_cluster", "=", "{", "}", "for", "cid", "in", "clus_obj", ".", "clus", ":", "cluster", "=", "clus_obj", ".", "clus", "[", "cid", "]", "cluster", ".", "update", "(", ")", "logger", ".", "debug", "(...
Run peak calling inside each cluster
[ "Run", "peak", "calling", "inside", "each", "cluster" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/detect/cluster.py#L235-L267
lpantano/seqcluster
seqcluster/libs/simulator.py
simulate
def simulate(args): """Main function that manage simulatin of small RNAs""" if args.fasta: name = None seq = "" reads = dict() with open(args.fasta) as in_handle: for line in in_handle: if line.startswith(">"): if name: ...
python
def simulate(args): """Main function that manage simulatin of small RNAs""" if args.fasta: name = None seq = "" reads = dict() with open(args.fasta) as in_handle: for line in in_handle: if line.startswith(">"): if name: ...
[ "def", "simulate", "(", "args", ")", ":", "if", "args", ".", "fasta", ":", "name", "=", "None", "seq", "=", "\"\"", "reads", "=", "dict", "(", ")", "with", "open", "(", "args", ".", "fasta", ")", "as", "in_handle", ":", "for", "line", "in", "in_h...
Main function that manage simulatin of small RNAs
[ "Main", "function", "that", "manage", "simulatin", "of", "small", "RNAs" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/simulator.py#L7-L24
lpantano/seqcluster
seqcluster/libs/simulator.py
_generate_reads
def _generate_reads(seq, name): """Main function that create reads from precursors""" reads = dict() if len(seq) < 130 and len(seq) > 70: reads.update(_mature(seq[:40], 0, name)) reads.update(_mature(seq[-40:], len(seq) - 40, name)) reads.update(_noise(seq, name)) reads.updat...
python
def _generate_reads(seq, name): """Main function that create reads from precursors""" reads = dict() if len(seq) < 130 and len(seq) > 70: reads.update(_mature(seq[:40], 0, name)) reads.update(_mature(seq[-40:], len(seq) - 40, name)) reads.update(_noise(seq, name)) reads.updat...
[ "def", "_generate_reads", "(", "seq", ",", "name", ")", ":", "reads", "=", "dict", "(", ")", "if", "len", "(", "seq", ")", "<", "130", "and", "len", "(", "seq", ")", ">", "70", ":", "reads", ".", "update", "(", "_mature", "(", "seq", "[", ":", ...
Main function that create reads from precursors
[ "Main", "function", "that", "create", "reads", "from", "precursors" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/simulator.py#L27-L35
lpantano/seqcluster
seqcluster/libs/simulator.py
_mature
def _mature(subseq, absolute, c, size=33, total=5000): """Create mature sequences around start/end""" reads = dict() probs = [0.1, 0.2, 0.4, 0.2, 0.1] end = 5 + size error = [-2, -1, 0, 1, 2] for error5 in error: for error3 in error: s = 5 - error5 e = end - erro...
python
def _mature(subseq, absolute, c, size=33, total=5000): """Create mature sequences around start/end""" reads = dict() probs = [0.1, 0.2, 0.4, 0.2, 0.1] end = 5 + size error = [-2, -1, 0, 1, 2] for error5 in error: for error3 in error: s = 5 - error5 e = end - erro...
[ "def", "_mature", "(", "subseq", ",", "absolute", ",", "c", ",", "size", "=", "33", ",", "total", "=", "5000", ")", ":", "reads", "=", "dict", "(", ")", "probs", "=", "[", "0.1", ",", "0.2", ",", "0.4", ",", "0.2", ",", "0.1", "]", "end", "="...
Create mature sequences around start/end
[ "Create", "mature", "sequences", "around", "start", "/", "end" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/simulator.py#L38-L52
lpantano/seqcluster
seqcluster/libs/simulator.py
_noise
def _noise(seq, c, size=33, total=1000): """Create mature sequences around start/end""" reads = dict() seen = 0 while seen < total: s = random.randint(0, len(seq) - size) e = s + size + random.randint(-5,5) p = random.uniform(0, 0.1) counts = int(p * total) + 1 se...
python
def _noise(seq, c, size=33, total=1000): """Create mature sequences around start/end""" reads = dict() seen = 0 while seen < total: s = random.randint(0, len(seq) - size) e = s + size + random.randint(-5,5) p = random.uniform(0, 0.1) counts = int(p * total) + 1 se...
[ "def", "_noise", "(", "seq", ",", "c", ",", "size", "=", "33", ",", "total", "=", "1000", ")", ":", "reads", "=", "dict", "(", ")", "seen", "=", "0", "while", "seen", "<", "total", ":", "s", "=", "random", ".", "randint", "(", "0", ",", "len"...
Create mature sequences around start/end
[ "Create", "mature", "sequences", "around", "start", "/", "end" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/simulator.py#L55-L67
lpantano/seqcluster
seqcluster/libs/simulator.py
_write_reads
def _write_reads(reads, prefix): """ Write fasta file, ma file and real position """ out_ma = prefix + ".ma" out_fasta = prefix + ".fasta" out_real = prefix + ".txt" with open(out_ma, 'w') as ma_handle: print("id\tseq\tsample", file=ma_handle, end="") with open(out_fasta, 'w'...
python
def _write_reads(reads, prefix): """ Write fasta file, ma file and real position """ out_ma = prefix + ".ma" out_fasta = prefix + ".fasta" out_real = prefix + ".txt" with open(out_ma, 'w') as ma_handle: print("id\tseq\tsample", file=ma_handle, end="") with open(out_fasta, 'w'...
[ "def", "_write_reads", "(", "reads", ",", "prefix", ")", ":", "out_ma", "=", "prefix", "+", "\".ma\"", "out_fasta", "=", "prefix", "+", "\".fasta\"", "out_real", "=", "prefix", "+", "\".txt\"", "with", "open", "(", "out_ma", ",", "'w'", ")", "as", "ma_ha...
Write fasta file, ma file and real position
[ "Write", "fasta", "file", "ma", "file", "and", "real", "position" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/simulator.py#L70-L85
lpantano/seqcluster
seqcluster/stats.py
stats
def stats(args): """Create stats from the analysis """ logger.info("Reading sequeces") data = parse_ma_file(args.ma) logger.info("Get sequences from sam") is_align = _read_sam(args.sam) is_json, is_db = _read_json(args.json) res = _summarise_sam(data, is_align, is_json, is_db) _write...
python
def stats(args): """Create stats from the analysis """ logger.info("Reading sequeces") data = parse_ma_file(args.ma) logger.info("Get sequences from sam") is_align = _read_sam(args.sam) is_json, is_db = _read_json(args.json) res = _summarise_sam(data, is_align, is_json, is_db) _write...
[ "def", "stats", "(", "args", ")", ":", "logger", ".", "info", "(", "\"Reading sequeces\"", ")", "data", "=", "parse_ma_file", "(", "args", ".", "ma", ")", "logger", ".", "info", "(", "\"Get sequences from sam\"", ")", "is_align", "=", "_read_sam", "(", "ar...
Create stats from the analysis
[ "Create", "stats", "from", "the", "analysis" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/stats.py#L12-L22
lpantano/seqcluster
seqcluster/stats.py
_read_json
def _read_json(fn_json): """read json information""" is_json = set() is_db = {} with open(fn_json) as handle: data = json.load(handle) # original Py 2.y core #for item in data[0].values(): # seqs_name = map(lambda (x): x.keys(), item['seqs']) # rewrite by 2to3 ...
python
def _read_json(fn_json): """read json information""" is_json = set() is_db = {} with open(fn_json) as handle: data = json.load(handle) # original Py 2.y core #for item in data[0].values(): # seqs_name = map(lambda (x): x.keys(), item['seqs']) # rewrite by 2to3 ...
[ "def", "_read_json", "(", "fn_json", ")", ":", "is_json", "=", "set", "(", ")", "is_db", "=", "{", "}", "with", "open", "(", "fn_json", ")", "as", "handle", ":", "data", "=", "json", ".", "load", "(", "handle", ")", "# original Py 2.y core", "#for item...
read json information
[ "read", "json", "information" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/stats.py#L35-L51
lpantano/seqcluster
seqcluster/libs/do.py
run
def run(cmd, data=None, checks=None, region=None, log_error=True, log_stdout=False): """Run the provided command, logging details and checking for errors. """ try: logger.debug(" ".join(str(x) for x in cmd) if not isinstance(cmd, basestring) else cmd) _do_run(cmd, checks, log_stdout)...
python
def run(cmd, data=None, checks=None, region=None, log_error=True, log_stdout=False): """Run the provided command, logging details and checking for errors. """ try: logger.debug(" ".join(str(x) for x in cmd) if not isinstance(cmd, basestring) else cmd) _do_run(cmd, checks, log_stdout)...
[ "def", "run", "(", "cmd", ",", "data", "=", "None", ",", "checks", "=", "None", ",", "region", "=", "None", ",", "log_error", "=", "True", ",", "log_stdout", "=", "False", ")", ":", "try", ":", "logger", ".", "debug", "(", "\" \"", ".", "join", "...
Run the provided command, logging details and checking for errors.
[ "Run", "the", "provided", "command", "logging", "details", "and", "checking", "for", "errors", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/do.py#L11-L21
lpantano/seqcluster
seqcluster/libs/do.py
_normalize_cmd_args
def _normalize_cmd_args(cmd): """Normalize subprocess arguments to handle list commands, string and pipes. Piped commands set pipefail and require use of bash to help with debugging intermediate errors. """ if isinstance(cmd, basestring): # check for standard or anonymous named pipes ...
python
def _normalize_cmd_args(cmd): """Normalize subprocess arguments to handle list commands, string and pipes. Piped commands set pipefail and require use of bash to help with debugging intermediate errors. """ if isinstance(cmd, basestring): # check for standard or anonymous named pipes ...
[ "def", "_normalize_cmd_args", "(", "cmd", ")", ":", "if", "isinstance", "(", "cmd", ",", "basestring", ")", ":", "# check for standard or anonymous named pipes", "if", "cmd", ".", "find", "(", "\" | \"", ")", ">", "0", "or", "cmd", ".", "find", "(", "\">(\""...
Normalize subprocess arguments to handle list commands, string and pipes. Piped commands set pipefail and require use of bash to help with debugging intermediate errors.
[ "Normalize", "subprocess", "arguments", "to", "handle", "list", "commands", "string", "and", "pipes", ".", "Piped", "commands", "set", "pipefail", "and", "require", "use", "of", "bash", "to", "help", "with", "debugging", "intermediate", "errors", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/do.py#L35-L47
lpantano/seqcluster
seqcluster/libs/do.py
_do_run
def _do_run(cmd, checks, log_stdout=False): """Perform running and check results, raising errors for issues. """ cmd, shell_arg, executable_arg = _normalize_cmd_args(cmd) s = subprocess.Popen(cmd, shell=shell_arg, executable=executable_arg, stdout=subprocess.PIPE, ...
python
def _do_run(cmd, checks, log_stdout=False): """Perform running and check results, raising errors for issues. """ cmd, shell_arg, executable_arg = _normalize_cmd_args(cmd) s = subprocess.Popen(cmd, shell=shell_arg, executable=executable_arg, stdout=subprocess.PIPE, ...
[ "def", "_do_run", "(", "cmd", ",", "checks", ",", "log_stdout", "=", "False", ")", ":", "cmd", ",", "shell_arg", ",", "executable_arg", "=", "_normalize_cmd_args", "(", "cmd", ")", "s", "=", "subprocess", ".", "Popen", "(", "cmd", ",", "shell", "=", "s...
Perform running and check results, raising errors for issues.
[ "Perform", "running", "and", "check", "results", "raising", "errors", "for", "issues", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/do.py#L49-L84
lpantano/seqcluster
seqcluster/libs/bayes.py
_dict_seq_locus
def _dict_seq_locus(list_c, loci_obj, seq_obj): """ return dict with sequences = [ cluster1, cluster2 ...] """ seqs = defaultdict(set) # n = len(list_c.keys()) for c in list_c.values(): for l in c.loci2seq: [seqs[s].add(c.id) for s in c.loci2seq[l]] common = [s for s in ...
python
def _dict_seq_locus(list_c, loci_obj, seq_obj): """ return dict with sequences = [ cluster1, cluster2 ...] """ seqs = defaultdict(set) # n = len(list_c.keys()) for c in list_c.values(): for l in c.loci2seq: [seqs[s].add(c.id) for s in c.loci2seq[l]] common = [s for s in ...
[ "def", "_dict_seq_locus", "(", "list_c", ",", "loci_obj", ",", "seq_obj", ")", ":", "seqs", "=", "defaultdict", "(", "set", ")", "# n = len(list_c.keys())", "for", "c", "in", "list_c", ".", "values", "(", ")", ":", "for", "l", "in", "c", ".", "loci2seq",...
return dict with sequences = [ cluster1, cluster2 ...]
[ "return", "dict", "with", "sequences", "=", "[", "cluster1", "cluster2", "...", "]" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/bayes.py#L51-L74
lpantano/seqcluster
seqcluster/libs/bayes.py
_update.Update
def Update(self, data): """Updates the PMF with new data. data: string cookie type """ for hypo in self.Values(): like = self.Likelihood(data, hypo) self.Mult(hypo, like) self.Normalize()
python
def Update(self, data): """Updates the PMF with new data. data: string cookie type """ for hypo in self.Values(): like = self.Likelihood(data, hypo) self.Mult(hypo, like) self.Normalize()
[ "def", "Update", "(", "self", ",", "data", ")", ":", "for", "hypo", "in", "self", ".", "Values", "(", ")", ":", "like", "=", "self", ".", "Likelihood", "(", "data", ",", "hypo", ")", "self", ".", "Mult", "(", "hypo", ",", "like", ")", "self", "...
Updates the PMF with new data. data: string cookie type
[ "Updates", "the", "PMF", "with", "new", "data", ".", "data", ":", "string", "cookie", "type" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/bayes.py#L25-L32
lpantano/seqcluster
seqcluster/libs/bayes.py
_update.Likelihood
def Likelihood(self, data, hypo): """The likelihood of the data under the hypothesis. data: string cookie type hypo: string bowl ID """ mix = self.loci[hypo] like = mix[data] return like
python
def Likelihood(self, data, hypo): """The likelihood of the data under the hypothesis. data: string cookie type hypo: string bowl ID """ mix = self.loci[hypo] like = mix[data] return like
[ "def", "Likelihood", "(", "self", ",", "data", ",", "hypo", ")", ":", "mix", "=", "self", ".", "loci", "[", "hypo", "]", "like", "=", "mix", "[", "data", "]", "return", "like" ]
The likelihood of the data under the hypothesis. data: string cookie type hypo: string bowl ID
[ "The", "likelihood", "of", "the", "data", "under", "the", "hypothesis", ".", "data", ":", "string", "cookie", "type", "hypo", ":", "string", "bowl", "ID" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/bayes.py#L34-L41
lpantano/seqcluster
seqcluster/libs/tool.py
show_seq
def show_seq(clus_obj, index): """Get the precursor and map sequences to it. this way we create a positional map.""" current = clus_obj.clus clus_seqt = clus_obj.seq clus_locit = clus_obj.loci itern = 0 for idc in current.keys(): itern += 1 timestamp = str(idc) se...
python
def show_seq(clus_obj, index): """Get the precursor and map sequences to it. this way we create a positional map.""" current = clus_obj.clus clus_seqt = clus_obj.seq clus_locit = clus_obj.loci itern = 0 for idc in current.keys(): itern += 1 timestamp = str(idc) se...
[ "def", "show_seq", "(", "clus_obj", ",", "index", ")", ":", "current", "=", "clus_obj", ".", "clus", "clus_seqt", "=", "clus_obj", ".", "seq", "clus_locit", "=", "clus_obj", ".", "loci", "itern", "=", "0", "for", "idc", "in", "current", ".", "keys", "(...
Get the precursor and map sequences to it. this way we create a positional map.
[ "Get", "the", "precursor", "and", "map", "sequences", "to", "it", ".", "this", "way", "we", "create", "a", "positional", "map", "." ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/tool.py#L58-L117
lpantano/seqcluster
seqcluster/libs/tool.py
_normalize_seqs
def _normalize_seqs(s, t): """Normalize to RPM""" for ids in s: obj = s[ids] [obj.norm_freq.update({sample: 1.0 * obj.freq[sample] / (t[sample]+1) * 1000000}) for sample in obj.norm_freq] s[ids] = obj return s
python
def _normalize_seqs(s, t): """Normalize to RPM""" for ids in s: obj = s[ids] [obj.norm_freq.update({sample: 1.0 * obj.freq[sample] / (t[sample]+1) * 1000000}) for sample in obj.norm_freq] s[ids] = obj return s
[ "def", "_normalize_seqs", "(", "s", ",", "t", ")", ":", "for", "ids", "in", "s", ":", "obj", "=", "s", "[", "ids", "]", "[", "obj", ".", "norm_freq", ".", "update", "(", "{", "sample", ":", "1.0", "*", "obj", ".", "freq", "[", "sample", "]", ...
Normalize to RPM
[ "Normalize", "to", "RPM" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/tool.py#L132-L138
lpantano/seqcluster
seqcluster/function/coral.py
prepare_bam
def prepare_bam(bam_in, precursors): """ Clean BAM file to keep only position inside the bigger cluster """ # use pybedtools to keep valid positions # intersect option with -b bigger_cluster_loci a = pybedtools.BedTool(bam_in) b = pybedtools.BedTool(precursors) c = a.intersect(b, u=True)...
python
def prepare_bam(bam_in, precursors): """ Clean BAM file to keep only position inside the bigger cluster """ # use pybedtools to keep valid positions # intersect option with -b bigger_cluster_loci a = pybedtools.BedTool(bam_in) b = pybedtools.BedTool(precursors) c = a.intersect(b, u=True)...
[ "def", "prepare_bam", "(", "bam_in", ",", "precursors", ")", ":", "# use pybedtools to keep valid positions", "# intersect option with -b bigger_cluster_loci", "a", "=", "pybedtools", ".", "BedTool", "(", "bam_in", ")", "b", "=", "pybedtools", ".", "BedTool", "(", "pr...
Clean BAM file to keep only position inside the bigger cluster
[ "Clean", "BAM", "file", "to", "keep", "only", "position", "inside", "the", "bigger", "cluster" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/coral.py#L18-L29
lpantano/seqcluster
seqcluster/function/coral.py
_reorder_columns
def _reorder_columns(bed_file): """ Reorder columns to be compatible with CoRaL """ new_bed = utils.splitext_plus(bed_file)[0] + '_order.bed' with open(bed_file) as in_handle: with open(new_bed, 'w') as out_handle: for line in in_handle: cols = line.strip().split(...
python
def _reorder_columns(bed_file): """ Reorder columns to be compatible with CoRaL """ new_bed = utils.splitext_plus(bed_file)[0] + '_order.bed' with open(bed_file) as in_handle: with open(new_bed, 'w') as out_handle: for line in in_handle: cols = line.strip().split(...
[ "def", "_reorder_columns", "(", "bed_file", ")", ":", "new_bed", "=", "utils", ".", "splitext_plus", "(", "bed_file", ")", "[", "0", "]", "+", "'_order.bed'", "with", "open", "(", "bed_file", ")", "as", "in_handle", ":", "with", "open", "(", "new_bed", "...
Reorder columns to be compatible with CoRaL
[ "Reorder", "columns", "to", "be", "compatible", "with", "CoRaL" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/coral.py#L40-L52
lpantano/seqcluster
seqcluster/function/coral.py
_fix_score_column
def _fix_score_column(cov_file): """ Move counts to score columns in bed file """ new_cov = utils.splitext_plus(cov_file)[0] + '_fix.cov' with open(cov_file) as in_handle: with open(new_cov, 'w') as out_handle: for line in in_handle: cols = line.strip().split("\t"...
python
def _fix_score_column(cov_file): """ Move counts to score columns in bed file """ new_cov = utils.splitext_plus(cov_file)[0] + '_fix.cov' with open(cov_file) as in_handle: with open(new_cov, 'w') as out_handle: for line in in_handle: cols = line.strip().split("\t"...
[ "def", "_fix_score_column", "(", "cov_file", ")", ":", "new_cov", "=", "utils", ".", "splitext_plus", "(", "cov_file", ")", "[", "0", "]", "+", "'_fix.cov'", "with", "open", "(", "cov_file", ")", "as", "in_handle", ":", "with", "open", "(", "new_cov", ",...
Move counts to score columns in bed file
[ "Move", "counts", "to", "score", "columns", "in", "bed", "file" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/coral.py#L55-L66
lpantano/seqcluster
seqcluster/function/coral.py
detect_regions
def detect_regions(bam_in, bed_file, out_dir, prefix): """ Detect regions using first CoRaL module """ bed_file = _reorder_columns(bed_file) counts_reads_cmd = ("coverageBed -s -counts -b {bam_in} " "-a {bed_file} | sort -k4,4 " "> {out_dir}/loci.cov")...
python
def detect_regions(bam_in, bed_file, out_dir, prefix): """ Detect regions using first CoRaL module """ bed_file = _reorder_columns(bed_file) counts_reads_cmd = ("coverageBed -s -counts -b {bam_in} " "-a {bed_file} | sort -k4,4 " "> {out_dir}/loci.cov")...
[ "def", "detect_regions", "(", "bam_in", ",", "bed_file", ",", "out_dir", ",", "prefix", ")", ":", "bed_file", "=", "_reorder_columns", "(", "bed_file", ")", "counts_reads_cmd", "=", "(", "\"coverageBed -s -counts -b {bam_in} \"", "\"-a {bed_file} | sort -k4,4 \"", "\"> ...
Detect regions using first CoRaL module
[ "Detect", "regions", "using", "first", "CoRaL", "module" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/coral.py#L69-L81
lpantano/seqcluster
seqcluster/function/coral.py
_order_antisense_column
def _order_antisense_column(cov_file, min_reads): """ Move counts to score columns in bed file """ new_cov = op.join(op.dirname(cov_file), 'feat_antisense.txt') with open(cov_file) as in_handle: with open(new_cov, 'w') as out_handle: print("name\tantisense", file=out_handle, end=...
python
def _order_antisense_column(cov_file, min_reads): """ Move counts to score columns in bed file """ new_cov = op.join(op.dirname(cov_file), 'feat_antisense.txt') with open(cov_file) as in_handle: with open(new_cov, 'w') as out_handle: print("name\tantisense", file=out_handle, end=...
[ "def", "_order_antisense_column", "(", "cov_file", ",", "min_reads", ")", ":", "new_cov", "=", "op", ".", "join", "(", "op", ".", "dirname", "(", "cov_file", ")", ",", "'feat_antisense.txt'", ")", "with", "open", "(", "cov_file", ")", "as", "in_handle", ":...
Move counts to score columns in bed file
[ "Move", "counts", "to", "score", "columns", "in", "bed", "file" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/coral.py#L84-L96
lpantano/seqcluster
seqcluster/function/coral.py
_reads_per_position
def _reads_per_position(bam_in, loci_file, out_dir): """ Create input for compute entropy """ data = Counter() a = pybedtools.BedTool(bam_in) b = pybedtools.BedTool(loci_file) c = a.intersect(b, s=True, bed=True, wo=True) for line in c: end = int(line[1]) + 1 + int(line[2]) if li...
python
def _reads_per_position(bam_in, loci_file, out_dir): """ Create input for compute entropy """ data = Counter() a = pybedtools.BedTool(bam_in) b = pybedtools.BedTool(loci_file) c = a.intersect(b, s=True, bed=True, wo=True) for line in c: end = int(line[1]) + 1 + int(line[2]) if li...
[ "def", "_reads_per_position", "(", "bam_in", ",", "loci_file", ",", "out_dir", ")", ":", "data", "=", "Counter", "(", ")", "a", "=", "pybedtools", ".", "BedTool", "(", "bam_in", ")", "b", "=", "pybedtools", ".", "BedTool", "(", "loci_file", ")", "c", "...
Create input for compute entropy
[ "Create", "input", "for", "compute", "entropy" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/coral.py#L99-L120
lpantano/seqcluster
seqcluster/function/coral.py
create_features
def create_features(bam_in, loci_file, reference, out_dir): """ Use feature extraction module from CoRaL """ lenvec_plus = op.join(out_dir, 'genomic_lenvec.plus') lenvec_minus = op.join(out_dir, 'genomic_lenvec.minus') compute_genomic_cmd = ("compute_genomic_lenvectors " ...
python
def create_features(bam_in, loci_file, reference, out_dir): """ Use feature extraction module from CoRaL """ lenvec_plus = op.join(out_dir, 'genomic_lenvec.plus') lenvec_minus = op.join(out_dir, 'genomic_lenvec.minus') compute_genomic_cmd = ("compute_genomic_lenvectors " ...
[ "def", "create_features", "(", "bam_in", ",", "loci_file", ",", "reference", ",", "out_dir", ")", ":", "lenvec_plus", "=", "op", ".", "join", "(", "out_dir", ",", "'genomic_lenvec.plus'", ")", "lenvec_minus", "=", "op", ".", "join", "(", "out_dir", ",", "'...
Use feature extraction module from CoRaL
[ "Use", "feature", "extraction", "module", "from", "CoRaL" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/coral.py#L123-L163
lpantano/seqcluster
seqcluster/create_report.py
report
def report(args): """ Create report in html format """ logger.info("reading sequeces") data = load_data(args.json) logger.info("create profile") data = make_profile(data, os.path.join(args.out, "profiles"), args) logger.info("create database") make_database(data, "seqcluster.db", ar...
python
def report(args): """ Create report in html format """ logger.info("reading sequeces") data = load_data(args.json) logger.info("create profile") data = make_profile(data, os.path.join(args.out, "profiles"), args) logger.info("create database") make_database(data, "seqcluster.db", ar...
[ "def", "report", "(", "args", ")", ":", "logger", ".", "info", "(", "\"reading sequeces\"", ")", "data", "=", "load_data", "(", "args", ".", "json", ")", "logger", ".", "info", "(", "\"create profile\"", ")", "data", "=", "make_profile", "(", "data", ","...
Create report in html format
[ "Create", "report", "in", "html", "format" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/create_report.py#L22-L34
lpantano/seqcluster
seqcluster/function/peakdetect.py
_summarize_peaks
def _summarize_peaks(peaks): """ merge peaks position if closer than 10 """ previous = peaks[0] new_peaks = [previous] for pos in peaks: if pos > previous + 10: new_peaks.add(pos) previous = pos return new_peaks
python
def _summarize_peaks(peaks): """ merge peaks position if closer than 10 """ previous = peaks[0] new_peaks = [previous] for pos in peaks: if pos > previous + 10: new_peaks.add(pos) previous = pos return new_peaks
[ "def", "_summarize_peaks", "(", "peaks", ")", ":", "previous", "=", "peaks", "[", "0", "]", "new_peaks", "=", "[", "previous", "]", "for", "pos", "in", "peaks", ":", "if", "pos", ">", "previous", "+", "10", ":", "new_peaks", ".", "add", "(", "pos", ...
merge peaks position if closer than 10
[ "merge", "peaks", "position", "if", "closer", "than", "10" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/peakdetect.py#L4-L14
lpantano/seqcluster
seqcluster/function/peakdetect.py
find_mature
def find_mature(x, y, win=10): """ Window apprach to find hills in the expression profile """ previous = min(y) peaks = [] intervals = range(x, y, win) for pos in intervals: if y[pos] > previous * 10: previous = y[pos] peaks.add(pos) peaks = _summarize_pea...
python
def find_mature(x, y, win=10): """ Window apprach to find hills in the expression profile """ previous = min(y) peaks = [] intervals = range(x, y, win) for pos in intervals: if y[pos] > previous * 10: previous = y[pos] peaks.add(pos) peaks = _summarize_pea...
[ "def", "find_mature", "(", "x", ",", "y", ",", "win", "=", "10", ")", ":", "previous", "=", "min", "(", "y", ")", "peaks", "=", "[", "]", "intervals", "=", "range", "(", "x", ",", "y", ",", "win", ")", "for", "pos", "in", "intervals", ":", "i...
Window apprach to find hills in the expression profile
[ "Window", "apprach", "to", "find", "hills", "in", "the", "expression", "profile" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/function/peakdetect.py#L17-L28
lpantano/seqcluster
seqcluster/libs/fastq.py
collapse
def collapse(in_file): """collapse identical sequences and keep Q""" keep = Counter() with open_fastq(in_file) as handle: for line in handle: if line.startswith("@"): if line.find("UMI") > -1: logger.info("Find UMI tags in read names, collapsing by UMI...
python
def collapse(in_file): """collapse identical sequences and keep Q""" keep = Counter() with open_fastq(in_file) as handle: for line in handle: if line.startswith("@"): if line.find("UMI") > -1: logger.info("Find UMI tags in read names, collapsing by UMI...
[ "def", "collapse", "(", "in_file", ")", ":", "keep", "=", "Counter", "(", ")", "with", "open_fastq", "(", "in_file", ")", "as", "handle", ":", "for", "line", "in", "handle", ":", "if", "line", ".", "startswith", "(", "\"@\"", ")", ":", "if", "line", ...
collapse identical sequences and keep Q
[ "collapse", "identical", "sequences", "and", "keep", "Q" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/fastq.py#L12-L29
lpantano/seqcluster
seqcluster/libs/fastq.py
collapse_umi
def collapse_umi(in_file): """collapse reads using UMI tags""" keep = defaultdict(dict) with open_fastq(in_file) as handle: for line in handle: if line.startswith("@"): m = re.search('UMI_([ATGC]*)', line.strip()) umis = m.group(0) seq = ha...
python
def collapse_umi(in_file): """collapse reads using UMI tags""" keep = defaultdict(dict) with open_fastq(in_file) as handle: for line in handle: if line.startswith("@"): m = re.search('UMI_([ATGC]*)', line.strip()) umis = m.group(0) seq = ha...
[ "def", "collapse_umi", "(", "in_file", ")", ":", "keep", "=", "defaultdict", "(", "dict", ")", "with", "open_fastq", "(", "in_file", ")", "as", "handle", ":", "for", "line", "in", "handle", ":", "if", "line", ".", "startswith", "(", "\"@\"", ")", ":", ...
collapse reads using UMI tags
[ "collapse", "reads", "using", "UMI", "tags" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/fastq.py#L32-L49
lpantano/seqcluster
seqcluster/libs/fastq.py
open_fastq
def open_fastq(in_file): """ open a fastq file, using gzip if it is gzipped from bcbio package """ _, ext = os.path.splitext(in_file) if ext == ".gz": return gzip.open(in_file, 'rb') if ext in [".fastq", ".fq", ".fasta", ".fa"]: return open(in_file, 'r') return ValueError("Fi...
python
def open_fastq(in_file): """ open a fastq file, using gzip if it is gzipped from bcbio package """ _, ext = os.path.splitext(in_file) if ext == ".gz": return gzip.open(in_file, 'rb') if ext in [".fastq", ".fq", ".fasta", ".fa"]: return open(in_file, 'r') return ValueError("Fi...
[ "def", "open_fastq", "(", "in_file", ")", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "in_file", ")", "if", "ext", "==", "\".gz\"", ":", "return", "gzip", ".", "open", "(", "in_file", ",", "'rb'", ")", "if", "ext", "in", "...
open a fastq file, using gzip if it is gzipped from bcbio package
[ "open", "a", "fastq", "file", "using", "gzip", "if", "it", "is", "gzipped", "from", "bcbio", "package" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/fastq.py#L52-L61
lpantano/seqcluster
seqcluster/collapse.py
collapse_fastq
def collapse_fastq(args): """collapse fasq files after adapter trimming """ try: umi_fn = args.fastq if _is_umi(args.fastq): umis = collapse(args.fastq) umi_fn = os.path.join(args.out, splitext_plus(os.path.basename(args.fastq))[0] + "_umi_trimmed.fastq") ...
python
def collapse_fastq(args): """collapse fasq files after adapter trimming """ try: umi_fn = args.fastq if _is_umi(args.fastq): umis = collapse(args.fastq) umi_fn = os.path.join(args.out, splitext_plus(os.path.basename(args.fastq))[0] + "_umi_trimmed.fastq") ...
[ "def", "collapse_fastq", "(", "args", ")", ":", "try", ":", "umi_fn", "=", "args", ".", "fastq", "if", "_is_umi", "(", "args", ".", "fastq", ")", ":", "umis", "=", "collapse", "(", "args", ".", "fastq", ")", "umi_fn", "=", "os", ".", "path", ".", ...
collapse fasq files after adapter trimming
[ "collapse", "fasq", "files", "after", "adapter", "trimming" ]
train
https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/collapse.py#L9-L25
nyergler/hieroglyph
src/hieroglyph/directives.py
filter_doctree_for_slides
def filter_doctree_for_slides(doctree): """Given a doctree, remove all non-slide related elements from it.""" current = 0 num_children = len(doctree.children) while current < num_children: child = doctree.children[current] child.replace_self( child.traverse(no_autoslides_fi...
python
def filter_doctree_for_slides(doctree): """Given a doctree, remove all non-slide related elements from it.""" current = 0 num_children = len(doctree.children) while current < num_children: child = doctree.children[current] child.replace_self( child.traverse(no_autoslides_fi...
[ "def", "filter_doctree_for_slides", "(", "doctree", ")", ":", "current", "=", "0", "num_children", "=", "len", "(", "doctree", ".", "children", ")", "while", "current", "<", "num_children", ":", "child", "=", "doctree", ".", "children", "[", "current", "]", ...
Given a doctree, remove all non-slide related elements from it.
[ "Given", "a", "doctree", "remove", "all", "non", "-", "slide", "related", "elements", "from", "it", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/directives.py#L309-L326
nyergler/hieroglyph
src/hieroglyph/directives.py
TransformNextSlides._make_title_node
def _make_title_node(self, node, increment=True): """Generate a new title node for ``node``. ``node`` is a ``nextslide`` node. The title will use the node's parent's title, or the title specified as an argument. """ parent_title_node = node.parent.next_node(nodes.title) ...
python
def _make_title_node(self, node, increment=True): """Generate a new title node for ``node``. ``node`` is a ``nextslide`` node. The title will use the node's parent's title, or the title specified as an argument. """ parent_title_node = node.parent.next_node(nodes.title) ...
[ "def", "_make_title_node", "(", "self", ",", "node", ",", "increment", "=", "True", ")", ":", "parent_title_node", "=", "node", ".", "parent", ".", "next_node", "(", "nodes", ".", "title", ")", "nextslide_info", "=", "getattr", "(", "parent_title_node", ",",...
Generate a new title node for ``node``. ``node`` is a ``nextslide`` node. The title will use the node's parent's title, or the title specified as an argument.
[ "Generate", "a", "new", "title", "node", "for", "node", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/directives.py#L137-L177
nyergler/hieroglyph
src/hieroglyph/directives.py
slideconf.apply
def apply(self, builder): """Apply the Slide Configuration to a Builder.""" if 'theme' in self.attributes: builder.apply_theme( self.attributes['theme'], builder.theme_options, )
python
def apply(self, builder): """Apply the Slide Configuration to a Builder.""" if 'theme' in self.attributes: builder.apply_theme( self.attributes['theme'], builder.theme_options, )
[ "def", "apply", "(", "self", ",", "builder", ")", ":", "if", "'theme'", "in", "self", ".", "attributes", ":", "builder", ".", "apply_theme", "(", "self", ".", "attributes", "[", "'theme'", "]", ",", "builder", ".", "theme_options", ",", ")" ]
Apply the Slide Configuration to a Builder.
[ "Apply", "the", "Slide", "Configuration", "to", "a", "Builder", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/directives.py#L217-L224
nyergler/hieroglyph
src/hieroglyph/directives.py
slideconf.get_conf
def get_conf(cls, builder, doctree=None): """Return a dictionary of slide configuration for this doctree.""" # set up the default conf result = { 'theme': builder.config.slide_theme, 'autoslides': builder.config.autoslides, 'slide_classes': [], } ...
python
def get_conf(cls, builder, doctree=None): """Return a dictionary of slide configuration for this doctree.""" # set up the default conf result = { 'theme': builder.config.slide_theme, 'autoslides': builder.config.autoslides, 'slide_classes': [], } ...
[ "def", "get_conf", "(", "cls", ",", "builder", ",", "doctree", "=", "None", ")", ":", "# set up the default conf", "result", "=", "{", "'theme'", ":", "builder", ".", "config", ".", "slide_theme", ",", "'autoslides'", ":", "builder", ".", "config", ".", "a...
Return a dictionary of slide configuration for this doctree.
[ "Return", "a", "dictionary", "of", "slide", "configuration", "for", "this", "doctree", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/directives.py#L241-L257
nyergler/hieroglyph
src/hieroglyph/slides.py
__fix_context
def __fix_context(context): """Return a new context dict based on original context. The new context will be a copy of the original, and some mutable members (such as script and css files) will also be copied to prevent polluting shared context. """ COPY_LISTS = ('script_files', 'css_files',) ...
python
def __fix_context(context): """Return a new context dict based on original context. The new context will be a copy of the original, and some mutable members (such as script and css files) will also be copied to prevent polluting shared context. """ COPY_LISTS = ('script_files', 'css_files',) ...
[ "def", "__fix_context", "(", "context", ")", ":", "COPY_LISTS", "=", "(", "'script_files'", ",", "'css_files'", ",", ")", "for", "attr", "in", "COPY_LISTS", ":", "if", "attr", "in", "context", ":", "context", "[", "attr", "]", "=", "context", "[", "attr"...
Return a new context dict based on original context. The new context will be a copy of the original, and some mutable members (such as script and css files) will also be copied to prevent polluting shared context.
[ "Return", "a", "new", "context", "dict", "based", "on", "original", "context", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/slides.py#L4-L18
nyergler/hieroglyph
src/hieroglyph/quickstart.py
ask_user
def ask_user(d): """Wrap sphinx.quickstart.ask_user, and add additional questions.""" # Print welcome message msg = bold('Welcome to the Hieroglyph %s quickstart utility.') % ( version(), ) print(msg) msg = """ This will ask questions for creating a Hieroglyph project, and then ask some...
python
def ask_user(d): """Wrap sphinx.quickstart.ask_user, and add additional questions.""" # Print welcome message msg = bold('Welcome to the Hieroglyph %s quickstart utility.') % ( version(), ) print(msg) msg = """ This will ask questions for creating a Hieroglyph project, and then ask some...
[ "def", "ask_user", "(", "d", ")", ":", "# Print welcome message", "msg", "=", "bold", "(", "'Welcome to the Hieroglyph %s quickstart utility.'", ")", "%", "(", "version", "(", ")", ",", ")", "print", "(", "msg", ")", "msg", "=", "\"\"\"\nThis will ask questions fo...
Wrap sphinx.quickstart.ask_user, and add additional questions.
[ "Wrap", "sphinx", ".", "quickstart", ".", "ask_user", "and", "add", "additional", "questions", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/quickstart.py#L16-L76
nyergler/hieroglyph
src/hieroglyph/writer.py
SlideData.get_slide_context
def get_slide_context(self): """Return the context dict for rendering this slide.""" return { 'title': self.title, 'level': self.level, 'content': self.content, 'classes': self.classes, 'slide_classes': self._filter_classes(exclude='content-')...
python
def get_slide_context(self): """Return the context dict for rendering this slide.""" return { 'title': self.title, 'level': self.level, 'content': self.content, 'classes': self.classes, 'slide_classes': self._filter_classes(exclude='content-')...
[ "def", "get_slide_context", "(", "self", ")", ":", "return", "{", "'title'", ":", "self", ".", "title", ",", "'level'", ":", "self", ".", "level", ",", "'content'", ":", "self", ".", "content", ",", "'classes'", ":", "self", ".", "classes", ",", "'slid...
Return the context dict for rendering this slide.
[ "Return", "the", "context", "dict", "for", "rendering", "this", "slide", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/writer.py#L83-L96
nyergler/hieroglyph
src/hieroglyph/writer.py
BaseSlideTranslator._add_slide_number
def _add_slide_number(self, slide_no): """Add the slide number to the output if enabled.""" if self.builder.config.slide_numbers: self.body.append( '\n<div class="slide-no">%s</div>\n' % (slide_no,), )
python
def _add_slide_number(self, slide_no): """Add the slide number to the output if enabled.""" if self.builder.config.slide_numbers: self.body.append( '\n<div class="slide-no">%s</div>\n' % (slide_no,), )
[ "def", "_add_slide_number", "(", "self", ",", "slide_no", ")", ":", "if", "self", ".", "builder", ".", "config", ".", "slide_numbers", ":", "self", ".", "body", ".", "append", "(", "'\\n<div class=\"slide-no\">%s</div>\\n'", "%", "(", "slide_no", ",", ")", "...
Add the slide number to the output if enabled.
[ "Add", "the", "slide", "number", "to", "the", "output", "if", "enabled", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/writer.py#L127-L133
nyergler/hieroglyph
src/hieroglyph/writer.py
BaseSlideTranslator._add_slide_footer
def _add_slide_footer(self, slide_no): """Add the slide footer to the output if enabled.""" if self.builder.config.slide_footer: self.body.append( '\n<div class="slide-footer">%s</div>\n' % ( self.builder.config.slide_footer, ), ...
python
def _add_slide_footer(self, slide_no): """Add the slide footer to the output if enabled.""" if self.builder.config.slide_footer: self.body.append( '\n<div class="slide-footer">%s</div>\n' % ( self.builder.config.slide_footer, ), ...
[ "def", "_add_slide_footer", "(", "self", ",", "slide_no", ")", ":", "if", "self", ".", "builder", ".", "config", ".", "slide_footer", ":", "self", ".", "body", ".", "append", "(", "'\\n<div class=\"slide-footer\">%s</div>\\n'", "%", "(", "self", ".", "builder"...
Add the slide footer to the output if enabled.
[ "Add", "the", "slide", "footer", "to", "the", "output", "if", "enabled", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/writer.py#L135-L143
nyergler/hieroglyph
src/hieroglyph/html.py
inspect_config
def inspect_config(app): """Inspect the Sphinx configuration and update for slide-linking. If links from HTML to slides are enabled, make sure the sidebar configuration includes the template and add the necessary theme directory as a loader so the sidebar template can be located. If the sidebar co...
python
def inspect_config(app): """Inspect the Sphinx configuration and update for slide-linking. If links from HTML to slides are enabled, make sure the sidebar configuration includes the template and add the necessary theme directory as a loader so the sidebar template can be located. If the sidebar co...
[ "def", "inspect_config", "(", "app", ")", ":", "# avoid import cycles :/", "from", "hieroglyph", "import", "writer", "# only reconfigure Sphinx if we're generating HTML", "if", "app", ".", "builder", ".", "name", "not", "in", "HTML_BUILDERS", ":", "return", "if", "app...
Inspect the Sphinx configuration and update for slide-linking. If links from HTML to slides are enabled, make sure the sidebar configuration includes the template and add the necessary theme directory as a loader so the sidebar template can be located. If the sidebar configuration already includes ``s...
[ "Inspect", "the", "Sphinx", "configuration", "and", "update", "for", "slide", "-", "linking", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/html.py#L12-L89
nyergler/hieroglyph
src/hieroglyph/html.py
slide_path
def slide_path(builder, pagename=None): """Calculate the relative path to the Slides for pagename.""" return builder.get_relative_uri( pagename or builder.current_docname, os.path.join( builder.app.config.slide_relative_path, pagename or builder.current_docname, ...
python
def slide_path(builder, pagename=None): """Calculate the relative path to the Slides for pagename.""" return builder.get_relative_uri( pagename or builder.current_docname, os.path.join( builder.app.config.slide_relative_path, pagename or builder.current_docname, ...
[ "def", "slide_path", "(", "builder", ",", "pagename", "=", "None", ")", ":", "return", "builder", ".", "get_relative_uri", "(", "pagename", "or", "builder", ".", "current_docname", ",", "os", ".", "path", ".", "join", "(", "builder", ".", "app", ".", "co...
Calculate the relative path to the Slides for pagename.
[ "Calculate", "the", "relative", "path", "to", "the", "Slides", "for", "pagename", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/html.py#L92-L100
nyergler/hieroglyph
src/hieroglyph/html.py
html_path
def html_path(builder, pagename=None): """Calculate the relative path to the Slides for pagename.""" return builder.get_relative_uri( pagename or builder.current_docname, os.path.join( builder.app.config.slide_html_relative_path, pagename or builder.current_docname, ...
python
def html_path(builder, pagename=None): """Calculate the relative path to the Slides for pagename.""" return builder.get_relative_uri( pagename or builder.current_docname, os.path.join( builder.app.config.slide_html_relative_path, pagename or builder.current_docname, ...
[ "def", "html_path", "(", "builder", ",", "pagename", "=", "None", ")", ":", "return", "builder", ".", "get_relative_uri", "(", "pagename", "or", "builder", ".", "current_docname", ",", "os", ".", "path", ".", "join", "(", "builder", ".", "app", ".", "con...
Calculate the relative path to the Slides for pagename.
[ "Calculate", "the", "relative", "path", "to", "the", "Slides", "for", "pagename", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/html.py#L103-L111
nyergler/hieroglyph
src/hieroglyph/html.py
add_link
def add_link(app, pagename, templatename, context, doctree): """Add the slides link to the HTML context.""" # we can only show the slidelink if we can resolve the filename context['show_slidelink'] = ( app.config.slide_link_html_to_slides and hasattr(app.builder, 'get_outfilename') ) ...
python
def add_link(app, pagename, templatename, context, doctree): """Add the slides link to the HTML context.""" # we can only show the slidelink if we can resolve the filename context['show_slidelink'] = ( app.config.slide_link_html_to_slides and hasattr(app.builder, 'get_outfilename') ) ...
[ "def", "add_link", "(", "app", ",", "pagename", ",", "templatename", ",", "context", ",", "doctree", ")", ":", "# we can only show the slidelink if we can resolve the filename", "context", "[", "'show_slidelink'", "]", "=", "(", "app", ".", "config", ".", "slide_lin...
Add the slides link to the HTML context.
[ "Add", "the", "slides", "link", "to", "the", "HTML", "context", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/html.py#L114-L124
nyergler/hieroglyph
src/hieroglyph/builder.py
AbstractSlideBuilder.apply_theme
def apply_theme(self, themename, themeoptions): """Apply a new theme to the document. This will store the existing theme configuration and apply a new one. """ # push the existing values onto the Stack self._theme_stack.append( (self.theme, self.theme_options) ...
python
def apply_theme(self, themename, themeoptions): """Apply a new theme to the document. This will store the existing theme configuration and apply a new one. """ # push the existing values onto the Stack self._theme_stack.append( (self.theme, self.theme_options) ...
[ "def", "apply_theme", "(", "self", ",", "themename", ",", "themeoptions", ")", ":", "# push the existing values onto the Stack", "self", ".", "_theme_stack", ".", "append", "(", "(", "self", ".", "theme", ",", "self", ".", "theme_options", ")", ")", "theme_facto...
Apply a new theme to the document. This will store the existing theme configuration and apply a new one.
[ "Apply", "a", "new", "theme", "to", "the", "document", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/builder.py#L82-L103
nyergler/hieroglyph
src/hieroglyph/builder.py
AbstractSlideBuilder.post_process_images
def post_process_images(self, doctree): """Pick the best candidate for all image URIs.""" super(AbstractSlideBuilder, self).post_process_images(doctree) # figure out where this doctree is in relation to the srcdir relative_base = ( ['..'] * doctree.attributes.ge...
python
def post_process_images(self, doctree): """Pick the best candidate for all image URIs.""" super(AbstractSlideBuilder, self).post_process_images(doctree) # figure out where this doctree is in relation to the srcdir relative_base = ( ['..'] * doctree.attributes.ge...
[ "def", "post_process_images", "(", "self", ",", "doctree", ")", ":", "super", "(", "AbstractSlideBuilder", ",", "self", ")", ".", "post_process_images", "(", "doctree", ")", "# figure out where this doctree is in relation to the srcdir", "relative_base", "=", "(", "[", ...
Pick the best candidate for all image URIs.
[ "Pick", "the", "best", "candidate", "for", "all", "image", "URIs", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/builder.py#L145-L167
nyergler/hieroglyph
src/hieroglyph/themes/slides2/static/scripts/md/render.py
parse_metadata
def parse_metadata(section): """Given the first part of a slide, returns metadata associated with it.""" metadata = {} metadata_lines = section.split('\n') for line in metadata_lines: colon_index = line.find(':') if colon_index != -1: key = line[:colon_index].strip() val = line[colon_index +...
python
def parse_metadata(section): """Given the first part of a slide, returns metadata associated with it.""" metadata = {} metadata_lines = section.split('\n') for line in metadata_lines: colon_index = line.find(':') if colon_index != -1: key = line[:colon_index].strip() val = line[colon_index +...
[ "def", "parse_metadata", "(", "section", ")", ":", "metadata", "=", "{", "}", "metadata_lines", "=", "section", ".", "split", "(", "'\\n'", ")", "for", "line", "in", "metadata_lines", ":", "colon_index", "=", "line", ".", "find", "(", "':'", ")", "if", ...
Given the first part of a slide, returns metadata associated with it.
[ "Given", "the", "first", "part", "of", "a", "slide", "returns", "metadata", "associated", "with", "it", "." ]
train
https://github.com/nyergler/hieroglyph/blob/1ef062fad5060006566f8d6bd3b5a231ac7e0488/src/hieroglyph/themes/slides2/static/scripts/md/render.py#L36-L47