sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:merge; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:features; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ignore_strand; 8, False; 9, block; 9, 10; 9, 12; 9, 13; 9, 20; 9, 30; 9, 31; 9, 74; 9, 75; 9, 85; 9, 103; 9, 109...
def merge(self, features, ignore_strand=False): """ Merge overlapping features together. Parameters ---------- features : iterator of Feature instances ignore_strand : bool If True, features on multiple strands will be merged, and the final stra...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:bed12; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 10; 3, 14; 3, 17; 3, 20; 4, identifier:self; 5, identifier:feature; 6, default_parameter; 6, 7; 6, 8; 7, identifier:block_featuretype; 8, list:['exon']; 8, 9; 9, string:'exon'; 10, default_parameter; ...
def bed12(self, feature, block_featuretype=['exon'], thick_featuretype=['CDS'], thin_featuretype=None, name_field='ID', color=None): """ Converts `feature` into a BED12 format. GFF and GTF files do not necessarily define genes consistently, so this method pro...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:inspect; 3, parameters; 3, 4; 3, 5; 3, 12; 3, 15; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:look_for; 7, list:['featuretype', 'chrom', 'attribute_keys', 'feature_count']; 7, 8; 7, 9; 7, 10;...
def inspect(data, look_for=['featuretype', 'chrom', 'attribute_keys', 'feature_count'], limit=None, verbose=True): """ Inspect a GFF or GTF data source. This function is useful for figuring out the different featuretypes found in a file (for potential removal before creating...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:feature_from_line; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:line; 5, default_parameter; 5, 6; 5, 7; 6, identifier:dialect; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:strict; 10, True; 11, default_parameter; 11, 12; ...
def feature_from_line(line, dialect=None, strict=True, keep_order=False): """ Given a line from a GFF file, return a Feature object Parameters ---------- line : string strict : bool If True (default), assume `line` is a single, tab-delimited string that has at least 9 fields. ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_reconstruct; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:keyvals; 5, identifier:dialect; 6, default_parameter; 6, 7; 6, 8; 7, identifier:keep_order; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort_attribute_values; ...
def _reconstruct(keyvals, dialect, keep_order=False, sort_attribute_values=False): """ Reconstructs the original attributes string according to the dialect. Parameters ========== keyvals : dict Attributes from a GFF/GTF feature dialect : dict Dialect containing...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 78; 2, function_name:create_db; 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; 3, 39; 3, 42; 3, 45; 3, 50; 3, 53; 3, 58; 3, 61; 3, 64; 3, 67; 3, 70; 3, 73; 3, 76; 4, identifier:data; 5, identifier:dbfn; 6, def...
def create_db(data, dbfn, id_spec=None, force=False, verbose=False, checklines=10, merge_strategy='error', transform=None, gtf_transcript_key='transcript_id', gtf_gene_key='gene_id', gtf_subfeature='exon', force_gff=False, force_dialect_check=False, from_string=Fa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_id_handler; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:f; 6, block; 6, 7; 6, 9; 6, 10; 6, 103; 6, 104; 6, 206; 6, 207; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, if_statement; 10, 11; 10, 20; 10, 28; 10, 44; 1...
def _id_handler(self, f): """ Given a Feature from self.iterator, figure out what the ID should be. This uses `self.id_spec` identify the ID. """ # If id_spec is a string, convert to iterable for later if isinstance(self.id_spec, six.string_types): id_key = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:browser; 3, parameters; 3, 4; 3, 7; 3, 10; 4, default_parameter; 4, 5; 4, 6; 5, identifier:tags; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:proxy; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:other_caps; 12, Non...
def browser(tags=None, proxy=None, other_caps=None): """ Interpret environment variables to configure Selenium. Performs validation, logging, and sensible defaults. There are three cases: 1. Local browsers: If the proper environment variables are not all set for the second case, then we us...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_local_browser_class; 3, parameters; 3, 4; 4, identifier:browser_name; 5, block; 5, 6; 5, 8; 5, 9; 5, 17; 5, 18; 5, 27; 5, 45; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, ...
def _local_browser_class(browser_name): """ Returns class, kwargs, and args needed to instantiate the local browser. """ # Log name of local browser LOGGER.info(u"Using local browser: %s [Default is firefox]", browser_name) # Get class of local browser based on name browser_class = BROWSER...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:filter; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filter_fn; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:desc; 10, None; 11, dictionary_splat_pattern; 11, 12; 12, ...
def filter(self, filter_fn=None, desc=None, **kwargs): """ Return a copy of this query, with some values removed. Example usages: .. code:: python # Returns a query that matches even numbers q.filter(filter_fn=lambda x: x % 2) # Returns a query tha...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:order_by_on_list; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:objects; 5, identifier:order_field; 6, default_parameter; 6, 7; 6, 8; 7, identifier:is_desc; 8, False; 9, block; 9, 10; 9, 12; 9, 31; 9, 53; 10, expression_statement; 10, 11; 11, ...
def order_by_on_list(objects, order_field, is_desc=False): """ Utility function to sort objects django-style even for non-query set collections :param objects: list of objects to sort :param order_field: field name, follows django conventions, so "foo__bar" means `foo.bar`, can be a callable. :para...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 42; 2, function_name:render_table; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 4, identifier:request; 5, identifier:table; 6, default_parameter; 6, 7; 6, 8; 7, identifier:links; 8, None; 9, default_paramete...
def render_table(request, table, links=None, context=None, template='tri_table/list.html', blank_on_empty=False, paginate_by=40, # pragma: no mutate page=None, paginator=None, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 2, function_name:create_network; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 4, identifier:self; 5, identifier:net_view_name; 6, identifier:cidr; 7, default_parameter; 7, 8; 7, 9; 8, identifier:nameservers; 9, None; 10, default_parameter...
def create_network(self, net_view_name, cidr, nameservers=None, members=None, gateway_ip=None, dhcp_trel_ip=None, network_extattrs=None): """Create NIOS Network and prepare DHCP options. Some DHCP options are valid for IPv4 only, so just skip processing ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_run_pass; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 177; 6, expression_statement; 6, 7; 7, comment; 8, while_statement; 8, 9; 8, 10; 9, True; 10, block; 10, 11; 10, 45; 10, 54; 10, 104; 10, 114; 10, 146; 10, 156; 11, tr...
def _run_pass(self): """Read lines from a file and performs a callback against them""" while True: try: data = self._file.read(4096) except IOError, e: if e.errno == errno.ESTALE: self.active = False return F...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:update_files; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 31; 5, 44; 5, 48; 5, 52; 5, 173; 5, 238; 5, 239; 5, 255; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 29; 9, boolean_operator:and; 9, 10; 9,...
def update_files(self): """Ensures all files are properly loaded. Detects new files, file removals, file rotation, and truncation. On non-linux platforms, it will also manually reload the file for tailing. Note that this hack is necessary because EOF is cached on BSD systems. """...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:gctx_file_path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:convert_neg_666; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:rid; 10,...
def parse(gctx_file_path, convert_neg_666=True, rid=None, cid=None, ridx=None, cidx=None, row_meta_only=False, col_meta_only=False, make_multiindex=False): """ Primary method of script. Reads in path to a gctx file and parses into GCToo object. Input: Mandatory: - gctx_file_path (...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:multi_index_df_to_component_dfs; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:multi_index_df; 5, default_parameter; 5, 6; 5, 7; 6, identifier:rid; 7, string:"rid"; 8, default_parameter; 8, 9; 8, 10; 9, identifier:cid; 10, string:"cid"; 11, b...
def multi_index_df_to_component_dfs(multi_index_df, rid="rid", cid="cid"): """ Convert a multi-index df into 3 component dfs. """ # Id level of the multiindex will become the index rids = list(multi_index_df.index.get_level_values(rid)) cids = list(multi_index_df.columns.get_level_values(cid)) # I...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:file_path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:convert_neg_666; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:rid; 10, None...
def parse(file_path, convert_neg_666=True, rid=None, cid=None, ridx=None, cidx=None, row_meta_only=False, col_meta_only=False, make_multiindex=False): """ Identifies whether file_path corresponds to a .gct or .gctx file and calls the correct corresponding parse method. Input: Mandator...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:assemble_concatenated_meta; 3, parameters; 3, 4; 3, 5; 4, identifier:concated_meta_dfs; 5, identifier:remove_all_metadata_fields; 6, block; 6, 7; 6, 9; 6, 10; 6, 32; 6, 44; 6, 45; 6, 46; 6, 54; 6, 66; 6, 81; 6, 85; 6, 86; 6, 104; 7, expression_...
def assemble_concatenated_meta(concated_meta_dfs, remove_all_metadata_fields): """ Assemble the concatenated metadata dfs together. For example, if horizontally concatenating, the concatenated metadata dfs are the column metadata dfs. Both indices are sorted. Args: concated_meta_dfs (list of pa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:assemble_data; 3, parameters; 3, 4; 3, 5; 4, identifier:data_dfs; 5, identifier:concat_direction; 6, block; 6, 7; 6, 9; 6, 127; 6, 128; 6, 146; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 13; 9, 14; 9, 68; 10, comparis...
def assemble_data(data_dfs, concat_direction): """ Assemble the data dfs together. Both indices are sorted. Args: data_dfs (list of pandas dfs) concat_direction (string): 'horiz' or 'vert' Returns: all_data_df_sorted (pandas df) """ if concat_direction == "horiz": ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:get_rows_to_keep; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:gctoo; 5, default_parameter; 5, 6; 5, 7; 6, identifier:rid; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:row_bool; 10, None; 11, default_parameter; 11,...
def get_rows_to_keep(gctoo, rid=None, row_bool=None, ridx=None, exclude_rid=None): """ Figure out based on the possible row inputs which rows to keep. Args: gctoo (GCToo object): rid (list of strings): row_bool (boolean array): ridx (list of integers): exclude_rid (list ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:get_cols_to_keep; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:gctoo; 5, default_parameter; 5, 6; 5, 7; 6, identifier:cid; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:col_bool; 10, None; 11, default_parameter; 11,...
def get_cols_to_keep(gctoo, cid=None, col_bool=None, cidx=None, exclude_cid=None): """ Figure out based on the possible columns inputs which columns to keep. Args: gctoo (GCToo object): cid (list of strings): col_bool (boolean array): cidx (list of integers): exclude_cid...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:finish; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:queue_name; 5, identifier:task_id; 6, identifier:owner; 7, default_parameter; 7, 8; 7, 9; 8, identifier:error; 9, False; 10, block; 10, 11; 10, 13; 10, 22; 10, 51; 10, 73; 10, 85; 10...
def finish(queue_name, task_id, owner, error=False): """Marks a work item on a queue as finished. Args: queue_name: Name of the queue the work item is on. task_id: ID of the task that is finished. owner: Who or what has the current lease on the task. error: Defaults to false. Tr...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:send_ready_for_review; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:build_id; 5, identifier:release_name; 6, identifier:release_number; 7, block; 7, 8; 7, 10; 7, 23; 7, 42; 7, 51; 7, 65; 7, 88; 7, 100; 7, 119; 7, 123; 7, 154; 7, 177; 7, 187; ...
def send_ready_for_review(build_id, release_name, release_number): """Sends an email indicating that the release is ready for review.""" build = models.Build.query.get(build_id) if not build.send_email: logging.debug( 'Not sending ready for review email because build does not have ' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:claim_invitations; 3, parameters; 3, 4; 4, identifier:user; 5, block; 5, 6; 5, 8; 5, 9; 5, 10; 5, 24; 5, 37; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12...
def claim_invitations(user): """Claims any pending invitations for the given user's email address.""" # See if there are any build invitations present for the user with this # email address. If so, replace all those invitations with the real user. invitation_user_id = '%s:%s' % ( models.User.EMA...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_check_release_done_processing; 3, parameters; 3, 4; 4, identifier:release; 5, block; 5, 6; 5, 8; 5, 43; 5, 60; 5, 104; 5, 122; 5, 123; 5, 124; 5, 130; 5, 136; 5, 142; 5, 161; 5, 171; 5, 180; 6, expression_statement; 6, 7; 7, comment; 8, if_sta...
def _check_release_done_processing(release): """Moves a release candidate to reviewing if all runs are done.""" if release.status != models.Release.PROCESSING: # NOTE: This statement also guards for situations where the user has # prematurely specified that the release is good or bad. Once the u...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:download; 3, parameters; 4, block; 4, 5; 4, 7; 4, 8; 4, 9; 4, 41; 4, 55; 4, 72; 4, 85; 4, 102; 4, 116; 4, 133; 4, 150; 4, 168; 4, 169; 4, 170; 4, 193; 4, 209; 4, 236; 5, expression_statement; 5, 6; 6, comment; 7, comment; 8, comment; 9, try_sta...
def download(): """Downloads an artifact by it's content hash.""" # Allow users with access to the build to download the file. Falls back # to API keys with access to the build. Prefer user first for speed. try: build = auth.can_user_access_build('build_id') except HTTPException: log...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_run; 3, parameters; 3, 4; 4, identifier:run; 5, block; 5, 6; 5, 8; 5, 9; 5, 10; 5, 11; 5, 28; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, comment; 10, comment; 11, if_statement; 11, 12; 11, 21; 12, comparison_operator:in; 12,...
def sort_run(run): """Sort function for runs within a release.""" # Sort errors first, then by name. Also show errors that were manually # approved, so the paging sort order stays the same even after users # approve a diff on the run page. if run.status in models.Run.DIFF_NEEDED_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:required_properties; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:additional_properties; 10, None; 11, default_param...
def parse(obj, required_properties=None, additional_properties=None, ignore_optional_property_errors=None): """Try to parse the given ``obj`` as a validator instance. :param obj: The object to be parsed. If it is a...: - :py:class:`Validator` instance, return it. - :py:class:`Validat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:adapts; 3, parameters; 3, 4; 4, dictionary_splat_pattern; 4, 5; 5, identifier:schemas; 6, block; 6, 7; 6, 9; 6, 18; 6, 147; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifie...
def adapts(**schemas): """Create a decorator for validating and adapting function parameters. Example:: @adapts(a="number", body={"+field_ids": [V.AdaptTo(int)], "is_ok": bool}) def f(a, body): print (a, body.field_ids, body.is_ok) :param schemas: The schema for adapting a giv...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:download; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 17; 3, 21; 3, 24; 4, identifier:self; 5, identifier:bundle_uuid; 6, identifier:replica; 7, default_parameter; 7, 8; 7, 9; 8, identifier:version; 9, string:""; 10, default_parame...
def download(self, bundle_uuid, replica, version="", download_dir="", metadata_files=('*',), data_files=('*',), num_retries=10, min_delay_seconds=0.25): """ Download a bundle and save it to the local filesystem as a directory. :param str bundle_uuid: The uuid o...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_do_download_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:dss_file; 6, identifier:fh; 7, identifier:num_retries; 8, identifier:min_delay_seconds; 9, block; 9, 10; 9, 12; 9, 20; 9, 24; 9, 28; 9, 385; 10, e...
def _do_download_file(self, dss_file, fh, num_retries, min_delay_seconds): """ Abstracts away complications for downloading a file, handles retries and delays, and computes its hash """ hasher = hashlib.sha256() delay = min_delay_seconds retries_left = num_retries ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:output; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:output; 6, default_parameter; 6, 7; 6, 8; 7, identifier:status; 8, None; 9, block; 9, 10; 9, 12; 9, 194; 10, expression_statement; 10, 11; 11, comment; 12, if_statement;...
def output(self, output, status=None): """Output text to stdout or a pager command. The status text is not outputted to pager or files. The message will be logged in the audit log, if enabled. The message will be written to the tee file, if enabled. The message will be written to...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:find_matches; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:text; 5, identifier:collection; 6, default_parameter; 6, 7; 6, 8; 7, identifier:start_only; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:fuzzy; 11, True;...
def find_matches(text, collection, start_only=False, fuzzy=True, casing=None): """Find completion matches for the given text. Given the user's input text and a collection of available completions, find completions matching the last word of the text. If `start_only` is True, the t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:cli_bindings; 3, parameters; 4, block; 4, 5; 4, 7; 4, 28; 4, 75; 4, 118; 4, 177; 4, 235; 4, 293; 4, 346; 5, expression_statement; 5, 6; 6, comment; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:key_binding_manager; 10...
def cli_bindings(): """ Custom key bindings for cli. """ key_binding_manager = KeyBindingManager( enable_open_in_editor=True, enable_system_bindings=True, enable_auto_suggest_bindings=True, enable_search=True, enable_abort_and_exit_bindings=True) @key_binding...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_get_thumbnail_options; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:context; 6, identifier:instance; 7, block; 7, 8; 7, 10; 7, 18; 7, 22; 7, 32; 7, 42; 7, 57; 7, 82; 7, 93; 7, 209; 8, expression_statement; 8, 9; 9, commen...
def _get_thumbnail_options(self, context, instance): """ Return the size and options of the thumbnail that should be inserted """ width, height = None, None subject_location = False placeholder_width = context.get('width', None) placeholder_height = context.get('h...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:group_and_sort_statements; 3, parameters; 3, 4; 3, 5; 4, identifier:stmt_list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ev_totals; 7, None; 8, block; 8, 9; 8, 11; 8, 38; 8, 45; 8, 53; 8, 61; 8, 144; 8, 145; 8, 277; 8, 298; 9, expression_...
def group_and_sort_statements(stmt_list, ev_totals=None): """Group statements by type and arguments, and sort by prevalence. Parameters ---------- stmt_list : list[Statement] A list of INDRA statements. ev_totals : dict{int: int} A dictionary, keyed by statement hash (shallow) with ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:make_stmt_from_sort_key; 3, parameters; 3, 4; 3, 5; 4, identifier:key; 5, identifier:verb; 6, block; 6, 7; 6, 9; 6, 30; 6, 37; 6, 46; 6, 146; 7, expression_statement; 7, 8; 8, comment; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_n...
def make_stmt_from_sort_key(key, verb): """Make a Statement from the sort key. Specifically, the sort key used by `group_and_sort_statements`. """ def make_agent(name): if name == 'None' or name is None: return None return Agent(name) StmtClass = get_statement_by_name(v...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:print_boolean_net; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:out_file; 7, None; 8, block; 8, 9; 8, 11; 8, 15; 8, 43; 8, 47; 8, 261; 8, 269; 8, 293; 9, expression_statement; 9, 10; 10, comment...
def print_boolean_net(self, out_file=None): """Return a Boolean network from the assembled graph. See https://github.com/ialbert/booleannet for details about the format used to encode the Boolean rules. Parameters ---------- out_file : Optional[str] A file n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_complex_agents; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:complex_id; 6, block; 6, 7; 6, 9; 6, 13; 6, 22; 6, 155; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12;...
def _get_complex_agents(self, complex_id): """Returns a list of agents corresponding to each of the constituents in a SIGNOR complex.""" agents = [] components = self._recursively_lookup_complex(complex_id) for c in components: db_refs = {} name = uniprot...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_args; 3, parameters; 3, 4; 4, identifier:node; 5, block; 5, 6; 5, 8; 5, 12; 5, 42; 5, 83; 5, 84; 5, 165; 5, 166; 5, 175; 5, 196; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, iden...
def get_args(node): """Return the arguments of a node in the event graph.""" arg_roles = {} args = node.findall('arg') + \ [node.find('arg1'), node.find('arg2'), node.find('arg3')] for arg in args: if arg is not None: id = arg.attrib.get('id') if id is not None: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:map_statements; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, for_statement; 8, 9; 8, 10; 8, 13; 9, identifier:stmt; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifi...
def map_statements(self): """Run the ontology mapping on the statements.""" for stmt in self.statements: for agent in stmt.agent_list(): if agent is None: continue all_mappings = [] for db_name, db_id in agent.db_refs.items(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:agent_texts_with_grounding; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 8; 5, 15; 5, 16; 5, 17; 5, 48; 5, 65; 5, 72; 5, 93; 5, 94; 5, 113; 5, 114; 5, 118; 5, 261; 5, 262; 5, 279; 6, expression_statement; 6, 7; 7, comment; 8, ex...
def agent_texts_with_grounding(stmts): """Return agent text groundings in a list of statements with their counts Parameters ---------- stmts: list of :py:class:`indra.statements.Statement` Returns ------- list of tuple List of tuples of the form (text: str, ((name_space: st...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:ungrounded_texts; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 8; 5, 45; 5, 52; 5, 60; 5, 78; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:ungrounded; 11, ...
def ungrounded_texts(stmts): """Return a list of all ungrounded entities ordered by number of mentions Parameters ---------- stmts : list of :py:class:`indra.statements.Statement` Returns ------- ungroundc : list of tuple list of tuples of the form (text: str, count: int) sorted in ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:protein_map_from_twg; 3, parameters; 3, 4; 4, identifier:twg; 5, block; 5, 6; 5, 8; 5, 12; 5, 16; 5, 20; 5, 27; 5, 150; 5, 159; 5, 168; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, i...
def protein_map_from_twg(twg): """Build map of entity texts to validate protein grounding. Looks at the grounding of the entity texts extracted from the statements and finds proteins where there is grounding to a human protein that maps to an HGNC name that is an exact match to the entity text. Return...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:save_sentences; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:twg; 5, identifier:stmts; 6, identifier:filename; 7, default_parameter; 7, 8; 7, 9; 8, identifier:agent_limit; 9, integer:300; 10, block; 10, 11; 10, 13; 10, 17; 10, 27; 10, ...
def save_sentences(twg, stmts, filename, agent_limit=300): """Write evidence sentences for stmts with ungrounded agents to csv file. Parameters ---------- twg: list of tuple list of tuples of ungrounded agent_texts with counts of the number of times they are mentioned in the list of sta...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_text_for_grounding; 3, parameters; 3, 4; 3, 5; 4, identifier:stmt; 5, identifier:agent_text; 6, block; 6, 7; 6, 9; 6, 13; 6, 14; 6, 107; 6, 108; 6, 155; 6, 156; 6, 180; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9,...
def _get_text_for_grounding(stmt, agent_text): """Get text context for Deft disambiguation If the INDRA database is available, attempts to get the fulltext from which the statement was extracted. If the fulltext is not available, the abstract is returned. If the indra database is not available, uses th...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:map_agents_for_stmt; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:stmt; 6, default_parameter; 6, 7; 6, 8; 7, identifier:do_rename; 8, True; 9, block; 9, 10; 9, 12; 9, 19; 9, 20; 9, 21; 9, 29; 9, 153; 9, 160; 9, 161; 9, 199...
def map_agents_for_stmt(self, stmt, do_rename=True): """Return a new Statement whose agents have been grounding mapped. Parameters ---------- stmt : :py:class:`indra.statements.Statement` The Statement whose agents need mapping. do_rename: Optional[bool] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:map_agent; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:agent; 6, identifier:do_rename; 7, block; 7, 8; 7, 10; 7, 21; 7, 32; 7, 51; 7, 52; 7, 53; 7, 78; 7, 79; 7, 80; 7, 113; 8, expression_statement; 8, 9; 9, comment; 10, ...
def map_agent(self, agent, do_rename): """Return the given Agent with its grounding mapped. This function grounds a single agent. It returns the new Agent object (which might be a different object if we load a new agent state from json) or the same object otherwise. Parameters ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:rename_agents; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stmts; 6, block; 6, 7; 6, 9; 6, 10; 6, 17; 6, 18; 6, 133; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_statement; 10, 11; 11, assignment; 11, 1...
def rename_agents(self, stmts): """Return a list of mapped statements with updated agent names. Creates a new list of statements without modifying the original list. The agents in a statement should be renamed if the grounding map has updated their db_refs. If an agent contains a FamPl...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_ptms; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:ptm_df; 6, block; 6, 7; 6, 9; 6, 16; 6, 17; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 1...
def get_ptms(self, ptm_df): """Generate Modification statements from the HPRD PTM data. Parameters ---------- ptm_df : pandas.DataFrame DataFrame loaded from the POST_TRANSLATIONAL_MODIFICATIONS.txt file. """ logger.info('Processing PTMs...') # Iterat...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_process_interaction; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:source_id; 6, identifier:interaction; 7, identifier:text; 8, identifier:pmid; 9, identifier:extra_annotations; 10, block; 10, 11; 10, 13...
def _process_interaction(self, source_id, interaction, text, pmid, extra_annotations): """Process an interaction JSON tuple from the ISI output, and adds up to one statement to the list of extracted statements. Parameters ---------- source_id : str ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_regulate_amounts; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 23; 5, 35; 5, 50; 5, 54; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:p; 11,...
def get_regulate_amounts(self): """Extract INDRA RegulateAmount Statements from the BioPAX model. This method extracts IncreaseAmount/DecreaseAmount Statements from the BioPAX model. It fully reuses BioPAX Pattern's org.biopax.paxtools.pattern.PatternBox.controlsExpressionWithTemplateRe...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_gef; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 23; 5, 35; 5, 50; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:p; 11, call; 11, 12; 11, 1...
def get_gef(self): """Extract Gef INDRA Statements from the BioPAX model. This method uses a custom BioPAX Pattern (one that is not implemented PatternBox) to query for controlled BiochemicalReactions in which the same protein is in complex with GDP on the left hand side and in ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_gap; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 16; 5, 23; 5, 35; 5, 50; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:p; 11, call; 11, 12; 11, 1...
def get_gap(self): """Extract Gap INDRA Statements from the BioPAX model. This method uses a custom BioPAX Pattern (one that is not implemented PatternBox) to query for controlled BiochemicalReactions in which the same protein is in complex with GTP on the left hand side and in ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_generic_modification; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:mod_class; 6, block; 6, 7; 6, 9; 6, 15; 6, 42; 6, 50; 6, 51; 6, 59; 6, 72; 6, 79; 6, 91; 6, 106; 6, 110; 6, 383; 7, expression_statement; 7, 8; 8, comment; ...
def _get_generic_modification(self, mod_class): """Get all modification reactions given a Modification class.""" mod_type = modclass_to_modtype[mod_class] if issubclass(mod_class, RemoveModification): mod_gain_const = mcct.LOSS mod_type = modtype_to_inverse[mod_type] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_extract_mod_from_feature; 3, parameters; 3, 4; 4, identifier:mf; 5, block; 5, 6; 5, 8; 5, 9; 5, 17; 5, 24; 5, 36; 5, 40; 5, 79; 5, 99; 5, 105; 5, 106; 5, 107; 5, 108; 5, 109; 5, 117; 5, 215; 5, 225; 6, expression_statement; 6, 7; 7, comment; 8...
def _extract_mod_from_feature(mf): """Extract the type of modification and the position from a ModificationFeature object in the INDRA format.""" # ModificationFeature / SequenceModificationVocabulary mf_type = mf.getModificationType() if mf_type is None: return None ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_activations; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 30; 5, 41; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:act_events; 11, call; 11,...
def get_activations(self): """Extract direct Activation INDRA Statements.""" act_events = self.tree.findall("EVENT/[type='ONT::ACTIVATE']") inact_events = self.tree.findall("EVENT/[type='ONT::DEACTIVATE']") inact_events += self.tree.findall("EVENT/[type='ONT::INHIBIT']") for even...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_activations_causal; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 20; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:ccs; 12, c...
def get_activations_causal(self): """Extract causal Activation INDRA Statements.""" # Search for causal connectives of type ONT::CAUSE ccs = self.tree.findall("CC/[type='ONT::CAUSE']") for cc in ccs: factor = cc.find("arg/[@role=':FACTOR']") outcome = cc.find("arg...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_activations_stimulate; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 10; 5, 11; 5, 12; 5, 23; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, comment; 10, comment; 11, comment; 12, expression_statement; 1...
def get_activations_stimulate(self): """Extract Activation INDRA Statements via stimulation.""" # TODO: extract to other patterns: # - Stimulation by EGF activates ERK # - Stimulation by EGF leads to ERK activation # Search for stimulation event stim_events = self.tree.fi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_degradations; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:deg_events; 11, call; 11, 12; 11, 17; ...
def get_degradations(self): """Extract Degradation INDRA Statements.""" deg_events = self.tree.findall("EVENT/[type='ONT::CONSUME']") for event in deg_events: if event.attrib['id'] in self._static_events: continue affected = event.find(".//*[@role=':AFFECT...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_complexes; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 19; 5, 30; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:bind_events; 11, call; 11, 12; 11,...
def get_complexes(self): """Extract Complex INDRA Statements.""" bind_events = self.tree.findall("EVENT/[type='ONT::BIND']") bind_events += self.tree.findall("EVENT/[type='ONT::INTERACT']") for event in bind_events: if event.attrib['id'] in self._static_events: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_modifications_indirect; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 20; 5, 21; 5, 26; 5, 133; 5, 240; 5, 247; 5, 254; 5, 255; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10;...
def get_modifications_indirect(self): """Extract indirect Modification INDRA Statements.""" # Get all the specific mod types mod_event_types = list(ont_to_mod_type.keys()) # Add ONT::PTMs as a special case mod_event_types += ['ONT::PTM'] def get_increase_events(mod_event...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:replace_activities; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 15; 5, 16; 5, 20; 5, 52; 5, 53; 5, 59; 5, 60; 5, 297; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, att...
def replace_activities(self): """Replace ative flags with Agent states when possible.""" logger.debug('Running PySB Preassembler replace activities') # TODO: handle activity hierarchies new_stmts = [] def has_agent_activity(stmt): """Return True if any agents in the ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:add_reverse_effects; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 13; 5, 17; 5, 21; 5, 25; 5, 211; 5, 215; 5, 279; 5, 306; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, ass...
def add_reverse_effects(self): """Add Statements for the reverse effects of some Statements. For instance, if a protein is phosphorylated but never dephosphorylated in the model, we add a generic dephosphorylation here. This step is usually optional in the assembly process. """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:map_sites; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:stmts; 6, block; 6, 7; 6, 9; 6, 13; 6, 17; 6, 54; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:...
def map_sites(self, stmts): """Check a set of statements for invalid modification sites. Statements are checked against Uniprot reference sequences to determine if residues referred to by post-translational modifications exist at the given positions. If there is nothing amiss w...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_map_agent_sites; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:agent; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 25; 6, 32; 6, 36; 6, 37; 6, 117; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 11, if_statement; ...
def _map_agent_sites(self, agent): """Check an agent for invalid sites and update if necessary. Parameters ---------- agent : :py:class:`indra.statements.Agent` Agent to check for invalid modification sites. Returns ------- tuple The firs...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_map_agent_mod; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:agent; 6, identifier:mod_condition; 7, block; 7, 8; 7, 10; 7, 11; 7, 18; 7, 35; 7, 36; 7, 51; 7, 52; 7, 84; 8, expression_statement; 8, 9; 9, comment; 10, commen...
def _map_agent_mod(self, agent, mod_condition): """Map a single modification condition on an agent. Parameters ---------- agent : :py:class:`indra.statements.Agent` Agent to check for invalid modification sites. mod_condition : :py:class:`indra.statements.ModConditio...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_graph_reductions; 3, parameters; 3, 4; 4, identifier:graph; 5, block; 5, 6; 5, 8; 5, 64; 5, 68; 5, 84; 5, 96; 5, 97; 5, 98; 5, 99; 5, 138; 6, expression_statement; 6, 7; 7, comment; 8, function_definition; 8, 9; 8, 10; 8, 13; 9, function_n...
def _get_graph_reductions(graph): """Return transitive reductions on a DAG. This is used to reduce the set of activities of a BaseAgent to the most specific one(s) possible. For instance, if a BaseAgent is know to have 'activity', 'catalytic' and 'kinase' activity, then this function will return {'...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:gather_implicit_activities; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, for_statement; 8, 9; 8, 10; 8, 13; 9, identifier:stmt; 10, attribute; 10, 11; 10, 12; 11, identifier:self; ...
def gather_implicit_activities(self): """Aggregate all implicit activities and active forms of Agents. Iterate over self.statements and collect the implied activities and active forms of Agents that appear in the Statements. Note that using this function to collect implied Agent activi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:reduce_activities; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 6, expression_statement; 6, 7; 7, comment; 8, for_statement; 8, 9; 8, 10; 8, 13; 9, identifier:stmt; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, ident...
def reduce_activities(self): """Rewrite the activity types referenced in Statements for consistency. Activity types are reduced to the most specific form whenever possible. For instance, if 'kinase' is the only specific activity type known for the BaseAgent of BRAF, its generic 'activit...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:infer_activations; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 8; 5, 12; 5, 20; 5, 28; 5, 190; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:linked_stmts; ...
def infer_activations(stmts): """Return inferred RegulateActivity from Modification + ActiveForm. This function looks for combinations of Modification and ActiveForm Statements and infers Activation/Inhibition Statements from them. For example, if we know that A phosphorylates B, and th...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:infer_active_forms; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 8; 5, 12; 5, 251; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:linked_stmts; 11, list:[]; ...
def infer_active_forms(stmts): """Return inferred ActiveForm from RegulateActivity + Modification. This function looks for combinations of Activation/Inhibition Statements and Modification Statements, and infers an ActiveForm from them. For example, if we know that A activates B and ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:infer_modifications; 3, parameters; 3, 4; 4, identifier:stmts; 5, block; 5, 6; 5, 8; 5, 12; 5, 191; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:linked_stmts; 11, list:[];...
def infer_modifications(stmts): """Return inferred Modification from RegulateActivity + ActiveForm. This function looks for combinations of Activation/Inhibition Statements and ActiveForm Statements that imply a Modification Statement. For example, if we know that A activates B, and pho...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:score_evidence_list; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:evidences; 6, block; 6, 7; 6, 9; 6, 129; 6, 147; 6, 164; 6, 171; 6, 178; 6, 179; 6, 180; 6, 181; 6, 182; 6, 183; 6, 184; 6, 185; 6, 186; 6, 187; 6, 196; 7, expres...
def score_evidence_list(self, evidences): """Return belief score given a list of supporting evidences.""" def _score(evidences): if not evidences: return 0 # Collect all unique sources sources = [ev.source_api for ev in evidences] uniq_sour...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:update_probs; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 10; 5, 14; 5, 24; 5, 83; 5, 84; 5, 88; 5, 160; 5, 161; 5, 162; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, comment; 10, expression_statement; 10...
def update_probs(self): """Update the internal probability values given the counts.""" # We deal with the prior probsfirst # This is a fixed assumed value for systematic error syst_error = 0.05 prior_probs = {'syst': {}, 'rand': {}} for source, (p, n) in self.prior_counts...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_hierarchy_probs; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:statements; 6, block; 6, 7; 6, 9; 6, 80; 6, 126; 6, 165; 6, 172; 6, 177; 6, 184; 7, expression_statement; 7, 8; 8, comment; 9, function_definition; 9, 10; 9, 11; ...
def set_hierarchy_probs(self, statements): """Sets hierarchical belief probabilities for INDRA Statements. The Statements are assumed to be in a hierarchical relation graph with the supports and supported_by attribute of each Statement object having been set. The hierarchical be...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_statements; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reprocess; 7, False; 8, block; 8, 9; 8, 11; 8, 226; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; 11, 19; 11...
def get_statements(self, reprocess=False): """General method to create statements.""" if self._statements is None or reprocess: # Handle the case that there is no content. if self.content is None: self._statements = [] return [] # Map ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:read; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:read_list; 6, default_parameter; 6, 7; 6, 8; 7, identifier:verbose; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:log; 11, False; 12, default_...
def read(self, read_list, verbose=False, log=False, n_per_proc=None): "Perform the actual reading." ret = [] self.prep_input(read_list) L = len(self.file_list) if L == 0: return ret logger.info("Beginning to run sparser.") output_file_list = [] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:read_pmid_sentences; 3, parameters; 3, 4; 3, 5; 4, identifier:pmid_sentences; 5, dictionary_splat_pattern; 5, 6; 6, identifier:drum_args; 7, block; 7, 8; 7, 10; 7, 32; 7, 33; 7, 43; 7, 47; 7, 51; 7, 52; 7, 238; 7, 239; 7, 252; 8, expression_sta...
def read_pmid_sentences(pmid_sentences, **drum_args): """Read sentences from a PMID-keyed dictonary and return all Statements Parameters ---------- pmid_sentences : dict[str, list[str]] A dictonary where each key is a PMID pointing to a list of sentences to be read. **drum_args ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:graph_query; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:kind; 5, identifier:source; 6, default_parameter; 6, 7; 6, 8; 7, identifier:target; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:neighbor_limit; 11, intege...
def graph_query(kind, source, target=None, neighbor_limit=1, database_filter=None): """Perform a graph query on PathwayCommons. For more information on these queries, see http://www.pathwaycommons.org/pc2/#graph Parameters ---------- kind : str The kind of graph query t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_CCLE_context; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:cell_types; 6, block; 6, 7; 6, 9; 6, 15; 6, 16; 6, 29; 6, 42; 6, 43; 6, 53; 6, 99; 6, 100; 6, 101; 6, 102; 6, 288; 6, 295; 6, 305; 7, expression_statement; 7, 8; 8, ...
def set_CCLE_context(self, cell_types): """Set context of all nodes and node members from CCLE.""" self.get_gene_names() # Get expression and mutations from context client exp_values = \ context_client.get_protein_expression(self._gene_names, cell_types) mut_values =...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_node_key; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:node_dict_item; 6, block; 6, 7; 6, 9; 6, 21; 6, 33; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, ident...
def _get_node_key(self, node_dict_item): """Return a tuple of sorted sources and targets given a node dict.""" s = tuple(sorted(node_dict_item['sources'])) t = tuple(sorted(node_dict_item['targets'])) return (s, t)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_get_node_groups; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 30; 5, 106; 5, 107; 5, 117; 5, 145; 5, 146; 5, 166; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, i...
def _get_node_groups(self): """Return a list of node id lists that are topologically identical. First construct a node_dict which is keyed to the node id and has a value which is a dict with keys 'sources' and 'targets'. The 'sources' and 'targets' each contain a list of tuples ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_group_edges; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 15; 5, 16; 5, 245; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:edges...
def _group_edges(self): """Group all edges that are topologically identical. This means that (i, source, target, polarity) are the same, then sets edges on parent (i.e. - group) nodes to 'Virtual' and creates a new edge to represent all of them. """ # edit edges on paren...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 40; 2, function_name:get_statements; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 4, default_parameter; 4, 5; 4, 6; 5, identifier:subject; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:object; 9, None;...
def get_statements(subject=None, object=None, agents=None, stmt_type=None, use_exact_type=False, persist=True, timeout=None, simple_response=False, ev_limit=10, best_first=True, tries=2, max_stmts=None): """Get a processor for the INDRA DB web API matching gi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_statements_by_hash; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:hash_list; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ev_limit; 7, integer:100; 8, default_parameter; 8, 9; 8, 10; 9, identifier:best_first; 10, True; 11, defau...
def get_statements_by_hash(hash_list, ev_limit=100, best_first=True, tries=2): """Get fully formed statements from a list of hashes. Parameters ---------- hash_list : list[int or str] A list of statement hashes. ev_limit : int or None Limit the amount of evidence returned per Statem...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:get_statements_for_paper; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:ids; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ev_limit; 7, integer:10; 8, default_parameter; 8, 9; 8, 10; 9, identifier:best_first; 10, True; 11, def...
def get_statements_for_paper(ids, ev_limit=10, best_first=True, tries=2, max_stmts=None): """Get the set of raw Statements extracted from a paper given by the id. Parameters ---------- ids : list[(<id type>, <id value>)] A list of tuples with ids and their type. The...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_statement_queries; 3, parameters; 3, 4; 3, 5; 4, identifier:stmts; 5, dictionary_splat_pattern; 5, 6; 6, identifier:params; 7, block; 7, 8; 7, 10; 7, 63; 7, 67; 7, 74; 7, 81; 7, 213; 8, expression_statement; 8, 9; 9, comment; 10, function_d...
def get_statement_queries(stmts, **params): """Get queries used to search based on a statement. In addition to the stmts, you can enter any parameters standard to the query. See https://github.com/indralab/indra_db/rest_api for a full list. Parameters ---------- stmts : list[Statement] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:make_statement; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:action; 6, identifier:mention; 7, block; 7, 8; 7, 10; 7, 25; 7, 33; 7, 34; 7, 35; 7, 36; 7, 37; 7, 38; 7, 39; 7, 43; 7, 111; 7, 112; 7, 118; 7, 124; 7, 132; 7, 1...
def make_statement(self, action, mention): """Makes an INDRA statement from a Geneways action and action mention. Parameters ---------- action : GenewaysAction The mechanism that the Geneways mention maps to. Note that several text mentions can correspond to the ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:directly_or_indirectly_related; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:ns1; 6, identifier:id1; 7, identifier:ns2; 8, identifier:id2; 9, identifier:closure_dict; 10, identifier:relation_func;...
def directly_or_indirectly_related(self, ns1, id1, ns2, id2, closure_dict, relation_func): """Return True if two entities have the speicified relationship. This relation is constructed possibly through multiple links connecting the two entities directly or...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:analyze_db_reading; 3, parameters; 3, 4; 3, 5; 4, identifier:job_prefix; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reading_queue; 7, string:'run_db_reading_queue'; 8, block; 8, 9; 8, 11; 8, 12; 8, 20; 8, 24; 8, 28; 8, 32; 8, 69; 8, 70; 8,...
def analyze_db_reading(job_prefix, reading_queue='run_db_reading_queue'): """Run various analysis on a particular reading job.""" # Analyze reach failures log_strs = get_logs_from_db_reading(job_prefix, reading_queue) indra_log_strs = [] all_reach_logs = [] log_stats = [] for log_str in log_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_create_base_agent; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:agent; 6, block; 6, 7; 6, 9; 6, 52; 6, 53; 6, 224; 6, 225; 6, 245; 7, expression_statement; 7, 8; 8, comment; 9, try_statement; 9, 10; 9, 24; 10, block; 10, 11;...
def get_create_base_agent(self, agent): """Return base agent with given name, creating it if needed.""" try: base_agent = self.agents[_n(agent.name)] except KeyError: base_agent = BaseAgent(_n(agent.name)) self.agents[_n(agent.name)] = base_agent # If...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:classify_nodes; 3, parameters; 3, 4; 3, 5; 4, identifier:graph; 5, identifier:hub; 6, block; 6, 7; 6, 9; 6, 20; 6, 144; 6, 148; 6, 234; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 1...
def classify_nodes(graph, hub): """Classify each node based on its type and relationship to the hub.""" node_stats = defaultdict(lambda: defaultdict(list)) for u, v, data in graph.edges(data=True): # This means the node is downstream of the hub if hub == u: h, o = u, v ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:doi_query; 3, parameters; 3, 4; 3, 5; 4, identifier:pmid; 5, default_parameter; 5, 6; 5, 7; 6, identifier:search_limit; 7, integer:10; 8, block; 8, 9; 8, 11; 8, 12; 8, 25; 8, 50; 8, 51; 8, 57; 8, 58; 8, 73; 8, 74; 8, 83; 8, 99; 8, 100; 8, 109; ...
def doi_query(pmid, search_limit=10): """Get the DOI for a PMID by matching CrossRef and Pubmed metadata. Searches CrossRef using the article title and then accepts search hits only if they have a matching journal ISSN and page number with what is obtained from the Pubmed database. """ # Get ar...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_agent_rule_str; 3, parameters; 3, 4; 4, identifier:agent; 5, block; 5, 6; 5, 8; 5, 18; 5, 19; 5, 254; 5, 263; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:rule_str_lis...
def get_agent_rule_str(agent): """Construct a string from an Agent as part of a PySB rule name.""" rule_str_list = [_n(agent.name)] # If it's a molecular agent if isinstance(agent, ist.Agent): for mod in agent.mods: mstr = abbrevs[mod.mod_type] if mod.residue is not None:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:grounded_monomer_patterns; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:model; 5, identifier:agent; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ignore_activities; 8, False; 9, block; 9, 10; 9, 12; 9, 13; 9, 46; 9, 47; 9, 48; 9, 52; 9, 138...
def grounded_monomer_patterns(model, agent, ignore_activities=False): """Get monomer patterns for the agent accounting for grounding information. Parameters ---------- model : pysb.core.Model The model to search for MonomerPatterns matching the given Agent. agent : indra.statements.Agent ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_site_pattern; 3, parameters; 3, 4; 4, identifier:agent; 5, block; 5, 6; 5, 8; 5, 20; 5, 24; 5, 25; 5, 62; 5, 63; 5, 147; 5, 148; 5, 203; 5, 204; 5, 222; 5, 223; 5, 261; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 17...
def get_site_pattern(agent): """Construct a dictionary of Monomer site states from an Agent. This crates the mapping to the associated PySB monomer from an INDRA Agent object.""" if not isinstance(agent, ist.Agent): return {} pattern = {} # Handle bound conditions for bc in agent.bo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:make_model; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:policies; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:initial_conditions; 10, True; 11, default_parame...
def make_model(self, policies=None, initial_conditions=True, reverse_effects=False, model_name='indra_model'): """Assemble the PySB model from the collected INDRA Statements. This method assembles a PySB model from the set of INDRA Statements. The assembled model is both retu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_modifications; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 9; 5, 13; 5, 24; 5, 30; 5, 31; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, ident...
def get_modifications(self): """Extract Modification INDRA Statements.""" # Find all event frames that are a type of protein modification qstr = "$.events.frames[(@.type is 'protein-modification')]" res = self.tree.execute(qstr) if res is None: return # Extrac...