idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
17,300 | def download_article ( id_val , id_type = 'doi' , on_retry = False ) : if id_type == 'pmid' : id_type = 'pubmed_id' url = '%s/%s' % ( elsevier_article_url_fmt % id_type , id_val ) params = { 'httpAccept' : 'text/xml' } res = requests . get ( url , params , headers = ELSEVIER_KEYS ) if res . status_code == 404 : logger ... | Low level function to get an XML article for a particular id . |
17,301 | def download_article_from_ids ( ** id_dict ) : valid_id_types = [ 'eid' , 'doi' , 'pmid' , 'pii' ] assert all ( [ k in valid_id_types for k in id_dict . keys ( ) ] ) , ( "One of these id keys is invalid: %s Valid keys are: %s." % ( list ( id_dict . keys ( ) ) , valid_id_types ) ) if 'doi' in id_dict . keys ( ) and id_d... | Download an article in XML format from Elsevier matching the set of ids . |
17,302 | def get_abstract ( doi ) : xml_string = download_article ( doi ) if xml_string is None : return None assert isinstance ( xml_string , str ) xml_tree = ET . XML ( xml_string . encode ( 'utf-8' ) , parser = UTB ( ) ) if xml_tree is None : return None coredata = xml_tree . find ( 'article:coredata' , elsevier_ns ) abstrac... | Get the abstract text of an article from Elsevier given a doi . |
17,303 | def get_article ( doi , output_format = 'txt' ) : xml_string = download_article ( doi ) if output_format == 'txt' and xml_string is not None : text = extract_text ( xml_string ) return text return xml_string | Get the full body of an article from Elsevier . |
17,304 | def extract_paragraphs ( xml_string ) : assert isinstance ( xml_string , str ) xml_tree = ET . XML ( xml_string . encode ( 'utf-8' ) , parser = UTB ( ) ) full_text = xml_tree . find ( 'article:originalText' , elsevier_ns ) if full_text is None : logger . info ( 'Could not find full text element article:originalText' ) ... | Get paragraphs from the body of the given Elsevier xml . |
17,305 | def get_dois ( query_str , count = 100 ) : url = '%s/%s' % ( elsevier_search_url , query_str ) params = { 'query' : query_str , 'count' : count , 'httpAccept' : 'application/xml' , 'sort' : '-coverdate' , 'field' : 'doi' } res = requests . get ( url , params ) if not res . status_code == 200 : return None tree = ET . X... | Search ScienceDirect through the API for articles . |
17,306 | def get_piis ( query_str ) : dates = range ( 1960 , datetime . datetime . now ( ) . year ) all_piis = flatten ( [ get_piis_for_date ( query_str , date ) for date in dates ] ) return all_piis | Search ScienceDirect through the API for articles and return PIIs . |
17,307 | def get_piis_for_date ( query_str , date ) : count = 200 params = { 'query' : query_str , 'count' : count , 'start' : 0 , 'sort' : '-coverdate' , 'date' : date , 'field' : 'pii' } all_piis = [ ] while True : res = requests . get ( elsevier_search_url , params , headers = ELSEVIER_KEYS ) if not res . status_code == 200 ... | Search ScienceDirect with a query string constrained to a given year . |
17,308 | def download_from_search ( query_str , folder , do_extract_text = True , max_results = None ) : piis = get_piis ( query_str ) for pii in piis [ : max_results ] : if os . path . exists ( os . path . join ( folder , '%s.txt' % pii ) ) : continue logger . info ( 'Downloading %s' % pii ) xml = download_article ( pii , 'pii... | Save raw text files based on a search for papers on ScienceDirect . |
17,309 | def extract_statement_from_query_result ( self , res ) : agent_start , agent_end , affected_start , affected_end = res agent_start = int ( agent_start ) agent_end = int ( agent_end ) affected_start = int ( affected_start ) affected_end = int ( affected_end ) agent = self . text [ agent_start : agent_end ] affected = se... | Adds a statement based on one element of a rdflib SPARQL query . |
17,310 | def extract_statements ( self ) : query = prefixes + results = self . graph . query ( query ) for res in results : self . extract_statement_from_query_result ( res ) query = query . replace ( 'role:AFFECTED' , 'role:RESULT' ) results = self . graph . query ( query ) for res in results : self . extract_statement_from_qu... | Extracts INDRA statements from the RDF graph via SPARQL queries . |
17,311 | def _recursively_lookup_complex ( self , complex_id ) : assert complex_id in self . complex_map expanded_agent_strings = [ ] expand_these_next = [ complex_id ] while len ( expand_these_next ) > 0 : c = expand_these_next [ 0 ] expand_these_next = expand_these_next [ 1 : ] assert c in self . complex_map for s in self . c... | Looks up the constitutents of a complex . If any constituent is itself a complex recursively expands until all constituents are not complexes . |
17,312 | def _get_complex_agents ( self , complex_id ) : agents = [ ] components = self . _recursively_lookup_complex ( complex_id ) for c in components : db_refs = { } name = uniprot_client . get_gene_name ( c ) if name is None : db_refs [ 'SIGNOR' ] = c else : db_refs [ 'UP' ] = c hgnc_id = hgnc_client . get_hgnc_id ( name ) ... | Returns a list of agents corresponding to each of the constituents in a SIGNOR complex . |
17,313 | def stmts_from_json ( json_in , on_missing_support = 'handle' ) : stmts = [ ] uuid_dict = { } for json_stmt in json_in : try : st = Statement . _from_json ( json_stmt ) except Exception as e : logger . warning ( "Error creating statement: %s" % e ) continue stmts . append ( st ) uuid_dict [ st . uuid ] = st for st in s... | Get a list of Statements from Statement jsons . |
17,314 | def stmts_to_json_file ( stmts , fname ) : with open ( fname , 'w' ) as fh : json . dump ( stmts_to_json ( stmts ) , fh , indent = 1 ) | Serialize a list of INDRA Statements into a JSON file . |
17,315 | def stmts_to_json ( stmts_in , use_sbo = False ) : if not isinstance ( stmts_in , list ) : json_dict = stmts_in . to_json ( use_sbo = use_sbo ) return json_dict else : json_dict = [ st . to_json ( use_sbo = use_sbo ) for st in stmts_in ] return json_dict | Return the JSON - serialized form of one or more INDRA Statements . |
17,316 | def _promote_support ( sup_list , uuid_dict , on_missing = 'handle' ) : valid_handling_choices = [ 'handle' , 'error' , 'ignore' ] if on_missing not in valid_handling_choices : raise InputError ( 'Invalid option for `on_missing_support`: \'%s\'\n' 'Choices are: %s.' % ( on_missing , str ( valid_handling_choices ) ) ) f... | Promote the list of support - related uuids to Statements if possible . |
17,317 | def draw_stmt_graph ( stmts ) : import networkx try : import matplotlib . pyplot as plt except Exception : logger . error ( 'Could not import matplotlib, not drawing graph.' ) return try : import pygraphviz except Exception : logger . error ( 'Could not import pygraphviz, not drawing graph.' ) return import numpy g = n... | Render the attributes of a list of Statements as directed graphs . |
17,318 | def _fix_json_agents ( ag_obj ) : if isinstance ( ag_obj , str ) : logger . info ( "Fixing string agent: %s." % ag_obj ) ret = { 'name' : ag_obj , 'db_refs' : { 'TEXT' : ag_obj } } elif isinstance ( ag_obj , list ) : ret = [ _fix_json_agents ( ag ) for ag in ag_obj ] elif isinstance ( ag_obj , dict ) and 'TEXT' in ag_o... | Fix the json representation of an agent . |
17,319 | def set_statements_pmid ( self , pmid ) : for stmt in self . json_stmts : evs = stmt . get ( 'evidence' , [ ] ) for ev in evs : ev [ 'pmid' ] = pmid for stmt in self . statements : for ev in stmt . evidence : ev . pmid = pmid | Set the evidence PMID of Statements that have been extracted . |
17,320 | def get_args ( node ) : 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 : arg_roles [ arg . attrib [ 'role' ] ] = ( arg . attrib [ 'id' ] , arg ) if no... | Return the arguments of a node in the event graph . |
17,321 | def type_match ( a , b ) : if a [ 'type' ] == b [ 'type' ] : return True eq_groups = [ { 'ONT::GENE-PROTEIN' , 'ONT::GENE' , 'ONT::PROTEIN' } , { 'ONT::PHARMACOLOGIC-SUBSTANCE' , 'ONT::CHEMICAL' } ] for eq_group in eq_groups : if a [ 'type' ] in eq_group and b [ 'type' ] in eq_group : return True return False | Return True of the types of a and b are compatible False otherwise . |
17,322 | def add_graph ( patterns , G ) : if not patterns : patterns . append ( [ G ] ) return for i , graphs in enumerate ( patterns ) : if networkx . is_isomorphic ( graphs [ 0 ] , G , node_match = type_match , edge_match = type_match ) : patterns [ i ] . append ( G ) return patterns . append ( [ G ] ) | Add a graph to a set of unique patterns . |
17,323 | def draw ( graph , fname ) : ag = networkx . nx_agraph . to_agraph ( graph ) ag . draw ( fname , prog = 'dot' ) | Draw a graph and save it into a file |
17,324 | def build_event_graph ( graph , tree , node ) : if node_key ( node ) in graph : return type = get_type ( node ) text = get_text ( node ) label = '%s (%s)' % ( type , text ) graph . add_node ( node_key ( node ) , type = type , label = label , text = text ) args = get_args ( node ) for arg_role , ( arg_id , arg_tag ) in ... | Return a DiGraph of a specific event structure built recursively |
17,325 | def get_extracted_events ( fnames ) : event_list = [ ] for fn in fnames : tp = trips . process_xml_file ( fn ) ed = tp . extracted_events for k , v in ed . items ( ) : event_list += v return event_list | Get a full list of all extracted event IDs from a list of EKB files |
17,326 | def check_event_coverage ( patterns , event_list ) : proportions = [ ] for pattern_list in patterns : proportion = 0 for pattern in pattern_list : for node in pattern . nodes ( ) : if node in event_list : proportion += 1.0 / len ( pattern_list ) break proportions . append ( proportion ) return proportions | Calculate the ratio of patterns that were extracted . |
17,327 | def map_statements ( self ) : 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 ( ) : if isinstance ( db_id , list ) : db_id = db_id [ 0 ] [ 0 ] mappings = self . _map_id ( db_name , db_id ) all_mappings += ... | Run the ontology mapping on the statements . |
17,328 | def load_grounding_map ( grounding_map_path , ignore_path = None , lineterminator = '\r\n' ) : g_map = { } map_rows = read_unicode_csv ( grounding_map_path , delimiter = ',' , quotechar = '"' , quoting = csv . QUOTE_MINIMAL , lineterminator = '\r\n' ) if ignore_path and os . path . exists ( ignore_path ) : ignore_rows ... | Return a grounding map dictionary loaded from a csv file . |
17,329 | def all_agents ( stmts ) : agents = [ ] for stmt in stmts : for agent in stmt . agent_list ( ) : if agent is not None and agent . db_refs . get ( 'TEXT' ) is not None : agents . append ( agent ) return agents | Return a list of all of the agents from a list of statements . |
17,330 | def get_sentences_for_agent ( text , stmts , max_sentences = None ) : sentences = [ ] for stmt in stmts : for agent in stmt . agent_list ( ) : if agent is not None and agent . db_refs . get ( 'TEXT' ) == text : sentences . append ( ( stmt . evidence [ 0 ] . pmid , stmt . evidence [ 0 ] . text ) ) if max_sentences is no... | Returns evidence sentences with a given agent text from a list of statements |
17,331 | def agent_texts_with_grounding ( stmts ) : allag = all_agents ( stmts ) for ag in allag : pfam_def = ag . db_refs . get ( 'PFAM-DEF' ) if pfam_def is not None : ag . db_refs [ 'PFAM-DEF' ] = tuple ( pfam_def ) refs = [ tuple ( ag . db_refs . items ( ) ) for ag in allag ] refs_counter = Counter ( refs ) refs_counter_dic... | Return agent text groundings in a list of statements with their counts |
17,332 | def ungrounded_texts ( stmts ) : ungrounded = [ ag . db_refs [ 'TEXT' ] for s in stmts for ag in s . agent_list ( ) if ag is not None and list ( ag . db_refs . keys ( ) ) == [ 'TEXT' ] ] ungroundc = Counter ( ungrounded ) ungroundc = ungroundc . items ( ) ungroundc = sorted ( ungroundc , key = lambda x : x [ 1 ] , reve... | Return a list of all ungrounded entities ordered by number of mentions |
17,333 | def get_agents_with_name ( name , stmts ) : return [ ag for stmt in stmts for ag in stmt . agent_list ( ) if ag is not None and ag . name == name ] | Return all agents within a list of statements with a particular name . |
17,334 | def save_base_map ( filename , grouped_by_text ) : rows = [ ] for group in grouped_by_text : text_string = group [ 0 ] for db , db_id , count in group [ 1 ] : if db == 'UP' : name = uniprot_client . get_mnemonic ( db_id ) else : name = '' row = [ text_string , db , db_id , count , name ] rows . append ( row ) write_uni... | Dump a list of agents along with groundings and counts into a csv file |
17,335 | def protein_map_from_twg ( twg ) : protein_map = { } unmatched = 0 matched = 0 logger . info ( 'Building grounding map for human proteins' ) for agent_text , grounding_list , _ in twg : if 'UP' not in [ entry [ 0 ] for entry in grounding_list ] : continue uniprot_ids = [ entry [ 1 ] for entry in grounding_list if entry... | Build map of entity texts to validate protein grounding . |
17,336 | def save_sentences ( twg , stmts , filename , agent_limit = 300 ) : sentences = [ ] unmapped_texts = [ t [ 0 ] for t in twg ] counter = 0 logger . info ( 'Getting sentences for top %d unmapped agent texts.' % agent_limit ) for text in unmapped_texts : agent_sentences = get_sentences_for_agent ( text , stmts ) sentences... | Write evidence sentences for stmts with ungrounded agents to csv file . |
17,337 | def _get_text_for_grounding ( stmt , agent_text ) : text = None try : from indra_db . util . content_scripts import get_text_content_from_text_refs from indra . literature . deft_tools import universal_extract_text refs = stmt . evidence [ 0 ] . text_refs if stmt . evidence [ 0 ] . pmid : refs [ 'PMID' ] = stmt . evide... | Get text context for Deft disambiguation |
17,338 | def update_agent_db_refs ( self , agent , agent_text , do_rename = True ) : map_db_refs = deepcopy ( self . gm . get ( agent_text ) ) self . standardize_agent_db_refs ( agent , map_db_refs , do_rename ) | Update db_refs of agent using the grounding map |
17,339 | def map_agents_for_stmt ( self , stmt , do_rename = True ) : mapped_stmt = deepcopy ( stmt ) agent_list = mapped_stmt . agent_list ( ) for idx , agent in enumerate ( agent_list ) : if agent is None : continue agent_txt = agent . db_refs . get ( 'TEXT' ) if agent_txt is None : continue new_agent , maps_to_none = self . ... | Return a new Statement whose agents have been grounding mapped . |
17,340 | def map_agent ( self , agent , do_rename ) : agent_text = agent . db_refs . get ( 'TEXT' ) mapped_to_agent_json = self . agent_map . get ( agent_text ) if mapped_to_agent_json : mapped_to_agent = Agent . _from_json ( mapped_to_agent_json [ 'agent' ] ) return mapped_to_agent , False if agent_text in self . gm . keys ( )... | Return the given Agent with its grounding mapped . |
17,341 | def map_agents ( self , stmts , do_rename = True ) : mapped_stmts = [ ] num_skipped = 0 for stmt in stmts : mapped_stmt = self . map_agents_for_stmt ( stmt , do_rename ) if mapped_stmt is not None : mapped_stmts . append ( mapped_stmt ) else : num_skipped += 1 logger . info ( '%s statements filtered out' % num_skipped ... | Return a new list of statements whose agents have been mapped |
17,342 | def rename_agents ( self , stmts ) : mapped_stmts = deepcopy ( stmts ) for _ , stmt in enumerate ( mapped_stmts ) : for agent in stmt . agent_list ( ) : if agent is None : continue if agent . db_refs . get ( 'FPLX' ) : agent . name = agent . db_refs . get ( 'FPLX' ) elif agent . db_refs . get ( 'UP' ) : gene_name = uni... | Return a list of mapped statements with updated agent names . |
17,343 | def get_complexes ( self , cplx_df ) : logger . info ( 'Processing complexes...' ) for cplx_id , this_cplx in cplx_df . groupby ( 'CPLX_ID' ) : agents = [ ] for hprd_id in this_cplx . HPRD_ID : ag = self . _make_agent ( hprd_id ) if ag is not None : agents . append ( ag ) if not agents : continue row0 = this_cplx . ilo... | Generate Complex Statements from the HPRD protein complexes data . |
17,344 | def get_ptms ( self , ptm_df ) : logger . info ( 'Processing PTMs...' ) for ix , row in ptm_df . iterrows ( ) : ptm_class = _ptm_map [ row [ 'MOD_TYPE' ] ] if ptm_class is None : continue sub_ag = self . _make_agent ( row [ 'HPRD_ID' ] , refseq_id = row [ 'REFSEQ_PROTEIN' ] ) if sub_ag is None : continue enz_id = _nan_... | Generate Modification statements from the HPRD PTM data . |
17,345 | def get_ppis ( self , ppi_df ) : logger . info ( 'Processing PPIs...' ) for ix , row in ppi_df . iterrows ( ) : agA = self . _make_agent ( row [ 'HPRD_ID_A' ] ) agB = self . _make_agent ( row [ 'HPRD_ID_B' ] ) if agA is None or agB is None : continue isoform_id = '%s_1' % row [ 'HPRD_ID_A' ] ev_list = self . _get_evide... | Generate Complex Statements from the HPRD PPI data . |
17,346 | def _build_verb_statement_mapping ( ) : path_this = os . path . dirname ( os . path . abspath ( __file__ ) ) map_path = os . path . join ( path_this , 'isi_verb_to_indra_statement_type.tsv' ) with open ( map_path , 'r' ) as f : first_line = True verb_to_statement_type = { } for line in f : if not first_line : line = li... | Build the mapping between ISI verb strings and INDRA statement classes . |
17,347 | def get_statements ( self ) : for k , v in self . reader_output . items ( ) : for interaction in v [ 'interactions' ] : self . _process_interaction ( k , interaction , v [ 'text' ] , self . pmid , self . extra_annotations ) | Process reader output to produce INDRA Statements . |
17,348 | def _process_interaction ( self , source_id , interaction , text , pmid , extra_annotations ) : verb = interaction [ 0 ] . lower ( ) subj = interaction [ - 2 ] obj = interaction [ - 1 ] subj = self . _make_agent ( subj ) obj = self . _make_agent ( obj ) annotations = deepcopy ( extra_annotations ) if 'interaction' in e... | Process an interaction JSON tuple from the ISI output and adds up to one statement to the list of extracted statements . |
17,349 | def make_annotation ( self ) : annotation = dict ( ) for item in dir ( self ) : if len ( item ) > 0 and item [ 0 ] != '_' and not inspect . ismethod ( getattr ( self , item ) ) : annotation [ item ] = getattr ( self , item ) return annotation | Returns a dictionary with all properties of the action mention . |
17,350 | def _match_to_array ( m ) : return [ _cast_biopax_element ( m . get ( i ) ) for i in range ( m . varSize ( ) ) ] | Returns an array consisting of the elements obtained from a pattern search cast into their appropriate classes . |
17,351 | def _is_complex ( pe ) : val = isinstance ( pe , _bp ( 'Complex' ) ) or isinstance ( pe , _bpimpl ( 'Complex' ) ) return val | Return True if the physical entity is a complex |
17,352 | def _is_protein ( pe ) : val = isinstance ( pe , _bp ( 'Protein' ) ) or isinstance ( pe , _bpimpl ( 'Protein' ) ) or isinstance ( pe , _bp ( 'ProteinReference' ) ) or isinstance ( pe , _bpimpl ( 'ProteinReference' ) ) return val | Return True if the element is a protein |
17,353 | def _is_rna ( pe ) : val = isinstance ( pe , _bp ( 'Rna' ) ) or isinstance ( pe , _bpimpl ( 'Rna' ) ) return val | Return True if the element is an RNA |
17,354 | def _is_small_molecule ( pe ) : val = isinstance ( pe , _bp ( 'SmallMolecule' ) ) or isinstance ( pe , _bpimpl ( 'SmallMolecule' ) ) or isinstance ( pe , _bp ( 'SmallMoleculeReference' ) ) or isinstance ( pe , _bpimpl ( 'SmallMoleculeReference' ) ) return val | Return True if the element is a small molecule |
17,355 | def _is_physical_entity ( pe ) : val = isinstance ( pe , _bp ( 'PhysicalEntity' ) ) or isinstance ( pe , _bpimpl ( 'PhysicalEntity' ) ) return val | Return True if the element is a physical entity |
17,356 | def _is_modification_or_activity ( feature ) : if not ( isinstance ( feature , _bp ( 'ModificationFeature' ) ) or isinstance ( feature , _bpimpl ( 'ModificationFeature' ) ) ) : return None mf_type = feature . getModificationType ( ) if mf_type is None : return None mf_type_terms = mf_type . getTerm ( ) . toArray ( ) fo... | Return True if the feature is a modification |
17,357 | def _is_reference ( bpe ) : if isinstance ( bpe , _bp ( 'ProteinReference' ) ) or isinstance ( bpe , _bpimpl ( 'ProteinReference' ) ) or isinstance ( bpe , _bp ( 'SmallMoleculeReference' ) ) or isinstance ( bpe , _bpimpl ( 'SmallMoleculeReference' ) ) or isinstance ( bpe , _bp ( 'RnaReference' ) ) or isinstance ( bpe ,... | Return True if the element is an entity reference . |
17,358 | def _is_entity ( bpe ) : if isinstance ( bpe , _bp ( 'Protein' ) ) or isinstance ( bpe , _bpimpl ( 'Protein' ) ) or isinstance ( bpe , _bp ( 'SmallMolecule' ) ) or isinstance ( bpe , _bpimpl ( 'SmallMolecule' ) ) or isinstance ( bpe , _bp ( 'Complex' ) ) or isinstance ( bpe , _bpimpl ( 'Complex' ) ) or isinstance ( bpe... | Return True if the element is a physical entity . |
17,359 | def _is_catalysis ( bpe ) : if isinstance ( bpe , _bp ( 'Catalysis' ) ) or isinstance ( bpe , _bpimpl ( 'Catalysis' ) ) : return True else : return False | Return True if the element is Catalysis . |
17,360 | def print_statements ( self ) : for i , stmt in enumerate ( self . statements ) : print ( "%s: %s" % ( i , stmt ) ) | Print all INDRA Statements collected by the processors . |
17,361 | def save_model ( self , file_name = None ) : if file_name is None : logger . error ( 'Missing file name' ) return pcc . model_to_owl ( self . model , file_name ) | Save the BioPAX model object in an OWL file . |
17,362 | def eliminate_exact_duplicates ( self ) : self . statements = list ( { stmt . get_hash ( shallow = False , refresh = True ) : stmt for stmt in self . statements } . values ( ) ) | Eliminate Statements that were extracted multiple times . |
17,363 | def get_complexes ( self ) : for obj in self . model . getObjects ( ) . toArray ( ) : bpe = _cast_biopax_element ( obj ) if not _is_complex ( bpe ) : continue ev = self . _get_evidence ( bpe ) members = self . _get_complex_members ( bpe ) if members is not None : if len ( members ) > 10 : logger . debug ( 'Skipping com... | Extract INDRA Complex Statements from the BioPAX model . |
17,364 | def get_modifications ( self ) : for modtype , modclass in modtype_to_modclass . items ( ) : if modtype == 'modification' : continue stmts = self . _get_generic_modification ( modclass ) self . statements += stmts | Extract INDRA Modification Statements from the BioPAX model . |
17,365 | def get_activity_modification ( self ) : mod_filter = 'residue modification, active' for is_active in [ True , False ] : p = self . _construct_modification_pattern ( ) rel = mcct . GAIN if is_active else mcct . LOSS p . add ( mcc ( rel , mod_filter ) , "input simple PE" , "output simple PE" ) s = _bpp ( 'Searcher' ) re... | Extract INDRA ActiveForm statements from the BioPAX model . |
17,366 | def get_regulate_amounts ( self ) : p = pb . controlsExpressionWithTemplateReac ( ) s = _bpp ( 'Searcher' ) res = s . searchPlain ( self . model , p ) res_array = [ _match_to_array ( m ) for m in res . toArray ( ) ] stmts = [ ] for res in res_array : controller = self . _get_agents_from_entity ( res [ 2 ] ) controlled_... | Extract INDRA RegulateAmount Statements from the BioPAX model . |
17,367 | def get_gef ( self ) : p = self . _gef_gap_base ( ) s = _bpp ( 'Searcher' ) res = s . searchPlain ( self . model , p ) res_array = [ _match_to_array ( m ) for m in res . toArray ( ) ] for r in res_array : controller_pe = r [ p . indexOf ( 'controller PE' ) ] input_pe = r [ p . indexOf ( 'input PE' ) ] input_spe = r [ p... | Extract Gef INDRA Statements from the BioPAX model . |
17,368 | def get_gap ( self ) : p = self . _gef_gap_base ( ) s = _bpp ( 'Searcher' ) res = s . searchPlain ( self . model , p ) res_array = [ _match_to_array ( m ) for m in res . toArray ( ) ] for r in res_array : controller_pe = r [ p . indexOf ( 'controller PE' ) ] input_pe = r [ p . indexOf ( 'input PE' ) ] input_spe = r [ p... | Extract Gap INDRA Statements from the BioPAX model . |
17,369 | def _get_entity_mods ( bpe ) : if _is_entity ( bpe ) : features = bpe . getFeature ( ) . toArray ( ) else : features = bpe . getEntityFeature ( ) . toArray ( ) mods = [ ] for feature in features : if not _is_modification ( feature ) : continue mc = BiopaxProcessor . _extract_mod_from_feature ( feature ) if mc is not No... | Get all the modifications of an entity in INDRA format |
17,370 | def _get_generic_modification ( self , mod_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 ] else : mod_gain_const = mcct . GAIN mod_filter = mod_type [ : 5 ] p = BiopaxProcessor . _construct_... | Get all modification reactions given a Modification class . |
17,371 | def _construct_modification_pattern ( ) : p = _bpp ( 'Pattern' ) ( _bpimpl ( 'PhysicalEntity' ) ( ) . getModelInterface ( ) , 'controller PE' ) p . add ( cb . peToControl ( ) , "controller PE" , "Control" ) p . add ( cb . controlToConv ( ) , "Control" , "Conversion" ) p . add ( _bpp ( 'constraint.NOT' ) ( cb . particip... | Construct the BioPAX pattern to extract modification reactions . |
17,372 | def _extract_mod_from_feature ( mf ) : mf_type = mf . getModificationType ( ) if mf_type is None : return None mf_type_terms = mf_type . getTerm ( ) . toArray ( ) known_mf_type = None for t in mf_type_terms : if t . startswith ( 'MOD_RES ' ) : t = t [ 8 : ] mf_type_indra = _mftype_dict . get ( t ) if mf_type_indra is n... | Extract the type of modification and the position from a ModificationFeature object in the INDRA format . |
17,373 | def _get_entref ( bpe ) : if not _is_reference ( bpe ) : try : er = bpe . getEntityReference ( ) except AttributeError : return None return er else : return bpe | Returns the entity reference of an entity if it exists or return the entity reference that was passed in as argument . |
17,374 | def _stmt_location_to_agents ( stmt , location ) : if location is None : return agents = stmt . agent_list ( ) for a in agents : if a is not None : a . location = location | Apply an event location to the Agents in the corresponding Statement . |
17,375 | def get_all_events ( self ) : self . all_events = { } events = self . tree . findall ( 'EVENT' ) events += self . tree . findall ( 'CC' ) for e in events : event_id = e . attrib [ 'id' ] if event_id in self . _static_events : continue event_type = e . find ( 'type' ) . text try : self . all_events [ event_type ] . appe... | Make a list of all events in the TRIPS EKB . |
17,376 | def get_activations ( self ) : 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 event in ( act_events + inact_events ) : event_id = event . attrib [ ... | Extract direct Activation INDRA Statements . |
17,377 | def get_activations_causal ( self ) : ccs = self . tree . findall ( "CC/[type='ONT::CAUSE']" ) for cc in ccs : factor = cc . find ( "arg/[@role=':FACTOR']" ) outcome = cc . find ( "arg/[@role=':OUTCOME']" ) if factor is None or outcome is None : continue factor_id = factor . attrib . get ( 'id' ) factor_term = self . t... | Extract causal Activation INDRA Statements . |
17,378 | def get_activations_stimulate ( self ) : stim_events = self . tree . findall ( "EVENT/[type='ONT::STIMULATE']" ) for event in stim_events : event_id = event . attrib . get ( 'id' ) if event_id in self . _static_events : continue controller = event . find ( "arg1/[@role=':AGENT']" ) affected = event . find ( "arg2/[@rol... | Extract Activation INDRA Statements via stimulation . |
17,379 | def get_degradations ( self ) : 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=':AFFECTED']" ) if affected is None : msg = 'Skipping degradation event with no affected ter... | Extract Degradation INDRA Statements . |
17,380 | def get_complexes ( self ) : 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 : continue arg1 = event . find ( "arg1" ) arg2 = event . find ( "arg2" ) ... | Extract Complex INDRA Statements . |
17,381 | def get_modifications ( self ) : mod_event_types = list ( ont_to_mod_type . keys ( ) ) mod_event_types += [ 'ONT::PTM' ] mod_events = [ ] for mod_event_type in mod_event_types : events = self . tree . findall ( "EVENT/[type='%s']" % mod_event_type ) mod_extracted = self . extracted_events . get ( mod_event_type , [ ] )... | Extract all types of Modification INDRA Statements . |
17,382 | def get_modifications_indirect ( self ) : mod_event_types = list ( ont_to_mod_type . keys ( ) ) mod_event_types += [ 'ONT::PTM' ] def get_increase_events ( mod_event_types ) : mod_events = [ ] events = self . tree . findall ( "EVENT/[type='ONT::INCREASE']" ) for event in events : affected = event . find ( ".//*[@role='... | Extract indirect Modification INDRA Statements . |
17,383 | def get_agents ( self ) : agents_dict = self . get_term_agents ( ) agents = [ a for a in agents_dict . values ( ) if a is not None ] return agents | Return list of INDRA Agents corresponding to TERMs in the EKB . |
17,384 | def get_term_agents ( self ) : terms = self . tree . findall ( 'TERM' ) agents = { } assoc_links = [ ] for term in terms : term_id = term . attrib . get ( 'id' ) if term_id : agent = self . _get_agent_by_id ( term_id , None ) agents [ term_id ] = agent aw = term . find ( 'assoc-with' ) if aw is not None : aw_id = aw . ... | Return dict of INDRA Agents keyed by corresponding TERMs in the EKB . |
17,385 | def _get_evidence_text ( self , event_tag ) : par_id = event_tag . attrib . get ( 'paragraph' ) uttnum = event_tag . attrib . get ( 'uttnum' ) event_text = event_tag . find ( 'text' ) if self . sentences is not None and uttnum is not None : sentence = self . sentences [ uttnum ] elif event_text is not None : sentence =... | Extract the evidence for an event . |
17,386 | def get_causal_edge ( stmt , activates ) : any_contact = any ( evidence . epistemics . get ( 'direct' , False ) for evidence in stmt . evidence ) if any_contact : return pc . DIRECTLY_INCREASES if activates else pc . DIRECTLY_DECREASES return pc . INCREASES if activates else pc . DECREASES | Returns the causal polar edge with the correct contact . |
17,387 | def to_database ( self , manager = None ) : network = pybel . to_database ( self . model , manager = manager ) return network | Send the model to the PyBEL database |
17,388 | def get_binding_site_name ( agent ) : grounding = agent . get_grounding ( ) if grounding != ( None , None ) : uri = hierarchies [ 'entity' ] . get_uri ( grounding [ 0 ] , grounding [ 1 ] ) parents = hierarchies [ 'entity' ] . get_parents ( uri , 'top' ) if parents : parent_uri = sorted ( parents ) [ 0 ] parent_agent = ... | Return a binding site name from a given agent . |
17,389 | def get_mod_site_name ( mod_condition ) : if mod_condition . residue is None : mod_str = abbrevs [ mod_condition . mod_type ] else : mod_str = mod_condition . residue mod_pos = mod_condition . position if mod_condition . position is not None else '' name = ( '%s%s' % ( mod_str , mod_pos ) ) return name | Return site names for a modification . |
17,390 | def process_flat_files ( id_mappings_file , complexes_file = None , ptm_file = None , ppi_file = None , seq_file = None , motif_window = 7 ) : id_df = pd . read_csv ( id_mappings_file , delimiter = '\t' , names = _hprd_id_cols , dtype = 'str' ) id_df = id_df . set_index ( 'HPRD_ID' ) if complexes_file is None and ptm_f... | Get INDRA Statements from HPRD data . |
17,391 | def _gather_active_forms ( self ) : for stmt in self . statements : if isinstance ( stmt , ActiveForm ) : base_agent = self . agent_set . get_create_base_agent ( stmt . agent ) agent_to_add = stmt . agent if stmt . agent . activity : new_agent = fast_deepcopy ( stmt . agent ) new_agent . activity = None agent_to_add = ... | Collect all the active forms of each Agent in the Statements . |
17,392 | def replace_activities ( self ) : logger . debug ( 'Running PySB Preassembler replace activities' ) new_stmts = [ ] def has_agent_activity ( stmt ) : for agent in stmt . agent_list ( ) : if isinstance ( agent , Agent ) and agent . activity is not None : return True return False self . _gather_active_forms ( ) for j , s... | Replace ative flags with Agent states when possible . |
17,393 | def add_reverse_effects ( self ) : pos_mod_sites = { } neg_mod_sites = { } syntheses = [ ] degradations = [ ] for stmt in self . statements : if isinstance ( stmt , Phosphorylation ) : agent = stmt . sub . name try : pos_mod_sites [ agent ] . append ( ( stmt . residue , stmt . position ) ) except KeyError : pos_mod_sit... | Add Statements for the reverse effects of some Statements . |
17,394 | def _get_uniprot_id ( agent ) : up_id = agent . db_refs . get ( 'UP' ) hgnc_id = agent . db_refs . get ( 'HGNC' ) if up_id is None : if hgnc_id is None : return None up_id = hgnc_client . get_uniprot_id ( hgnc_id ) if up_id is None : return None if not isinstance ( up_id , basestring ) and isinstance ( up_id [ 0 ] , ba... | Return the UniProt ID for an agent looking up in HGNC if necessary . |
17,395 | def map_sites ( self , stmts ) : valid_statements = [ ] mapped_statements = [ ] for stmt in stmts : mapped_stmt = self . map_stmt_sites ( stmt ) if mapped_stmt is not None : mapped_statements . append ( mapped_stmt ) else : valid_statements . append ( stmt ) return valid_statements , mapped_statements | Check a set of statements for invalid modification sites . |
17,396 | def _map_agent_sites ( self , agent ) : if agent is None or not agent . mods : return [ ] , agent new_agent = deepcopy ( agent ) mapped_sites = [ ] for idx , mod_condition in enumerate ( agent . mods ) : mapped_site = self . _map_agent_mod ( agent , mod_condition ) if not mapped_site or mapped_site . not_invalid ( ) : ... | Check an agent for invalid sites and update if necessary . |
17,397 | def _map_agent_mod ( self , agent , mod_condition ) : up_id = _get_uniprot_id ( agent ) if not up_id : logger . debug ( "No uniprot ID for %s" % agent . name ) return None if mod_condition . position is None or mod_condition . residue is None : return None mapped_site = self . map_to_human_ref ( up_id , 'uniprot' , mod... | Map a single modification condition on an agent . |
17,398 | def _get_graph_reductions ( graph ) : def frontier ( g , nd ) : if g . out_degree ( nd ) == 0 : return set ( [ nd ] ) else : frontiers = set ( ) for n in g . successors ( nd ) : frontiers = frontiers . union ( frontier ( graph , n ) ) return frontiers reductions = { } nodes_sort = list ( networkx . algorithms . dag . t... | Return transitive reductions on a DAG . |
17,399 | def gather_explicit_activities ( self ) : for stmt in self . statements : agents = stmt . agent_list ( ) for agent in agents : if agent is not None and agent . activity is not None : agent_base = self . _get_base ( agent ) agent_base . add_activity ( agent . activity . activity_type ) if isinstance ( stmt , RegulateAct... | Aggregate all explicit activities and active forms of Agents . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.