nodes stringlengths 501 22.4k | edges stringlengths 138 5.07k | code stringlengths 108 19.3k |
|---|---|---|
0, module; 1, function_definition; 2, function_name:values; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, function_definition; 8, return_statement; 9, comment:"""
Return a list themeables sorted in reverse based
on the their depth in the inheritance hierarchy.
The sor... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 6, 9; 7, 10; 7, 11; 7, 12; 8, 13; 11, 14; 12, 15; 13, 16; 13, 17; 15, 18; 17, 19; 17, 20; 17, 21; 18, 22; 18, 23; 19, 24; 19, 25; 20, 26; 20, 27; 21, 28; 21, 29; 23, 30; 24, 31; 24, 32; 25, 33; 30, 34; 30, 35; 34, 36; 34, 37 | def values(self):
"""
Return a list themeables sorted in reverse based
on the their depth in the inheritance hierarchy.
The sorting is key applying and merging the themeables
so that they do not clash i.e :class:`axis_line`
applied before :class:`axis_line_x`.
""... |
0, module; 1, function_definition; 2, function_name:topological_sort; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, for_statement; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, while_statement; 1... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 6, 16; 7, 17; 8, 18; 9, 19; 9, 20; 9, 21; 10, 22; 10, 23; 10, 24; 11, 25; 12, 26; 12, 27; 12, 28; 13, 29; 14, 30; 14, 31; 15, 32; 15, 33; 15, 34; 17, 35; 17, 36; 18, 37; 18, 38; 21, 39; 24, 40; 25, 41; 25, 42; 28, 43; 29, 44... | def topological_sort(self):
""" Returns a topological ordering of the DAG.
Returns:
list: A list of topologically sorted nodes in the graph.
Raises:
ValueError: Raised if the graph is not acyclic.
"""
graph = self.graph
in_degree = {}
fo... |
0, module; 1, function_definition; 2, function_name:_music_lib_search; 3, parameters; 4, block; 5, identifier:self; 6, identifier:search; 7, identifier:start; 8, identifier:max_items; 9, expression_statement; 10, expression_statement; 11, comment:# Get result information; 12, expression_statement; 13, for_statement; 14... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 9, 15; 10, 16; 12, 17; 13, 18; 13, 19; 13, 20; 14, 21; 16, 22; 16, 23; 17, 24; 17, 25; 19, 26; 19, 27; 19, 28; 20, 29; 21, 30; 21, 31; 23, 32; 23, 33; 26, 34; 27, 35; 28, 36; 29, 37; 32, 38; 32, 39; 33, 40; 37, 41; 37, 42; 38, 43; ... | def _music_lib_search(self, search, start, max_items):
"""Perform a music library search and extract search numbers.
You can get an overview of all the relevant search prefixes (like
'A:') and their meaning with the request:
.. code ::
response = device.contentDirectory.Brows... |
0, module; 1, function_definition; 2, function_name:unique; 3, parameters; 4, block; 5, identifier:seq; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""Return the unique elements of a collection even if those elements are
unhashable and unsortable, like dic... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 9, 15; 11, 16; 11, 17; 14, 18; 18, 19; 18, 20; 19, 21; 19, 22; 20, 23; 23, 24; 24, 25; 24, 26; 25, 27; 25, 28; 26, 29 | def unique(seq):
"""Return the unique elements of a collection even if those elements are
unhashable and unsortable, like dicts and sets"""
cleaned = []
for each in seq:
if each not in cleaned:
cleaned.append(each)
return cleaned |
0, module; 1, function_definition; 2, function_name:build_schema_info; 3, parameters; 4, block; 5, identifier:connection_alias; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, with_statement; 10, return_statement; 11, comment:"""
Construct schema information via engine-specific que... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 8, 13; 9, 14; 9, 15; 10, 16; 12, 17; 12, 18; 13, 19; 13, 20; 14, 21; 15, 22; 15, 23; 18, 24; 18, 25; 21, 26; 22, 27; 23, 28; 23, 29; 23, 30; 25, 31; 26, 32; 26, 33; 27, 34; 27, 35; 30, 36; 30, 37; 30, 38; 30, 39; 30, 40; 32, 41; 32, 42; 33, 43; ... | def build_schema_info(connection_alias):
"""
Construct schema information via engine-specific queries of the tables in the DB.
:return: Schema information of the following form, sorted by db_table_name.
[
("db_table_name",
[
("... |
0, module; 1, function_definition; 2, function_name:fetchThreads; 3, parameters; 4, block; 5, identifier:self; 6, identifier:thread_location; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, while_statement; 14, comment:#... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 7, 18; 7, 19; 8, 20; 8, 21; 9, 22; 9, 23; 10, 24; 11, 25; 12, 26; 13, 27; 13, 28; 13, 29; 15, 30; 15, 31; 16, 32; 16, 33; 17, 34; 25, 35; 25, 36; 26, 37; 26, 38; 29, 39; 29, 40; 29, 41; 29, 42; 29, 43; 29, 44; ... | def fetchThreads(self, thread_location, before=None, after=None, limit=None):
"""
Get all threads in thread_location.
Threads will be sorted from newest to oldest.
:param thread_location: models.ThreadLocation: INBOX, PENDING, ARCHIVED or OTHER
:param before: Fetch only thread b... |
0, module; 1, function_definition; 2, function_name:_get_key_value; 3, parameters; 4, block; 5, identifier:self; 6, identifier:key; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, identifier:is_hll; 11, False; 12, string; 13, identifier:is_hll; 14, comment:# get hll value; 15, block; 16, else_clause... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 7, 10; 7, 11; 8, 12; 9, 13; 9, 14; 9, 15; 9, 16; 12, 17; 15, 18; 16, 19; 16, 20; 18, 21; 20, 22; 21, 23; 21, 24; 22, 25; 23, 26; 23, 27; 24, 28; 24, 29; 25, 30; 25, 31; 26, 32; 26, 33; 30, 34; 30, 35; 31, 36; 34, 37; 34, 38 | def _get_key_value(self, key, is_hll=False):
'''
Returns the proper key value for the stats
@param key: the redis key
@param is_hll: the key is a HyperLogLog, else is a sorted set
'''
if is_hll:
# get hll value
return self.redis_conn.execute_comma... |
0, module; 1, function_definition; 2, function_name:_get_bin; 3, parameters; 4, block; 5, identifier:self; 6, identifier:key; 7, expression_statement; 8, comment:# keys based on score; 9, expression_statement; 10, comment:# this doesnt return them in order, need to bin first; 11, for_statement; 12, return_statement; 13... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 9, 14; 11, 15; 11, 16; 11, 17; 12, 18; 13, 19; 14, 20; 14, 21; 16, 22; 16, 23; 17, 24; 17, 25; 17, 26; 17, 27; 17, 28; 22, 29; 22, 30; 23, 31; 24, 32; 26, 33; 27, 34; 27, 35; 28, 36; 29, 37; 29, 38; 32, 39; 32, 40; 33, 41; 33, 42; 34, 43;... | def _get_bin(self, key):
'''
Returns a binned dictionary based on redis zscore
@return: The sorted dict
'''
# keys based on score
sortedDict = {}
# this doesnt return them in order, need to bin first
for item in self.redis_conn.zscan_iter(key):
... |
0, module; 1, function_definition; 2, function_name:_is_viable_phone_number; 3, parameters; 4, block; 5, identifier:number; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, return_statement; 10, comment:"""Checks to see if a string could possibly be a phone number.
At the moment, checks to see... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 7, 12; 8, 13; 9, 14; 11, 15; 11, 16; 12, 17; 13, 18; 13, 19; 14, 20; 14, 21; 15, 22; 15, 23; 17, 24; 19, 25; 19, 26; 21, 27; 23, 28; 26, 29; 26, 30 | def _is_viable_phone_number(number):
"""Checks to see if a string could possibly be a phone number.
At the moment, checks to see that the string begins with at least 2
digits, ignoring any punctuation commonly found in phone numbers. This
method does not require the number to be normalized in advance ... |
0, module; 1, function_definition; 2, function_name:__encoded_params_for_signature; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:params; 7, expression_statement; 8, function_definition; 9, return_statement; 10, comment:"""
Sort and combine query parameters into a single string, excluding those that... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 7, 10; 8, 11; 8, 12; 8, 13; 9, 14; 12, 15; 13, 16; 14, 17; 14, 18; 16, 19; 16, 20; 16, 21; 17, 22; 17, 23; 18, 24; 19, 25; 19, 26; 20, 27; 20, 28; 21, 29; 21, 30; 21, 31; 21, 32; 21, 33; 21, 34; 24, 35; 24, 36; 27, 37; 27, 38; 28, 39; 29, 40; 29, 41; 30, 42; 30, 43;... | def __encoded_params_for_signature(cls, params):
"""
Sort and combine query parameters into a single string, excluding those that should be removed and joining with '&'
"""
def encoded_pairs(params):
for k, v in six.iteritems(params):
if k == 'hmac':
... |
0, module; 1, function_definition; 2, function_name:group_keys; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, for_statement; 8, comment:"""Return an iterator over member names for groups only.
Examples
--------
>>> import zarr
>>> g1 = zarr.group()
>>>... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 7, 10; 7, 11; 10, 12; 10, 13; 11, 14; 11, 15; 13, 16; 14, 17; 15, 18; 15, 19; 16, 20; 16, 21; 17, 22; 17, 23; 18, 24; 18, 25; 19, 26; 21, 27; 21, 28; 23, 29; 23, 30; 25, 31; 25, 32; 26, 33; 27, 34; 27, 35; 28, 36; 28, 37; 29, 38; 29, 39; 31, 40; 31, 41; 33, 42 | def group_keys(self):
"""Return an iterator over member names for groups only.
Examples
--------
>>> import zarr
>>> g1 = zarr.group()
>>> g2 = g1.create_group('foo')
>>> g3 = g1.create_group('bar')
>>> d1 = g1.create_dataset('baz', shape=100, chunks=10)
... |
0, module; 1, function_definition; 2, function_name:array_keys; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, for_statement; 8, comment:"""Return an iterator over member names for arrays only.
Examples
--------
>>> import zarr
>>> g1 = zarr.group()
>>>... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 7, 10; 7, 11; 10, 12; 10, 13; 11, 14; 11, 15; 13, 16; 14, 17; 15, 18; 15, 19; 16, 20; 16, 21; 17, 22; 17, 23; 18, 24; 18, 25; 19, 26; 21, 27; 21, 28; 23, 29; 23, 30; 25, 31; 25, 32; 26, 33; 27, 34; 27, 35; 28, 36; 28, 37; 29, 38; 29, 39; 31, 40; 31, 41; 33, 42 | def array_keys(self):
"""Return an iterator over member names for arrays only.
Examples
--------
>>> import zarr
>>> g1 = zarr.group()
>>> g2 = g1.create_group('foo')
>>> g3 = g1.create_group('bar')
>>> d1 = g1.create_dataset('baz', shape=100, chunks=10)
... |
0, module; 1, function_definition; 2, function_name:init_array; 3, parameters; 4, block; 5, identifier:store; 6, identifier:shape; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, defa... | 0, 1; 1, 2; 1, 3; 1, 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; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 7, 23; 7, 24; 8, 25; 8, 26; 9, 27; 9, 28; 10, 29; 10, 30; 11, 31; 11, 32; 12, 33; 12, 34; 13, 35; 13, 36; 14, 37; 14, 38; 15, 39; 15, 40; 16, 41; 16, 42; 17, 43; 19, 44; 21, 4... | def init_array(store, shape, chunks=True, dtype=None, compressor='default',
fill_value=None, order='C', overwrite=False, path=None,
chunk_store=None, filters=None, object_codec=None):
"""Initialize an array store with the given configuration. Note that this is a low-level
function ... |
0, module; 1, function_definition; 2, function_name:view; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, expression_statement; 14, expression_statement; 15, expr... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 6, 28; 6, 29; 7, 30; 7, 31; 8, 32; 8, 33; 9, 34; 9, 35; 10, 36; 10, 37; 11, 38; 11, 39; 12, 40; 12, 41; 13, 42; 14, 43; 15, 44; 16, 45; 17, ... | def view(self, shape=None, chunks=None, dtype=None,
fill_value=None, filters=None, read_only=None,
synchronizer=None):
"""Return an array sharing the same data.
Parameters
----------
shape : int or tuple of ints
Array shape.
chunks : int or ... |
0, module; 1, function_definition; 2, function_name:image_field_data; 3, parameters; 4, block; 5, identifier:request; 6, default_parameter; 7, expression_statement; 8, try_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, if_statement; 13, return_statement; 14, identifier:include_empt... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 6, 14; 6, 15; 7, 16; 8, 17; 8, 18; 9, 19; 10, 20; 11, 21; 11, 22; 11, 23; 12, 24; 12, 25; 13, 26; 17, 27; 18, 28; 18, 29; 19, 30; 19, 31; 20, 32; 20, 33; 23, 34; 23, 35; 24, 36; 25, 37; 27, 38; 29, 39; 30, 40; 30, 41; 31, 42; 33, 43; 34, ... | def image_field_data(request, include_empty_option=False):
"""Returns a list of tuples of all images.
Generates a sorted list of images available. And returns a list of
(id, name) tuples.
:param request: django http request object
:param include_empty_option: flag to include a empty tuple in the f... |
0, module; 1, function_definition; 2, function_name:sort_flavor_list; 3, parameters; 4, block; 5, identifier:request; 6, identifier:flavors; 7, default_parameter; 8, expression_statement; 9, function_definition; 10, try_statement; 11, identifier:with_menu_label; 12, True; 13, comment:"""Utility method to sort a list of... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 7, 11; 7, 12; 8, 13; 9, 14; 9, 15; 9, 16; 10, 17; 10, 18; 15, 19; 15, 20; 16, 21; 17, 22; 17, 23; 17, 24; 17, 25; 17, 26; 17, 27; 18, 28; 18, 29; 21, 30; 21, 31; 22, 32; 23, 33; 24, 34; 25, 35; 25, 36; 25, 37; 26, 38; 26, 39; 26, 40; 27, 41; 29, 42; 29, 43; 3... | def sort_flavor_list(request, flavors, with_menu_label=True):
"""Utility method to sort a list of flavors.
By default, returns the available flavors, sorted by RAM usage (ascending).
Override these behaviours with a ``CREATE_INSTANCE_FLAVOR_SORT`` dict
in ``local_settings.py``.
"""
def get_key(... |
0, module; 1, function_definition; 2, function_name:image_list_detailed; 3, parameters; 4, block; 5, identifier:request; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, dictionary_splat_pattern; 13, expression_statement; 14, expre... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 4, 28; 4, 29; 6, 30; 6, 31; 7, 32; 7, 33; 8, 34; 8, 35; 9, 36; 9, 37; 10, 38; 10, 39; 11, 40; 11, 41; 12, 42; 13, 43; 14, 44; 15, 45; 16, 46... | def image_list_detailed(request, marker=None, sort_dir='desc',
sort_key='created_at', filters=None, paginate=False,
reversed_order=False, **kwargs):
"""Thin layer above glanceclient, for handling pagination issues.
It provides iterating both forward and backward ... |
0, module; 1, function_definition; 2, function_name:metadefs_namespace_list; 3, parameters; 4, block; 5, identifier:request; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, comment:# Listing namespaces requires the v2 API. If n... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 4, 28; 4, 29; 4, 30; 4, 31; 4, 32; 4, 33; 6, 34; 6, 35; 7, 36; 7, 37; 8, 38; 8, 39; 9, 40; 9, 41; 10, 42; 10, 43; 11, 44; 14, 45; 14, 46; 15... | def metadefs_namespace_list(request,
filters=None,
sort_dir='asc',
sort_key='namespace',
marker=None,
paginate=False):
"""Retrieve a listing of Namespaces
:param paginate:... |
0, module; 1, function_definition; 2, function_name:sort_js_files; 3, parameters; 4, block; 5, identifier:js_files; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, comment:"""Sorts JavaScrip... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 12, 19; 14, 20; 14, 21; 15, 22; 15, 23; 16, 24; 16, 25; 17, 26; 17, 27; 18, 28; 18, 29; 19, 30; 19, 31; 19, 32; 21, 33; 21, 34; 21, 35; 23, 36; 23, 37; 23, 38; 25, 39; 25, 40; 25, 41; 27, 42; 27, 43; 2... | def sort_js_files(js_files):
"""Sorts JavaScript files in `js_files`.
It sorts JavaScript files in a given `js_files`
into source files, mock files and spec files based on file extension.
Output:
* sources: source files for production. The order of source files
is significant and should be... |
0, module; 1, function_definition; 2, function_name:_slice_mostly_sorted; 3, parameters; 4, block; 5, identifier:array; 6, identifier:keep; 7, identifier:rest; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, expression_statement;... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 8, 20; 8, 21; 9, 22; 10, 23; 10, 24; 11, 25; 12, 26; 13, 27; 13, 28; 13, 29; 14, 30; 15, 31; 16, 32; 16, 33; 16, 34; 17, 35; 17, 36; 17, 37; 18, 38; 19, 39; 23, 40; 23, 41; 24, 42; 25, 43; 25, 44;... | def _slice_mostly_sorted(array, keep, rest, ind=None):
"""Slice dask array `array` that is almost entirely sorted already.
We perform approximately `2 * len(keep)` slices on `array`.
This is OK, since `keep` is small. Individually, each of these slices
is entirely sorted.
Parameters
----------... |
0, module; 1, function_definition; 2, function_name:sort_servers_closest; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, generic_type; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, comment:# these tasks should never raise, returns None on errors; 12, expression_statement; 13, comment... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 4, 7; 5, 8; 5, 9; 5, 10; 5, 11; 5, 12; 5, 13; 5, 14; 5, 15; 5, 16; 6, 17; 6, 18; 7, 19; 7, 20; 8, 21; 9, 22; 9, 23; 10, 24; 12, 25; 14, 26; 15, 27; 16, 28; 18, 29; 20, 30; 22, 31; 23, 32; 24, 33; 24, 34; 25, 35; 25, 36; 26, 37; 26, 38; 26, 39; 27, 40; 27, 41; 29, 42; 29, 43; 30, 44; ... | def sort_servers_closest(servers: Sequence[str]) -> Sequence[Tuple[str, float]]:
"""Sorts a list of servers by http round-trip time
Params:
servers: sequence of http server urls
Returns:
sequence of pairs of url,rtt in seconds, sorted by rtt, excluding failed servers
(possibly empty... |
0, module; 1, function_definition; 2, function_name:get_runs_by_id; 3, parameters; 4, block; 5, identifier:self; 6, identifier:config_id; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, expression_statement; 12, return_statement; 13, comment:"""
returns a list of runs... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 8, 14; 9, 15; 10, 16; 10, 17; 10, 18; 11, 19; 12, 20; 14, 21; 14, 22; 15, 23; 15, 24; 17, 25; 17, 26; 18, 27; 19, 28; 19, 29; 20, 30; 22, 31; 22, 32; 25, 33; 25, 34; 27, 35; 27, 36; 28, 37; 28, 38; 29, 39; 31, 40; 31, 41; 33, 42; 33, 43; ... | def get_runs_by_id(self, config_id):
"""
returns a list of runs for a given config id
The runs are sorted by ascending budget, so '-1' will give
the longest run for this config.
"""
d = self.data[config_id]
runs = []
for b in d.results.keys():
try:
err_logs = d.exceptions.get(b, None)
if d... |
0, module; 1, function_definition; 2, function_name:spell; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, typed_parameter; 8, generic_type; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier:word; 15, type; 16, identifier:List; 1... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 4, 8; 5, 9; 5, 10; 5, 11; 5, 12; 5, 13; 7, 14; 7, 15; 8, 16; 8, 17; 9, 18; 10, 19; 10, 20; 11, 21; 12, 22; 13, 23; 15, 24; 17, 25; 19, 26; 20, 27; 21, 28; 21, 29; 22, 30; 22, 31; 25, 32; 27, 33; 29, 34; 30, 35; 30, 36; 31, 37; 31, 38; 34, 39; 34, 40; 37, 41; 37, 42; 38, 43; 38,... | def spell(self, word: str) -> List[str]:
"""
Return a list of possible words, according to edit distance of 1 and 2,
sorted by frequency of word occurrance in the spelling dictionary
:param str word: A word to check its spelling
"""
if not word:
return ""
... |
0, module; 1, function_definition; 2, function_name:rank; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, typed_default_parameter; 8, identifier:Counter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, return_statement; 13, identifier:words; 14, type; 15, identifier:exclude_stopwords; 16, type... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 4, 8; 5, 9; 5, 10; 5, 11; 5, 12; 6, 13; 6, 14; 7, 15; 7, 16; 7, 17; 9, 18; 10, 19; 10, 20; 11, 21; 11, 22; 12, 23; 14, 24; 16, 25; 19, 26; 20, 27; 22, 28; 23, 29; 23, 30; 24, 31; 24, 32; 27, 33; 28, 34; 30, 35; 32, 36; 34, 37; 34, 38; 36, 39; 38, 40; 38, 41; 38, 42; 41, 43; 41,... | def rank(words: List[str], exclude_stopwords: bool = False) -> Counter:
"""
Sort words by frequency
:param list words: a list of words
:param bool exclude_stopwords: exclude stopwords
:return: Counter
"""
if not words:
return None
if exclude_stopwords:
words = [word for... |
0, module; 1, function_definition; 2, function_name:iter; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, dictionary_splat_pattern; 10, expression_statement; 11, assert_statement; 12, if_statement; 13, expression_statement; 14, while_statement; 15, ident... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 6, 15; 6, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 11, 23; 12, 24; 12, 25; 13, 26; 14, 27; 14, 28; 23, 29; 23, 30; 24, 31; 24, 32; 25, 33; 26, 34; 26, 35; 27, 36; 27, 37; 28, 38; 28, 39; 28, 40; 28, 41; 28, 42; 28, 43; 28, 44... | def iter(self, offset=0, count=None, pagesize=None, **kwargs):
"""Iterates over the collection.
This method is equivalent to the :meth:`list` method, but
it returns an iterator and can load a certain number of entities at a
time from the server.
:param offset: The index of the ... |
0, module; 1, function_definition; 2, function_name:list; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, dictionary_splat_pattern; 8, expression_statement; 9, comment:# response = self.get(count=count, **kwargs); 10, comment:# return self._load_list(response); 11, return_statement; 12, identifier... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 8, 15; 11, 16; 16, 17; 16, 18; 18, 19; 19, 20; 19, 21; 20, 22; 20, 23; 21, 24; 21, 25; 24, 26; 24, 27; 25, 28 | def list(self, count=None, **kwargs):
"""Retrieves a list of entities in this collection.
The entire collection is loaded at once and is returned as a list. This
function makes a single roundtrip to the server, plus at most two more if
the ``autologin`` field of :func:`connect` is set t... |
0, module; 1, function_definition; 2, function_name:query; 3, parameters; 4, block; 5, identifier:self; 6, dictionary_splat_pattern; 7, expression_statement; 8, return_statement; 9, identifier:query; 10, comment:"""
Gets the results of query, with optional parameters sort, limit, skip, and fields.
:par... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 6, 9; 7, 10; 8, 11; 11, 12; 11, 13; 12, 14; 12, 15; 13, 16; 16, 17; 16, 18; 17, 19; 17, 20; 18, 21; 19, 22; 19, 23; 21, 24; 22, 25; 22, 26; 25, 27; 25, 28; 27, 29; 27, 30; 29, 31; 29, 32; 30, 33; 30, 34; 34, 35 | def query(self, **query):
"""
Gets the results of query, with optional parameters sort, limit, skip, and fields.
:param query: Optional parameters. Valid options are sort, limit, skip, and fields
:type query: ``dict``
:return: Array of documents retrieved by query.
:rty... |
0, module; 1, function_definition; 2, function_name:query; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, dictionary_splat_pattern; 14, expression_statement; 15,... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 6, 21; 6, 22; 7, 23; 7, 24; 8, 25; 8, 26; 9, 27; 9, 28; 10, 29; 10, 30; 11, 31; 11, 32; 12, 33; 12, 34; 13, 35; 14, 36; 15, 37; 16, 38; 17, 39; 18, 40; 19, 41; 20, 42; 28, 43; 37, 44; 37, 4... | def query(self, area=None, date=None, raw=None, area_relation='Intersects',
order_by=None, limit=None, offset=0, **keywords):
"""Query the OpenSearch API with the coordinates of an area, a date interval
and any other search keywords accepted by the API.
Parameters
--------... |
0, module; 1, function_definition; 2, function_name:get_suggested_type_names; 3, parameters; 4, block; 5, identifier:schema; 6, identifier:output_type; 7, identifier:field_name; 8, expression_statement; 9, if_statement; 10, comment:# Otherwise, must be an Object type, which does not have possible fields.; 11, return_st... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 8, 12; 9, 13; 9, 14; 11, 15; 13, 16; 13, 17; 14, 18; 14, 19; 14, 20; 14, 21; 14, 22; 14, 23; 14, 24; 14, 25; 17, 26; 17, 27; 18, 28; 19, 29; 20, 30; 20, 31; 20, 32; 22, 33; 24, 34; 25, 35; 27, 36; 27, 37; 28, 38; 28, 39; 29, 40; 29, 41; 31, 42; 31, 43;... | def get_suggested_type_names(schema, output_type, field_name):
"""Go through all of the implementations of type, as well as the interfaces
that they implement. If any of those types include the provided field,
suggest them, sorted by how often the type is referenced, starting
with Interfaces."""
... |
0, module; 1, function_definition; 2, function_name:suggestion_list; 3, parameters; 4, block; 5, identifier:inp; 6, identifier:options; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, comment:"""
Given an invalid input string and a list of val... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 8, 13; 9, 14; 10, 15; 10, 16; 10, 17; 11, 18; 13, 19; 13, 20; 14, 21; 14, 22; 17, 23; 17, 24; 17, 25; 18, 26; 18, 27; 20, 28; 20, 29; 22, 30; 22, 31; 23, 32; 24, 33; 25, 34; 25, 35; 27, 36; 27, 37; 30, 38; 30, 39; 32, 40; 32, 41; 33, 42; 33, 43;... | def suggestion_list(inp, options):
"""
Given an invalid input string and a list of valid options, returns a filtered
list of valid options sorted based on their similarity with the input.
"""
options_by_distance = OrderedDict()
input_threshold = len(inp) / 2
for option in options:
... |
0, module; 1, function_definition; 2, function_name:lexical_distance; 3, parameters; 4, block; 5, identifier:a; 6, identifier:b; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, for_statement; 12, return_statement; 13, comment:"""
Computes the lexical distance betwe... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 8, 14; 9, 15; 10, 16; 10, 17; 10, 18; 11, 19; 11, 20; 11, 21; 12, 22; 14, 23; 14, 24; 15, 25; 15, 26; 17, 27; 17, 28; 18, 29; 20, 30; 20, 31; 21, 32; 22, 33; 22, 34; 24, 35; 24, 36; 26, 37; 26, 38; 28, 39; 29, 40; 29, 41; 29, 42; 31, 43; ... | def lexical_distance(a, b):
"""
Computes the lexical distance between strings A and B.
The "distance" between two strings is given by counting the minimum number
of edits needed to transform string A into string B. An edit can be an
insertion, deletion, or substitution of a single character, or ... |
0, module; 1, function_definition; 2, function_name:arrange; 3, parameters; 4, block; 5, identifier:df; 6, list_splat_pattern; 7, dictionary_splat_pattern; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 6, 14; 7, 15; 8, 16; 9, 17; 10, 18; 11, 19; 12, 20; 13, 21; 17, 22; 17, 23; 18, 24; 18, 25; 19, 26; 19, 27; 20, 28; 20, 29; 21, 30; 21, 31; 21, 32; 23, 33; 23, 34; 25, 35; 25, 36; 27, 37; 27, 38; 29, 39; 29, 40; 30, 41; 30, 42; 31, 43; 31... | def arrange(df, *args, **kwargs):
"""Calls `pandas.DataFrame.sort_values` to sort a DataFrame according to
criteria.
See:
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.sort_values.html
For a list of specific keyword arguments for sort_values (which will be
the same in ... |
0, module; 1, function_definition; 2, function_name:csort; 3, parameters; 4, block; 5, identifier:objs; 6, identifier:key; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""Order-preserving sorting function."""; 11, assignment; 12, call; 13, identifier:idxs; 14, call; 15, identifier:... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 7, 10; 8, 11; 9, 12; 11, 13; 11, 14; 12, 15; 12, 16; 14, 17; 14, 18; 16, 19; 16, 20; 18, 21; 18, 22; 20, 23; 20, 24; 21, 25; 21, 26; 22, 27; 22, 28; 24, 29; 24, 30; 27, 31; 27, 32; 28, 33; 28, 34; 29, 35; 30, 36; 30, 37; 34, 38; 36, 39; 36, 40; 37, 41; 37, 42; 40, 4... | def csort(objs, key):
"""Order-preserving sorting function."""
idxs = dict((obj, i) for (i, obj) in enumerate(objs))
return sorted(objs, key=lambda obj: (key(obj), idxs[obj])) |
0, module; 1, function_definition; 2, function_name:fast_combine_pairs; 3, parameters; 4, block; 5, identifier:files; 6, identifier:force_single; 7, identifier:full_name; 8, identifier:separators; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_state... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 9, 21; 10, 22; 11, 23; 12, 24; 13, 25; 14, 26; 16, 27; 16, 28; 16, 29; 18, 30; 20, 31; 22, 32; 22, 33; 23, 34; 23, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 29, 42; 30, 43; 30, 44... | def fast_combine_pairs(files, force_single, full_name, separators):
"""
assume files that need to be paired are within 10 entries of each other, once the list is sorted
"""
files = sort_filenames(files)
chunks = tz.sliding_window(10, files)
pairs = [combine_pairs(chunk, force_single, full_name, ... |
0, module; 1, function_definition; 2, function_name:align_bam; 3, parameters; 4, block; 5, identifier:in_bam; 6, identifier:ref_file; 7, identifier:names; 8, identifier:align_dir; 9, identifier:data; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_s... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 10, 21; 11, 22; 12, 23; 13, 24; 14, 25; 15, 26; 16, 27; 18, 28; 19, 29; 19, 30; 20, 31; 22, 32; 22, 33; 23, 34; 23, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 27, 42; 27, 43; 28, 4... | def align_bam(in_bam, ref_file, names, align_dir, data):
"""Perform direct alignment of an input BAM file with BWA using pipes.
This avoids disk IO by piping between processes:
- samtools sort of input BAM to queryname
- bedtools conversion to interleaved FASTQ
- bwa-mem alignment
- samtool... |
0, module; 1, function_definition; 2, function_name:_combine_regions; 3, parameters; 4, block; 5, identifier:all_regions; 6, identifier:ref_regions; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, function_definition; 11, expression_statement; 12, for_statement; 13, expression_statement; 14, exp... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 7, 16; 8, 17; 9, 18; 9, 19; 9, 20; 10, 21; 10, 22; 10, 23; 11, 24; 12, 25; 12, 26; 12, 27; 13, 28; 14, 29; 15, 30; 17, 31; 17, 32; 18, 33; 18, 34; 19, 35; 19, 36; 20, 37; 22, 38; 23, 39; 23, 40; 24, 41; 24, 42; 27, 43; 28, 4... | def _combine_regions(all_regions, ref_regions):
"""Combine multiple BEDtools regions of regions into sorted final BEDtool.
"""
chrom_order = {}
for i, x in enumerate(ref_regions):
chrom_order[x.chrom] = i
def wchrom_key(x):
chrom, start, end = x
return (chrom_order[chrom], st... |
0, module; 1, function_definition; 2, function_name:_add_meta; 3, parameters; 4, block; 5, identifier:xs; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:sample; 13, None; 14, identifier:config; 15, None; 16, comment:"... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 7, 15; 8, 16; 9, 17; 10, 18; 10, 19; 10, 20; 11, 21; 17, 22; 17, 23; 20, 24; 20, 25; 20, 26; 20, 27; 20, 28; 24, 29; 24, 30; 25, 31; 26, 32; 26, 33; 27, 34; 27, 35; 28, 36; 29, 37; 29, 38; 30, 39; 31, 40; 31, 41; 33, 42; 33, 43; 35... | def _add_meta(xs, sample=None, config=None):
"""Add top level information about the sample or flowcell to output.
Sorts outputs into sample names (sample input) and project (config input).
"""
out = []
for x in xs:
if not isinstance(x["path"], six.string_types) or not os.path.exists(x["path... |
0, module; 1, function_definition; 2, function_name:report; 3, parameters; 4, block; 5, identifier:self; 6, identifier:align_bam; 7, identifier:ref_file; 8, identifier:is_paired; 9, identifier:bait_file; 10, identifier:target_file; 11, identifier:variant_region_file; 12, identifier:config; 13, expression_statement; 14,... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 13, 28; 14, 29; 15, 30; 18, 31; 19, 32; 20, 33; 20, 34; 21, 35; 21, 36; 21, 37; 22, 38; 23, 39; 24, 40; 25, 41; 25, 42; 26, 43; 26, 44; 27, ... | def report(self, align_bam, ref_file, is_paired, bait_file, target_file,
variant_region_file, config):
"""Produce report metrics using Picard with sorted aligned BAM file.
"""
dup_metrics = self._get_current_dup_metrics(align_bam)
align_metrics = self._collect_align_metric... |
0, module; 1, function_definition; 2, function_name:report; 3, parameters; 4, block; 5, identifier:self; 6, identifier:align_bam; 7, identifier:ref_file; 8, identifier:gtf_file; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, comment:# collect duplication metrics; 13, expression_statement; 14... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 9, 22; 9, 23; 10, 24; 10, 25; 11, 26; 13, 27; 14, 28; 15, 29; 16, 30; 16, 31; 17, 32; 18, 33; 19, 34; 20, 35; 20, 36; 21, 37; 27, 38; 27, 39; 28, 40; 28, 41; 29, 42; 29, 43; 31, 44; ... | def report(self, align_bam, ref_file, gtf_file, is_paired=False, rrna_file="null"):
"""Produce report metrics for a RNASeq experiment using Picard
with a sorted aligned BAM file.
"""
# collect duplication metrics
dup_metrics = self._get_current_dup_metrics(align_bam)
al... |
0, module; 1, function_definition; 2, function_name:apply_recal; 3, parameters; 4, block; 5, identifier:data; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, comment:# CWL does not have work/alignment BAM separation; 11, if_statement; 12, if_statement; 13, return_statemen... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 6, 14; 7, 15; 8, 16; 9, 17; 9, 18; 9, 19; 9, 20; 11, 21; 11, 22; 12, 23; 12, 24; 13, 25; 15, 26; 15, 27; 16, 28; 16, 29; 17, 30; 17, 31; 18, 32; 19, 33; 19, 34; 20, 35; 20, 36; 21, 37; 21, 38; 22, 39; 23, 40; 23, 41; 24, 42; 27, 43; 27, 4... | def apply_recal(data):
"""Apply recalibration tables to the sorted aligned BAM, producing recalibrated BAM.
"""
orig_bam = dd.get_align_bam(data) or dd.get_work_bam(data)
had_work_bam = "work_bam" in data
if dd.get_recalibrate(data) in [True, "gatk"]:
if data.get("prep_recal"):
l... |
0, module; 1, function_definition; 2, function_name:_prep_callable_bed; 3, parameters; 4, block; 5, identifier:in_file; 6, identifier:work_dir; 7, identifier:stats; 8, identifier:data; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, return_statement; 14, comment:"""Sor... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 9, 14; 10, 15; 11, 16; 12, 17; 12, 18; 13, 19; 15, 20; 15, 21; 16, 22; 16, 23; 17, 24; 18, 25; 19, 26; 19, 27; 21, 28; 21, 29; 23, 30; 23, 31; 24, 32; 24, 33; 25, 34; 25, 35; 26, 36; 26, 37; 27, 38; 27, 39; 28, 40; 28, 41; 29, 42; 29, 43;... | def _prep_callable_bed(in_file, work_dir, stats, data):
"""Sort and merge callable BED regions to prevent SV double counting
"""
out_file = os.path.join(work_dir, "%s-merge.bed.gz" % utils.splitext_plus(os.path.basename(in_file))[0])
gsort = config_utils.get_program("gsort", data)
if not utils.file_... |
0, module; 1, function_definition; 2, function_name:fake_index; 3, parameters; 4, block; 5, identifier:in_bam; 6, identifier:data; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, return_statement; 11, comment:"""Create a fake index file for namesorted BAMs. bais require by CWL for consistency.
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 9, 13; 9, 14; 10, 15; 12, 16; 12, 17; 13, 18; 14, 19; 17, 20; 17, 21; 18, 22; 18, 23; 19, 24; 19, 25; 22, 26; 22, 27; 23, 28; 24, 29; 25, 30; 29, 31; 30, 32; 30, 33; 31, 34; 31, 35; 32, 36; 33, 37; 34, 38; 34, 39; 35, 40; 36, 41; 37, 42; 39, 43;... | def fake_index(in_bam, data):
"""Create a fake index file for namesorted BAMs. bais require by CWL for consistency.
"""
index_file = "%s.bai" % in_bam
if not utils.file_exists(index_file):
with file_transaction(data, index_file) as tx_out_file:
with open(tx_out_file, "w") as out_hand... |
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, block; 5, identifier:in_bam; 6, identifier:config; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, assert_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, if_statement; 15, return_sta... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 7, 16; 7, 17; 8, 18; 8, 19; 9, 20; 10, 21; 10, 22; 11, 23; 11, 24; 12, 25; 13, 26; 14, 27; 14, 28; 15, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 23, 35; 24, 36; 25, 37; 25, 38; 26, 39; 26, 40; 27, 41; 28, 42; 28, 43; 28, 4... | def sort(in_bam, config, order="coordinate", out_dir=None):
"""Sort a BAM file, skipping if already present.
"""
assert is_bam(in_bam), "%s in not a BAM file" % in_bam
if bam_already_sorted(in_bam, config, order):
return in_bam
sort_stem = _get_sort_stem(in_bam, order, out_dir)
sort_fil... |
0, module; 1, function_definition; 2, function_name:tobam_cl; 3, parameters; 4, block; 5, identifier:data; 6, identifier:out_file; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, with_statement; 12, identifier:is_paired; 13, False; 14, comment:"""Prepare command lin... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 7, 13; 8, 14; 9, 15; 10, 16; 11, 17; 11, 18; 15, 19; 15, 20; 16, 21; 16, 22; 17, 23; 18, 24; 20, 25; 20, 26; 22, 27; 22, 28; 23, 29; 24, 30; 24, 31; 24, 32; 24, 33; 24, 34; 26, 35; 27, 36; 27, 37; 28, 38; 29, 39; 29, 40; 30, 41; 31, 42; 32, 43; ... | def tobam_cl(data, out_file, is_paired=False):
"""Prepare command line for producing de-duplicated sorted output.
- If no deduplication, sort and prepare a BAM file.
- If paired, then use samblaster and prepare discordant outputs.
- If unpaired, use biobambam's bammarkduplicates
"""
do_dedup = ... |
0, module; 1, function_definition; 2, function_name:sam_to_sortbam_cl; 3, parameters; 4, block; 5, identifier:data; 6, identifier:tx_out_file; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, i... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 7, 15; 8, 16; 9, 17; 10, 18; 11, 19; 12, 20; 13, 21; 17, 22; 17, 23; 18, 24; 18, 25; 19, 26; 19, 27; 20, 28; 20, 29; 21, 30; 23, 31; 23, 32; 24, 33; 24, 34; 25, 35; 25, 36; 27, 37; 27, 38; 29, 39; 29, 40; 29, 41; 30, 42; 30, 43; 31... | def sam_to_sortbam_cl(data, tx_out_file, name_sort=False):
"""Convert to sorted BAM output.
Set name_sort to True to sort reads by queryname
"""
samtools = config_utils.get_program("samtools", data["config"])
cores, mem = _get_cores_memory(data, downscale=2)
tmp_file = "%s-sorttmp" % utils.spli... |
0, module; 1, function_definition; 2, function_name:samblaster_dedup_sort; 3, parameters; 4, block; 5, identifier:data; 6, identifier:tx_out_file; 7, identifier:tx_sr_file; 8, identifier:tx_disc_file; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_s... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 9, 28; 10, 29; 11, 30; 12, 31; 13, 32; 15, 33; 17, 34; 18, 35; 19, 36; 19, 37; 19, 38; 21, 39; 22, 40; 23, 41; 24, 42; 26, 43; 27, 44; 29, 4... | def samblaster_dedup_sort(data, tx_out_file, tx_sr_file, tx_disc_file):
"""Deduplicate and sort with samblaster, produces split read and discordant pair files.
"""
samblaster = config_utils.get_program("samblaster", data["config"])
samtools = config_utils.get_program("samtools", data["config"])
tmp_... |
0, module; 1, function_definition; 2, function_name:_biobambam_dedup_sort; 3, parameters; 4, block; 5, identifier:data; 6, identifier:tx_out_file; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, return_statement; 13, comment:"""Perform streaming... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 8, 14; 9, 15; 10, 16; 11, 17; 11, 18; 11, 19; 12, 20; 14, 21; 14, 22; 15, 23; 15, 24; 16, 25; 16, 26; 17, 27; 17, 28; 18, 29; 18, 30; 19, 31; 19, 32; 20, 33; 20, 34; 22, 35; 22, 36; 23, 37; 23, 38; 24, 39; 24, 40; 26, 41; 26, 42; 27, 43; ... | def _biobambam_dedup_sort(data, tx_out_file):
"""Perform streaming deduplication and sorting with biobambam's bamsormadup
"""
samtools = config_utils.get_program("samtools", data["config"])
cores, mem = _get_cores_memory(data, downscale=2)
tmp_file = "%s-sorttmp" % utils.splitext_plus(tx_out_file)[0... |
0, module; 1, function_definition; 2, function_name:_prepare_bam_file; 3, parameters; 4, block; 5, identifier:bam_file; 6, identifier:tmp_dir; 7, identifier:config; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, comment:"""
Pipe sort by name cmd in case sort by coordin... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 8, 12; 9, 13; 10, 14; 10, 15; 11, 16; 13, 17; 13, 18; 14, 19; 14, 20; 15, 21; 18, 22; 18, 23; 21, 24; 23, 25; 23, 26; 24, 27; 24, 28; 28, 29; 28, 30; 30, 31; 30, 32; 30, 33 | def _prepare_bam_file(bam_file, tmp_dir, config):
"""
Pipe sort by name cmd in case sort by coordinates
"""
sort_mode = _get_sort_order(bam_file, config)
if sort_mode != "queryname":
bam_file = sort(bam_file, config, "queryname")
return bam_file |
0, module; 1, function_definition; 2, function_name:_concat_records; 3, parameters; 4, block; 5, identifier:items_by_key; 6, identifier:input_order; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, return_statement; 14, comment... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 9, 16; 9, 17; 9, 18; 10, 19; 11, 20; 12, 21; 12, 22; 13, 23; 15, 24; 15, 25; 16, 26; 16, 27; 17, 28; 17, 29; 18, 30; 19, 31; 19, 32; 20, 33; 20, 34; 21, 35; 21, 36; 22, 37; 22, 38; 22, 39; 22, 40; 23, 41; 23, 42; 28, 43; 28,... | def _concat_records(items_by_key, input_order):
"""Concatenate records into a single key to avoid merging.
Handles heterogeneous records that will then be sorted out in
the processing fuction.
"""
all_records = []
for (k, t) in input_order.items():
if t == "record":
all_reco... |
0, module; 1, function_definition; 2, function_name:_combine_files; 3, parameters; 4, block; 5, identifier:tsv_files; 6, identifier:work_dir; 7, identifier:data; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, return_statement; 14, comment:"""C... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 8, 14; 9, 15; 10, 16; 11, 17; 12, 18; 12, 19; 13, 20; 15, 21; 15, 22; 16, 23; 16, 24; 17, 25; 17, 26; 18, 27; 19, 28; 22, 29; 22, 30; 24, 31; 24, 32; 26, 33; 26, 34; 27, 35; 27, 36; 28, 37; 28, 38; 29, 39; 29, 40; 30, 41; 31, 42; 31, 43; ... | def _combine_files(tsv_files, work_dir, data):
"""Combine multiple priority tsv files into a final sorted output.
"""
header = "\t".join(["caller", "sample", "chrom", "start", "end", "svtype",
"lof", "annotation", "split_read_support", "paired_support_PE", "paired_support_PR"])
s... |
0, module; 1, function_definition; 2, function_name:sort_filenames; 3, parameters; 4, block; 5, identifier:filenames; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, return_statement; 10, comment:"""
sort a list of files by filename only, ignoring the directory names
"""; 11, assig... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 9, 13; 11, 14; 11, 15; 12, 16; 12, 17; 13, 18; 13, 19; 15, 20; 15, 21; 17, 22; 17, 23; 18, 24; 18, 25; 19, 26; 19, 27; 20, 28; 20, 29; 21, 30; 21, 31; 22, 32; 22, 33; 23, 34; 23, 35; 28, 36; 28, 37; 29, 38; 35, 39; 35, 40; 36, 41; 36, 42; 40, 43... | def sort_filenames(filenames):
"""
sort a list of files by filename only, ignoring the directory names
"""
basenames = [os.path.basename(x) for x in filenames]
indexes = [i[0] for i in sorted(enumerate(basenames), key=lambda x:x[1])]
return [filenames[x] for x in indexes] |
0, module; 1, function_definition; 2, function_name:sort_csv; 3, parameters; 4, block; 5, identifier:in_file; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, return_statement; 10, comment:"""Sort a CSV file by read name, allowing direct comparison.
"""; 11, assignment; 12, not_operator; 13, bl... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 8, 13; 9, 14; 11, 15; 11, 16; 12, 17; 13, 18; 13, 19; 16, 20; 16, 21; 17, 22; 18, 23; 19, 24; 19, 25; 22, 26; 22, 27; 23, 28; 23, 29; 24, 30; 25, 31; 25, 32; 26, 33; 26, 34; 27, 35; 27, 36; 29, 37; 29, 38; 29, 39; 29, 40; 30, 41; 31, 42; 32, 43;... | def sort_csv(in_file):
"""Sort a CSV file by read name, allowing direct comparison.
"""
out_file = "%s.sort" % in_file
if not (os.path.exists(out_file) and os.path.getsize(out_file) > 0):
cl = ["sort", "-k", "1,1", in_file]
with open(out_file, "w") as out_handle:
child = subp... |
0, module; 1, function_definition; 2, function_name:hydra_to_vcf_writer; 3, parameters; 4, block; 5, identifier:hydra_file; 6, identifier:genome_2bit; 7, identifier:options; 8, identifier:out_handle; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, for_statement... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 9, 14; 10, 15; 11, 16; 12, 17; 13, 18; 13, 19; 13, 20; 15, 21; 15, 22; 16, 23; 16, 24; 17, 25; 17, 26; 20, 27; 22, 28; 24, 29; 24, 30; 25, 31; 25, 32; 26, 33; 27, 34; 30, 35; 33, 36; 33, 37; 34, 38; 34, 39; 35, 40; 35, 41; 37, 42; 37, 43;... | def hydra_to_vcf_writer(hydra_file, genome_2bit, options, out_handle):
"""Write hydra output as sorted VCF file.
Requires loading the hydra file into memory to perform sorting
on output VCF. Could generalize this to no sorting or by-chromosome
approach if this proves too memory intensive.
"""
_... |
0, module; 1, function_definition; 2, function_name:_split_by_ready_regions; 3, parameters; 4, block; 5, identifier:ext; 6, identifier:file_key; 7, identifier:dir_ext_fn; 8, expression_statement; 9, function_definition; 10, function_definition; 11, function_definition; 12, return_statement; 13, comment:"""Organize spli... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 8, 13; 9, 14; 9, 15; 9, 16; 10, 17; 10, 18; 10, 19; 11, 20; 11, 21; 11, 22; 12, 23; 15, 24; 16, 25; 16, 26; 16, 27; 18, 28; 19, 29; 19, 30; 21, 31; 22, 32; 25, 33; 26, 34; 27, 35; 29, 36; 30, 37; 30, 38; 30, 39; 32, 40; 32, 41; 32, 42; 33, 43; 3... | def _split_by_ready_regions(ext, file_key, dir_ext_fn):
"""Organize splits based on regions generated by parallel_prep_region.
Sort splits so largest regions analyzed first, avoiding potentially lagging runs
at end.
"""
def _sort_by_size(region_w_bams):
region, _ = region_w_bams
_, ... |
0, module; 1, function_definition; 2, function_name:_combine_variants; 3, parameters; 4, block; 5, identifier:in_vcfs; 6, identifier:out_file; 7, identifier:ref_file; 8, identifier:config; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, with_statement; 13, return_statement; 14, comment:... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 9, 14; 10, 15; 11, 16; 12, 17; 12, 18; 13, 19; 15, 20; 15, 21; 16, 22; 16, 23; 17, 24; 18, 25; 18, 26; 20, 27; 20, 28; 24, 29; 25, 30; 25, 31; 25, 32; 26, 33; 26, 34; 29, 35; 29, 36; 31, 37; 31, 38; 32, 39; 33, 40; 34, 41; 35, 42; 35, 43;... | def _combine_variants(in_vcfs, out_file, ref_file, config):
"""Combine variant files, writing the header from the first non-empty input.
in_vcfs is a list with each item starting with the chromosome regions,
and ending with the input file.
We sort by these regions to ensure the output file is in the ex... |
0, module; 1, function_definition; 2, function_name:picard_sort; 3, parameters; 4, block; 5, identifier:picard; 6, identifier:align_bam; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, if_statement; 15, re... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 7, 16; 7, 17; 8, 18; 8, 19; 9, 20; 9, 21; 10, 22; 10, 23; 11, 24; 12, 25; 13, 26; 13, 27; 14, 28; 14, 29; 15, 30; 25, 31; 25, 32; 26, 33; 26, 34; 27, 35; 28, 36; 29, 37; 31, 38; 31, 39; 32, 40; 32, 41; 35, 42; 36, 43; 36, 44... | def picard_sort(picard, align_bam, sort_order="coordinate",
out_file=None, compression_level=None, pipe=False):
"""Sort a BAM file by coordinates.
"""
base, ext = os.path.splitext(align_bam)
if out_file is None:
out_file = "%s-sort%s" % (base, ext)
if not file_exists(out_file... |
0, module; 1, function_definition; 2, function_name:picard_fix_rgs; 3, parameters; 4, block; 5, identifier:picard; 6, identifier:in_bam; 7, identifier:names; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, return_statement; 12, comment:"""Add read group information to BAM files and coordinate so... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 8, 12; 9, 13; 10, 14; 10, 15; 11, 16; 13, 17; 13, 18; 14, 19; 15, 20; 18, 21; 18, 22; 19, 23; 19, 24; 20, 25; 20, 26; 22, 27; 22, 28; 24, 29; 25, 30; 26, 31; 27, 32; 27, 33; 30, 34; 31, 35; 31, 36; 32, 37; 32, 38; 33, 39; 34, 40; 34, 41; 35, 42; 36, 43... | def picard_fix_rgs(picard, in_bam, names):
"""Add read group information to BAM files and coordinate sort.
"""
out_file = "%s-fixrgs.bam" % os.path.splitext(in_bam)[0]
if not file_exists(out_file):
with tx_tmpdir(picard._config) as tmp_dir:
with file_transaction(picard._config, out_f... |
0, module; 1, function_definition; 2, function_name:_enforce_max_region_size; 3, parameters; 4, block; 5, identifier:in_file; 6, identifier:data; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, function_definition; 11, expression_statement; 12, if_statement; 13, return_statement; 14, comm... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 7, 14; 8, 15; 9, 16; 10, 17; 10, 18; 10, 19; 11, 20; 12, 21; 12, 22; 13, 23; 15, 24; 15, 25; 16, 26; 16, 27; 18, 28; 19, 29; 20, 30; 20, 31; 21, 32; 22, 33; 29, 34; 31, 35; 31, 36; 32, 37; 32, 38; 33, 39; 33, 40; 33, 41; 34, 42; 34, 43; 3... | def _enforce_max_region_size(in_file, data):
"""Ensure we don't have any chunks in the region greater than 20kb.
VarDict memory usage depends on size of individual windows in the input
file. This breaks regions into 20kb chunks with 250bp overlaps. 20kb gives
~1Gb/core memory usage and the overlaps avo... |
0, module; 1, function_definition; 2, function_name:_prep_vrn_file; 3, parameters; 4, block; 5, identifier:in_file; 6, identifier:vcaller; 7, identifier:work_dir; 8, identifier:somatic_info; 9, identifier:ignore_file; 10, identifier:config; 11, expression_statement; 12, if_statement; 13, expression_statement; 14, if_st... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 11, 16; 12, 17; 12, 18; 12, 19; 12, 20; 13, 21; 14, 22; 14, 23; 15, 24; 17, 25; 17, 26; 18, 27; 19, 28; 19, 29; 20, 30; 21, 31; 21, 32; 22, 33; 23, 34; 23, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 27, 41; 28, 42; 28, 43; ... | def _prep_vrn_file(in_file, vcaller, work_dir, somatic_info, ignore_file, config):
"""Create a variant file to feed into the PhyloWGS prep script, limiting records.
Sorts by depth, adding top covered samples up to the sample_size supported
by PhyloWGS. The logic is that the higher depth samples will have b... |
0, module; 1, function_definition; 2, function_name:concat; 3, parameters; 4, block; 5, identifier:bed_files; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, if_statement; 11, return_statement; 12, identifier:catted; 13, None; 14, comment:"""
recursively concat a set of ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 8, 15; 9, 16; 9, 17; 10, 18; 10, 19; 10, 20; 11, 21; 15, 22; 15, 23; 16, 24; 16, 25; 17, 26; 18, 27; 19, 28; 19, 29; 20, 30; 21, 31; 21, 32; 23, 33; 23, 34; 23, 35; 24, 36; 24, 37; 26, 38; 26, 39; 26, 40; 26, 41; 28, 42; 29, 43; 30... | def concat(bed_files, catted=None):
"""
recursively concat a set of BED files, returning a
sorted bedtools object of the result
"""
bed_files = [x for x in bed_files if x]
if len(bed_files) == 0:
if catted:
# move to a .bed extension for downstream tools if not already
... |
0, module; 1, function_definition; 2, function_name:_get_sv_callers; 3, parameters; 4, block; 5, identifier:items; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""
return a sorted list of all of the structural variant callers run
"""; 11, assignment; 12, i... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 9, 15; 11, 16; 11, 17; 14, 18; 15, 19; 15, 20; 18, 21; 18, 22; 18, 23; 19, 24; 19, 25; 22, 26; 22, 27; 23, 28; 24, 29; 24, 30; 26, 31; 26, 32; 27, 33; 27, 34; 28, 35; 30, 36; 35, 37; 35, 38; 36, 39; 36, 40; 37, 41; 37, 42; 38, 43; ... | def _get_sv_callers(items):
"""
return a sorted list of all of the structural variant callers run
"""
callers = []
for data in items:
for sv in data.get("sv", []):
callers.append(sv["variantcaller"])
return list(set([x for x in callers if x != "sv-ensemble"])).sort() |
0, module; 1, function_definition; 2, function_name:get_sort_cmd; 3, parameters; 4, block; 5, default_parameter; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, if_statement; 10, return_statement; 11, identifier:tmp_dir; 12, None; 13, comment:"""Retrieve GNU coreutils sort command, using version-s... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 5, 11; 5, 12; 6, 13; 7, 14; 8, 15; 8, 16; 8, 17; 9, 18; 9, 19; 10, 20; 14, 21; 14, 22; 16, 23; 17, 24; 18, 25; 18, 26; 19, 27; 22, 28; 22, 29; 23, 30; 24, 31; 25, 32; 25, 33; 26, 34; 26, 35; 27, 36; 28, 37; 28, 38; 30, 39; 30, 40; 31, 41; 33, 42; 33, 43; 34, ... | def get_sort_cmd(tmp_dir=None):
"""Retrieve GNU coreutils sort command, using version-sort if available.
Recent versions of sort have alpha-numeric sorting, which provides
more natural sorting of chromosomes (chr1, chr2) instead of (chr1, chr10).
This also fixes versions of sort, like 8.22 in CentOS 7.... |
0, module; 1, function_definition; 2, function_name:clean_file; 3, parameters; 4, block; 5, identifier:in_file; 6, identifier:data; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, comment:# Remove non-ascii characters. Used in coverage analysis, to support JSON code in on... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 9, 20; 10, 21; 13, 22; 14, 23; 14, 24; 22, 25; 22, 26; 24, 27; 24, 28; 24, 29; 24, 30; 24, 31; 24, 32; 24, 33; 24, 34; 24, 35; 26, 36; 26, 37; 26, 38; 27, 39; 27, 40; 29, 41; 29, 42; 30, 43; 31, 4... | def clean_file(in_file, data, prefix="", bedprep_dir=None, simple=None):
"""Prepare a clean sorted input BED file without headers
"""
# Remove non-ascii characters. Used in coverage analysis, to support JSON code in one column
# and be happy with sambamba:
simple = "iconv -c -f utf-8 -t ascii | se... |
0, module; 1, function_definition; 2, function_name:_sort_by_region; 3, parameters; 4, block; 5, identifier:fnames; 6, identifier:regions; 7, identifier:ref_file; 8, identifier:config; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, expression_statement; 13, assert_statement; 14, expression_st... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 9, 18; 10, 19; 11, 20; 11, 21; 11, 22; 12, 23; 13, 24; 13, 25; 14, 26; 15, 27; 15, 28; 15, 29; 16, 30; 17, 31; 19, 32; 19, 33; 20, 34; 20, 35; 21, 36; 21, 37; 22, 38; 23, 39; 23, 40; 24, 41; 24, 42; 25, 43; 25,... | def _sort_by_region(fnames, regions, ref_file, config):
"""Sort a set of regionally split files by region for ordered output.
"""
contig_order = {}
for i, sq in enumerate(ref.file_contigs(ref_file, config)):
contig_order[sq.name] = i
sitems = []
assert len(regions) == len(fnames), (regio... |
0, module; 1, function_definition; 2, function_name:_get_file_list; 3, parameters; 4, block; 5, identifier:orig_files; 6, identifier:out_file; 7, identifier:regions; 8, identifier:ref_file; 9, identifier:config; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, expressi... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 10, 18; 11, 19; 12, 20; 13, 21; 13, 22; 13, 23; 13, 24; 13, 25; 14, 26; 15, 27; 16, 28; 16, 29; 17, 30; 19, 31; 19, 32; 20, 33; 20, 34; 21, 35; 21, 36; 23, 37; 24, 38; 24, 39; 25, 40; 26, 41; 26, 42; 27, 43; 27... | def _get_file_list(orig_files, out_file, regions, ref_file, config):
"""Create file with region sorted list of non-empty VCFs for concatenating.
"""
sorted_files = _sort_by_region(orig_files, regions, ref_file, config)
exist_files = [(c, x) for c, x in sorted_files if os.path.exists(x) and vcf_has_varia... |
0, module; 1, function_definition; 2, function_name:sort_by_ref; 3, parameters; 4, block; 5, identifier:vcf_file; 6, identifier:data; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, return_statement; 11, comment:"""Sort a VCF file by genome reference and position, adding contig information.
"... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 9, 13; 9, 14; 10, 15; 12, 16; 12, 17; 13, 18; 14, 19; 15, 20; 15, 21; 17, 22; 17, 23; 18, 24; 18, 25; 19, 26; 19, 27; 21, 28; 21, 29; 23, 30; 23, 31; 24, 32; 24, 33; 25, 34; 25, 35; 26, 36; 27, 37; 27, 38; 27, 39; 27, 40; 27, 41; 29, 42; 29, 43;... | def sort_by_ref(vcf_file, data):
"""Sort a VCF file by genome reference and position, adding contig information.
"""
out_file = "%s-prep.vcf.gz" % utils.splitext_plus(vcf_file)[0]
if not utils.file_uptodate(out_file, vcf_file):
with file_transaction(data, out_file) as tx_out_file:
he... |
0, module; 1, function_definition; 2, function_name:align_to_sort_bam; 3, parameters; 4, block; 5, identifier:fastq1; 6, identifier:fastq2; 7, identifier:aligner; 8, identifier:data; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, expression_statement; 14, expression_s... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 9, 19; 10, 20; 11, 21; 12, 22; 12, 23; 13, 24; 14, 25; 15, 26; 16, 27; 16, 28; 16, 29; 17, 30; 17, 31; 18, 32; 20, 33; 20, 34; 21, 35; 21, 36; 22, 37; 22, 38; 23, 39; 24, 40; 24, 41; 25, 42; 25, 43; 26, ... | def align_to_sort_bam(fastq1, fastq2, aligner, data):
"""Align to the named genome build, returning a sorted BAM file.
"""
names = data["rgnames"]
align_dir_parts = [data["dirs"]["work"], "align", names["sample"]]
if data.get("disambiguate"):
align_dir_parts.append(data["disambiguate"]["geno... |
0, module; 1, function_definition; 2, function_name:_align_from_fastq; 3, parameters; 4, block; 5, identifier:fastq1; 6, identifier:fastq2; 7, identifier:aligner; 8, identifier:align_ref; 9, identifier:sam_ref; 10, identifier:names; 11, identifier:align_dir; 12, identifier:data; 13, expression_statement; 14, expression... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 13, 19; 14, 20; 15, 21; 16, 22; 18, 23; 18, 24; 18, 25; 18, 26; 20, 27; 20, 28; 21, 29; 21, 30; 22, 31; 22, 32; 23, 33; 23, 34; 24, 35; 24, 36; 26, 37; 28, 38; 28, 39; 30, 40; 30, 41; 32, 42; 32, 43; 34,... | def _align_from_fastq(fastq1, fastq2, aligner, align_ref, sam_ref, names,
align_dir, data):
"""Align from fastq inputs, producing sorted BAM output.
"""
config = data["config"]
align_fn = TOOLS[aligner].align_fn
out = align_fn(fastq1, fastq2, align_ref, names, align_dir, data)
... |
0, module; 1, function_definition; 2, function_name:picard_prep; 3, parameters; 4, block; 5, identifier:in_bam; 6, identifier:names; 7, identifier:ref_file; 8, identifier:dirs; 9, identifier:data; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_stat... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 10, 19; 11, 20; 12, 21; 13, 22; 14, 23; 15, 24; 15, 25; 16, 26; 17, 27; 18, 28; 20, 29; 20, 30; 21, 31; 21, 32; 22, 33; 22, 34; 23, 35; 23, 36; 24, 37; 25, 38; 26, 39; 26, 40; 27, 41; 27, 42; 28, 43; 28,... | def picard_prep(in_bam, names, ref_file, dirs, data):
"""Prepare input BAM using Picard and GATK cleaning tools.
- ReorderSam to reorder file to reference
- AddOrReplaceReadGroups to add read group information and coordinate sort
- PrintReads to filters to remove problem records:
- filterMBQ to rem... |
0, module; 1, function_definition; 2, function_name:iterate_flattened_separately; 3, parameters; 4, block; 5, identifier:dictionary; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, for_statement; 10, expression_statement; 11, for_statement; 12, expression_statement; 13, for_statement; 14, identifier:... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 6, 14; 6, 15; 7, 16; 8, 17; 8, 18; 9, 19; 9, 20; 9, 21; 10, 22; 11, 23; 11, 24; 11, 25; 12, 26; 13, 27; 13, 28; 13, 29; 17, 30; 17, 31; 18, 32; 21, 33; 22, 34; 22, 35; 24, 36; 24, 37; 25, 38; 26, 39; 26, 40; 28, 41; 28, 42; 29, 43; 29, 44... | def iterate_flattened_separately(dictionary, manually_sorted_keys=None):
"""
Recursively iterate over the items of a dictionary in a special order.
First iterate over manually sorted keys and then over all items that are
non-dictionary values (sorted by keys), then over the rest
(sorted by keys), p... |
0, module; 1, function_definition; 2, function_name:gather_command_line_options; 3, parameters; 4, block; 5, default_parameter; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, return_statement; 10, identifier:filter_disabled; 11, None; 12, comment:"""Get a sorted list of all CommandLineOption subc... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 5, 10; 5, 11; 6, 12; 7, 13; 7, 14; 8, 15; 9, 16; 13, 17; 13, 18; 14, 19; 15, 20; 15, 21; 16, 22; 16, 23; 19, 24; 21, 25; 21, 26; 21, 27; 23, 28; 23, 29; 24, 30; 24, 31; 26, 32; 26, 33; 27, 34; 29, 35; 29, 36; 31, 37; 33, 38; 33, 39; 34, 40; 34, 41; 36, 42; 36, 43; 3... | def gather_command_line_options(filter_disabled=None):
"""Get a sorted list of all CommandLineOption subclasses."""
if filter_disabled is None:
filter_disabled = not SETTINGS.COMMAND_LINE.SHOW_DISABLED_OPTIONS
options = [opt for opt in get_inheritors(CommandLineOption)
if not filter_d... |
0, module; 1, function_definition; 2, function_name:bar; 3, parameters; 4, block; 5, identifier:df; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_param... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 3, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 4, 28; 4, 29; 4, 30; 4, 31; 4, 32; 4, 33; 4, 34; 6, 35; 6, 36; 7, 37; 7, 38; 8, 39; 8, 40; 9, 41; 9, 42; 10, 43; 10, 44; 11, 45; 11, 46; 12,... | def bar(df, figsize=(24, 10), fontsize=16, labels=None, log=False, color='dimgray', inline=False,
filter=None, n=0, p=0, sort=None):
"""
A bar chart visualization of the nullity of the given DataFrame.
:param df: The input DataFrame.
:param log: Whether or not to display a logorithmic plot. Def... |
0, module; 1, function_definition; 2, function_name:heatmap; 3, parameters; 4, block; 5, identifier:df; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_p... | 0, 1; 1, 2; 1, 3; 1, 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; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 4, 28; 4, 29; 4, 30; 4, 31; 4, 32; 4, 33; 4, 34; 4, 35; 4, 36; 4, 37; 4, 38; 4, 39; 4, 40; 4, 41; 6, 42; 6, 43; 7, 44; 7, 45; 8, 46; 8, 47; ... | def heatmap(df, inline=False,
filter=None, n=0, p=0, sort=None,
figsize=(20, 12), fontsize=16, labels=True,
cmap='RdBu', vmin=-1, vmax=1, cbar=True
):
"""
Presents a `seaborn` heatmap visualization of nullity correlation in the given DataFrame.
Note that... |
0, module; 1, function_definition; 2, function_name:dendrogram; 3, parameters; 4, block; 5, identifier:df; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, expres... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 4, 27; 4, 28; 4, 29; 4, 30; 4, 31; 4, 32; 4, 33; 4, 34; 4, 35; 4, 36; 4, 37; 4, 38; 4, 39; 4, 40; 4, 41; 6, 42; 6, 43; 7, 44; 7, 45; 8, 46; 8, 47; ... | def dendrogram(df, method='average',
filter=None, n=0, p=0, sort=None,
orientation=None, figsize=None,
fontsize=16, inline=False
):
"""
Fits a `scipy` hierarchical clustering algorithm to the given DataFrame's variables and visualizes the results as
... |
0, module; 1, function_definition; 2, function_name:nullity_sort; 3, parameters; 4, block; 5, identifier:df; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, identifier:sort; 10, None; 11, comment:"""
Sorts a DataFrame according to its nullity, in either ascending or descending order.
:param ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 6, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 8, 15; 12, 16; 12, 17; 13, 18; 14, 19; 14, 20; 15, 21; 17, 22; 18, 23; 19, 24; 19, 25; 20, 26; 21, 27; 23, 28; 23, 29; 23, 30; 25, 31; 26, 32; 27, 33; 28, 34; 28, 35; 29, 36; 29, 37; 32, 38; 32, 39; 32, 40; 36, 41; 36, 42; 37, 43; ... | def nullity_sort(df, sort=None):
"""
Sorts a DataFrame according to its nullity, in either ascending or descending order.
:param df: The DataFrame object being sorted.
:param sort: The sorting method: either "ascending", "descending", or None (default).
:return: The nullity-sorted DataFrame.
""... |
0, module; 1, function_definition; 2, function_name:sortino_ratio; 3, parameters; 4, block; 5, identifier:returns; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, expression_statement... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 6, 23; 6, 24; 7, 25; 7, 26; 8, 27; 8, 28; 9, 29; 9, 30; 10, 31; 10, 32; 11, 33; 12, 34; 13, 35; 13, 36; 14, 37; 15, 38; 15, 39; 16, 40; 17, 41; 18, 42; 19, 43; 20, 44; 21, 45;... | def sortino_ratio(returns,
required_return=0,
period=DAILY,
annualization=None,
out=None,
_downside_risk=None):
"""
Determines the Sortino ratio of a strategy.
Parameters
----------
returns : pd.Series or np.n... |
0, module; 1, function_definition; 2, function_name:downside_risk; 3, parameters; 4, block; 5, identifier:returns; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, if_statement; 13, expression_statement; 14, if_statement; 15,... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 6, 23; 6, 24; 7, 25; 7, 26; 8, 27; 8, 28; 9, 29; 9, 30; 10, 31; 11, 32; 12, 33; 12, 34; 13, 35; 14, 36; 14, 37; 15, 38; 16, 39; 17, 40; 18, 41; 19, 42; 20, 43; 21, 44; 21, 45;... | def downside_risk(returns,
required_return=0,
period=DAILY,
annualization=None,
out=None):
"""
Determines the downside deviation below a threshold
Parameters
----------
returns : pd.Series or np.ndarray or pd.DataFrame
... |
0, module; 1, function_definition; 2, function_name:GetLoadingOrder; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""Returns a list of filenames sorted by loading order.
Only includes files that Loader's standardize... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 6, 10; 7, 11; 8, 12; 8, 13; 8, 14; 9, 15; 11, 16; 11, 17; 12, 18; 12, 19; 13, 20; 13, 21; 14, 22; 14, 23; 15, 24; 15, 25; 20, 26; 20, 27; 22, 28; 23, 29; 23, 30; 25, 31; 25, 32; 26, 33; 26, 34; 28, 35; 28, 36; 29, 37; 29, 38; 30, 39; 31, 40; 31, 41; 32, 42; 32, 43; ... | def GetLoadingOrder(self):
"""Returns a list of filenames sorted by loading order.
Only includes files that Loader's standardized loading knows how to load"""
result = {}
for filename, mapping in self._file_mapping.iteritems():
loading_order = mapping['loading_order']
if loading_order is not... |
0, module; 1, function_definition; 2, function_name:GetOrderKey; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, comment:"""Return a tuple that can be u... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 11, 19; 11, 20; 12, 21; 14, 22; 14, 23; 15, 24; 15, 25; 16, 26; 16, 27; 17, 28; 17, 29; 20, 30; 23, 31; 24, 32; 24, 33; 25, 34; 26, 35; 26, 36; 27, 37; 30, 38; 31, 39; 34, 40; 34, 41; 37, 42; 37, 43; 3... | def GetOrderKey(self):
"""Return a tuple that can be used to sort problems into a consistent order.
Returns:
A list of values.
"""
context_attributes = ['_type']
context_attributes.extend(ExceptionWithContext.CONTEXT_PARTS)
context_attributes.extend(self._GetExtraOrderAttributes())
t... |
0, module; 1, function_definition; 2, function_name:AddShapePointObjectUnsorted; 3, parameters; 4, block; 5, identifier:self; 6, identifier:shapepoint; 7, identifier:problems; 8, expression_statement; 9, if_statement; 10, if_statement; 11, if_statement; 12, if_statement; 13, expression_statement; 14, expression_stateme... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 8, 16; 9, 17; 9, 18; 9, 19; 9, 20; 10, 21; 10, 22; 11, 23; 11, 24; 12, 25; 12, 26; 13, 27; 14, 28; 15, 29; 17, 30; 18, 31; 19, 32; 19, 33; 20, 34; 21, 35; 21, 36; 22, 37; 23, 38; 23, 39; 24, 40; 24, 41; 25, 42; 25, 43; 26, 4... | def AddShapePointObjectUnsorted(self, shapepoint, problems):
"""Insert a point into a correct position by sequence. """
if (len(self.sequence) == 0 or
shapepoint.shape_pt_sequence >= self.sequence[-1]):
index = len(self.sequence)
elif shapepoint.shape_pt_sequence <= self.sequence[0]:
ind... |
0, module; 1, function_definition; 2, function_name:GetStopTimes; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, expression_statement; 8, comment:# In theory problems=None should be safe because data from database has been; 9, comment:# validated. See comment in _LoadStopTimes for why this isn't ... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 6, 17; 6, 18; 7, 19; 10, 20; 11, 21; 12, 22; 13, 23; 14, 24; 14, 25; 14, 26; 14, 27; 15, 28; 15, 29; 15, 30; 16, 31; 20, 32; 20, 33; 21, 34; 21, 35; 22, 36; 22, 37; 23, 38; 23, 39; 24, 40; 24, 41; 27, 42; 29, 43; 29, ... | def GetStopTimes(self, problems=None):
"""Return a sorted list of StopTime objects for this trip."""
# In theory problems=None should be safe because data from database has been
# validated. See comment in _LoadStopTimes for why this isn't always true.
cursor = self._schedule._connection.cursor()
cu... |
0, module; 1, function_definition; 2, function_name:GetFrequencyStartTimes; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, comment:# for each headway period of the trip; 9, for_statement; 10, return_statement; 11, comment:"""Return a list of start time for each headway... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 9, 13; 9, 14; 9, 15; 10, 16; 12, 17; 12, 18; 14, 19; 14, 20; 15, 21; 15, 22; 15, 23; 15, 24; 19, 25; 19, 26; 21, 27; 23, 28; 24, 29; 24, 30; 27, 31; 27, 32; 28, 33; 28, 34; 29, 35; 29, 36; 30, 37; 30, 38; 30, 39; 31, 40; 31, 41; 31, 42; 32, 43; ... | def GetFrequencyStartTimes(self):
"""Return a list of start time for each headway-based run.
Returns:
a sorted list of seconds since midnight, the start time of each run. If
this trip doesn't have headways returns an empty list."""
start_times = []
# for each headway period of the trip
... |
0, module; 1, function_definition; 2, function_name:create; 3, parameters; 4, block; 5, identifier:filename; 6, identifier:spec; 7, expression_statement; 8, import_from_statement; 9, if_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, if_statement; 1... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 7, 25; 8, 26; 8, 27; 9, 28; 9, 29; 9, 30; 10, 31; 11, 32; 12, 33; 13, 34; 14, 35; 14, 36; 15, 37; 15, 38; 16, 39; 17, 40; 18, 41; 19, 42; 20, 43; 20, 44; 21, 45;... | def create(filename, spec):
"""Create a new segy file.
Create a new segy file with the geometry and properties given by `spec`.
This enables creating SEGY files from your data. The created file supports
all segyio modes, but has an emphasis on writing. The spec must be
complete, otherwise an except... |
0, module; 1, function_definition; 2, function_name:rotation; 3, parameters; 4, block; 5, identifier:f; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, r... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 6, 16; 6, 17; 7, 18; 8, 19; 8, 20; 9, 21; 10, 22; 10, 23; 11, 24; 12, 25; 13, 26; 14, 27; 15, 28; 17, 29; 19, 30; 19, 31; 20, 32; 21, 33; 21, 34; 22, 35; 22, 36; 23, 37; 23, 38; 23, 39; 24, 40; 24, 41; 25, 42; 25, 43; 26, 44... | def rotation(f, line = 'fast'):
""" Find rotation of the survey
Find the clock-wise rotation and origin of `line` as ``(rot, cdpx, cdpy)``
The clock-wise rotation is defined as the angle in radians between line
given by the first and last trace of the first line and the axis that gives
increasing ... |
0, module; 1, function_definition; 2, function_name:from_array3D; 3, parameters; 4, block; 5, identifier:filename; 6, identifier:data; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, expression_statement; 14, expression_statem... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 9, 22; 10, 23; 10, 24; 11, 25; 11, 26; 12, 27; 13, 28; 14, 29; 15, 30; 15, 31; 16, 32; 22, 33; 22, 34; 28, 35; 28, 36; 29, 37; 29, 38; 30, 39; 30, 40; 31, 41; 31, 42; 32, 43; 32, 44;... | def from_array3D(filename, data, iline=189,
xline=193,
format=SegySampleFormat.IBM_FLOAT_4_BYTE,
dt=4000,
delrt=0):
""" Create a new SEGY file from a 3D array
Create an structured ... |
0, module; 1, function_definition; 2, function_name:open; 3, parameters; 4, block; 5, identifier:filename; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, if_statement; 14, expression_statement; 15, if_st... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 6, 24; 6, 25; 7, 26; 7, 27; 8, 28; 8, 29; 9, 30; 9, 31; 10, 32; 10, 33; 11, 34; 11, 35; 12, 36; 13, 37; 13, 38; 14, 39; 15, 40; 15, 41; 16, 42; 16, 43; 17, 44; 18, 45; ... | def open(filename, mode="r", iline = 189,
xline = 193,
strict = True,
ignore_geometry = False,
endian = 'big'):
"""Open a segy file.
Opens a segy file and tries to figure out its sorting, inline ... |
0, module; 1, function_definition; 2, function_name:calc_min_interval; 3, parameters; 4, block; 5, identifier:x; 6, identifier:alpha; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, if_statement; 14, expression_... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 7, 18; 8, 19; 9, 20; 10, 21; 11, 22; 12, 23; 13, 24; 13, 25; 14, 26; 15, 27; 16, 28; 17, 29; 19, 30; 19, 31; 20, 32; 20, 33; 21, 34; 21, 35; 22, 36; 22, 37; 23, 38; 23, 39; 24, 40; 24, 41; 25, 42; 25, 43; 26, 4... | def calc_min_interval(x, alpha):
"""Internal method to determine the minimum interval of
a given width
Assumes that x is sorted numpy array.
"""
n = len(x)
cred_mass = 1.0 - alpha
interval_idx_inc = int(np.floor(cred_mass * n))
n_intervals = n - interval_idx_inc
interval_width = x... |
0, module; 1, function_definition; 2, function_name:_compute_gas_price; 3, parameters; 4, block; 5, identifier:probabilities; 6, identifier:desired_probability; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, for_statement; 12, comment:"""
Given a sorted range of ``P... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 8, 13; 9, 14; 10, 15; 10, 16; 10, 17; 11, 18; 11, 19; 11, 20; 11, 21; 13, 22; 13, 23; 14, 24; 14, 25; 15, 26; 15, 27; 16, 28; 17, 29; 17, 30; 18, 31; 18, 32; 19, 33; 19, 34; 20, 35; 20, 36; 20, 37; 20, 38; 20, 39; 20, 40; 20, 41; 21, 42; 21, 43;... | def _compute_gas_price(probabilities, desired_probability):
"""
Given a sorted range of ``Probability`` named-tuples returns a gas price
computed based on where the ``desired_probability`` would fall within the
range.
:param probabilities: An iterable of `Probability` named-tuples sorted in reverse... |
0, module; 1, function_definition; 2, function_name:generate_X_grid; 3, parameters; 4, block; 5, identifier:self; 6, identifier:term; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, comment:# cant do Intercept; 12, if_statement; 13, comment:# process each subterm in a TensorTe... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 10, 20; 10, 21; 12, 22; 12, 23; 14, 24; 14, 25; 14, 26; 14, 27; 14, 28; 14, 29; 20, 30; 21, 31; 22, 32; 22, 33; 23, 34; 24, 35; 24, 36; 25, 37; 25, 38; 25, 39; 25, 40; 27, 41; 27, 42; 29, 43; 30, ... | def generate_X_grid(self, term, n=100, meshgrid=False):
"""create a nice grid of X data
array is sorted by feature and uniformly spaced,
so the marginal and joint distributions are likely wrong
if term is >= 0, we generate n samples per feature,
which results in n^deg samples,
... |
0, module; 1, function_definition; 2, function_name:build_from_info; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:info; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, comment:"""build a TensorTerm instance from a dict
Parameters
----------
... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 9, 13; 9, 14; 9, 15; 10, 16; 12, 17; 12, 18; 14, 19; 14, 20; 15, 21; 16, 22; 16, 23; 20, 24; 21, 25; 23, 26; 25, 27; 25, 28; 26, 29; 27, 30; 27, 31; 28, 32; 32, 33; 32, 34; 33, 35; 33, 36; 34, 37 | def build_from_info(cls, info):
"""build a TensorTerm instance from a dict
Parameters
----------
cls : class
info : dict
contains all information needed to build the term
Return
------
TensorTerm instance
"""
terms = []
... |
0, module; 1, function_definition; 2, function_name:sort_kate_imports; 3, parameters; 4, block; 5, default_parameter; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 1... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 5, 17; 5, 18; 6, 19; 6, 20; 7, 21; 8, 22; 9, 23; 10, 24; 11, 25; 12, 26; 13, 27; 14, 28; 15, 29; 15, 30; 16, 31; 22, 32; 22, 33; 23, 34; 23, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 27, 42; 27, 43; 28, 44; ... | def sort_kate_imports(add_imports=(), remove_imports=()):
"""Sorts imports within Kate while maintaining cursor position and selection, even if length of file changes."""
document = kate.activeDocument()
view = document.activeView()
position = view.cursorPosition()
selection = view.selectionRange()
... |
0, module; 1, function_definition; 2, function_name:_get_line; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, identifier:str; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, return_statement; 12, comment:"""Returns the current line from the file while incrementing the index."""... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 4, 7; 5, 8; 5, 9; 5, 10; 5, 11; 8, 12; 9, 13; 10, 14; 11, 15; 13, 16; 13, 17; 14, 18; 14, 19; 17, 20; 17, 21; 18, 22; 18, 23; 20, 24; 20, 25; 21, 26; 21, 27 | def _get_line(self) -> str:
"""Returns the current line from the file while incrementing the index."""
line = self.in_lines[self.index]
self.index += 1
return line |
0, module; 1, function_definition; 2, function_name:_add_comments; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, typed_parameter; 8, typed_default_parameter; 9, identifier:str; 10, expression_statement; 11, if_statement; 12, if_statement; 13, identifier:comments; 14, type; 15, identifier:original_string; 16,... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 4, 9; 5, 10; 5, 11; 5, 12; 7, 13; 7, 14; 8, 15; 8, 16; 8, 17; 10, 18; 11, 19; 11, 20; 12, 21; 12, 22; 12, 23; 14, 24; 16, 25; 19, 26; 19, 27; 20, 28; 21, 29; 22, 30; 23, 31; 24, 32; 24, 33; 26, 34; 26, 35; 27, 36; 28, 37; 30, 38; 31, 39; 33, 40; 37, 41; 37, 42; 39, 43; 40... | def _add_comments(
self,
comments: Optional[Sequence[str]],
original_string: str = ""
) -> str:
"""
Returns a string with comments added if ignore_comments is not set.
"""
if self.config['ignore_comments']:
return self._strip_comments(original_... |
0, module; 1, function_definition; 2, function_name:_wrap; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, typed_parameter; 8, identifier:str; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, return_statement; 13, identifier:line; 14, type; 15, comment:"""
Returns an import ... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 4, 8; 5, 9; 5, 10; 5, 11; 5, 12; 7, 13; 7, 14; 9, 15; 10, 16; 11, 17; 11, 18; 11, 19; 12, 20; 14, 21; 16, 22; 16, 23; 17, 24; 17, 25; 18, 26; 18, 27; 18, 28; 18, 29; 19, 30; 19, 31; 23, 32; 23, 33; 24, 34; 24, 35; 25, 36; 25, 37; 26, 38; 27, 39; 28, 40; 28, 41; 29, 42; 29, 43; ... | def _wrap(self, line: str) -> str:
"""
Returns an import wrapped to the specified line-length, if possible.
"""
wrap_mode = self.config['multi_line_output']
if len(line) > self.config['line_length'] and wrap_mode != WrapModes.NOQA:
line_without_comment = line
... |
0, module; 1, function_definition; 2, function_name:get_formatter; 3, parameters; 4, block; 5, identifier:name; 6, expression_statement; 7, for_statement; 8, comment:"""
Looks up a formatter class given a prefix to it.
The names are sorted, and the first matching class is returned.
"""; 9, identifier:k; 10,... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 7, 10; 7, 11; 10, 12; 10, 13; 11, 14; 13, 15; 14, 16; 14, 17; 16, 18; 16, 19; 17, 20; 18, 21; 18, 22; 19, 23; 20, 24; 24, 25; 24, 26 | def get_formatter(name):
"""
Looks up a formatter class given a prefix to it.
The names are sorted, and the first matching class is returned.
"""
for k in sorted(_FORMATTERS):
if k.startswith(name):
return _FORMATTERS[k] |
0, module; 1, function_definition; 2, function_name:call_once; 3, parameters; 4, block; 5, identifier:func; 6, expression_statement; 7, expression_statement; 8, if_statement; 9, decorated_definition; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, comment:"""Decor... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 6, 14; 7, 15; 8, 16; 8, 17; 9, 18; 9, 19; 10, 20; 11, 21; 12, 22; 13, 23; 15, 24; 15, 25; 16, 26; 16, 27; 17, 28; 18, 29; 19, 30; 19, 31; 19, 32; 19, 33; 20, 34; 20, 35; 21, 36; 21, 37; 22, 38; 22, 39; 25, 40; 25, 41; 26, 42; 26, 43; 27, ... | def call_once(func):
"""Decorate a function to only allow it to be called once.
Note that it doesn't make sense to only call a function once if it takes
arguments (use @functools.lru_cache for that sort of thing), so this only
works on callables that take no args.
"""
argspec = inspect.getargspec(func)
i... |
0, module; 1, function_definition; 2, function_name:paginate; 3, parameters; 4, block; 5, identifier:self; 6, identifier:model_class; 7, identifier:order_by; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, expression_statement; 14, expression_state... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 8, 23; 8, 24; 9, 25; 9, 26; 10, 27; 10, 28; 11, 29; 11, 30; 12, 31; 13, 32; 14, 33; 15, 34; 15, 35; 15, 36; 16, 37; 17, 38; 18, 39; 18, 40; 19, 41; 20, 42; 21, 43; 22, 44; 31,... | def paginate(self, model_class, order_by, page_num=1, page_size=100, conditions=None, settings=None):
'''
Selects records and returns a single page of model instances.
- `model_class`: the model class matching the query's table,
or `None` for getting back instances of an ad-hoc model.... |
0, module; 1, function_definition; 2, function_name:compute_memory_contents_under_schedule; 3, parameters; 4, block; 5, identifier:self; 6, identifier:schedule; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, comment:"""Th... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 8, 14; 9, 15; 10, 16; 11, 17; 11, 18; 11, 19; 12, 20; 14, 21; 14, 22; 15, 23; 15, 24; 16, 25; 16, 26; 19, 27; 19, 28; 19, 29; 19, 30; 19, 31; 19, 32; 19, 33; 22, 34; 22, 35; 24, 36; 24, 37; 27, 38; 29, 39; 29, 40; 29, 41; 30, 42; 32, 43; ... | def compute_memory_contents_under_schedule(self, schedule):
"""The in-memory tensors present when executing each operation in schedule.
Simulates running operations in the order given by a schedule. Keeps track
of the tensors in memory at every point in time, and outputs a list (one
entry for each poin... |
0, module; 1, function_definition; 2, function_name:sort; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, typed_parameter; 8, typed_default_parameter; 9, dictionary_splat_pattern; 10, string; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, if_statement; 15, if_statement; 16, e... | 0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 5, 11; 5, 12; 5, 13; 5, 14; 5, 15; 5, 16; 5, 17; 5, 18; 5, 19; 5, 20; 5, 21; 5, 22; 5, 23; 5, 24; 7, 25; 7, 26; 8, 27; 8, 28; 8, 29; 9, 30; 10, 31; 11, 32; 12, 33; 13, 34; 14, 35; 14, 36; 15, 37; 15, 38; 16, 39; 17, 40; 18, 41; 19, 42; 20, 43; 20, 44; 21, 45;... | def sort(self, by: str, out: object = '', **kwargs) -> 'SASdata':
"""
Sort the SAS Data Set
:param by: REQUIRED variable to sort by (BY <DESCENDING> variable-1 <<DESCENDING> variable-2 ...>;)
:param out: OPTIONAL takes either a string 'libref.table' or 'table' which will go to WORK or U... |
0, module; 1, function_definition; 2, function_name:find_items; 3, parameters; 4, block; 5, identifier:self; 6, identifier:q; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, expressio... | 0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 3, 13; 3, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 7, 26; 7, 27; 8, 28; 8, 29; 9, 30; 9, 31; 10, 32; 10, 33; 11, 34; 11, 35; 12, 36; 12, 37; 13, 38; 13, 39; 14, 40; 14, 41; 15, 42; 16, 43; 16, 44; 17, 45; ... | def find_items(self, q, shape=ID_ONLY, depth=SHALLOW, additional_fields=None, order_fields=None,
calendar_view=None, page_size=None, max_items=None, offset=0):
"""
Private method to call the FindItem service
:param q: a Q instance containing any restrictions
:param sh... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.