sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_cyclic_graph_best_effort; 3, parameters; 3, 4; 3, 5; 4, identifier:graph; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pick_first; 7, string:'head'; 8, block; 8, 9; 8, 11; 8, 15; 8, 21; 8, 22; 8, 23; 8, 24; 8, 47; 8, 51; 8, 89; 8, 93; 8...
def sort_cyclic_graph_best_effort(graph, pick_first='head'): """Fallback for cases in which the graph has cycles.""" ordered = [] visited = set() # Go first on the pick_first chain then go back again on the others # that were not visited. Given the way the graph is built both chains # will alway...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:circlescan; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:x0; 5, identifier:y0; 6, identifier:r1; 7, identifier:r2; 8, block; 8, 9; 8, 11; 8, 12; 8, 22; 8, 32; 8, 33; 8, 37; 8, 38; 8, 48; 9, expression_statement; 9, 10; 10, comment; 11, ...
def circlescan(x0, y0, r1, r2): """Scan pixels in a circle pattern around a center point :param x0: Center x-coordinate :type x0: float :param y0: Center y-coordinate :type y0: float :param r1: Initial radius :type r1: float :param r2: Final radius :type r2: float :returns: Coor...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:ringscan; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:x0; 5, identifier:y0; 6, identifier:r1; 7, identifier:r2; 8, default_parameter; 8, 9; 8, 10; 9, identifier:metric; 10, identifier:chebyshev; 11, block; 11, 12; 11, 14; 11, 15...
def ringscan(x0, y0, r1, r2, metric=chebyshev): """Scan pixels in a ring pattern around a center point clockwise :param x0: Center x-coordinate :type x0: int :param y0: Center y-coordinate :type y0: int :param r1: Initial radius :type r1: int :param r2: Final radius :type r2: int ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:fetch; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:callback; 6, block; 6, 7; 6, 9; 6, 10; 6, 25; 6, 26; 6, 36; 6, 37; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, ...
def fetch(self, callback): """ Perform a full synchronization flow. .. code-block:: python :linenos: >>> client = basecrm.Client(access_token='<YOUR_PERSONAL_ACCESS_TOKEN>') >>> sync = basecrm.Sync(client=client, device_uuid='<YOUR_DEVICES_UUID>') ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:define_residues_for_plotting_traj; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:analysis_cutoff; 6, block; 6, 7; 6, 9; 6, 15; 6, 16; 6, 58; 6, 89; 6, 131; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10...
def define_residues_for_plotting_traj(self, analysis_cutoff): """ Since plotting all residues that have made contact with the ligand over a lenghty simulation is not always feasible or desirable. Therefore, only the residues that have been in contact with ligand for a long amount of time...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_donors_and_acceptors_in_ligand; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 24; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:atom_names; 11, lis...
def find_donors_and_acceptors_in_ligand(self): """ Since MDAnalysis a pre-set list for acceptor and donor atoms for proteins and solvents from specific forcefields, it is necessary to find donor and acceptor atoms for the ligand molecule. This function uses RDKit and searches through lig...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:determine_hbonds_for_drawing; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:analysis_cutoff; 6, block; 6, 7; 6, 9; 6, 18; 6, 88; 6, 89; 6, 126; 6, 127; 6, 133; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9...
def determine_hbonds_for_drawing(self, analysis_cutoff): """ Since plotting all hydrogen bonds could lead to a messy plot, a cutoff has to be imple- mented. In this function the frequency of each hydrogen bond is summated and the total compared against analysis cutoff - a fraction multip...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:distance_function_match; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:l1; 5, identifier:l2; 6, identifier:thresh; 7, identifier:dist_fn; 8, default_parameter; 8, 9; 8, 10; 9, identifier:norm_funcs; 10, list:[]; 11, block; 11, 12;...
def distance_function_match(l1, l2, thresh, dist_fn, norm_funcs=[]): """Returns pairs of matching indices from l1 and l2.""" common = [] # We will keep track of the global index in the source list as we # will successively reduce their sizes. l1 = list(enumerate(l1)) l2 = list(enumerate(l2)) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_match_by_norm_func; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:l1; 5, identifier:l2; 6, identifier:norm_fn; 7, identifier:dist_fn; 8, identifier:thresh; 9, block; 9, 10; 9, 12; 9, 16; 9, 29; 9, 42; 9, 61; 9, 80; 9, 222; 9, 232;...
def _match_by_norm_func(l1, l2, norm_fn, dist_fn, thresh): """Matches elements in l1 and l2 using normalization functions. Splits the elements in each list into buckets given by the normalization function. If the same normalization value points to a bucket from the first list and a bucket from the seco...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:dump; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:props; 5, identifier:fp; 6, default_parameter; 6, 7; 6, 8; 7, identifier:separator; 8, string:'='; 9, default_parameter; 9, 10; 9, 11; 10, identifier:comments; 11, None; ...
def dump(props, fp, separator='=', comments=None, timestamp=True, sort_keys=False): """ Write a series of key-value pairs to a file in simple line-oriented ``.properties`` format. :param props: A mapping or iterable of ``(key, value)`` pairs to write to ``fp``. All keys and values in ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:dumps; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:props; 5, default_parameter; 5, 6; 5, 7; 6, identifier:separator; 7, string:'='; 8, default_parameter; 8, 9; 8, 10; 9, identifier:comments; 10, None; 11, default_parameter; 11...
def dumps(props, separator='=', comments=None, timestamp=True, sort_keys=False): """ Convert a series of key-value pairs to a text string in simple line-oriented ``.properties`` format. :param props: A mapping or iterable of ``(key, value)`` pairs to serialize. All keys and values in ``props`` ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:variants; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:case_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:skip; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:count; 11, integer:1000; ...
def variants(self, case_id, skip=0, count=1000, filters=None): """Return count variants for a case. This function needs to have different behaviours based on what is asked for. It should allways try to give minimal information back to improve on speed. For example, if consequences are n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:_format_variant; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:self; 5, identifier:case_id; 6, identifier:gemini_variant; 7, identifier:individual_objs; 8, default_parameter; 8, 9; 8, 10; 9, identifier:index; 10, integer:0;...
def _format_variant(self, case_id, gemini_variant, individual_objs, index=0, add_all_info=False): """Make a puzzle variant from a gemini variant Args: case_id (str): related case id gemini_variant (GeminiQueryRow): The gemini variant ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:arg; 3, parameters; 3, 4; 3, 6; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 201; 9, expression_statement; 9, 10; 10, comment; 11, function_definition; 11, 1...
def arg(*args, **kwargs): """ Dcorates a function or a class method to add to the argument parser """ def decorate(func): """ Decorate """ # we'll set the command name with the passed cmd_name argument, if # exist, else the command name will be the function name ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:class_args; 3, parameters; 3, 4; 4, identifier:cls; 5, block; 5, 6; 5, 8; 5, 9; 5, 18; 5, 19; 5, 27; 5, 28; 5, 34; 5, 38; 5, 39; 5, 50; 5, 51; 5, 102; 5, 167; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10...
def class_args(cls): """ Decorates a class to handle the arguments parser. """ # get the Singleton ap_ = ArgParseInator(skip_init=True) # collect special vars (really need?) utils.collect_appendvars(ap_, cls) # set class reference cls.__cls__ = cls cmds = {} # get eventual cl...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_args; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 15; 5, 16; 5, 22; 5, 40; 5, 41; 5, 63; 5, 107; 5, 108; 5, 120; 5, 121; 5, 243; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9...
def parse_args(self): """ Parse our arguments. """ # compile the parser self._compile() # clear the args self.args = None self._self_event('before_parse', 'parse', *sys.argv[1:], **{}) # list commands/subcommands in argv cmds = [cmd for cmd...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:check_command; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:new_attributes; 7, block; 7, 8; 7, 10; 7, 11; 7, 23; 7, 78; 7, 109; 7, 110; 7, 118; 7, 119; 7, 133; 7, 134; 8, expression_statement; ...
def check_command(self, **new_attributes): """ Check if 'was passed a valid action in the command line and if so, executes it by passing parameters and returning the result. :return: (Any) Return the result of the called function, if provided, or None. """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:merge; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 27; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifi...
def merge(self): """Populates result members. Performs the merge algorithm using the specified config and fills in the members that provide stats about the merging procedure. Attributes: merged_root: The result of the merge. aligned_root, aligned_head, aligned_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_zadd; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:key; 6, identifier:pk; 7, default_parameter; 7, 8; 7, 9; 8, identifier:ts; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:ttl; 12, None; 13,...
def _zadd(self, key, pk, ts=None, ttl=None): """Redis lua func to add an event to the corresponding sorted set. :param key: the key to be stored in redis server :param pk: the primary key of event :param ts: timestamp of the event, default to redis_server's current timestamp ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:add; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:event; 6, identifier:pk; 7, default_parameter; 7, 8; 7, 9; 8, identifier:ts; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:ttl; 12, None; 13,...
def add(self, event, pk, ts=None, ttl=None): """Add an event to event store. All events were stored in a sorted set in redis with timestamp as rank score. :param event: the event to be added, format should be ``table_action`` :param pk: the primary key of event :param ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:add_parameter; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 10; 7, 27; 7, 38; 7, 48; 7, 57; 7, 79; 7, 87; 7, 113; 7, 126; 7, 136; 7, 152; 7, 179; 7, 216; 7, 224; 7, 2...
def add_parameter(self, **kwargs): '''Add the parameter to ``Parameters``. **Arguments** The arguments are lumped into two groups:``Parameters.add_parameter`` and ``argparse.ArgumentParser.add_argument``. Parameters that are only used by ``Parameters.add_parameter`` are remove...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:mysql_pub; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:mysql_dsn; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tables; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:blocking; 10, False; 11, dictionary_splat_pattern; 11...
def mysql_pub(mysql_dsn, tables=None, blocking=False, **kwargs): """MySQL row-based binlog events pub. **General Usage** Listen and pub all tables events:: mysql_pub(mysql_dsn) Listen and pub only some tables events:: mysql_pub(mysql_dsn, tables=["test"]) By default the ``mysql...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:do_step; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:values; 6, identifier:xy_values; 7, identifier:coeff; 8, identifier:width; 9, block; 9, 10; 9, 12; 9, 27; 9, 206; 9, 225; 9, 243; 10, expression_statement; ...
def do_step(self, values, xy_values,coeff, width): """Calculates forces between two diagrams and pushes them apart by tenth of width""" forces = {k:[] for k,i in enumerate(xy_values)} for (index1, value1), (index2,value2) in combinations(enumerate(xy_values),2): f = self.calc_2d_forc...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:execute_get; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:resource; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 21; 8, 33; 8, 39; 8, 45; 8, 114; 8, 154; 8, 166; 8, 193; 9, expression_...
def execute_get(self, resource, **kwargs): """ Execute an HTTP GET request against the API endpoints. This method is meant for internal use. :param resource: The last part of the URI :param kwargs: Additional query parameters (and optionally headers) :return: The HTTP re...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:variants; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:case_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:skip; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:count; 11, integer:1000; ...
def variants(self, case_id, skip=0, count=1000, filters=None): """Return all variants in the VCF. This function will apply the given filter and return the 'count' first variants. If skip the first 'skip' variants will not be regarded. Args: case_id (str): Path to a ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_get_filtered_variants; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:vcf_file_path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filters; 8, dictionary; 9, block; 9, 10; 9, 12; 9, 18; 9, 24; 9, 30; 9, 55; 9, 72; 9, 89; ...
def _get_filtered_variants(self, vcf_file_path, filters={}): """Check if variants follows the filters This function will try to make filters faster for the vcf adapter Args: vcf_file_path(str): Path to vcf filters (dict): A dictionary with filters ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:group; 3, parameters; 3, 4; 3, 5; 4, identifier:iterable; 5, identifier:key; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, for_statement; 9, 10; 9, 13; 9, 26; 10, pattern_list; 10, 11; 10, 12; 11, identifier:_; 12, identif...
def group(iterable, key): """ groupby which sorts the input, discards the key and returns the output as a sequence of lists. """ for _, grouped in groupby(sorted(iterable, key=key), key=key): yield list(grouped)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 15; 5, 33; 5, 44; 5, 50; 5, 56; 5, 65; 5, 81; 5, 101; 5, 124; 5, 244; 5, 304; 6, expression_statement; 6, 7; 7, string:'''Run the LaTeX compilation.'''; 8, comment; 9,...
def run(self): '''Run the LaTeX compilation.''' # store files self.old_dir = [] if self.opt.clean: self.old_dir = os.listdir('.') cite_counter, toc_file, gloss_files = self._read_latex_files() self.latex_run() self.read_glossaries() gloss_ch...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:embed_ising; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:source_linear; 5, identifier:source_quadratic; 6, identifier:embedding; 7, identifier:target_adjacency; 8, default_parameter; 8, 9; 8, 10; 9, identifier:chain_strength; 10...
def embed_ising(source_linear, source_quadratic, embedding, target_adjacency, chain_strength=1.0): """Embeds a logical Ising model onto another graph via an embedding. Args: source_linear (dict): The linear biases to be embedded. Should be a dict of the form {v: bias, ...} where v is a vari...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:fit_richness; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:atol; 7, float:1.e-3; 8, default_parameter; 8, 9; 8, 10; 9, identifier:maxiter; 10, integer:50; 11, block; 11, 12; 11, 14; 11, 1...
def fit_richness(self, atol=1.e-3, maxiter=50): """ Maximize the log-likelihood as a function of richness. ADW 2018-06-04: Does it make sense to set the richness to the mle? Parameters: ----------- atol : absolute tolerence for conversion maxiter : maximum numbe...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:make_request; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:url; 5, default_parameter; 5, 6; 5, 7; 6, identifier:method; 7, string:'GET'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:query; 10, None; 11,...
def make_request( url, method='GET', query=None, body=None, auth=None, timeout=10, client=None, macaroons=None): """Make a request with the provided data. @param url The url to make the request to. @param method The HTTP request method (defaulting to "GET"). @param query A dict of the q...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:time_stops; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 13; 9, not_operator; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifie...
def time_stops(self): """ Valid time steps for this service as a list of datetime objects. """ if not self.supports_time: return [] if self.service.calendar == 'standard': units = self.service.time_interval_units interval = self.service.time_interval ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:sort_strings; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:strings; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sort_order; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:reverse; 10, False; 11, default_parameter...
def sort_strings(strings, sort_order=None, reverse=False, case_sensitive=False, sort_order_first=True): """Sort a list of strings according to the provided sorted list of string prefixes TODO: - Provide an option to use `.startswith()` rather than a fixed prefix length (will be much slower) Argume...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:clean_field_dict; 3, parameters; 3, 4; 3, 5; 3, 10; 4, identifier:field_dict; 5, default_parameter; 5, 6; 5, 7; 6, identifier:cleaner; 7, attribute; 7, 8; 7, 9; 8, identifier:str; 9, identifier:strip; 10, default_parameter; 10, 11; 10, 12; 11,...
def clean_field_dict(field_dict, cleaner=str.strip, time_zone=None): r"""Normalize field values by stripping whitespace from strings, localizing datetimes to a timezone, etc >>> (sorted(clean_field_dict({'_state': object(), 'x': 1, 'y': "\t Wash Me! \n" }).items()) == ... [('x', 1), ('y', 'Wash Me!')]) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:hist_from_counts; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:counts; 5, default_parameter; 5, 6; 5, 7; 6, identifier:normalize; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:cumulative; 10, False; 1...
def hist_from_counts(counts, normalize=False, cumulative=False, to_str=False, sep=',', min_bin=None, max_bin=None): """Compute an emprical histogram, PMF or CDF in a list of lists TESTME: compare results to hist_from_values_list and hist_from_float_values_list """ counters = [dict((i, c)for i, c in enu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 38; 2, function_name:normalize_serial_number; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 16; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 4, identifier:sn; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_length; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:...
def normalize_serial_number(sn, max_length=None, left_fill='0', right_fill=str(), blank=str(), valid_chars=' -0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', invalid_chars=None, strip_whitesp...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:listify; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:values; 5, default_parameter; 5, 6; 5, 7; 6, identifier:N; 7, integer:1; 8, default_parameter; 8, 9; 8, 10; 9, identifier:delim; 10, None; 11, block; 11, 12; 11, 14; 11, 23; 11, 24; 11, 9...
def listify(values, N=1, delim=None): """Return an N-length list, with elements values, extrapolating as necessary. >>> listify("don't split into characters") ["don't split into characters"] >>> listify("len = 3", 3) ['len = 3', 'len = 3', 'len = 3'] >>> listify("But split on a delimeter, if re...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:best_fit; 3, parameters; 3, 4; 3, 5; 4, identifier:li; 5, identifier:value; 6, block; 6, 7; 6, 9; 6, 26; 6, 38; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:index; 12,...
def best_fit(li, value): """For a sorted list li, returns the closest item to value""" index = min(bisect_left(li, value), len(li) - 1) if index in (0, len(li)): return index if li[index] - value < value - li[index-1]: return index else: return index-1
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:proj4_to_epsg; 3, parameters; 3, 4; 4, identifier:projection; 5, block; 5, 6; 5, 8; 5, 34; 5, 35; 5, 46; 5, 59; 5, 60; 5, 81; 5, 93; 5, 167; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name...
def proj4_to_epsg(projection): """Attempts to convert a PROJ4 projection object to an EPSG code and returns None if conversion fails""" def make_definition(value): return {x.strip().lower() for x in value.split('+') if x} # Use the EPSG in the definition if available match = EPSG_RE.search(pro...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:index_pix_in_pixels; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:pix; 5, identifier:pixels; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:outside; 11, unary_operator...
def index_pix_in_pixels(pix,pixels,sort=False,outside=-1): """ Find the indices of a set of pixels into another set of pixels. !!! ASSUMES SORTED PIXELS !!! Parameters: ----------- pix : set of search pixels pixels : set of reference pixels Returns: -------- index : index ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:files; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:entity_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:manifest; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:filename; 11, None; ...
def files(self, entity_id, manifest=None, filename=None, read_file=False, channel=None): ''' Get the files or file contents of a file for an entity. If all files are requested, a dictionary of filenames and urls for the files in the archive are returned. If filena...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 33; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:includes; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, ...
def search(self, text, includes=None, doc_type=None, limit=None, autocomplete=False, promulgated_only=False, tags=None, sort=None, owner=None, series=None): ''' Search for entities in the charmstore. @param text The text to search for. @param includes What ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:list; 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:includes; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:doc_type; 10, None; 11, default_paramete...
def list(self, includes=None, doc_type=None, promulgated_only=False, sort=None, owner=None, series=None): ''' List entities in the charmstore. @param includes What metadata to return in results (e.g. charm-config). @param doc_type Filter to this type: bundle or charm. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_common_query_parameters; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:doc_type; 6, identifier:includes; 7, identifier:owner; 8, identifier:promulgated_only; 9, identifier:series; 10, identifier:s...
def _common_query_parameters(self, doc_type, includes, owner, promulgated_only, series, sort): ''' Extract common query parameters between search and list into slice. @param includes What metadata to return in results (e.g. charm-config). @param doc_type...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:extract_one; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:L; 6, identifier:P; 7, identifier:R; 8, block; 8, 9; 8, 11; 8, 14; 8, 15; 8, 108; 8, 117; 8, 120; 8, 121; 8, 129; 8, 130; 8, 185; 8, 194; 8, 197; 8, 198; 9, e...
def extract_one(self, L, P, R): """ Given left context `L`, punctuation mark `P`, and right context R`, extract features. Probability distributions for any quantile-based features will not be modified. """ yield "*bias*" # L feature(s) if match(QUOTE, L): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:call; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:command; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 11; 8, 26; 8, 36; 8, 40; 8, 107; 8, 123; 8, 181; 8, 231; 9, expression_statement; 9, 1...
def call(self, command, **kwargs): """ Make a request to DynamoDB using the raw botocore API Parameters ---------- command : str The name of the Dynamo command to execute **kwargs : dict The parameters to pass up in the request Raises ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:delete_item2; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 4, identifier:self; 5, identifier:tablename; 6, identifier:key; 7, default_parameter; 7, 8; 7, 9; 8, identifier:expr_values; 9, None; 10, default_pa...
def delete_item2(self, tablename, key, expr_values=None, alias=None, condition=None, returns=NONE, return_capacity=None, return_item_collection_metrics=NONE, **kwargs): """ Delete an item from a table For many parameters you will want to reference the D...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:update_item; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, identifier:tablename; 6, identifier:key; 7, identifier:updates; 8, default_parameter; 8, 9; 8, 10; 9, identifier:returns; 10, identifier:NONE...
def update_item(self, tablename, key, updates, returns=NONE, return_capacity=None, expect_or=False, **kwargs): """ Update a single item in a table This uses the older version of the DynamoDB API. See also: :meth:`~.update_item2`. Parameters ---------...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 38; 2, function_name:query; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 3, 36; 4, identifier:self; 5, identifier:tablename; 6, default_parameter; 6, 7; 6, 8; 7, identifier:attributes; 8, None; 9, default_parameter...
def query(self, tablename, attributes=None, consistent=False, count=False, index=None, limit=None, desc=False, return_capacity=None, filter=None, filter_or=False, exclusive_start_key=None, **kwargs): """ Perform an index query on a table This uses the older version o...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:letter_scales; 3, parameters; 3, 4; 4, identifier:counts; 5, block; 5, 6; 5, 8; 5, 29; 5, 49; 5, 63; 6, expression_statement; 6, 7; 7, comment; 8, try_statement; 8, 9; 8, 23; 9, block; 9, 10; 10, expression_statement; 10, 11; 11, assignment; 11...
def letter_scales(counts): """Convert letter counts to frequencies, sorted increasing.""" try: scale = 1.0 / sum(counts.values()) except ZeroDivisionError: # This logo is all gaps, nothing can be done return [] freqs = [(aa, cnt*scale) for aa, cnt in counts.iteritems() if cnt] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:count_diffs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 12; 4, identifier:align; 5, identifier:feats; 6, identifier:inseq; 7, identifier:locus; 8, identifier:cutoff; 9, default_parameter; 9, 10; 9, 11; 10, identifier:verbose; 11, Fa...
def count_diffs(align, feats, inseq, locus, cutoff, verbose=False, verbosity=0): """ count_diffs - Counts the number of mismatches, gaps, and insertions and then determines if those are within an acceptable range. :param align: The alignment :type align: ``List`` :param feats: Dicto...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:cmd_debug; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:argv; 6, identifier:help; 7, block; 7, 8; 7, 10; 7, 28; 7, 34; 7, 56; 7, 73; 7, 90; 7, 107; 7, 124; 7, 147; 7, 156; 7, 165; 7, 173; 7, 183; 7, 317; 7, 347; 8, express...
def cmd_debug(self, argv, help): """Prints some debug info for this script""" parser = argparse.ArgumentParser( prog="%s debug" % self.progname, description=help, ) instances = self.instances parser.add_argument("instance", nargs=1, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:cmd_ssh; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:argv; 6, identifier:help; 7, block; 7, 8; 7, 10; 7, 28; 7, 39; 7, 61; 7, 76; 7, 83; 7, 87; 7, 91; 7, 148; 7, 149; 7, 194; 7, 200; 7, 216; 7, 274; 7, 280; 7, 292; 7, 298...
def cmd_ssh(self, argv, help): """Log into the instance with ssh using the automatically generated known hosts""" parser = argparse.ArgumentParser( prog="%s ssh" % self.progname, description=help, ) instances = self.get_instances(command='init_ssh_key') pa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 9; 2, function_name:add_alignment; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:ref_seq; 6, identifier:annotation; 7, type; 7, 8; 8, identifier:Annotation; 9, block; 9, 10; 9, 12; 9, 19; 9, 23; 9, 36; 9, 54; 9, 427; 9, 433; 10, expressi...
def add_alignment(self, ref_seq, annotation) -> Annotation: """ add_alignment - method for adding the alignment to an annotation :param ref_seq: List of reference sequences :type ref_seq: List :param annotation: The complete annotation :type annotation: Annotation ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:build_tree; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:data; 6, identifier:tagname; 7, default_parameter; 7, 8; 7, 9; 8, identifier:attrs; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:dept...
def build_tree(self, data, tagname, attrs=None, depth=0): r"""Build xml tree. :param data: data for build xml. :param tagname: element tag name. :param attrs: element attributes. Default:``None``. :type attrs: dict or None :param depth: element depth of the hierarchy. De...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_parse_remind; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:filename; 6, default_parameter; 6, 7; 6, 8; 7, identifier:lines; 8, string:''; 9, block; 9, 10; 9, 12; 9, 16; 9, 20; 9, 39; 9, 60; 9, 109; 9, 117; 9, 283; 9, 284;...
def _parse_remind(self, filename, lines=''): """Calls remind and parses the output into a dict filename -- the remind file (included files will be used as well) lines -- used as stdin to remind (filename will be set to -) """ files = {} reminders = {} if lines: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_parse_remind_line; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:line; 6, identifier:text; 7, block; 7, 8; 7, 10; 7, 14; 7, 24; 7, 42; 7, 134; 7, 156; 7, 176; 7, 205; 7, 221; 7, 232; 7, 239; 7, 259; 7, 278; 7, 297; 8, expr...
def _parse_remind_line(self, line, text): """Parse a line of remind output into a dict line -- the remind output text -- the original remind input """ event = {} line = line.split(None, 6) dat = [int(f) for f in line[0].split('/')] if line[4] != '*': ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_gen_vevent; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:event; 6, identifier:vevent; 7, block; 7, 8; 7, 10; 7, 25; 7, 43; 7, 56; 7, 69; 7, 87; 7, 114; 7, 132; 7, 150; 7, 283; 8, expression_statement; 8, 9; 9, comment; 10...
def _gen_vevent(self, event, vevent): """Generate vevent from given event""" vevent.add('dtstart').value = event['dtstart'][0] vevent.add('dtstamp').value = datetime.fromtimestamp(self._mtime) vevent.add('summary').value = event['msg'] vevent.add('uid').value = event['uid'] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:to_remind; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 4, identifier:self; 5, identifier:vevent; 6, default_parameter; 6, 7; 6, 8; 7, identifier:label; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:p...
def to_remind(self, vevent, label=None, priority=None, tags=None, tail=None, sep=" ", postdate=None, posttime=None): """Generate a Remind command from the given vevent""" remind = ['REM'] trigdates = None if hasattr(vevent, 'rrule'): trigdates = Remind._par...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:module_name_from_path; 3, parameters; 3, 4; 3, 5; 4, identifier:folder_name; 5, default_parameter; 5, 6; 5, 7; 6, identifier:verbose; 7, False; 8, block; 8, 9; 8, 11; 8, 12; 8, 23; 8, 34; 8, 45; 8, 51; 8, 58; 8, 59; 8, 63; 8, 73; 8, 74; 8, 75; ...
def module_name_from_path(folder_name, verbose=False): """ takes in a path to a folder or file and return the module path and the path to the module the module is idenitified by the path being in os.path, e.g. if /Users/Projects/Python/ is in os.path, then folder_name = '/Users/PycharmProje...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main; 3, parameters; 4, block; 4, 5; 4, 7; 4, 15; 4, 32; 4, 49; 4, 63; 4, 77; 4, 91; 4, 99; 4, 105; 4, 111; 4, 115; 4, 124; 4, 128; 4, 137; 4, 141; 4, 150; 4, 154; 4, 163; 4, 183; 4, 187; 4, 213; 4, 225; 4, 356; 5, expression_statement; 5, 6; 6...
def main(): """This is run if file is directly executed, but not if imported as module. Having this in a separate function allows importing the file into interactive python, and still able to execute the function for testing""" parser = argparse.ArgumentParser() parser.add_argument("-f", "--fil...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_push_subtree; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:leaves; 7, type; 7, 8; 8, generic_type; 8, 9; 8, 10; 9, identifier:List; 10, type_parameter; 10, 11; 11, type; 11, 12; 12, identifier:b...
def _push_subtree(self, leaves: List[bytes]): """Extend with a full subtree <= the current minimum subtree. The leaves must form a full subtree, i.e. of size 2^k for some k. If there is a minimum subtree (i.e. __mintree_height > 0), then the input subtree must be smaller or of equal siz...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:blocks; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:aln; 5, default_parameter; 5, 6; 5, 7; 6, identifier:threshold; 7, float:0.5; 8, default_parameter; 8, 9; 8, 10; 9, identifier:weights; 10, None; 11, block; 11, 12; 11, 14; 11, 19; 11, 110...
def blocks(aln, threshold=0.5, weights=None): """Remove gappy columns from an alignment.""" assert len(aln) if weights == False: def pct_nongaps(col): return 1 - (float(col.count('-')) / len(col)) else: if weights in (None, True): weights = sequence_weights(aln, '...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sequence_weights; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:aln; 5, default_parameter; 5, 6; 5, 7; 6, identifier:scaling; 7, string:'none'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:gap_chars; 10, string:'-.'; 11, block; 11, 12; 11...
def sequence_weights(aln, scaling='none', gap_chars='-.'): """Weight aligned sequences to emphasize more divergent members. Returns a list of floating-point numbers between 0 and 1, corresponding to the proportional weight of each sequence in the alignment. The first list is the weight of the first seq...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:load_and_append; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:instrument_dict; 5, default_parameter; 5, 6; 5, 7; 6, identifier:instruments; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:raise_errors; 10, False; 11, block; 11, 12;...
def load_and_append(instrument_dict, instruments=None, raise_errors=False): """ load instrument from instrument_dict and append to instruments Args: instrument_dict: dictionary of form instrument_dict = { name_of_instrument_1 : {"...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_scan_nodes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:nodelist; 5, identifier:context; 6, identifier:instance_types; 7, default_parameter; 7, 8; 7, 9; 8, identifier:current_block; 9, None; 10, default_parameter; 10, 11; 10, ...
def _scan_nodes(nodelist, context, instance_types, current_block=None, ignore_blocks=None): """ Loop through all nodes of a single scope level. :type nodelist: django.template.base.NodeList :type current_block: BlockNode :param instance_types: The instance to look for """ results = [] f...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:run_command; 3, parameters; 3, 4; 4, identifier:commands; 5, comment; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 15; 6, 19; 6, 23; 6, 191; 6, 196; 6, 235; 6, 245; 6, 251; 6, 259; 6, 278; 6, 290; 7, expression_statement; 7, 8; 8, comment; 9, c...
def run_command(commands): # type: (Union[AnyStr, List[AnyStr]]) -> List[AnyStr] """Execute external command, and return the output lines list. In windows, refers to `handling-subprocess-crash-in-windows`_. Args: commands: string or list Returns: output ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:intersect_keys; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:keys; 5, identifier:reffile; 6, default_parameter; 6, 7; 6, 8; 7, identifier:cache; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:clean_accs; 11, False; 12, bl...
def intersect_keys(keys, reffile, cache=False, clean_accs=False): """Extract SeqRecords from the index by matching keys. keys - an iterable of sequence identifiers/accessions to select reffile - name of a FASTA file to extract the specified sequences from cache - save an index of the reference FASTA se...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:family_check; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 25; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 16; 11, attribute; 11, 12; 11, 15; 12, attrib...
def family_check(self): """ Check if the family members break the structure of the family. eg. nonexistent parent, wrong sex on parent etc. Also extracts all trios found, this is of help for many at the moment since GATK can only do phasing of trios and duos....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:to_ped; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:outfile; 7, None; 8, block; 8, 9; 8, 11; 8, 21; 8, 29; 8, 66; 8, 85; 8, 114; 9, expression_statement; 9, 10; 10, comment; 11, expression_stat...
def to_ped(self, outfile=None): """ Print the individuals of the family in ped format The header will be the original ped header plus all headers found in extra info of the individuals """ ped_header = [ '#FamilyID', 'IndividualID...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:refresh_instruments; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 25; 5, 124; 5, 125; 5, 126; 5, 135; 5, 164; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 13; 9, function_name:list_acce...
def refresh_instruments(self): """ if self.tree_settings has been expanded, ask instruments for their actual values """ def list_access_nested_dict(dict, somelist): """ Allows one to use a list to access a nested dictionary, for example: listAccessNest...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:post; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:endpoint; 6, identifier:data; 7, default_parameter; 7, 8; 7, 9; 8, identifier:parallelism; 9, integer:5; 10, block; 10, 11; 10, 13; 10, 47; 10, 59; 10, 73; 10, 81; ...
def post(self, endpoint, data, parallelism=5): """ Executes most of the request. The parallelism parameter is useful to avoid swamping the API service with calls. Thus the entire set of requests won't be all made at once, but in chunked groups. :param endpoint: string indicatin...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_contents_static; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:block_alias; 6, identifier:context; 7, block; 7, 8; 7, 10; 7, 18; 7, 26; 7, 27; 7, 71; 7, 77; 7, 84; 7, 93; 7, 276; 7, 282; 7, 293; 7, 302; 7, 312; 7, 333; ...
def get_contents_static(self, block_alias, context): """Returns contents of a static block.""" if 'request' not in context: # No use in further actions as we won't ever know current URL. return '' current_url = context['request'].path # Resolve current view nam...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:files_to_pif; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:files; 5, default_parameter; 5, 6; 5, 7; 6, identifier:verbose; 7, integer:0; 8, default_parameter; 8, 9; 8, 10; 9, identifier:quality_report; 10, True; 11, default_parameter;...
def files_to_pif(files, verbose=0, quality_report=True, inline=True): '''Given a directory that contains output from a DFT calculation, parse the data and return a pif object Input: files - [str] list of files from which the parser is allowed to read. verbose - int, How much status mess...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 11; 2, function_name:_sort_cards; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:cards; 7, type; 7, 8; 8, identifier:Generator; 9, type; 9, 10; 10, identifier:list; 11, block; 11, 12; 11, 14; 12, expression_state...
def _sort_cards(self, cards: Generator) -> list: '''sort cards by blocknum and blockseq''' return sorted([card.__dict__ for card in cards], key=itemgetter('blocknum', 'blockseq', 'cardseq'))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_label; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, string:'''Find the label for the output files for this calculation '''; 8, if_statement; 8, 9; 8, 14; 8, 219; 8, 220;...
def _get_label(self): '''Find the label for the output files for this calculation ''' if self._label is None: foundfiles = False for f in self._files: if ".files" in f: foundfiles = True self._label = f.sp...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_estimate_progress; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 13; 5, 21; 5, 22; 5, 31; 5, 32; 5, 133; 5, 389; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; ...
def _estimate_progress(self): """ estimates the current progress that is then used in _receive_signal :return: current progress in percent """ estimate = True # ==== get the current subscript and the time it takes to execute it ===== current_subscript = self._cur...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_default_settings; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:sub_scripts; 5, identifier:script_order; 6, identifier:script_execution_freq; 7, identifier:iterator_type; 8, block; 8, 9; 8, 11; 8, 249; 8, 377; 9, expression_statement...
def get_default_settings(sub_scripts, script_order, script_execution_freq, iterator_type): """ assigning the actual script settings depending on the iterator type this might be overwritten by classes that inherit form ScriptIterator Args: sub_scripts: dictionary with the su...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:consensus; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:aln; 5, default_parameter; 5, 6; 5, 7; 6, identifier:weights; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:gap_threshold; 10, float:0.5; 11, default_parameter...
def consensus(aln, weights=None, gap_threshold=0.5, simple=False, trim_ends=True): """Get the consensus of an alignment, as a string. Emit gap characters for majority-gap columns; apply various strategies to choose the consensus amino acid type for the remaining columns. Parameters ---------- ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:make_simple_col_consensus; 3, parameters; 3, 4; 4, identifier:bg_freqs; 5, block; 5, 6; 5, 8; 5, 9; 5, 203; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, function_definition; 9, 10; 9, 11; 9, 19; 9, 20; 10, function_name:col_consens...
def make_simple_col_consensus(bg_freqs): """Consensus by simple plurality, unweighted. Resolves ties by two heuristics: 1. Prefer the aa that follows the preceding consensus aa type most often in the original sequences. 2. Finally, prefer the less-common aa type. """ # Hack: use default...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:supported; 3, parameters; 3, 4; 4, identifier:aln; 5, block; 5, 6; 5, 8; 5, 202; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 12; 9, function_name:col_consensus; 10, parameters; 10, 11; 11, identifier:colum...
def supported(aln): """Get only the supported consensus residues in each column. Meaning: - Omit majority-gap columns - Omit columns where no residue type appears more than once - In case of a tie, return all the top-scoring residue types (no prioritization) Returns a *list* -- not a str...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_aliases; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:aliases; 6, block; 6, 7; 6, 9; 6, 15; 6, 21; 6, 36; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 1...
def sort_aliases(self, aliases): """Sorts the given aliases list, returns a sorted list. :param list aliases: :return: sorted aliases list """ self._cache_init() if not aliases: return aliases parent_aliases = self._cache_get_entry(self.CACHE_NAME_PAR...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:load_and_append; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:probe_dict; 5, identifier:probes; 6, default_parameter; 6, 7; 6, 8; 7, identifier:instruments; 8, dictionary; 9, block; 9, 10; 9, 12; 9, 16; 9, 20; 9, 27; 9, 31; 9, 38; 9, 39; 9, 6...
def load_and_append(probe_dict, probes, instruments={}): """ load probes from probe_dict and append to probes, if additional instruments are required create them and add them to instruments Args: probe_dict: dictionary of form probe_dict = { inst...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:_get_line; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:search_string; 6, identifier:search_file; 7, default_parameter; 7, 8; 7, 9; 8, identifier:return_string; 9, True; 10, default_parameter; 10, 11; 10, 12;...
def _get_line(self, search_string, search_file, return_string=True, case_sens=True): '''Return the first line containing a set of strings in a file. If return_string is False, we just return whether such a line was found. If case_sens is False, the search is case insensitive. '...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:action_remove; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:request; 6, identifier:category_list; 7, block; 7, 8; 7, 10; 7, 27; 7, 42; 7, 53; 7, 64; 7, 75; 7, 85; 7, 97; 7, 121; 7, 129; 7, 188; 7, 201; 7, 209; 7, 252; 8, ex...
def action_remove(cls, request, category_list): """Handles `remove` action from CategoryList editor. Removes an actual category if a target object is not set for the list. Removes a tie-to-category object if a target object is set for the list. :param Request request: Django request ob...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:action_add; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:cls; 5, identifier:request; 6, identifier:category_list; 7, block; 7, 8; 7, 10; 7, 27; 7, 43; 7, 54; 7, 97; 7, 156; 7, 160; 7, 337; 8, expression_statement; 8, 9; 9, comment; 10, if_sta...
def action_add(cls, request, category_list): """Handles `add` action from CategoryList editor. Adds an actual category if a target object is not set for the list. Adds a tie-to-category object if a target object is set for the list. :param Request request: Django request object ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:verify; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 12; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:headers; 7, type; 7, 8; 8, identifier:Mapping; 9, default_parameter; 9, 10; 9, 11; 10, identifier:method; 11, None; 12, default_p...
async def verify(self, headers: Mapping, method=None, path=None): """ Parse Signature Authorization header and verify signature `headers` is a dict or multidict of headers `host` is a override for the 'host' header (defaults to value in headers). `method` is the HTTP...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:set_config; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:config; 7, block; 7, 8; 7, 10; 7, 14; 7, 43; 7, 74; 7, 105; 7, 121; 7, 152; 7, 183; 7, 216; 7, 247; 7, 263; 7, 279; 7, 310; 7, 334; 7, 3...
def set_config(self, **config): """Shadow all the current config.""" reinit = False if 'stdopt' in config: stdopt = config.pop('stdopt') reinit = (stdopt != self.stdopt) self.stdopt = stdopt if 'attachopt' in config: attachopt = config.pop(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:preview; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:stream; 7, attribute; 7, 8; 7, 9; 8, identifier:sys; 9, identifier:stdout; 10, block; 10, 11; 10, 13; 10, 19; 10, 35; 10, 40; 10, 51; 10, 5...
def preview(self, stream=sys.stdout): """A quick preview of docpie. Print all the parsed object""" write = stream.write write(('[Quick preview of Docpie %s]' % self._version).center(80, '=')) write('\n') write(' sections '.center(80, '-')) write('\n') write(se...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parts; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 12; 5, 18; 5, 22; 5, 23; 5, 24; 5, 28; 5, 29; 5, 30; 5, 34; 5, 45; 5, 49; 5, 120; 5, 192; 5, 220; 5, 255; 5, 256; 5, 265; 6, expression_statement; 6, 7; 7, comment; 8, exp...
def parts(self): """Return an array of batch parts to submit""" parts = [] upserts = dict() deletes = [] # we keep track of the batch size as we go (pretty close approximation!) so we can chunk it small enough # to limit the HTTP posts to under 700KB - server limits to...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:compare_versions; 3, parameters; 3, 4; 3, 5; 4, identifier:version_a; 5, identifier:version_b; 6, block; 6, 7; 6, 9; 6, 18; 6, 25; 6, 57; 6, 167; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 1...
def compare_versions(version_a, version_b): """Compare two RPM version strings Compares two RPM version strings and returns an integer indicating the result of the comparison. The method of comparison mirrors that used by RPM, so results should be the same for any standard RPM package. To perf...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_compare_blocks; 3, parameters; 3, 4; 3, 5; 4, identifier:block_a; 5, identifier:block_b; 6, block; 6, 7; 6, 9; 6, 18; 6, 64; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11...
def _compare_blocks(block_a, block_b): """Compare two blocks of characters Compares two blocks of characters of the form returned by either the :any:`_pop_digits` or :any:`_pop_letters` function. Blocks should be character lists containing only digits or only letters. Both blocks should contain the...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:Find; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:node_type; 6, identifier:item_type; 7, block; 7, 8; 7, 10; 7, 75; 8, expression_statement; 8, 9; 9, string:''' method for finding specific types of notation from n...
def Find(self, node_type, item_type): ''' method for finding specific types of notation from nodes. will currently return the first one it encounters because this method's only really intended for some types of notation for which the exact value doesn't really matter. :...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:SplitString; 3, parameters; 3, 4; 4, identifier:value; 5, block; 5, 6; 5, 8; 5, 15; 5, 24; 5, 31; 5, 35; 5, 85; 5, 248; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:string...
def SplitString(value): """simple method that puts in spaces every 10 characters""" string_length = len(value) chunks = int(string_length / 10) string_list = list(value) lstring = "" if chunks > 1: lstring = "\\markup { \n\r \column { " for i in range(int(chunks)): l...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:NumbersToWords; 3, parameters; 3, 4; 4, identifier:number; 5, block; 5, 6; 5, 8; 5, 21; 5, 34; 5, 38; 5, 188; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:units; 11, list:...
def NumbersToWords(number): """ little function that converts numbers to words. This could be more efficient, and won't work if the number is bigger than 999 but it's for stave names, and I doubt any part would have more than 10 staves let alone 999. """ units = [ 'one', 'two', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_generate_image; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:self; 5, identifier:matrix; 6, identifier:width; 7, identifier:height; 8, identifier:padding; 9, identifier:foreground; 10, identifier:background; ...
def _generate_image(self, matrix, width, height, padding, foreground, background, image_format): """ Generates an identicon image in requested image format out of the passed block matrix, with the requested width, height, padding, foreground colour, background colour, and image format. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:alignment_to_reads; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:sam_merged; 5, identifier:output_dir; 6, default_parameter; 6, 7; 6, 8; 7, identifier:parameters; 8, identifier:DEFAULT_PARAMETERS; 9, default_parameter; 9, 10; 9,...
def alignment_to_reads( sam_merged, output_dir, parameters=DEFAULT_PARAMETERS, save_memory=True, *bin_fasta ): """Generate reads from ambiguous alignment file Extract reads found to be mapping an input FASTA bin. If one read maps, the whole pair is extracted and written to the outpu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_validate_config; 3, parameters; 3, 4; 4, identifier:config; 5, block; 5, 6; 5, 8; 5, 21; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:isinstance; 12, ...
def _validate_config(config): """Validate that the provided configurtion is valid. Each dictionary in the configuration list must have the following mandatory entries : {label: {host(string), port(int), dbpath(string|list of strings)}} It can also contain 1 optional key: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:taskinfo; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 23; 5, 40; 5, 48; 5, 62; 5, 76; 5, 90; 5, 106; 5, 122; 5, 123; 5, 124; 5, 141; 5, 148; 5, 154; 5, 484; 6, expression_statement; 6, 7; 7, comment; 8, expression_statemen...
def taskinfo(self): """ Retrieve the Task Information """ task_input = {'taskName': 'QueryTask', 'inputParameters': {"Task_Name": self._name}} info = taskengine.execute(task_input, self._engine, cwd=self._cwd) task_def = info['outputParameters']['DEFINITI...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:distance_diagonal_law; 3, parameters; 3, 4; 3, 5; 4, identifier:matrix; 5, default_parameter; 5, 6; 5, 7; 6, identifier:positions; 7, None; 8, block; 8, 9; 8, 11; 8, 20; 8, 59; 8, 73; 8, 92; 8, 96; 8, 119; 8, 186; 8, 193; 9, expression_statemen...
def distance_diagonal_law(matrix, positions=None): """Compute a distance law trend using the contact averages of equal distances. Specific positions can be supplied if needed. """ n = min(matrix.shape) if positions is None: return np.array([np.average(np.diagonal(matrix, j)) for j in range(...