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_documentation_string stringlengths 1 47.2k | 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... | 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. | 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... | 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 ... | 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... | Method to invoke the Python pdb debugger when this element is
about to be parsed. Set breakFlag to True to enable, False to
disable. | 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... | 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). | 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... | 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... | 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... | 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... | 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.
"""
... | 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. | 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... | 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. | 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])... | factory class method for Chain
:param line: header of a chain (in .chain format) | 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... | 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. ... | 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... | return the slice entry (in a bed6 format), AS IS in the chain header | 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... | return a BED6 entry, thus DOES coordinate conversion for minus strands | 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... | parse a .chain file into a list of the type [(L{Chain}, arr, arr, arr) ...]
:param fname: name of the file | 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],
... | factory method for an EPOitem
:param line: a line of input | 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:
... | Load an entire file in the EPO format into a dictionary of the type {gab_id => [Epoitem, ...]}
:param fname: file name | 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.... | 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) ..] | 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... | 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... | 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... | Join together alignment blocks to create a semi human projected local
alignment (small reference sequence deletions are kept as supported by
the local alignment). | 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', ... | 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... | 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" % ( ... | Read a file into a dictionary of bitsets | 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)
... | Read a list into a dictionary of bitsets | 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( ... | Read a file by chrom name into a bitset | 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... | 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`. | 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 | Use struct.unpack to decode a double precision float into eight bytes | 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 | Extract the _mantissa bits from a double-precision floating
point value. | 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 | Determine whether the mantissa bits of the given double are all
zero. | 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... | Read a wiggle file and return a dict of BinnedArray objects keyed
by chromosome. | 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 (%... | Return the subset of offsets needed to contain intervals over (0,max_size) | 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:
... | Find the smallest bin that can contain interval (start,end) | 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... | Create an empty index for intervals in the range min, max | 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) | Add the interval (start,end) with associated value val to the index | 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:
... | Move the file pointer to a particular offset. | 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)
... | 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. | 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 | returns the calling class' name and dictionary | 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):
... | 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 | 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... | returns the pair (score,pieces)
where pieces is a list of ungapped segments (start1,start2,length,pctId)
with start1,start2 origin-0 | 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 * ... | converts a score and pieces to an alignment | 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 )... | Yield start,end tuples for each span of clear bits in [range_start,range_end) | 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 ) | Iterate something printing progress bar to stdout | 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... | For constructing a CDB structure in a file. Able to calculate size on
disk and write to a file | 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 | Read a 'LEN' file and return a mapping from chromosome to length | 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
... | 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. | 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... | 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. | 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... | 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]) ... ] | 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... | elements = [(chr, s, e, id), ...], this is to join elements that have a
deletion in the 'to' species | 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... | transform/map the elements of this file and dump the output on 'ofname | 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.... | name says it. | 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... | Load features. For BED, only BED4 columns are loaded.
For narrowPeak, all columns are loaded. | 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
"""
... | 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 | 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 ... | find the intersecting elements
:param chrom: chromosome
:param start: start
:param end: end
:return: a list of intersecting elements | 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... | 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). | 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... | Create a new Matrix with attributes taken from `other` but with the
values taken from `values` if provided | 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
#... | Create the reverse complement of this matrix. The result probably
only makese sense if the alphabet is that of DNA ('A','C','G','T'). | 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... | Create a standard logodds scoring matrix. | 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... | 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. | 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... | Score each valid position in `string` using this scoring matrix.
Positions which were not scored are set to nan. | 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... | [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... | 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... | 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... | 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... | [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
... | 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... | [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 ... | 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... | [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
... | 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... | [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... | 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 ... | [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
... | 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... | 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 ... | 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... | 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 | 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[... | 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 | 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... | 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... | 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... | [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... | 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... | [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... | 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.
... | [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... | 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... | Ensure method has the same signature matching method on parent interface.
:param method: L{quarkc.ast.Method} instance. | 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
... | 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... | 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 | Return a node's documentation as a string, pulling from annotations
or constructing a simple fake as needed. | 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) | Return a node's code | 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'])
... | Setup the environ dictionary and add the
`'ws4py.socket'` key. Its associated value
is the real socket underlying socket. | 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.
... | 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. | 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
... | Unfortunately the base class forces us
to override the whole method to actually provide our wsgi handler. | 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)
... | Semantic action for rules like 'A = B (C B)*'. | 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... | 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... | 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) | Wake the INA219 from power down mode | 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... | 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. | 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 ... | 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... | 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.
... | 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... | 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... | 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 | 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... | 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 | 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... | 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... | 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... | 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... | 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
... | 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... | 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... | 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... | 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
... | 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 ... | 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... | 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... | 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... | 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... | 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... | 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 ... | 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... | 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... | 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... | 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... | 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... | 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. | 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 ... | 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.
... | 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... | Programmatically delete notifications via the Intel API.
:param ids: A list of IDs to delete from the notification feed.
:returns: The post response. | 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) | Returns botocore.credential.Credential object. | 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
... | Check required group(s) | https://github.com/fabric-bolt/fabric-bolt/blob/0f434783026f1b9ce16a416fa496d76921fe49ca/fabric_bolt/core/mixins/views.py#L9-L21 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.