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
remove_gaps
skip column if either is a gap
ctbBio/compare_aligned.py
def remove_gaps(A, B): """ skip column if either is a gap """ a_seq, b_seq = [], [] for a, b in zip(list(A), list(B)): if a == '-' or a == '.' or b == '-' or b == '.': continue a_seq.append(a) b_seq.append(b) return ''.join(a_seq), ''.join(b_seq)
def remove_gaps(A, B): """ skip column if either is a gap """ a_seq, b_seq = [], [] for a, b in zip(list(A), list(B)): if a == '-' or a == '.' or b == '-' or b == '.': continue a_seq.append(a) b_seq.append(b) return ''.join(a_seq), ''.join(b_seq)
[ "skip", "column", "if", "either", "is", "a", "gap" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L52-L62
[ "def", "remove_gaps", "(", "A", ",", "B", ")", ":", "a_seq", ",", "b_seq", "=", "[", "]", ",", "[", "]", "for", "a", ",", "b", "in", "zip", "(", "list", "(", "A", ")", ",", "list", "(", "B", ")", ")", ":", "if", "a", "==", "'-'", "or", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
compare_seqs
compare pairs of sequences
ctbBio/compare_aligned.py
def compare_seqs(seqs): """ compare pairs of sequences """ A, B, ignore_gaps = seqs a, b = A[1], B[1] # actual sequences if len(a) != len(b): print('# reads are not the same length', file=sys.stderr) exit() if ignore_gaps is True: pident = calc_pident_ignore_gaps(a, b...
def compare_seqs(seqs): """ compare pairs of sequences """ A, B, ignore_gaps = seqs a, b = A[1], B[1] # actual sequences if len(a) != len(b): print('# reads are not the same length', file=sys.stderr) exit() if ignore_gaps is True: pident = calc_pident_ignore_gaps(a, b...
[ "compare", "pairs", "of", "sequences" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L64-L77
[ "def", "compare_seqs", "(", "seqs", ")", ":", "A", ",", "B", ",", "ignore_gaps", "=", "seqs", "a", ",", "b", "=", "A", "[", "1", "]", ",", "B", "[", "1", "]", "# actual sequences", "if", "len", "(", "a", ")", "!=", "len", "(", "b", ")", ":", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
compare_seqs_leven
calculate Levenshtein ratio of sequences
ctbBio/compare_aligned.py
def compare_seqs_leven(seqs): """ calculate Levenshtein ratio of sequences """ A, B, ignore_gaps = seqs a, b = remove_gaps(A[1], B[1]) # actual sequences if len(a) != len(b): print('# reads are not the same length', file=sys.stderr) exit() pident = lr(a, b) * 100 return A...
def compare_seqs_leven(seqs): """ calculate Levenshtein ratio of sequences """ A, B, ignore_gaps = seqs a, b = remove_gaps(A[1], B[1]) # actual sequences if len(a) != len(b): print('# reads are not the same length', file=sys.stderr) exit() pident = lr(a, b) * 100 return A...
[ "calculate", "Levenshtein", "ratio", "of", "sequences" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L79-L89
[ "def", "compare_seqs_leven", "(", "seqs", ")", ":", "A", ",", "B", ",", "ignore_gaps", "=", "seqs", "a", ",", "b", "=", "remove_gaps", "(", "A", "[", "1", "]", ",", "B", "[", "1", "]", ")", "# actual sequences", "if", "len", "(", "a", ")", "!=", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
pairwise_compare
make pairwise sequence comparisons between aligned sequences
ctbBio/compare_aligned.py
def pairwise_compare(afa, leven, threads, print_list, ignore_gaps): """ make pairwise sequence comparisons between aligned sequences """ # load sequences into dictionary seqs = {seq[0]: seq for seq in nr_fasta([afa], append_index = True)} num_seqs = len(seqs) # define all pairs pairs = (...
def pairwise_compare(afa, leven, threads, print_list, ignore_gaps): """ make pairwise sequence comparisons between aligned sequences """ # load sequences into dictionary seqs = {seq[0]: seq for seq in nr_fasta([afa], append_index = True)} num_seqs = len(seqs) # define all pairs pairs = (...
[ "make", "pairwise", "sequence", "comparisons", "between", "aligned", "sequences" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L91-L110
[ "def", "pairwise_compare", "(", "afa", ",", "leven", ",", "threads", ",", "print_list", ",", "ignore_gaps", ")", ":", "# load sequences into dictionary", "seqs", "=", "{", "seq", "[", "0", "]", ":", "seq", "for", "seq", "in", "nr_fasta", "(", "[", "afa", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
to_dictionary
- convert list of comparisons to dictionary - print list of pidents (if requested) to stderr
ctbBio/compare_aligned.py
def to_dictionary(pw, print_list): """ - convert list of comparisons to dictionary - print list of pidents (if requested) to stderr """ pairs = {} for p in pw: a, b, pident = p if a not in pairs: pairs[a] = {a: '-'} if b not in pairs: pairs[b] = {b...
def to_dictionary(pw, print_list): """ - convert list of comparisons to dictionary - print list of pidents (if requested) to stderr """ pairs = {} for p in pw: a, b, pident = p if a not in pairs: pairs[a] = {a: '-'} if b not in pairs: pairs[b] = {b...
[ "-", "convert", "list", "of", "comparisons", "to", "dictionary", "-", "print", "list", "of", "pidents", "(", "if", "requested", ")", "to", "stderr" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L112-L130
[ "def", "to_dictionary", "(", "pw", ",", "print_list", ")", ":", "pairs", "=", "{", "}", "for", "p", "in", "pw", ":", "a", ",", "b", ",", "pident", "=", "p", "if", "a", "not", "in", "pairs", ":", "pairs", "[", "a", "]", "=", "{", "a", ":", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
print_pairwise
print matrix of pidents to stdout
ctbBio/compare_aligned.py
def print_pairwise(pw, median = False): """ print matrix of pidents to stdout """ names = sorted(set([i for i in pw])) if len(names) != 0: if '>' in names[0]: yield ['#'] + [i.split('>')[1] for i in names if '>' in i] else: yield ['#'] + names for a in...
def print_pairwise(pw, median = False): """ print matrix of pidents to stdout """ names = sorted(set([i for i in pw])) if len(names) != 0: if '>' in names[0]: yield ['#'] + [i.split('>')[1] for i in names if '>' in i] else: yield ['#'] + names for a in...
[ "print", "matrix", "of", "pidents", "to", "stdout" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L132-L155
[ "def", "print_pairwise", "(", "pw", ",", "median", "=", "False", ")", ":", "names", "=", "sorted", "(", "set", "(", "[", "i", "for", "i", "in", "pw", "]", ")", ")", "if", "len", "(", "names", ")", "!=", "0", ":", "if", "'>'", "in", "names", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
print_comps
print stats for comparisons
ctbBio/compare_aligned.py
def print_comps(comps): """ print stats for comparisons """ if comps == []: print('n/a') else: print('# min: %s, max: %s, mean: %s' % \ (min(comps), max(comps), np.mean(comps)))
def print_comps(comps): """ print stats for comparisons """ if comps == []: print('n/a') else: print('# min: %s, max: %s, mean: %s' % \ (min(comps), max(comps), np.mean(comps)))
[ "print", "stats", "for", "comparisons" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L157-L165
[ "def", "print_comps", "(", "comps", ")", ":", "if", "comps", "==", "[", "]", ":", "print", "(", "'n/a'", ")", "else", ":", "print", "(", "'# min: %s, max: %s, mean: %s'", "%", "(", "min", "(", "comps", ")", ",", "max", "(", "comps", ")", ",", "np", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
compare_clades
print min. pident within each clade and then matrix of between-clade max.
ctbBio/compare_aligned.py
def compare_clades(pw): """ print min. pident within each clade and then matrix of between-clade max. """ names = sorted(set([i for i in pw])) for i in range(0, 4): wi, bt = {}, {} for a in names: for b in pw[a]: if ';' not in a or ';' not in b: ...
def compare_clades(pw): """ print min. pident within each clade and then matrix of between-clade max. """ names = sorted(set([i for i in pw])) for i in range(0, 4): wi, bt = {}, {} for a in names: for b in pw[a]: if ';' not in a or ';' not in b: ...
[ "print", "min", ".", "pident", "within", "each", "clade", "and", "then", "matrix", "of", "between", "-", "clade", "max", "." ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L167-L216
[ "def", "compare_clades", "(", "pw", ")", ":", "names", "=", "sorted", "(", "set", "(", "[", "i", "for", "i", "in", "pw", "]", ")", ")", "for", "i", "in", "range", "(", "0", ",", "4", ")", ":", "wi", ",", "bt", "=", "{", "}", ",", "{", "}"...
83b2566b3a5745437ec651cd6cafddd056846240
train
matrix2dictionary
convert matrix to dictionary of comparisons
ctbBio/compare_aligned.py
def matrix2dictionary(matrix): """ convert matrix to dictionary of comparisons """ pw = {} for line in matrix: line = line.strip().split('\t') if line[0].startswith('#'): names = line[1:] continue a = line[0] for i, pident in enumerate(line[1:]...
def matrix2dictionary(matrix): """ convert matrix to dictionary of comparisons """ pw = {} for line in matrix: line = line.strip().split('\t') if line[0].startswith('#'): names = line[1:] continue a = line[0] for i, pident in enumerate(line[1:]...
[ "convert", "matrix", "to", "dictionary", "of", "comparisons" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/compare_aligned.py#L218-L239
[ "def", "matrix2dictionary", "(", "matrix", ")", ":", "pw", "=", "{", "}", "for", "line", "in", "matrix", ":", "line", "=", "line", ".", "strip", "(", ")", ".", "split", "(", "'\\t'", ")", "if", "line", "[", "0", "]", ".", "startswith", "(", "'#'"...
83b2566b3a5745437ec651cd6cafddd056846240
train
setoption
Set argument parser option.
bootstrap_py/commands.py
def setoption(parser, metadata=None): """Set argument parser option.""" parser.add_argument('-v', action='version', version=__version__) subparsers = parser.add_subparsers(help='sub commands help') create_cmd = subparsers.add_parser('create') create_cmd.add_argument('name', ...
def setoption(parser, metadata=None): """Set argument parser option.""" parser.add_argument('-v', action='version', version=__version__) subparsers = parser.add_subparsers(help='sub commands help') create_cmd = subparsers.add_parser('create') create_cmd.add_argument('name', ...
[ "Set", "argument", "parser", "option", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/commands.py#L12-L51
[ "def", "setoption", "(", "parser", ",", "metadata", "=", "None", ")", ":", "parser", ".", "add_argument", "(", "'-v'", ",", "action", "=", "'version'", ",", "version", "=", "__version__", ")", "subparsers", "=", "parser", ".", "add_subparsers", "(", "help"...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
valid_url
Validate url. :rtype: str :return: url :param str url: package homepage url.
bootstrap_py/commands.py
def valid_url(url): """Validate url. :rtype: str :return: url :param str url: package homepage url. """ regex = re.compile( r'^(?:http)s?://' r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+' r'(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?))' r'(?:/?|[/?]\S+)$', re.IGNORECA...
def valid_url(url): """Validate url. :rtype: str :return: url :param str url: package homepage url. """ regex = re.compile( r'^(?:http)s?://' r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+' r'(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?))' r'(?:/?|[/?]\S+)$', re.IGNORECA...
[ "Validate", "url", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/commands.py#L54-L69
[ "def", "valid_url", "(", "url", ")", ":", "regex", "=", "re", ".", "compile", "(", "r'^(?:http)s?://'", "r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+'", "r'(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}\\.?))'", "r'(?:/?|[/?]\\S+)$'", ",", "re", ".", "IGNORECASE", ")", "if", "not",...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
parse_options
Parse argument options.
bootstrap_py/commands.py
def parse_options(metadata): """Parse argument options.""" parser = argparse.ArgumentParser(description='%(prog)s usage:', prog=__prog__) setoption(parser, metadata=metadata) return parser
def parse_options(metadata): """Parse argument options.""" parser = argparse.ArgumentParser(description='%(prog)s usage:', prog=__prog__) setoption(parser, metadata=metadata) return parser
[ "Parse", "argument", "options", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/commands.py#L72-L77
[ "def", "parse_options", "(", "metadata", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'%(prog)s usage:'", ",", "prog", "=", "__prog__", ")", "setoption", "(", "parser", ",", "metadata", "=", "metadata", ")", "return", ...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
main
Execute main processes.
bootstrap_py/commands.py
def main(): """Execute main processes.""" try: pkg_version = Update() if pkg_version.updatable(): pkg_version.show_message() metadata = control.retreive_metadata() parser = parse_options(metadata) argvs = sys.argv if len(argvs) <= 1: parser...
def main(): """Execute main processes.""" try: pkg_version = Update() if pkg_version.updatable(): pkg_version.show_message() metadata = control.retreive_metadata() parser = parse_options(metadata) argvs = sys.argv if len(argvs) <= 1: parser...
[ "Execute", "main", "processes", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/commands.py#L80-L99
[ "def", "main", "(", ")", ":", "try", ":", "pkg_version", "=", "Update", "(", ")", "if", "pkg_version", ".", "updatable", "(", ")", ":", "pkg_version", ".", "show_message", "(", ")", "metadata", "=", "control", ".", "retreive_metadata", "(", ")", "parser"...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
PackageData._set_param
Set name:value property to Package object.
bootstrap_py/package.py
def _set_param(self, name, value): """Set name:value property to Package object.""" if name == 'status': setattr(self, name, self.metadata.status().get(value)) elif name == 'license': setattr(self, name, self.metadata.licenses().get(value)) elif name == 'name': ...
def _set_param(self, name, value): """Set name:value property to Package object.""" if name == 'status': setattr(self, name, self.metadata.status().get(value)) elif name == 'license': setattr(self, name, self.metadata.licenses().get(value)) elif name == 'name': ...
[ "Set", "name", ":", "value", "property", "to", "Package", "object", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/package.py#L32-L42
[ "def", "_set_param", "(", "self", ",", "name", ",", "value", ")", ":", "if", "name", "==", "'status'", ":", "setattr", "(", "self", ",", "name", ",", "self", ".", "metadata", ".", "status", "(", ")", ".", "get", "(", "value", ")", ")", "elif", "n...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
PackageData._check_or_set_default_params
Check key and set default vaule when it does not exists.
bootstrap_py/package.py
def _check_or_set_default_params(self): """Check key and set default vaule when it does not exists.""" if not hasattr(self, 'date'): self._set_param('date', datetime.utcnow().strftime('%Y-%m-%d')) if not hasattr(self, 'version'): self._set_param('version', self.default_ve...
def _check_or_set_default_params(self): """Check key and set default vaule when it does not exists.""" if not hasattr(self, 'date'): self._set_param('date', datetime.utcnow().strftime('%Y-%m-%d')) if not hasattr(self, 'version'): self._set_param('version', self.default_ve...
[ "Check", "key", "and", "set", "default", "vaule", "when", "it", "does", "not", "exists", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/package.py#L44-L52
[ "def", "_check_or_set_default_params", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'date'", ")", ":", "self", ".", "_set_param", "(", "'date'", ",", "datetime", ".", "utcnow", "(", ")", ".", "strftime", "(", "'%Y-%m-%d'", ")", ")", ...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
PackageTree.move
Move directory from working directory to output directory.
bootstrap_py/package.py
def move(self): """Move directory from working directory to output directory.""" if not os.path.isdir(self.outdir): os.makedirs(self.outdir) shutil.move(self.tmpdir, os.path.join(self.outdir, self.name))
def move(self): """Move directory from working directory to output directory.""" if not os.path.isdir(self.outdir): os.makedirs(self.outdir) shutil.move(self.tmpdir, os.path.join(self.outdir, self.name))
[ "Move", "directory", "from", "working", "directory", "to", "output", "directory", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/package.py#L169-L173
[ "def", "move", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "outdir", ")", ":", "os", ".", "makedirs", "(", "self", ".", "outdir", ")", "shutil", ".", "move", "(", "self", ".", "tmpdir", ",", "os", ".",...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
PackageTree.vcs_init
Initialize VCS repository.
bootstrap_py/package.py
def vcs_init(self): """Initialize VCS repository.""" VCS(os.path.join(self.outdir, self.name), self.pkg_data)
def vcs_init(self): """Initialize VCS repository.""" VCS(os.path.join(self.outdir, self.name), self.pkg_data)
[ "Initialize", "VCS", "repository", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/package.py#L185-L187
[ "def", "vcs_init", "(", "self", ")", ":", "VCS", "(", "os", ".", "path", ".", "join", "(", "self", ".", "outdir", ",", "self", ".", "name", ")", ",", "self", ".", "pkg_data", ")" ]
95d56ed98ef409fd9f019dc352fd1c3711533275
train
example_capture
example_capture An example capture script Change the network interface by ``export CAP_DEVICE=eth0``
network_pipeline/scripts/base_capture.py
def example_capture(): """example_capture An example capture script Change the network interface by ``export CAP_DEVICE=eth0`` """ dev = ev( "CAP_DEVICE", "lo") """ Ignore ports for forwarding to consolidators: Redis Internal VM: 6379, 16379 RabbitMQ Internal VM...
def example_capture(): """example_capture An example capture script Change the network interface by ``export CAP_DEVICE=eth0`` """ dev = ev( "CAP_DEVICE", "lo") """ Ignore ports for forwarding to consolidators: Redis Internal VM: 6379, 16379 RabbitMQ Internal VM...
[ "example_capture" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/base_capture.py#L13-L48
[ "def", "example_capture", "(", ")", ":", "dev", "=", "ev", "(", "\"CAP_DEVICE\"", ",", "\"lo\"", ")", "\"\"\"\n Ignore ports for forwarding to consolidators:\n\n Redis Internal VM: 6379, 16379\n RabbitMQ Internal VM: 5672, 15672, 25672\n \"\"\"", "# http://biot.com/capstats/b...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
capture_udp_packets
capture_udp_packets Capture ``UDP`` packets and call the ``handle_packets`` method Change the network interface by ``export CAP_DEVICE=eth0``
network_pipeline/scripts/capture_udp.py
def capture_udp_packets(): """capture_udp_packets Capture ``UDP`` packets and call the ``handle_packets`` method Change the network interface by ``export CAP_DEVICE=eth0`` """ dev = ev( "CAP_DEVICE", "lo") """ Ignore ports for forwarding to consolidators: Redis VM: 6...
def capture_udp_packets(): """capture_udp_packets Capture ``UDP`` packets and call the ``handle_packets`` method Change the network interface by ``export CAP_DEVICE=eth0`` """ dev = ev( "CAP_DEVICE", "lo") """ Ignore ports for forwarding to consolidators: Redis VM: 6...
[ "capture_udp_packets" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/capture_udp.py#L13-L48
[ "def", "capture_udp_packets", "(", ")", ":", "dev", "=", "ev", "(", "\"CAP_DEVICE\"", ",", "\"lo\"", ")", "\"\"\"\n Ignore ports for forwarding to consolidators:\n\n Redis VM: 6379, 16379\n RabbitMQ VM: 5672, 15672, 25672\n\n \"\"\"", "# http://biot.com/capstats/bpf.html", ...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
find_steam_location
Finds the location of the current Steam installation on Windows machines. Returns None for any non-Windows machines, or for Windows machines where Steam is not installed.
pysteam/winutils.py
def find_steam_location(): """ Finds the location of the current Steam installation on Windows machines. Returns None for any non-Windows machines, or for Windows machines where Steam is not installed. """ if registry is None: return None key = registry.CreateKey(registry.HKEY_CURRENT_USER,"Software\...
def find_steam_location(): """ Finds the location of the current Steam installation on Windows machines. Returns None for any non-Windows machines, or for Windows machines where Steam is not installed. """ if registry is None: return None key = registry.CreateKey(registry.HKEY_CURRENT_USER,"Software\...
[ "Finds", "the", "location", "of", "the", "current", "Steam", "installation", "on", "Windows", "machines", ".", "Returns", "None", "for", "any", "non", "-", "Windows", "machines", "or", "for", "Windows", "machines", "where", "Steam", "is", "not", "installed", ...
scottrice/pysteam
python
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/winutils.py#L10-L20
[ "def", "find_steam_location", "(", ")", ":", "if", "registry", "is", "None", ":", "return", "None", "key", "=", "registry", ".", "CreateKey", "(", "registry", ".", "HKEY_CURRENT_USER", ",", "\"Software\\Valve\\Steam\"", ")", "return", "registry", ".", "QueryValu...
1eb2254b5235a053a953e596fa7602d0b110245d
train
convert_pkt_to_json
convert_pkt_to_json Inspired by: https://gist.githubusercontent.com/cr0hn/1b0c2e672cd0721d3a07/raw/9144676ceb12dbd545e6dce366822bbedde8de2c/pkg_to_json.py This function convert a Scapy packet to JSON :param pkg: A kamene package :type pkg: objects :return: A JSON data :rtype: dict()
network_pipeline/convert_pkt_to_json.py
def convert_pkt_to_json(pkg): """ convert_pkt_to_json Inspired by: https://gist.githubusercontent.com/cr0hn/1b0c2e672cd0721d3a07/raw/9144676ceb12dbd545e6dce366822bbedde8de2c/pkg_to_json.py This function convert a Scapy packet to JSON :param pkg: A kamene package :type pkg: objects :return:...
def convert_pkt_to_json(pkg): """ convert_pkt_to_json Inspired by: https://gist.githubusercontent.com/cr0hn/1b0c2e672cd0721d3a07/raw/9144676ceb12dbd545e6dce366822bbedde8de2c/pkg_to_json.py This function convert a Scapy packet to JSON :param pkg: A kamene package :type pkg: objects :return:...
[ "convert_pkt_to_json", "Inspired", "by", ":", "https", ":", "//", "gist", ".", "githubusercontent", ".", "com", "/", "cr0hn", "/", "1b0c2e672cd0721d3a07", "/", "raw", "/", "9144676ceb12dbd545e6dce366822bbedde8de2c", "/", "pkg_to_json", ".", "py", "This", "function",...
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/convert_pkt_to_json.py#L12-L259
[ "def", "convert_pkt_to_json", "(", "pkg", ")", ":", "results", "=", "defaultdict", "(", "dict", ")", "try", ":", "for", "index", "in", "range", "(", "0", ",", "len", "(", "pkg", ")", ")", ":", "layer", "=", "pkg", "[", "index", "]", "# Get layer name...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
plot_PCoA
Plot PCoA principal coordinates scaled by the relative abundances of otu_name.
bin/PCoA_bubble.py
def plot_PCoA(cat_data, otu_name, unifrac, names, colors, xr, yr, outDir, save_as, plot_style): """ Plot PCoA principal coordinates scaled by the relative abundances of otu_name. """ fig = plt.figure(figsize=(14, 8)) ax = fig.add_subplot(111) for i, cat in enumerate(cat_data):...
def plot_PCoA(cat_data, otu_name, unifrac, names, colors, xr, yr, outDir, save_as, plot_style): """ Plot PCoA principal coordinates scaled by the relative abundances of otu_name. """ fig = plt.figure(figsize=(14, 8)) ax = fig.add_subplot(111) for i, cat in enumerate(cat_data):...
[ "Plot", "PCoA", "principal", "coordinates", "scaled", "by", "the", "relative", "abundances", "of", "otu_name", "." ]
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/PCoA_bubble.py#L36-L65
[ "def", "plot_PCoA", "(", "cat_data", ",", "otu_name", ",", "unifrac", ",", "names", ",", "colors", ",", "xr", ",", "yr", ",", "outDir", ",", "save_as", ",", "plot_style", ")", ":", "fig", "=", "plt", ".", "figure", "(", "figsize", "=", "(", "14", "...
0b74ef171e6a84761710548501dfac71285a58a3
train
split_by_category
Split up the column data in a biom table by mapping category value.
bin/transpose_biom.py
def split_by_category(biom_cols, mapping, category_id): """ Split up the column data in a biom table by mapping category value. """ columns = defaultdict(list) for i, col in enumerate(biom_cols): columns[mapping[col['id']][category_id]].append((i, col)) return columns
def split_by_category(biom_cols, mapping, category_id): """ Split up the column data in a biom table by mapping category value. """ columns = defaultdict(list) for i, col in enumerate(biom_cols): columns[mapping[col['id']][category_id]].append((i, col)) return columns
[ "Split", "up", "the", "column", "data", "in", "a", "biom", "table", "by", "mapping", "category", "value", "." ]
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/transpose_biom.py#L17-L25
[ "def", "split_by_category", "(", "biom_cols", ",", "mapping", ",", "category_id", ")", ":", "columns", "=", "defaultdict", "(", "list", ")", "for", "i", ",", "col", "in", "enumerate", "(", "biom_cols", ")", ":", "columns", "[", "mapping", "[", "col", "["...
0b74ef171e6a84761710548501dfac71285a58a3
train
print_line
print line if starts with ...
ctbBio/stockholm2oneline.py
def print_line(l): """ print line if starts with ... """ print_lines = ['# STOCKHOLM', '#=GF', '#=GS', ' '] if len(l.split()) == 0: return True for start in print_lines: if l.startswith(start): return True return False
def print_line(l): """ print line if starts with ... """ print_lines = ['# STOCKHOLM', '#=GF', '#=GS', ' '] if len(l.split()) == 0: return True for start in print_lines: if l.startswith(start): return True return False
[ "print", "line", "if", "starts", "with", "..." ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/stockholm2oneline.py#L11-L21
[ "def", "print_line", "(", "l", ")", ":", "print_lines", "=", "[", "'# STOCKHOLM'", ",", "'#=GF'", ",", "'#=GS'", ",", "' '", "]", "if", "len", "(", "l", ".", "split", "(", ")", ")", "==", "0", ":", "return", "True", "for", "start", "in", "print_lin...
83b2566b3a5745437ec651cd6cafddd056846240
train
stock2one
convert stockholm to single line format
ctbBio/stockholm2oneline.py
def stock2one(stock): """ convert stockholm to single line format """ lines = {} for line in stock: line = line.strip() if print_line(line) is True: yield line continue if line.startswith('//'): continue ID, seq = line.rsplit(' ', 1...
def stock2one(stock): """ convert stockholm to single line format """ lines = {} for line in stock: line = line.strip() if print_line(line) is True: yield line continue if line.startswith('//'): continue ID, seq = line.rsplit(' ', 1...
[ "convert", "stockholm", "to", "single", "line", "format" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/stockholm2oneline.py#L23-L44
[ "def", "stock2one", "(", "stock", ")", ":", "lines", "=", "{", "}", "for", "line", "in", "stock", ":", "line", "=", "line", ".", "strip", "(", ")", "if", "print_line", "(", "line", ")", "is", "True", ":", "yield", "line", "continue", "if", "line", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
math_func
Statics the methods. wut.
uno/helpers.py
def math_func(f): """ Statics the methods. wut. """ @wraps(f) def wrapper(*args, **kwargs): if len(args) > 0: return_type = type(args[0]) if kwargs.has_key('return_type'): return_type = kwargs['return_type'] kwargs.pop('return_type') re...
def math_func(f): """ Statics the methods. wut. """ @wraps(f) def wrapper(*args, **kwargs): if len(args) > 0: return_type = type(args[0]) if kwargs.has_key('return_type'): return_type = kwargs['return_type'] kwargs.pop('return_type') re...
[ "Statics", "the", "methods", ".", "wut", "." ]
elbow-jason/Uno-deprecated
python
https://github.com/elbow-jason/Uno-deprecated/blob/4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4/uno/helpers.py#L8-L22
[ "def", "math_func", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">", "0", ":", "return_type", "=", "type", "(", "args", "[", "0", "]", ...
4ad07d7b84e5b6e3e2b2c89db69448906f24b4e4
train
dump_stats
Show stats when pings are done
network_pipeline/scripts/icmp_send_msg.py
def dump_stats(myStats): """ Show stats when pings are done """ print("\n----%s PYTHON PING Statistics----" % (myStats.thisIP)) if myStats.pktsSent > 0: myStats.fracLoss = (myStats.pktsSent - myStats.pktsRcvd) \ / myStats.pktsSent print(("%d packets transmitted, %d pack...
def dump_stats(myStats): """ Show stats when pings are done """ print("\n----%s PYTHON PING Statistics----" % (myStats.thisIP)) if myStats.pktsSent > 0: myStats.fracLoss = (myStats.pktsSent - myStats.pktsRcvd) \ / myStats.pktsSent print(("%d packets transmitted, %d pack...
[ "Show", "stats", "when", "pings", "are", "done" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/icmp_send_msg.py#L470-L495
[ "def", "dump_stats", "(", "myStats", ")", ":", "print", "(", "\"\\n----%s PYTHON PING Statistics----\"", "%", "(", "myStats", ".", "thisIP", ")", ")", "if", "myStats", ".", "pktsSent", ">", "0", ":", "myStats", ".", "fracLoss", "=", "(", "myStats", ".", "p...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
verbose_ping
Send >count< ping to >destIP< with the given >timeout< and display the result.
network_pipeline/scripts/icmp_send_msg.py
def verbose_ping(hostname, timeout=WAIT_TIMEOUT, count=NUM_PACKETS, packet_size=PACKET_SIZE, path_finder=False): """ Send >count< ping to >destIP< with the given >timeout< and display the result. """ signal.signal(signal.SIGINT, signal_handler) # Handle Ctrl-C if hasattr(signa...
def verbose_ping(hostname, timeout=WAIT_TIMEOUT, count=NUM_PACKETS, packet_size=PACKET_SIZE, path_finder=False): """ Send >count< ping to >destIP< with the given >timeout< and display the result. """ signal.signal(signal.SIGINT, signal_handler) # Handle Ctrl-C if hasattr(signa...
[ "Send", ">", "count<", "ping", "to", ">", "destIP<", "with", "the", "given", ">", "timeout<", "and", "display", "the", "result", "." ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/scripts/icmp_send_msg.py#L507-L551
[ "def", "verbose_ping", "(", "hostname", ",", "timeout", "=", "WAIT_TIMEOUT", ",", "count", "=", "NUM_PACKETS", ",", "packet_size", "=", "PACKET_SIZE", ",", "path_finder", "=", "False", ")", ":", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
Update.updatable
bootstrap-py package updatable?.
bootstrap_py/update.py
def updatable(self): """bootstrap-py package updatable?.""" if self.latest_version > self.current_version: updatable_version = self.latest_version else: updatable_version = False return updatable_version
def updatable(self): """bootstrap-py package updatable?.""" if self.latest_version > self.current_version: updatable_version = self.latest_version else: updatable_version = False return updatable_version
[ "bootstrap", "-", "py", "package", "updatable?", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/update.py#L29-L35
[ "def", "updatable", "(", "self", ")", ":", "if", "self", ".", "latest_version", ">", "self", ".", "current_version", ":", "updatable_version", "=", "self", ".", "latest_version", "else", ":", "updatable_version", "=", "False", "return", "updatable_version" ]
95d56ed98ef409fd9f019dc352fd1c3711533275
train
Update.show_message
Show message updatable.
bootstrap_py/update.py
def show_message(self): """Show message updatable.""" print( 'current version: {current_version}\n' 'latest version : {latest_version}'.format( current_version=self.current_version, latest_version=self.latest_version))
def show_message(self): """Show message updatable.""" print( 'current version: {current_version}\n' 'latest version : {latest_version}'.format( current_version=self.current_version, latest_version=self.latest_version))
[ "Show", "message", "updatable", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/update.py#L37-L43
[ "def", "show_message", "(", "self", ")", ":", "print", "(", "'current version: {current_version}\\n'", "'latest version : {latest_version}'", ".", "format", "(", "current_version", "=", "self", ".", "current_version", ",", "latest_version", "=", "self", ".", "latest_ver...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
condense_otus
Traverse the input otu-sequence file, collect the non-unique OTU IDs and file the sequences associated with then under the unique OTU ID as defined by the input matrix. :@type otuF: file :@param otuF: The output file from QIIME's pick_otus.py :@type nuniqueF: file :@param nuniqueF: The matrix o...
bin/pick_otus_condense.py
def condense_otus(otuF, nuniqueF): """ Traverse the input otu-sequence file, collect the non-unique OTU IDs and file the sequences associated with then under the unique OTU ID as defined by the input matrix. :@type otuF: file :@param otuF: The output file from QIIME's pick_otus.py :@type nu...
def condense_otus(otuF, nuniqueF): """ Traverse the input otu-sequence file, collect the non-unique OTU IDs and file the sequences associated with then under the unique OTU ID as defined by the input matrix. :@type otuF: file :@param otuF: The output file from QIIME's pick_otus.py :@type nu...
[ "Traverse", "the", "input", "otu", "-", "sequence", "file", "collect", "the", "non", "-", "unique", "OTU", "IDs", "and", "file", "the", "sequences", "associated", "with", "then", "under", "the", "unique", "OTU", "ID", "as", "defined", "by", "the", "input",...
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/pick_otus_condense.py#L14-L51
[ "def", "condense_otus", "(", "otuF", ",", "nuniqueF", ")", ":", "uniqueOTUs", "=", "set", "(", ")", "nuOTUs", "=", "{", "}", "# parse non-unique otu matrix", "for", "line", "in", "nuniqueF", ":", "line", "=", "line", ".", "split", "(", ")", "uOTU", "=", ...
0b74ef171e6a84761710548501dfac71285a58a3
train
rna_bases
determine if read overlaps with rna, if so count bases
ctbBio/rRNA_copies.py
def rna_bases(rna_cov, scaffold, bases, line): """ determine if read overlaps with rna, if so count bases """ start = int(line[3]) stop = start + bases - 1 if scaffold not in rna_cov: return rna_cov for pos in rna_cov[scaffold][2]: ol = get_overlap([start, stop], pos) ...
def rna_bases(rna_cov, scaffold, bases, line): """ determine if read overlaps with rna, if so count bases """ start = int(line[3]) stop = start + bases - 1 if scaffold not in rna_cov: return rna_cov for pos in rna_cov[scaffold][2]: ol = get_overlap([start, stop], pos) ...
[ "determine", "if", "read", "overlaps", "with", "rna", "if", "so", "count", "bases" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_copies.py#L18-L29
[ "def", "rna_bases", "(", "rna_cov", ",", "scaffold", ",", "bases", ",", "line", ")", ":", "start", "=", "int", "(", "line", "[", "3", "]", ")", "stop", "=", "start", "+", "bases", "-", "1", "if", "scaffold", "not", "in", "rna_cov", ":", "return", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
parse_s2bins
parse ggKbase scaffold-to-bin mapping - scaffolds-to-bins and bins-to-scaffolds
ctbBio/rRNA_copies.py
def parse_s2bins(s2bins): """ parse ggKbase scaffold-to-bin mapping - scaffolds-to-bins and bins-to-scaffolds """ s2b = {} b2s = {} for line in s2bins: line = line.strip().split() s, b = line[0], line[1] if 'UNK' in b: continue if len(line) > 2...
def parse_s2bins(s2bins): """ parse ggKbase scaffold-to-bin mapping - scaffolds-to-bins and bins-to-scaffolds """ s2b = {} b2s = {} for line in s2bins: line = line.strip().split() s, b = line[0], line[1] if 'UNK' in b: continue if len(line) > 2...
[ "parse", "ggKbase", "scaffold", "-", "to", "-", "bin", "mapping", "-", "scaffolds", "-", "to", "-", "bins", "and", "bins", "-", "to", "-", "scaffolds" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_copies.py#L31-L52
[ "def", "parse_s2bins", "(", "s2bins", ")", ":", "s2b", "=", "{", "}", "b2s", "=", "{", "}", "for", "line", "in", "s2bins", ":", "line", "=", "line", ".", "strip", "(", ")", ".", "split", "(", ")", "s", ",", "b", "=", "line", "[", "0", "]", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
parse_rna
parse [16,23]SfromHMM.py output - rna_cov[scaffold] = [0, 0, []] # [bases, length, ranges]
ctbBio/rRNA_copies.py
def parse_rna(rna, s2bins, min_rna): """ parse [16,23]SfromHMM.py output - rna_cov[scaffold] = [0, 0, []] # [bases, length, ranges] """ rna_cov = {} for seq in parse_fasta(rna): # check that length passes threshold length = len(seq[1]) if length < min_rna: con...
def parse_rna(rna, s2bins, min_rna): """ parse [16,23]SfromHMM.py output - rna_cov[scaffold] = [0, 0, []] # [bases, length, ranges] """ rna_cov = {} for seq in parse_fasta(rna): # check that length passes threshold length = len(seq[1]) if length < min_rna: con...
[ "parse", "[", "16", "23", "]", "SfromHMM", ".", "py", "output", "-", "rna_cov", "[", "scaffold", "]", "=", "[", "0", "0", "[]", "]", "#", "[", "bases", "length", "ranges", "]" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_copies.py#L54-L74
[ "def", "parse_rna", "(", "rna", ",", "s2bins", ",", "min_rna", ")", ":", "rna_cov", "=", "{", "}", "for", "seq", "in", "parse_fasta", "(", "rna", ")", ":", "# check that length passes threshold", "length", "=", "len", "(", "seq", "[", "1", "]", ")", "i...
83b2566b3a5745437ec651cd6cafddd056846240
train
filter_missing_rna
remove any bins that don't have 16S
ctbBio/rRNA_copies.py
def filter_missing_rna(s2bins, bins2s, rna_cov): """ remove any bins that don't have 16S """ for bin, scaffolds in list(bins2s.items()): c = 0 for s in scaffolds: if s in rna_cov: c += 1 if c == 0: del bins2s[bin] for scaffold, bin in l...
def filter_missing_rna(s2bins, bins2s, rna_cov): """ remove any bins that don't have 16S """ for bin, scaffolds in list(bins2s.items()): c = 0 for s in scaffolds: if s in rna_cov: c += 1 if c == 0: del bins2s[bin] for scaffold, bin in l...
[ "remove", "any", "bins", "that", "don", "t", "have", "16S" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_copies.py#L76-L90
[ "def", "filter_missing_rna", "(", "s2bins", ",", "bins2s", ",", "rna_cov", ")", ":", "for", "bin", ",", "scaffolds", "in", "list", "(", "bins2s", ".", "items", "(", ")", ")", ":", "c", "=", "0", "for", "s", "in", "scaffolds", ":", "if", "s", "in", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
calc_bin_cov
calculate bin coverage
ctbBio/rRNA_copies.py
def calc_bin_cov(scaffolds, cov): """ calculate bin coverage """ bases = sum([cov[i][0] for i in scaffolds if i in cov]) length = sum([cov[i][1] for i in scaffolds if i in cov]) if length == 0: return 0 return float(float(bases)/float(length))
def calc_bin_cov(scaffolds, cov): """ calculate bin coverage """ bases = sum([cov[i][0] for i in scaffolds if i in cov]) length = sum([cov[i][1] for i in scaffolds if i in cov]) if length == 0: return 0 return float(float(bases)/float(length))
[ "calculate", "bin", "coverage" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_copies.py#L92-L100
[ "def", "calc_bin_cov", "(", "scaffolds", ",", "cov", ")", ":", "bases", "=", "sum", "(", "[", "cov", "[", "i", "]", "[", "0", "]", "for", "i", "in", "scaffolds", "if", "i", "in", "cov", "]", ")", "length", "=", "sum", "(", "[", "cov", "[", "i...
83b2566b3a5745437ec651cd6cafddd056846240
train
copies
1. determine bin coverage 2. determine rRNA gene coverage 3. compare
ctbBio/rRNA_copies.py
def copies(mapping, s2bins, rna, min_rna = 800, mismatches = 0): """ 1. determine bin coverage 2. determine rRNA gene coverage 3. compare """ cov = {} # cov[scaffold] = [bases, length] s2bins, bins2s = parse_s2bins(s2bins) rna_cov = parse_rna(rna, s2bins, min_rna) s2bins, bins2s = fi...
def copies(mapping, s2bins, rna, min_rna = 800, mismatches = 0): """ 1. determine bin coverage 2. determine rRNA gene coverage 3. compare """ cov = {} # cov[scaffold] = [bases, length] s2bins, bins2s = parse_s2bins(s2bins) rna_cov = parse_rna(rna, s2bins, min_rna) s2bins, bins2s = fi...
[ "1", ".", "determine", "bin", "coverage", "2", ".", "determine", "rRNA", "gene", "coverage", "3", ".", "compare" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/rRNA_copies.py#L102-L160
[ "def", "copies", "(", "mapping", ",", "s2bins", ",", "rna", ",", "min_rna", "=", "800", ",", "mismatches", "=", "0", ")", ":", "cov", "=", "{", "}", "# cov[scaffold] = [bases, length]", "s2bins", ",", "bins2s", "=", "parse_s2bins", "(", "s2bins", ")", "r...
83b2566b3a5745437ec651cd6cafddd056846240
train
TranslationFormSet.clean
Make sure there is at least a translation has been filled in. If a default language has been specified, make sure that it exists amongst translations.
multilingual_model/forms.py
def clean(self): """ Make sure there is at least a translation has been filled in. If a default language has been specified, make sure that it exists amongst translations. """ # First make sure the super's clean method is called upon. super(TranslationFormSet, se...
def clean(self): """ Make sure there is at least a translation has been filled in. If a default language has been specified, make sure that it exists amongst translations. """ # First make sure the super's clean method is called upon. super(TranslationFormSet, se...
[ "Make", "sure", "there", "is", "at", "least", "a", "translation", "has", "been", "filled", "in", ".", "If", "a", "default", "language", "has", "been", "specified", "make", "sure", "that", "it", "exists", "amongst", "translations", "." ]
dokterbob/django-multilingual-model
python
https://github.com/dokterbob/django-multilingual-model/blob/2479b2c3d6f7b697e95aa1e082c8bc8699f1f638/multilingual_model/forms.py#L19-L58
[ "def", "clean", "(", "self", ")", ":", "# First make sure the super's clean method is called upon.", "super", "(", "TranslationFormSet", ",", "self", ")", ".", "clean", "(", ")", "if", "settings", ".", "HIDE_LANGUAGE", ":", "return", "if", "len", "(", "self", "....
2479b2c3d6f7b697e95aa1e082c8bc8699f1f638
train
TranslationFormSet._get_default_language
If a default language has been set, and is still available in `self.available_languages`, return it and remove it from the list. If not, simply pop the first available language.
multilingual_model/forms.py
def _get_default_language(self): """ If a default language has been set, and is still available in `self.available_languages`, return it and remove it from the list. If not, simply pop the first available language. """ assert hasattr(self, 'available_languages'), \ ...
def _get_default_language(self): """ If a default language has been set, and is still available in `self.available_languages`, return it and remove it from the list. If not, simply pop the first available language. """ assert hasattr(self, 'available_languages'), \ ...
[ "If", "a", "default", "language", "has", "been", "set", "and", "is", "still", "available", "in", "self", ".", "available_languages", "return", "it", "and", "remove", "it", "from", "the", "list", "." ]
dokterbob/django-multilingual-model
python
https://github.com/dokterbob/django-multilingual-model/blob/2479b2c3d6f7b697e95aa1e082c8bc8699f1f638/multilingual_model/forms.py#L68-L94
[ "def", "_get_default_language", "(", "self", ")", ":", "assert", "hasattr", "(", "self", ",", "'available_languages'", ")", ",", "'No available languages have been generated.'", "assert", "len", "(", "self", ".", "available_languages", ")", ">", "0", ",", "'No avail...
2479b2c3d6f7b697e95aa1e082c8bc8699f1f638
train
TranslationFormSet._construct_form
Construct the form, overriding the initial value for `language_code`.
multilingual_model/forms.py
def _construct_form(self, i, **kwargs): """ Construct the form, overriding the initial value for `language_code`. """ if not settings.HIDE_LANGUAGE: self._construct_available_languages() form = super(TranslationFormSet, self)._construct_form(i, **kwargs) if ...
def _construct_form(self, i, **kwargs): """ Construct the form, overriding the initial value for `language_code`. """ if not settings.HIDE_LANGUAGE: self._construct_available_languages() form = super(TranslationFormSet, self)._construct_form(i, **kwargs) if ...
[ "Construct", "the", "form", "overriding", "the", "initial", "value", "for", "language_code", "." ]
dokterbob/django-multilingual-model
python
https://github.com/dokterbob/django-multilingual-model/blob/2479b2c3d6f7b697e95aa1e082c8bc8699f1f638/multilingual_model/forms.py#L96-L128
[ "def", "_construct_form", "(", "self", ",", "i", ",", "*", "*", "kwargs", ")", ":", "if", "not", "settings", ".", "HIDE_LANGUAGE", ":", "self", ".", "_construct_available_languages", "(", ")", "form", "=", "super", "(", "TranslationFormSet", ",", "self", "...
2479b2c3d6f7b697e95aa1e082c8bc8699f1f638
train
filter_by_sample_pct
Split the list of OTUs (and associated sequence ids) into two lists: those occurring in more than some percentage of samples and those less than the cutoff. :type otus: dict :param otus: {otuid: [taxonomy, [sequence IDs]]} :type nsamples: int :param nsamples: The total number of samples in the ...
bin/prune_otus.py
def filter_by_sample_pct(otus, nsamples, pct, phyl_level): """ Split the list of OTUs (and associated sequence ids) into two lists: those occurring in more than some percentage of samples and those less than the cutoff. :type otus: dict :param otus: {otuid: [taxonomy, [sequence IDs]]} :type...
def filter_by_sample_pct(otus, nsamples, pct, phyl_level): """ Split the list of OTUs (and associated sequence ids) into two lists: those occurring in more than some percentage of samples and those less than the cutoff. :type otus: dict :param otus: {otuid: [taxonomy, [sequence IDs]]} :type...
[ "Split", "the", "list", "of", "OTUs", "(", "and", "associated", "sequence", "ids", ")", "into", "two", "lists", ":", "those", "occurring", "in", "more", "than", "some", "percentage", "of", "samples", "and", "those", "less", "than", "the", "cutoff", "." ]
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/prune_otus.py#L18-L63
[ "def", "filter_by_sample_pct", "(", "otus", ",", "nsamples", ",", "pct", ",", "phyl_level", ")", ":", "if", "phyl_level", "not", "in", "[", "'k'", ",", "'p'", ",", "'c'", ",", "'o'", ",", "'f'", ",", "'g'", ",", "'s'", "]", ":", "phyl_level", "=", ...
0b74ef171e6a84761710548501dfac71285a58a3
train
filter_by_sequence_pct
Split the list of OTUs (and associated sequence ids) into two lists: those occurring associated with more than some percentage of total sequences and those less than the cutoff. :type otus: dict :param otus: {otuid: [taxonomy, [sequence IDs]]} :type nseqs: int :param nseqs: The total number of ...
bin/prune_otus.py
def filter_by_sequence_pct(otus, nseqs, pct, phyl_level): """ Split the list of OTUs (and associated sequence ids) into two lists: those occurring associated with more than some percentage of total sequences and those less than the cutoff. :type otus: dict :param otus: {otuid: [taxonomy, [seque...
def filter_by_sequence_pct(otus, nseqs, pct, phyl_level): """ Split the list of OTUs (and associated sequence ids) into two lists: those occurring associated with more than some percentage of total sequences and those less than the cutoff. :type otus: dict :param otus: {otuid: [taxonomy, [seque...
[ "Split", "the", "list", "of", "OTUs", "(", "and", "associated", "sequence", "ids", ")", "into", "two", "lists", ":", "those", "occurring", "associated", "with", "more", "than", "some", "percentage", "of", "total", "sequences", "and", "those", "less", "than",...
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/prune_otus.py#L66-L109
[ "def", "filter_by_sequence_pct", "(", "otus", ",", "nseqs", ",", "pct", ",", "phyl_level", ")", ":", "if", "phyl_level", "not", "in", "[", "'k'", ",", "'p'", ",", "'c'", ",", "'o'", ",", "'f'", ",", "'g'", ",", "'s'", "]", ":", "phyl_level", "=", "...
0b74ef171e6a84761710548501dfac71285a58a3
train
fq_merge
merge separate fastq files
ctbBio/fastq_merge.py
def fq_merge(R1, R2): """ merge separate fastq files """ c = itertools.cycle([1, 2, 3, 4]) for r1, r2 in zip(R1, R2): n = next(c) if n == 1: pair = [[], []] pair[0].append(r1.strip()) pair[1].append(r2.strip()) if n == 4: yield pair
def fq_merge(R1, R2): """ merge separate fastq files """ c = itertools.cycle([1, 2, 3, 4]) for r1, r2 in zip(R1, R2): n = next(c) if n == 1: pair = [[], []] pair[0].append(r1.strip()) pair[1].append(r2.strip()) if n == 4: yield pair
[ "merge", "separate", "fastq", "files" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/fastq_merge.py#L13-L25
[ "def", "fq_merge", "(", "R1", ",", "R2", ")", ":", "c", "=", "itertools", ".", "cycle", "(", "[", "1", ",", "2", ",", "3", ",", "4", "]", ")", "for", "r1", ",", "r2", "in", "zip", "(", "R1", ",", "R2", ")", ":", "n", "=", "next", "(", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
Ketama._build_circle
Creates hash ring.
nydus/contrib/ketama.py
def _build_circle(self): """ Creates hash ring. """ total_weight = 0 for node in self._nodes: total_weight += self._weights.get(node, 1) for node in self._nodes: weight = self._weights.get(node, 1) ks = math.floor((40 * len(self._...
def _build_circle(self): """ Creates hash ring. """ total_weight = 0 for node in self._nodes: total_weight += self._weights.get(node, 1) for node in self._nodes: weight = self._weights.get(node, 1) ks = math.floor((40 * len(self._...
[ "Creates", "hash", "ring", "." ]
disqus/nydus
python
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/contrib/ketama.py#L35-L60
[ "def", "_build_circle", "(", "self", ")", ":", "total_weight", "=", "0", "for", "node", "in", "self", ".", "_nodes", ":", "total_weight", "+=", "self", ".", "_weights", ".", "get", "(", "node", ",", "1", ")", "for", "node", "in", "self", ".", "_nodes...
9b505840da47a34f758a830c3992fa5dcb7bb7ad
train
Ketama._get_node_pos
Return node position(integer) for a given key. Else return None
nydus/contrib/ketama.py
def _get_node_pos(self, key): """ Return node position(integer) for a given key. Else return None """ if not self._hashring: return None key = self._gen_key(key) nodes = self._sorted_keys pos = bisect(nodes, key) if pos == len(nodes): ...
def _get_node_pos(self, key): """ Return node position(integer) for a given key. Else return None """ if not self._hashring: return None key = self._gen_key(key) nodes = self._sorted_keys pos = bisect(nodes, key) if pos == len(nodes): ...
[ "Return", "node", "position", "(", "integer", ")", "for", "a", "given", "key", ".", "Else", "return", "None" ]
disqus/nydus
python
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/contrib/ketama.py#L62-L76
[ "def", "_get_node_pos", "(", "self", ",", "key", ")", ":", "if", "not", "self", ".", "_hashring", ":", "return", "None", "key", "=", "self", ".", "_gen_key", "(", "key", ")", "nodes", "=", "self", ".", "_sorted_keys", "pos", "=", "bisect", "(", "node...
9b505840da47a34f758a830c3992fa5dcb7bb7ad
train
Ketama._gen_key
Return long integer for a given key, that represent it place on the hash ring.
nydus/contrib/ketama.py
def _gen_key(self, key): """ Return long integer for a given key, that represent it place on the hash ring. """ b_key = self._md5_digest(key) return self._hashi(b_key, lambda x: x)
def _gen_key(self, key): """ Return long integer for a given key, that represent it place on the hash ring. """ b_key = self._md5_digest(key) return self._hashi(b_key, lambda x: x)
[ "Return", "long", "integer", "for", "a", "given", "key", "that", "represent", "it", "place", "on", "the", "hash", "ring", "." ]
disqus/nydus
python
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/contrib/ketama.py#L78-L84
[ "def", "_gen_key", "(", "self", ",", "key", ")", ":", "b_key", "=", "self", ".", "_md5_digest", "(", "key", ")", "return", "self", ".", "_hashi", "(", "b_key", ",", "lambda", "x", ":", "x", ")" ]
9b505840da47a34f758a830c3992fa5dcb7bb7ad
train
Ketama.remove_node
Removes node from circle and rebuild it.
nydus/contrib/ketama.py
def remove_node(self, node): """ Removes node from circle and rebuild it. """ try: self._nodes.remove(node) del self._weights[node] except (KeyError, ValueError): pass self._hashring = dict() self._sorted_keys = [] ...
def remove_node(self, node): """ Removes node from circle and rebuild it. """ try: self._nodes.remove(node) del self._weights[node] except (KeyError, ValueError): pass self._hashring = dict() self._sorted_keys = [] ...
[ "Removes", "node", "from", "circle", "and", "rebuild", "it", "." ]
disqus/nydus
python
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/contrib/ketama.py#L95-L107
[ "def", "remove_node", "(", "self", ",", "node", ")", ":", "try", ":", "self", ".", "_nodes", ".", "remove", "(", "node", ")", "del", "self", ".", "_weights", "[", "node", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "pass", "self", ...
9b505840da47a34f758a830c3992fa5dcb7bb7ad
train
Ketama.add_node
Adds node to circle and rebuild it.
nydus/contrib/ketama.py
def add_node(self, node, weight=1): """ Adds node to circle and rebuild it. """ self._nodes.add(node) self._weights[node] = weight self._hashring = dict() self._sorted_keys = [] self._build_circle()
def add_node(self, node, weight=1): """ Adds node to circle and rebuild it. """ self._nodes.add(node) self._weights[node] = weight self._hashring = dict() self._sorted_keys = [] self._build_circle()
[ "Adds", "node", "to", "circle", "and", "rebuild", "it", "." ]
disqus/nydus
python
https://github.com/disqus/nydus/blob/9b505840da47a34f758a830c3992fa5dcb7bb7ad/nydus/contrib/ketama.py#L109-L118
[ "def", "add_node", "(", "self", ",", "node", ",", "weight", "=", "1", ")", ":", "self", ".", "_nodes", ".", "add", "(", "node", ")", "self", ".", "_weights", "[", "node", "]", "=", "weight", "self", ".", "_hashring", "=", "dict", "(", ")", "self"...
9b505840da47a34f758a830c3992fa5dcb7bb7ad
train
RecordPacketsToCSV.process_ether_frame
process_ether_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: ether frame for packet
network_pipeline/record_packets_to_csv.py
def process_ether_frame(self, id=None, msg=None): """process_ether_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg ...
def process_ether_frame(self, id=None, msg=None): """process_ether_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg ...
[ "process_ether_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L128-L163
[ "def", "process_ether_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.process_ip_frame
process_ip_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: ip frame for packet
network_pipeline/record_packets_to_csv.py
def process_ip_frame(self, id=None, msg=None): """process_ip_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param ...
def process_ip_frame(self, id=None, msg=None): """process_ip_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param ...
[ "process_ip_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L166-L201
[ "def", "process_ip_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df", ...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.process_ipvsix_frame
process_ipvsix_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: ipv6 frame for packet
network_pipeline/record_packets_to_csv.py
def process_ipvsix_frame(self, id=None, msg=None): """process_ipvsix_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg...
def process_ipvsix_frame(self, id=None, msg=None): """process_ipvsix_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg...
[ "process_ipvsix_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L204-L239
[ "def", "process_ipvsix_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "d...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.process_tcp_frame
process_tcp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: tcp frame for packet
network_pipeline/record_packets_to_csv.py
def process_tcp_frame(self, id=None, msg=None): """process_tcp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
def process_tcp_frame(self, id=None, msg=None): """process_tcp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
[ "process_tcp_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L242-L277
[ "def", "process_tcp_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df",...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.process_udp_frame
process_udp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: udp frame for packet
network_pipeline/record_packets_to_csv.py
def process_udp_frame(self, id=None, msg=None): """process_udp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
def process_udp_frame(self, id=None, msg=None): """process_udp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
[ "process_udp_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L280-L315
[ "def", "process_udp_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df",...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.process_dns_frame
process_dns_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: dns frame for packet
network_pipeline/record_packets_to_csv.py
def process_dns_frame(self, id=None, msg=None): """process_dns_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
def process_dns_frame(self, id=None, msg=None): """process_dns_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
[ "process_dns_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L318-L353
[ "def", "process_dns_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df",...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.process_icmp_frame
process_icmp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: icmp frame for packet
network_pipeline/record_packets_to_csv.py
def process_icmp_frame(self, id=None, msg=None): """process_icmp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg ...
def process_icmp_frame(self, id=None, msg=None): """process_icmp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg ...
[ "process_icmp_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L356-L391
[ "def", "process_icmp_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df"...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.process_arp_frame
process_arp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: arp frame for packet
network_pipeline/record_packets_to_csv.py
def process_arp_frame(self, id=None, msg=None): """process_arp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
def process_arp_frame(self, id=None, msg=None): """process_arp_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
[ "process_arp_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L394-L429
[ "def", "process_arp_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df",...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.process_raw_frame
process_raw_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: raw frame for packet
network_pipeline/record_packets_to_csv.py
def process_raw_frame(self, id=None, msg=None): """process_raw_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
def process_raw_frame(self, id=None, msg=None): """process_raw_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
[ "process_raw_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L432-L467
[ "def", "process_raw_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df",...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.process_pad_frame
process_pad_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: pad frame for packet
network_pipeline/record_packets_to_csv.py
def process_pad_frame(self, id=None, msg=None): """process_pad_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
def process_pad_frame(self, id=None, msg=None): """process_pad_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
[ "process_pad_frame" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L470-L505
[ "def", "process_pad_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df",...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.build_flat_msg
build_flat_msg :param id: unique id for this message :param msg: message dictionary to flatten
network_pipeline/record_packets_to_csv.py
def build_flat_msg(self, id=None, msg=None): """build_flat_msg :param id: unique id for this message :param msg: message dictionary to flatten """ flat_msg = {} if not id: log.error("Please pass in an id") ...
def build_flat_msg(self, id=None, msg=None): """build_flat_msg :param id: unique id for this message :param msg: message dictionary to flatten """ flat_msg = {} if not id: log.error("Please pass in an id") ...
[ "build_flat_msg" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L508-L586
[ "def", "build_flat_msg", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "flat_msg", "=", "{", "}", "if", "not", "id", ":", "log", ".", "error", "(", "\"Please pass in an id\"", ")", "return", "None", "if", "not", "msg", ":", ...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.build_all_keys_dict
build_all_keys_dict
network_pipeline/record_packets_to_csv.py
def build_all_keys_dict(self): """build_all_keys_dict""" log.info("finding keys") for k in self.eth_keys: ak = "{}".format(k) if ak not in self.all_keys: self.all_keys[ak] = k # end of building all eths for k in self.ip_keys: a...
def build_all_keys_dict(self): """build_all_keys_dict""" log.info("finding keys") for k in self.eth_keys: ak = "{}".format(k) if ak not in self.all_keys: self.all_keys[ak] = k # end of building all eths for k in self.ip_keys: a...
[ "build_all_keys_dict" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L589-L650
[ "def", "build_all_keys_dict", "(", "self", ")", ":", "log", ".", "info", "(", "\"finding keys\"", ")", "for", "k", "in", "self", ".", "eth_keys", ":", "ak", "=", "\"{}\"", ".", "format", "(", "k", ")", "if", "ak", "not", "in", "self", ".", "all_keys"...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.flatten_all
flatten_all
network_pipeline/record_packets_to_csv.py
def flatten_all(self): """flatten_all""" log.info("flattening - START") self.all_rows = [] for idx, r in enumerate(self.all_flat): new_row = {"idx": idx} for k in self.all_keys_list: if k in r: new_row[k] = r[k] ...
def flatten_all(self): """flatten_all""" log.info("flattening - START") self.all_rows = [] for idx, r in enumerate(self.all_flat): new_row = {"idx": idx} for k in self.all_keys_list: if k in r: new_row[k] = r[k] ...
[ "flatten_all" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L654-L676
[ "def", "flatten_all", "(", "self", ")", ":", "log", ".", "info", "(", "\"flattening - START\"", ")", "self", ".", "all_rows", "=", "[", "]", "for", "idx", ",", "r", "in", "enumerate", "(", "self", ".", "all_flat", ")", ":", "new_row", "=", "{", "\"id...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.create_json_archive
create_json_archive
network_pipeline/record_packets_to_csv.py
def create_json_archive(self): """create_json_archive""" archive_data = {"packets": self.recv_msgs, "dataset": self.dataset_name, "num_packets": len(self.recv_msgs), "created": rnow()} self.write_to_file(archive_data, ...
def create_json_archive(self): """create_json_archive""" archive_data = {"packets": self.recv_msgs, "dataset": self.dataset_name, "num_packets": len(self.recv_msgs), "created": rnow()} self.write_to_file(archive_data, ...
[ "create_json_archive" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L679-L687
[ "def", "create_json_archive", "(", "self", ")", ":", "archive_data", "=", "{", "\"packets\"", ":", "self", ".", "recv_msgs", ",", "\"dataset\"", ":", "self", ".", "dataset_name", ",", "\"num_packets\"", ":", "len", "(", "self", ".", "recv_msgs", ")", ",", ...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.convert_to_df
convert_to_df
network_pipeline/record_packets_to_csv.py
def convert_to_df(self): """convert_to_df""" log.info(("converting={}") .format(len(self.all_rows))) if len(self.all_rows) == 0: return self.df = pd.DataFrame(self.all_rows).set_index("idx") if len(self.df) != len(self.all_rows): log.e...
def convert_to_df(self): """convert_to_df""" log.info(("converting={}") .format(len(self.all_rows))) if len(self.all_rows) == 0: return self.df = pd.DataFrame(self.all_rows).set_index("idx") if len(self.df) != len(self.all_rows): log.e...
[ "convert_to_df" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L691-L709
[ "def", "convert_to_df", "(", "self", ")", ":", "log", ".", "info", "(", "(", "\"converting={}\"", ")", ".", "format", "(", "len", "(", "self", ".", "all_rows", ")", ")", ")", "if", "len", "(", "self", ".", "all_rows", ")", "==", "0", ":", "return",...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.write_to_file
write_to_file :param data_dict: :param output_file_path:
network_pipeline/record_packets_to_csv.py
def write_to_file(self, data_dict, output_file_path): """write_to_file :param data_dict: :param output_file_path: """ log.info("saving={}".format(output_file_path)) with open(output_file_path, "w") as output_file: ...
def write_to_file(self, data_dict, output_file_path): """write_to_file :param data_dict: :param output_file_path: """ log.info("saving={}".format(output_file_path)) with open(output_file_path, "w") as output_file: ...
[ "write_to_file" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L713-L724
[ "def", "write_to_file", "(", "self", ",", "data_dict", ",", "output_file_path", ")", ":", "log", ".", "info", "(", "\"saving={}\"", ".", "format", "(", "output_file_path", ")", ")", "with", "open", "(", "output_file_path", ",", "\"w\"", ")", "as", "output_fi...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.save_df_as_csv
save_df_as_csv
network_pipeline/record_packets_to_csv.py
def save_df_as_csv(self): """save_df_as_csv""" if len(self.all_rows) == 0: log.info(("no df={} to save") .format(self.df)) return else: log.info(("saving " "packets={} file={} rows={}") .format(...
def save_df_as_csv(self): """save_df_as_csv""" if len(self.all_rows) == 0: log.info(("no df={} to save") .format(self.df)) return else: log.info(("saving " "packets={} file={} rows={}") .format(...
[ "save_df_as_csv" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L727-L748
[ "def", "save_df_as_csv", "(", "self", ")", ":", "if", "len", "(", "self", ".", "all_rows", ")", "==", "0", ":", "log", ".", "info", "(", "(", "\"no df={} to save\"", ")", ".", "format", "(", "self", ".", "df", ")", ")", "return", "else", ":", "log"...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.save_data
save_data
network_pipeline/record_packets_to_csv.py
def save_data(self): """save_data""" state = "" try: state = "create_json_archive" log.info("creating json archive") self.create_json_archive() state = "building_unique_keys" log.info("processing all unique keys") self.bu...
def save_data(self): """save_data""" state = "" try: state = "create_json_archive" log.info("creating json archive") self.create_json_archive() state = "building_unique_keys" log.info("processing all unique keys") self.bu...
[ "save_data" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L752-L790
[ "def", "save_data", "(", "self", ")", ":", "state", "=", "\"\"", "try", ":", "state", "=", "\"create_json_archive\"", "log", ".", "info", "(", "\"creating json archive\"", ")", "self", ".", "create_json_archive", "(", ")", "state", "=", "\"building_unique_keys\"...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.handle_msg
handle_msg :param body: dictionary contents from the message body :param org_message: message object can ack, requeue or reject
network_pipeline/record_packets_to_csv.py
def handle_msg(self, body, org_message): """handle_msg :param body: dictionary contents from the message body :param org_message: message object can ack, requeue or reject """ if os.path.exists(self.stop_for_file): log.info(("De...
def handle_msg(self, body, org_message): """handle_msg :param body: dictionary contents from the message body :param org_message: message object can ack, requeue or reject """ if os.path.exists(self.stop_for_file): log.info(("De...
[ "handle_msg" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L793-L879
[ "def", "handle_msg", "(", "self", ",", "body", ",", "org_message", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "stop_for_file", ")", ":", "log", ".", "info", "(", "(", "\"Detected stop_file={} \"", "\"shutting down\"", ")", ".", "...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
RecordPacketsToCSV.publish_predictions_to_core
publish_predictions_to_core
network_pipeline/record_packets_to_csv.py
def publish_predictions_to_core(self): """publish_predictions_to_core""" status = FAILED msg = "not started" try: msg = "generating request" log.info(msg) # noqa https://stackoverflow.com/questions/29815129/pandas-dataframe-to-list-of-dictionaries ...
def publish_predictions_to_core(self): """publish_predictions_to_core""" status = FAILED msg = "not started" try: msg = "generating request" log.info(msg) # noqa https://stackoverflow.com/questions/29815129/pandas-dataframe-to-list-of-dictionaries ...
[ "publish_predictions_to_core" ]
jay-johnson/network-pipeline
python
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L882-L948
[ "def", "publish_predictions_to_core", "(", "self", ")", ":", "status", "=", "FAILED", "msg", "=", "\"not started\"", "try", ":", "msg", "=", "\"generating request\"", "log", ".", "info", "(", "msg", ")", "# noqa https://stackoverflow.com/questions/29815129/pandas-datafr...
4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa
train
FgdcParser._init_data_map
OVERRIDDEN: Initialize required FGDC data map with XPATHS and specialized functions
gis_metadata/fgdc_metadata_parser.py
def _init_data_map(self): """ OVERRIDDEN: Initialize required FGDC data map with XPATHS and specialized functions """ if self._data_map is not None: return # Initiation happens once # Parse and validate the FGDC metadata root if self._xml_tree is None: fgdc_ro...
def _init_data_map(self): """ OVERRIDDEN: Initialize required FGDC data map with XPATHS and specialized functions """ if self._data_map is not None: return # Initiation happens once # Parse and validate the FGDC metadata root if self._xml_tree is None: fgdc_ro...
[ "OVERRIDDEN", ":", "Initialize", "required", "FGDC", "data", "map", "with", "XPATHS", "and", "specialized", "functions" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/fgdc_metadata_parser.py#L108-L243
[ "def", "_init_data_map", "(", "self", ")", ":", "if", "self", ".", "_data_map", "is", "not", "None", ":", "return", "# Initiation happens once", "# Parse and validate the FGDC metadata root", "if", "self", ".", "_xml_tree", "is", "None", ":", "fgdc_root", "=", "FG...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
FgdcParser._update_raster_info
Ensures complete removal of raster_info given the two roots: <spdoinfo> and <spref>
gis_metadata/fgdc_metadata_parser.py
def _update_raster_info(self, **update_props): """ Ensures complete removal of raster_info given the two roots: <spdoinfo> and <spref> """ xpath_map = self._data_structures[update_props['prop']] return [ update_complex(xpath_root=self._data_map.get('_raster_info_root'), xpath_map=x...
def _update_raster_info(self, **update_props): """ Ensures complete removal of raster_info given the two roots: <spdoinfo> and <spref> """ xpath_map = self._data_structures[update_props['prop']] return [ update_complex(xpath_root=self._data_map.get('_raster_info_root'), xpath_map=x...
[ "Ensures", "complete", "removal", "of", "raster_info", "given", "the", "two", "roots", ":", "<spdoinfo", ">", "and", "<spref", ">" ]
consbio/gis-metadata-parser
python
https://github.com/consbio/gis-metadata-parser/blob/59eefb2e51cd4d8cc3e94623a2167499ca9ef70f/gis_metadata/fgdc_metadata_parser.py#L266-L274
[ "def", "_update_raster_info", "(", "self", ",", "*", "*", "update_props", ")", ":", "xpath_map", "=", "self", ".", "_data_structures", "[", "update_props", "[", "'prop'", "]", "]", "return", "[", "update_complex", "(", "xpath_root", "=", "self", ".", "_data_...
59eefb2e51cd4d8cc3e94623a2167499ca9ef70f
train
has_custom_image
Returns True if there exists a custom image for app_id.
pysteam/grid.py
def has_custom_image(user_context, app_id): """Returns True if there exists a custom image for app_id.""" possible_paths = _valid_custom_image_paths(user_context, app_id) return any(map(os.path.exists, possible_paths))
def has_custom_image(user_context, app_id): """Returns True if there exists a custom image for app_id.""" possible_paths = _valid_custom_image_paths(user_context, app_id) return any(map(os.path.exists, possible_paths))
[ "Returns", "True", "if", "there", "exists", "a", "custom", "image", "for", "app_id", "." ]
scottrice/pysteam
python
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/grid.py#L32-L35
[ "def", "has_custom_image", "(", "user_context", ",", "app_id", ")", ":", "possible_paths", "=", "_valid_custom_image_paths", "(", "user_context", ",", "app_id", ")", "return", "any", "(", "map", "(", "os", ".", "path", ".", "exists", ",", "possible_paths", ")"...
1eb2254b5235a053a953e596fa7602d0b110245d
train
get_custom_image
Returns the custom image associated with a given app. If there are multiple candidate images on disk, one is chosen arbitrarily.
pysteam/grid.py
def get_custom_image(user_context, app_id): """Returns the custom image associated with a given app. If there are multiple candidate images on disk, one is chosen arbitrarily.""" possible_paths = _valid_custom_image_paths(user_context, app_id) existing_images = filter(os.path.exists, possible_paths) if len(ex...
def get_custom_image(user_context, app_id): """Returns the custom image associated with a given app. If there are multiple candidate images on disk, one is chosen arbitrarily.""" possible_paths = _valid_custom_image_paths(user_context, app_id) existing_images = filter(os.path.exists, possible_paths) if len(ex...
[ "Returns", "the", "custom", "image", "associated", "with", "a", "given", "app", ".", "If", "there", "are", "multiple", "candidate", "images", "on", "disk", "one", "is", "chosen", "arbitrarily", "." ]
scottrice/pysteam
python
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/grid.py#L37-L43
[ "def", "get_custom_image", "(", "user_context", ",", "app_id", ")", ":", "possible_paths", "=", "_valid_custom_image_paths", "(", "user_context", ",", "app_id", ")", "existing_images", "=", "filter", "(", "os", ".", "path", ".", "exists", ",", "possible_paths", ...
1eb2254b5235a053a953e596fa7602d0b110245d
train
set_custom_image
Sets the custom image for `app_id` to be the image located at `image_path`. If there already exists a custom image for `app_id` it will be deleted. Returns True is setting the image was successful.
pysteam/grid.py
def set_custom_image(user_context, app_id, image_path): """Sets the custom image for `app_id` to be the image located at `image_path`. If there already exists a custom image for `app_id` it will be deleted. Returns True is setting the image was successful.""" if image_path is None: return False if not os...
def set_custom_image(user_context, app_id, image_path): """Sets the custom image for `app_id` to be the image located at `image_path`. If there already exists a custom image for `app_id` it will be deleted. Returns True is setting the image was successful.""" if image_path is None: return False if not os...
[ "Sets", "the", "custom", "image", "for", "app_id", "to", "be", "the", "image", "located", "at", "image_path", ".", "If", "there", "already", "exists", "a", "custom", "image", "for", "app_id", "it", "will", "be", "deleted", ".", "Returns", "True", "is", "...
scottrice/pysteam
python
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/grid.py#L45-L70
[ "def", "set_custom_image", "(", "user_context", ",", "app_id", ",", "image_path", ")", ":", "if", "image_path", "is", "None", ":", "return", "False", "if", "not", "os", ".", "path", ".", "exists", "(", "image_path", ")", ":", "return", "False", "(", "roo...
1eb2254b5235a053a953e596fa7602d0b110245d
train
Profile.from_file
Read an orthography profile from a metadata file or a default tab-separated profile file.
src/segments/profile.py
def from_file(cls, fname, form=None): """ Read an orthography profile from a metadata file or a default tab-separated profile file. """ try: tg = TableGroup.from_file(fname) opfname = None except JSONDecodeError: tg = TableGroup.fromvalue(cls.M...
def from_file(cls, fname, form=None): """ Read an orthography profile from a metadata file or a default tab-separated profile file. """ try: tg = TableGroup.from_file(fname) opfname = None except JSONDecodeError: tg = TableGroup.fromvalue(cls.M...
[ "Read", "an", "orthography", "profile", "from", "a", "metadata", "file", "or", "a", "default", "tab", "-", "separated", "profile", "file", "." ]
cldf/segments
python
https://github.com/cldf/segments/blob/9136a4ec89555bf9b574399ffbb07f3cc9a9f45f/src/segments/profile.py#L100-L117
[ "def", "from_file", "(", "cls", ",", "fname", ",", "form", "=", "None", ")", ":", "try", ":", "tg", "=", "TableGroup", ".", "from_file", "(", "fname", ")", "opfname", "=", "None", "except", "JSONDecodeError", ":", "tg", "=", "TableGroup", ".", "fromval...
9136a4ec89555bf9b574399ffbb07f3cc9a9f45f
train
Profile.from_text
Create a Profile instance from the Unicode graphemes found in `text`. Parameters ---------- text mapping Returns ------- A Profile instance.
src/segments/profile.py
def from_text(cls, text, mapping='mapping'): """ Create a Profile instance from the Unicode graphemes found in `text`. Parameters ---------- text mapping Returns ------- A Profile instance. """ graphemes = Counter(grapheme_patter...
def from_text(cls, text, mapping='mapping'): """ Create a Profile instance from the Unicode graphemes found in `text`. Parameters ---------- text mapping Returns ------- A Profile instance. """ graphemes = Counter(grapheme_patter...
[ "Create", "a", "Profile", "instance", "from", "the", "Unicode", "graphemes", "found", "in", "text", "." ]
cldf/segments
python
https://github.com/cldf/segments/blob/9136a4ec89555bf9b574399ffbb07f3cc9a9f45f/src/segments/profile.py#L120-L141
[ "def", "from_text", "(", "cls", ",", "text", ",", "mapping", "=", "'mapping'", ")", ":", "graphemes", "=", "Counter", "(", "grapheme_pattern", ".", "findall", "(", "text", ")", ")", "specs", "=", "[", "OrderedDict", "(", "[", "(", "cls", ".", "GRAPHEME...
9136a4ec89555bf9b574399ffbb07f3cc9a9f45f
train
split_fasta
split fasta file into separate fasta files based on list of scaffolds that belong to each separate file
ctbBio/name2fasta.py
def split_fasta(f, id2f): """ split fasta file into separate fasta files based on list of scaffolds that belong to each separate file """ opened = {} for seq in parse_fasta(f): id = seq[0].split('>')[1].split()[0] if id not in id2f: continue fasta = id2f[id] ...
def split_fasta(f, id2f): """ split fasta file into separate fasta files based on list of scaffolds that belong to each separate file """ opened = {} for seq in parse_fasta(f): id = seq[0].split('>')[1].split()[0] if id not in id2f: continue fasta = id2f[id] ...
[ "split", "fasta", "file", "into", "separate", "fasta", "files", "based", "on", "list", "of", "scaffolds", "that", "belong", "to", "each", "separate", "file" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/name2fasta.py#L7-L22
[ "def", "split_fasta", "(", "f", ",", "id2f", ")", ":", "opened", "=", "{", "}", "for", "seq", "in", "parse_fasta", "(", "f", ")", ":", "id", "=", "seq", "[", "0", "]", ".", "split", "(", "'>'", ")", "[", "1", "]", ".", "split", "(", ")", "[...
83b2566b3a5745437ec651cd6cafddd056846240
train
Steam._is_user_directory
Check whether `pathname` is a valid user data directory This method is meant to be called on the contents of the userdata dir. As such, it will return True when `pathname` refers to a directory name that can be interpreted as a users' userID.
pysteam/legacy/steam.py
def _is_user_directory(self, pathname): """Check whether `pathname` is a valid user data directory This method is meant to be called on the contents of the userdata dir. As such, it will return True when `pathname` refers to a directory name that can be interpreted as a users' userID. """...
def _is_user_directory(self, pathname): """Check whether `pathname` is a valid user data directory This method is meant to be called on the contents of the userdata dir. As such, it will return True when `pathname` refers to a directory name that can be interpreted as a users' userID. """...
[ "Check", "whether", "pathname", "is", "a", "valid", "user", "data", "directory" ]
scottrice/pysteam
python
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/legacy/steam.py#L47-L58
[ "def", "_is_user_directory", "(", "self", ",", "pathname", ")", ":", "fullpath", "=", "os", ".", "path", ".", "join", "(", "self", ".", "userdata_location", "(", ")", ",", "pathname", ")", "# SteamOS puts a directory named 'anonymous' in the userdata directory", "# ...
1eb2254b5235a053a953e596fa7602d0b110245d
train
Steam.local_users
Returns an array of user ids for users on the filesystem
pysteam/legacy/steam.py
def local_users(self): """Returns an array of user ids for users on the filesystem""" # Any users on the machine will have an entry inside of the userdata # folder. As such, the easiest way to find a list of all users on the # machine is to just list the folders inside userdata u...
def local_users(self): """Returns an array of user ids for users on the filesystem""" # Any users on the machine will have an entry inside of the userdata # folder. As such, the easiest way to find a list of all users on the # machine is to just list the folders inside userdata u...
[ "Returns", "an", "array", "of", "user", "ids", "for", "users", "on", "the", "filesystem" ]
scottrice/pysteam
python
https://github.com/scottrice/pysteam/blob/1eb2254b5235a053a953e596fa7602d0b110245d/pysteam/legacy/steam.py#L80-L87
[ "def", "local_users", "(", "self", ")", ":", "# Any users on the machine will have an entry inside of the userdata", "# folder. As such, the easiest way to find a list of all users on the", "# machine is to just list the folders inside userdata", "userdirs", "=", "filter", "(", "self", "...
1eb2254b5235a053a953e596fa7602d0b110245d
train
calculate_temperature_equivalent
Calculates the temperature equivalent from a series of average daily temperatures according to the formula: 0.6 * tempDay0 + 0.3 * tempDay-1 + 0.1 * tempDay-2 Parameters ---------- series : Pandas Series Returns ------- Pandas Series
opengrid/library/weather.py
def calculate_temperature_equivalent(temperatures): """ Calculates the temperature equivalent from a series of average daily temperatures according to the formula: 0.6 * tempDay0 + 0.3 * tempDay-1 + 0.1 * tempDay-2 Parameters ---------- series : Pandas Series Returns ------- Pandas...
def calculate_temperature_equivalent(temperatures): """ Calculates the temperature equivalent from a series of average daily temperatures according to the formula: 0.6 * tempDay0 + 0.3 * tempDay-1 + 0.1 * tempDay-2 Parameters ---------- series : Pandas Series Returns ------- Pandas...
[ "Calculates", "the", "temperature", "equivalent", "from", "a", "series", "of", "average", "daily", "temperatures", "according", "to", "the", "formula", ":", "0", ".", "6", "*", "tempDay0", "+", "0", ".", "3", "*", "tempDay", "-", "1", "+", "0", ".", "1...
opengridcc/opengrid
python
https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/weather.py#L12-L28
[ "def", "calculate_temperature_equivalent", "(", "temperatures", ")", ":", "ret", "=", "0.6", "*", "temperatures", "+", "0.3", "*", "temperatures", ".", "shift", "(", "1", ")", "+", "0.1", "*", "temperatures", ".", "shift", "(", "2", ")", "ret", ".", "nam...
69b8da3c8fcea9300226c45ef0628cd6d4307651
train
_calculate_degree_days
Calculates degree days, starting with a series of temperature equivalent values Parameters ---------- temperature_equivalent : Pandas Series base_temperature : float cooling : bool Set True if you want cooling degree days instead of heating degree days Returns ------- Pandas Se...
opengrid/library/weather.py
def _calculate_degree_days(temperature_equivalent, base_temperature, cooling=False): """ Calculates degree days, starting with a series of temperature equivalent values Parameters ---------- temperature_equivalent : Pandas Series base_temperature : float cooling : bool Set True if y...
def _calculate_degree_days(temperature_equivalent, base_temperature, cooling=False): """ Calculates degree days, starting with a series of temperature equivalent values Parameters ---------- temperature_equivalent : Pandas Series base_temperature : float cooling : bool Set True if y...
[ "Calculates", "degree", "days", "starting", "with", "a", "series", "of", "temperature", "equivalent", "values" ]
opengridcc/opengrid
python
https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/weather.py#L31-L59
[ "def", "_calculate_degree_days", "(", "temperature_equivalent", ",", "base_temperature", ",", "cooling", "=", "False", ")", ":", "if", "cooling", ":", "ret", "=", "temperature_equivalent", "-", "base_temperature", "else", ":", "ret", "=", "base_temperature", "-", ...
69b8da3c8fcea9300226c45ef0628cd6d4307651
train
compute_degree_days
Compute degree-days for heating and/or cooling Parameters ---------- ts : pandas.Series Contains ambient (outside) temperature. Series name (ts.name) does not matter. heating_base_temperatures: list For each base temperature the heating degree-days will be computed cooling_base_temp...
opengrid/library/weather.py
def compute_degree_days(ts, heating_base_temperatures, cooling_base_temperatures): """ Compute degree-days for heating and/or cooling Parameters ---------- ts : pandas.Series Contains ambient (outside) temperature. Series name (ts.name) does not matter. heating_base_temperatures: list ...
def compute_degree_days(ts, heating_base_temperatures, cooling_base_temperatures): """ Compute degree-days for heating and/or cooling Parameters ---------- ts : pandas.Series Contains ambient (outside) temperature. Series name (ts.name) does not matter. heating_base_temperatures: list ...
[ "Compute", "degree", "-", "days", "for", "heating", "and", "/", "or", "cooling" ]
opengridcc/opengrid
python
https://github.com/opengridcc/opengrid/blob/69b8da3c8fcea9300226c45ef0628cd6d4307651/opengrid/library/weather.py#L62-L96
[ "def", "compute_degree_days", "(", "ts", ",", "heating_base_temperatures", ",", "cooling_base_temperatures", ")", ":", "# verify the sampling rate: should be at least daily.", "mean_sampling_rate", "=", "(", "ts", ".", "index", "[", "-", "1", "]", "-", "ts", ".", "ind...
69b8da3c8fcea9300226c45ef0628cd6d4307651
train
Classifiers.status
Development status.
bootstrap_py/classifiers.py
def status(self): """Development status.""" return {self._acronym_status(l): l for l in self.resp_text.split('\n') if l.startswith(self.prefix_status)}
def status(self): """Development status.""" return {self._acronym_status(l): l for l in self.resp_text.split('\n') if l.startswith(self.prefix_status)}
[ "Development", "status", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/classifiers.py#L33-L36
[ "def", "status", "(", "self", ")", ":", "return", "{", "self", ".", "_acronym_status", "(", "l", ")", ":", "l", "for", "l", "in", "self", ".", "resp_text", ".", "split", "(", "'\\n'", ")", "if", "l", ".", "startswith", "(", "self", ".", "prefix_sta...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
Classifiers.licenses
OSI Approved license.
bootstrap_py/classifiers.py
def licenses(self): """OSI Approved license.""" return {self._acronym_lic(l): l for l in self.resp_text.split('\n') if l.startswith(self.prefix_lic)}
def licenses(self): """OSI Approved license.""" return {self._acronym_lic(l): l for l in self.resp_text.split('\n') if l.startswith(self.prefix_lic)}
[ "OSI", "Approved", "license", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/classifiers.py#L43-L46
[ "def", "licenses", "(", "self", ")", ":", "return", "{", "self", ".", "_acronym_lic", "(", "l", ")", ":", "l", "for", "l", "in", "self", ".", "resp_text", ".", "split", "(", "'\\n'", ")", "if", "l", ".", "startswith", "(", "self", ".", "prefix_lic"...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
Classifiers.licenses_desc
Remove prefix.
bootstrap_py/classifiers.py
def licenses_desc(self): """Remove prefix.""" return {self._acronym_lic(l): l.split(self.prefix_lic)[1] for l in self.resp_text.split('\n') if l.startswith(self.prefix_lic)}
def licenses_desc(self): """Remove prefix.""" return {self._acronym_lic(l): l.split(self.prefix_lic)[1] for l in self.resp_text.split('\n') if l.startswith(self.prefix_lic)}
[ "Remove", "prefix", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/classifiers.py#L48-L52
[ "def", "licenses_desc", "(", "self", ")", ":", "return", "{", "self", ".", "_acronym_lic", "(", "l", ")", ":", "l", ".", "split", "(", "self", ".", "prefix_lic", ")", "[", "1", "]", "for", "l", "in", "self", ".", "resp_text", ".", "split", "(", "...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
Classifiers._acronym_lic
Convert license acronym.
bootstrap_py/classifiers.py
def _acronym_lic(self, license_statement): """Convert license acronym.""" pat = re.compile(r'\(([\w+\W?\s?]+)\)') if pat.search(license_statement): lic = pat.search(license_statement).group(1) if lic.startswith('CNRI'): acronym_licence = lic[:4] ...
def _acronym_lic(self, license_statement): """Convert license acronym.""" pat = re.compile(r'\(([\w+\W?\s?]+)\)') if pat.search(license_statement): lic = pat.search(license_statement).group(1) if lic.startswith('CNRI'): acronym_licence = lic[:4] ...
[ "Convert", "license", "acronym", "." ]
mkouhei/bootstrap-py
python
https://github.com/mkouhei/bootstrap-py/blob/95d56ed98ef409fd9f019dc352fd1c3711533275/bootstrap_py/classifiers.py#L54-L67
[ "def", "_acronym_lic", "(", "self", ",", "license_statement", ")", ":", "pat", "=", "re", ".", "compile", "(", "r'\\(([\\w+\\W?\\s?]+)\\)'", ")", "if", "pat", ".", "search", "(", "license_statement", ")", ":", "lic", "=", "pat", ".", "search", "(", "licens...
95d56ed98ef409fd9f019dc352fd1c3711533275
train
calcMD5
calc MD5 based on path
ctbBio/ncbi_download.py
def calcMD5(path): """ calc MD5 based on path """ # check that file exists if os.path.exists(path) is False: yield False else: command = ['md5sum', path] p = Popen(command, stdout = PIPE) for line in p.communicate()[0].splitlines(): yield line.decode('...
def calcMD5(path): """ calc MD5 based on path """ # check that file exists if os.path.exists(path) is False: yield False else: command = ['md5sum', path] p = Popen(command, stdout = PIPE) for line in p.communicate()[0].splitlines(): yield line.decode('...
[ "calc", "MD5", "based", "on", "path" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/ncbi_download.py#L18-L31
[ "def", "calcMD5", "(", "path", ")", ":", "# check that file exists", "if", "os", ".", "path", ".", "exists", "(", "path", ")", "is", "False", ":", "yield", "False", "else", ":", "command", "=", "[", "'md5sum'", ",", "path", "]", "p", "=", "Popen", "(...
83b2566b3a5745437ec651cd6cafddd056846240
train
md5check
* comfirm that downloaded files match md5 checksum on server * if md5 is False, only check path for the download
ctbBio/ncbi_download.py
def md5check(f, ftp, md5, exclude): """ * comfirm that downloaded files match md5 checksum on server * if md5 is False, only check path for the download """ files = glob(f) # if no md5 file is specified: download files if path does not exist if md5 is False: if len(files) == 0: ...
def md5check(f, ftp, md5, exclude): """ * comfirm that downloaded files match md5 checksum on server * if md5 is False, only check path for the download """ files = glob(f) # if no md5 file is specified: download files if path does not exist if md5 is False: if len(files) == 0: ...
[ "*", "comfirm", "that", "downloaded", "files", "match", "md5", "checksum", "on", "server", "*", "if", "md5", "is", "False", "only", "check", "path", "for", "the", "download" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/ncbi_download.py#L33-L72
[ "def", "md5check", "(", "f", ",", "ftp", ",", "md5", ",", "exclude", ")", ":", "files", "=", "glob", "(", "f", ")", "# if no md5 file is specified: download files if path does not exist", "if", "md5", "is", "False", ":", "if", "len", "(", "files", ")", "==",...
83b2566b3a5745437ec651cd6cafddd056846240
train
wget
download files with wget
ctbBio/ncbi_download.py
def wget(ftp, f = False, exclude = False, name = False, md5 = False, tries = 10): """ download files with wget """ # file name if f is False: f = ftp.rsplit('/', 1)[-1] # downloaded file if it does not already exist # check md5s on server (optional) t = 0 while md5check(f, ft...
def wget(ftp, f = False, exclude = False, name = False, md5 = False, tries = 10): """ download files with wget """ # file name if f is False: f = ftp.rsplit('/', 1)[-1] # downloaded file if it does not already exist # check md5s on server (optional) t = 0 while md5check(f, ft...
[ "download", "files", "with", "wget" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/ncbi_download.py#L74-L97
[ "def", "wget", "(", "ftp", ",", "f", "=", "False", ",", "exclude", "=", "False", ",", "name", "=", "False", ",", "md5", "=", "False", ",", "tries", "=", "10", ")", ":", "# file name", "if", "f", "is", "False", ":", "f", "=", "ftp", ".", "rsplit...
83b2566b3a5745437ec651cd6cafddd056846240
train
check
check that at least one of queries is in list, l
ctbBio/ncbi_download.py
def check(line, queries): """ check that at least one of queries is in list, l """ line = line.strip() spLine = line.replace('.', ' ').split() matches = set(spLine).intersection(queries) if len(matches) > 0: return matches, line.split('\t') return matches, False
def check(line, queries): """ check that at least one of queries is in list, l """ line = line.strip() spLine = line.replace('.', ' ').split() matches = set(spLine).intersection(queries) if len(matches) > 0: return matches, line.split('\t') return matches, False
[ "check", "that", "at", "least", "one", "of", "queries", "is", "in", "list", "l" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/ncbi_download.py#L99-L109
[ "def", "check", "(", "line", ",", "queries", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "spLine", "=", "line", ".", "replace", "(", "'.'", ",", "' '", ")", ".", "split", "(", ")", "matches", "=", "set", "(", "spLine", ")", ".", "int...
83b2566b3a5745437ec651cd6cafddd056846240
train
entrez
search entrez using specified database and accession
ctbBio/ncbi_download.py
def entrez(db, acc): """ search entrez using specified database and accession """ c1 = ['esearch', '-db', db, '-query', acc] c2 = ['efetch', '-db', 'BioSample', '-format', 'docsum'] p1 = Popen(c1, stdout = PIPE, stderr = PIPE) p2 = Popen(c2, stdin = p1.stdout, stdout = PIPE, stderr = PIP...
def entrez(db, acc): """ search entrez using specified database and accession """ c1 = ['esearch', '-db', db, '-query', acc] c2 = ['efetch', '-db', 'BioSample', '-format', 'docsum'] p1 = Popen(c1, stdout = PIPE, stderr = PIPE) p2 = Popen(c2, stdin = p1.stdout, stdout = PIPE, stderr = PIP...
[ "search", "entrez", "using", "specified", "database", "and", "accession" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/ncbi_download.py#L111-L120
[ "def", "entrez", "(", "db", ",", "acc", ")", ":", "c1", "=", "[", "'esearch'", ",", "'-db'", ",", "db", ",", "'-query'", ",", "acc", "]", "c2", "=", "[", "'efetch'", ",", "'-db'", ",", "'BioSample'", ",", "'-format'", ",", "'docsum'", "]", "p1", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
searchAccession
attempt to use NCBI Entrez to get BioSample ID
ctbBio/ncbi_download.py
def searchAccession(acc): """ attempt to use NCBI Entrez to get BioSample ID """ # try genbank file # genome database out, error = entrez('genome', acc) for line in out.splitlines(): line = line.decode('ascii').strip() if 'Assembly_Accession' in line or 'BioSample' in lin...
def searchAccession(acc): """ attempt to use NCBI Entrez to get BioSample ID """ # try genbank file # genome database out, error = entrez('genome', acc) for line in out.splitlines(): line = line.decode('ascii').strip() if 'Assembly_Accession' in line or 'BioSample' in lin...
[ "attempt", "to", "use", "NCBI", "Entrez", "to", "get", "BioSample", "ID" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/ncbi_download.py#L122-L156
[ "def", "searchAccession", "(", "acc", ")", ":", "# try genbank file", "# genome database", "out", ",", "error", "=", "entrez", "(", "'genome'", ",", "acc", ")", "for", "line", "in", "out", ".", "splitlines", "(", ")", ":", "line", "=", "line", ".", "deco...
83b2566b3a5745437ec651cd6cafddd056846240
train
getFTPs
download genome info from NCBI
ctbBio/ncbi_download.py
def getFTPs(accessions, ftp, search, exclude, convert = False, threads = 1, attempt = 1, max_attempts = 2): """ download genome info from NCBI """ info = wget(ftp)[0] allMatches = [] for genome in open(info, encoding = 'utf8'): genome = str(genome) matches, genomeInfo...
def getFTPs(accessions, ftp, search, exclude, convert = False, threads = 1, attempt = 1, max_attempts = 2): """ download genome info from NCBI """ info = wget(ftp)[0] allMatches = [] for genome in open(info, encoding = 'utf8'): genome = str(genome) matches, genomeInfo...
[ "download", "genome", "info", "from", "NCBI" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/ncbi_download.py#L158-L195
[ "def", "getFTPs", "(", "accessions", ",", "ftp", ",", "search", ",", "exclude", ",", "convert", "=", "False", ",", "threads", "=", "1", ",", "attempt", "=", "1", ",", "max_attempts", "=", "2", ")", ":", "info", "=", "wget", "(", "ftp", ")", "[", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
download
download genomes from NCBI
ctbBio/ncbi_download.py
def download(args): """ download genomes from NCBI """ accessions, infoFTP = set(args['g']), args['i'] search, exclude = args['s'], args['e'] FTPs = getFTPs(accessions, infoFTP, search, exclude, threads = args['t'], convert = args['convert']) if args['test'] is True: for ...
def download(args): """ download genomes from NCBI """ accessions, infoFTP = set(args['g']), args['i'] search, exclude = args['s'], args['e'] FTPs = getFTPs(accessions, infoFTP, search, exclude, threads = args['t'], convert = args['convert']) if args['test'] is True: for ...
[ "download", "genomes", "from", "NCBI" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/ncbi_download.py#L204-L221
[ "def", "download", "(", "args", ")", ":", "accessions", ",", "infoFTP", "=", "set", "(", "args", "[", "'g'", "]", ")", ",", "args", "[", "'i'", "]", "search", ",", "exclude", "=", "args", "[", "'s'", "]", ",", "args", "[", "'e'", "]", "FTPs", "...
83b2566b3a5745437ec651cd6cafddd056846240
train
fix_fasta
remove pesky characters from fasta file header
ctbBio/fix_fasta.py
def fix_fasta(fasta): """ remove pesky characters from fasta file header """ for seq in parse_fasta(fasta): seq[0] = remove_char(seq[0]) if len(seq[1]) > 0: yield seq
def fix_fasta(fasta): """ remove pesky characters from fasta file header """ for seq in parse_fasta(fasta): seq[0] = remove_char(seq[0]) if len(seq[1]) > 0: yield seq
[ "remove", "pesky", "characters", "from", "fasta", "file", "header" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/fix_fasta.py#L18-L25
[ "def", "fix_fasta", "(", "fasta", ")", ":", "for", "seq", "in", "parse_fasta", "(", "fasta", ")", ":", "seq", "[", "0", "]", "=", "remove_char", "(", "seq", "[", "0", "]", ")", "if", "len", "(", "seq", "[", "1", "]", ")", ">", "0", ":", "yiel...
83b2566b3a5745437ec651cd6cafddd056846240
train
plot_LDA
Plot transformed LDA data.
bin/LDA.py
def plot_LDA(X_lda, y_lda, class_colors, exp_var, style, fig_size, label_pad, font_size, sids, dim=2, zangles=None, pt_size=250, out_fp=""): """ Plot transformed LDA data. """ cats = class_colors.keys() fig = plt.figure(figsize=fig_size) if dim == 3: try: assert ...
def plot_LDA(X_lda, y_lda, class_colors, exp_var, style, fig_size, label_pad, font_size, sids, dim=2, zangles=None, pt_size=250, out_fp=""): """ Plot transformed LDA data. """ cats = class_colors.keys() fig = plt.figure(figsize=fig_size) if dim == 3: try: assert ...
[ "Plot", "transformed", "LDA", "data", "." ]
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/LDA.py#L45-L121
[ "def", "plot_LDA", "(", "X_lda", ",", "y_lda", ",", "class_colors", ",", "exp_var", ",", "style", ",", "fig_size", ",", "label_pad", ",", "font_size", ",", "sids", ",", "dim", "=", "2", ",", "zangles", "=", "None", ",", "pt_size", "=", "250", ",", "o...
0b74ef171e6a84761710548501dfac71285a58a3
train
run_LDA
Run LinearDiscriminantAnalysis on input dataframe (df) and return transformed data, scalings and explained variance by discriminants.
bin/LDA.py
def run_LDA(df): """ Run LinearDiscriminantAnalysis on input dataframe (df) and return transformed data, scalings and explained variance by discriminants. """ # Prep variables for sklearn LDA X = df.iloc[:, 1:df.shape[1]].values # input data matrix y = df["Condition"].values ...
def run_LDA(df): """ Run LinearDiscriminantAnalysis on input dataframe (df) and return transformed data, scalings and explained variance by discriminants. """ # Prep variables for sklearn LDA X = df.iloc[:, 1:df.shape[1]].values # input data matrix y = df["Condition"].values ...
[ "Run", "LinearDiscriminantAnalysis", "on", "input", "dataframe", "(", "df", ")", "and", "return", "transformed", "data", "scalings", "and", "explained", "variance", "by", "discriminants", "." ]
smdabdoub/phylotoast
python
https://github.com/smdabdoub/phylotoast/blob/0b74ef171e6a84761710548501dfac71285a58a3/bin/LDA.py#L124-L142
[ "def", "run_LDA", "(", "df", ")", ":", "# Prep variables for sklearn LDA", "X", "=", "df", ".", "iloc", "[", ":", ",", "1", ":", "df", ".", "shape", "[", "1", "]", "]", ".", "values", "# input data matrix", "y", "=", "df", "[", "\"Condition\"", "]", ...
0b74ef171e6a84761710548501dfac71285a58a3
train
_calc_frames
Compute a DataFrame summary of a Stats object.
pstatsviewer/viewer.py
def _calc_frames(stats): """ Compute a DataFrame summary of a Stats object. """ timings = [] callers = [] for key, values in iteritems(stats.stats): timings.append( pd.Series( key + values[:-1], index=timing_colnames, ) ) ...
def _calc_frames(stats): """ Compute a DataFrame summary of a Stats object. """ timings = [] callers = [] for key, values in iteritems(stats.stats): timings.append( pd.Series( key + values[:-1], index=timing_colnames, ) ) ...
[ "Compute", "a", "DataFrame", "summary", "of", "a", "Stats", "object", "." ]
ssanderson/pstats-view
python
https://github.com/ssanderson/pstats-view/blob/62148d4e01765806bc5e6bb40628cdb186482c05/pstatsviewer/viewer.py#L40-L66
[ "def", "_calc_frames", "(", "stats", ")", ":", "timings", "=", "[", "]", "callers", "=", "[", "]", "for", "key", ",", "values", "in", "iteritems", "(", "stats", ".", "stats", ")", ":", "timings", ".", "append", "(", "pd", ".", "Series", "(", "key",...
62148d4e01765806bc5e6bb40628cdb186482c05
train
unmapped
get unmapped reads
ctbBio/unmapped.py
def unmapped(sam, mates): """ get unmapped reads """ for read in sam: if read.startswith('@') is True: continue read = read.strip().split() if read[2] == '*' and read[6] == '*': yield read elif mates is True: if read[2] == '*' or re...
def unmapped(sam, mates): """ get unmapped reads """ for read in sam: if read.startswith('@') is True: continue read = read.strip().split() if read[2] == '*' and read[6] == '*': yield read elif mates is True: if read[2] == '*' or re...
[ "get", "unmapped", "reads" ]
christophertbrown/bioscripts
python
https://github.com/christophertbrown/bioscripts/blob/83b2566b3a5745437ec651cd6cafddd056846240/ctbBio/unmapped.py#L11-L26
[ "def", "unmapped", "(", "sam", ",", "mates", ")", ":", "for", "read", "in", "sam", ":", "if", "read", ".", "startswith", "(", "'@'", ")", "is", "True", ":", "continue", "read", "=", "read", ".", "strip", "(", ")", ".", "split", "(", ")", "if", ...
83b2566b3a5745437ec651cd6cafddd056846240
train
sugartex_preprocess
Preprocess text for SugarTeX Pandoc filter. Replaces 'ˎ' with `$` (except `\ˎ`), replaces `\ˎ` with `ˎ`
sugartex/pre_sugartex.py
def sugartex_preprocess(source: str) -> str: """ Preprocess text for SugarTeX Pandoc filter. Replaces 'ˎ' with `$` (except `\ˎ`), replaces `\ˎ` with `ˎ` """ rep = {r'\ˎ': 'ˎ', 'ˎ': '$'} return re.sub(r'\\ˎ|ˎ', lambda m: rep[m.group(0)], source)
def sugartex_preprocess(source: str) -> str: """ Preprocess text for SugarTeX Pandoc filter. Replaces 'ˎ' with `$` (except `\ˎ`), replaces `\ˎ` with `ˎ` """ rep = {r'\ˎ': 'ˎ', 'ˎ': '$'} return re.sub(r'\\ˎ|ˎ', lambda m: rep[m.group(0)], source)
[ "Preprocess", "text", "for", "SugarTeX", "Pandoc", "filter", ".", "Replaces", "ˎ", "with", "$", "(", "except", "\\", "ˎ", ")", "replaces", "\\", "ˎ", "with", "ˎ" ]
kiwi0fruit/sugartex
python
https://github.com/kiwi0fruit/sugartex/blob/9eb13703cb02d3e2163c9c5f29df280f6bf49cec/sugartex/pre_sugartex.py#L13-L19
[ "def", "sugartex_preprocess", "(", "source", ":", "str", ")", "->", "str", ":", "rep", "=", "{", "r'\\ˎ':", " ", "ˎ', ", "'", "': '", "$", "}", "", "return", "re", ".", "sub", "(", "r'\\\\ˎ|ˎ', ", "l", "mbda m", " ", "r", "p[m", ".", "g", "r", "o...
9eb13703cb02d3e2163c9c5f29df280f6bf49cec
train
sugartex_replace_all
Replace all with SugarTeX. Runs ``sugartex_preprocess`` then iterates via regex and replaces each math between '$...$'.
sugartex/pre_sugartex.py
def sugartex_replace_all(string): """ Replace all with SugarTeX. Runs ``sugartex_preprocess`` then iterates via regex and replaces each math between '$...$'. """ string = sugartex_preprocess(string).replace(r'\$', SESSION_ID) return re.sub( r'(?<=\$)[^$]*(?=\$)', lambda m: su...
def sugartex_replace_all(string): """ Replace all with SugarTeX. Runs ``sugartex_preprocess`` then iterates via regex and replaces each math between '$...$'. """ string = sugartex_preprocess(string).replace(r'\$', SESSION_ID) return re.sub( r'(?<=\$)[^$]*(?=\$)', lambda m: su...
[ "Replace", "all", "with", "SugarTeX", ".", "Runs", "sugartex_preprocess", "then", "iterates", "via", "regex", "and", "replaces", "each", "math", "between", "$", "...", "$", "." ]
kiwi0fruit/sugartex
python
https://github.com/kiwi0fruit/sugartex/blob/9eb13703cb02d3e2163c9c5f29df280f6bf49cec/sugartex/pre_sugartex.py#L25-L36
[ "def", "sugartex_replace_all", "(", "string", ")", ":", "string", "=", "sugartex_preprocess", "(", "string", ")", ".", "replace", "(", "r'\\$'", ",", "SESSION_ID", ")", "return", "re", ".", "sub", "(", "r'(?<=\\$)[^$]*(?=\\$)'", ",", "lambda", "m", ":", "sug...
9eb13703cb02d3e2163c9c5f29df280f6bf49cec