sequence stringlengths 546 16.2k | code stringlengths 108 19.3k |
|---|---|
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_sh_ids; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:identity; 6, identifier:backend_name; 7, block; 7, 8; 7, 10; 7, 11; 7, 22; 7, 32; 8, expression_statement; 8, 9; 9, comment; 10, comment; 11, expression_statement; 1... | def get_sh_ids(self, identity, backend_name):
""" Return the Sorting Hat id and uuid for an identity """
# Convert the dict to tuple so it is hashable
identity_tuple = tuple(identity.items())
sh_ids = self.__get_sh_ids_cache(identity_tuple, backend_name)
return sh_ids |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_sh_identity; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:item; 6, default_parameter; 6, 7; 6, 8; 7, identifier:identity_field; 8, None; 9, block; 9, 10; 9, 12; 9, 64; 9, 68; 9, 82; 9, 86; 9, 87; 9, 107; 9, 115; 10, ex... | def get_sh_identity(self, item, identity_field=None):
""" Return a Sorting Hat identity using bugzilla user data """
def fill_list_identity(identity, user_list_data):
""" Fill identity with user data in first item in list """
identity['username'] = user_list_data[0]['__text__']
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:feed; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:from_date; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:from_offset; 10, None; 11, default_para... | def feed(self, from_date=None, from_offset=None, category=None,
latest_items=None, arthur_items=None, filter_classified=None):
""" Feed data in Elastic from Perceval or Arthur """
if self.fetch_archive:
items = self.perceval_backend.fetch_from_archive()
self.feed_it... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_identities; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:item; 6, block; 6, 7; 6, 9; 6, 163; 6, 171; 6, 278; 6, 384; 7, expression_statement; 7, 8; 8, comment; 9, function_definition; 9, 10; 9, 11; 9, 15; 10, function_name:a... | def get_identities(self, item):
""" Return the identities from an item.
If the repo is in GitHub, get the usernames from GitHub. """
def add_sh_github_identity(user, user_field, rol):
""" Add a new github identity to SH if it does not exists """
github_repo = None
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:areas_of_code; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:git_enrich; 5, identifier:in_conn; 6, identifier:out_conn; 7, default_parameter; 7, 8; 7, 9; 8, identifier:block_size; 9, integer:100; 10, block; 10, 11; 10, 13; 10, 31; 10, 3... | def areas_of_code(git_enrich, in_conn, out_conn, block_size=100):
"""Build and index for areas of code from a given Perceval RAW index.
:param block_size: size of items block.
:param git_enrich: GitEnrich object to deal with SortingHat affiliations.
:param in_conn: ESPandasConnector to read from.
:... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 10; 2, function_name:_make_serializer; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:meas; 5, identifier:schema; 6, identifier:rm_none; 7, identifier:extra_tags; 8, identifier:placeholder; 9, comment; 10, block; 10, 11; 10, 13; 10, 19; 10, 23; 1... | def _make_serializer(meas, schema, rm_none, extra_tags, placeholder): # noqa: C901
"""Factory of line protocol parsers"""
_validate_schema(schema, placeholder)
tags = []
fields = []
ts = None
meas = meas
for k, t in schema.items():
if t is MEASUREMENT:
meas = f"{{i.{k}}}... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 1, 23; 2, function_name:iterpoints; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:resp; 6, type; 6, 7; 7, identifier:dict; 8, typed_default_parameter; 8, 9; 8, 10; 8, 16; 9, identifier:parser; 10, type; 10, 11; 11, generic_type; 11, ... | def iterpoints(resp: dict, parser: Optional[Callable] = None) -> Iterator[Any]:
"""Iterates a response JSON yielding data point by point.
Can be used with both regular and chunked responses.
By default, returns just a plain list of values representing each point,
without column names, or other metadata... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 1, 13; 2, function_name:serialize; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:df; 5, identifier:measurement; 6, default_parameter; 6, 7; 6, 8; 7, identifier:tag_columns; 8, None; 9, dictionary_splat_pattern; 9, 10; 10, identifier:extra_tags; 11, type... | def serialize(df, measurement, tag_columns=None, **extra_tags) -> bytes:
"""Converts a Pandas DataFrame into line protocol format"""
# Pre-processing
if measurement is None:
raise ValueError("Missing 'measurement'")
if not isinstance(df.index, pd.DatetimeIndex):
raise ValueError('DataFra... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:get_my_feed; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:limit; 7, integer:150; 8, default_parameter; 8, 9; 8, 10; 9, identifier:offset; 10, integer:20; 11, default_paramet... | def get_my_feed(self, limit=150, offset=20, sort="updated", nid=None):
"""Get my feed
:type limit: int
:param limit: Number of posts from feed to get, starting from ``offset``
:type offset: int
:param offset: Offset starting from bottom of feed
:type sort: str
:p... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:filter_feed; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:updated; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:following; 10, False; 11, default... | def filter_feed(self, updated=False, following=False, folder=False,
filter_folder="", sort="updated", nid=None):
"""Get filtered feed
Only one filter type (updated, following, folder) is possible.
:type nid: str
:param nid: This is the ID of the network to get the ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_dataset; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:dataset; 6, block; 6, 7; 6, 9; 6, 10; 6, 14; 6, 22; 6, 225; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 1... | def get_dataset(self, dataset):
"""
Checks to see if the dataset is present. If not, it downloads and unzips it.
"""
# If the dataset is present, no need to download anything.
success = True
dataset_path = self.base_dataset_path + dataset
if not isdir(dataset_path... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:install; 3, parameters; 3, 4; 3, 7; 3, 27; 3, 30; 4, default_parameter; 4, 5; 4, 6; 5, identifier:verbose; 6, True; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose_destination; 9, conditional_expression:if; 9, 10; 9, 17; 9, 24; 10, cal... | def install(verbose=True,
verbose_destination=sys.__stderr__.fileno() if hasattr(sys.__stderr__, 'fileno') else sys.__stderr__,
strict=True,
**kwargs):
"""
Installs the manhole.
Args:
verbose (bool): Set it to ``False`` to squelch the logging.
verbose_des... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 38; 2, function_name:update; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 4, comment; 5, identifier:self; 6, identifier:alert_condition_nrql_id; 7, identifier:policy_id; 8, default_parameter; 8, 9; 8, ... | def update( # noqa: C901
self, alert_condition_nrql_id, policy_id, name=None, threshold_type=None, query=None,
since_value=None, terms=None, expected_groups=None, value_function=None,
runbook_url=None, ignore_overlap=None, enabled=True):
"""
Updates any of the option... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, identifier:policy_id; 6, identifier:name; 7, identifier:threshold_type; 8, identifier:query; 9, identifier:since_value;... | def create(
self, policy_id, name, threshold_type, query, since_value, terms,
expected_groups=None, value_function=None, runbook_url=None,
ignore_overlap=None, enabled=True):
"""
Creates an alert condition nrql
:type policy_id: int
:param policy_id: A... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 34; 2, function_name:update; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 4, identifier:self; 5, identifier:alert_condition_id; 6, identifier:policy_id; 7, default_parameter; 7, 8; 7, 9; 8, identifier:type; 9, None... | def update(
self, alert_condition_id, policy_id,
type=None,
condition_scope=None,
name=None,
entities=None,
metric=None,
runbook_url=None,
terms=None,
user_defined=None,
enabled=None):
"""
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:operatorPrecedence; 3, parameters; 3, 4; 3, 5; 4, identifier:base; 5, identifier:operators; 6, block; 6, 7; 6, 9; 6, 10; 6, 16; 6, 17; 6, 33; 6, 53; 6, 226; 6, 227; 6, 231; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_s... | def operatorPrecedence(base, operators):
"""
This re-implements pyparsing's operatorPrecedence function.
It gets rid of a few annoying bugs, like always putting operators inside
a Group, and matching the whole grammar with Forward first (there may
actually be a reason for that, but I couldn't find ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:readGraph; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:edgeList; 5, default_parameter; 5, 6; 5, 7; 6, identifier:nodeList; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:directed; 10, False; 11, default_param... | def readGraph(edgeList, nodeList = None, directed = False, idKey = 'ID', eSource = 'From', eDest = 'To'):
"""Reads the files given by _edgeList_ and _nodeList_ and creates a networkx graph for the files.
This is designed only for the files produced by metaknowledge and is meant to be the reverse of [writeGraph... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:writeGraph; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:grph; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:edgeInfo; 8, True; 9, default_parameter; 9, 10; 9, 11; 10, identifier:typing; 11, F... | def writeGraph(grph, name, edgeInfo = True, typing = False, suffix = 'csv', overwrite = True, allSameAttribute = False):
"""Writes both the edge list and the node attribute list of _grph_ to files starting with _name_.
The output files start with _name_, the file type (edgeList, nodeAttributes) then if typing ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:mergeGraphs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:targetGraph; 5, identifier:addedGraph; 6, default_parameter; 6, 7; 6, 8; 7, identifier:incrementedNodeVal; 8, string:'count'; 9, default_parameter; 9, 10; 9, 11; 10, identifier:... | def mergeGraphs(targetGraph, addedGraph, incrementedNodeVal = 'count', incrementedEdgeVal = 'weight'):
"""A quick way of merging graphs, this is meant to be quick and is only intended for graphs generated by metaknowledge. This does not check anything and as such may cause unexpected results if the source and targe... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:writeRecord; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:f; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 13; 9, 29; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifi... | def writeRecord(self, f):
"""This is nearly identical to the original the FAU tag is the only tag not writen in the same place, doing so would require changing the parser and lots of extra logic.
"""
if self.bad:
raise BadPubmedRecord("This record cannot be converted to a file as the... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 32; 2, function_name:graphDensityContourPlot; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 4, identifier:G; 5, default_parameter; 5, 6; 5, 7; 6, identifier:iters; 7, integer:50; 8, default_parameter; 8, 9; 8, 10; 9, identifier:... | def graphDensityContourPlot(G, iters = 50, layout = None, layoutScaleFactor = 1, overlay = False, nodeSize = 10, axisSamples = 100, blurringFactor = .1, contours = 15, graphType = 'coloured'):
"""Creates a 3D plot giving the density of nodes on a 2D plane, as a surface in 3D.
Most of the options are for tweaki... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:makeNodeTuple; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 4, identifier:citation; 5, identifier:idVal; 6, identifier:nodeInfo; 7, identifier:fullInfo; 8, identifier:nodeType; 9, identifier:count; 10, identif... | def makeNodeTuple(citation, idVal, nodeInfo, fullInfo, nodeType, count, coreCitesDict, coreValues, detailedValues, addCR):
"""Makes a tuple of idVal and a dict of the selected attributes"""
d = {}
if nodeInfo:
if nodeType == 'full':
if coreValues:
if citation in coreCites... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:expandRecs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:G; 5, identifier:RecCollect; 6, identifier:nodeType; 7, identifier:weighted; 8, block; 8, 9; 8, 11; 9, expression_statement; 9, 10; 10, comment; 11, for_statement; 11, 12; 11, 13;... | def expandRecs(G, RecCollect, nodeType, weighted):
"""Expand all the citations from _RecCollect_"""
for Rec in RecCollect:
fullCiteList = [makeID(c, nodeType) for c in Rec.createCitation(multiCite = True)]
if len(fullCiteList) > 1:
for i, citeID1 in enumerate(fullCiteList):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:writeBib; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:fname; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:maxStringLength; 10, integer:1000; 11, default... | def writeBib(self, fname = None, maxStringLength = 1000, wosMode = False, reducedOutput = False, niceIDs = True):
"""Writes a bibTex entry to _fname_ for each `Record` in the collection.
If the Record is of a journal article (PT J) the bibtext type is set to `'article'`, otherwise it is set to `'misc'`... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:makeDict; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:onlyTheseTags; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:longNames; 10, False; 11, default_para... | def makeDict(self, onlyTheseTags = None, longNames = False, raw = False, numAuthors = True, genderCounts = True):
"""Returns a dict with each key a tag and the values being lists of the values for each of the Records in the collection, `None` is given when there is no value and they are in the same order across... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 44; 2, function_name:networkCoCitation; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:dropAnon; 7, True; 8, default_parameter; 8, 9;... | def networkCoCitation(self, dropAnon = True, nodeType = "full", nodeInfo = True, fullInfo = False, weighted = True, dropNonJournals = False, count = True, keyWords = None, detailedCore = True, detailedCoreAttributes = False, coreOnly = False, expandedCore = False, addCR = False):
"""Creates a co-citation networ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:networkBibCoupling; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:weighted; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:fullInfo; 10, False; 11, default_parameter; 11,... | def networkBibCoupling(self, weighted = True, fullInfo = False, addCR = False):
"""Creates a bibliographic coupling network based on citations for the RecordCollection.
# Parameters
_weighted_ : `optional bool`
> Default `True`, if `True` the weight of the edges will be added to the n... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:localCiteStats; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pandasFriendly; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:keyType; 10, string:"citation"; 11, block; 11, 12; ... | def localCiteStats(self, pandasFriendly = False, keyType = "citation"):
"""Returns a dict with all the citations in the CR field as keys and the number of times they occur as the values
# Parameters
_pandasFriendly_ : `optional [bool]`
> default `False`, makes the output be a dict wit... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:citeFilter; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:keyString; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:field; 10, string:'all'; 11, default_param... | def citeFilter(self, keyString = '', field = 'all', reverse = False, caseSensitive = False):
"""Filters `Records` by some string, _keyString_, in their citations and returns all `Records` with at least one citation possessing _keyString_ in the field given by _field_.
# Parameters
_keyString_ ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:rankedSeries; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:self; 5, identifier:tag; 6, default_parameter; 6, 7; 6, 8; 7, identifier:outputFile; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:giv... | def rankedSeries(self, tag, outputFile = None, giveCounts = True, giveRanks = False, greatestFirst = True, pandasMode = True, limitTo = None):
"""Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by their number of occurrences. A list can also be returned with the the counts... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:timeSeries; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tag; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:outputFile; 10, None; 11, default_param... | def timeSeries(self, tag = None, outputFile = None, giveYears = True, greatestFirst = True, limitTo = False, pandasMode = True):
"""Creates an pandas dict of the ordered list of all the values of _tag_, with and ranked by the year the occurred in, multiple year occurrences will create multiple entries. A list c... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:cooccurrenceCounts; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:keyTag; 6, list_splat_pattern; 6, 7; 7, identifier:countedTags; 8, block; 8, 9; 8, 11; 8, 29; 8, 42; 8, 64; 8, 68; 8, 85; 8, 106; 8, 269; 9, expression_state... | def cooccurrenceCounts(self, keyTag, *countedTags):
"""Counts the number of times values from any of the _countedTags_ occurs with _keyTag_. The counts are retuned as a dictionary with the values of _keyTag_ mapping to dictionaries with each of the _countedTags_ values mapping to thier counts.
# Parame... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:getCitations; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:field; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:values; 10, None; 11, default_parameter; 11, 12; 11, 13;... | def getCitations(self, field = None, values = None, pandasFriendly = True):
"""Creates a pandas ready dict with each row a different citation and columns containing the original string, year, journal and author's name.
There are also options to filter the output citations with _field_ and _values_
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:proQuestParser; 3, parameters; 3, 4; 4, identifier:proFile; 5, block; 5, 6; 5, 8; 5, 9; 5, 13; 5, 19; 5, 23; 5, 27; 5, 307; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 1... | def proQuestParser(proFile):
"""Parses a ProQuest file, _proFile_, to extract the individual entries.
A ProQuest file has three sections, first a list of the contained entries, second the full metadata and finally a bibtex formatted entry for the record. This parser only uses the first two as the bibtex contai... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:minus; 3, parameters; 3, 4; 3, 5; 4, identifier:repo_list_a; 5, identifier:repo_list_b; 6, block; 6, 7; 6, 9; 6, 17; 6, 29; 6, 35; 6, 62; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12;... | def minus(repo_list_a, repo_list_b):
"""Method to create a list of repositories such that the repository
belongs to repo list a but not repo list b.
In an ideal scenario we should be able to do this by set(a) - set(b)
but as GithubRepositories have shown that set() on them is not reliab... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:__clean_and_tokenize; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:doc_list; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 33; 6, 39; 6, 40; 6, 41; 6, 48; 6, 49; 6, 57; 6, 58; 6, 66; 6, 135; 7, expression_statement; 7, 8; 8, comment; 9... | def __clean_and_tokenize(self, doc_list):
"""Method to clean and tokenize the document list.
:param doc_list: Document list to clean and tokenize.
:return: Cleaned and tokenized document list.
"""
# Some repositories fill entire documentation in description. We ignore
# ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:__get_search_results; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:url; 6, identifier:limit; 7, identifier:order_by; 8, identifier:sort_order; 9, identifier:filter; 10, block; 10, 11; 10, 13; 10, 29; 10,... | def __get_search_results(self, url, limit, order_by, sort_order, filter):
"""
helper function for getting search results up to specified limit on the number of results. The Fred HTTP API
truncates to 1000 results per request, so this may issue multiple HTTP requests to obtain more available data... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:1000; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order_by; 11, None;... | def search(self, text, limit=1000, order_by=None, sort_order=None, filter=None):
"""
Do a fulltext search for series in the Fred dataset. Returns information about matching series in a DataFrame.
Parameters
----------
text : str
text to do fulltext search on, e.g., '... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search_by_release; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:release_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:order... | def search_by_release(self, release_id, limit=0, order_by=None, sort_order=None, filter=None):
"""
Search for series that belongs to a release id. Returns information about matching series in a DataFrame.
Parameters
----------
release_id : int
release id, e.g., 151
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search_by_category; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:category_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:limit; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:ord... | def search_by_category(self, category_id, limit=0, order_by=None, sort_order=None, filter=None):
"""
Search for series that belongs to a category id. Returns information about matching series in a DataFrame.
Parameters
----------
category_id : int
category id, e.g., ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:format_name; 3, parameters; 3, 4; 4, identifier:subject; 5, block; 5, 6; 5, 8; 5, 33; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 16; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_list; 11, 12; 11, 13; ... | def format_name(subject):
"""Convert a subject into the canonical form for distinguished names.
This function does not take care of sorting the subject in any meaningful order.
Examples::
>>> format_name([('CN', 'example.com'), ])
'/CN=example.com'
>>> format_name([('CN', 'example... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_name; 3, parameters; 3, 4; 4, identifier:name; 5, block; 5, 6; 5, 8; 5, 16; 5, 23; 5, 70; 5, 71; 5, 109; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:name; 11, call;... | def parse_name(name):
"""Parses a subject string as used in OpenSSLs command line utilities.
The ``name`` is expected to be close to the subject format commonly used by OpenSSL, for example
``/C=AT/L=Vienna/CN=example.com/emailAddress=user@example.com``. The function does its best to be lenient
on devi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_general_name; 3, parameters; 3, 4; 4, identifier:name; 5, block; 5, 6; 5, 8; 5, 15; 5, 19; 5, 28; 5, 51; 5, 214; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:name; 1... | def parse_general_name(name):
"""Parse a general name from user input.
This function will do its best to detect the intended type of any value passed to it:
>>> parse_general_name('example.com')
<DNSName(value='example.com')>
>>> parse_general_name('*.example.com')
<DNSName(value='*.example.co... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:render; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 12; 9, 13; 9, 14; 9, 24; 9, 39; 9, 63; 9, 79; 9, 80; 9, 8... | def render(self, *args, **kwargs):
"""Renders the element and all his childrens."""
# args kwargs API provided for last minute content injection
# self._reverse_mro_func('pre_render')
pretty = kwargs.pop("pretty", False)
if pretty and self._stable != "pretty":
self._s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:_insert; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:dom_group; 6, default_parameter; 6, 7; 6, 8; 7, identifier:idx; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:prepend; 11, False; 12, defaul... | def _insert(self, dom_group, idx=None, prepend=False, name=None):
"""Inserts a DOMGroup inside this element.
If provided at the given index, if prepend at the start of the childs list, by default at the end.
If the child is a DOMElement, correctly links the child.
If the DOMGroup have a ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:check_label; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:labels; 5, identifier:required; 6, identifier:value_regex; 7, identifier:target_labels; 8, block; 8, 9; 8, 11; 8, 31; 9, expression_statement; 9, 10; 10, comment; 11, expression_... | def check_label(labels, required, value_regex, target_labels):
"""
Check if the label is required and match the regex
:param labels: [str]
:param required: bool (if the presence means pass or not)
:param value_regex: str (using search method)
:param target_labels: [str]
:return: bool (requi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:receive_fmf_metadata; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:name; 5, identifier:path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:object_list; 8, False; 9, block; 9, 10; 9, 12; 9, 16; 9, 23; 9, 32; 9, 33; 9, 62; 9, 67; 9, 124; 10, ... | def receive_fmf_metadata(name, path, object_list=False):
"""
search node identified by name fmfpath
:param path: path to filesystem
:param name: str - name as pattern to search - "/name" (prepended hierarchy item)
:param object_list: bool, if true, return whole list of found items
:return: Tree... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prune_overridden; 3, parameters; 3, 4; 4, identifier:ansi_string; 5, block; 5, 6; 5, 8; 5, 29; 5, 30; 5, 144; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:multi_seqs; 11, ... | def prune_overridden(ansi_string):
"""Remove color codes that are rendered ineffective by subsequent codes in one escape sequence then sort codes.
:param str ansi_string: Incoming ansi_string with ANSI color codes.
:return: Color string with pruned color sequences.
:rtype: str
"""
multi_seqs =... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:parse_input; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:tagged_string; 5, identifier:disable_colors; 6, identifier:keep_tags; 7, block; 7, 8; 7, 10; 7, 17; 7, 26; 7, 27; 7, 70; 7, 71; 7, 81; 7, 88; 7, 89; 7, 112; 7, 113; 7, 120; 7, 121; 7, ... | def parse_input(tagged_string, disable_colors, keep_tags):
"""Perform the actual conversion of tags to ANSI escaped codes.
Provides a version of the input without any colors for len() and other methods.
:param str tagged_string: The input unicode value.
:param bool disable_colors: Strip all colors in ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:memoize; 3, parameters; 3, 4; 4, identifier:method; 5, block; 5, 6; 5, 8; 5, 20; 5, 21; 5, 27; 5, 33; 5, 183; 5, 184; 5, 190; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:... | def memoize(method):
"""
A decorator for functions of sources which memoize the results of the last _CACHE_SIZE calls,
:param method: method to be memoized
:return: the decorated method
"""
cache = method.cache = collections.OrderedDict()
# Put these two methods in the local space (faster... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_set_value; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:new_value; 6, block; 6, 7; 6, 9; 6, 38; 6, 67; 6, 68; 6, 102; 6, 103; 6, 104; 6, 128; 6, 129; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 21; 10,... | def _set_value(self, new_value):
"""Sets the current value of the parameter, ensuring that it is within the allowed range."""
if self.min_value is not None and new_value < self.min_value:
raise SettingOutOfBounds(
"Trying to set parameter {0} = {1}, which is less than the m... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_uninformative_prior; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:prior_class; 6, block; 6, 7; 6, 9; 6, 15; 6, 61; 6, 108; 6, 124; 6, 140; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assign... | def set_uninformative_prior(self, prior_class):
"""
Sets the prior for the parameter to a uniform prior between the current minimum and maximum, or a
log-uniform prior between the current minimum and maximum.
NOTE: if the current minimum and maximum are not defined, the default bounds f... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:find_library; 3, parameters; 3, 4; 3, 5; 4, identifier:library_root; 5, default_parameter; 5, 6; 5, 7; 6, identifier:additional_places; 7, None; 8, block; 8, 9; 8, 11; 8, 12; 8, 13; 8, 24; 9, expression_statement; 9, 10; 10, comment; 11, commen... | def find_library(library_root, additional_places=None):
"""
Returns the name of the library without extension
:param library_root: root of the library to search, for example "cfitsio_" will match libcfitsio_1.2.3.4.so
:return: the name of the library found (NOTE: this is *not* the path), and a director... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:LDA_discriminants; 3, parameters; 3, 4; 3, 5; 4, identifier:x; 5, identifier:labels; 6, block; 6, 7; 6, 9; 6, 10; 6, 28; 6, 29; 6, 39; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, try_statement; 10, 11; 10, 21; 11, block; 11, 12; ... | def LDA_discriminants(x, labels):
"""
Linear Discriminant Analysis helper for determination how many columns of
data should be reduced.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
* `labels` : list of labels (iterable), every item should be label for \
s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:train; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:x; 6, identifier:d; 7, default_parameter; 7, 8; 7, 9; 8, identifier:epochs; 9, integer:10; 10, default_parameter; 10, 11; 10, 12; 11, identifier:shuffle; 12... | def train(self, x, d, epochs=10, shuffle=False):
"""
Function for batch training of MLP.
**Args:**
* `x` : input array (2-dimensional array).
Every row represents one input vector (features).
* `d` : input array (n-dimensional array).
Every row represen... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:PCA_components; 3, parameters; 3, 4; 4, identifier:x; 5, block; 5, 6; 5, 8; 5, 9; 5, 27; 5, 28; 5, 48; 5, 49; 5, 63; 5, 64; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, try_statement; 9, 10; 9, 20; 10, block; 10, 11; 11, expression... | def PCA_components(x):
"""
Principal Component Analysis helper to check out eigenvalues of components.
**Args:**
* `x` : input matrix (2d array), every row represents new sample
**Returns:**
* `components`: sorted array of principal components eigenvalues
"""
# validat... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:add_mpl_colorbar; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:dfr; 5, identifier:fig; 6, identifier:dend; 7, identifier:params; 8, default_parameter; 8, 9; 8, 10; 9, identifier:orientation; 10, string:"row"; 11, block; 11, 12; 1... | def add_mpl_colorbar(dfr, fig, dend, params, orientation="row"):
"""Add class colorbars to Matplotlib heatmap."""
for name in dfr.index[dend["dendrogram"]["leaves"]]:
if name not in params.classes:
params.classes[name] = name
# Assign a numerical value to each class, for mpl
classdi... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:calculate_anim; 3, parameters; 3, 4; 3, 5; 4, identifier:infiles; 5, identifier:org_lengths; 6, block; 6, 7; 6, 9; 6, 16; 6, 23; 6, 39; 6, 47; 6, 48; 6, 229; 6, 230; 6, 237; 6, 250; 6, 322; 6, 341; 6, 342; 7, expression_statement; 7, 8; 8, comm... | def calculate_anim(infiles, org_lengths):
"""Returns ANIm result dataframes for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Finds ANI by the ANIm method, as described in Richter et al (2009)
Proc Natl Acad S... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:unified_anib; 3, parameters; 3, 4; 3, 5; 4, identifier:infiles; 5, identifier:org_lengths; 6, block; 6, 7; 6, 9; 6, 19; 6, 37; 6, 45; 6, 46; 6, 308; 6, 309; 6, 319; 6, 389; 6, 408; 6, 409; 7, expression_statement; 7, 8; 8, comment; 9, expressio... | def unified_anib(infiles, org_lengths):
"""Calculate ANIb for files in input directory.
- infiles - paths to each input file
- org_lengths - dictionary of input sequence lengths, keyed by sequence
Calculates ANI by the ANIb method, as described in Goris et al. (2007)
Int J Syst Evol Micr 57: 81-91... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:process_deltadir; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:delta_dir; 5, identifier:org_lengths; 6, default_parameter; 6, 7; 6, 8; 7, identifier:logger; 8, None; 9, block; 9, 10; 9, 12; 9, 13; 9, 14; 9, 24; 9, 25; 9, 40; 9, 41; 9, 64; 9, ... | def process_deltadir(delta_dir, org_lengths, logger=None):
"""Returns a tuple of ANIm results for .deltas in passed directory.
- delta_dir - path to the directory containing .delta files
- org_lengths - dictionary of total sequence lengths, keyed by sequence
Returns the following pandas dataframes in ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:write_contigs; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:asm_uid; 5, identifier:contig_uids; 6, default_parameter; 6, 7; 6, 8; 7, identifier:batchsize; 8, integer:10000; 9, block; 9, 10; 9, 12; 9, 13; 9, 21; 9, 22; 9, 48; 9, 60; 9, 87; 9, ... | def write_contigs(asm_uid, contig_uids, batchsize=10000):
"""Writes assembly contigs out to a single FASTA file in the script's
designated output directory.
FASTA records are returned, as GenBank and even GenBankWithParts format
records don't reliably give correct sequence in all cases.
The script... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:calculate_tetra_zscore; 3, parameters; 3, 4; 4, identifier:filename; 5, block; 5, 6; 5, 8; 5, 9; 5, 10; 5, 11; 5, 39; 5, 268; 5, 269; 5, 270; 5, 274; 5, 327; 5, 328; 5, 329; 5, 333; 5, 337; 5, 458; 6, expression_statement; 6, 7; 7, comment; 8, ... | def calculate_tetra_zscore(filename):
"""Returns TETRA Z-score for the sequence in the passed file.
- filename - path to sequence file
Calculates mono-, di-, tri- and tetranucleotide frequencies
for each sequence, on each strand, and follows Teeling et al. (2004)
in calculating a corresponding Z-s... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:calculate_correlations; 3, parameters; 3, 4; 4, identifier:tetra_z; 5, block; 5, 6; 5, 8; 5, 19; 5, 41; 5, 255; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:orgs; 11, call... | def calculate_correlations(tetra_z):
"""Returns dataframe of Pearson correlation coefficients.
- tetra_z - dictionary of Z-scores, keyed by sequence ID
Calculates Pearson correlation coefficient from Z scores for each
tetranucleotide. This is done longhand here, which is fast enough,
but for robus... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:process_blast; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:blast_dir; 5, identifier:org_lengths; 6, default_parameter; 6, 7; 6, 8; 7, identifier:fraglengths; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identi... | def process_blast(
blast_dir,
org_lengths,
fraglengths=None,
mode="ANIb",
identity=0.3,
coverage=0.7,
logger=None,
):
"""Returns a tuple of ANIb results for .blast_tab files in the output dir.
- blast_dir - path to the directory containing .blast_tab files
- org_lengths - the ba... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:run_dependency_graph; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:jobgraph; 5, default_parameter; 5, 6; 5, 7; 6, identifier:logger; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:jgprefix; 10, string:"ANIm_SGE_JG"; ... | def run_dependency_graph(jobgraph, logger=None, jgprefix="ANIm_SGE_JG",
sgegroupsize=10000, sgeargs=None):
"""Creates and runs GridEngine scripts for jobs based on the passed
jobgraph.
- jobgraph - list of jobs, which may have dependencies.
- verbose - flag for multiprocessing ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:outputpairedstats; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 3, 16; 3, 17; 3, 18; 3, 19; 3, 20; 4, identifier:fname; 5, identifier:writemode; 6, identifier:name1; 7, identifier:n1; 8, identifi... | def outputpairedstats(fname,writemode,name1,n1,m1,se1,min1,max1,name2,n2,m2,se2,min2,max2,statname,stat,prob):
"""
Prints or write to a file stats for two groups, using the name, n,
mean, sterr, min and max for each group, as well as the statistic name,
its value, and the associated p-value.
Usage: outputpaireds... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:GeneReader; 3, parameters; 3, 4; 3, 5; 4, identifier:fh; 5, default_parameter; 5, 6; 5, 7; 6, identifier:format; 7, string:'gff'; 8, block; 8, 9; 8, 11; 8, 18; 8, 47; 8, 211; 8, 215; 8, 219; 9, expression_statement; 9, 10; 10, comment; 11, expr... | def GeneReader( fh, format='gff' ):
""" yield chrom, strand, gene_exons, name """
known_formats = ( 'gff', 'gtf', 'bed')
if format not in known_formats:
print('%s format not in %s' % (format, ",".join( known_formats )), file=sys.stderr)
raise Exception('?')
if format == 'bed':
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:read_next_maf; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:file; 5, default_parameter; 5, 6; 5, 7; 6, identifier:species_to_lengths; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:parse_e_rows; 10, False; 11, block; 11, 12; 11, 1... | def read_next_maf( file, species_to_lengths=None, parse_e_rows=False ):
"""
Read the next MAF block from `file` and return as an `Alignment`
instance. If `parse_i_rows` is true, empty components will be created
when e rows are encountered.
"""
alignment = Alignment(species_to_lengths=species_t... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse_record; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:lines; 6, block; 6, 7; 6, 9; 6, 10; 6, 14; 6, 55; 6, 59; 6, 60; 6, 66; 6, 70; 6, 449; 6, 450; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_state... | def parse_record( self, lines ):
"""
Parse a TRANSFAC record out of `lines` and return a motif.
"""
# Break lines up
temp_lines = []
for line in lines:
fields = line.rstrip( "\r\n" ).split( None, 1 )
if len( fields ) == 1:
fields.ap... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:tile_interval; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:sources; 5, identifier:index; 6, identifier:ref_src; 7, identifier:start; 8, identifier:end; 9, default_parameter; 9, 10; 9, 11; 10, identifier:seq_db; 11, None; 1... | def tile_interval( sources, index, ref_src, start, end, seq_db=None ):
"""
Tile maf blocks onto an interval. The resulting block will span the interval
exactly and contain the column from the highest scoring alignment at each
position.
`sources`: list of sequence source names to include in final bl... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:binned_bitsets_proximity; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:f; 5, default_parameter; 5, 6; 5, 7; 6, identifier:chrom_col; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start_col; 10, in... | 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" % ( ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:to_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:Class; 5, identifier:dict; 6, identifier:file; 7, default_parameter; 7, 8; 7, 9; 8, identifier:is_little_endian; 9, True; 10, block; 10, 11; 10, 13; 10, 23; 10, 31; 10, 32; 10, 44; ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:transform; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:elem; 5, identifier:chain_CT_CQ; 6, identifier:max_gap; 7, block; 7, 8; 7, 10; 7, 17; 7, 49; 7, 80; 7, 86; 7, 92; 7, 111; 7, 131; 7, 139; 7, 140; 7, 212; 7, 219; 7, 226; 7, 244; 7, 245; ... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:visit_Method; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:method; 6, block; 6, 7; 6, 9; 6, 17; 6, 62; 6, 90; 6, 113; 6, 114; 6, 115; 6, 139; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignm... | 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... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:file_search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:offset; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:timeout; 11, None; 12, block; 12, ... | 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
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_handle_retry; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:resp; 6, block; 6, 7; 6, 9; 6, 20; 6, 30; 6, 50; 6, 69; 6, 119; 6, 154; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 1... | def _handle_retry(self, resp):
"""Handle any exceptions during API request or
parsing its response status code.
Parameters:
resp: requests.Response instance obtained during concerning request
or None, when request failed
Returns: True if should retry our request or ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_event_triggers; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 20; 5, 28; 5, 108; 5, 118; 5, 119; 5, 361; 5, 378; 5, 391; 5, 399; 5, 407; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8... | def get_event_triggers(self):
"""
Returns dict of supported events.
Key = Event Type
List = Channels that have that event activated
"""
events = {}
nvrflag = False
event_xml = []
url = '%s/ISAPI/Event/triggers' % self.root_url
try:
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_device_info; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 20; 5, 24; 5, 207; 5, 227; 5, 248; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:d... | def get_device_info(self):
"""Parse deviceInfo into dictionary."""
device_info = {}
url = '%s/ISAPI/System/deviceInfo' % self.root_url
using_digest = False
try:
response = self.hik_request.get(url, timeout=CONNECT_TIMEOUT)
if response.status_code == reque... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:alert_stream; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:reset_event; 6, identifier:kill_event; 7, block; 7, 8; 7, 10; 7, 23; 7, 27; 7, 31; 7, 35; 7, 43; 7, 44; 8, expression_statement; 8, 9; 9, comment; 10, expression_s... | def alert_stream(self, reset_event, kill_event):
"""Open event stream."""
_LOGGING.debug('Stream Thread Started: %s, %s', self.name, self.cam_id)
start_event = False
parse_string = ""
fail_count = 0
url = '%s/ISAPI/Event/notification/alertStream' % self.root_url
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:construct_request; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:ticker; 5, default_parameter; 5, 6; 5, 7; 6, identifier:fields; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:date; 10, None; 11, default_parame... | def construct_request(ticker, fields=None, date=None,
date_from=None, date_to=None, freq=None):
"""Construct a request string for querying TR DWE.
tickers - ticker or symbol
fields - list of fields.
date - date for a single-date query
da... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:set; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:name; 6, identifier:value; 7, default_parameter; 7, 8; 7, 9; 8, identifier:index; 9, unary_operator:-; 9, 10; 10, integer:1; 11, block; 11, 12; 11, 14; 11, 15; 11, 3... | def set(self, name, value, index=-1):
"""
Assign the ``value`` to the child having the given ``name`` at the ``index`` position
:type name: ``str``
:param name: the child name (e.g. PID)
:type value: an instance of :class:`Element <hl7apy.core.Element>`, a `str` or an instance ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:init_app; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:app; 6, default_parameter; 6, 7; 6, 8; 7, identifier:config_prefix; 8, None; 9, block; 9, 10; 9, 12; 9, 13; 9, 28; 9, 29; 9, 39; 9, 40; 9, 59; 9, 60; 9, 61; 9, 68; 9, ... | def init_app(self, app, config_prefix=None):
"""
Actual method to read redis settings from app configuration, initialize
Redis connection and copy all public connection methods to current
instance.
:param app: :class:`flask.Flask` application instance.
:param config_pref... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 1, 7; 1, 8; 2, function_name:__setup_native_run; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, comment; 7, comment; 8, block; 8, 9; 8, 16; 8, 17; 8, 32; 8, 62; 8, 75; 8, 76; 8, 77; 8, 78; 8, 90; 8, 91; 8, 104; 8, 105; 8, 106; 8, 130; 8, 131; 8, ... | def __setup_native_run(self):
# These options are appended to mounted volume arguments
# NOTE: This tells Docker to re-label the directory for compatibility
# with SELinux. See `man docker-run` for more information.
self.vol_opts = ['z']
# Pass variables to scubainit
se... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 18; 2, function_name:sort; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:records; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Sequence; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:Record; 12, type; 12, 13; 1... | def sort(records: Sequence[Record]) -> List[Record]:
"Sort records into a canonical order, suitable for comparison."
return sorted(records, key=_record_key) |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_issubclass_Mapping_covariant; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:subclass; 5, identifier:superclass; 6, identifier:bound_Generic; 7, identifier:bound_typevars; 8, identifier:bound_typevars_readonly; 9, ide... | def _issubclass_Mapping_covariant(subclass, superclass, bound_Generic, bound_typevars,
bound_typevars_readonly, follow_fwd_refs, _recursion_check):
"""Helper for _issubclass, a.k.a pytypes.issubtype.
This subclass-check treats Mapping-values as covariant.
"""
if is_Generic(subclass):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:_isinstance; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:obj; 5, identifier:cls; 6, default_parameter; 6, 7; 6, 8; 7, identifier:bound_Generic; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:bound_typ... | def _isinstance(obj, cls, bound_Generic=None, bound_typevars=None,
bound_typevars_readonly=False, follow_fwd_refs=True, _recursion_check=None):
"""Access this via ``pytypes.is_of_type``.
Works like ``isinstance``, but supports PEP 484 style types from ``typing`` module.
obj : Any
The object... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:typelogged_module; 3, parameters; 3, 4; 4, identifier:md; 5, block; 5, 6; 5, 8; 5, 16; 5, 70; 5, 76; 5, 105; 5, 111; 5, 134; 5, 135; 5, 136; 5, 137; 5, 138; 5, 148; 5, 203; 5, 228; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, ... | def typelogged_module(md):
"""Works like typelogged, but is only applicable to modules by explicit call).
md must be a module or a module name contained in sys.modules.
"""
if not pytypes.typelogging_enabled:
return md
if isinstance(md, str):
if md in sys.modules:
md = sy... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:import_process_elements; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:document; 5, identifier:diagram_graph; 6, identifier:sequence_flows; 7, identifier:process_elements_dict; 8, identifier:plane_element; 9, block; 9, 10; 9, 12; 1... | def import_process_elements(document, diagram_graph, sequence_flows, process_elements_dict, plane_element):
"""
Method for importing all 'process' elements in diagram.
:param document: XML document,
:param diagram_graph: NetworkX graph representing a BPMN process diagram,
:param... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:generate_nodes_clasification; 3, parameters; 3, 4; 4, identifier:bpmn_diagram; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 20; 5, 24; 5, 37; 5, 55; 5, 68; 5, 86; 5, 99; 5, 117; 5, 130; 5, 148; 5, 161; 5, 179; 5, 192; 5, 210; 5, 223; 5, 241; 5, 254; ... | def generate_nodes_clasification(bpmn_diagram):
"""
Diagram elements classification. Implementation based on article "A Simple Algorithm for Automatic Layout of
BPMN Processes".
Assigns a classification to the diagram element according to specific element parameters.
- Element - ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:hclust_linearize; 3, parameters; 3, 4; 4, identifier:U; 5, block; 5, 6; 5, 8; 5, 14; 5, 23; 6, expression_statement; 6, 7; 7, comment; 8, import_from_statement; 8, 9; 8, 12; 9, dotted_name; 9, 10; 9, 11; 10, identifier:scipy; 11, identifier:clu... | def hclust_linearize(U):
"""Sorts the rows of a matrix by hierarchical clustering.
Parameters:
U (ndarray) : matrix of data
Returns:
prm (ndarray) : permutation of the rows
"""
from scipy.cluster import hierarchy
Z = hierarchy.ward(U)
return hierarchy.leaves_list(hierarchy... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:kruskal_align; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:U; 5, identifier:V; 6, default_parameter; 6, 7; 6, 8; 7, identifier:permute_U; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:permute_V; 11, False; 12, block; 12... | def kruskal_align(U, V, permute_U=False, permute_V=False):
"""Aligns two KTensors and returns a similarity score.
Parameters
----------
U : KTensor
First kruskal tensor to align.
V : KTensor
Second kruskal tensor to align.
permute_U : bool
If True, modifies 'U' to align ... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:randn_ktensor; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:shape; 5, identifier:rank; 6, default_parameter; 6, 7; 6, 8; 7, identifier:norm; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:random_state; 11, None; 12, block;... | def randn_ktensor(shape, rank, norm=None, random_state=None):
"""
Generates a random N-way tensor with rank R, where the entries are
drawn from the standard normal distribution.
Parameters
----------
shape : tuple
shape of the tensor
rank : integer
rank of the tensor
n... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:fit; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:X; 6, identifier:ranks; 7, default_parameter; 7, 8; 7, 9; 8, identifier:replicates; 9, integer:1; 10, default_parameter; 10, 11; 10, 12; 11, identifier:verbos... | def fit(self, X, ranks, replicates=1, verbose=True):
"""
Fits CP tensor decompositions for different choices of rank.
Parameters
----------
X : array_like
Real tensor
ranks : int, or iterable
iterable specifying number of components in each model
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_create_model_class; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:model; 6, block; 6, 7; 6, 9; 6, 19; 6, 20; 6, 45; 6, 46; 6, 64; 6, 76; 6, 115; 6, 116; 6, 117; 6, 161; 7, expression_statement; 7, 8; 8, comment; 9, expression_st... | def _create_model_class(self, model):
"""Generate the model proxy class.
:return: a :class:`odoorpc.models.Model` class
"""
cls_name = model.replace('.', '_')
# Hack for Python 2 (no need to do this for Python 3)
if sys.version_info[0] < 3:
if isinstance(cls_... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_init_values; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:context; 7, None; 8, block; 8, 9; 8, 11; 8, 24; 8, 25; 8, 29; 8, 59; 8, 60; 9, expression_statement; 9, 10; 10, comment; 11, if_stateme... | def _init_values(self, context=None):
"""Retrieve field values from the server.
May be used to restore the original values in the purpose to cancel
all changes made.
"""
if context is None:
context = self.env.context
# Get basic fields (no relational ones)
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_resource_id; 3, parameters; 3, 4; 4, identifier:rid; 5, block; 5, 6; 5, 8; 5, 14; 5, 23; 5, 123; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 11; 9, not_operator; 9, 10; 10, identifier:rid; 11, block; 11, 12; 12, r... | def parse_resource_id(rid):
"""Parses a resource_id into its various parts.
Returns a dictionary with a single key-value pair, 'name': rid, if invalid resource id.
:param rid: The resource id being parsed
:type rid: str
:returns: A dictionary with with following key/value pairs (if found):
... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:lookup_instance; 3, parameters; 3, 4; 3, 8; 3, 13; 3, 18; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:name; 6, type; 6, 7; 7, identifier:str; 8, typed_default_parameter; 8, 9; 8, 10; 8, 12; 9, identifier:instance_type; 10, type; 10, 11; 11, ... | def lookup_instance(name: str, instance_type: str = '', image_name: str = '',
states: tuple = ('running', 'stopped', 'initializing')):
"""Looks up AWS instance for given instance name, like
simple.worker. If no instance found in current AWS environment, returns None. """
ec2 = get_ec2_resour... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:extract_attr_for_match; 3, parameters; 3, 4; 3, 5; 4, identifier:items; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 11; 7, 15; 7, 40; 7, 44; 7, 55; 7, 129; 7, 144; 7, 151; 8, expression_statement; 8, 9; 9,... | def extract_attr_for_match(items, **kwargs):
"""Helper method to get attribute value for an item matching some criterion.
Specify target criteria value as dict, with target attribute having value -1
Example:
to extract state of vpc matching given vpc id
response = [{'State': 'available', 'VpcId': 'vpc-2bb... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_maybe_create_resources; 3, parameters; 3, 4; 4, typed_default_parameter; 4, 5; 4, 6; 4, 8; 5, identifier:logging_task; 6, type; 6, 7; 7, identifier:Task; 8, None; 9, block; 9, 10; 9, 12; 9, 39; 9, 122; 10, expression_statement; 10, 11; 11, com... | def _maybe_create_resources(logging_task: Task = None):
"""Use heuristics to decide to possibly create resources"""
def log(*args):
if logging_task:
logging_task.log(*args)
else:
util.log(*args)
def should_create_resources():
"""Check if gateway, keypair, vpc exist."""
prefix = u.get... |
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_set_aws_environment; 3, parameters; 3, 4; 4, typed_default_parameter; 4, 5; 4, 6; 4, 8; 5, identifier:task; 6, type; 6, 7; 7, identifier:Task; 8, None; 9, block; 9, 10; 9, 12; 9, 24; 9, 36; 9, 63; 9, 89; 9, 90; 9, 113; 9, 114; 9, 115; 9, 150; ... | def _set_aws_environment(task: Task = None):
"""Sets up AWS environment from NCLUSTER environment variables"""
current_zone = os.environ.get('NCLUSTER_ZONE', '')
current_region = os.environ.get('AWS_DEFAULT_REGION', '')
def log(*args):
if task:
task.log(*args)
else:
util.log(*args)
if cu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.