partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
find_consensus
find consensus base based on nucleotide frequencies
ctbBio/genome_variation.py
def find_consensus(bases): """ find consensus base based on nucleotide frequencies """ nucs = ['A', 'T', 'G', 'C', 'N'] total = sum([bases[nuc] for nuc in nucs if nuc in bases]) # save most common base as consensus (random nuc if there is a tie) try: top = max([bases[nuc] for nuc...
def find_consensus(bases): """ find consensus base based on nucleotide frequencies """ nucs = ['A', 'T', 'G', 'C', 'N'] total = sum([bases[nuc] for nuc in nucs if nuc in bases]) # save most common base as consensus (random nuc if there is a tie) try: top = max([bases[nuc] for nuc...
[ "find", "consensus", "base", "based", "on", "nucleotide", "frequencies" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L371-L402
[ "def", "find_consensus", "(", "bases", ")", ":", "nucs", "=", "[", "'A'", ",", "'T'", ",", "'G'", ",", "'C'", ",", "'N'", "]", "total", "=", "sum", "(", "[", "bases", "[", "nuc", "]", "for", "nuc", "in", "nucs", "if", "nuc", "in", "bases", "]",...
83b2566b3a5745437ec651cd6cafddd056846240
train
calc_frequencies
print bp frequencies to table genomes = {} # genomes[genome][contig][sample] = {'bp_stats':{}}
ctbBio/genome_variation.py
def calc_frequencies(genomes, bp_table, min_cov, min_per): """ print bp frequencies to table genomes = {} # genomes[genome][contig][sample] = {'bp_stats':{}} """ nucs = ['A', 'T', 'G', 'C', 'N'] if bp_table is not False: bp_table = open(bp_table, 'w') header = ['#genome', 'contig...
def calc_frequencies(genomes, bp_table, min_cov, min_per): """ print bp frequencies to table genomes = {} # genomes[genome][contig][sample] = {'bp_stats':{}} """ nucs = ['A', 'T', 'G', 'C', 'N'] if bp_table is not False: bp_table = open(bp_table, 'w') header = ['#genome', 'contig...
[ "print", "bp", "frequencies", "to", "table", "genomes", "=", "{}", "#", "genomes", "[", "genome", "]", "[", "contig", "]", "[", "sample", "]", "=", "{", "bp_stats", ":", "{}", "}" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L404-L449
[ "def", "calc_frequencies", "(", "genomes", ",", "bp_table", ",", "min_cov", ",", "min_per", ")", ":", "nucs", "=", "[", "'A'", ",", "'T'", ",", "'G'", ",", "'C'", ",", "'N'", "]", "if", "bp_table", "is", "not", "False", ":", "bp_table", "=", "open", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
print_consensus
print consensensus sequences for each genome and sample
ctbBio/genome_variation.py
def print_consensus(genomes): """ print consensensus sequences for each genome and sample """ # generate consensus sequences cons = {} # cons[genome][sample][contig] = consensus for genome, contigs in list(genomes.items()): cons[genome] = {} for contig, samples in list(contigs.it...
def print_consensus(genomes): """ print consensensus sequences for each genome and sample """ # generate consensus sequences cons = {} # cons[genome][sample][contig] = consensus for genome, contigs in list(genomes.items()): cons[genome] = {} for contig, samples in list(contigs.it...
[ "print", "consensensus", "sequences", "for", "each", "genome", "and", "sample" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L451-L478
[ "def", "print_consensus", "(", "genomes", ")", ":", "# generate consensus sequences", "cons", "=", "{", "}", "# cons[genome][sample][contig] = consensus", "for", "genome", ",", "contigs", "in", "list", "(", "genomes", ".", "items", "(", ")", ")", ":", "cons", "[...
83b2566b3a5745437ec651cd6cafddd056846240
train
print_stats
print substitution rate data to table genomes[genome][contig][sample] = \ {'bp_stats':{}, 'sub_rates'[locus] = {ref PnPs, consensus PnPs}}
ctbBio/genome_variation.py
def print_stats(genomes): """ print substitution rate data to table genomes[genome][contig][sample] = \ {'bp_stats':{}, 'sub_rates'[locus] = {ref PnPs, consensus PnPs}} """ header = ['#genome', 'contig', 'locus', 'position', 'strand', 'length', \ 'sample', 'coverage', \ ...
def print_stats(genomes): """ print substitution rate data to table genomes[genome][contig][sample] = \ {'bp_stats':{}, 'sub_rates'[locus] = {ref PnPs, consensus PnPs}} """ header = ['#genome', 'contig', 'locus', 'position', 'strand', 'length', \ 'sample', 'coverage', \ ...
[ "print", "substitution", "rate", "data", "to", "table", "genomes", "[", "genome", "]", "[", "contig", "]", "[", "sample", "]", "=", "\\", "{", "bp_stats", ":", "{}", "sub_rates", "[", "locus", "]", "=", "{", "ref", "PnPs", "consensus", "PnPs", "}}" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L480-L504
[ "def", "print_stats", "(", "genomes", ")", ":", "header", "=", "[", "'#genome'", ",", "'contig'", ",", "'locus'", ",", "'position'", ",", "'strand'", ",", "'length'", ",", "'sample'", ",", "'coverage'", ",", "'ref. Pn/Ps'", ",", "'ref SNP density'", ",", "'c...
83b2566b3a5745437ec651cd6cafddd056846240
train
variation
quantify genomic variation from mapping genomes[genome][contig][sample] = \ {'bp_stats':[], 'sub_rates'[locus] = {ref PnPs, consensus PnPs, ...}}
ctbBio/genome_variation.py
def variation(fastas, sams, s2b, annots, qual, min_cov, min_per, no_sub, bp_table, print_con): """ quantify genomic variation from mapping genomes[genome][contig][sample] = \ {'bp_stats':[], 'sub_rates'[locus] = {ref PnPs, consensus PnPs, ...}} """ genomes = {} # save base-pair data...
def variation(fastas, sams, s2b, annots, qual, min_cov, min_per, no_sub, bp_table, print_con): """ quantify genomic variation from mapping genomes[genome][contig][sample] = \ {'bp_stats':[], 'sub_rates'[locus] = {ref PnPs, consensus PnPs, ...}} """ genomes = {} # save base-pair data...
[ "quantify", "genomic", "variation", "from", "mapping", "genomes", "[", "genome", "]", "[", "contig", "]", "[", "sample", "]", "=", "\\", "{", "bp_stats", ":", "[]", "sub_rates", "[", "locus", "]", "=", "{", "ref", "PnPs", "consensus", "PnPs", "...", "}...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_variation.py#L506-L544
[ "def", "variation", "(", "fastas", ",", "sams", ",", "s2b", ",", "annots", ",", "qual", ",", "min_cov", ",", "min_per", ",", "no_sub", ",", "bp_table", ",", "print_con", ")", ":", "genomes", "=", "{", "}", "# save base-pair data structures for each genome-samp...
83b2566b3a5745437ec651cd6cafddd056846240
train
calc_custom
custom = {(reads mapped to scaffold)/(total reads for sample)}/(length of scaffold)
ctbBio/genome_abundance.py
def calc_custom(custom, genome, scaffold, sequence, scaffold_coverage, total_bases): """ custom = {(reads mapped to scaffold)/(total reads for sample)}/(length of scaffold) """ index = 0 if scaffold in scaffold_coverage: # what if the scaffold does not have bases mapped back to it? (this *should* not happen) if ...
def calc_custom(custom, genome, scaffold, sequence, scaffold_coverage, total_bases): """ custom = {(reads mapped to scaffold)/(total reads for sample)}/(length of scaffold) """ index = 0 if scaffold in scaffold_coverage: # what if the scaffold does not have bases mapped back to it? (this *should* not happen) if ...
[ "custom", "=", "{", "(", "reads", "mapped", "to", "scaffold", ")", "/", "(", "total", "reads", "for", "sample", ")", "}", "/", "(", "length", "of", "scaffold", ")" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_abundance.py#L13-L27
[ "def", "calc_custom", "(", "custom", ",", "genome", ",", "scaffold", ",", "sequence", ",", "scaffold_coverage", ",", "total_bases", ")", ":", "index", "=", "0", "if", "scaffold", "in", "scaffold_coverage", ":", "# what if the scaffold does not have bases mapped back t...
83b2566b3a5745437ec651cd6cafddd056846240
train
absolute_abundance
absolute abundance = (number of bases mapped to genome / total number of bases in sample) * 100
ctbBio/genome_abundance.py
def absolute_abundance(coverage, total_bases): """ absolute abundance = (number of bases mapped to genome / total number of bases in sample) * 100 """ absolute = {} for genome in coverage: absolute[genome] = [] index = 0 for calc in coverage[genome]: bases = calc[0] total = total_bases[index] absolu...
def absolute_abundance(coverage, total_bases): """ absolute abundance = (number of bases mapped to genome / total number of bases in sample) * 100 """ absolute = {} for genome in coverage: absolute[genome] = [] index = 0 for calc in coverage[genome]: bases = calc[0] total = total_bases[index] absolu...
[ "absolute", "abundance", "=", "(", "number", "of", "bases", "mapped", "to", "genome", "/", "total", "number", "of", "bases", "in", "sample", ")", "*", "100" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_abundance.py#L45-L65
[ "def", "absolute_abundance", "(", "coverage", ",", "total_bases", ")", ":", "absolute", "=", "{", "}", "for", "genome", "in", "coverage", ":", "absolute", "[", "genome", "]", "=", "[", "]", "index", "=", "0", "for", "calc", "in", "coverage", "[", "geno...
83b2566b3a5745437ec651cd6cafddd056846240
train
relative_abundance
cov = number of bases / length of genome relative abundance = [(cov) / sum(cov for all genomes)] * 100
ctbBio/genome_abundance.py
def relative_abundance(coverage): """ cov = number of bases / length of genome relative abundance = [(cov) / sum(cov for all genomes)] * 100 """ relative = {} sums = [] for genome in coverage: for cov in coverage[genome]: sums.append(0) break for genome in coverage: index = 0 for cov in coverage[geno...
def relative_abundance(coverage): """ cov = number of bases / length of genome relative abundance = [(cov) / sum(cov for all genomes)] * 100 """ relative = {} sums = [] for genome in coverage: for cov in coverage[genome]: sums.append(0) break for genome in coverage: index = 0 for cov in coverage[geno...
[ "cov", "=", "number", "of", "bases", "/", "length", "of", "genome", "relative", "abundance", "=", "[", "(", "cov", ")", "/", "sum", "(", "cov", "for", "all", "genomes", ")", "]", "*", "100" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_abundance.py#L67-L92
[ "def", "relative_abundance", "(", "coverage", ")", ":", "relative", "=", "{", "}", "sums", "=", "[", "]", "for", "genome", "in", "coverage", ":", "for", "cov", "in", "coverage", "[", "genome", "]", ":", "sums", ".", "append", "(", "0", ")", "break", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
genome_coverage
coverage = (number of bases / length of genome) * 100
ctbBio/genome_abundance.py
def genome_coverage(genomes, scaffold_coverage, total_bases): """ coverage = (number of bases / length of genome) * 100 """ coverage = {} custom = {} std = {} for genome in genomes: for sequence in parse_fasta(genome): scaffold = sequence[0].split('>')[1].split()[0] coverage, std = sum_coverage(coverage,...
def genome_coverage(genomes, scaffold_coverage, total_bases): """ coverage = (number of bases / length of genome) * 100 """ coverage = {} custom = {} std = {} for genome in genomes: for sequence in parse_fasta(genome): scaffold = sequence[0].split('>')[1].split()[0] coverage, std = sum_coverage(coverage,...
[ "coverage", "=", "(", "number", "of", "bases", "/", "length", "of", "genome", ")", "*", "100" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_abundance.py#L116-L146
[ "def", "genome_coverage", "(", "genomes", ",", "scaffold_coverage", ",", "total_bases", ")", ":", "coverage", "=", "{", "}", "custom", "=", "{", "}", "std", "=", "{", "}", "for", "genome", "in", "genomes", ":", "for", "sequence", "in", "parse_fasta", "("...
83b2566b3a5745437ec651cd6cafddd056846240
train
parse_cov
calculate genome coverage from scaffold coverage table
ctbBio/genome_coverage.py
def parse_cov(cov_table, scaffold2genome): """ calculate genome coverage from scaffold coverage table """ size = {} # size[genome] = genome size mapped = {} # mapped[genome][sample] = mapped bases # parse coverage files for line in open(cov_table): line = line.strip().split('\t') ...
def parse_cov(cov_table, scaffold2genome): """ calculate genome coverage from scaffold coverage table """ size = {} # size[genome] = genome size mapped = {} # mapped[genome][sample] = mapped bases # parse coverage files for line in open(cov_table): line = line.strip().split('\t') ...
[ "calculate", "genome", "coverage", "from", "scaffold", "coverage", "table" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_coverage.py#L13-L50
[ "def", "parse_cov", "(", "cov_table", ",", "scaffold2genome", ")", ":", "size", "=", "{", "}", "# size[genome] = genome size", "mapped", "=", "{", "}", "# mapped[genome][sample] = mapped bases", "# parse coverage files", "for", "line", "in", "open", "(", "cov_table", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
genome_coverage
calculate genome coverage from scaffold coverage
ctbBio/genome_coverage.py
def genome_coverage(covs, s2b): """ calculate genome coverage from scaffold coverage """ COV = [] for cov in covs: COV.append(parse_cov(cov, s2b)) return pd.concat(COV)
def genome_coverage(covs, s2b): """ calculate genome coverage from scaffold coverage """ COV = [] for cov in covs: COV.append(parse_cov(cov, s2b)) return pd.concat(COV)
[ "calculate", "genome", "coverage", "from", "scaffold", "coverage" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_coverage.py#L52-L59
[ "def", "genome_coverage", "(", "covs", ",", "s2b", ")", ":", "COV", "=", "[", "]", "for", "cov", "in", "covs", ":", "COV", ".", "append", "(", "parse_cov", "(", "cov", ",", "s2b", ")", ")", "return", "pd", ".", "concat", "(", "COV", ")" ]
83b2566b3a5745437ec651cd6cafddd056846240
train
parse_s2bs
convert s2b files to dictionary
ctbBio/genome_coverage.py
def parse_s2bs(s2bs): """ convert s2b files to dictionary """ s2b = {} for s in s2bs: for line in open(s): line = line.strip().split('\t') s, b = line[0], line[1] s2b[s] = b return s2b
def parse_s2bs(s2bs): """ convert s2b files to dictionary """ s2b = {} for s in s2bs: for line in open(s): line = line.strip().split('\t') s, b = line[0], line[1] s2b[s] = b return s2b
[ "convert", "s2b", "files", "to", "dictionary" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_coverage.py#L61-L71
[ "def", "parse_s2bs", "(", "s2bs", ")", ":", "s2b", "=", "{", "}", "for", "s", "in", "s2bs", ":", "for", "line", "in", "open", "(", "s", ")", ":", "line", "=", "line", ".", "strip", "(", ")", ".", "split", "(", "'\\t'", ")", "s", ",", "b", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
fa2s2b
convert fastas to s2b dictionary
ctbBio/genome_coverage.py
def fa2s2b(fastas): """ convert fastas to s2b dictionary """ s2b = {} for fa in fastas: for seq in parse_fasta(fa): s = seq[0].split('>', 1)[1].split()[0] s2b[s] = fa.rsplit('/', 1)[-1].rsplit('.', 1)[0] return s2b
def fa2s2b(fastas): """ convert fastas to s2b dictionary """ s2b = {} for fa in fastas: for seq in parse_fasta(fa): s = seq[0].split('>', 1)[1].split()[0] s2b[s] = fa.rsplit('/', 1)[-1].rsplit('.', 1)[0] return s2b
[ "convert", "fastas", "to", "s2b", "dictionary" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/genome_coverage.py#L73-L82
[ "def", "fa2s2b", "(", "fastas", ")", ":", "s2b", "=", "{", "}", "for", "fa", "in", "fastas", ":", "for", "seq", "in", "parse_fasta", "(", "fa", ")", ":", "s", "=", "seq", "[", "0", "]", ".", "split", "(", "'>'", ",", "1", ")", "[", "1", "]"...
83b2566b3a5745437ec651cd6cafddd056846240
train
eth_addr
eth_addr :param f: eth frame
network_pipeline/parse_network_data.py
def eth_addr(f): """eth_addr :param f: eth frame """ data = "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x" % (f[0], f[1], f[2], f[3], ...
def eth_addr(f): """eth_addr :param f: eth frame """ data = "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x" % (f[0], f[1], f[2], f[3], ...
[ "eth_addr" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/parse_network_data.py#L41-L52
[ "def", "eth_addr", "(", "f", ")", ":", "data", "=", "\"%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\"", "%", "(", "f", "[", "0", "]", ",", "f", "[", "1", "]", ",", "f", "[", "2", "]", ",", "f", "[", "3", "]", ",", "f", "[", "4", "]", ",", "f", "[", "5", ...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
parse_network_data
build_node :param data_packet: raw recvfrom data :param filter_keys: list of strings to filter and remove baby-birding packets to yourself :param record_tcp: want to record TCP frames? :param record_udp: want to record UDP frames? :param record_arp: w...
network_pipeline/parse_network_data.py
def parse_network_data(data_packet=None, include_filter_key=None, filter_keys=[], record_tcp=True, record_udp=True, record_arp=True, record_icmp=True): """build_node :param ...
def parse_network_data(data_packet=None, include_filter_key=None, filter_keys=[], record_tcp=True, record_udp=True, record_arp=True, record_icmp=True): """build_node :param ...
[ "build_node" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/parse_network_data.py#L75-L552
[ "def", "parse_network_data", "(", "data_packet", "=", "None", ",", "include_filter_key", "=", "None", ",", "filter_keys", "=", "[", "]", ",", "record_tcp", "=", "True", ",", "record_udp", "=", "True", ",", "record_arp", "=", "True", ",", "record_icmp", "=", ...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
filter_ambiguity
Filters out sequences with too much ambiguity as defined by the method parameters. :type records: list :param records: A list of sequences :type repeats: int :param repeats: Defines the number of repeated N that trigger truncating a sequence. :type percent: float :param ...
bin/filter_ambiguity.py
def filter_ambiguity(records, percent=0.5): # , repeats=6) """ Filters out sequences with too much ambiguity as defined by the method parameters. :type records: list :param records: A list of sequences :type repeats: int :param repeats: Defines the number of repeated N that trigger truncat...
def filter_ambiguity(records, percent=0.5): # , repeats=6) """ Filters out sequences with too much ambiguity as defined by the method parameters. :type records: list :param records: A list of sequences :type repeats: int :param repeats: Defines the number of repeated N that trigger truncat...
[ "Filters", "out", "sequences", "with", "too", "much", "ambiguity", "as", "defined", "by", "the", "method", "parameters", "." ]
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/filter_ambiguity.py#L16-L41
[ "def", "filter_ambiguity", "(", "records", ",", "percent", "=", "0.5", ")", ":", "# , repeats=6)", "seqs", "=", "[", "]", "# Ns = ''.join(['N' for _ in range(repeats)])", "count", "=", "0", "for", "record", "in", "records", ":", "if", "record", ".", "seq", "."...
0b74ef171e6a84761710548501dfac71285a58a3
train
Tree._parse
:param root: Tree node. :param line: String to parse. :param idx: Global counter of characters parsed. :return: (list of parsed graphemes, incremented character count)
src/segments/tree.py
def _parse(self, root, line, idx): """ :param root: Tree node. :param line: String to parse. :param idx: Global counter of characters parsed. :return: (list of parsed graphemes, incremented character count) """ # Base (or degenerate..) case. if len(line) =...
def _parse(self, root, line, idx): """ :param root: Tree node. :param line: String to parse. :param idx: Global counter of characters parsed. :return: (list of parsed graphemes, incremented character count) """ # Base (or degenerate..) case. if len(line) =...
[ ":", "param", "root", ":", "Tree", "node", ".", ":", "param", "line", ":", "String", "to", "parse", ".", ":", "param", "idx", ":", "Global", "counter", "of", "characters", "parsed", ".", ":", "return", ":", "(", "list", "of", "parsed", "graphemes", "...
cldf/segments
python
https://github.com/cldf/segments/blob/9136a4ec89555bf9b574399ffbb07f3cc9a9f45f/src/segments/tree.py#L42-L70
[ "def", "_parse", "(", "self", ",", "root", ",", "line", ",", "idx", ")", ":", "# Base (or degenerate..) case.", "if", "len", "(", "line", ")", "==", "0", ":", "return", "[", "]", ",", "idx", "parse", "=", "[", "]", "curr", "=", "0", "node", "=", ...
9136a4ec89555bf9b574399ffbb07f3cc9a9f45f
train
package_existent
Search package. * :class:`bootstrap_py.exceptions.Conflict` exception occurs when user specified name has already existed. * :class:`bootstrap_py.exceptions.BackendFailure` exception occurs when PyPI service is down. :param str name: package name
bootstrap_py/pypi.py
def package_existent(name): """Search package. * :class:`bootstrap_py.exceptions.Conflict` exception occurs when user specified name has already existed. * :class:`bootstrap_py.exceptions.BackendFailure` exception occurs when PyPI service is down. :param str name: package name """ ...
def package_existent(name): """Search package. * :class:`bootstrap_py.exceptions.Conflict` exception occurs when user specified name has already existed. * :class:`bootstrap_py.exceptions.BackendFailure` exception occurs when PyPI service is down. :param str name: package name """ ...
[ "Search", "package", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/pypi.py#L12-L33
[ "def", "package_existent", "(", "name", ")", ":", "try", ":", "response", "=", "requests", ".", "get", "(", "PYPI_URL", ".", "format", "(", "name", ")", ")", "if", "response", ".", "ok", ":", "msg", "=", "(", "'[error] \"{0}\" is registered already in PyPI.\...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
write_relative_abundance
Given a BIOM table, calculate per-sample relative abundance for each OTU and write out to a tab-separated file listing OTUs as rows and Samples as columns. :type biom: biom object :param biom: BIOM-formatted OTU/Sample abundance data :type out_fn: str :param out_fn: The full path to the desired ...
bin/biom_relative_abundance.py
def write_relative_abundance(rel_abd, biomf, out_fn, sort_by=None): """ Given a BIOM table, calculate per-sample relative abundance for each OTU and write out to a tab-separated file listing OTUs as rows and Samples as columns. :type biom: biom object :param biom: BIOM-formatted OTU/Sample abund...
def write_relative_abundance(rel_abd, biomf, out_fn, sort_by=None): """ Given a BIOM table, calculate per-sample relative abundance for each OTU and write out to a tab-separated file listing OTUs as rows and Samples as columns. :type biom: biom object :param biom: BIOM-formatted OTU/Sample abund...
[ "Given", "a", "BIOM", "table", "calculate", "per", "-", "sample", "relative", "abundance", "for", "each", "OTU", "and", "write", "out", "to", "a", "tab", "-", "separated", "file", "listing", "OTUs", "as", "rows", "and", "Samples", "as", "columns", ".", "...
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/biom_relative_abundance.py#L15-L39
[ "def", "write_relative_abundance", "(", "rel_abd", ",", "biomf", ",", "out_fn", ",", "sort_by", "=", "None", ")", ":", "with", "open", "(", "out_fn", ",", "'w'", ")", "as", "out_f", ":", "sids", "=", "sorted", "(", "set", "(", "biomf", ".", "ids", "(...
0b74ef171e6a84761710548501dfac71285a58a3
train
append_index_id
add index to id to make it unique wrt ids
ctbBio/nr_fasta.py
def append_index_id(id, ids): """ add index to id to make it unique wrt ids """ index = 1 mod = '%s_%s' % (id, index) while mod in ids: index += 1 mod = '%s_%s' % (id, index) ids.append(mod) return mod, ids
def append_index_id(id, ids): """ add index to id to make it unique wrt ids """ index = 1 mod = '%s_%s' % (id, index) while mod in ids: index += 1 mod = '%s_%s' % (id, index) ids.append(mod) return mod, ids
[ "add", "index", "to", "id", "to", "make", "it", "unique", "wrt", "ids" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/nr_fasta.py#L11-L21
[ "def", "append_index_id", "(", "id", ",", "ids", ")", ":", "index", "=", "1", "mod", "=", "'%s_%s'", "%", "(", "id", ",", "index", ")", "while", "mod", "in", "ids", ":", "index", "+=", "1", "mod", "=", "'%s_%s'", "%", "(", "id", ",", "index", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
de_rep
de-replicate fastas based on sequence names
ctbBio/nr_fasta.py
def de_rep(fastas, append_index, return_original = False): """ de-replicate fastas based on sequence names """ ids = [] for fasta in fastas: for seq in parse_fasta(fasta): header = seq[0].split('>')[1].split() id = header[0] if id not in ids: ...
def de_rep(fastas, append_index, return_original = False): """ de-replicate fastas based on sequence names """ ids = [] for fasta in fastas: for seq in parse_fasta(fasta): header = seq[0].split('>')[1].split() id = header[0] if id not in ids: ...
[ "de", "-", "replicate", "fastas", "based", "on", "sequence", "names" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/nr_fasta.py#L23-L43
[ "def", "de_rep", "(", "fastas", ",", "append_index", ",", "return_original", "=", "False", ")", ":", "ids", "=", "[", "]", "for", "fasta", "in", "fastas", ":", "for", "seq", "in", "parse_fasta", "(", "fasta", ")", ":", "header", "=", "seq", "[", "0",...
83b2566b3a5745437ec651cd6cafddd056846240
train
get
Request data associated with `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :returns: a dict of the nearest postcode's data or None if no postcode data is found.
postcodes.py
def get(postcode): """ Request data associated with `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :returns: a dict of the nearest postcode's data or None if no postcode data is found. """ po...
def get(postcode): """ Request data associated with `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :returns: a dict of the nearest postcode's data or None if no postcode data is found. """ po...
[ "Request", "data", "associated", "with", "postcode", "." ]
e-dard/postcodes
python
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L22-L34
[ "def", "get", "(", "postcode", ")", ":", "postcode", "=", "quote", "(", "postcode", ".", "replace", "(", "' '", ",", "''", ")", ")", "url", "=", "'%s/postcode/%s.json'", "%", "(", "END_POINT", ",", "postcode", ")", "return", "_get_json_resp", "(", "url",...
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
train
get_from_postcode
Request all postcode data within `distance` miles of `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :param distance: distance in miles to `postcode`. :returns: a list of dicts containing postcode data within the ...
postcodes.py
def get_from_postcode(postcode, distance): """ Request all postcode data within `distance` miles of `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :param distance: distance in miles to `postcode`. :returns: a ...
def get_from_postcode(postcode, distance): """ Request all postcode data within `distance` miles of `postcode`. :param postcode: the postcode to search for. The postcode may contain spaces (they will be removed). :param distance: distance in miles to `postcode`. :returns: a ...
[ "Request", "all", "postcode", "data", "within", "distance", "miles", "of", "postcode", "." ]
e-dard/postcodes
python
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L56-L69
[ "def", "get_from_postcode", "(", "postcode", ",", "distance", ")", ":", "postcode", "=", "quote", "(", "postcode", ".", "replace", "(", "' '", ",", "''", ")", ")", "return", "_get_from", "(", "distance", ",", "'postcode=%s'", "%", "postcode", ")" ]
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
train
PostCoder._check_point
Checks if latitude and longitude correct
postcodes.py
def _check_point(self, lat, lng): """ Checks if latitude and longitude correct """ if abs(lat) > 90 or abs(lng) > 180: msg = "Illegal lat and/or lng, (%s, %s) provided." % (lat, lng) raise IllegalPointException(msg)
def _check_point(self, lat, lng): """ Checks if latitude and longitude correct """ if abs(lat) > 90 or abs(lng) > 180: msg = "Illegal lat and/or lng, (%s, %s) provided." % (lat, lng) raise IllegalPointException(msg)
[ "Checks", "if", "latitude", "and", "longitude", "correct" ]
e-dard/postcodes
python
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L123-L127
[ "def", "_check_point", "(", "self", ",", "lat", ",", "lng", ")", ":", "if", "abs", "(", "lat", ")", ">", "90", "or", "abs", "(", "lng", ")", ">", "180", ":", "msg", "=", "\"Illegal lat and/or lng, (%s, %s) provided.\"", "%", "(", "lat", ",", "lng", "...
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
train
PostCoder._lookup
Checks for cached responses, before requesting from web-service
postcodes.py
def _lookup(self, skip_cache, fun, *args, **kwargs): """ Checks for cached responses, before requesting from web-service """ if args not in self.cache or skip_cache: self.cache[args] = fun(*args, **kwargs) return self.cache[args]
def _lookup(self, skip_cache, fun, *args, **kwargs): """ Checks for cached responses, before requesting from web-service """ if args not in self.cache or skip_cache: self.cache[args] = fun(*args, **kwargs) return self.cache[args]
[ "Checks", "for", "cached", "responses", "before", "requesting", "from", "web", "-", "service" ]
e-dard/postcodes
python
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L129-L136
[ "def", "_lookup", "(", "self", ",", "skip_cache", ",", "fun", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", "not", "in", "self", ".", "cache", "or", "skip_cache", ":", "self", ".", "cache", "[", "args", "]", "=", "fun", "(", ...
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
train
PostCoder.get
Calls `postcodes.get` and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an explicit request. Given postcode data doesn't really change, it's unlike...
postcodes.py
def get(self, postcode, skip_cache=False): """ Calls `postcodes.get` and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an explicit request. Given postcode data...
def get(self, postcode, skip_cache=False): """ Calls `postcodes.get` and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an explicit request. Given postcode data...
[ "Calls", "postcodes", ".", "get", "and", "by", "default", "utilises", "a", "local", "cache", ".", ":", "param", "skip_cache", ":", "optional", "argument", "specifying", "whether", "to", "skip", "the", "cache", "and", "make", "an", "explicit", "request", ".",...
e-dard/postcodes
python
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L138-L150
[ "def", "get", "(", "self", ",", "postcode", ",", "skip_cache", "=", "False", ")", ":", "# remove spaces and change case here due to caching", "postcode", "=", "postcode", ".", "lower", "(", ")", ".", "replace", "(", "' '", ",", "''", ")", "return", "self", "...
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
train
PostCoder.get_nearest
Calls `postcodes.get_nearest` but checks correctness of `lat` and `long`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an explicit request. :raises IllegalPointException: if the latitude o...
postcodes.py
def get_nearest(self, lat, lng, skip_cache=False): """ Calls `postcodes.get_nearest` but checks correctness of `lat` and `long`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an exp...
def get_nearest(self, lat, lng, skip_cache=False): """ Calls `postcodes.get_nearest` but checks correctness of `lat` and `long`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an exp...
[ "Calls", "postcodes", ".", "get_nearest", "but", "checks", "correctness", "of", "lat", "and", "long", "and", "by", "default", "utilises", "a", "local", "cache", "." ]
e-dard/postcodes
python
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L152-L167
[ "def", "get_nearest", "(", "self", ",", "lat", ",", "lng", ",", "skip_cache", "=", "False", ")", ":", "lat", ",", "lng", "=", "float", "(", "lat", ")", ",", "float", "(", "lng", ")", "self", ".", "_check_point", "(", "lat", ",", "lng", ")", "retu...
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
train
PostCoder.get_from_postcode
Calls `postcodes.get_from_postcode` but checks correctness of `distance`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an explicit request. :raises IllegalPointException: if the latitude o...
postcodes.py
def get_from_postcode(self, postcode, distance, skip_cache=False): """ Calls `postcodes.get_from_postcode` but checks correctness of `distance`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache ...
def get_from_postcode(self, postcode, distance, skip_cache=False): """ Calls `postcodes.get_from_postcode` but checks correctness of `distance`, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache ...
[ "Calls", "postcodes", ".", "get_from_postcode", "but", "checks", "correctness", "of", "distance", "and", "by", "default", "utilises", "a", "local", "cache", "." ]
e-dard/postcodes
python
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L169-L189
[ "def", "get_from_postcode", "(", "self", ",", "postcode", ",", "distance", ",", "skip_cache", "=", "False", ")", ":", "distance", "=", "float", "(", "distance", ")", "if", "distance", "<", "0", ":", "raise", "IllegalDistanceException", "(", "\"Distance must no...
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
train
PostCoder.get_from_geo
Calls `postcodes.get_from_geo` but checks the correctness of all arguments, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and make an explicit request. :raises IllegalPointException: if the latitude...
postcodes.py
def get_from_geo(self, lat, lng, distance, skip_cache=False): """ Calls `postcodes.get_from_geo` but checks the correctness of all arguments, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and...
def get_from_geo(self, lat, lng, distance, skip_cache=False): """ Calls `postcodes.get_from_geo` but checks the correctness of all arguments, and by default utilises a local cache. :param skip_cache: optional argument specifying whether to skip the cache and...
[ "Calls", "postcodes", ".", "get_from_geo", "but", "checks", "the", "correctness", "of", "all", "arguments", "and", "by", "default", "utilises", "a", "local", "cache", "." ]
e-dard/postcodes
python
https://github.com/e-dard/postcodes/blob/d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005/postcodes.py#L191-L210
[ "def", "get_from_geo", "(", "self", ",", "lat", ",", "lng", ",", "distance", ",", "skip_cache", "=", "False", ")", ":", "# remove spaces and change case here due to caching", "lat", ",", "lng", ",", "distance", "=", "float", "(", "lat", ")", ",", "float", "(...
d63c47b4ecd765bc2e4e6ba34bc0b8a796f44005
train
insertions_from_masked
get coordinates of insertions from insertion-masked sequence
ctbBio/rRNA_insertions.py
def insertions_from_masked(seq): """ get coordinates of insertions from insertion-masked sequence """ insertions = [] prev = True for i, base in enumerate(seq): if base.isupper() and prev is True: insertions.append([]) prev = False elif base.islower(): ...
def insertions_from_masked(seq): """ get coordinates of insertions from insertion-masked sequence """ insertions = [] prev = True for i, base in enumerate(seq): if base.isupper() and prev is True: insertions.append([]) prev = False elif base.islower(): ...
[ "get", "coordinates", "of", "insertions", "from", "insertion", "-", "masked", "sequence" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L15-L28
[ "def", "insertions_from_masked", "(", "seq", ")", ":", "insertions", "=", "[", "]", "prev", "=", "True", "for", "i", ",", "base", "in", "enumerate", "(", "seq", ")", ":", "if", "base", ".", "isupper", "(", ")", "and", "prev", "is", "True", ":", "in...
83b2566b3a5745437ec651cd6cafddd056846240
train
analyze_fa
analyze fa (names, insertions) and convert fasta to prodigal/cmscan safe file - find insertions (masked sequence) - make upper case - assign names to id number
ctbBio/rRNA_insertions.py
def analyze_fa(fa): """ analyze fa (names, insertions) and convert fasta to prodigal/cmscan safe file - find insertions (masked sequence) - make upper case - assign names to id number """ if fa.name == '<stdin>': safe = 'temp.id' else: safe = '%s.id' % (fa.name) safe ...
def analyze_fa(fa): """ analyze fa (names, insertions) and convert fasta to prodigal/cmscan safe file - find insertions (masked sequence) - make upper case - assign names to id number """ if fa.name == '<stdin>': safe = 'temp.id' else: safe = '%s.id' % (fa.name) safe ...
[ "analyze", "fa", "(", "names", "insertions", ")", "and", "convert", "fasta", "to", "prodigal", "/", "cmscan", "safe", "file", "-", "find", "insertions", "(", "masked", "sequence", ")", "-", "make", "upper", "case", "-", "assign", "names", "to", "id", "nu...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L30-L62
[ "def", "analyze_fa", "(", "fa", ")", ":", "if", "fa", ".", "name", "==", "'<stdin>'", ":", "safe", "=", "'temp.id'", "else", ":", "safe", "=", "'%s.id'", "%", "(", "fa", ".", "name", ")", "safe", "=", "open", "(", "safe", ",", "'w'", ")", "sequen...
83b2566b3a5745437ec651cd6cafddd056846240
train
seq_info
get insertion information from header
ctbBio/rRNA_insertions.py
def seq_info(names, id2names, insertions, sequences): """ get insertion information from header """ seqs = {} # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] for name in names: id = id2names[name] gene = name.split('fromHMM::', 1)[0].rs...
def seq_info(names, id2names, insertions, sequences): """ get insertion information from header """ seqs = {} # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] for name in names: id = id2names[name] gene = name.split('fromHMM::', 1)[0].rs...
[ "get", "insertion", "information", "from", "header" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L64-L86
[ "def", "seq_info", "(", "names", ",", "id2names", ",", "insertions", ",", "sequences", ")", ":", "seqs", "=", "{", "}", "# seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]]", "for", "name", "in", "names", ":", "id", "=", "id...
83b2566b3a5745437ec651cd6cafddd056846240
train
check_overlap
make sure thresh % feature is contained within insertion
ctbBio/rRNA_insertions.py
def check_overlap(pos, ins, thresh): """ make sure thresh % feature is contained within insertion """ ins_pos = ins[0] ins_len = ins[2] ol = overlap(ins_pos, pos) feat_len = pos[1] - pos[0] + 1 # print float(ol) / float(feat_len) if float(ol) / float(feat_len) >= thresh: retur...
def check_overlap(pos, ins, thresh): """ make sure thresh % feature is contained within insertion """ ins_pos = ins[0] ins_len = ins[2] ol = overlap(ins_pos, pos) feat_len = pos[1] - pos[0] + 1 # print float(ol) / float(feat_len) if float(ol) / float(feat_len) >= thresh: retur...
[ "make", "sure", "thresh", "%", "feature", "is", "contained", "within", "insertion" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L91-L102
[ "def", "check_overlap", "(", "pos", ",", "ins", ",", "thresh", ")", ":", "ins_pos", "=", "ins", "[", "0", "]", "ins_len", "=", "ins", "[", "2", "]", "ol", "=", "overlap", "(", "ins_pos", ",", "pos", ")", "feat_len", "=", "pos", "[", "1", "]", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
find_orfs
find orfs and see if they overlap with insertions # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]]
ctbBio/rRNA_insertions.py
def find_orfs(fa, seqs): """ find orfs and see if they overlap with insertions # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] """ faa = '%s.prodigal.faa' % (fa) fna = '%s.prodigal.fna' % (fa) gbk = '%s.prodigal.gbk' % (fa) if os.path.exist...
def find_orfs(fa, seqs): """ find orfs and see if they overlap with insertions # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] """ faa = '%s.prodigal.faa' % (fa) fna = '%s.prodigal.fna' % (fa) gbk = '%s.prodigal.gbk' % (fa) if os.path.exist...
[ "find", "orfs", "and", "see", "if", "they", "overlap", "with", "insertions", "#", "seqs", "[", "id", "]", "=", "[", "gene", "model", "[[", "i", "-", "gene_pos", "i", "-", "model_pos", "i", "-", "length", "iseq", "[", "orfs", "]", "[", "introns", "]...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L104-L126
[ "def", "find_orfs", "(", "fa", ",", "seqs", ")", ":", "faa", "=", "'%s.prodigal.faa'", "%", "(", "fa", ")", "fna", "=", "'%s.prodigal.fna'", "%", "(", "fa", ")", "gbk", "=", "'%s.prodigal.gbk'", "%", "(", "fa", ")", "if", "os", ".", "path", ".", "e...
83b2566b3a5745437ec651cd6cafddd056846240
train
find_introns
find introns by searching Rfam intron databse using cmscan # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]]
ctbBio/rRNA_insertions.py
def find_introns(fa, seqs, sequences, threads): """ find introns by searching Rfam intron databse using cmscan # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] """ db = '%s/rfam/Rfam.cm.1_1.introns' % (os.environ['databases']) out = '%s.rfam-introns...
def find_introns(fa, seqs, sequences, threads): """ find introns by searching Rfam intron databse using cmscan # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] """ db = '%s/rfam/Rfam.cm.1_1.introns' % (os.environ['databases']) out = '%s.rfam-introns...
[ "find", "introns", "by", "searching", "Rfam", "intron", "databse", "using", "cmscan", "#", "seqs", "[", "id", "]", "=", "[", "gene", "model", "[[", "i", "-", "gene_pos", "i", "-", "model_pos", "i", "-", "length", "iseq", "[", "orfs", "]", "[", "intro...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L128-L156
[ "def", "find_introns", "(", "fa", ",", "seqs", ",", "sequences", ",", "threads", ")", ":", "db", "=", "'%s/rfam/Rfam.cm.1_1.introns'", "%", "(", "os", ".", "environ", "[", "'databases'", "]", ")", "out", "=", "'%s.rfam-introns.cmscan'", "%", "(", "fa", ")"...
83b2566b3a5745437ec651cd6cafddd056846240
train
annotate_orfs
search orfs against pfam # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?, {orf: annotations}], ...]]
ctbBio/rRNA_insertions.py
def annotate_orfs(fa, seqs, threads, threshold = 1e-6): """ search orfs against pfam # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?, {orf: annotations}], ...]] """ db = '%s/pfam/Pfam-A.hmm' % os.environ['databases'] base = fa.rsplit('.', ...
def annotate_orfs(fa, seqs, threads, threshold = 1e-6): """ search orfs against pfam # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?, {orf: annotations}], ...]] """ db = '%s/pfam/Pfam-A.hmm' % os.environ['databases'] base = fa.rsplit('.', ...
[ "search", "orfs", "against", "pfam", "#", "seqs", "[", "id", "]", "=", "[", "gene", "model", "[[", "i", "-", "gene_pos", "i", "-", "model_pos", "i", "-", "length", "iseq", "[", "orfs", "]", "[", "introns", "]", "orfs?", "introns?", "{", "orf", ":",...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L158-L195
[ "def", "annotate_orfs", "(", "fa", ",", "seqs", ",", "threads", ",", "threshold", "=", "1e-6", ")", ":", "db", "=", "'%s/pfam/Pfam-A.hmm'", "%", "os", ".", "environ", "[", "'databases'", "]", "base", "=", "fa", ".", "rsplit", "(", "'.'", ",", "1", ")...
83b2566b3a5745437ec651cd6cafddd056846240
train
analyze_insertions
- find ORFs using Prodigal - find introns using cmscan (vs Rfam intron database) - check that ORFs and intron overlap with insertion region - plot insertion length versus model position for each insertion (based on insertion type)
ctbBio/rRNA_insertions.py
def analyze_insertions(fa, threads = 6): """ - find ORFs using Prodigal - find introns using cmscan (vs Rfam intron database) - check that ORFs and intron overlap with insertion region - plot insertion length versus model position for each insertion (based on insertion type) """ safe, sequen...
def analyze_insertions(fa, threads = 6): """ - find ORFs using Prodigal - find introns using cmscan (vs Rfam intron database) - check that ORFs and intron overlap with insertion region - plot insertion length versus model position for each insertion (based on insertion type) """ safe, sequen...
[ "-", "find", "ORFs", "using", "Prodigal", "-", "find", "introns", "using", "cmscan", "(", "vs", "Rfam", "intron", "database", ")", "-", "check", "that", "ORFs", "and", "intron", "overlap", "with", "insertion", "region", "-", "plot", "insertion", "length", ...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L197-L210
[ "def", "analyze_insertions", "(", "fa", ",", "threads", "=", "6", ")", ":", "safe", ",", "sequences", ",", "id2name", ",", "names", ",", "insertions", "=", "analyze_fa", "(", "fa", ")", "seqs", "=", "seq_info", "(", "names", ",", "id2name", ",", "inser...
83b2566b3a5745437ec651cd6cafddd056846240
train
seqs2bool
convert orf and intron information to boolean # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?], ...]]
ctbBio/rRNA_insertions.py
def seqs2bool(seqs): """ convert orf and intron information to boolean # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?], ...]] """ for seq in s...
def seqs2bool(seqs): """ convert orf and intron information to boolean # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns]], ...]] # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?], ...]] """ for seq in s...
[ "convert", "orf", "and", "intron", "information", "to", "boolean", "#", "seqs", "[", "id", "]", "=", "[", "gene", "model", "[[", "i", "-", "gene_pos", "i", "-", "model_pos", "i", "-", "length", "iseq", "[", "orfs", "]", "[", "introns", "]]", "...", ...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L212-L229
[ "def", "seqs2bool", "(", "seqs", ")", ":", "for", "seq", "in", "seqs", ":", "for", "i", ",", "ins", "in", "enumerate", "(", "seqs", "[", "seq", "]", "[", "2", "]", ")", ":", "if", "len", "(", "ins", "[", "4", "]", ")", ">", "0", ":", "ins",...
83b2566b3a5745437ec651cd6cafddd056846240
train
print_table
print table of results # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?], ...]]
ctbBio/rRNA_insertions.py
def print_table(seqs, id2name, name): """ print table of results # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?], ...]] """ itable = open('%s.itable' % (name.rsplit('.', 1)[0]), 'w') print('\t'.join(['#sequence', 'gene', 'model', 'inserti...
def print_table(seqs, id2name, name): """ print table of results # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?], ...]] """ itable = open('%s.itable' % (name.rsplit('.', 1)[0]), 'w') print('\t'.join(['#sequence', 'gene', 'model', 'inserti...
[ "print", "table", "of", "results", "#", "seqs", "[", "id", "]", "=", "[", "gene", "model", "[[", "i", "-", "gene_pos", "i", "-", "model_pos", "i", "-", "length", "iseq", "[", "orfs", "]", "[", "introns", "]", "orfs?", "introns?", "]", "...", "]]" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L231-L261
[ "def", "print_table", "(", "seqs", ",", "id2name", ",", "name", ")", ":", "itable", "=", "open", "(", "'%s.itable'", "%", "(", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "[", "0", "]", ")", ",", "'w'", ")", "print", "(", "'\\t'", ".", "j...
83b2566b3a5745437ec651cd6cafddd056846240
train
print_seqs
print fasta of introns and ORFs # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?, [orf annotations]], ...]]
ctbBio/rRNA_insertions.py
def print_seqs(seqs, id2name, name): """ print fasta of introns and ORFs # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?, [orf annotations]], ...]] """ orfs = open('%s.orfs.faa' % (name.rsplit('.', 1)[0]), 'w') introns = open('%s.introns.f...
def print_seqs(seqs, id2name, name): """ print fasta of introns and ORFs # seqs[id] = [gene, model, [[i-gene_pos, i-model_pos, i-length, iseq, [orfs], [introns], orfs?, introns?, [orf annotations]], ...]] """ orfs = open('%s.orfs.faa' % (name.rsplit('.', 1)[0]), 'w') introns = open('%s.introns.f...
[ "print", "fasta", "of", "introns", "and", "ORFs", "#", "seqs", "[", "id", "]", "=", "[", "gene", "model", "[[", "i", "-", "gene_pos", "i", "-", "model_pos", "i", "-", "length", "iseq", "[", "orfs", "]", "[", "introns", "]", "orfs?", "introns?", "["...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L263-L303
[ "def", "print_seqs", "(", "seqs", ",", "id2name", ",", "name", ")", ":", "orfs", "=", "open", "(", "'%s.orfs.faa'", "%", "(", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "[", "0", "]", ")", ",", "'w'", ")", "introns", "=", "open", "(", "'...
83b2566b3a5745437ec651cd6cafddd056846240
train
max_insertion
length of largest insertion
ctbBio/rRNA_insertions.py
def max_insertion(seqs, gene, domain): """ length of largest insertion """ seqs = [i[2] for i in list(seqs.values()) if i[2] != [] and i[0] == gene and i[1] == domain] lengths = [] for seq in seqs: for ins in seq: lengths.append(int(ins[2])) if lengths == []: retu...
def max_insertion(seqs, gene, domain): """ length of largest insertion """ seqs = [i[2] for i in list(seqs.values()) if i[2] != [] and i[0] == gene and i[1] == domain] lengths = [] for seq in seqs: for ins in seq: lengths.append(int(ins[2])) if lengths == []: retu...
[ "length", "of", "largest", "insertion" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L305-L316
[ "def", "max_insertion", "(", "seqs", ",", "gene", ",", "domain", ")", ":", "seqs", "=", "[", "i", "[", "2", "]", "for", "i", "in", "list", "(", "seqs", ".", "values", "(", ")", ")", "if", "i", "[", "2", "]", "!=", "[", "]", "and", "i", "[",...
83b2566b3a5745437ec651cd6cafddd056846240
train
model_length
get length of model
ctbBio/rRNA_insertions.py
def model_length(gene, domain): """ get length of model """ if gene == '16S': domain2max = {'E_coli_K12': int(1538), 'bacteria': int(1689), 'archaea': int(1563), 'eukarya': int(2652)} return domain2max[domain] elif gene == '23S': domain2max = {'E_coli_K12': int(2903), 'bacter...
def model_length(gene, domain): """ get length of model """ if gene == '16S': domain2max = {'E_coli_K12': int(1538), 'bacteria': int(1689), 'archaea': int(1563), 'eukarya': int(2652)} return domain2max[domain] elif gene == '23S': domain2max = {'E_coli_K12': int(2903), 'bacter...
[ "get", "length", "of", "model" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L318-L330
[ "def", "model_length", "(", "gene", ",", "domain", ")", ":", "if", "gene", "==", "'16S'", ":", "domain2max", "=", "{", "'E_coli_K12'", ":", "int", "(", "1538", ")", ",", "'bacteria'", ":", "int", "(", "1689", ")", ",", "'archaea'", ":", "int", "(", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
setup_markers
setup unique marker for every orf annotation - change size if necessary
ctbBio/rRNA_insertions.py
def setup_markers(seqs): """ setup unique marker for every orf annotation - change size if necessary """ family2marker = {} # family2marker[family] = [marker, size] markers = cycle(['^', 'p', '*', '+', 'x', 'd', '|', 'v', '>', '<', '8']) size = 60 families = [] for seq in list(seqs.v...
def setup_markers(seqs): """ setup unique marker for every orf annotation - change size if necessary """ family2marker = {} # family2marker[family] = [marker, size] markers = cycle(['^', 'p', '*', '+', 'x', 'd', '|', 'v', '>', '<', '8']) size = 60 families = [] for seq in list(seqs.v...
[ "setup", "unique", "marker", "for", "every", "orf", "annotation", "-", "change", "size", "if", "necessary" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L332-L351
[ "def", "setup_markers", "(", "seqs", ")", ":", "family2marker", "=", "{", "}", "# family2marker[family] = [marker, size]", "markers", "=", "cycle", "(", "[", "'^'", ",", "'p'", ",", "'*'", ",", "'+'", ",", "'x'", ",", "'d'", ",", "'|'", ",", "'v'", ",", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
plot_insertions
plot insertions wrt model positions 2 panels: 1. insertions with ORF - triangle if has intron - circle if no intron 2. insertion does not have ORF - triangle if has intron - circle if no intron *3. conservation of sequence in model *4. ...
ctbBio/rRNA_insertions.py
def plot_insertions(fname, seqs, gene, domain, tax, id2name): """ plot insertions wrt model positions 2 panels: 1. insertions with ORF - triangle if has intron - circle if no intron 2. insertion does not have ORF - triangle if has intron - circ...
def plot_insertions(fname, seqs, gene, domain, tax, id2name): """ plot insertions wrt model positions 2 panels: 1. insertions with ORF - triangle if has intron - circle if no intron 2. insertion does not have ORF - triangle if has intron - circ...
[ "plot", "insertions", "wrt", "model", "positions", "2", "panels", ":", "1", ".", "insertions", "with", "ORF", "-", "triangle", "if", "has", "intron", "-", "circle", "if", "no", "intron", "2", ".", "insertion", "does", "not", "have", "ORF", "-", "triangle...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L353-L463
[ "def", "plot_insertions", "(", "fname", ",", "seqs", ",", "gene", ",", "domain", ",", "tax", ",", "id2name", ")", ":", "# import", "import", "matplotlib", "import", "matplotlib", ".", "pyplot", "as", "plt", "import", "numpy", "as", "np", "from", "matplotli...
83b2566b3a5745437ec651cd6cafddd056846240
train
plot_by_gene_and_domain
plot insertions for each gene and domain
ctbBio/rRNA_insertions.py
def plot_by_gene_and_domain(name, seqs, tax, id2name): """ plot insertions for each gene and domain """ for gene in set([seq[0] for seq in list(seqs.values())]): for domain in set([seq[1] for seq in list(seqs.values())]): plot_insertions(name, seqs, gene, domain, tax, id2name)
def plot_by_gene_and_domain(name, seqs, tax, id2name): """ plot insertions for each gene and domain """ for gene in set([seq[0] for seq in list(seqs.values())]): for domain in set([seq[1] for seq in list(seqs.values())]): plot_insertions(name, seqs, gene, domain, tax, id2name)
[ "plot", "insertions", "for", "each", "gene", "and", "domain" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_insertions.py#L551-L557
[ "def", "plot_by_gene_and_domain", "(", "name", ",", "seqs", ",", "tax", ",", "id2name", ")", ":", "for", "gene", "in", "set", "(", "[", "seq", "[", "0", "]", "for", "seq", "in", "list", "(", "seqs", ".", "values", "(", ")", ")", "]", ")", ":", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
normalize_bit
normalize the bit score: normalization factor = average max bit score for the two ORFs normalized = bit score / normalization factor
ctbBio/neto.py
def normalize_bit(A, B, bit, id2desc): """ normalize the bit score: normalization factor = average max bit score for the two ORFs normalized = bit score / normalization factor """ Amax, Bmax = id2desc[A][-1], id2desc[B][-1] norm_factor = float(numpy.average([Amax, Bmax])) normalized = bi...
def normalize_bit(A, B, bit, id2desc): """ normalize the bit score: normalization factor = average max bit score for the two ORFs normalized = bit score / normalization factor """ Amax, Bmax = id2desc[A][-1], id2desc[B][-1] norm_factor = float(numpy.average([Amax, Bmax])) normalized = bi...
[ "normalize", "the", "bit", "score", ":", "normalization", "factor", "=", "average", "max", "bit", "score", "for", "the", "two", "ORFs", "normalized", "=", "bit", "score", "/", "normalization", "factor" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L26-L35
[ "def", "normalize_bit", "(", "A", ",", "B", ",", "bit", ",", "id2desc", ")", ":", "Amax", ",", "Bmax", "=", "id2desc", "[", "A", "]", "[", "-", "1", "]", ",", "id2desc", "[", "B", "]", "[", "-", "1", "]", "norm_factor", "=", "float", "(", "nu...
83b2566b3a5745437ec651cd6cafddd056846240
train
get_descriptions
get the description for each ORF
ctbBio/neto.py
def get_descriptions(fastas): """ get the description for each ORF """ id2desc = {} for fasta in fastas: for seq in parse_fasta(fasta): header = seq[0].split('>')[1].split(' ') id = header[0] if len(header) > 1: desc = ' '.join(header[1:])...
def get_descriptions(fastas): """ get the description for each ORF """ id2desc = {} for fasta in fastas: for seq in parse_fasta(fasta): header = seq[0].split('>')[1].split(' ') id = header[0] if len(header) > 1: desc = ' '.join(header[1:])...
[ "get", "the", "description", "for", "each", "ORF" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L37-L52
[ "def", "get_descriptions", "(", "fastas", ")", ":", "id2desc", "=", "{", "}", "for", "fasta", "in", "fastas", ":", "for", "seq", "in", "parse_fasta", "(", "fasta", ")", ":", "header", "=", "seq", "[", "0", "]", ".", "split", "(", "'>'", ")", "[", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
print_genome_matrix
optimize later? slow ... should combine with calculate_threshold module
ctbBio/neto.py
def print_genome_matrix(hits, fastas, id2desc, file_name): """ optimize later? slow ... should combine with calculate_threshold module """ out = open(file_name, 'w') fastas = sorted(fastas) print('## percent identity between genomes', file=out) print('# - \t %s' % ('\t'.join(fastas)), fi...
def print_genome_matrix(hits, fastas, id2desc, file_name): """ optimize later? slow ... should combine with calculate_threshold module """ out = open(file_name, 'w') fastas = sorted(fastas) print('## percent identity between genomes', file=out) print('# - \t %s' % ('\t'.join(fastas)), fi...
[ "optimize", "later?", "slow", "...", "should", "combine", "with", "calculate_threshold", "module" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L140-L171
[ "def", "print_genome_matrix", "(", "hits", ",", "fastas", ",", "id2desc", ",", "file_name", ")", ":", "out", "=", "open", "(", "file_name", ",", "'w'", ")", "fastas", "=", "sorted", "(", "fastas", ")", "print", "(", "'## percent identity between genomes'", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
self_compare
compare genome to self to get the best possible bit score for each ORF
ctbBio/neto.py
def self_compare(fastas, id2desc, algorithm): """ compare genome to self to get the best possible bit score for each ORF """ for fasta in fastas: blast = open(search(fasta, fasta, method = algorithm, alignment = 'local')) for hit in best_blast(blast, 1): id, bit = hit[0].spli...
def self_compare(fastas, id2desc, algorithm): """ compare genome to self to get the best possible bit score for each ORF """ for fasta in fastas: blast = open(search(fasta, fasta, method = algorithm, alignment = 'local')) for hit in best_blast(blast, 1): id, bit = hit[0].spli...
[ "compare", "genome", "to", "self", "to", "get", "the", "best", "possible", "bit", "score", "for", "each", "ORF" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L240-L249
[ "def", "self_compare", "(", "fastas", ",", "id2desc", ",", "algorithm", ")", ":", "for", "fasta", "in", "fastas", ":", "blast", "=", "open", "(", "search", "(", "fasta", ",", "fasta", ",", "method", "=", "algorithm", ",", "alignment", "=", "'local'", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
compare_genomes
make all pairwise genome comparisons to get rbhs rbh = {genome: {other_genome: {rbh_id: [rbh_match, pident, e, bit, norm_bit]]}}
ctbBio/neto.py
def compare_genomes(fastas, id2desc, algorithm): """ make all pairwise genome comparisons to get rbhs rbh = {genome: {other_genome: {rbh_id: [rbh_match, pident, e, bit, norm_bit]]}} """ hits = {} for pair in itertools.permutations(fastas, 2): if pair[0] not in hits: hits[pair...
def compare_genomes(fastas, id2desc, algorithm): """ make all pairwise genome comparisons to get rbhs rbh = {genome: {other_genome: {rbh_id: [rbh_match, pident, e, bit, norm_bit]]}} """ hits = {} for pair in itertools.permutations(fastas, 2): if pair[0] not in hits: hits[pair...
[ "make", "all", "pairwise", "genome", "comparisons", "to", "get", "rbhs", "rbh", "=", "{", "genome", ":", "{", "other_genome", ":", "{", "rbh_id", ":", "[", "rbh_match", "pident", "e", "bit", "norm_bit", "]]", "}}" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L251-L274
[ "def", "compare_genomes", "(", "fastas", ",", "id2desc", ",", "algorithm", ")", ":", "hits", "=", "{", "}", "for", "pair", "in", "itertools", ".", "permutations", "(", "fastas", ",", "2", ")", ":", "if", "pair", "[", "0", "]", "not", "in", "hits", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
calc_thresholds
if thresholds are not specififed, calculate based on the distribution of normalized bit scores
ctbBio/neto.py
def calc_thresholds(rbh, file_name, thresholds = [False, False, False, False], stdevs = 2): """ if thresholds are not specififed, calculate based on the distribution of normalized bit scores """ calc_threshold = thresholds[-1] norm_threshold = {} for pair in itertools.permutations([i for i in rb...
def calc_thresholds(rbh, file_name, thresholds = [False, False, False, False], stdevs = 2): """ if thresholds are not specififed, calculate based on the distribution of normalized bit scores """ calc_threshold = thresholds[-1] norm_threshold = {} for pair in itertools.permutations([i for i in rb...
[ "if", "thresholds", "are", "not", "specififed", "calculate", "based", "on", "the", "distribution", "of", "normalized", "bit", "scores" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L303-L352
[ "def", "calc_thresholds", "(", "rbh", ",", "file_name", ",", "thresholds", "=", "[", "False", ",", "False", ",", "False", ",", "False", "]", ",", "stdevs", "=", "2", ")", ":", "calc_threshold", "=", "thresholds", "[", "-", "1", "]", "norm_threshold", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
rbh_network
make the network based on rbhs and score thresholds
ctbBio/neto.py
def rbh_network(id2desc, rbh, file_name, thresholds = [False, False, False, False]): """ make the network based on rbhs and score thresholds """ g = nx.Graph() # network graph for storing rbhs filtered = {} e_thresh, bit_thresh, length_thresh, norm_thresh = thresholds for genome in rbh: ...
def rbh_network(id2desc, rbh, file_name, thresholds = [False, False, False, False]): """ make the network based on rbhs and score thresholds """ g = nx.Graph() # network graph for storing rbhs filtered = {} e_thresh, bit_thresh, length_thresh, norm_thresh = thresholds for genome in rbh: ...
[ "make", "the", "network", "based", "on", "rbhs", "and", "score", "thresholds" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L354-L414
[ "def", "rbh_network", "(", "id2desc", ",", "rbh", ",", "file_name", ",", "thresholds", "=", "[", "False", ",", "False", ",", "False", ",", "False", "]", ")", ":", "g", "=", "nx", ".", "Graph", "(", ")", "# network graph for storing rbhs", "filtered", "="...
83b2566b3a5745437ec651cd6cafddd056846240
train
neto
make and split a rbh network
ctbBio/neto.py
def neto(fastas, algorithm = 'usearch', e = 0.01, bit = 40, length = .65, norm_bit = False): """ make and split a rbh network """ thresholds = [e, bit, length, norm_bit] id2desc = get_descriptions(fastas) # get [fasta, description, length] for ORF id id2desc = self_compare(fastas, id...
def neto(fastas, algorithm = 'usearch', e = 0.01, bit = 40, length = .65, norm_bit = False): """ make and split a rbh network """ thresholds = [e, bit, length, norm_bit] id2desc = get_descriptions(fastas) # get [fasta, description, length] for ORF id id2desc = self_compare(fastas, id...
[ "make", "and", "split", "a", "rbh", "network" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L416-L445
[ "def", "neto", "(", "fastas", ",", "algorithm", "=", "'usearch'", ",", "e", "=", "0.01", ",", "bit", "=", "40", ",", "length", "=", ".65", ",", "norm_bit", "=", "False", ")", ":", "thresholds", "=", "[", "e", ",", "bit", ",", "length", ",", "norm...
83b2566b3a5745437ec651cd6cafddd056846240
train
network
make a rbh network for all pair-wise genome comparisons - filter network based on normalized bit score (default, automatic) or specified e-value / bit score - evaluate the scores for each genome pair compared - build second network that is filtered so that clusters have only one ORF per genome - evaluat...
ctbBio/neto.py
def network(thresholds, fastas, algorithm = 'usearch'): """ make a rbh network for all pair-wise genome comparisons - filter network based on normalized bit score (default, automatic) or specified e-value / bit score - evaluate the scores for each genome pair compared - build second network that is ...
def network(thresholds, fastas, algorithm = 'usearch'): """ make a rbh network for all pair-wise genome comparisons - filter network based on normalized bit score (default, automatic) or specified e-value / bit score - evaluate the scores for each genome pair compared - build second network that is ...
[ "make", "a", "rbh", "network", "for", "all", "pair", "-", "wise", "genome", "comparisons", "-", "filter", "network", "based", "on", "normalized", "bit", "score", "(", "default", "automatic", ")", "or", "specified", "e", "-", "value", "/", "bit", "score", ...
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/neto.py#L447-L481
[ "def", "network", "(", "thresholds", ",", "fastas", ",", "algorithm", "=", "'usearch'", ")", ":", "id2desc", "=", "get_descriptions", "(", "fastas", ")", "# get [fasta, description, length] for ORF id", "id2desc", "=", "self_compare", "(", "fastas", ",", "id2desc", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
user_specific_data_directory
Returns the subdirectory in `userdata` which acts as the root of the user-specific filesystem in Steam (aka all user-specific files are stored under this directory)
pysteam/paths.py
def user_specific_data_directory(user_context): """Returns the subdirectory in `userdata` which acts as the root of the user-specific filesystem in Steam (aka all user-specific files are stored under this directory)""" return os.path.join( user_context.steam.userdata_directory, user_context.user_id )
def user_specific_data_directory(user_context): """Returns the subdirectory in `userdata` which acts as the root of the user-specific filesystem in Steam (aka all user-specific files are stored under this directory)""" return os.path.join( user_context.steam.userdata_directory, user_context.user_id )
[ "Returns", "the", "subdirectory", "in", "userdata", "which", "acts", "as", "the", "root", "of", "the", "user", "-", "specific", "filesystem", "in", "Steam", "(", "aka", "all", "user", "-", "specific", "files", "are", "stored", "under", "this", "directory", ...
scottrice/pysteam
python
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/paths.py#L48-L55
[ "def", "user_specific_data_directory", "(", "user_context", ")", ":", "return", "os", ".", "path", ".", "join", "(", "user_context", ".", "steam", ".", "userdata_directory", ",", "user_context", ".", "user_id", ")" ]
1eb2254b5235a053a953e596fa7602d0b110245d
train
IsoParser._init_data_map
OVERRIDDEN: Initialize required ISO-19115 data map with XPATHS and specialized functions
gis_metadata/iso_metadata_parser.py
def _init_data_map(self): """ OVERRIDDEN: Initialize required ISO-19115 data map with XPATHS and specialized functions """ if self._data_map is not None: return # Initiation happens once # Parse and validate the ISO metadata root if self._xml_tree is None: iso...
def _init_data_map(self): """ OVERRIDDEN: Initialize required ISO-19115 data map with XPATHS and specialized functions """ if self._data_map is not None: return # Initiation happens once # Parse and validate the ISO metadata root if self._xml_tree is None: iso...
[ "OVERRIDDEN", ":", "Initialize", "required", "ISO", "-", "19115", "data", "map", "with", "XPATHS", "and", "specialized", "functions" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L196-L353
[ "def", "_init_data_map", "(", "self", ")", ":", "if", "self", ".", "_data_map", "is", "not", "None", ":", "return", "# Initiation happens once", "# Parse and validate the ISO metadata root", "if", "self", ".", "_xml_tree", "is", "None", ":", "iso_root", "=", "ISO_...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._parse_attribute_details
Concatenates a list of Attribute Details data structures parsed from a remote file
gis_metadata/iso_metadata_parser.py
def _parse_attribute_details(self, prop=ATTRIBUTES): """ Concatenates a list of Attribute Details data structures parsed from a remote file """ parsed_attributes = self._parse_attribute_details_file(prop) if parsed_attributes is None: # If not in the (official) remote location, try ...
def _parse_attribute_details(self, prop=ATTRIBUTES): """ Concatenates a list of Attribute Details data structures parsed from a remote file """ parsed_attributes = self._parse_attribute_details_file(prop) if parsed_attributes is None: # If not in the (official) remote location, try ...
[ "Concatenates", "a", "list", "of", "Attribute", "Details", "data", "structures", "parsed", "from", "a", "remote", "file" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L355-L367
[ "def", "_parse_attribute_details", "(", "self", ",", "prop", "=", "ATTRIBUTES", ")", ":", "parsed_attributes", "=", "self", ".", "_parse_attribute_details_file", "(", "prop", ")", "if", "parsed_attributes", "is", "None", ":", "# If not in the (official) remote location,...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._parse_attribute_details_file
Concatenates a list of Attribute Details data structures parsed from a remote file
gis_metadata/iso_metadata_parser.py
def _parse_attribute_details_file(self, prop=ATTRIBUTES): """ Concatenates a list of Attribute Details data structures parsed from a remote file """ # Parse content from remote file URL, which may be stored in one of two places: # Starting at: contentInfo/MD_FeatureCatalogueDescription/featu...
def _parse_attribute_details_file(self, prop=ATTRIBUTES): """ Concatenates a list of Attribute Details data structures parsed from a remote file """ # Parse content from remote file URL, which may be stored in one of two places: # Starting at: contentInfo/MD_FeatureCatalogueDescription/featu...
[ "Concatenates", "a", "list", "of", "Attribute", "Details", "data", "structures", "parsed", "from", "a", "remote", "file" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L369-L392
[ "def", "_parse_attribute_details_file", "(", "self", ",", "prop", "=", "ATTRIBUTES", ")", ":", "# Parse content from remote file URL, which may be stored in one of two places:", "# Starting at: contentInfo/MD_FeatureCatalogueDescription/featureCatalogueCitation", "# ATTRIBUTE: href", ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._parse_digital_forms
Concatenates a list of Digital Form data structures parsed from the metadata
gis_metadata/iso_metadata_parser.py
def _parse_digital_forms(self, prop=DIGITAL_FORMS): """ Concatenates a list of Digital Form data structures parsed from the metadata """ xpath_map = self._data_structures[prop] # Parse base digital form fields: 'name', 'content', 'decompression', 'version', 'specification' xpath_root =...
def _parse_digital_forms(self, prop=DIGITAL_FORMS): """ Concatenates a list of Digital Form data structures parsed from the metadata """ xpath_map = self._data_structures[prop] # Parse base digital form fields: 'name', 'content', 'decompression', 'version', 'specification' xpath_root =...
[ "Concatenates", "a", "list", "of", "Digital", "Form", "data", "structures", "parsed", "from", "the", "metadata" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L394-L451
[ "def", "_parse_digital_forms", "(", "self", ",", "prop", "=", "DIGITAL_FORMS", ")", ":", "xpath_map", "=", "self", ".", "_data_structures", "[", "prop", "]", "# Parse base digital form fields: 'name', 'content', 'decompression', 'version', 'specification'", "xpath_root", "=",...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._parse_keywords
Parse type-specific keywords from the metadata: Theme or Place
gis_metadata/iso_metadata_parser.py
def _parse_keywords(self, prop): """ Parse type-specific keywords from the metadata: Theme or Place """ keywords = [] if prop in KEYWORD_PROPS: xpath_root = self._data_map['_keywords_root'] xpath_map = self._data_structures[prop] xtype = xpath_map['keyword_...
def _parse_keywords(self, prop): """ Parse type-specific keywords from the metadata: Theme or Place """ keywords = [] if prop in KEYWORD_PROPS: xpath_root = self._data_map['_keywords_root'] xpath_map = self._data_structures[prop] xtype = xpath_map['keyword_...
[ "Parse", "type", "-", "specific", "keywords", "from", "the", "metadata", ":", "Theme", "or", "Place" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L453-L470
[ "def", "_parse_keywords", "(", "self", ",", "prop", ")", ":", "keywords", "=", "[", "]", "if", "prop", "in", "KEYWORD_PROPS", ":", "xpath_root", "=", "self", ".", "_data_map", "[", "'_keywords_root'", "]", "xpath_map", "=", "self", ".", "_data_structures", ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._parse_raster_info
Collapses multiple dimensions into a single raster_info complex struct
gis_metadata/iso_metadata_parser.py
def _parse_raster_info(self, prop=RASTER_INFO): """ Collapses multiple dimensions into a single raster_info complex struct """ raster_info = {}.fromkeys(_iso_definitions[prop], u'') # Ensure conversion of lists to newlines is in place raster_info['dimensions'] = get_default_for_complex...
def _parse_raster_info(self, prop=RASTER_INFO): """ Collapses multiple dimensions into a single raster_info complex struct """ raster_info = {}.fromkeys(_iso_definitions[prop], u'') # Ensure conversion of lists to newlines is in place raster_info['dimensions'] = get_default_for_complex...
[ "Collapses", "multiple", "dimensions", "into", "a", "single", "raster_info", "complex", "struct" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L472-L502
[ "def", "_parse_raster_info", "(", "self", ",", "prop", "=", "RASTER_INFO", ")", ":", "raster_info", "=", "{", "}", ".", "fromkeys", "(", "_iso_definitions", "[", "prop", "]", ",", "u''", ")", "# Ensure conversion of lists to newlines is in place", "raster_info", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._update_attribute_details
Update operation for ISO Attribute Details metadata: write to "MD_Metadata/featureType"
gis_metadata/iso_metadata_parser.py
def _update_attribute_details(self, **update_props): """ Update operation for ISO Attribute Details metadata: write to "MD_Metadata/featureType" """ tree_to_update = update_props['tree_to_update'] xpath = self._data_map['_attr_citation'] # Cannot write to remote file: remove the featur...
def _update_attribute_details(self, **update_props): """ Update operation for ISO Attribute Details metadata: write to "MD_Metadata/featureType" """ tree_to_update = update_props['tree_to_update'] xpath = self._data_map['_attr_citation'] # Cannot write to remote file: remove the featur...
[ "Update", "operation", "for", "ISO", "Attribute", "Details", "metadata", ":", "write", "to", "MD_Metadata", "/", "featureType" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L504-L515
[ "def", "_update_attribute_details", "(", "self", ",", "*", "*", "update_props", ")", ":", "tree_to_update", "=", "update_props", "[", "'tree_to_update'", "]", "xpath", "=", "self", ".", "_data_map", "[", "'_attr_citation'", "]", "# Cannot write to remote file: remove ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._update_digital_forms
Update operation for ISO Digital Forms metadata :see: gis_metadata.utils._complex_definitions[DIGITAL_FORMS]
gis_metadata/iso_metadata_parser.py
def _update_digital_forms(self, **update_props): """ Update operation for ISO Digital Forms metadata :see: gis_metadata.utils._complex_definitions[DIGITAL_FORMS] """ digital_forms = wrap_value(update_props['values']) # Update all Digital Form properties: distributionFor...
def _update_digital_forms(self, **update_props): """ Update operation for ISO Digital Forms metadata :see: gis_metadata.utils._complex_definitions[DIGITAL_FORMS] """ digital_forms = wrap_value(update_props['values']) # Update all Digital Form properties: distributionFor...
[ "Update", "operation", "for", "ISO", "Digital", "Forms", "metadata", ":", "see", ":", "gis_metadata", ".", "utils", ".", "_complex_definitions", "[", "DIGITAL_FORMS", "]" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L539-L590
[ "def", "_update_digital_forms", "(", "self", ",", "*", "*", "update_props", ")", ":", "digital_forms", "=", "wrap_value", "(", "update_props", "[", "'values'", "]", ")", "# Update all Digital Form properties: distributionFormat*", "xpath_map", "=", "self", ".", "_data...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._update_keywords
Update operation for ISO type-specific Keywords metadata: Theme or Place
gis_metadata/iso_metadata_parser.py
def _update_keywords(self, **update_props): """ Update operation for ISO type-specific Keywords metadata: Theme or Place """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = update_props['values'] keywords = [] if prop in KEYWORD_PRO...
def _update_keywords(self, **update_props): """ Update operation for ISO type-specific Keywords metadata: Theme or Place """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = update_props['values'] keywords = [] if prop in KEYWORD_PRO...
[ "Update", "operation", "for", "ISO", "type", "-", "specific", "Keywords", "metadata", ":", "Theme", "or", "Place" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L592-L620
[ "def", "_update_keywords", "(", "self", ",", "*", "*", "update_props", ")", ":", "tree_to_update", "=", "update_props", "[", "'tree_to_update'", "]", "prop", "=", "update_props", "[", "'prop'", "]", "values", "=", "update_props", "[", "'values'", "]", "keyword...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._update_raster_info
Derives multiple dimensions from a single raster_info complex struct
gis_metadata/iso_metadata_parser.py
def _update_raster_info(self, **update_props): """ Derives multiple dimensions from a single raster_info complex struct """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = update_props.pop('values') # Update number of dimensions at raster_in...
def _update_raster_info(self, **update_props): """ Derives multiple dimensions from a single raster_info complex struct """ tree_to_update = update_props['tree_to_update'] prop = update_props['prop'] values = update_props.pop('values') # Update number of dimensions at raster_in...
[ "Derives", "multiple", "dimensions", "from", "a", "single", "raster_info", "complex", "struct" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L622-L666
[ "def", "_update_raster_info", "(", "self", ",", "*", "*", "update_props", ")", ":", "tree_to_update", "=", "update_props", "[", "'tree_to_update'", "]", "prop", "=", "update_props", "[", "'prop'", "]", "values", "=", "update_props", ".", "pop", "(", "'values'"...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser.update
OVERRIDDEN: Prevents writing multiple CharacterStrings per XPATH property
gis_metadata/iso_metadata_parser.py
def update(self, use_template=False, **metadata_defaults): """ OVERRIDDEN: Prevents writing multiple CharacterStrings per XPATH property """ self.validate() tree_to_update = self._xml_tree if not use_template else self._get_template(**metadata_defaults) supported_props = self._metadata...
def update(self, use_template=False, **metadata_defaults): """ OVERRIDDEN: Prevents writing multiple CharacterStrings per XPATH property """ self.validate() tree_to_update = self._xml_tree if not use_template else self._get_template(**metadata_defaults) supported_props = self._metadata...
[ "OVERRIDDEN", ":", "Prevents", "writing", "multiple", "CharacterStrings", "per", "XPATH", "property" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L668-L689
[ "def", "update", "(", "self", ",", "use_template", "=", "False", ",", "*", "*", "metadata_defaults", ")", ":", "self", ".", "validate", "(", ")", "tree_to_update", "=", "self", ".", "_xml_tree", "if", "not", "use_template", "else", "self", ".", "_get_templ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
IsoParser._trim_xpath
Removes primitive type tags from an XPATH
gis_metadata/iso_metadata_parser.py
def _trim_xpath(self, xpath, prop): """ Removes primitive type tags from an XPATH """ xroot = self._get_xroot_for(prop) if xroot is None and isinstance(xpath, string_types): xtags = xpath.split(XPATH_DELIM) if xtags[-1] in _iso_tag_primitives: xroot = X...
def _trim_xpath(self, xpath, prop): """ Removes primitive type tags from an XPATH """ xroot = self._get_xroot_for(prop) if xroot is None and isinstance(xpath, string_types): xtags = xpath.split(XPATH_DELIM) if xtags[-1] in _iso_tag_primitives: xroot = X...
[ "Removes", "primitive", "type", "tags", "from", "an", "XPATH" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/iso_metadata_parser.py#L691-L702
[ "def", "_trim_xpath", "(", "self", ",", "xpath", ",", "prop", ")", ":", "xroot", "=", "self", ".", "_get_xroot_for", "(", "prop", ")", "if", "xroot", "is", "None", "and", "isinstance", "(", "xpath", ",", "string_types", ")", ":", "xtags", "=", "xpath",...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
shortcut_app_id
Generates the app id for a given shortcut. Steam uses app ids as a unique identifier for games, but since shortcuts dont have a canonical serverside representation they need to be generated on the fly. The important part about this function is that it will generate the same app id as Steam does for a given shor...
pysteam/shortcuts.py
def shortcut_app_id(shortcut): """ Generates the app id for a given shortcut. Steam uses app ids as a unique identifier for games, but since shortcuts dont have a canonical serverside representation they need to be generated on the fly. The important part about this function is that it will generate the same ...
def shortcut_app_id(shortcut): """ Generates the app id for a given shortcut. Steam uses app ids as a unique identifier for games, but since shortcuts dont have a canonical serverside representation they need to be generated on the fly. The important part about this function is that it will generate the same ...
[ "Generates", "the", "app", "id", "for", "a", "given", "shortcut", ".", "Steam", "uses", "app", "ids", "as", "a", "unique", "identifier", "for", "games", "but", "since", "shortcuts", "dont", "have", "a", "canonical", "serverside", "representation", "they", "n...
scottrice/pysteam
python
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/shortcuts.py#L9-L21
[ "def", "shortcut_app_id", "(", "shortcut", ")", ":", "algorithm", "=", "Crc", "(", "width", "=", "32", ",", "poly", "=", "0x04C11DB7", ",", "reflect_in", "=", "True", ",", "xor_in", "=", "0xffffffff", ",", "reflect_out", "=", "True", ",", "xor_out", "=",...
1eb2254b5235a053a953e596fa7602d0b110245d
train
VCS._config
Execute git config.
bootstrap_py/vcs.py
def _config(self): """Execute git config.""" cfg_wr = self.repo.config_writer() cfg_wr.add_section('user') cfg_wr.set_value('user', 'name', self.metadata.author) cfg_wr.set_value('user', 'email', self.metadata.email) cfg_wr.release()
def _config(self): """Execute git config.""" cfg_wr = self.repo.config_writer() cfg_wr.add_section('user') cfg_wr.set_value('user', 'name', self.metadata.author) cfg_wr.set_value('user', 'email', self.metadata.email) cfg_wr.release()
[ "Execute", "git", "config", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/vcs.py#L35-L41
[ "def", "_config", "(", "self", ")", ":", "cfg_wr", "=", "self", ".", "repo", ".", "config_writer", "(", ")", "cfg_wr", ".", "add_section", "(", "'user'", ")", "cfg_wr", ".", "set_value", "(", "'user'", ",", "'name'", ",", "self", ".", "metadata", ".", ...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
VCS._remote_add
Execute git remote add.
bootstrap_py/vcs.py
def _remote_add(self): """Execute git remote add.""" self.repo.create_remote( 'origin', 'git@github.com:{username}/{repo}.git'.format( username=self.metadata.username, repo=self.metadata.name))
def _remote_add(self): """Execute git remote add.""" self.repo.create_remote( 'origin', 'git@github.com:{username}/{repo}.git'.format( username=self.metadata.username, repo=self.metadata.name))
[ "Execute", "git", "remote", "add", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/vcs.py#L47-L53
[ "def", "_remote_add", "(", "self", ")", ":", "self", ".", "repo", ".", "create_remote", "(", "'origin'", ",", "'git@github.com:{username}/{repo}.git'", ".", "format", "(", "username", "=", "self", ".", "metadata", ".", "username", ",", "repo", "=", "self", "...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
BaseScript.start
Starts execution of the script
basescript/basescript.py
def start(self): ''' Starts execution of the script ''' # invoke the appropriate sub-command as requested from command-line try: self.args.func() except SystemExit as e: if e.code != 0: raise except KeyboardInterrupt: ...
def start(self): ''' Starts execution of the script ''' # invoke the appropriate sub-command as requested from command-line try: self.args.func() except SystemExit as e: if e.code != 0: raise except KeyboardInterrupt: ...
[ "Starts", "execution", "of", "the", "script" ]
deep-compute/basescript
python
https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/basescript.py#L67-L87
[ "def", "start", "(", "self", ")", ":", "# invoke the appropriate sub-command as requested from command-line", "try", ":", "self", ".", "args", ".", "func", "(", ")", "except", "SystemExit", "as", "e", ":", "if", "e", ".", "code", "!=", "0", ":", "raise", "ex...
f7233963c5291530fcb2444a7f45b556e6407b90
train
BaseScript.define_baseargs
Define basic command-line arguments required by the script. @parser is a parser object created using the `argparse` module. returns: None
basescript/basescript.py
def define_baseargs(self, parser): ''' Define basic command-line arguments required by the script. @parser is a parser object created using the `argparse` module. returns: None ''' parser.add_argument('--name', default=sys.argv[0], help='Name to identify this ...
def define_baseargs(self, parser): ''' Define basic command-line arguments required by the script. @parser is a parser object created using the `argparse` module. returns: None ''' parser.add_argument('--name', default=sys.argv[0], help='Name to identify this ...
[ "Define", "basic", "command", "-", "line", "arguments", "required", "by", "the", "script", "." ]
deep-compute/basescript
python
https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/basescript.py#L123-L151
[ "def", "define_baseargs", "(", "self", ",", "parser", ")", ":", "parser", ".", "add_argument", "(", "'--name'", ",", "default", "=", "sys", ".", "argv", "[", "0", "]", ",", "help", "=", "'Name to identify this instance'", ")", "parser", ".", "add_argument", ...
f7233963c5291530fcb2444a7f45b556e6407b90
train
SourceCoder.cleanup_payload
Basically, turns payload that looks like ' \\n ' to ''. In the calling function, if this function returns '' no object is added for that payload.
uno/parser/source_coder.py
def cleanup_payload(self, payload): """ Basically, turns payload that looks like ' \\n ' to ''. In the calling function, if this function returns '' no object is added for that payload. """ p = payload.replace('\n', '') p = p.rstrip() p = p.lstrip() ...
def cleanup_payload(self, payload): """ Basically, turns payload that looks like ' \\n ' to ''. In the calling function, if this function returns '' no object is added for that payload. """ p = payload.replace('\n', '') p = p.rstrip() p = p.lstrip() ...
[ "Basically", "turns", "payload", "that", "looks", "like", "\\\\", "n", "to", ".", "In", "the", "calling", "function", "if", "this", "function", "returns", "no", "object", "is", "added", "for", "that", "payload", "." ]
elbow-jason/Uno-deprecated
python
https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/parser/source_coder.py#L73-L82
[ "def", "cleanup_payload", "(", "self", ",", "payload", ")", ":", "p", "=", "payload", ".", "replace", "(", "'\\n'", ",", "''", ")", "p", "=", "p", ".", "rstrip", "(", ")", "p", "=", "p", ".", "lstrip", "(", ")", "return", "p" ]
4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4
train
format_xpaths
:return: a copy of xpath_map, but with XPATHs formatted with ordered or keyword values
gis_metadata/utils.py
def format_xpaths(xpath_map, *args, **kwargs): """ :return: a copy of xpath_map, but with XPATHs formatted with ordered or keyword values """ formatted = {}.fromkeys(xpath_map) for key, xpath in iteritems(xpath_map): formatted[key] = xpath.format(*args, **kwargs) return formatted
def format_xpaths(xpath_map, *args, **kwargs): """ :return: a copy of xpath_map, but with XPATHs formatted with ordered or keyword values """ formatted = {}.fromkeys(xpath_map) for key, xpath in iteritems(xpath_map): formatted[key] = xpath.format(*args, **kwargs) return formatted
[ ":", "return", ":", "a", "copy", "of", "xpath_map", "but", "with", "XPATHs", "formatted", "with", "ordered", "or", "keyword", "values" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L162-L170
[ "def", "format_xpaths", "(", "xpath_map", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "formatted", "=", "{", "}", ".", "fromkeys", "(", "xpath_map", ")", "for", "key", ",", "xpath", "in", "iteritems", "(", "xpath_map", ")", ":", "formatted", ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
get_xpath_root
:return: the base of an XPATH: the part preceding any format keys or attribute references
gis_metadata/utils.py
def get_xpath_root(xpath): """ :return: the base of an XPATH: the part preceding any format keys or attribute references """ if xpath: if xpath.startswith('@'): xpath = '' else: index = xpath.find('/@' if '@' in xpath else '/{') xpath = xpath[:index] if index...
def get_xpath_root(xpath): """ :return: the base of an XPATH: the part preceding any format keys or attribute references """ if xpath: if xpath.startswith('@'): xpath = '' else: index = xpath.find('/@' if '@' in xpath else '/{') xpath = xpath[:index] if index...
[ ":", "return", ":", "the", "base", "of", "an", "XPATH", ":", "the", "part", "preceding", "any", "format", "keys", "or", "attribute", "references" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L188-L198
[ "def", "get_xpath_root", "(", "xpath", ")", ":", "if", "xpath", ":", "if", "xpath", ".", "startswith", "(", "'@'", ")", ":", "xpath", "=", "''", "else", ":", "index", "=", "xpath", ".", "find", "(", "'/@'", "if", "'@'", "in", "xpath", "else", "'/{'...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
get_xpath_branch
:return: the relative part of an XPATH: that which extends past the root provided
gis_metadata/utils.py
def get_xpath_branch(xroot, xpath): """ :return: the relative part of an XPATH: that which extends past the root provided """ if xroot and xpath and xpath.startswith(xroot): xpath = xpath[len(xroot):] xpath = xpath.lstrip(XPATH_DELIM) return xpath
def get_xpath_branch(xroot, xpath): """ :return: the relative part of an XPATH: that which extends past the root provided """ if xroot and xpath and xpath.startswith(xroot): xpath = xpath[len(xroot):] xpath = xpath.lstrip(XPATH_DELIM) return xpath
[ ":", "return", ":", "the", "relative", "part", "of", "an", "XPATH", ":", "that", "which", "extends", "past", "the", "root", "provided" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L201-L208
[ "def", "get_xpath_branch", "(", "xroot", ",", "xpath", ")", ":", "if", "xroot", "and", "xpath", "and", "xpath", ".", "startswith", "(", "xroot", ")", ":", "xpath", "=", "xpath", "[", "len", "(", "xroot", ")", ":", "]", "xpath", "=", "xpath", ".", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
get_xpath_tuple
:return: a tuple with the base of an XPATH followed by any format key or attribute reference
gis_metadata/utils.py
def get_xpath_tuple(xpath): """ :return: a tuple with the base of an XPATH followed by any format key or attribute reference """ xroot = get_xpath_root(xpath) xattr = None if xroot != xpath: xattr = get_xpath_branch(xroot, xpath).strip('@') return (xroot, xattr)
def get_xpath_tuple(xpath): """ :return: a tuple with the base of an XPATH followed by any format key or attribute reference """ xroot = get_xpath_root(xpath) xattr = None if xroot != xpath: xattr = get_xpath_branch(xroot, xpath).strip('@') return (xroot, xattr)
[ ":", "return", ":", "a", "tuple", "with", "the", "base", "of", "an", "XPATH", "followed", "by", "any", "format", "key", "or", "attribute", "reference" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L211-L220
[ "def", "get_xpath_tuple", "(", "xpath", ")", ":", "xroot", "=", "get_xpath_root", "(", "xpath", ")", "xattr", "=", "None", "if", "xroot", "!=", "xpath", ":", "xattr", "=", "get_xpath_branch", "(", "xroot", ",", "xpath", ")", ".", "strip", "(", "'@'", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
get_default_for
Ensures complex property types have the correct default values
gis_metadata/utils.py
def get_default_for(prop, value): """ Ensures complex property types have the correct default values """ prop = prop.strip('_') # Handle alternate props (leading underscores) val = reduce_value(value) # Filtering of value happens here if prop in _COMPLEX_LISTS: return wrap_value(val) ...
def get_default_for(prop, value): """ Ensures complex property types have the correct default values """ prop = prop.strip('_') # Handle alternate props (leading underscores) val = reduce_value(value) # Filtering of value happens here if prop in _COMPLEX_LISTS: return wrap_value(val) ...
[ "Ensures", "complex", "property", "types", "have", "the", "correct", "default", "values" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L223-L234
[ "def", "get_default_for", "(", "prop", ",", "value", ")", ":", "prop", "=", "prop", ".", "strip", "(", "'_'", ")", "# Handle alternate props (leading underscores)", "val", "=", "reduce_value", "(", "value", ")", "# Filtering of value happens here", "if", "prop", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
has_property
Parse xpath for any attribute reference "path/@attr" and check for root and presence of attribute. :return: True if xpath is present in the element along with any attribute referenced, otherwise False
gis_metadata/utils.py
def has_property(elem_to_parse, xpath): """ Parse xpath for any attribute reference "path/@attr" and check for root and presence of attribute. :return: True if xpath is present in the element along with any attribute referenced, otherwise False """ xroot, attr = get_xpath_tuple(xpath) if not x...
def has_property(elem_to_parse, xpath): """ Parse xpath for any attribute reference "path/@attr" and check for root and presence of attribute. :return: True if xpath is present in the element along with any attribute referenced, otherwise False """ xroot, attr = get_xpath_tuple(xpath) if not x...
[ "Parse", "xpath", "for", "any", "attribute", "reference", "path", "/" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L262-L275
[ "def", "has_property", "(", "elem_to_parse", ",", "xpath", ")", ":", "xroot", ",", "attr", "=", "get_xpath_tuple", "(", "xpath", ")", "if", "not", "xroot", "and", "not", "attr", ":", "return", "False", "elif", "not", "attr", ":", "return", "bool", "(", ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
parse_complex
Creates and returns a Dictionary data structure parsed from the metadata. :param tree_to_parse: the XML tree compatible with element_utils to be parsed :param xpath_root: the XPATH location of the structure inside the parent element :param xpath_map: a dict of XPATHs corresponding to a complex definition ...
gis_metadata/utils.py
def parse_complex(tree_to_parse, xpath_root, xpath_map, complex_key): """ Creates and returns a Dictionary data structure parsed from the metadata. :param tree_to_parse: the XML tree compatible with element_utils to be parsed :param xpath_root: the XPATH location of the structure inside the parent eleme...
def parse_complex(tree_to_parse, xpath_root, xpath_map, complex_key): """ Creates and returns a Dictionary data structure parsed from the metadata. :param tree_to_parse: the XML tree compatible with element_utils to be parsed :param xpath_root: the XPATH location of the structure inside the parent eleme...
[ "Creates", "and", "returns", "a", "Dictionary", "data", "structure", "parsed", "from", "the", "metadata", ".", ":", "param", "tree_to_parse", ":", "the", "XML", "tree", "compatible", "with", "element_utils", "to", "be", "parsed", ":", "param", "xpath_root", ":...
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L278-L296
[ "def", "parse_complex", "(", "tree_to_parse", ",", "xpath_root", ",", "xpath_map", ",", "complex_key", ")", ":", "complex_struct", "=", "{", "}", "for", "prop", "in", "_complex_definitions", ".", "get", "(", "complex_key", ",", "xpath_map", ")", ":", "# Normal...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
parse_complex_list
Creates and returns a list of Dictionary data structures parsed from the metadata. :param tree_to_parse: the XML tree compatible with element_utils to be parsed :param xpath_root: the XPATH location of each structure inside the parent element :param xpath_map: a dict of XPATHs corresponding to a complex def...
gis_metadata/utils.py
def parse_complex_list(tree_to_parse, xpath_root, xpath_map, complex_key): """ Creates and returns a list of Dictionary data structures parsed from the metadata. :param tree_to_parse: the XML tree compatible with element_utils to be parsed :param xpath_root: the XPATH location of each structure inside t...
def parse_complex_list(tree_to_parse, xpath_root, xpath_map, complex_key): """ Creates and returns a list of Dictionary data structures parsed from the metadata. :param tree_to_parse: the XML tree compatible with element_utils to be parsed :param xpath_root: the XPATH location of each structure inside t...
[ "Creates", "and", "returns", "a", "list", "of", "Dictionary", "data", "structures", "parsed", "from", "the", "metadata", ".", ":", "param", "tree_to_parse", ":", "the", "XML", "tree", "compatible", "with", "element_utils", "to", "be", "parsed", ":", "param", ...
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L299-L315
[ "def", "parse_complex_list", "(", "tree_to_parse", ",", "xpath_root", ",", "xpath_map", ",", "complex_key", ")", ":", "complex_list", "=", "[", "]", "for", "element", "in", "get_elements", "(", "tree_to_parse", ",", "xpath_root", ")", ":", "complex_struct", "=",...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
parse_dates
Creates and returns a Dates Dictionary data structure given the parameters provided :param tree_to_parse: the XML tree from which to construct the Dates data structure :param xpath_map: a map containing the following type-specific XPATHs: multiple, range, range_begin, range_end, and single
gis_metadata/utils.py
def parse_dates(tree_to_parse, xpath_map): """ Creates and returns a Dates Dictionary data structure given the parameters provided :param tree_to_parse: the XML tree from which to construct the Dates data structure :param xpath_map: a map containing the following type-specific XPATHs: multiple, ...
def parse_dates(tree_to_parse, xpath_map): """ Creates and returns a Dates Dictionary data structure given the parameters provided :param tree_to_parse: the XML tree from which to construct the Dates data structure :param xpath_map: a map containing the following type-specific XPATHs: multiple, ...
[ "Creates", "and", "returns", "a", "Dates", "Dictionary", "data", "structure", "given", "the", "parameters", "provided", ":", "param", "tree_to_parse", ":", "the", "XML", "tree", "from", "which", "to", "construct", "the", "Dates", "data", "structure", ":", "par...
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L318-L351
[ "def", "parse_dates", "(", "tree_to_parse", ",", "xpath_map", ")", ":", "# Determine dates to query based on metadata elements", "values", "=", "wrap_value", "(", "parse_property", "(", "tree_to_parse", ",", "None", ",", "xpath_map", ",", "DATE_TYPE_SINGLE", ")", ")", ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
parse_property
Defines the default parsing behavior for metadata values. :param tree_to_parse: the XML tree compatible with element_utils to be parsed :param xpath_root: used to determine the relative XPATH location within the parent element :param xpath_map: a dict of XPATHs that may contain alternate locations for a pro...
gis_metadata/utils.py
def parse_property(tree_to_parse, xpath_root, xpath_map, prop): """ Defines the default parsing behavior for metadata values. :param tree_to_parse: the XML tree compatible with element_utils to be parsed :param xpath_root: used to determine the relative XPATH location within the parent element :para...
def parse_property(tree_to_parse, xpath_root, xpath_map, prop): """ Defines the default parsing behavior for metadata values. :param tree_to_parse: the XML tree compatible with element_utils to be parsed :param xpath_root: used to determine the relative XPATH location within the parent element :para...
[ "Defines", "the", "default", "parsing", "behavior", "for", "metadata", "values", ".", ":", "param", "tree_to_parse", ":", "the", "XML", "tree", "compatible", "with", "element_utils", "to", "be", "parsed", ":", "param", "xpath_root", ":", "used", "to", "determi...
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L354-L389
[ "def", "parse_property", "(", "tree_to_parse", ",", "xpath_root", ",", "xpath_map", ",", "prop", ")", ":", "xpath", "=", "xpath_map", "[", "prop", "]", "if", "isinstance", "(", "xpath", ",", "ParserProperty", ")", ":", "if", "xpath", ".", "xpath", "is", ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
update_property
Either update the tree the default way, or call the custom updater Default Way: Existing values in the tree are overwritten. If xpaths contains a single path, then each value is written to the tree at that path. If xpaths contains a list of xpaths, then the values corresponding to each xpath index are writ...
gis_metadata/utils.py
def update_property(tree_to_update, xpath_root, xpaths, prop, values, supported=None): """ Either update the tree the default way, or call the custom updater Default Way: Existing values in the tree are overwritten. If xpaths contains a single path, then each value is written to the tree at that path. ...
def update_property(tree_to_update, xpath_root, xpaths, prop, values, supported=None): """ Either update the tree the default way, or call the custom updater Default Way: Existing values in the tree are overwritten. If xpaths contains a single path, then each value is written to the tree at that path. ...
[ "Either", "update", "the", "tree", "the", "default", "way", "or", "call", "the", "custom", "updater" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L392-L423
[ "def", "update_property", "(", "tree_to_update", ",", "xpath_root", ",", "xpaths", ",", "prop", ",", "values", ",", "supported", "=", "None", ")", ":", "if", "supported", "and", "prop", ".", "startswith", "(", "'_'", ")", "and", "prop", ".", "strip", "("...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
_update_property
Default update operation for a single parser property. If xpaths contains one xpath, then one element per value will be inserted at that location in the tree_to_update; otherwise, the number of values must match the number of xpaths.
gis_metadata/utils.py
def _update_property(tree_to_update, xpath_root, xpaths, values): """ Default update operation for a single parser property. If xpaths contains one xpath, then one element per value will be inserted at that location in the tree_to_update; otherwise, the number of values must match the number of xpaths. ...
def _update_property(tree_to_update, xpath_root, xpaths, values): """ Default update operation for a single parser property. If xpaths contains one xpath, then one element per value will be inserted at that location in the tree_to_update; otherwise, the number of values must match the number of xpaths. ...
[ "Default", "update", "operation", "for", "a", "single", "parser", "property", ".", "If", "xpaths", "contains", "one", "xpath", "then", "one", "element", "per", "value", "will", "be", "inserted", "at", "that", "location", "in", "the", "tree_to_update", ";", "...
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L426-L486
[ "def", "_update_property", "(", "tree_to_update", ",", "xpath_root", ",", "xpaths", ",", "values", ")", ":", "# Inner function to update a specific XPATH with the values provided", "def", "update_element", "(", "elem", ",", "idx", ",", "root", ",", "path", ",", "vals"...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
update_complex
Updates and returns the updated complex Element parsed from tree_to_update. :param tree_to_update: the XML tree compatible with element_utils to be updated :param xpath_root: the XPATH location of the root of the complex Element :param xpath_map: a Dictionary of XPATHs corresponding to the complex structure...
gis_metadata/utils.py
def update_complex(tree_to_update, xpath_root, xpath_map, prop, values): """ Updates and returns the updated complex Element parsed from tree_to_update. :param tree_to_update: the XML tree compatible with element_utils to be updated :param xpath_root: the XPATH location of the root of the complex Elemen...
def update_complex(tree_to_update, xpath_root, xpath_map, prop, values): """ Updates and returns the updated complex Element parsed from tree_to_update. :param tree_to_update: the XML tree compatible with element_utils to be updated :param xpath_root: the XPATH location of the root of the complex Elemen...
[ "Updates", "and", "returns", "the", "updated", "complex", "Element", "parsed", "from", "tree_to_update", ".", ":", "param", "tree_to_update", ":", "the", "XML", "tree", "compatible", "with", "element_utils", "to", "be", "updated", ":", "param", "xpath_root", ":"...
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L489-L513
[ "def", "update_complex", "(", "tree_to_update", ",", "xpath_root", ",", "xpath_map", ",", "prop", ",", "values", ")", ":", "remove_element", "(", "tree_to_update", ",", "xpath_root", ",", "True", ")", "values", "=", "reduce_value", "(", "values", ",", "{", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
update_complex_list
Updates and returns the list of updated complex Elements parsed from tree_to_update. :param tree_to_update: the XML tree compatible with element_utils to be updated :param xpath_root: the XPATH location of each complex Element :param xpath_map: a Dictionary of XPATHs corresponding to the complex structure d...
gis_metadata/utils.py
def update_complex_list(tree_to_update, xpath_root, xpath_map, prop, values): """ Updates and returns the list of updated complex Elements parsed from tree_to_update. :param tree_to_update: the XML tree compatible with element_utils to be updated :param xpath_root: the XPATH location of each complex Ele...
def update_complex_list(tree_to_update, xpath_root, xpath_map, prop, values): """ Updates and returns the list of updated complex Elements parsed from tree_to_update. :param tree_to_update: the XML tree compatible with element_utils to be updated :param xpath_root: the XPATH location of each complex Ele...
[ "Updates", "and", "returns", "the", "list", "of", "updated", "complex", "Elements", "parsed", "from", "tree_to_update", ".", ":", "param", "tree_to_update", ":", "the", "XML", "tree", "compatible", "with", "element_utils", "to", "be", "updated", ":", "param", ...
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L516-L544
[ "def", "update_complex_list", "(", "tree_to_update", ",", "xpath_root", ",", "xpath_map", ",", "prop", ",", "values", ")", ":", "complex_list", "=", "[", "]", "remove_element", "(", "tree_to_update", ",", "xpath_root", ",", "True", ")", "if", "not", "values", ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
validate_any
Validates any metadata property, complex or simple (string or array)
gis_metadata/utils.py
def validate_any(prop, value, xpath_map=None): """ Validates any metadata property, complex or simple (string or array) """ if value is not None: if prop in (ATTRIBUTES, CONTACTS, DIGITAL_FORMS): validate_complex_list(prop, value, xpath_map) elif prop in (BOUNDING_BOX, LARGER_WORKS...
def validate_any(prop, value, xpath_map=None): """ Validates any metadata property, complex or simple (string or array) """ if value is not None: if prop in (ATTRIBUTES, CONTACTS, DIGITAL_FORMS): validate_complex_list(prop, value, xpath_map) elif prop in (BOUNDING_BOX, LARGER_WORKS...
[ "Validates", "any", "metadata", "property", "complex", "or", "simple", "(", "string", "or", "array", ")" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L547-L569
[ "def", "validate_any", "(", "prop", ",", "value", ",", "xpath_map", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "if", "prop", "in", "(", "ATTRIBUTES", ",", "CONTACTS", ",", "DIGITAL_FORMS", ")", ":", "validate_complex_list", "(", "pro...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
validate_complex
Default validation for single complex data structure
gis_metadata/utils.py
def validate_complex(prop, value, xpath_map=None): """ Default validation for single complex data structure """ if value is not None: validate_type(prop, value, dict) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: complex_keys =...
def validate_complex(prop, value, xpath_map=None): """ Default validation for single complex data structure """ if value is not None: validate_type(prop, value, dict) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: complex_keys =...
[ "Default", "validation", "for", "single", "complex", "data", "structure" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L572-L589
[ "def", "validate_complex", "(", "prop", ",", "value", ",", "xpath_map", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "validate_type", "(", "prop", ",", "value", ",", "dict", ")", "if", "prop", "in", "_complex_definitions", ":", "comple...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
validate_complex_list
Default validation for Attribute Details data structure
gis_metadata/utils.py
def validate_complex_list(prop, value, xpath_map=None): """ Default validation for Attribute Details data structure """ if value is not None: validate_type(prop, value, (dict, list)) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: ...
def validate_complex_list(prop, value, xpath_map=None): """ Default validation for Attribute Details data structure """ if value is not None: validate_type(prop, value, (dict, list)) if prop in _complex_definitions: complex_keys = _complex_definitions[prop] else: ...
[ "Default", "validation", "for", "Attribute", "Details", "data", "structure" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L592-L618
[ "def", "validate_complex_list", "(", "prop", ",", "value", ",", "xpath_map", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "validate_type", "(", "prop", ",", "value", ",", "(", "dict", ",", "list", ")", ")", "if", "prop", "in", "_co...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
validate_dates
Default validation for Date Types data structure
gis_metadata/utils.py
def validate_dates(prop, value, xpath_map=None): """ Default validation for Date Types data structure """ if value is not None: validate_type(prop, value, dict) date_keys = set(value) if date_keys: if DATE_TYPE not in date_keys or DATE_VALUES not in date_keys: ...
def validate_dates(prop, value, xpath_map=None): """ Default validation for Date Types data structure """ if value is not None: validate_type(prop, value, dict) date_keys = set(value) if date_keys: if DATE_TYPE not in date_keys or DATE_VALUES not in date_keys: ...
[ "Default", "validation", "for", "Date", "Types", "data", "structure" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L621-L663
[ "def", "validate_dates", "(", "prop", ",", "value", ",", "xpath_map", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "validate_type", "(", "prop", ",", "value", ",", "dict", ")", "date_keys", "=", "set", "(", "value", ")", "if", "dat...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
validate_process_steps
Default validation for Process Steps data structure
gis_metadata/utils.py
def validate_process_steps(prop, value): """ Default validation for Process Steps data structure """ if value is not None: validate_type(prop, value, (dict, list)) procstep_keys = set(_complex_definitions[prop]) for idx, procstep in enumerate(wrap_value(value)): ps_idx = p...
def validate_process_steps(prop, value): """ Default validation for Process Steps data structure """ if value is not None: validate_type(prop, value, (dict, list)) procstep_keys = set(_complex_definitions[prop]) for idx, procstep in enumerate(wrap_value(value)): ps_idx = p...
[ "Default", "validation", "for", "Process", "Steps", "data", "structure" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L666-L691
[ "def", "validate_process_steps", "(", "prop", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "validate_type", "(", "prop", ",", "value", ",", "(", "dict", ",", "list", ")", ")", "procstep_keys", "=", "set", "(", "_complex_definitions", ...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
validate_properties
Ensures the key set contains the base supported properties for a Parser :param props: a set of property names to validate against those supported
gis_metadata/utils.py
def validate_properties(props, required): """ Ensures the key set contains the base supported properties for a Parser :param props: a set of property names to validate against those supported """ props = set(props) required = set(required or _supported_props) if len(required.intersection(p...
def validate_properties(props, required): """ Ensures the key set contains the base supported properties for a Parser :param props: a set of property names to validate against those supported """ props = set(props) required = set(required or _supported_props) if len(required.intersection(p...
[ "Ensures", "the", "key", "set", "contains", "the", "base", "supported", "properties", "for", "a", "Parser", ":", "param", "props", ":", "a", "set", "of", "property", "names", "to", "validate", "against", "those", "supported" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L694-L707
[ "def", "validate_properties", "(", "props", ",", "required", ")", ":", "props", "=", "set", "(", "props", ")", "required", "=", "set", "(", "required", "or", "_supported_props", ")", "if", "len", "(", "required", ".", "intersection", "(", "props", ")", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
validate_type
Default validation for all types
gis_metadata/utils.py
def validate_type(prop, value, expected): """ Default validation for all types """ # Validate on expected type(s), but ignore None: defaults handled elsewhere if value is not None and not isinstance(value, expected): _validation_error(prop, type(value).__name__, None, expected)
def validate_type(prop, value, expected): """ Default validation for all types """ # Validate on expected type(s), but ignore None: defaults handled elsewhere if value is not None and not isinstance(value, expected): _validation_error(prop, type(value).__name__, None, expected)
[ "Default", "validation", "for", "all", "types" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L710-L715
[ "def", "validate_type", "(", "prop", ",", "value", ",", "expected", ")", ":", "# Validate on expected type(s), but ignore None: defaults handled elsewhere", "if", "value", "is", "not", "None", "and", "not", "isinstance", "(", "value", ",", "expected", ")", ":", "_va...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
_validation_error
Default validation for updated properties
gis_metadata/utils.py
def _validation_error(prop, prop_type, prop_value, expected): """ Default validation for updated properties """ if prop_type is None: attrib = 'value' assigned = prop_value else: attrib = 'type' assigned = prop_type raise ValidationError( 'Invalid property {attr...
def _validation_error(prop, prop_type, prop_value, expected): """ Default validation for updated properties """ if prop_type is None: attrib = 'value' assigned = prop_value else: attrib = 'type' assigned = prop_type raise ValidationError( 'Invalid property {attr...
[ "Default", "validation", "for", "updated", "properties" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L718-L732
[ "def", "_validation_error", "(", "prop", ",", "prop_type", ",", "prop_value", ",", "expected", ")", ":", "if", "prop_type", "is", "None", ":", "attrib", "=", "'value'", "assigned", "=", "prop_value", "else", ":", "attrib", "=", "'type'", "assigned", "=", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
ParserProperty.get_prop
Calls the getter with no arguments and returns its value
gis_metadata/utils.py
def get_prop(self, prop): """ Calls the getter with no arguments and returns its value """ if self._parser is None: raise ConfigurationError('Cannot call ParserProperty."get_prop" with no parser configured') return self._parser(prop) if prop else self._parser()
def get_prop(self, prop): """ Calls the getter with no arguments and returns its value """ if self._parser is None: raise ConfigurationError('Cannot call ParserProperty."get_prop" with no parser configured') return self._parser(prop) if prop else self._parser()
[ "Calls", "the", "getter", "with", "no", "arguments", "and", "returns", "its", "value" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L765-L771
[ "def", "get_prop", "(", "self", ",", "prop", ")", ":", "if", "self", ".", "_parser", "is", "None", ":", "raise", "ConfigurationError", "(", "'Cannot call ParserProperty.\"get_prop\" with no parser configured'", ")", "return", "self", ".", "_parser", "(", "prop", "...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
ParserProperty.set_prop
Calls the setter with the specified keyword arguments for flexibility. :param setter_args: must contain tree_to_update, prop, values :return: None, or the value updated for complex values
gis_metadata/utils.py
def set_prop(self, **setter_args): """ Calls the setter with the specified keyword arguments for flexibility. :param setter_args: must contain tree_to_update, prop, values :return: None, or the value updated for complex values """ if self.xpath: setter_args['...
def set_prop(self, **setter_args): """ Calls the setter with the specified keyword arguments for flexibility. :param setter_args: must contain tree_to_update, prop, values :return: None, or the value updated for complex values """ if self.xpath: setter_args['...
[ "Calls", "the", "setter", "with", "the", "specified", "keyword", "arguments", "for", "flexibility", ".", ":", "param", "setter_args", ":", "must", "contain", "tree_to_update", "prop", "values", ":", "return", ":", "None", "or", "the", "value", "updated", "for"...
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/utils.py#L773-L783
[ "def", "set_prop", "(", "self", ",", "*", "*", "setter_args", ")", ":", "if", "self", ".", "xpath", ":", "setter_args", "[", "'xpaths'", "]", "=", "self", ".", "xpath", "return", "self", ".", "_updater", "(", "*", "*", "setter_args", ")" ]
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
grouped_command
Given a list of commands (which are assumed groupable), return a new command which is a batch (multi) command. For ``set`` commands the outcome will be:: set_multi({key: value}, **kwargs) For ``get`` and ``delete`` commands, the outcome will be:: get_multi(list_of_keys, **kwargs) (O...
nydus/db/backends/memcache.py
def grouped_command(commands): """ Given a list of commands (which are assumed groupable), return a new command which is a batch (multi) command. For ``set`` commands the outcome will be:: set_multi({key: value}, **kwargs) For ``get`` and ``delete`` commands, the outcome will be:: ...
def grouped_command(commands): """ Given a list of commands (which are assumed groupable), return a new command which is a batch (multi) command. For ``set`` commands the outcome will be:: set_multi({key: value}, **kwargs) For ``get`` and ``delete`` commands, the outcome will be:: ...
[ "Given", "a", "list", "of", "commands", "(", "which", "are", "assumed", "groupable", ")", "return", "a", "new", "command", "which", "is", "a", "batch", "(", "multi", ")", "command", "." ]
disqus/nydus
python
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/backends/memcache.py#L67-L94
[ "def", "grouped_command", "(", "commands", ")", ":", "base", "=", "commands", "[", "0", "]", "name", "=", "base", ".", "get_name", "(", ")", "multi_command", "=", "EventualCommand", "(", "'%s_multi'", "%", "name", ")", "if", "name", "in", "(", "'get'", ...
9b505840da47a34f758a830c3992fa5dcb7bb7ad
train
can_group_commands
Returns a boolean representing whether these commands can be grouped together or not. A few things are taken into account for this decision: For ``set`` commands: - Are all arguments other than the key/value the same? For ``delete`` and ``get`` commands: - Are all arguments other than the k...
nydus/db/backends/memcache.py
def can_group_commands(command, next_command): """ Returns a boolean representing whether these commands can be grouped together or not. A few things are taken into account for this decision: For ``set`` commands: - Are all arguments other than the key/value the same? For ``delete`` and ...
def can_group_commands(command, next_command): """ Returns a boolean representing whether these commands can be grouped together or not. A few things are taken into account for this decision: For ``set`` commands: - Are all arguments other than the key/value the same? For ``delete`` and ...
[ "Returns", "a", "boolean", "representing", "whether", "these", "commands", "can", "be", "grouped", "together", "or", "not", "." ]
disqus/nydus
python
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/backends/memcache.py#L97-L135
[ "def", "can_group_commands", "(", "command", ",", "next_command", ")", ":", "multi_capable_commands", "=", "(", "'get'", ",", "'set'", ",", "'delete'", ")", "if", "next_command", "is", "None", ":", "return", "False", "name", "=", "command", ".", "get_name", ...
9b505840da47a34f758a830c3992fa5dcb7bb7ad
train
regroup_commands
Returns a list of tuples: [(command_to_run, [list, of, commands])] If the list of commands has a single item, the command was not grouped.
nydus/db/backends/memcache.py
def regroup_commands(commands): """ Returns a list of tuples: [(command_to_run, [list, of, commands])] If the list of commands has a single item, the command was not grouped. """ grouped = [] pending = [] def group_pending(): if not pending: return new...
def regroup_commands(commands): """ Returns a list of tuples: [(command_to_run, [list, of, commands])] If the list of commands has a single item, the command was not grouped. """ grouped = [] pending = [] def group_pending(): if not pending: return new...
[ "Returns", "a", "list", "of", "tuples", ":" ]
disqus/nydus
python
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/db/backends/memcache.py#L138-L182
[ "def", "regroup_commands", "(", "commands", ")", ":", "grouped", "=", "[", "]", "pending", "=", "[", "]", "def", "group_pending", "(", ")", ":", "if", "not", "pending", ":", "return", "new_command", "=", "grouped_command", "(", "pending", ")", "result", ...
9b505840da47a34f758a830c3992fa5dcb7bb7ad