repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
bxlab/bx-python
lib/bx_extras/pyparsing.py
countedArray
def countedArray( expr ): """Helper to define a counted list of expressions. This helper defines a pattern of the form:: integer expr expr expr... where the leading integer tells how many expr expressions follow. The matched tokens returns the array of expr tokens as a list - the lea...
python
def countedArray( expr ): """Helper to define a counted list of expressions. This helper defines a pattern of the form:: integer expr expr expr... where the leading integer tells how many expr expressions follow. The matched tokens returns the array of expr tokens as a list - the lea...
[ "def", "countedArray", "(", "expr", ")", ":", "arrayExpr", "=", "Forward", "(", ")", "def", "countFieldParseAction", "(", "s", ",", "l", ",", "t", ")", ":", "n", "=", "int", "(", "t", "[", "0", "]", ")", "arrayExpr", "<<", "(", "n", "and", "Group...
Helper to define a counted list of expressions. This helper defines a pattern of the form:: integer expr expr expr... where the leading integer tells how many expr expressions follow. The matched tokens returns the array of expr tokens as a list - the leading count token is suppressed.
[ "Helper", "to", "define", "a", "counted", "list", "of", "expressions", ".", "This", "helper", "defines", "a", "pattern", "of", "the", "form", "::", "integer", "expr", "expr", "expr", "...", "where", "the", "leading", "integer", "tells", "how", "many", "exp...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pyparsing.py#L3051-L3063
bxlab/bx-python
lib/bx_extras/pyparsing.py
nestedExpr
def nestedExpr(opener="(", closer=")", content=None, ignoreExpr=quotedString): """Helper method for defining nested lists enclosed in opening and closing delimiters ("(" and ")" are the default). Parameters: - opener - opening character for a nested list (default="("); can also be a pyparsing...
python
def nestedExpr(opener="(", closer=")", content=None, ignoreExpr=quotedString): """Helper method for defining nested lists enclosed in opening and closing delimiters ("(" and ")" are the default). Parameters: - opener - opening character for a nested list (default="("); can also be a pyparsing...
[ "def", "nestedExpr", "(", "opener", "=", "\"(\"", ",", "closer", "=", "\")\"", ",", "content", "=", "None", ",", "ignoreExpr", "=", "quotedString", ")", ":", "if", "opener", "==", "closer", ":", "raise", "ValueError", "(", "\"opening and closing strings cannot...
Helper method for defining nested lists enclosed in opening and closing delimiters ("(" and ")" are the default). Parameters: - opener - opening character for a nested list (default="("); can also be a pyparsing expression - closer - closing character for a nested list (default=")"); can ...
[ "Helper", "method", "for", "defining", "nested", "lists", "enclosed", "in", "opening", "and", "closing", "delimiters", "(", "(", "and", ")", "are", "the", "default", ")", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pyparsing.py#L3443-L3481
bxlab/bx-python
lib/bx_extras/pyparsing.py
ParserElement.setBreak
def setBreak(self,breakFlag = True): """Method to invoke the Python pdb debugger when this element is about to be parsed. Set breakFlag to True to enable, False to disable. """ if breakFlag: _parseMethod = self._parse def breaker(instring, loc, doAct...
python
def setBreak(self,breakFlag = True): """Method to invoke the Python pdb debugger when this element is about to be parsed. Set breakFlag to True to enable, False to disable. """ if breakFlag: _parseMethod = self._parse def breaker(instring, loc, doAct...
[ "def", "setBreak", "(", "self", ",", "breakFlag", "=", "True", ")", ":", "if", "breakFlag", ":", "_parseMethod", "=", "self", ".", "_parse", "def", "breaker", "(", "instring", ",", "loc", ",", "doActions", "=", "True", ",", "callPreParse", "=", "True", ...
Method to invoke the Python pdb debugger when this element is about to be parsed. Set breakFlag to True to enable, False to disable.
[ "Method", "to", "invoke", "the", "Python", "pdb", "debugger", "when", "this", "element", "is", "about", "to", "be", "parsed", ".", "Set", "breakFlag", "to", "True", "to", "enable", "False", "to", "disable", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pyparsing.py#L709-L725
bxlab/bx-python
lib/bx_extras/pyparsing.py
ParserElement._normalizeParseActionArgs
def _normalizeParseActionArgs( f ): """Internal method used to decorate parse actions that take fewer than 3 arguments, so that all parse actions can be called as f(s,l,t).""" STAR_ARGS = 4 try: restore = None if isinstance(f,type): restore = f...
python
def _normalizeParseActionArgs( f ): """Internal method used to decorate parse actions that take fewer than 3 arguments, so that all parse actions can be called as f(s,l,t).""" STAR_ARGS = 4 try: restore = None if isinstance(f,type): restore = f...
[ "def", "_normalizeParseActionArgs", "(", "f", ")", ":", "STAR_ARGS", "=", "4", "try", ":", "restore", "=", "None", "if", "isinstance", "(", "f", ",", "type", ")", ":", "restore", "=", "f", "f", "=", "f", ".", "__init__", "if", "not", "_PY3K", ":", ...
Internal method used to decorate parse actions that take fewer than 3 arguments, so that all parse actions can be called as f(s,l,t).
[ "Internal", "method", "used", "to", "decorate", "parse", "actions", "that", "take", "fewer", "than", "3", "arguments", "so", "that", "all", "parse", "actions", "can", "be", "called", "as", "f", "(", "s", "l", "t", ")", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pyparsing.py#L727-L818
bxlab/bx-python
lib/bx_extras/pyparsing.py
ParserElement.parseString
def parseString( self, instring, parseAll=False ): """Execute the parse expression with the given string. This is the main interface to the client code, once the complete expression has been built. If you want the grammar to require that the entire input string be su...
python
def parseString( self, instring, parseAll=False ): """Execute the parse expression with the given string. This is the main interface to the client code, once the complete expression has been built. If you want the grammar to require that the entire input string be su...
[ "def", "parseString", "(", "self", ",", "instring", ",", "parseAll", "=", "False", ")", ":", "ParserElement", ".", "resetCache", "(", ")", "if", "not", "self", ".", "streamlined", ":", "self", ".", "streamline", "(", ")", "#~ self.saveAsList = True", "for", ...
Execute the parse expression with the given string. This is the main interface to the client code, once the complete expression has been built. If you want the grammar to require that the entire input string be successfully parsed, then set parseAll to True (equivalent to en...
[ "Execute", "the", "parse", "expression", "with", "the", "given", "string", ".", "This", "is", "the", "main", "interface", "to", "the", "client", "code", "once", "the", "complete", "expression", "has", "been", "built", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pyparsing.py#L1019-L1052
bxlab/bx-python
lib/bx_extras/pyparsing.py
ParserElement.transformString
def transformString( self, instring ): """Extension to scanString, to modify matching text with modified tokens that may be returned from a parse action. To use transformString, define a grammar and attach a parse action to it that modifies the returned token list. Invoking tra...
python
def transformString( self, instring ): """Extension to scanString, to modify matching text with modified tokens that may be returned from a parse action. To use transformString, define a grammar and attach a parse action to it that modifies the returned token list. Invoking tra...
[ "def", "transformString", "(", "self", ",", "instring", ")", ":", "out", "=", "[", "]", "lastE", "=", "0", "# force preservation of <TAB>s, to minimize unwanted transformation of string, and to", "# keep string locs straight between transformString and scanString", "self", ".", ...
Extension to scanString, to modify matching text with modified tokens that may be returned from a parse action. To use transformString, define a grammar and attach a parse action to it that modifies the returned token list. Invoking transformString() on a target string will then scan f...
[ "Extension", "to", "scanString", "to", "modify", "matching", "text", "with", "modified", "tokens", "that", "may", "be", "returned", "from", "a", "parse", "action", ".", "To", "use", "transformString", "define", "a", "grammar", "and", "attach", "a", "parse", ...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pyparsing.py#L1086-L1109
bxlab/bx-python
lib/bx_extras/pyparsing.py
ParserElement.searchString
def searchString( self, instring, maxMatches=_MAX_INT ): """Another extension to scanString, simplifying the access to the tokens found to match the given parse expression. May be called with optional maxMatches argument, to clip searching after 'n' matches are found. """ ...
python
def searchString( self, instring, maxMatches=_MAX_INT ): """Another extension to scanString, simplifying the access to the tokens found to match the given parse expression. May be called with optional maxMatches argument, to clip searching after 'n' matches are found. """ ...
[ "def", "searchString", "(", "self", ",", "instring", ",", "maxMatches", "=", "_MAX_INT", ")", ":", "return", "ParseResults", "(", "[", "t", "for", "t", ",", "s", ",", "e", "in", "self", ".", "scanString", "(", "instring", ",", "maxMatches", ")", "]", ...
Another extension to scanString, simplifying the access to the tokens found to match the given parse expression. May be called with optional maxMatches argument, to clip searching after 'n' matches are found.
[ "Another", "extension", "to", "scanString", "simplifying", "the", "access", "to", "the", "tokens", "found", "to", "match", "the", "given", "parse", "expression", ".", "May", "be", "called", "with", "optional", "maxMatches", "argument", "to", "clip", "searching",...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pyparsing.py#L1111-L1116
bxlab/bx-python
lib/bx_extras/pyparsing.py
ParserElement.parseFile
def parseFile( self, file_or_filename ): """Execute the parse expression on the given file or filename. If a filename is specified (instead of a file object), the entire file is opened, read, and closed before parsing. """ try: file_contents = file_or_filename.r...
python
def parseFile( self, file_or_filename ): """Execute the parse expression on the given file or filename. If a filename is specified (instead of a file object), the entire file is opened, read, and closed before parsing. """ try: file_contents = file_or_filename.r...
[ "def", "parseFile", "(", "self", ",", "file_or_filename", ")", ":", "try", ":", "file_contents", "=", "file_or_filename", ".", "read", "(", ")", "except", "AttributeError", ":", "f", "=", "open", "(", "file_or_filename", ",", "\"rb\"", ")", "file_contents", ...
Execute the parse expression on the given file or filename. If a filename is specified (instead of a file object), the entire file is opened, read, and closed before parsing.
[ "Execute", "the", "parse", "expression", "on", "the", "given", "file", "or", "filename", ".", "If", "a", "filename", "is", "specified", "(", "instead", "of", "a", "file", "object", ")", "the", "entire", "file", "is", "opened", "read", "and", "closed", "b...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/pyparsing.py#L1364-L1375
bxlab/bx-python
lib/bx/align/epo.py
Chain._strfactory
def _strfactory(cls, line): """factory class method for Chain :param line: header of a chain (in .chain format) """ assert type(line) == str, "this is a factory from string" line = line.rstrip().split()[1:] # the first component is the keyword "chain" tup = [t[0](t[1])...
python
def _strfactory(cls, line): """factory class method for Chain :param line: header of a chain (in .chain format) """ assert type(line) == str, "this is a factory from string" line = line.rstrip().split()[1:] # the first component is the keyword "chain" tup = [t[0](t[1])...
[ "def", "_strfactory", "(", "cls", ",", "line", ")", ":", "assert", "type", "(", "line", ")", "==", "str", ",", "\"this is a factory from string\"", "line", "=", "line", ".", "rstrip", "(", ")", ".", "split", "(", ")", "[", "1", ":", "]", "# the first c...
factory class method for Chain :param line: header of a chain (in .chain format)
[ "factory", "class", "method", "for", "Chain" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L30-L40
bxlab/bx-python
lib/bx/align/epo.py
Chain._make_from_epo
def _make_from_epo(cls, trg_comp, qr_comp, trg_chrom_sizes, qr_chrom_sizes): """crate a chain of collinear rings from the given components. The target of the chain will always be on the forward strand. This is done to avoid confusion when mapping psl files. So, if trg_comp.strand=-, qr...
python
def _make_from_epo(cls, trg_comp, qr_comp, trg_chrom_sizes, qr_chrom_sizes): """crate a chain of collinear rings from the given components. The target of the chain will always be on the forward strand. This is done to avoid confusion when mapping psl files. So, if trg_comp.strand=-, qr...
[ "def", "_make_from_epo", "(", "cls", ",", "trg_comp", ",", "qr_comp", ",", "trg_chrom_sizes", ",", "qr_chrom_sizes", ")", ":", "# size, target, query arrays", "S", ",", "T", ",", "Q", "=", "[", "]", ",", "[", "]", ",", "[", "]", "#the target strand of the ch...
crate a chain of collinear rings from the given components. The target of the chain will always be on the forward strand. This is done to avoid confusion when mapping psl files. So, if trg_comp.strand=-, qr_comp.strand=- (resp. +) the chain header will have tStrand=+, qStrand=+ (resp. ...
[ "crate", "a", "chain", "of", "collinear", "rings", "from", "the", "given", "components", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L43-L123
bxlab/bx-python
lib/bx/align/epo.py
Chain.slice
def slice(self, who): "return the slice entry (in a bed6 format), AS IS in the chain header" assert who in ('t', 'q'), "who should be 't' or 'q'" if who == 't': return (self.tName, self.tStart, self.tEnd, self.id, self.score, self.tStrand) else: return (self.qNa...
python
def slice(self, who): "return the slice entry (in a bed6 format), AS IS in the chain header" assert who in ('t', 'q'), "who should be 't' or 'q'" if who == 't': return (self.tName, self.tStart, self.tEnd, self.id, self.score, self.tStrand) else: return (self.qNa...
[ "def", "slice", "(", "self", ",", "who", ")", ":", "assert", "who", "in", "(", "'t'", ",", "'q'", ")", ",", "\"who should be 't' or 'q'\"", "if", "who", "==", "'t'", ":", "return", "(", "self", ".", "tName", ",", "self", ".", "tStart", ",", "self", ...
return the slice entry (in a bed6 format), AS IS in the chain header
[ "return", "the", "slice", "entry", "(", "in", "a", "bed6", "format", ")", "AS", "IS", "in", "the", "chain", "header" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L125-L133
bxlab/bx-python
lib/bx/align/epo.py
Chain.bedInterval
def bedInterval(self, who): "return a BED6 entry, thus DOES coordinate conversion for minus strands" if who == 't': st, en = self.tStart, self.tEnd if self.tStrand == '-': st, en = self.tSize-en, self.tSize-st return (self.tName, st, en, self.id, self...
python
def bedInterval(self, who): "return a BED6 entry, thus DOES coordinate conversion for minus strands" if who == 't': st, en = self.tStart, self.tEnd if self.tStrand == '-': st, en = self.tSize-en, self.tSize-st return (self.tName, st, en, self.id, self...
[ "def", "bedInterval", "(", "self", ",", "who", ")", ":", "if", "who", "==", "'t'", ":", "st", ",", "en", "=", "self", ".", "tStart", ",", "self", ".", "tEnd", "if", "self", ".", "tStrand", "==", "'-'", ":", "st", ",", "en", "=", "self", ".", ...
return a BED6 entry, thus DOES coordinate conversion for minus strands
[ "return", "a", "BED6", "entry", "thus", "DOES", "coordinate", "conversion", "for", "minus", "strands" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L135-L148
bxlab/bx-python
lib/bx/align/epo.py
Chain._parse_file
def _parse_file(cls, path, pickle=False): """parse a .chain file into a list of the type [(L{Chain}, arr, arr, arr) ...] :param fname: name of the file""" fname = path if fname.endswith(".gz"): fname = path[:-3] if fname.endswith('.pkl'): #you asked for...
python
def _parse_file(cls, path, pickle=False): """parse a .chain file into a list of the type [(L{Chain}, arr, arr, arr) ...] :param fname: name of the file""" fname = path if fname.endswith(".gz"): fname = path[:-3] if fname.endswith('.pkl'): #you asked for...
[ "def", "_parse_file", "(", "cls", ",", "path", ",", "pickle", "=", "False", ")", ":", "fname", "=", "path", "if", "fname", ".", "endswith", "(", "\".gz\"", ")", ":", "fname", "=", "path", "[", ":", "-", "3", "]", "if", "fname", ".", "endswith", "...
parse a .chain file into a list of the type [(L{Chain}, arr, arr, arr) ...] :param fname: name of the file
[ "parse", "a", ".", "chain", "file", "into", "a", "list", "of", "the", "type", "[", "(", "L", "{", "Chain", "}", "arr", "arr", "arr", ")", "...", "]" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L151-L176
bxlab/bx-python
lib/bx/align/epo.py
EPOitem._strfactory
def _strfactory(cls, line): """factory method for an EPOitem :param line: a line of input""" cmp = line.rstrip().split() chrom = cmp[2] if not chrom.startswith("chr"): chrom = "chr%s" % chrom instance = tuple.__new__(cls, (cmp[0], cmp[1], ...
python
def _strfactory(cls, line): """factory method for an EPOitem :param line: a line of input""" cmp = line.rstrip().split() chrom = cmp[2] if not chrom.startswith("chr"): chrom = "chr%s" % chrom instance = tuple.__new__(cls, (cmp[0], cmp[1], ...
[ "def", "_strfactory", "(", "cls", ",", "line", ")", ":", "cmp", "=", "line", ".", "rstrip", "(", ")", ".", "split", "(", ")", "chrom", "=", "cmp", "[", "2", "]", "if", "not", "chrom", ".", "startswith", "(", "\"chr\"", ")", ":", "chrom", "=", "...
factory method for an EPOitem :param line: a line of input
[ "factory", "method", "for", "an", "EPOitem" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L192-L210
bxlab/bx-python
lib/bx/align/epo.py
EPOitem._parse_epo
def _parse_epo(cls, fname): """Load an entire file in the EPO format into a dictionary of the type {gab_id => [Epoitem, ...]} :param fname: file name""" data = {} with open(fname) as fd: for el in (cls._strfactory(_) for _ in fd): if el: ...
python
def _parse_epo(cls, fname): """Load an entire file in the EPO format into a dictionary of the type {gab_id => [Epoitem, ...]} :param fname: file name""" data = {} with open(fname) as fd: for el in (cls._strfactory(_) for _ in fd): if el: ...
[ "def", "_parse_epo", "(", "cls", ",", "fname", ")", ":", "data", "=", "{", "}", "with", "open", "(", "fname", ")", "as", "fd", ":", "for", "el", "in", "(", "cls", ".", "_strfactory", "(", "_", ")", "for", "_", "in", "fd", ")", ":", "if", "el"...
Load an entire file in the EPO format into a dictionary of the type {gab_id => [Epoitem, ...]} :param fname: file name
[ "Load", "an", "entire", "file", "in", "the", "EPO", "format", "into", "a", "dictionary", "of", "the", "type", "{", "gab_id", "=", ">", "[", "Epoitem", "...", "]", "}" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L213-L224
bxlab/bx-python
lib/bx/align/epo.py
EPOitem.cigar_iter
def cigar_iter(self, reverse): """self.cigar => [(length, type) ... ] iterate the cigar :param reverse: whether to iterate in the reverse direction (right-to-left) :type reverse: boolean :return a list of pairs of the type [(length, M/D) ..] """ l = 0 P = self....
python
def cigar_iter(self, reverse): """self.cigar => [(length, type) ... ] iterate the cigar :param reverse: whether to iterate in the reverse direction (right-to-left) :type reverse: boolean :return a list of pairs of the type [(length, M/D) ..] """ l = 0 P = self....
[ "def", "cigar_iter", "(", "self", ",", "reverse", ")", ":", "l", "=", "0", "P", "=", "self", ".", "cigar_pattern", "data", "=", "[", "]", "cigar", "=", "self", ".", "cigar", "parsed_cigar", "=", "re", ".", "findall", "(", "P", ",", "cigar", ")", ...
self.cigar => [(length, type) ... ] iterate the cigar :param reverse: whether to iterate in the reverse direction (right-to-left) :type reverse: boolean :return a list of pairs of the type [(length, M/D) ..]
[ "self", ".", "cigar", "=", ">", "[", "(", "length", "type", ")", "...", "]", "iterate", "the", "cigar" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L226-L247
bxlab/bx-python
lib/bx/align/epo.py
EPOitem.intervals
def intervals(self, reverse, thr=0): """return a list of (0-based half-open) intervals representing the match regions of the cigar for example 4MD4M2DM with reverse=False will produce [(0,4), (5,9), (11,12)] 4MD4M2DM with reverse=True will produce [(0,1), (3,7), (8,12)] (= 12 - previous interva...
python
def intervals(self, reverse, thr=0): """return a list of (0-based half-open) intervals representing the match regions of the cigar for example 4MD4M2DM with reverse=False will produce [(0,4), (5,9), (11,12)] 4MD4M2DM with reverse=True will produce [(0,1), (3,7), (8,12)] (= 12 - previous interva...
[ "def", "intervals", "(", "self", ",", "reverse", ",", "thr", "=", "0", ")", ":", "d", "=", "[", "(", "thr", ",", "thr", ")", "]", "dl", "=", "0", "for", "tup", "in", "self", ".", "cigar_iter", "(", "reverse", ")", ":", "if", "tup", "[", "1", ...
return a list of (0-based half-open) intervals representing the match regions of the cigar for example 4MD4M2DM with reverse=False will produce [(0,4), (5,9), (11,12)] 4MD4M2DM with reverse=True will produce [(0,1), (3,7), (8,12)] (= 12 - previous interval) :param reverse: whether to iterate i...
[ "return", "a", "list", "of", "(", "0", "-", "based", "half", "-", "open", ")", "intervals", "representing", "the", "match", "regions", "of", "the", "cigar" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/epo.py#L249-L278
bxlab/bx-python
scripts/maf_tile_2.py
do_interval
def do_interval( sources, index, out, ref_src, start, end, seq_db, missing_data, strand ): """ Join together alignment blocks to create a semi human projected local alignment (small reference sequence deletions are kept as supported by the local alignment). """ ref_src_size = None # Make s...
python
def do_interval( sources, index, out, ref_src, start, end, seq_db, missing_data, strand ): """ Join together alignment blocks to create a semi human projected local alignment (small reference sequence deletions are kept as supported by the local alignment). """ ref_src_size = None # Make s...
[ "def", "do_interval", "(", "sources", ",", "index", ",", "out", ",", "ref_src", ",", "start", ",", "end", ",", "seq_db", ",", "missing_data", ",", "strand", ")", ":", "ref_src_size", "=", "None", "# Make sure the reference component is also the first in the source l...
Join together alignment blocks to create a semi human projected local alignment (small reference sequence deletions are kept as supported by the local alignment).
[ "Join", "together", "alignment", "blocks", "to", "create", "a", "semi", "human", "projected", "local", "alignment", "(", "small", "reference", "sequence", "deletions", "are", "kept", "as", "supported", "by", "the", "local", "alignment", ")", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/maf_tile_2.py#L139-L272
bxlab/bx-python
lib/bx/bitset_builders.py
binned_bitsets_from_file
def binned_bitsets_from_file( f, chrom_col=0, start_col=1, end_col=2, strand_col=5, upstream_pad=0, downstream_pad=0, lens={} ): """ Read a file into a dictionary of bitsets. The defaults arguments - 'f' should be a file like object (or any iterable containing strings) - 'chrom_col', 'start_col', ...
python
def binned_bitsets_from_file( f, chrom_col=0, start_col=1, end_col=2, strand_col=5, upstream_pad=0, downstream_pad=0, lens={} ): """ Read a file into a dictionary of bitsets. The defaults arguments - 'f' should be a file like object (or any iterable containing strings) - 'chrom_col', 'start_col', ...
[ "def", "binned_bitsets_from_file", "(", "f", ",", "chrom_col", "=", "0", ",", "start_col", "=", "1", ",", "end_col", "=", "2", ",", "strand_col", "=", "5", ",", "upstream_pad", "=", "0", ",", "downstream_pad", "=", "0", ",", "lens", "=", "{", "}", ")...
Read a file into a dictionary of bitsets. The defaults arguments - 'f' should be a file like object (or any iterable containing strings) - 'chrom_col', 'start_col', and 'end_col' must exist in each line. - 'strand_col' is optional, any line without it will be assumed to be '+' - if 'lens' is prov...
[ "Read", "a", "file", "into", "a", "dictionary", "of", "bitsets", ".", "The", "defaults", "arguments", "-", "f", "should", "be", "a", "file", "like", "object", "(", "or", "any", "iterable", "containing", "strings", ")", "-", "chrom_col", "start_col", "and",...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/bitset_builders.py#L12-L47
bxlab/bx-python
lib/bx/bitset_builders.py
binned_bitsets_proximity
def binned_bitsets_proximity( f, chrom_col=0, start_col=1, end_col=2, strand_col=5, upstream=0, downstream=0 ): """Read a file into a dictionary of bitsets""" last_chrom = None last_bitset = None bitsets = dict() for line in f: if line.startswith("#"): continue # print "input=%s" % ( ...
python
def binned_bitsets_proximity( f, chrom_col=0, start_col=1, end_col=2, strand_col=5, upstream=0, downstream=0 ): """Read a file into a dictionary of bitsets""" last_chrom = None last_bitset = None bitsets = dict() for line in f: if line.startswith("#"): continue # print "input=%s" % ( ...
[ "def", "binned_bitsets_proximity", "(", "f", ",", "chrom_col", "=", "0", ",", "start_col", "=", "1", ",", "end_col", "=", "2", ",", "strand_col", "=", "5", ",", "upstream", "=", "0", ",", "downstream", "=", "0", ")", ":", "last_chrom", "=", "None", "...
Read a file into a dictionary of bitsets
[ "Read", "a", "file", "into", "a", "dictionary", "of", "bitsets" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/bitset_builders.py#L100-L128
bxlab/bx-python
lib/bx/bitset_builders.py
binned_bitsets_from_list
def binned_bitsets_from_list( list=[] ): """Read a list into a dictionary of bitsets""" last_chrom = None last_bitset = None bitsets = dict() for l in list: chrom = l[0] if chrom != last_chrom: if chrom not in bitsets: bitsets[chrom] = BinnedBitSet(MAX) ...
python
def binned_bitsets_from_list( list=[] ): """Read a list into a dictionary of bitsets""" last_chrom = None last_bitset = None bitsets = dict() for l in list: chrom = l[0] if chrom != last_chrom: if chrom not in bitsets: bitsets[chrom] = BinnedBitSet(MAX) ...
[ "def", "binned_bitsets_from_list", "(", "list", "=", "[", "]", ")", ":", "last_chrom", "=", "None", "last_bitset", "=", "None", "bitsets", "=", "dict", "(", ")", "for", "l", "in", "list", ":", "chrom", "=", "l", "[", "0", "]", "if", "chrom", "!=", ...
Read a list into a dictionary of bitsets
[ "Read", "a", "list", "into", "a", "dictionary", "of", "bitsets" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/bitset_builders.py#L130-L144
bxlab/bx-python
lib/bx/bitset_builders.py
binned_bitsets_by_chrom
def binned_bitsets_by_chrom( f, chrom, chrom_col=0, start_col=1, end_col=2): """Read a file by chrom name into a bitset""" bitset = BinnedBitSet( MAX ) for line in f: if line.startswith("#"): continue fields = line.split() if fields[chrom_col] == chrom: start, end = int( ...
python
def binned_bitsets_by_chrom( f, chrom, chrom_col=0, start_col=1, end_col=2): """Read a file by chrom name into a bitset""" bitset = BinnedBitSet( MAX ) for line in f: if line.startswith("#"): continue fields = line.split() if fields[chrom_col] == chrom: start, end = int( ...
[ "def", "binned_bitsets_by_chrom", "(", "f", ",", "chrom", ",", "chrom_col", "=", "0", ",", "start_col", "=", "1", ",", "end_col", "=", "2", ")", ":", "bitset", "=", "BinnedBitSet", "(", "MAX", ")", "for", "line", "in", "f", ":", "if", "line", ".", ...
Read a file by chrom name into a bitset
[ "Read", "a", "file", "by", "chrom", "name", "into", "a", "bitset" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/bitset_builders.py#L146-L155
bxlab/bx-python
lib/bx/align/tools/chop.py
chop_list
def chop_list( blocks, src, start, end ): """ For each alignment block in the sequence `blocks`, chop out the portion of the block that overlaps the interval [`start`,`end`) in the component/species named `src`. """ new_blocks = [] for block in blocks: ref = block.get_component_by_s...
python
def chop_list( blocks, src, start, end ): """ For each alignment block in the sequence `blocks`, chop out the portion of the block that overlaps the interval [`start`,`end`) in the component/species named `src`. """ new_blocks = [] for block in blocks: ref = block.get_component_by_s...
[ "def", "chop_list", "(", "blocks", ",", "src", ",", "start", ",", "end", ")", ":", "new_blocks", "=", "[", "]", "for", "block", "in", "blocks", ":", "ref", "=", "block", ".", "get_component_by_src", "(", "src", ")", "# If the reference component is on the '-...
For each alignment block in the sequence `blocks`, chop out the portion of the block that overlaps the interval [`start`,`end`) in the component/species named `src`.
[ "For", "each", "alignment", "block", "in", "the", "sequence", "blocks", "chop", "out", "the", "portion", "of", "the", "block", "that", "overlaps", "the", "interval", "[", "start", "end", ")", "in", "the", "component", "/", "species", "named", "src", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/tools/chop.py#L6-L29
bxlab/bx-python
lib/bx_extras/fpconst.py
_double_as_bytes
def _double_as_bytes(dval): "Use struct.unpack to decode a double precision float into eight bytes" tmp = list(struct.unpack('8B',struct.pack('d', dval))) if not _big_endian: tmp.reverse() return tmp
python
def _double_as_bytes(dval): "Use struct.unpack to decode a double precision float into eight bytes" tmp = list(struct.unpack('8B',struct.pack('d', dval))) if not _big_endian: tmp.reverse() return tmp
[ "def", "_double_as_bytes", "(", "dval", ")", ":", "tmp", "=", "list", "(", "struct", ".", "unpack", "(", "'8B'", ",", "struct", ".", "pack", "(", "'d'", ",", "dval", ")", ")", ")", "if", "not", "_big_endian", ":", "tmp", ".", "reverse", "(", ")", ...
Use struct.unpack to decode a double precision float into eight bytes
[ "Use", "struct", ".", "unpack", "to", "decode", "a", "double", "precision", "float", "into", "eight", "bytes" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/fpconst.py#L45-L50
bxlab/bx-python
lib/bx_extras/fpconst.py
_mantissa
def _mantissa(dval): """Extract the _mantissa bits from a double-precision floating point value.""" bb = _double_as_bytes(dval) mantissa = bb[1] & 0x0f << 48 mantissa += bb[2] << 40 mantissa += bb[3] << 32 mantissa += bb[4] return mantissa
python
def _mantissa(dval): """Extract the _mantissa bits from a double-precision floating point value.""" bb = _double_as_bytes(dval) mantissa = bb[1] & 0x0f << 48 mantissa += bb[2] << 40 mantissa += bb[3] << 32 mantissa += bb[4] return mantissa
[ "def", "_mantissa", "(", "dval", ")", ":", "bb", "=", "_double_as_bytes", "(", "dval", ")", "mantissa", "=", "bb", "[", "1", "]", "&", "0x0f", "<<", "48", "mantissa", "+=", "bb", "[", "2", "]", "<<", "40", "mantissa", "+=", "bb", "[", "3", "]", ...
Extract the _mantissa bits from a double-precision floating point value.
[ "Extract", "the", "_mantissa", "bits", "from", "a", "double", "-", "precision", "floating", "point", "value", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/fpconst.py#L72-L81
bxlab/bx-python
lib/bx_extras/fpconst.py
_zero_mantissa
def _zero_mantissa(dval): """Determine whether the mantissa bits of the given double are all zero.""" bb = _double_as_bytes(dval) return ((bb[1] & 0x0f) | reduce(operator.or_, bb[2:])) == 0
python
def _zero_mantissa(dval): """Determine whether the mantissa bits of the given double are all zero.""" bb = _double_as_bytes(dval) return ((bb[1] & 0x0f) | reduce(operator.or_, bb[2:])) == 0
[ "def", "_zero_mantissa", "(", "dval", ")", ":", "bb", "=", "_double_as_bytes", "(", "dval", ")", "return", "(", "(", "bb", "[", "1", "]", "&", "0x0f", ")", "|", "reduce", "(", "operator", ".", "or_", ",", "bb", "[", "2", ":", "]", ")", ")", "==...
Determine whether the mantissa bits of the given double are all zero.
[ "Determine", "whether", "the", "mantissa", "bits", "of", "the", "given", "double", "are", "all", "zero", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/fpconst.py#L83-L87
bxlab/bx-python
scripts/aggregate_scores_in_intervals.py
load_scores_wiggle
def load_scores_wiggle( fname ): """ Read a wiggle file and return a dict of BinnedArray objects keyed by chromosome. """ scores_by_chrom = dict() for chrom, pos, val in bx.wiggle.Reader( misc.open_compressed( fname ) ): if chrom not in scores_by_chrom: scores_by_chrom[chrom...
python
def load_scores_wiggle( fname ): """ Read a wiggle file and return a dict of BinnedArray objects keyed by chromosome. """ scores_by_chrom = dict() for chrom, pos, val in bx.wiggle.Reader( misc.open_compressed( fname ) ): if chrom not in scores_by_chrom: scores_by_chrom[chrom...
[ "def", "load_scores_wiggle", "(", "fname", ")", ":", "scores_by_chrom", "=", "dict", "(", ")", "for", "chrom", ",", "pos", ",", "val", "in", "bx", ".", "wiggle", ".", "Reader", "(", "misc", ".", "open_compressed", "(", "fname", ")", ")", ":", "if", "...
Read a wiggle file and return a dict of BinnedArray objects keyed by chromosome.
[ "Read", "a", "wiggle", "file", "and", "return", "a", "dict", "of", "BinnedArray", "objects", "keyed", "by", "chromosome", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/aggregate_scores_in_intervals.py#L60-L70
bxlab/bx-python
lib/bx/interval_index_file.py
offsets_for_max_size
def offsets_for_max_size( max_size ): """ Return the subset of offsets needed to contain intervals over (0,max_size) """ for i, max in enumerate( reversed( BIN_OFFSETS_MAX ) ): if max_size < max: break else: raise Exception( "%d is larger than the maximum possible size (%...
python
def offsets_for_max_size( max_size ): """ Return the subset of offsets needed to contain intervals over (0,max_size) """ for i, max in enumerate( reversed( BIN_OFFSETS_MAX ) ): if max_size < max: break else: raise Exception( "%d is larger than the maximum possible size (%...
[ "def", "offsets_for_max_size", "(", "max_size", ")", ":", "for", "i", ",", "max", "in", "enumerate", "(", "reversed", "(", "BIN_OFFSETS_MAX", ")", ")", ":", "if", "max_size", "<", "max", ":", "break", "else", ":", "raise", "Exception", "(", "\"%d is larger...
Return the subset of offsets needed to contain intervals over (0,max_size)
[ "Return", "the", "subset", "of", "offsets", "needed", "to", "contain", "intervals", "over", "(", "0", "max_size", ")" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/interval_index_file.py#L128-L137
bxlab/bx-python
lib/bx/interval_index_file.py
bin_for_range
def bin_for_range( start, end, offsets=None ): """Find the smallest bin that can contain interval (start,end)""" if offsets is None: offsets = BIN_OFFSETS start_bin, end_bin = start, max(start, end - 1) start_bin >>= BIN_FIRST_SHIFT end_bin >>= BIN_FIRST_SHIFT for offset in offsets: ...
python
def bin_for_range( start, end, offsets=None ): """Find the smallest bin that can contain interval (start,end)""" if offsets is None: offsets = BIN_OFFSETS start_bin, end_bin = start, max(start, end - 1) start_bin >>= BIN_FIRST_SHIFT end_bin >>= BIN_FIRST_SHIFT for offset in offsets: ...
[ "def", "bin_for_range", "(", "start", ",", "end", ",", "offsets", "=", "None", ")", ":", "if", "offsets", "is", "None", ":", "offsets", "=", "BIN_OFFSETS", "start_bin", ",", "end_bin", "=", "start", ",", "max", "(", "start", ",", "end", "-", "1", ")"...
Find the smallest bin that can contain interval (start,end)
[ "Find", "the", "smallest", "bin", "that", "can", "contain", "interval", "(", "start", "end", ")" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/interval_index_file.py#L139-L152
bxlab/bx-python
lib/bx/interval_index_file.py
Index.new
def new( self, min, max ): """Create an empty index for intervals in the range min, max""" # Ensure the range will fit given the shifting strategy assert MIN <= min <= max <= MAX self.min = min self.max = max # Determine offsets to use self.offsets = offsets_for_m...
python
def new( self, min, max ): """Create an empty index for intervals in the range min, max""" # Ensure the range will fit given the shifting strategy assert MIN <= min <= max <= MAX self.min = min self.max = max # Determine offsets to use self.offsets = offsets_for_m...
[ "def", "new", "(", "self", ",", "min", ",", "max", ")", ":", "# Ensure the range will fit given the shifting strategy", "assert", "MIN", "<=", "min", "<=", "max", "<=", "MAX", "self", ".", "min", "=", "min", "self", ".", "max", "=", "max", "# Determine offse...
Create an empty index for intervals in the range min, max
[ "Create", "an", "empty", "index", "for", "intervals", "in", "the", "range", "min", "max" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/interval_index_file.py#L357-L368
bxlab/bx-python
lib/bx/interval_index_file.py
Index.add
def add( self, start, end, val ): """Add the interval (start,end) with associated value val to the index""" insort( self.bins[ bin_for_range( start, end, offsets=self.offsets ) ], ( start, end, val ) ) assert val >= 0 self.max_val = max(self.max_val,val)
python
def add( self, start, end, val ): """Add the interval (start,end) with associated value val to the index""" insort( self.bins[ bin_for_range( start, end, offsets=self.offsets ) ], ( start, end, val ) ) assert val >= 0 self.max_val = max(self.max_val,val)
[ "def", "add", "(", "self", ",", "start", ",", "end", ",", "val", ")", ":", "insort", "(", "self", ".", "bins", "[", "bin_for_range", "(", "start", ",", "end", ",", "offsets", "=", "self", ".", "offsets", ")", "]", ",", "(", "start", ",", "end", ...
Add the interval (start,end) with associated value val to the index
[ "Add", "the", "interval", "(", "start", "end", ")", "with", "associated", "value", "val", "to", "the", "index" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/interval_index_file.py#L395-L399
bxlab/bx-python
lib/bx/misc/filecache.py
FileCache.seek
def seek( self, offset, whence=0 ): """ Move the file pointer to a particular offset. """ # Determine absolute target position if whence == 0: target_pos = offset elif whence == 1: target_pos = self.file_pos + offset elif whence == 2: ...
python
def seek( self, offset, whence=0 ): """ Move the file pointer to a particular offset. """ # Determine absolute target position if whence == 0: target_pos = offset elif whence == 1: target_pos = self.file_pos + offset elif whence == 2: ...
[ "def", "seek", "(", "self", ",", "offset", ",", "whence", "=", "0", ")", ":", "# Determine absolute target position", "if", "whence", "==", "0", ":", "target_pos", "=", "offset", "elif", "whence", "==", "1", ":", "target_pos", "=", "self", ".", "file_pos",...
Move the file pointer to a particular offset.
[ "Move", "the", "file", "pointer", "to", "a", "particular", "offset", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/misc/filecache.py#L60-L82
bxlab/bx-python
lib/bx_extras/lrucache.py
LRUCache.mtime
def mtime(self, key): """Return the last modification time for the cache record with key. May be useful for cache instances where the stored values can get 'stale', such as caching file or network resource contents.""" if key not in self.__dict: raise CacheKeyError(key) ...
python
def mtime(self, key): """Return the last modification time for the cache record with key. May be useful for cache instances where the stored values can get 'stale', such as caching file or network resource contents.""" if key not in self.__dict: raise CacheKeyError(key) ...
[ "def", "mtime", "(", "self", ",", "key", ")", ":", "if", "key", "not", "in", "self", ".", "__dict", ":", "raise", "CacheKeyError", "(", "key", ")", "else", ":", "node", "=", "self", ".", "__dict", "[", "key", "]", "return", "node", ".", "mtime" ]
Return the last modification time for the cache record with key. May be useful for cache instances where the stored values can get 'stale', such as caching file or network resource contents.
[ "Return", "the", "last", "modification", "time", "for", "the", "cache", "record", "with", "key", ".", "May", "be", "useful", "for", "cache", "instances", "where", "the", "stored", "values", "can", "get", "stale", "such", "as", "caching", "file", "or", "net...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx_extras/lrucache.py#L203-L211
bxlab/bx-python
lib/bx/cookbook/attribute.py
class_space
def class_space(classlevel=3): "returns the calling class' name and dictionary" frame = sys._getframe(classlevel) classname = frame.f_code.co_name classdict = frame.f_locals return classname, classdict
python
def class_space(classlevel=3): "returns the calling class' name and dictionary" frame = sys._getframe(classlevel) classname = frame.f_code.co_name classdict = frame.f_locals return classname, classdict
[ "def", "class_space", "(", "classlevel", "=", "3", ")", ":", "frame", "=", "sys", ".", "_getframe", "(", "classlevel", ")", "classname", "=", "frame", ".", "f_code", ".", "co_name", "classdict", "=", "frame", ".", "f_locals", "return", "classname", ",", ...
returns the calling class' name and dictionary
[ "returns", "the", "calling", "class", "name", "and", "dictionary" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/cookbook/attribute.py#L67-L72
bxlab/bx-python
lib/bx/cookbook/attribute.py
_attribute
def _attribute(permission='rwd', **kwds): """returns one property for each (key,value) pair in kwds; each property provides the specified level of access(permission): 'r': readable, 'w':writable, 'd':deletable """ classname, classdict = class_space() def _property(attrname, default): ...
python
def _attribute(permission='rwd', **kwds): """returns one property for each (key,value) pair in kwds; each property provides the specified level of access(permission): 'r': readable, 'w':writable, 'd':deletable """ classname, classdict = class_space() def _property(attrname, default): ...
[ "def", "_attribute", "(", "permission", "=", "'rwd'", ",", "*", "*", "kwds", ")", ":", "classname", ",", "classdict", "=", "class_space", "(", ")", "def", "_property", "(", "attrname", ",", "default", ")", ":", "propname", ",", "attrname", "=", "attrname...
returns one property for each (key,value) pair in kwds; each property provides the specified level of access(permission): 'r': readable, 'w':writable, 'd':deletable
[ "returns", "one", "property", "for", "each", "(", "key", "value", ")", "pair", "in", "kwds", ";", "each", "property", "provides", "the", "specified", "level", "of", "access", "(", "permission", ")", ":", "r", ":", "readable", "w", ":", "writable", "d", ...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/cookbook/attribute.py#L93-L120
bxlab/bx-python
lib/bx/align/lav.py
Reader.parse_a_stanza
def parse_a_stanza(self): """returns the pair (score,pieces) where pieces is a list of ungapped segments (start1,start2,length,pctId) with start1,start2 origin-0""" # 's' line -- score, 1 field line = self.fetch_line(report=" in a-stanza") fields = line.split() assert (fields[0] == "s"), "s line exp...
python
def parse_a_stanza(self): """returns the pair (score,pieces) where pieces is a list of ungapped segments (start1,start2,length,pctId) with start1,start2 origin-0""" # 's' line -- score, 1 field line = self.fetch_line(report=" in a-stanza") fields = line.split() assert (fields[0] == "s"), "s line exp...
[ "def", "parse_a_stanza", "(", "self", ")", ":", "# 's' line -- score, 1 field", "line", "=", "self", ".", "fetch_line", "(", "report", "=", "\" in a-stanza\"", ")", "fields", "=", "line", ".", "split", "(", ")", "assert", "(", "fields", "[", "0", "]", "=="...
returns the pair (score,pieces) where pieces is a list of ungapped segments (start1,start2,length,pctId) with start1,start2 origin-0
[ "returns", "the", "pair", "(", "score", "pieces", ")", "where", "pieces", "is", "a", "list", "of", "ungapped", "segments", "(", "start1", "start2", "length", "pctId", ")", "with", "start1", "start2", "origin", "-", "0" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/lav.py#L231-L276
bxlab/bx-python
lib/bx/align/lav.py
Reader.build_alignment
def build_alignment(self,score,pieces): """converts a score and pieces to an alignment""" # build text self.open_seqs() text1 = text2 = "" end1 = end2 = None for (start1,start2,length,pctId) in pieces: if (end1 != None): if (start1 == end1): # insertion in sequence 2 text1 += self.seq1_gap * ...
python
def build_alignment(self,score,pieces): """converts a score and pieces to an alignment""" # build text self.open_seqs() text1 = text2 = "" end1 = end2 = None for (start1,start2,length,pctId) in pieces: if (end1 != None): if (start1 == end1): # insertion in sequence 2 text1 += self.seq1_gap * ...
[ "def", "build_alignment", "(", "self", ",", "score", ",", "pieces", ")", ":", "# build text", "self", ".", "open_seqs", "(", ")", "text1", "=", "text2", "=", "\"\"", "end1", "=", "end2", "=", "None", "for", "(", "start1", ",", "start2", ",", "length", ...
converts a score and pieces to an alignment
[ "converts", "a", "score", "and", "pieces", "to", "an", "alignment" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/align/lav.py#L326-L357
bxlab/bx-python
lib/bx/intervals/operations/__init__.py
bits_clear_in_range
def bits_clear_in_range( bits, range_start, range_end ): """ Yield start,end tuples for each span of clear bits in [range_start,range_end) """ end = range_start while 1: start = bits.next_clear( end ) if start >= range_end: break end = min( bits.next_set( start ), range_end )...
python
def bits_clear_in_range( bits, range_start, range_end ): """ Yield start,end tuples for each span of clear bits in [range_start,range_end) """ end = range_start while 1: start = bits.next_clear( end ) if start >= range_end: break end = min( bits.next_set( start ), range_end )...
[ "def", "bits_clear_in_range", "(", "bits", ",", "range_start", ",", "range_end", ")", ":", "end", "=", "range_start", "while", "1", ":", "start", "=", "bits", ".", "next_clear", "(", "end", ")", "if", "start", ">=", "range_end", ":", "break", "end", "=",...
Yield start,end tuples for each span of clear bits in [range_start,range_end)
[ "Yield", "start", "end", "tuples", "for", "each", "span", "of", "clear", "bits", "in", "[", "range_start", "range_end", ")" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/intervals/operations/__init__.py#L31-L40
bxlab/bx-python
lib/bx/cookbook/progress_bar.py
iterprogress
def iterprogress( sized_iterable ): """ Iterate something printing progress bar to stdout """ pb = ProgressBar( 0, len( sized_iterable ) ) for i, value in enumerate( sized_iterable ): yield value pb.update_and_print( i, sys.stderr )
python
def iterprogress( sized_iterable ): """ Iterate something printing progress bar to stdout """ pb = ProgressBar( 0, len( sized_iterable ) ) for i, value in enumerate( sized_iterable ): yield value pb.update_and_print( i, sys.stderr )
[ "def", "iterprogress", "(", "sized_iterable", ")", ":", "pb", "=", "ProgressBar", "(", "0", ",", "len", "(", "sized_iterable", ")", ")", "for", "i", ",", "value", "in", "enumerate", "(", "sized_iterable", ")", ":", "yield", "value", "pb", ".", "update_an...
Iterate something printing progress bar to stdout
[ "Iterate", "something", "printing", "progress", "bar", "to", "stdout" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/cookbook/progress_bar.py#L61-L68
bxlab/bx-python
lib/bx/misc/cdb.py
FileCDBDict.to_file
def to_file( Class, dict, file, is_little_endian=True ): """ For constructing a CDB structure in a file. Able to calculate size on disk and write to a file """ io = BinaryFileWriter( file, is_little_endian=is_little_endian ) start_offset = io.tell() # Header is of...
python
def to_file( Class, dict, file, is_little_endian=True ): """ For constructing a CDB structure in a file. Able to calculate size on disk and write to a file """ io = BinaryFileWriter( file, is_little_endian=is_little_endian ) start_offset = io.tell() # Header is of...
[ "def", "to_file", "(", "Class", ",", "dict", ",", "file", ",", "is_little_endian", "=", "True", ")", ":", "io", "=", "BinaryFileWriter", "(", "file", ",", "is_little_endian", "=", "is_little_endian", ")", "start_offset", "=", "io", ".", "tell", "(", ")", ...
For constructing a CDB structure in a file. Able to calculate size on disk and write to a file
[ "For", "constructing", "a", "CDB", "structure", "in", "a", "file", ".", "Able", "to", "calculate", "size", "on", "disk", "and", "write", "to", "a", "file" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/misc/cdb.py#L65-L117
bxlab/bx-python
scripts/bed_complement.py
read_len
def read_len( f ): """Read a 'LEN' file and return a mapping from chromosome to length""" mapping = dict() for line in f: fields = line.split() mapping[ fields[0] ] = int( fields[1] ) return mapping
python
def read_len( f ): """Read a 'LEN' file and return a mapping from chromosome to length""" mapping = dict() for line in f: fields = line.split() mapping[ fields[0] ] = int( fields[1] ) return mapping
[ "def", "read_len", "(", "f", ")", ":", "mapping", "=", "dict", "(", ")", "for", "line", "in", "f", ":", "fields", "=", "line", ".", "split", "(", ")", "mapping", "[", "fields", "[", "0", "]", "]", "=", "int", "(", "fields", "[", "1", "]", ")"...
Read a 'LEN' file and return a mapping from chromosome to length
[ "Read", "a", "LEN", "file", "and", "return", "a", "mapping", "from", "chromosome", "to", "length" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/bed_complement.py#L20-L26
bxlab/bx-python
lib/bx/motif/logo/__init__.py
freqs_to_heights
def freqs_to_heights( matrix ): """ Calculate logo height using the method of: Schneider TD, Stephens RM. "Sequence logos: a new way to display consensus sequences." Nucleic Acids Res. 1990 Oct 25;18(20):6097-100. """ # Columns are sequence positions, rows are symbol counts/frequencies ...
python
def freqs_to_heights( matrix ): """ Calculate logo height using the method of: Schneider TD, Stephens RM. "Sequence logos: a new way to display consensus sequences." Nucleic Acids Res. 1990 Oct 25;18(20):6097-100. """ # Columns are sequence positions, rows are symbol counts/frequencies ...
[ "def", "freqs_to_heights", "(", "matrix", ")", ":", "# Columns are sequence positions, rows are symbol counts/frequencies", "f", "=", "matrix", ".", "values", ".", "transpose", "(", ")", "n", ",", "m", "=", "f", ".", "shape", "# Ensure normalized", "f", "=", "f", ...
Calculate logo height using the method of: Schneider TD, Stephens RM. "Sequence logos: a new way to display consensus sequences." Nucleic Acids Res. 1990 Oct 25;18(20):6097-100.
[ "Calculate", "logo", "height", "using", "the", "method", "of", ":", "Schneider", "TD", "Stephens", "RM", ".", "Sequence", "logos", ":", "a", "new", "way", "to", "display", "consensus", "sequences", ".", "Nucleic", "Acids", "Res", ".", "1990", "Oct", "25", ...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/motif/logo/__init__.py#L21-L36
bxlab/bx-python
lib/bx/motif/logo/__init__.py
eps_logo
def eps_logo( matrix, base_width, height, colors=DNA_DEFAULT_COLORS ): """ Return an EPS document containing a sequence logo for matrix where each bases is shown as a column of `base_width` points and the total logo height is `height` points. If `colors` is provided it is a mapping from characters t...
python
def eps_logo( matrix, base_width, height, colors=DNA_DEFAULT_COLORS ): """ Return an EPS document containing a sequence logo for matrix where each bases is shown as a column of `base_width` points and the total logo height is `height` points. If `colors` is provided it is a mapping from characters t...
[ "def", "eps_logo", "(", "matrix", ",", "base_width", ",", "height", ",", "colors", "=", "DNA_DEFAULT_COLORS", ")", ":", "alphabet", "=", "matrix", ".", "sorted_alphabet", "rval", "=", "StringIO", "(", ")", "# Read header ans substitute in width / height", "header", ...
Return an EPS document containing a sequence logo for matrix where each bases is shown as a column of `base_width` points and the total logo height is `height` points. If `colors` is provided it is a mapping from characters to rgb color strings.
[ "Return", "an", "EPS", "document", "containing", "a", "sequence", "logo", "for", "matrix", "where", "each", "bases", "is", "shown", "as", "a", "column", "of", "base_width", "points", "and", "the", "total", "logo", "height", "is", "height", "points", ".", "...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/motif/logo/__init__.py#L38-L72
bxlab/bx-python
scripts/bnMapper.py
transform
def transform(elem, chain_CT_CQ, max_gap): """transform the coordinates of this elem into the other species. elem intersects this chain's ginterval. :return: a list of the type [(to_chr, start, end, elem[id]) ... ]""" (chain, CT, CQ) = chain_CT_CQ start, end = max(elem['start'], chain.tStart) - cha...
python
def transform(elem, chain_CT_CQ, max_gap): """transform the coordinates of this elem into the other species. elem intersects this chain's ginterval. :return: a list of the type [(to_chr, start, end, elem[id]) ... ]""" (chain, CT, CQ) = chain_CT_CQ start, end = max(elem['start'], chain.tStart) - cha...
[ "def", "transform", "(", "elem", ",", "chain_CT_CQ", ",", "max_gap", ")", ":", "(", "chain", ",", "CT", ",", "CQ", ")", "=", "chain_CT_CQ", "start", ",", "end", "=", "max", "(", "elem", "[", "'start'", "]", ",", "chain", ".", "tStart", ")", "-", ...
transform the coordinates of this elem into the other species. elem intersects this chain's ginterval. :return: a list of the type [(to_chr, start, end, elem[id]) ... ]
[ "transform", "the", "coordinates", "of", "this", "elem", "into", "the", "other", "species", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/bnMapper.py#L63-L100
bxlab/bx-python
scripts/bnMapper.py
union_elements
def union_elements(elements): """elements = [(chr, s, e, id), ...], this is to join elements that have a deletion in the 'to' species """ if len(elements) < 2: return elements assert set( [e[3] for e in elements] ) == set( [elements[0][3]] ), "more than one id" el_id = elements[0][3] union...
python
def union_elements(elements): """elements = [(chr, s, e, id), ...], this is to join elements that have a deletion in the 'to' species """ if len(elements) < 2: return elements assert set( [e[3] for e in elements] ) == set( [elements[0][3]] ), "more than one id" el_id = elements[0][3] union...
[ "def", "union_elements", "(", "elements", ")", ":", "if", "len", "(", "elements", ")", "<", "2", ":", "return", "elements", "assert", "set", "(", "[", "e", "[", "3", "]", "for", "e", "in", "elements", "]", ")", "==", "set", "(", "[", "elements", ...
elements = [(chr, s, e, id), ...], this is to join elements that have a deletion in the 'to' species
[ "elements", "=", "[", "(", "chr", "s", "e", "id", ")", "...", "]", "this", "is", "to", "join", "elements", "that", "have", "a", "deletion", "in", "the", "to", "species" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/bnMapper.py#L102-L117
bxlab/bx-python
scripts/bnMapper.py
transform_file
def transform_file(ELEMS, ofname, EPO, TREE, opt): "transform/map the elements of this file and dump the output on 'ofname'" BED4_FRM = "%s\t%d\t%d\t%s\n" log.info("%s (%d) elements ..." % (opt.screen and "screening" or "transforming", ELEMS.shape[0])) with open(ofname, 'w') as out_fd: if opt.s...
python
def transform_file(ELEMS, ofname, EPO, TREE, opt): "transform/map the elements of this file and dump the output on 'ofname'" BED4_FRM = "%s\t%d\t%d\t%s\n" log.info("%s (%d) elements ..." % (opt.screen and "screening" or "transforming", ELEMS.shape[0])) with open(ofname, 'w') as out_fd: if opt.s...
[ "def", "transform_file", "(", "ELEMS", ",", "ofname", ",", "EPO", ",", "TREE", ",", "opt", ")", ":", "BED4_FRM", "=", "\"%s\\t%d\\t%d\\t%s\\n\"", "log", ".", "info", "(", "\"%s (%d) elements ...\"", "%", "(", "opt", ".", "screen", "and", "\"screening\"", "or...
transform/map the elements of this file and dump the output on 'ofname
[ "transform", "/", "map", "the", "elements", "of", "this", "file", "and", "dump", "the", "output", "on", "ofname" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/bnMapper.py#L209-L226
bxlab/bx-python
scripts/bnMapper.py
loadChains
def loadChains(path): "name says it." EPO = epo.Chain._parse_file(path, True) ## convert coordinates w.r.t the forward strand (into slices) ## compute cummulative intervals for i in range( len(EPO) ): ch, S, T, Q = EPO[i] if ch.tStrand == '-': ch = ch._replace(tEnd = ch....
python
def loadChains(path): "name says it." EPO = epo.Chain._parse_file(path, True) ## convert coordinates w.r.t the forward strand (into slices) ## compute cummulative intervals for i in range( len(EPO) ): ch, S, T, Q = EPO[i] if ch.tStrand == '-': ch = ch._replace(tEnd = ch....
[ "def", "loadChains", "(", "path", ")", ":", "EPO", "=", "epo", ".", "Chain", ".", "_parse_file", "(", "path", ",", "True", ")", "## convert coordinates w.r.t the forward strand (into slices)", "## compute cummulative intervals", "for", "i", "in", "range", "(", "len"...
name says it.
[ "name", "says", "it", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/bnMapper.py#L228-L248
bxlab/bx-python
scripts/bnMapper.py
loadFeatures
def loadFeatures(path, opt): """ Load features. For BED, only BED4 columns are loaded. For narrowPeak, all columns are loaded. """ log.info("loading from %s ..." % path) data = [] if opt.in_format == "BED": with open(path) as fd: for line in fd: c...
python
def loadFeatures(path, opt): """ Load features. For BED, only BED4 columns are loaded. For narrowPeak, all columns are loaded. """ log.info("loading from %s ..." % path) data = [] if opt.in_format == "BED": with open(path) as fd: for line in fd: c...
[ "def", "loadFeatures", "(", "path", ",", "opt", ")", ":", "log", ".", "info", "(", "\"loading from %s ...\"", "%", "path", ")", "data", "=", "[", "]", "if", "opt", ".", "in_format", "==", "\"BED\"", ":", "with", "open", "(", "path", ")", "as", "fd", ...
Load features. For BED, only BED4 columns are loaded. For narrowPeak, all columns are loaded.
[ "Load", "features", ".", "For", "BED", "only", "BED4", "columns", "are", "loaded", ".", "For", "narrowPeak", "all", "columns", "are", "loaded", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/bnMapper.py#L250-L272
bxlab/bx-python
scripts/bnMapper.py
GIntervalTree.add
def add(self, chrom, element): """insert an element. use this method as the IntervalTree one. this will simply call the IntervalTree.add method on the right tree :param chrom: chromosome :param element: the argument of IntervalTree.insert_interval :return: None """ ...
python
def add(self, chrom, element): """insert an element. use this method as the IntervalTree one. this will simply call the IntervalTree.add method on the right tree :param chrom: chromosome :param element: the argument of IntervalTree.insert_interval :return: None """ ...
[ "def", "add", "(", "self", ",", "chrom", ",", "element", ")", ":", "self", ".", "_trees", ".", "setdefault", "(", "chrom", ",", "IntervalTree", "(", ")", ")", ".", "insert_interval", "(", "element", ")" ]
insert an element. use this method as the IntervalTree one. this will simply call the IntervalTree.add method on the right tree :param chrom: chromosome :param element: the argument of IntervalTree.insert_interval :return: None
[ "insert", "an", "element", ".", "use", "this", "method", "as", "the", "IntervalTree", "one", ".", "this", "will", "simply", "call", "the", "IntervalTree", ".", "add", "method", "on", "the", "right", "tree" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/bnMapper.py#L38-L47
bxlab/bx-python
scripts/bnMapper.py
GIntervalTree.find
def find(self, chrom, start, end): """find the intersecting elements :param chrom: chromosome :param start: start :param end: end :return: a list of intersecting elements""" tree = self._trees.get( chrom, None ) if tree: return tree.find( start, end ...
python
def find(self, chrom, start, end): """find the intersecting elements :param chrom: chromosome :param start: start :param end: end :return: a list of intersecting elements""" tree = self._trees.get( chrom, None ) if tree: return tree.find( start, end ...
[ "def", "find", "(", "self", ",", "chrom", ",", "start", ",", "end", ")", ":", "tree", "=", "self", ".", "_trees", ".", "get", "(", "chrom", ",", "None", ")", "if", "tree", ":", "return", "tree", ".", "find", "(", "start", ",", "end", ")", "#ret...
find the intersecting elements :param chrom: chromosome :param start: start :param end: end :return: a list of intersecting elements
[ "find", "the", "intersecting", "elements" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/scripts/bnMapper.py#L49-L61
bxlab/bx-python
lib/bx/motif/pwm.py
BaseMatrix.from_rows
def from_rows( Class, alphabet, rows ): """ Create a new matrix for a sequence over alphabet `alphabet` taking values from `rows` which is a list whose length is the width of the matrix, and whose elements are lists of values associated with each character (in the order those ch...
python
def from_rows( Class, alphabet, rows ): """ Create a new matrix for a sequence over alphabet `alphabet` taking values from `rows` which is a list whose length is the width of the matrix, and whose elements are lists of values associated with each character (in the order those ch...
[ "def", "from_rows", "(", "Class", ",", "alphabet", ",", "rows", ")", ":", "# Sorted alphabet", "sorted_alphabet", "=", "sorted", "(", "alphabet", ")", "# Character to index mapping (initialized to -1)", "char_to_index", "=", "zeros", "(", "(", "256", ")", ",", "in...
Create a new matrix for a sequence over alphabet `alphabet` taking values from `rows` which is a list whose length is the width of the matrix, and whose elements are lists of values associated with each character (in the order those characters appear in alphabet).
[ "Create", "a", "new", "matrix", "for", "a", "sequence", "over", "alphabet", "alphabet", "taking", "values", "from", "rows", "which", "is", "a", "list", "whose", "length", "is", "the", "width", "of", "the", "matrix", "and", "whose", "elements", "are", "list...
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/motif/pwm.py#L23-L48
bxlab/bx-python
lib/bx/motif/pwm.py
BaseMatrix.create_from_other
def create_from_other( Class, other, values=None ): """ Create a new Matrix with attributes taken from `other` but with the values taken from `values` if provided """ m = Class() m.alphabet = other.alphabet m.sorted_alphabet = other.sorted_alphabet m.char...
python
def create_from_other( Class, other, values=None ): """ Create a new Matrix with attributes taken from `other` but with the values taken from `values` if provided """ m = Class() m.alphabet = other.alphabet m.sorted_alphabet = other.sorted_alphabet m.char...
[ "def", "create_from_other", "(", "Class", ",", "other", ",", "values", "=", "None", ")", ":", "m", "=", "Class", "(", ")", "m", ".", "alphabet", "=", "other", ".", "alphabet", "m", ".", "sorted_alphabet", "=", "other", ".", "sorted_alphabet", "m", ".",...
Create a new Matrix with attributes taken from `other` but with the values taken from `values` if provided
[ "Create", "a", "new", "Matrix", "with", "attributes", "taken", "from", "other", "but", "with", "the", "values", "taken", "from", "values", "if", "provided" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/motif/pwm.py#L51-L64
bxlab/bx-python
lib/bx/motif/pwm.py
BaseMatrix.reverse_complement
def reverse_complement( self ): """ Create the reverse complement of this matrix. The result probably only makese sense if the alphabet is that of DNA ('A','C','G','T'). """ rval = copy( self ) # Conveniently enough, reversing rows and columns is exactly what we #...
python
def reverse_complement( self ): """ Create the reverse complement of this matrix. The result probably only makese sense if the alphabet is that of DNA ('A','C','G','T'). """ rval = copy( self ) # Conveniently enough, reversing rows and columns is exactly what we #...
[ "def", "reverse_complement", "(", "self", ")", ":", "rval", "=", "copy", "(", "self", ")", "# Conveniently enough, reversing rows and columns is exactly what we", "# want, since this results in A swapping with T and C swapping with G.", "rval", ".", "values", "=", "self", ".", ...
Create the reverse complement of this matrix. The result probably only makese sense if the alphabet is that of DNA ('A','C','G','T').
[ "Create", "the", "reverse", "complement", "of", "this", "matrix", ".", "The", "result", "probably", "only", "makese", "sense", "if", "the", "alphabet", "is", "that", "of", "DNA", "(", "A", "C", "G", "T", ")", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/motif/pwm.py#L73-L82
bxlab/bx-python
lib/bx/motif/pwm.py
FrequencyMatrix.to_logodds_scoring_matrix
def to_logodds_scoring_matrix( self, background=None, correction=DEFAULT_CORRECTION ): """ Create a standard logodds scoring matrix. """ alphabet_size = len( self.alphabet ) if background is None: background = ones( alphabet_size, float32 ) / alphabet_size # R...
python
def to_logodds_scoring_matrix( self, background=None, correction=DEFAULT_CORRECTION ): """ Create a standard logodds scoring matrix. """ alphabet_size = len( self.alphabet ) if background is None: background = ones( alphabet_size, float32 ) / alphabet_size # R...
[ "def", "to_logodds_scoring_matrix", "(", "self", ",", "background", "=", "None", ",", "correction", "=", "DEFAULT_CORRECTION", ")", ":", "alphabet_size", "=", "len", "(", "self", ".", "alphabet", ")", "if", "background", "is", "None", ":", "background", "=", ...
Create a standard logodds scoring matrix.
[ "Create", "a", "standard", "logodds", "scoring", "matrix", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/motif/pwm.py#L95-L107
bxlab/bx-python
lib/bx/motif/pwm.py
FrequencyMatrix.to_stormo_scoring_matrix
def to_stormo_scoring_matrix( self, background=None ): """ Create a scoring matrix from this count matrix using the method from: Hertz, G.Z. and G.D. Stormo (1999). Identifying DNA and protein patterns with statistically significant alignments of multiple sequences. Bioinformatics 15(7...
python
def to_stormo_scoring_matrix( self, background=None ): """ Create a scoring matrix from this count matrix using the method from: Hertz, G.Z. and G.D. Stormo (1999). Identifying DNA and protein patterns with statistically significant alignments of multiple sequences. Bioinformatics 15(7...
[ "def", "to_stormo_scoring_matrix", "(", "self", ",", "background", "=", "None", ")", ":", "alphabet_size", "=", "len", "(", "self", ".", "alphabet", ")", "if", "background", "is", "None", ":", "background", "=", "ones", "(", "alphabet_size", ",", "float32", ...
Create a scoring matrix from this count matrix using the method from: Hertz, G.Z. and G.D. Stormo (1999). Identifying DNA and protein patterns with statistically significant alignments of multiple sequences. Bioinformatics 15(7): 563-577.
[ "Create", "a", "scoring", "matrix", "from", "this", "count", "matrix", "using", "the", "method", "from", ":" ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/motif/pwm.py#L109-L123
bxlab/bx-python
lib/bx/motif/pwm.py
ScoringMatrix.score_string
def score_string( self, string ): """ Score each valid position in `string` using this scoring matrix. Positions which were not scored are set to nan. """ rval = zeros( len( string ), float32 ) rval[:] = nan _pwm.score_string( self.values, self.char_to_index, str...
python
def score_string( self, string ): """ Score each valid position in `string` using this scoring matrix. Positions which were not scored are set to nan. """ rval = zeros( len( string ), float32 ) rval[:] = nan _pwm.score_string( self.values, self.char_to_index, str...
[ "def", "score_string", "(", "self", ",", "string", ")", ":", "rval", "=", "zeros", "(", "len", "(", "string", ")", ",", "float32", ")", "rval", "[", ":", "]", "=", "nan", "_pwm", ".", "score_string", "(", "self", ".", "values", ",", "self", ".", ...
Score each valid position in `string` using this scoring matrix. Positions which were not scored are set to nan.
[ "Score", "each", "valid", "position", "in", "string", "using", "this", "scoring", "matrix", ".", "Positions", "which", "were", "not", "scored", "are", "set", "to", "nan", "." ]
train
https://github.com/bxlab/bx-python/blob/09cb725284803df90a468d910f2274628d8647de/lib/bx/motif/pwm.py#L131-L139
jborean93/ntlm-auth
ntlm_auth/compute_keys.py
_get_exchange_key_ntlm_v1
def _get_exchange_key_ntlm_v1(negotiate_flags, session_base_key, server_challenge, lm_challenge_response, lm_hash): """ [MS-NLMP] v28.0 2016-07-14 3.4.5.1 KXKEY Calculates the Key Exchange Key for NTLMv1 authentication. Used for signing an...
python
def _get_exchange_key_ntlm_v1(negotiate_flags, session_base_key, server_challenge, lm_challenge_response, lm_hash): """ [MS-NLMP] v28.0 2016-07-14 3.4.5.1 KXKEY Calculates the Key Exchange Key for NTLMv1 authentication. Used for signing an...
[ "def", "_get_exchange_key_ntlm_v1", "(", "negotiate_flags", ",", "session_base_key", ",", "server_challenge", ",", "lm_challenge_response", ",", "lm_hash", ")", ":", "if", "negotiate_flags", "&", "NegotiateFlags", ".", "NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY", ":", "key...
[MS-NLMP] v28.0 2016-07-14 3.4.5.1 KXKEY Calculates the Key Exchange Key for NTLMv1 authentication. Used for signing and sealing messages :param negotiate_flags: The negotiated NTLM flags :param session_base_key: A session key calculated from the user password challenge :param server_c...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_keys.py#L11-L52
jborean93/ntlm-auth
ntlm_auth/compute_keys.py
_get_seal_key_ntlm1
def _get_seal_key_ntlm1(negotiate_flags, exported_session_key): """ 3.4.5.3 SEALKEY Calculates the seal_key used to seal (encrypt) messages. This for authentication where NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY has not been negotiated. Will weaken the keys if NTLMSSP_NEGOTIATE_56 is not negot...
python
def _get_seal_key_ntlm1(negotiate_flags, exported_session_key): """ 3.4.5.3 SEALKEY Calculates the seal_key used to seal (encrypt) messages. This for authentication where NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY has not been negotiated. Will weaken the keys if NTLMSSP_NEGOTIATE_56 is not negot...
[ "def", "_get_seal_key_ntlm1", "(", "negotiate_flags", ",", "exported_session_key", ")", ":", "if", "negotiate_flags", "&", "NegotiateFlags", ".", "NTLMSSP_NEGOTIATE_56", ":", "seal_key", "=", "exported_session_key", "[", ":", "7", "]", "+", "b\"\\xa0\"", "else", ":"...
3.4.5.3 SEALKEY Calculates the seal_key used to seal (encrypt) messages. This for authentication where NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY has not been negotiated. Will weaken the keys if NTLMSSP_NEGOTIATE_56 is not negotiated it will default to the 40-bit key :param negotiate_flags: The neg...
[ "3", ".", "4", ".", "5", ".", "3", "SEALKEY", "Calculates", "the", "seal_key", "used", "to", "seal", "(", "encrypt", ")", "messages", ".", "This", "for", "authentication", "where", "NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY", "has", "not", "been", "negotiated",...
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_keys.py#L116-L134
jborean93/ntlm-auth
ntlm_auth/compute_response.py
ComputeResponse.get_nt_challenge_response
def get_nt_challenge_response(self, lm_challenge_response, server_certificate_hash=None, cbt_data=None): """ [MS-NLMP] v28.0 2016-07-14 3.3.1 - NTLM v1 Authentication 3.3.2 - NTLM v2 Authentication This method returns the NtChallengeResponse ke...
python
def get_nt_challenge_response(self, lm_challenge_response, server_certificate_hash=None, cbt_data=None): """ [MS-NLMP] v28.0 2016-07-14 3.3.1 - NTLM v1 Authentication 3.3.2 - NTLM v2 Authentication This method returns the NtChallengeResponse ke...
[ "def", "get_nt_challenge_response", "(", "self", ",", "lm_challenge_response", ",", "server_certificate_hash", "=", "None", ",", "cbt_data", "=", "None", ")", ":", "if", "self", ".", "_negotiate_flags", "&", "NegotiateFlags", ".", "NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECU...
[MS-NLMP] v28.0 2016-07-14 3.3.1 - NTLM v1 Authentication 3.3.2 - NTLM v2 Authentication This method returns the NtChallengeResponse key based on the ntlm_compatibility chosen and the target_info supplied by the CHALLENGE_MESSAGE. It is quite different from what is set in the ...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_response.py#L103-L206
jborean93/ntlm-auth
ntlm_auth/compute_response.py
ComputeResponse._get_LMv2_response
def _get_LMv2_response(user_name, password, domain_name, server_challenge, client_challenge): """ [MS-NLMP] v28.0 2016-07-14 2.2.2.4 LMv2_RESPONSE The LMv2_RESPONSE structure defines the NTLM v2 authentication LmChallengeResponse in the AUTHENTICATE_ME...
python
def _get_LMv2_response(user_name, password, domain_name, server_challenge, client_challenge): """ [MS-NLMP] v28.0 2016-07-14 2.2.2.4 LMv2_RESPONSE The LMv2_RESPONSE structure defines the NTLM v2 authentication LmChallengeResponse in the AUTHENTICATE_ME...
[ "def", "_get_LMv2_response", "(", "user_name", ",", "password", ",", "domain_name", ",", "server_challenge", ",", "client_challenge", ")", ":", "nt_hash", "=", "comphash", ".", "_ntowfv2", "(", "user_name", ",", "password", ",", "domain_name", ")", "challenge", ...
[MS-NLMP] v28.0 2016-07-14 2.2.2.4 LMv2_RESPONSE The LMv2_RESPONSE structure defines the NTLM v2 authentication LmChallengeResponse in the AUTHENTICATE_MESSAGE. This response is used only when NTLM v2 authentication is configured. :param user_name: The user name of the user we ...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_response.py#L250-L277
jborean93/ntlm-auth
ntlm_auth/compute_response.py
ComputeResponse._get_NTLM2_response
def _get_NTLM2_response(password, server_challenge, client_challenge): """ [MS-NLMP] v28.0 2016-07-14 This name is really misleading as it isn't NTLM v2 authentication rather this authentication is only used when the ntlm_compatibility level is set to a value < 3 (No NTLMv2 auth...
python
def _get_NTLM2_response(password, server_challenge, client_challenge): """ [MS-NLMP] v28.0 2016-07-14 This name is really misleading as it isn't NTLM v2 authentication rather this authentication is only used when the ntlm_compatibility level is set to a value < 3 (No NTLMv2 auth...
[ "def", "_get_NTLM2_response", "(", "password", ",", "server_challenge", ",", "client_challenge", ")", ":", "ntlm_hash", "=", "comphash", ".", "_ntowfv1", "(", "password", ")", "challenge", "=", "server_challenge", "+", "client_challenge", "nt_session_hash", "=", "ha...
[MS-NLMP] v28.0 2016-07-14 This name is really misleading as it isn't NTLM v2 authentication rather this authentication is only used when the ntlm_compatibility level is set to a value < 3 (No NTLMv2 auth) but the NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY flag is set in the negotiate ...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_response.py#L305-L333
jborean93/ntlm-auth
ntlm_auth/compute_response.py
ComputeResponse._get_NTLMv2_response
def _get_NTLMv2_response(user_name, password, domain_name, server_challenge, client_challenge, timestamp, target_info): """ [MS-NLMP] v28.0 2016-07-14 2.2.2.8 NTLM V2 Response: NTLMv2_RESPONSE The NTLMv2_RESPONSE strucutre define...
python
def _get_NTLMv2_response(user_name, password, domain_name, server_challenge, client_challenge, timestamp, target_info): """ [MS-NLMP] v28.0 2016-07-14 2.2.2.8 NTLM V2 Response: NTLMv2_RESPONSE The NTLMv2_RESPONSE strucutre define...
[ "def", "_get_NTLMv2_response", "(", "user_name", ",", "password", ",", "domain_name", ",", "server_challenge", ",", "client_challenge", ",", "timestamp", ",", "target_info", ")", ":", "nt_hash", "=", "comphash", ".", "_ntowfv2", "(", "user_name", ",", "password", ...
[MS-NLMP] v28.0 2016-07-14 2.2.2.8 NTLM V2 Response: NTLMv2_RESPONSE The NTLMv2_RESPONSE strucutre defines the NTLMv2 authentication NtChallengeResponse in the AUTHENTICATE_MESSAGE. This response is used only when NTLMv2 authentication is configured. The guide on how this is co...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_response.py#L336-L379
jborean93/ntlm-auth
ntlm_auth/compute_response.py
ComputeResponse._get_NTLMv2_temp
def _get_NTLMv2_temp(timestamp, client_challenge, target_info): """ [MS-NLMP] v28.0 2016-07-14 2.2.2.7 NTLMv2_CLIENT_CHALLENGE - variable length The NTLMv2_CLIENT_CHALLENGE structure defines the client challenge in the AUTHENTICATE_MESSAGE. This structure is used only when NTLM ...
python
def _get_NTLMv2_temp(timestamp, client_challenge, target_info): """ [MS-NLMP] v28.0 2016-07-14 2.2.2.7 NTLMv2_CLIENT_CHALLENGE - variable length The NTLMv2_CLIENT_CHALLENGE structure defines the client challenge in the AUTHENTICATE_MESSAGE. This structure is used only when NTLM ...
[ "def", "_get_NTLMv2_temp", "(", "timestamp", ",", "client_challenge", ",", "target_info", ")", ":", "resp_type", "=", "b'\\x01'", "hi_resp_type", "=", "b'\\x01'", "reserved1", "=", "b'\\x00'", "*", "2", "reserved2", "=", "b'\\x00'", "*", "4", "reserved3", "=", ...
[MS-NLMP] v28.0 2016-07-14 2.2.2.7 NTLMv2_CLIENT_CHALLENGE - variable length The NTLMv2_CLIENT_CHALLENGE structure defines the client challenge in the AUTHENTICATE_MESSAGE. This structure is used only when NTLM v2 authentication is configured and is transported in the NTLMv2_RESPONSE ...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_response.py#L382-L430
jborean93/ntlm-auth
ntlm_auth/compute_response.py
ComputeResponse._calc_resp
def _calc_resp(password_hash, server_challenge): """ Generate the LM response given a 16-byte password hash and the challenge from the CHALLENGE_MESSAGE :param password_hash: A 16-byte password hash :param server_challenge: A random 8-byte response generated by the s...
python
def _calc_resp(password_hash, server_challenge): """ Generate the LM response given a 16-byte password hash and the challenge from the CHALLENGE_MESSAGE :param password_hash: A 16-byte password hash :param server_challenge: A random 8-byte response generated by the s...
[ "def", "_calc_resp", "(", "password_hash", ",", "server_challenge", ")", ":", "# padding with zeros to make the hash 21 bytes long", "password_hash", "+=", "b'\\x00'", "*", "(", "21", "-", "len", "(", "password_hash", ")", ")", "res", "=", "b''", "dobj", "=", "DES...
Generate the LM response given a 16-byte password hash and the challenge from the CHALLENGE_MESSAGE :param password_hash: A 16-byte password hash :param server_challenge: A random 8-byte response generated by the server in the CHALLENGE_MESSAGE :return res: A 24-byte buffer ...
[ "Generate", "the", "LM", "response", "given", "a", "16", "-", "byte", "password", "hash", "and", "the", "challenge", "from", "the", "CHALLENGE_MESSAGE" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_response.py#L433-L455
jborean93/ntlm-auth
ntlm_auth/des.py
DES.encrypt
def encrypt(self, data, pad=True): """ DES encrypts the data based on the key it was initialised with. :param data: The bytes string to encrypt :param pad: Whether to right pad data with \x00 to a multiple of 8 :return: The encrypted bytes string """ encrypted_da...
python
def encrypt(self, data, pad=True): """ DES encrypts the data based on the key it was initialised with. :param data: The bytes string to encrypt :param pad: Whether to right pad data with \x00 to a multiple of 8 :return: The encrypted bytes string """ encrypted_da...
[ "def", "encrypt", "(", "self", ",", "data", ",", "pad", "=", "True", ")", ":", "encrypted_data", "=", "b\"\"", "for", "i", "in", "range", "(", "0", ",", "len", "(", "data", ")", ",", "8", ")", ":", "block", "=", "data", "[", "i", ":", "i", "+...
DES encrypts the data based on the key it was initialised with. :param data: The bytes string to encrypt :param pad: Whether to right pad data with \x00 to a multiple of 8 :return: The encrypted bytes string
[ "DES", "encrypts", "the", "data", "based", "on", "the", "key", "it", "was", "initialised", "with", "." ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/des.py#L150-L169
jborean93/ntlm-auth
ntlm_auth/des.py
DES.decrypt
def decrypt(self, data): """ DES decrypts the data based on the key it was initialised with. :param data: The encrypted bytes string to decrypt :return: The decrypted bytes string """ decrypted_data = b"" for i in range(0, len(data), 8): block = data[...
python
def decrypt(self, data): """ DES decrypts the data based on the key it was initialised with. :param data: The encrypted bytes string to decrypt :return: The decrypted bytes string """ decrypted_data = b"" for i in range(0, len(data), 8): block = data[...
[ "def", "decrypt", "(", "self", ",", "data", ")", ":", "decrypted_data", "=", "b\"\"", "for", "i", "in", "range", "(", "0", ",", "len", "(", "data", ")", ",", "8", ")", ":", "block", "=", "data", "[", "i", ":", "i", "+", "8", "]", "block_length"...
DES decrypts the data based on the key it was initialised with. :param data: The encrypted bytes string to decrypt :return: The decrypted bytes string
[ "DES", "decrypts", "the", "data", "based", "on", "the", "key", "it", "was", "initialised", "with", "." ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/des.py#L171-L188
jborean93/ntlm-auth
ntlm_auth/des.py
DES.key56_to_key64
def key56_to_key64(key): """ This takes in an a bytes string of 7 bytes and converts it to a bytes string of 8 bytes with the odd parity bit being set to every 8 bits, For example b"\x01\x02\x03\x04\x05\x06\x07" 00000001 00000010 00000011 00000100 00000101 00000110 0000...
python
def key56_to_key64(key): """ This takes in an a bytes string of 7 bytes and converts it to a bytes string of 8 bytes with the odd parity bit being set to every 8 bits, For example b"\x01\x02\x03\x04\x05\x06\x07" 00000001 00000010 00000011 00000100 00000101 00000110 0000...
[ "def", "key56_to_key64", "(", "key", ")", ":", "if", "len", "(", "key", ")", "!=", "7", ":", "raise", "ValueError", "(", "\"DES 7-byte key is not 7 bytes in length, \"", "\"actual: %d\"", "%", "len", "(", "key", ")", ")", "new_key", "=", "b\"\"", "for", "i",...
This takes in an a bytes string of 7 bytes and converts it to a bytes string of 8 bytes with the odd parity bit being set to every 8 bits, For example b"\x01\x02\x03\x04\x05\x06\x07" 00000001 00000010 00000011 00000100 00000101 00000110 00000111 is converted to b"\x01...
[ "This", "takes", "in", "an", "a", "bytes", "string", "of", "7", "bytes", "and", "converts", "it", "to", "a", "bytes", "string", "of", "8", "bytes", "with", "the", "odd", "parity", "bit", "being", "set", "to", "every", "8", "bits" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/des.py#L191-L234
jborean93/ntlm-auth
ntlm_auth/compute_hash.py
_lmowfv1
def _lmowfv1(password): """ [MS-NLMP] v28.0 2016-07-14 3.3.1 NTLM v1 Authentication Same function as LMOWFv1 in document to create a one way hash of the password. Only used in NTLMv1 auth without session security :param password: The password or hash of the user we are trying to authen...
python
def _lmowfv1(password): """ [MS-NLMP] v28.0 2016-07-14 3.3.1 NTLM v1 Authentication Same function as LMOWFv1 in document to create a one way hash of the password. Only used in NTLMv1 auth without session security :param password: The password or hash of the user we are trying to authen...
[ "def", "_lmowfv1", "(", "password", ")", ":", "# if the password is a hash, return the LM hash", "if", "re", ".", "match", "(", "r'^[a-fA-F\\d]{32}:[a-fA-F\\d]{32}$'", ",", "password", ")", ":", "lm_hash", "=", "binascii", ".", "unhexlify", "(", "password", ".", "sp...
[MS-NLMP] v28.0 2016-07-14 3.3.1 NTLM v1 Authentication Same function as LMOWFv1 in document to create a one way hash of the password. Only used in NTLMv1 auth without session security :param password: The password or hash of the user we are trying to authenticate with :return res: A Lan M...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_hash.py#L12-L45
jborean93/ntlm-auth
ntlm_auth/compute_hash.py
_ntowfv1
def _ntowfv1(password): """ [MS-NLMP] v28.0 2016-07-14 3.3.1 NTLM v1 Authentication Same function as NTOWFv1 in document to create a one way hash of the password. Only used in NTLMv1 auth without session security :param password: The password or hash of the user we are trying to authen...
python
def _ntowfv1(password): """ [MS-NLMP] v28.0 2016-07-14 3.3.1 NTLM v1 Authentication Same function as NTOWFv1 in document to create a one way hash of the password. Only used in NTLMv1 auth without session security :param password: The password or hash of the user we are trying to authen...
[ "def", "_ntowfv1", "(", "password", ")", ":", "# if the password is a hash, return the NT hash", "if", "re", ".", "match", "(", "r'^[a-fA-F\\d]{32}:[a-fA-F\\d]{32}$'", ",", "password", ")", ":", "nt_hash", "=", "binascii", ".", "unhexlify", "(", "password", ".", "sp...
[MS-NLMP] v28.0 2016-07-14 3.3.1 NTLM v1 Authentication Same function as NTOWFv1 in document to create a one way hash of the password. Only used in NTLMv1 auth without session security :param password: The password or hash of the user we are trying to authenticate with :return digest: An N...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_hash.py#L48-L67
jborean93/ntlm-auth
ntlm_auth/compute_hash.py
_ntowfv2
def _ntowfv2(user_name, password, domain_name): """ [MS-NLMP] v28.0 2016-07-14 3.3.2 NTLM v2 Authentication Same function as NTOWFv2 (and LMOWFv2) in document to create a one way hash of the password. This combines some extra security features over the v1 calculations used in NTLMv2 auth. ...
python
def _ntowfv2(user_name, password, domain_name): """ [MS-NLMP] v28.0 2016-07-14 3.3.2 NTLM v2 Authentication Same function as NTOWFv2 (and LMOWFv2) in document to create a one way hash of the password. This combines some extra security features over the v1 calculations used in NTLMv2 auth. ...
[ "def", "_ntowfv2", "(", "user_name", ",", "password", ",", "domain_name", ")", ":", "digest", "=", "_ntowfv1", "(", "password", ")", "user", "=", "(", "user_name", ".", "upper", "(", ")", "+", "domain_name", ")", ".", "encode", "(", "'utf-16-le'", ")", ...
[MS-NLMP] v28.0 2016-07-14 3.3.2 NTLM v2 Authentication Same function as NTOWFv2 (and LMOWFv2) in document to create a one way hash of the password. This combines some extra security features over the v1 calculations used in NTLMv2 auth. :param user_name: The user name of the user we are trying to...
[ "[", "MS", "-", "NLMP", "]", "v28", ".", "0", "2016", "-", "07", "-", "14" ]
train
https://github.com/jborean93/ntlm-auth/blob/2c7cd81516d9bfd42e8ff473a534d876b21ebb38/ntlm_auth/compute_hash.py#L70-L91
datawire/quark
quarkc/compiler.py
Check.visit_Method
def visit_Method(self, method): """ Ensure method has the same signature matching method on parent interface. :param method: L{quarkc.ast.Method} instance. """ resolved_method = method.resolved.type def get_params(method, extra_bindings): # The Method should...
python
def visit_Method(self, method): """ Ensure method has the same signature matching method on parent interface. :param method: L{quarkc.ast.Method} instance. """ resolved_method = method.resolved.type def get_params(method, extra_bindings): # The Method should...
[ "def", "visit_Method", "(", "self", ",", "method", ")", ":", "resolved_method", "=", "method", ".", "resolved", ".", "type", "def", "get_params", "(", "method", ",", "extra_bindings", ")", ":", "# The Method should already be the resolved version.", "result", "=", ...
Ensure method has the same signature matching method on parent interface. :param method: L{quarkc.ast.Method} instance.
[ "Ensure", "method", "has", "the", "same", "signature", "matching", "method", "on", "parent", "interface", "." ]
train
https://github.com/datawire/quark/blob/df0058a148b077c0aff535eb6ee382605c556273/quarkc/compiler.py#L743-L786
datawire/quark
quarkc/compiler.py
Compiler.urlparse
def urlparse(self, url, top=True, text=None, include=False, recurse=True): """ Parse a quark file and, optionally, its recursive dependencies. A quark file (main.q) is loaded via urlparse() can have two kinds of dependencies, `use a.q` or `include b.q`. For the `use` case each file ...
python
def urlparse(self, url, top=True, text=None, include=False, recurse=True): """ Parse a quark file and, optionally, its recursive dependencies. A quark file (main.q) is loaded via urlparse() can have two kinds of dependencies, `use a.q` or `include b.q`. For the `use` case each file ...
[ "def", "urlparse", "(", "self", ",", "url", ",", "top", "=", "True", ",", "text", "=", "None", ",", "include", "=", "False", ",", "recurse", "=", "True", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "url", ")", ":", "url", "=", "os", ...
Parse a quark file and, optionally, its recursive dependencies. A quark file (main.q) is loaded via urlparse() can have two kinds of dependencies, `use a.q` or `include b.q`. For the `use` case each file is added as a separate top-level root to self.roots. For the `include` case the fil...
[ "Parse", "a", "quark", "file", "and", "optionally", "its", "recursive", "dependencies", "." ]
train
https://github.com/datawire/quark/blob/df0058a148b077c0aff535eb6ee382605c556273/quarkc/compiler.py#L928-L1014
datawire/quark
quarkc/docmaker.py
get_doc
def get_doc(node): """ Return a node's documentation as a string, pulling from annotations or constructing a simple fake as needed. """ res = " ".join(get_doc_annotations(node)) if not res: res = "(%s)" % node.__class__.__name__.lower() return res
python
def get_doc(node): """ Return a node's documentation as a string, pulling from annotations or constructing a simple fake as needed. """ res = " ".join(get_doc_annotations(node)) if not res: res = "(%s)" % node.__class__.__name__.lower() return res
[ "def", "get_doc", "(", "node", ")", ":", "res", "=", "\" \"", ".", "join", "(", "get_doc_annotations", "(", "node", ")", ")", "if", "not", "res", ":", "res", "=", "\"(%s)\"", "%", "node", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", "...
Return a node's documentation as a string, pulling from annotations or constructing a simple fake as needed.
[ "Return", "a", "node", "s", "documentation", "as", "a", "string", "pulling", "from", "annotations", "or", "constructing", "a", "simple", "fake", "as", "needed", "." ]
train
https://github.com/datawire/quark/blob/df0058a148b077c0aff535eb6ee382605c556273/quarkc/docmaker.py#L75-L83
datawire/quark
quarkc/docmaker.py
get_code
def get_code(node, coder=Coder()): """ Return a node's code """ return cgi.escape(str(coder.code(node)), quote=True)
python
def get_code(node, coder=Coder()): """ Return a node's code """ return cgi.escape(str(coder.code(node)), quote=True)
[ "def", "get_code", "(", "node", ",", "coder", "=", "Coder", "(", ")", ")", ":", "return", "cgi", ".", "escape", "(", "str", "(", "coder", ".", "code", "(", "node", ")", ")", ",", "quote", "=", "True", ")" ]
Return a node's code
[ "Return", "a", "node", "s", "code" ]
train
https://github.com/datawire/quark/blob/df0058a148b077c0aff535eb6ee382605c556273/quarkc/docmaker.py#L86-L90
datawire/quark
quarkc/lib/quark_ws4py_fixup.py
WebSocketWSGIHandler.setup_environ
def setup_environ(self): """ Setup the environ dictionary and add the `'ws4py.socket'` key. Its associated value is the real socket underlying socket. """ SimpleHandler.setup_environ(self) self.environ['ws4py.socket'] = get_connection(self.environ['wsgi.input']) ...
python
def setup_environ(self): """ Setup the environ dictionary and add the `'ws4py.socket'` key. Its associated value is the real socket underlying socket. """ SimpleHandler.setup_environ(self) self.environ['ws4py.socket'] = get_connection(self.environ['wsgi.input']) ...
[ "def", "setup_environ", "(", "self", ")", ":", "SimpleHandler", ".", "setup_environ", "(", "self", ")", "self", ".", "environ", "[", "'ws4py.socket'", "]", "=", "get_connection", "(", "self", ".", "environ", "[", "'wsgi.input'", "]", ")", "self", ".", "htt...
Setup the environ dictionary and add the `'ws4py.socket'` key. Its associated value is the real socket underlying socket.
[ "Setup", "the", "environ", "dictionary", "and", "add", "the", "ws4py", ".", "socket", "key", ".", "Its", "associated", "value", "is", "the", "real", "socket", "underlying", "socket", "." ]
train
https://github.com/datawire/quark/blob/df0058a148b077c0aff535eb6ee382605c556273/quarkc/lib/quark_ws4py_fixup.py#L21-L29
datawire/quark
quarkc/lib/quark_ws4py_fixup.py
WebSocketWSGIHandler.finish_response
def finish_response(self): """ Completes the response and performs the following tasks: - Remove the `'ws4py.socket'` and `'ws4py.websocket'` environ keys. - Attach the returned websocket, if any, to the WSGI server using its ``link_websocket_to_server`` method. ...
python
def finish_response(self): """ Completes the response and performs the following tasks: - Remove the `'ws4py.socket'` and `'ws4py.websocket'` environ keys. - Attach the returned websocket, if any, to the WSGI server using its ``link_websocket_to_server`` method. ...
[ "def", "finish_response", "(", "self", ")", ":", "# force execution of the result iterator until first actual content", "rest", "=", "iter", "(", "self", ".", "result", ")", "first", "=", "list", "(", "itertools", ".", "islice", "(", "rest", ",", "1", ")", ")", ...
Completes the response and performs the following tasks: - Remove the `'ws4py.socket'` and `'ws4py.websocket'` environ keys. - Attach the returned websocket, if any, to the WSGI server using its ``link_websocket_to_server`` method.
[ "Completes", "the", "response", "and", "performs", "the", "following", "tasks", ":" ]
train
https://github.com/datawire/quark/blob/df0058a148b077c0aff535eb6ee382605c556273/quarkc/lib/quark_ws4py_fixup.py#L31-L58
datawire/quark
quarkc/lib/quark_ws4py_fixup.py
WebSocketWSGIRequestHandler.handle
def handle(self): """ Unfortunately the base class forces us to override the whole method to actually provide our wsgi handler. """ self.raw_requestline = self.rfile.readline() if not self.parse_request(): # An error code has been sent, just exit return ...
python
def handle(self): """ Unfortunately the base class forces us to override the whole method to actually provide our wsgi handler. """ self.raw_requestline = self.rfile.readline() if not self.parse_request(): # An error code has been sent, just exit return ...
[ "def", "handle", "(", "self", ")", ":", "self", ".", "raw_requestline", "=", "self", ".", "rfile", ".", "readline", "(", ")", "if", "not", "self", ".", "parse_request", "(", ")", ":", "# An error code has been sent, just exit", "return", "# next line is where we...
Unfortunately the base class forces us to override the whole method to actually provide our wsgi handler.
[ "Unfortunately", "the", "base", "class", "forces", "us", "to", "override", "the", "whole", "method", "to", "actually", "provide", "our", "wsgi", "handler", "." ]
train
https://github.com/datawire/quark/blob/df0058a148b077c0aff535eb6ee382605c556273/quarkc/lib/quark_ws4py_fixup.py#L62-L76
datawire/quark
quarkc/parser.py
right_associative_infix_rule
def right_associative_infix_rule(operator, grammar_rule): """Semantic action for rules like 'A = B (C B)*'.""" def semantic_action(self, node, (result, remaining)): while remaining: op, rhs = remaining.pop(0) result = operator(Attr(result, Name(self.aliases[op])), [rhs], op) ...
python
def right_associative_infix_rule(operator, grammar_rule): """Semantic action for rules like 'A = B (C B)*'.""" def semantic_action(self, node, (result, remaining)): while remaining: op, rhs = remaining.pop(0) result = operator(Attr(result, Name(self.aliases[op])), [rhs], op) ...
[ "def", "right_associative_infix_rule", "(", "operator", ",", "grammar_rule", ")", ":", "def", "semantic_action", "(", "self", ",", "node", ",", "(", "result", ",", "remaining", ")", ")", ":", "while", "remaining", ":", "op", ",", "rhs", "=", "remaining", "...
Semantic action for rules like 'A = B (C B)*'.
[ "Semantic", "action", "for", "rules", "like", "A", "=", "B", "(", "C", "B", ")", "*", "." ]
train
https://github.com/datawire/quark/blob/df0058a148b077c0aff535eb6ee382605c556273/quarkc/parser.py#L35-L42
chrisb2/pi_ina219
ina219.py
INA219.configure
def configure(self, voltage_range=RANGE_32V, gain=GAIN_AUTO, bus_adc=ADC_12BIT, shunt_adc=ADC_12BIT): """ Configures and calibrates how the INA219 will take measurements. Arguments: voltage_range -- The full scale voltage range, this is either 16V or 32V represente...
python
def configure(self, voltage_range=RANGE_32V, gain=GAIN_AUTO, bus_adc=ADC_12BIT, shunt_adc=ADC_12BIT): """ Configures and calibrates how the INA219 will take measurements. Arguments: voltage_range -- The full scale voltage range, this is either 16V or 32V represente...
[ "def", "configure", "(", "self", ",", "voltage_range", "=", "RANGE_32V", ",", "gain", "=", "GAIN_AUTO", ",", "bus_adc", "=", "ADC_12BIT", ",", "shunt_adc", "=", "ADC_12BIT", ")", ":", "self", ".", "__validate_voltage_range", "(", "voltage_range", ")", "self", ...
Configures and calibrates how the INA219 will take measurements. Arguments: voltage_range -- The full scale voltage range, this is either 16V or 32V represented by one of the following constants; RANGE_16V, RANGE_32V (default). gain -- The gain which controls the maximum...
[ "Configures", "and", "calibrates", "how", "the", "INA219", "will", "take", "measurements", "." ]
train
https://github.com/chrisb2/pi_ina219/blob/2caeb8a387286ac3504905a0d2d478370a691339/ina219.py#L113-L166
chrisb2/pi_ina219
ina219.py
INA219.wake
def wake(self): """ Wake the INA219 from power down mode """ configuration = self._read_configuration() self._configuration_register(configuration | 0x0007) # 40us delay to recover from powerdown (p14 of spec) time.sleep(0.00004)
python
def wake(self): """ Wake the INA219 from power down mode """ configuration = self._read_configuration() self._configuration_register(configuration | 0x0007) # 40us delay to recover from powerdown (p14 of spec) time.sleep(0.00004)
[ "def", "wake", "(", "self", ")", ":", "configuration", "=", "self", ".", "_read_configuration", "(", ")", "self", ".", "_configuration_register", "(", "configuration", "|", "0x0007", ")", "# 40us delay to recover from powerdown (p14 of spec)", "time", ".", "sleep", ...
Wake the INA219 from power down mode
[ "Wake", "the", "INA219", "from", "power", "down", "mode" ]
train
https://github.com/chrisb2/pi_ina219/blob/2caeb8a387286ac3504905a0d2d478370a691339/ina219.py#L202-L207
blacktop/virustotal-api
virus_total_apis/api.py
_return_response_and_status_code
def _return_response_and_status_code(response, json_results=True): """ Output the requests response content or content as json and status code :rtype : dict :param response: requests response object :param json_results: Should return JSON or raw content :return: dict containing the response content...
python
def _return_response_and_status_code(response, json_results=True): """ Output the requests response content or content as json and status code :rtype : dict :param response: requests response object :param json_results: Should return JSON or raw content :return: dict containing the response content...
[ "def", "_return_response_and_status_code", "(", "response", ",", "json_results", "=", "True", ")", ":", "if", "response", ".", "status_code", "==", "requests", ".", "codes", ".", "ok", ":", "return", "dict", "(", "results", "=", "response", ".", "json", "(",...
Output the requests response content or content as json and status code :rtype : dict :param response: requests response object :param json_results: Should return JSON or raw content :return: dict containing the response content and/or the status code with error string.
[ "Output", "the", "requests", "response", "content", "or", "content", "as", "json", "and", "status", "code" ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L954-L979
blacktop/virustotal-api
virus_total_apis/api.py
PublicApi.rescan_file
def rescan_file(self, this_hash, timeout=None): """ Rescan a previously submitted filed or schedule an scan to be performed in the future. :param this_hash: a md5/sha1/sha256 hash. You can also specify a CSV list made up of a combination of any of the three allowed hashes (up ...
python
def rescan_file(self, this_hash, timeout=None): """ Rescan a previously submitted filed or schedule an scan to be performed in the future. :param this_hash: a md5/sha1/sha256 hash. You can also specify a CSV list made up of a combination of any of the three allowed hashes (up ...
[ "def", "rescan_file", "(", "self", ",", "this_hash", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", ",", "'resource'", ":", "this_hash", "}", "try", ":", "response", "=", "requests", ".", "post", "("...
Rescan a previously submitted filed or schedule an scan to be performed in the future. :param this_hash: a md5/sha1/sha256 hash. You can also specify a CSV list made up of a combination of any of the three allowed hashes (up to 25 items), this allows you to perform a batch request wit...
[ "Rescan", "a", "previously", "submitted", "filed", "or", "schedule", "an", "scan", "to", "be", "performed", "in", "the", "future", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L98-L115
blacktop/virustotal-api
virus_total_apis/api.py
PublicApi.put_comments
def put_comments(self, resource, comment, timeout=None): """ Post a comment on a file or URL. The initial idea of VirusTotal Community was that users should be able to make comments on files and URLs, the comments may be malware analyses, false positive flags, disinfection instructions, etc. ...
python
def put_comments(self, resource, comment, timeout=None): """ Post a comment on a file or URL. The initial idea of VirusTotal Community was that users should be able to make comments on files and URLs, the comments may be malware analyses, false positive flags, disinfection instructions, etc. ...
[ "def", "put_comments", "(", "self", ",", "resource", ",", "comment", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", ",", "'resource'", ":", "resource", ",", "'comment'", ":", "comment", "}", "try", "...
Post a comment on a file or URL. The initial idea of VirusTotal Community was that users should be able to make comments on files and URLs, the comments may be malware analyses, false positive flags, disinfection instructions, etc. Imagine you have some automatic setup that can produce interes...
[ "Post", "a", "comment", "on", "a", "file", "or", "URL", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L188-L213
blacktop/virustotal-api
virus_total_apis/api.py
PublicApi.get_ip_report
def get_ip_report(self, this_ip, timeout=None): """ Get IP address reports. :param this_ip: a valid IPv4 address in dotted quad notation, for the time being only IPv4 addresses are supported. :param timeout: The amount of time in seconds the request should wait before ti...
python
def get_ip_report(self, this_ip, timeout=None): """ Get IP address reports. :param this_ip: a valid IPv4 address in dotted quad notation, for the time being only IPv4 addresses are supported. :param timeout: The amount of time in seconds the request should wait before ti...
[ "def", "get_ip_report", "(", "self", ",", "this_ip", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", ",", "'ip'", ":", "this_ip", "}", "try", ":", "response", "=", "requests", ".", "get", "(", "self...
Get IP address reports. :param this_ip: a valid IPv4 address in dotted quad notation, for the time being only IPv4 addresses are supported. :param timeout: The amount of time in seconds the request should wait before timing out. :return: JSON response
[ "Get", "IP", "address", "reports", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L215-L234
blacktop/virustotal-api
virus_total_apis/api.py
PublicApi.get_domain_report
def get_domain_report(self, this_domain, timeout=None): """ Get information about a given domain. :param this_domain: a domain name. :param timeout: The amount of time in seconds the request should wait before timing out. :return: JSON response """ params = {'apikey': s...
python
def get_domain_report(self, this_domain, timeout=None): """ Get information about a given domain. :param this_domain: a domain name. :param timeout: The amount of time in seconds the request should wait before timing out. :return: JSON response """ params = {'apikey': s...
[ "def", "get_domain_report", "(", "self", ",", "this_domain", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", ",", "'domain'", ":", "this_domain", "}", "try", ":", "response", "=", "requests", ".", "get"...
Get information about a given domain. :param this_domain: a domain name. :param timeout: The amount of time in seconds the request should wait before timing out. :return: JSON response
[ "Get", "information", "about", "a", "given", "domain", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L236-L251
blacktop/virustotal-api
virus_total_apis/api.py
PrivateApi.scan_file
def scan_file(self, this_file, notify_url=None, notify_changes_only=None, from_disk=True, filename=None, timeout=None): """ Submit a file to be scanned by VirusTotal. Allows you to send a file fo...
python
def scan_file(self, this_file, notify_url=None, notify_changes_only=None, from_disk=True, filename=None, timeout=None): """ Submit a file to be scanned by VirusTotal. Allows you to send a file fo...
[ "def", "scan_file", "(", "self", ",", "this_file", ",", "notify_url", "=", "None", ",", "notify_changes_only", "=", "None", ",", "from_disk", "=", "True", ",", "filename", "=", "None", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'"...
Submit a file to be scanned by VirusTotal. Allows you to send a file for scanning with VirusTotal. Before performing your submissions we encourage you to retrieve the latest report on the files, if it is recent enough you might want to save time and bandwidth by making use of it. File size limi...
[ "Submit", "a", "file", "to", "be", "scanned", "by", "VirusTotal", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L256-L298
blacktop/virustotal-api
virus_total_apis/api.py
PrivateApi.get_upload_url
def get_upload_url(self, timeout=None): """ Get a special URL for submitted files bigger than 32MB. In order to submit files bigger than 32MB you need to obtain a special upload URL to which you can POST files up to 200MB in size. This API generates such a URL. :param timeout: The amou...
python
def get_upload_url(self, timeout=None): """ Get a special URL for submitted files bigger than 32MB. In order to submit files bigger than 32MB you need to obtain a special upload URL to which you can POST files up to 200MB in size. This API generates such a URL. :param timeout: The amou...
[ "def", "get_upload_url", "(", "self", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", "}", "try", ":", "response", "=", "requests", ".", "get", "(", "self", ".", "base", "+", "'file/scan/upload_url'", ...
Get a special URL for submitted files bigger than 32MB. In order to submit files bigger than 32MB you need to obtain a special upload URL to which you can POST files up to 200MB in size. This API generates such a URL. :param timeout: The amount of time in seconds the request should wait before...
[ "Get", "a", "special", "URL", "for", "submitted", "files", "bigger", "than", "32MB", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L301-L323
blacktop/virustotal-api
virus_total_apis/api.py
PrivateApi.rescan_file
def rescan_file(self, resource, date='', period='', repeat='', notify_url='', notify_changes_only='', timeout=None): """ Rescan a previously submitted filed or schedule an scan to be performed in the future. This API allows you to rescan files present in VirusTotal's file store without having to ...
python
def rescan_file(self, resource, date='', period='', repeat='', notify_url='', notify_changes_only='', timeout=None): """ Rescan a previously submitted filed or schedule an scan to be performed in the future. This API allows you to rescan files present in VirusTotal's file store without having to ...
[ "def", "rescan_file", "(", "self", ",", "resource", ",", "date", "=", "''", ",", "period", "=", "''", ",", "repeat", "=", "''", ",", "notify_url", "=", "''", ",", "notify_changes_only", "=", "''", ",", "timeout", "=", "None", ")", ":", "params", "=",...
Rescan a previously submitted filed or schedule an scan to be performed in the future. This API allows you to rescan files present in VirusTotal's file store without having to resubmit them, thus saving bandwidth. You only need to know one of the hashes of the file to rescan. :param re...
[ "Rescan", "a", "previously", "submitted", "filed", "or", "schedule", "an", "scan", "to", "be", "performed", "in", "the", "future", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L325-L358
blacktop/virustotal-api
virus_total_apis/api.py
PrivateApi.get_file_report
def get_file_report(self, resource, allinfo=1, timeout=None): """ Get the scan results for a file. Retrieves a concluded file scan report for a given file. Unlike the public API, this call allows you to also access all the information we have on a particular file (VirusTotal metadata, signature...
python
def get_file_report(self, resource, allinfo=1, timeout=None): """ Get the scan results for a file. Retrieves a concluded file scan report for a given file. Unlike the public API, this call allows you to also access all the information we have on a particular file (VirusTotal metadata, signature...
[ "def", "get_file_report", "(", "self", ",", "resource", ",", "allinfo", "=", "1", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", ",", "'resource'", ":", "resource", ",", "'allinfo'", ":", "allinfo", ...
Get the scan results for a file. Retrieves a concluded file scan report for a given file. Unlike the public API, this call allows you to also access all the information we have on a particular file (VirusTotal metadata, signature information, structural information, etc.) by using the allinfo p...
[ "Get", "the", "scan", "results", "for", "a", "file", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L382-L409
blacktop/virustotal-api
virus_total_apis/api.py
PrivateApi.file_search
def file_search(self, query, offset=None, timeout=None): """ Search for samples. In addition to retrieving all information on a particular file, VirusTotal allows you to perform what we call "advanced reverse searches". Reverse searches take you from a file property to a list of files that ...
python
def file_search(self, query, offset=None, timeout=None): """ Search for samples. In addition to retrieving all information on a particular file, VirusTotal allows you to perform what we call "advanced reverse searches". Reverse searches take you from a file property to a list of files that ...
[ "def", "file_search", "(", "self", ",", "query", ",", "offset", "=", "None", ",", "timeout", "=", "None", ")", ":", "params", "=", "dict", "(", "apikey", "=", "self", ".", "api_key", ",", "query", "=", "query", ",", "offset", "=", "offset", ")", "t...
Search for samples. In addition to retrieving all information on a particular file, VirusTotal allows you to perform what we call "advanced reverse searches". Reverse searches take you from a file property to a list of files that match that property. For example, this functionality enables you ...
[ "Search", "for", "samples", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L469-L509
blacktop/virustotal-api
virus_total_apis/api.py
PrivateApi.get_file_clusters
def get_file_clusters(self, this_date, timeout=None): """ File similarity clusters for a given time frame. VirusTotal has built its own in-house file similarity clustering functionality. At present, this clustering works only on PE, PDF, DOC and RTF files and is based on a very simple structura...
python
def get_file_clusters(self, this_date, timeout=None): """ File similarity clusters for a given time frame. VirusTotal has built its own in-house file similarity clustering functionality. At present, this clustering works only on PE, PDF, DOC and RTF files and is based on a very simple structura...
[ "def", "get_file_clusters", "(", "self", ",", "this_date", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", ",", "'date'", ":", "this_date", "}", "try", ":", "response", "=", "requests", ".", "get", "(...
File similarity clusters for a given time frame. VirusTotal has built its own in-house file similarity clustering functionality. At present, this clustering works only on PE, PDF, DOC and RTF files and is based on a very simple structural feature hash. This hash can very often be confused by ce...
[ "File", "similarity", "clusters", "for", "a", "given", "time", "frame", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L511-L550
blacktop/virustotal-api
virus_total_apis/api.py
PrivateApi.get_url_distribution
def get_url_distribution(self, after=None, reports='true', limit=1000, timeout=None): """ Get a live feed with the lastest URLs submitted to VirusTotal. Allows you to retrieve a live feed of URLs submitted to VirusTotal, along with their scan reports. This call enables you to stay synced with V...
python
def get_url_distribution(self, after=None, reports='true', limit=1000, timeout=None): """ Get a live feed with the lastest URLs submitted to VirusTotal. Allows you to retrieve a live feed of URLs submitted to VirusTotal, along with their scan reports. This call enables you to stay synced with V...
[ "def", "get_url_distribution", "(", "self", ",", "after", "=", "None", ",", "reports", "=", "'true'", ",", "limit", "=", "1000", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", ",", "'after'", ":", ...
Get a live feed with the lastest URLs submitted to VirusTotal. Allows you to retrieve a live feed of URLs submitted to VirusTotal, along with their scan reports. This call enables you to stay synced with VirusTotal URL submissions and replicate our dataset. :param after: (optional) Retrieve UR...
[ "Get", "a", "live", "feed", "with", "the", "lastest", "URLs", "submitted", "to", "VirusTotal", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L663-L689
blacktop/virustotal-api
virus_total_apis/api.py
PrivateApi.get_url_feed
def get_url_feed(self, package=None, timeout=None): """ Get a live file feed with the latest files submitted to VirusTotal. Allows you to retrieve a live feed of reports on absolutely all URLs scanned by VirusTotal. This API requires you to stay relatively synced with the live submissions as on...
python
def get_url_feed(self, package=None, timeout=None): """ Get a live file feed with the latest files submitted to VirusTotal. Allows you to retrieve a live feed of reports on absolutely all URLs scanned by VirusTotal. This API requires you to stay relatively synced with the live submissions as on...
[ "def", "get_url_feed", "(", "self", ",", "package", "=", "None", ",", "timeout", "=", "None", ")", ":", "if", "package", "is", "None", ":", "now", "=", "datetime", ".", "utcnow", "(", ")", "five_minutes_ago", "=", "now", "-", "timedelta", "(", "minutes...
Get a live file feed with the latest files submitted to VirusTotal. Allows you to retrieve a live feed of reports on absolutely all URLs scanned by VirusTotal. This API requires you to stay relatively synced with the live submissions as only a backlog of 24 hours is provided at any given point ...
[ "Get", "a", "live", "file", "feed", "with", "the", "latest", "files", "submitted", "to", "VirusTotal", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L691-L724
blacktop/virustotal-api
virus_total_apis/api.py
IntelApi.get_hashes_from_search
def get_hashes_from_search(self, query, page=None, timeout=None): """ Get the scan results for a file. Even if you do not have a Private Mass API key that you can use, you can still automate VirusTotal Intelligence searches pretty much in the same way that the searching for files api call works...
python
def get_hashes_from_search(self, query, page=None, timeout=None): """ Get the scan results for a file. Even if you do not have a Private Mass API key that you can use, you can still automate VirusTotal Intelligence searches pretty much in the same way that the searching for files api call works...
[ "def", "get_hashes_from_search", "(", "self", ",", "query", ",", "page", "=", "None", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'query'", ":", "query", ",", "'apikey'", ":", "self", ".", "api_key", ",", "'page'", ":", "page", "}", "...
Get the scan results for a file. Even if you do not have a Private Mass API key that you can use, you can still automate VirusTotal Intelligence searches pretty much in the same way that the searching for files api call works. :param query: a VirusTotal Intelligence search string in accordance...
[ "Get", "the", "scan", "results", "for", "a", "file", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L806-L831
blacktop/virustotal-api
virus_total_apis/api.py
IntelApi.get_file
def get_file(self, file_hash, save_file_at, timeout=None): """ Get the scan results for a file. Even if you do not have a Private Mass API key that you can use, you can still download files from the VirusTotal storage making use of your VirusTotal Intelligence quota, i.e. programmatic downloads...
python
def get_file(self, file_hash, save_file_at, timeout=None): """ Get the scan results for a file. Even if you do not have a Private Mass API key that you can use, you can still download files from the VirusTotal storage making use of your VirusTotal Intelligence quota, i.e. programmatic downloads...
[ "def", "get_file", "(", "self", ",", "file_hash", ",", "save_file_at", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'hash'", ":", "file_hash", ",", "'apikey'", ":", "self", ".", "api_key", "}", "try", ":", "response", "=", "requests", "....
Get the scan results for a file. Even if you do not have a Private Mass API key that you can use, you can still download files from the VirusTotal storage making use of your VirusTotal Intelligence quota, i.e. programmatic downloads will also deduct quota. :param file_hash: You may use...
[ "Get", "the", "scan", "results", "for", "a", "file", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L833-L859
blacktop/virustotal-api
virus_total_apis/api.py
IntelApi.get_all_file_report_pages
def get_all_file_report_pages(self, query): """ Get File Report (All Pages). :param query: a VirusTotal Intelligence search string in accordance with the file search documentation. :return: All JSON responses appended together. """ responses = [] r = self.get_hashes_from...
python
def get_all_file_report_pages(self, query): """ Get File Report (All Pages). :param query: a VirusTotal Intelligence search string in accordance with the file search documentation. :return: All JSON responses appended together. """ responses = [] r = self.get_hashes_from...
[ "def", "get_all_file_report_pages", "(", "self", ",", "query", ")", ":", "responses", "=", "[", "]", "r", "=", "self", ".", "get_hashes_from_search", "(", "query", ")", "responses", ".", "append", "(", "r", ")", "if", "(", "'results'", "in", "r", ".", ...
Get File Report (All Pages). :param query: a VirusTotal Intelligence search string in accordance with the file search documentation. :return: All JSON responses appended together.
[ "Get", "File", "Report", "(", "All", "Pages", ")", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L861-L885
blacktop/virustotal-api
virus_total_apis/api.py
IntelApi.get_intel_notifications_feed
def get_intel_notifications_feed(self, page=None, timeout=None): """ Get notification feed in JSON for further processing. :param page: the next_page property of the results of a previously issued query to this API. This parameter should not be provided if it is the very first query to the ...
python
def get_intel_notifications_feed(self, page=None, timeout=None): """ Get notification feed in JSON for further processing. :param page: the next_page property of the results of a previously issued query to this API. This parameter should not be provided if it is the very first query to the ...
[ "def", "get_intel_notifications_feed", "(", "self", ",", "page", "=", "None", ",", "timeout", "=", "None", ")", ":", "params", "=", "{", "'apikey'", ":", "self", ".", "api_key", ",", "'next'", ":", "page", "}", "try", ":", "response", "=", "requests", ...
Get notification feed in JSON for further processing. :param page: the next_page property of the results of a previously issued query to this API. This parameter should not be provided if it is the very first query to the API, i.e. if we are retrieving the first page of results. ...
[ "Get", "notification", "feed", "in", "JSON", "for", "further", "processing", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L887-L911
blacktop/virustotal-api
virus_total_apis/api.py
IntelApi.delete_intel_notifications
def delete_intel_notifications(self, ids, timeout=None): """ Programmatically delete notifications via the Intel API. :param ids: A list of IDs to delete from the notification feed. :returns: The post response. """ if not isinstance(ids, list): raise TypeError("ids m...
python
def delete_intel_notifications(self, ids, timeout=None): """ Programmatically delete notifications via the Intel API. :param ids: A list of IDs to delete from the notification feed. :returns: The post response. """ if not isinstance(ids, list): raise TypeError("ids m...
[ "def", "delete_intel_notifications", "(", "self", ",", "ids", ",", "timeout", "=", "None", ")", ":", "if", "not", "isinstance", "(", "ids", ",", "list", ")", ":", "raise", "TypeError", "(", "\"ids must be a list\"", ")", "# VirusTotal needs ids as a stringified ar...
Programmatically delete notifications via the Intel API. :param ids: A list of IDs to delete from the notification feed. :returns: The post response.
[ "Programmatically", "delete", "notifications", "via", "the", "Intel", "API", "." ]
train
https://github.com/blacktop/virustotal-api/blob/4e01e1c6d87255ec8370ac2a4ee16edce00e1e86/virus_total_apis/api.py#L913-L934
localstack/localstack-python-client
localstack_client/session.py
Session.get_credentials
def get_credentials(self): """ Returns botocore.credential.Credential object. """ return Credentials(access_key=self.aws_access_key_id, secret_key=self.aws_secret_access_key, token=self.aws_session_token)
python
def get_credentials(self): """ Returns botocore.credential.Credential object. """ return Credentials(access_key=self.aws_access_key_id, secret_key=self.aws_secret_access_key, token=self.aws_session_token)
[ "def", "get_credentials", "(", "self", ")", ":", "return", "Credentials", "(", "access_key", "=", "self", ".", "aws_access_key_id", ",", "secret_key", "=", "self", ".", "aws_secret_access_key", ",", "token", "=", "self", ".", "aws_session_token", ")" ]
Returns botocore.credential.Credential object.
[ "Returns", "botocore", ".", "credential", ".", "Credential", "object", "." ]
train
https://github.com/localstack/localstack-python-client/blob/62ab3f3d5ce94105f8374963397dfbf05d4f0642/localstack_client/session.py#L25-L31
fabric-bolt/fabric-bolt
fabric_bolt/core/mixins/views.py
MultipleGroupRequiredMixin.check_membership
def check_membership(self, group): """ Check required group(s) """ user_groups = self.request.user.groups.values_list("name", flat=True) if isinstance(group, (list, tuple)): for req_group in group: if req_group in user_groups: return True ...
python
def check_membership(self, group): """ Check required group(s) """ user_groups = self.request.user.groups.values_list("name", flat=True) if isinstance(group, (list, tuple)): for req_group in group: if req_group in user_groups: return True ...
[ "def", "check_membership", "(", "self", ",", "group", ")", ":", "user_groups", "=", "self", ".", "request", ".", "user", ".", "groups", ".", "values_list", "(", "\"name\"", ",", "flat", "=", "True", ")", "if", "isinstance", "(", "group", ",", "(", "lis...
Check required group(s)
[ "Check", "required", "group", "(", "s", ")" ]
train
https://github.com/fabric-bolt/fabric-bolt/blob/0f434783026f1b9ce16a416fa496d76921fe49ca/fabric_bolt/core/mixins/views.py#L9-L21