repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.find_event_with_outgoing_edges
def find_event_with_outgoing_edges(self, event_name, desired_relations): """Gets a list of event nodes with the specified event_name and outgoing edges annotated with each of the specified relations. Parameters ---------- event_name : str Look for event nodes with th...
python
def find_event_with_outgoing_edges(self, event_name, desired_relations): """Gets a list of event nodes with the specified event_name and outgoing edges annotated with each of the specified relations. Parameters ---------- event_name : str Look for event nodes with th...
[ "def", "find_event_with_outgoing_edges", "(", "self", ",", "event_name", ",", "desired_relations", ")", ":", "G", "=", "self", ".", "G", "desired_relations", "=", "set", "(", "desired_relations", ")", "desired_event_nodes", "=", "[", "]", "for", "node", "in", ...
Gets a list of event nodes with the specified event_name and outgoing edges annotated with each of the specified relations. Parameters ---------- event_name : str Look for event nodes with this name desired_relations : list[str] Look for event nodes with ...
[ "Gets", "a", "list", "of", "event", "nodes", "with", "the", "specified", "event_name", "and", "outgoing", "edges", "annotated", "with", "each", "of", "the", "specified", "relations", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L154-L186
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.get_related_node
def get_related_node(self, node, relation): """Looks for an edge from node to some other node, such that the edge is annotated with the given relation. If there exists such an edge, returns the name of the node it points to. Otherwise, returns None.""" G = self.G for edge in G.ed...
python
def get_related_node(self, node, relation): """Looks for an edge from node to some other node, such that the edge is annotated with the given relation. If there exists such an edge, returns the name of the node it points to. Otherwise, returns None.""" G = self.G for edge in G.ed...
[ "def", "get_related_node", "(", "self", ",", "node", ",", "relation", ")", ":", "G", "=", "self", ".", "G", "for", "edge", "in", "G", ".", "edges", "(", "node", ")", ":", "to", "=", "edge", "[", "1", "]", "to_relation", "=", "G", ".", "edges", ...
Looks for an edge from node to some other node, such that the edge is annotated with the given relation. If there exists such an edge, returns the name of the node it points to. Otherwise, returns None.
[ "Looks", "for", "an", "edge", "from", "node", "to", "some", "other", "node", "such", "that", "the", "edge", "is", "annotated", "with", "the", "given", "relation", ".", "If", "there", "exists", "such", "an", "edge", "returns", "the", "name", "of", "the", ...
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L188-L199
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.get_entity_text_for_relation
def get_entity_text_for_relation(self, node, relation): """Looks for an edge from node to some other node, such that the edge is annotated with the given relation. If there exists such an edge, and the node at the other edge is an entity, return that entity's text. Otherwise, returns Non...
python
def get_entity_text_for_relation(self, node, relation): """Looks for an edge from node to some other node, such that the edge is annotated with the given relation. If there exists such an edge, and the node at the other edge is an entity, return that entity's text. Otherwise, returns Non...
[ "def", "get_entity_text_for_relation", "(", "self", ",", "node", ",", "relation", ")", ":", "G", "=", "self", ".", "G", "related_node", "=", "self", ".", "get_related_node", "(", "node", ",", "relation", ")", "if", "related_node", "is", "not", "None", ":",...
Looks for an edge from node to some other node, such that the edge is annotated with the given relation. If there exists such an edge, and the node at the other edge is an entity, return that entity's text. Otherwise, returns None.
[ "Looks", "for", "an", "edge", "from", "node", "to", "some", "other", "node", "such", "that", "the", "edge", "is", "annotated", "with", "the", "given", "relation", ".", "If", "there", "exists", "such", "an", "edge", "and", "the", "node", "at", "the", "o...
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L201-L215
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.process_increase_expression_amount
def process_increase_expression_amount(self): """Looks for Positive_Regulation events with a specified Cause and a Gene_Expression theme, and processes them into INDRA statements. """ statements = [] pwcs = self.find_event_parent_with_event_child( 'Positive_regul...
python
def process_increase_expression_amount(self): """Looks for Positive_Regulation events with a specified Cause and a Gene_Expression theme, and processes them into INDRA statements. """ statements = [] pwcs = self.find_event_parent_with_event_child( 'Positive_regul...
[ "def", "process_increase_expression_amount", "(", "self", ")", ":", "statements", "=", "[", "]", "pwcs", "=", "self", ".", "find_event_parent_with_event_child", "(", "'Positive_regulation'", ",", "'Gene_expression'", ")", "for", "pair", "in", "pwcs", ":", "pos_reg",...
Looks for Positive_Regulation events with a specified Cause and a Gene_Expression theme, and processes them into INDRA statements.
[ "Looks", "for", "Positive_Regulation", "events", "with", "a", "specified", "Cause", "and", "a", "Gene_Expression", "theme", "and", "processes", "them", "into", "INDRA", "statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L217-L239
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.process_phosphorylation_statements
def process_phosphorylation_statements(self): """Looks for Phosphorylation events in the graph and extracts them into INDRA statements. In particular, looks for a Positive_regulation event node with a child Phosphorylation event node. If Positive_regulation has an outgoing Caus...
python
def process_phosphorylation_statements(self): """Looks for Phosphorylation events in the graph and extracts them into INDRA statements. In particular, looks for a Positive_regulation event node with a child Phosphorylation event node. If Positive_regulation has an outgoing Caus...
[ "def", "process_phosphorylation_statements", "(", "self", ")", ":", "G", "=", "self", ".", "G", "statements", "=", "[", "]", "pwcs", "=", "self", ".", "find_event_parent_with_event_child", "(", "'Positive_regulation'", ",", "'Phosphorylation'", ")", "for", "pair",...
Looks for Phosphorylation events in the graph and extracts them into INDRA statements. In particular, looks for a Positive_regulation event node with a child Phosphorylation event node. If Positive_regulation has an outgoing Cause edge, that's the subject If Phosphorylation has...
[ "Looks", "for", "Phosphorylation", "events", "in", "the", "graph", "and", "extracts", "them", "into", "INDRA", "statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L265-L309
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.process_binding_statements
def process_binding_statements(self): """Looks for Binding events in the graph and extracts them into INDRA statements. In particular, looks for a Binding event node with outgoing edges with relations Theme and Theme2 - the entities these edges point to are the two constituents ...
python
def process_binding_statements(self): """Looks for Binding events in the graph and extracts them into INDRA statements. In particular, looks for a Binding event node with outgoing edges with relations Theme and Theme2 - the entities these edges point to are the two constituents ...
[ "def", "process_binding_statements", "(", "self", ")", ":", "G", "=", "self", ".", "G", "statements", "=", "[", "]", "binding_nodes", "=", "self", ".", "find_event_with_outgoing_edges", "(", "'Binding'", ",", "[", "'Theme'", ",", "'Theme2'", "]", ")", "for",...
Looks for Binding events in the graph and extracts them into INDRA statements. In particular, looks for a Binding event node with outgoing edges with relations Theme and Theme2 - the entities these edges point to are the two constituents of the Complex INDRA statement.
[ "Looks", "for", "Binding", "events", "in", "the", "graph", "and", "extracts", "them", "into", "INDRA", "statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L311-L338
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.node_to_evidence
def node_to_evidence(self, entity_node, is_direct): """Computes an evidence object for a statement. We assume that the entire event happens within a single statement, and get the text of the sentence by getting the text of the sentence containing the provided node that corresponds to on...
python
def node_to_evidence(self, entity_node, is_direct): """Computes an evidence object for a statement. We assume that the entire event happens within a single statement, and get the text of the sentence by getting the text of the sentence containing the provided node that corresponds to on...
[ "def", "node_to_evidence", "(", "self", ",", "entity_node", ",", "is_direct", ")", ":", "# We assume that the entire event is within a single sentence, and", "# get this sentence by getting the sentence containing one of the", "# entities", "sentence_text", "=", "self", ".", "G", ...
Computes an evidence object for a statement. We assume that the entire event happens within a single statement, and get the text of the sentence by getting the text of the sentence containing the provided node that corresponds to one of the entities participanting in the event. ...
[ "Computes", "an", "evidence", "object", "for", "a", "statement", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L340-L375
sorgerlab/indra
indra/sources/tees/processor.py
TEESProcessor.connected_subgraph
def connected_subgraph(self, node): """Returns the subgraph containing the given node, its ancestors, and its descendants. Parameters ---------- node : str We want to create the subgraph containing this node. Returns ------- subgraph : networ...
python
def connected_subgraph(self, node): """Returns the subgraph containing the given node, its ancestors, and its descendants. Parameters ---------- node : str We want to create the subgraph containing this node. Returns ------- subgraph : networ...
[ "def", "connected_subgraph", "(", "self", ",", "node", ")", ":", "G", "=", "self", ".", "G", "subgraph_nodes", "=", "set", "(", ")", "subgraph_nodes", ".", "add", "(", "node", ")", "subgraph_nodes", ".", "update", "(", "dag", ".", "ancestors", "(", "G"...
Returns the subgraph containing the given node, its ancestors, and its descendants. Parameters ---------- node : str We want to create the subgraph containing this node. Returns ------- subgraph : networkx.DiGraph The subgraph containing ...
[ "Returns", "the", "subgraph", "containing", "the", "given", "node", "its", "ancestors", "and", "its", "descendants", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/processor.py#L377-L412
sorgerlab/indra
indra/sources/trips/api.py
process_text
def process_text(text, save_xml_name='trips_output.xml', save_xml_pretty=True, offline=False, service_endpoint='drum'): """Return a TripsProcessor by processing text. Parameters ---------- text : str The text to be processed. save_xml_name : Optional[str] The name o...
python
def process_text(text, save_xml_name='trips_output.xml', save_xml_pretty=True, offline=False, service_endpoint='drum'): """Return a TripsProcessor by processing text. Parameters ---------- text : str The text to be processed. save_xml_name : Optional[str] The name o...
[ "def", "process_text", "(", "text", ",", "save_xml_name", "=", "'trips_output.xml'", ",", "save_xml_pretty", "=", "True", ",", "offline", "=", "False", ",", "service_endpoint", "=", "'drum'", ")", ":", "if", "not", "offline", ":", "html", "=", "client", ".",...
Return a TripsProcessor by processing text. Parameters ---------- text : str The text to be processed. save_xml_name : Optional[str] The name of the file to save the returned TRIPS extraction knowledge base XML. Default: trips_output.xml save_xml_pretty : Optional[bool] ...
[ "Return", "a", "TripsProcessor", "by", "processing", "text", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/api.py#L18-L80
sorgerlab/indra
indra/sources/trips/api.py
process_xml_file
def process_xml_file(file_name): """Return a TripsProcessor by processing a TRIPS EKB XML file. Parameters ---------- file_name : str Path to a TRIPS extraction knowledge base (EKB) file to be processed. Returns ------- tp : TripsProcessor A TripsProcessor containing the ex...
python
def process_xml_file(file_name): """Return a TripsProcessor by processing a TRIPS EKB XML file. Parameters ---------- file_name : str Path to a TRIPS extraction knowledge base (EKB) file to be processed. Returns ------- tp : TripsProcessor A TripsProcessor containing the ex...
[ "def", "process_xml_file", "(", "file_name", ")", ":", "with", "open", "(", "file_name", ",", "'rb'", ")", "as", "fh", ":", "ekb", "=", "fh", ".", "read", "(", ")", ".", "decode", "(", "'utf-8'", ")", "return", "process_xml", "(", "ekb", ")" ]
Return a TripsProcessor by processing a TRIPS EKB XML file. Parameters ---------- file_name : str Path to a TRIPS extraction knowledge base (EKB) file to be processed. Returns ------- tp : TripsProcessor A TripsProcessor containing the extracted INDRA Statements in tp.s...
[ "Return", "a", "TripsProcessor", "by", "processing", "a", "TRIPS", "EKB", "XML", "file", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/api.py#L83-L99
sorgerlab/indra
indra/sources/trips/api.py
process_xml
def process_xml(xml_string): """Return a TripsProcessor by processing a TRIPS EKB XML string. Parameters ---------- xml_string : str A TRIPS extraction knowledge base (EKB) string to be processed. http://trips.ihmc.us/parser/api.html Returns ------- tp : TripsProcessor ...
python
def process_xml(xml_string): """Return a TripsProcessor by processing a TRIPS EKB XML string. Parameters ---------- xml_string : str A TRIPS extraction knowledge base (EKB) string to be processed. http://trips.ihmc.us/parser/api.html Returns ------- tp : TripsProcessor ...
[ "def", "process_xml", "(", "xml_string", ")", ":", "tp", "=", "TripsProcessor", "(", "xml_string", ")", "if", "tp", ".", "tree", "is", "None", ":", "return", "None", "tp", ".", "get_modifications_indirect", "(", ")", "tp", ".", "get_activations_causal", "(",...
Return a TripsProcessor by processing a TRIPS EKB XML string. Parameters ---------- xml_string : str A TRIPS extraction knowledge base (EKB) string to be processed. http://trips.ihmc.us/parser/api.html Returns ------- tp : TripsProcessor A TripsProcessor containing the ...
[ "Return", "a", "TripsProcessor", "by", "processing", "a", "TRIPS", "EKB", "XML", "string", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trips/api.py#L102-L134
sorgerlab/indra
indra/belief/wm_scorer.py
load_eidos_curation_table
def load_eidos_curation_table(): """Return a pandas table of Eidos curation data.""" url = 'https://raw.githubusercontent.com/clulab/eidos/master/' + \ 'src/main/resources/org/clulab/wm/eidos/english/confidence/' + \ 'rule_summary.tsv' # Load the table of scores from the URL above into a dat...
python
def load_eidos_curation_table(): """Return a pandas table of Eidos curation data.""" url = 'https://raw.githubusercontent.com/clulab/eidos/master/' + \ 'src/main/resources/org/clulab/wm/eidos/english/confidence/' + \ 'rule_summary.tsv' # Load the table of scores from the URL above into a dat...
[ "def", "load_eidos_curation_table", "(", ")", ":", "url", "=", "'https://raw.githubusercontent.com/clulab/eidos/master/'", "+", "'src/main/resources/org/clulab/wm/eidos/english/confidence/'", "+", "'rule_summary.tsv'", "# Load the table of scores from the URL above into a data frame", "res...
Return a pandas table of Eidos curation data.
[ "Return", "a", "pandas", "table", "of", "Eidos", "curation", "data", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/wm_scorer.py#L11-L21
sorgerlab/indra
indra/belief/wm_scorer.py
get_eidos_bayesian_scorer
def get_eidos_bayesian_scorer(prior_counts=None): """Return a BayesianScorer based on Eidos curation counts.""" table = load_eidos_curation_table() subtype_counts = {'eidos': {r: [c, i] for r, c, i in zip(table['RULE'], table['Num correct'], ta...
python
def get_eidos_bayesian_scorer(prior_counts=None): """Return a BayesianScorer based on Eidos curation counts.""" table = load_eidos_curation_table() subtype_counts = {'eidos': {r: [c, i] for r, c, i in zip(table['RULE'], table['Num correct'], ta...
[ "def", "get_eidos_bayesian_scorer", "(", "prior_counts", "=", "None", ")", ":", "table", "=", "load_eidos_curation_table", "(", ")", "subtype_counts", "=", "{", "'eidos'", ":", "{", "r", ":", "[", "c", ",", "i", "]", "for", "r", ",", "c", ",", "i", "in...
Return a BayesianScorer based on Eidos curation counts.
[ "Return", "a", "BayesianScorer", "based", "on", "Eidos", "curation", "counts", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/wm_scorer.py#L24-L35
sorgerlab/indra
indra/belief/wm_scorer.py
get_eidos_scorer
def get_eidos_scorer(): """Return a SimpleScorer based on Eidos curated precision estimates.""" table = load_eidos_curation_table() # Get the overall precision total_num = table['COUNT of RULE'].sum() weighted_sum = table['COUNT of RULE'].dot(table['% correct']) precision = weighted_sum / total...
python
def get_eidos_scorer(): """Return a SimpleScorer based on Eidos curated precision estimates.""" table = load_eidos_curation_table() # Get the overall precision total_num = table['COUNT of RULE'].sum() weighted_sum = table['COUNT of RULE'].dot(table['% correct']) precision = weighted_sum / total...
[ "def", "get_eidos_scorer", "(", ")", ":", "table", "=", "load_eidos_curation_table", "(", ")", "# Get the overall precision", "total_num", "=", "table", "[", "'COUNT of RULE'", "]", ".", "sum", "(", ")", "weighted_sum", "=", "table", "[", "'COUNT of RULE'", "]", ...
Return a SimpleScorer based on Eidos curated precision estimates.
[ "Return", "a", "SimpleScorer", "based", "on", "Eidos", "curated", "precision", "estimates", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/belief/wm_scorer.py#L38-L57
sorgerlab/indra
indra/sources/trrust/api.py
process_from_web
def process_from_web(): """Return a TrrustProcessor based on the online interaction table. Returns ------- TrrustProcessor A TrrustProcessor object that has a list of INDRA Statements in its statements attribute. """ logger.info('Downloading table from %s' % trrust_human_url) ...
python
def process_from_web(): """Return a TrrustProcessor based on the online interaction table. Returns ------- TrrustProcessor A TrrustProcessor object that has a list of INDRA Statements in its statements attribute. """ logger.info('Downloading table from %s' % trrust_human_url) ...
[ "def", "process_from_web", "(", ")", ":", "logger", ".", "info", "(", "'Downloading table from %s'", "%", "trrust_human_url", ")", "res", "=", "requests", ".", "get", "(", "trrust_human_url", ")", "res", ".", "raise_for_status", "(", ")", "df", "=", "pandas", ...
Return a TrrustProcessor based on the online interaction table. Returns ------- TrrustProcessor A TrrustProcessor object that has a list of INDRA Statements in its statements attribute.
[ "Return", "a", "TrrustProcessor", "based", "on", "the", "online", "interaction", "table", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/trrust/api.py#L18-L33
sorgerlab/indra
indra/sources/rlimsp/api.py
process_from_webservice
def process_from_webservice(id_val, id_type='pmcid', source='pmc', with_grounding=True): """Return an output from RLIMS-p for the given PubMed ID or PMC ID. Parameters ---------- id_val : str A PMCID, with the prefix PMC, or pmid, with no prefix, of the paper to ...
python
def process_from_webservice(id_val, id_type='pmcid', source='pmc', with_grounding=True): """Return an output from RLIMS-p for the given PubMed ID or PMC ID. Parameters ---------- id_val : str A PMCID, with the prefix PMC, or pmid, with no prefix, of the paper to ...
[ "def", "process_from_webservice", "(", "id_val", ",", "id_type", "=", "'pmcid'", ",", "source", "=", "'pmc'", ",", "with_grounding", "=", "True", ")", ":", "if", "with_grounding", ":", "fmt", "=", "'%s.normed/%s/%s'", "else", ":", "fmt", "=", "'%s/%s/%s'", "...
Return an output from RLIMS-p for the given PubMed ID or PMC ID. Parameters ---------- id_val : str A PMCID, with the prefix PMC, or pmid, with no prefix, of the paper to be "read". id_type : str Either 'pmid' or 'pmcid'. The default is 'pmcid'. source : str Either '...
[ "Return", "an", "output", "from", "RLIMS", "-", "p", "for", "the", "given", "PubMed", "ID", "or", "PMC", "ID", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/rlimsp/api.py#L21-L59
sorgerlab/indra
indra/sources/rlimsp/api.py
process_from_json_file
def process_from_json_file(filename, doc_id_type=None): """Process RLIMSP extractions from a bulk-download JSON file. Parameters ---------- filename : str Path to the JSON file. doc_id_type : Optional[str] In some cases the RLIMS-P paragraph info doesn't contain 'pmid' or 'p...
python
def process_from_json_file(filename, doc_id_type=None): """Process RLIMSP extractions from a bulk-download JSON file. Parameters ---------- filename : str Path to the JSON file. doc_id_type : Optional[str] In some cases the RLIMS-P paragraph info doesn't contain 'pmid' or 'p...
[ "def", "process_from_json_file", "(", "filename", ",", "doc_id_type", "=", "None", ")", ":", "with", "open", "(", "filename", ",", "'rt'", ")", "as", "f", ":", "lines", "=", "f", ".", "readlines", "(", ")", "json_list", "=", "[", "]", "for", "line", ...
Process RLIMSP extractions from a bulk-download JSON file. Parameters ---------- filename : str Path to the JSON file. doc_id_type : Optional[str] In some cases the RLIMS-P paragraph info doesn't contain 'pmid' or 'pmcid' explicitly, instead if contains a 'docId' key. This param...
[ "Process", "RLIMSP", "extractions", "from", "a", "bulk", "-", "download", "JSON", "file", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/rlimsp/api.py#L62-L88
sorgerlab/indra
indra/util/nested_dict.py
NestedDict.export_dict
def export_dict(self): "Convert this into an ordinary dict (of dicts)." return {k: v.export_dict() if isinstance(v, self.__class__) else v for k, v in self.items()}
python
def export_dict(self): "Convert this into an ordinary dict (of dicts)." return {k: v.export_dict() if isinstance(v, self.__class__) else v for k, v in self.items()}
[ "def", "export_dict", "(", "self", ")", ":", "return", "{", "k", ":", "v", ".", "export_dict", "(", ")", "if", "isinstance", "(", "v", ",", "self", ".", "__class__", ")", "else", "v", "for", "k", ",", "v", "in", "self", ".", "items", "(", ")", ...
Convert this into an ordinary dict (of dicts).
[ "Convert", "this", "into", "an", "ordinary", "dict", "(", "of", "dicts", ")", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L53-L56
sorgerlab/indra
indra/util/nested_dict.py
NestedDict.get
def get(self, key): "Find the first value within the tree which has the key." if key in self.keys(): return self[key] else: res = None for v in self.values(): # This could get weird if the actual expected returned value # is Non...
python
def get(self, key): "Find the first value within the tree which has the key." if key in self.keys(): return self[key] else: res = None for v in self.values(): # This could get weird if the actual expected returned value # is Non...
[ "def", "get", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "keys", "(", ")", ":", "return", "self", "[", "key", "]", "else", ":", "res", "=", "None", "for", "v", "in", "self", ".", "values", "(", ")", ":", "# This could ge...
Find the first value within the tree which has the key.
[ "Find", "the", "first", "value", "within", "the", "tree", "which", "has", "the", "key", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L58-L72
sorgerlab/indra
indra/util/nested_dict.py
NestedDict.get_path
def get_path(self, key): "Like `get`, but also return the path taken to the value." if key in self.keys(): return (key,), self[key] else: key_path, res = (None, None) for sub_key, v in self.items(): if isinstance(v, self.__class__): ...
python
def get_path(self, key): "Like `get`, but also return the path taken to the value." if key in self.keys(): return (key,), self[key] else: key_path, res = (None, None) for sub_key, v in self.items(): if isinstance(v, self.__class__): ...
[ "def", "get_path", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "keys", "(", ")", ":", "return", "(", "key", ",", ")", ",", "self", "[", "key", "]", "else", ":", "key_path", ",", "res", "=", "(", "None", ",", "None", ")"...
Like `get`, but also return the path taken to the value.
[ "Like", "get", "but", "also", "return", "the", "path", "taken", "to", "the", "value", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L74-L89
sorgerlab/indra
indra/util/nested_dict.py
NestedDict.gets
def gets(self, key): "Like `get`, but return all matches, not just the first." result_list = [] if key in self.keys(): result_list.append(self[key]) for v in self.values(): if isinstance(v, self.__class__): sub_res_list = v.gets(key) ...
python
def gets(self, key): "Like `get`, but return all matches, not just the first." result_list = [] if key in self.keys(): result_list.append(self[key]) for v in self.values(): if isinstance(v, self.__class__): sub_res_list = v.gets(key) ...
[ "def", "gets", "(", "self", ",", "key", ")", ":", "result_list", "=", "[", "]", "if", "key", "in", "self", ".", "keys", "(", ")", ":", "result_list", ".", "append", "(", "self", "[", "key", "]", ")", "for", "v", "in", "self", ".", "values", "("...
Like `get`, but return all matches, not just the first.
[ "Like", "get", "but", "return", "all", "matches", "not", "just", "the", "first", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L91-L104
sorgerlab/indra
indra/util/nested_dict.py
NestedDict.get_paths
def get_paths(self, key): "Like `gets`, but include the paths, like `get_path` for all matches." result_list = [] if key in self.keys(): result_list.append(((key,), self[key])) for sub_key, v in self.items(): if isinstance(v, self.__class__): sub_r...
python
def get_paths(self, key): "Like `gets`, but include the paths, like `get_path` for all matches." result_list = [] if key in self.keys(): result_list.append(((key,), self[key])) for sub_key, v in self.items(): if isinstance(v, self.__class__): sub_r...
[ "def", "get_paths", "(", "self", ",", "key", ")", ":", "result_list", "=", "[", "]", "if", "key", "in", "self", ".", "keys", "(", ")", ":", "result_list", ".", "append", "(", "(", "(", "key", ",", ")", ",", "self", "[", "key", "]", ")", ")", ...
Like `gets`, but include the paths, like `get_path` for all matches.
[ "Like", "gets", "but", "include", "the", "paths", "like", "get_path", "for", "all", "matches", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L106-L119
sorgerlab/indra
indra/util/nested_dict.py
NestedDict.get_leaves
def get_leaves(self): """Get the deepest entries as a flat set.""" ret_set = set() for val in self.values(): if isinstance(val, self.__class__): ret_set |= val.get_leaves() elif isinstance(val, dict): ret_set |= set(val.values()) ...
python
def get_leaves(self): """Get the deepest entries as a flat set.""" ret_set = set() for val in self.values(): if isinstance(val, self.__class__): ret_set |= val.get_leaves() elif isinstance(val, dict): ret_set |= set(val.values()) ...
[ "def", "get_leaves", "(", "self", ")", ":", "ret_set", "=", "set", "(", ")", "for", "val", "in", "self", ".", "values", "(", ")", ":", "if", "isinstance", "(", "val", ",", "self", ".", "__class__", ")", ":", "ret_set", "|=", "val", ".", "get_leaves...
Get the deepest entries as a flat set.
[ "Get", "the", "deepest", "entries", "as", "a", "flat", "set", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/nested_dict.py#L121-L135
sorgerlab/indra
indra/sources/reach/processor.py
_read_reach_rule_regexps
def _read_reach_rule_regexps(): """Load in a file with the regular expressions corresponding to each reach rule. Why regular expression matching? The rule name in found_by has instances of some reach rules for each possible event type (activation, binding, etc). This makes for too many different typ...
python
def _read_reach_rule_regexps(): """Load in a file with the regular expressions corresponding to each reach rule. Why regular expression matching? The rule name in found_by has instances of some reach rules for each possible event type (activation, binding, etc). This makes for too many different typ...
[ "def", "_read_reach_rule_regexps", "(", ")", ":", "reach_rule_filename", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "'reach_rule_regexps.txt'", ")", ...
Load in a file with the regular expressions corresponding to each reach rule. Why regular expression matching? The rule name in found_by has instances of some reach rules for each possible event type (activation, binding, etc). This makes for too many different types of rules for practical curation ...
[ "Load", "in", "a", "file", "with", "the", "regular", "expressions", "corresponding", "to", "each", "reach", "rule", ".", "Why", "regular", "expression", "matching?", "The", "rule", "name", "in", "found_by", "has", "instances", "of", "some", "reach", "rules", ...
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L812-L829
sorgerlab/indra
indra/sources/reach/processor.py
determine_reach_subtype
def determine_reach_subtype(event_name): """Returns the category of reach rule from the reach rule instance. Looks at a list of regular expressions corresponding to reach rule types, and returns the longest regexp that matches, or None if none of them match. Parameters ---------- evidence ...
python
def determine_reach_subtype(event_name): """Returns the category of reach rule from the reach rule instance. Looks at a list of regular expressions corresponding to reach rule types, and returns the longest regexp that matches, or None if none of them match. Parameters ---------- evidence ...
[ "def", "determine_reach_subtype", "(", "event_name", ")", ":", "best_match_length", "=", "None", "best_match", "=", "None", "for", "ss", "in", "reach_rule_regexps", ":", "if", "re", ".", "search", "(", "ss", ",", "event_name", ")", ":", "if", "best_match", "...
Returns the category of reach rule from the reach rule instance. Looks at a list of regular expressions corresponding to reach rule types, and returns the longest regexp that matches, or None if none of them match. Parameters ---------- evidence : indra.statements.Evidence A reach evid...
[ "Returns", "the", "category", "of", "reach", "rule", "from", "the", "reach", "rule", "instance", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L835-L862
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor.print_event_statistics
def print_event_statistics(self): """Print the number of events in the REACH output by type.""" logger.info('All events by type') logger.info('-------------------') for k, v in self.all_events.items(): logger.info('%s, %s' % (k, len(v))) logger.info('-----------------...
python
def print_event_statistics(self): """Print the number of events in the REACH output by type.""" logger.info('All events by type') logger.info('-------------------') for k, v in self.all_events.items(): logger.info('%s, %s' % (k, len(v))) logger.info('-----------------...
[ "def", "print_event_statistics", "(", "self", ")", ":", "logger", ".", "info", "(", "'All events by type'", ")", "logger", ".", "info", "(", "'-------------------'", ")", "for", "k", ",", "v", "in", "self", ".", "all_events", ".", "items", "(", ")", ":", ...
Print the number of events in the REACH output by type.
[ "Print", "the", "number", "of", "events", "in", "the", "REACH", "output", "by", "type", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L52-L58
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor.get_all_events
def get_all_events(self): """Gather all event IDs in the REACH output by type. These IDs are stored in the self.all_events dict. """ self.all_events = {} events = self.tree.execute("$.events.frames") if events is None: return for e in events: ...
python
def get_all_events(self): """Gather all event IDs in the REACH output by type. These IDs are stored in the self.all_events dict. """ self.all_events = {} events = self.tree.execute("$.events.frames") if events is None: return for e in events: ...
[ "def", "get_all_events", "(", "self", ")", ":", "self", ".", "all_events", "=", "{", "}", "events", "=", "self", ".", "tree", ".", "execute", "(", "\"$.events.frames\"", ")", "if", "events", "is", "None", ":", "return", "for", "e", "in", "events", ":",...
Gather all event IDs in the REACH output by type. These IDs are stored in the self.all_events dict.
[ "Gather", "all", "event", "IDs", "in", "the", "REACH", "output", "by", "type", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L60-L75
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor.get_modifications
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...
python
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...
[ "def", "get_modifications", "(", "self", ")", ":", "# 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", "i...
Extract Modification INDRA Statements.
[ "Extract", "Modification", "INDRA", "Statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L87-L173
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor.get_regulate_amounts
def get_regulate_amounts(self): """Extract RegulateAmount INDRA Statements.""" qstr = "$.events.frames[(@.type is 'transcription')]" res = self.tree.execute(qstr) all_res = [] if res is not None: all_res += list(res) qstr = "$.events.frames[(@.type is 'amount'...
python
def get_regulate_amounts(self): """Extract RegulateAmount INDRA Statements.""" qstr = "$.events.frames[(@.type is 'transcription')]" res = self.tree.execute(qstr) all_res = [] if res is not None: all_res += list(res) qstr = "$.events.frames[(@.type is 'amount'...
[ "def", "get_regulate_amounts", "(", "self", ")", ":", "qstr", "=", "\"$.events.frames[(@.type is 'transcription')]\"", "res", "=", "self", ".", "tree", ".", "execute", "(", "qstr", ")", "all_res", "=", "[", "]", "if", "res", "is", "not", "None", ":", "all_re...
Extract RegulateAmount INDRA Statements.
[ "Extract", "RegulateAmount", "INDRA", "Statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L175-L224
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor.get_complexes
def get_complexes(self): """Extract INDRA Complex Statements.""" qstr = "$.events.frames[@.type is 'complex-assembly']" res = self.tree.execute(qstr) if res is None: return for r in res: epistemics = self._get_epistemics(r) if epistemics.get('...
python
def get_complexes(self): """Extract INDRA Complex Statements.""" qstr = "$.events.frames[@.type is 'complex-assembly']" res = self.tree.execute(qstr) if res is None: return for r in res: epistemics = self._get_epistemics(r) if epistemics.get('...
[ "def", "get_complexes", "(", "self", ")", ":", "qstr", "=", "\"$.events.frames[@.type is 'complex-assembly']\"", "res", "=", "self", ".", "tree", ".", "execute", "(", "qstr", ")", "if", "res", "is", "None", ":", "return", "for", "r", "in", "res", ":", "epi...
Extract INDRA Complex Statements.
[ "Extract", "INDRA", "Complex", "Statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L226-L258
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor.get_activation
def get_activation(self): """Extract INDRA Activation Statements.""" qstr = "$.events.frames[@.type is 'activation']" res = self.tree.execute(qstr) if res is None: return for r in res: epistemics = self._get_epistemics(r) if epistemics.get('neg...
python
def get_activation(self): """Extract INDRA Activation Statements.""" qstr = "$.events.frames[@.type is 'activation']" res = self.tree.execute(qstr) if res is None: return for r in res: epistemics = self._get_epistemics(r) if epistemics.get('neg...
[ "def", "get_activation", "(", "self", ")", ":", "qstr", "=", "\"$.events.frames[@.type is 'activation']\"", "res", "=", "self", ".", "tree", ".", "execute", "(", "qstr", ")", "if", "res", "is", "None", ":", "return", "for", "r", "in", "res", ":", "epistemi...
Extract INDRA Activation Statements.
[ "Extract", "INDRA", "Activation", "Statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L260-L292
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor.get_translocation
def get_translocation(self): """Extract INDRA Translocation Statements.""" qstr = "$.events.frames[@.type is 'translocation']" res = self.tree.execute(qstr) if res is None: return for r in res: epistemics = self._get_epistemics(r) if epistemics...
python
def get_translocation(self): """Extract INDRA Translocation Statements.""" qstr = "$.events.frames[@.type is 'translocation']" res = self.tree.execute(qstr) if res is None: return for r in res: epistemics = self._get_epistemics(r) if epistemics...
[ "def", "get_translocation", "(", "self", ")", ":", "qstr", "=", "\"$.events.frames[@.type is 'translocation']\"", "res", "=", "self", ".", "tree", ".", "execute", "(", "qstr", ")", "if", "res", "is", "None", ":", "return", "for", "r", "in", "res", ":", "ep...
Extract INDRA Translocation Statements.
[ "Extract", "INDRA", "Translocation", "Statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L294-L324
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor._get_mod_conditions
def _get_mod_conditions(self, mod_term): """Return a list of ModConditions given a mod term dict.""" site = mod_term.get('site') if site is not None: mods = self._parse_site_text(site) else: mods = [Site(None, None)] mcs = [] for mod in mods: ...
python
def _get_mod_conditions(self, mod_term): """Return a list of ModConditions given a mod term dict.""" site = mod_term.get('site') if site is not None: mods = self._parse_site_text(site) else: mods = [Site(None, None)] mcs = [] for mod in mods: ...
[ "def", "_get_mod_conditions", "(", "self", ",", "mod_term", ")", ":", "site", "=", "mod_term", ".", "get", "(", "'site'", ")", "if", "site", "is", "not", "None", ":", "mods", "=", "self", ".", "_parse_site_text", "(", "site", ")", "else", ":", "mods", ...
Return a list of ModConditions given a mod term dict.
[ "Return", "a", "list", "of", "ModConditions", "given", "a", "mod", "term", "dict", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L469-L489
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor._get_entity_coordinates
def _get_entity_coordinates(self, entity_term): """Return sentence coordinates for a given entity. Given an entity term return the associated sentence coordinates as a tuple of the form (int, int). Returns None if for any reason the sentence coordinates cannot be found. """ ...
python
def _get_entity_coordinates(self, entity_term): """Return sentence coordinates for a given entity. Given an entity term return the associated sentence coordinates as a tuple of the form (int, int). Returns None if for any reason the sentence coordinates cannot be found. """ ...
[ "def", "_get_entity_coordinates", "(", "self", ",", "entity_term", ")", ":", "# The following lines get the starting coordinate of the sentence", "# containing the entity.", "sent_id", "=", "entity_term", ".", "get", "(", "'sentence'", ")", "if", "sent_id", "is", "None", ...
Return sentence coordinates for a given entity. Given an entity term return the associated sentence coordinates as a tuple of the form (int, int). Returns None if for any reason the sentence coordinates cannot be found.
[ "Return", "sentence", "coordinates", "for", "a", "given", "entity", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L491-L529
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor._get_section
def _get_section(self, event): """Get the section of the paper that the event is from.""" sentence_id = event.get('sentence') section = None if sentence_id: qstr = "$.sentences.frames[(@.frame_id is \'%s\')]" % sentence_id res = self.tree.execute(qstr) ...
python
def _get_section(self, event): """Get the section of the paper that the event is from.""" sentence_id = event.get('sentence') section = None if sentence_id: qstr = "$.sentences.frames[(@.frame_id is \'%s\')]" % sentence_id res = self.tree.execute(qstr) ...
[ "def", "_get_section", "(", "self", ",", "event", ")", ":", "sentence_id", "=", "event", ".", "get", "(", "'sentence'", ")", "section", "=", "None", "if", "sentence_id", ":", "qstr", "=", "\"$.sentences.frames[(@.frame_id is \\'%s\\')]\"", "%", "sentence_id", "r...
Get the section of the paper that the event is from.
[ "Get", "the", "section", "of", "the", "paper", "that", "the", "event", "is", "from", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L610-L644
sorgerlab/indra
indra/sources/reach/processor.py
ReachProcessor._get_controller_agent
def _get_controller_agent(self, arg): """Return a single or a complex controller agent.""" controller_agent = None controller = arg.get('arg') # There is either a single controller here if controller is not None: controller_agent, coords = self._get_agent_from_entity(...
python
def _get_controller_agent(self, arg): """Return a single or a complex controller agent.""" controller_agent = None controller = arg.get('arg') # There is either a single controller here if controller is not None: controller_agent, coords = self._get_agent_from_entity(...
[ "def", "_get_controller_agent", "(", "self", ",", "arg", ")", ":", "controller_agent", "=", "None", "controller", "=", "arg", ".", "get", "(", "'arg'", ")", "# There is either a single controller here", "if", "controller", "is", "not", "None", ":", "controller_age...
Return a single or a complex controller agent.
[ "Return", "a", "single", "or", "a", "complex", "controller", "agent", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/processor.py#L646-L663
sorgerlab/indra
indra/sources/eidos/processor.py
_sanitize
def _sanitize(text): """Return sanitized Eidos text field for human readability.""" d = {'-LRB-': '(', '-RRB-': ')'} return re.sub('|'.join(d.keys()), lambda m: d[m.group(0)], text)
python
def _sanitize(text): """Return sanitized Eidos text field for human readability.""" d = {'-LRB-': '(', '-RRB-': ')'} return re.sub('|'.join(d.keys()), lambda m: d[m.group(0)], text)
[ "def", "_sanitize", "(", "text", ")", ":", "d", "=", "{", "'-LRB-'", ":", "'('", ",", "'-RRB-'", ":", "')'", "}", "return", "re", ".", "sub", "(", "'|'", ".", "join", "(", "d", ".", "keys", "(", ")", ")", ",", "lambda", "m", ":", "d", "[", ...
Return sanitized Eidos text field for human readability.
[ "Return", "sanitized", "Eidos", "text", "field", "for", "human", "readability", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L380-L383
sorgerlab/indra
indra/sources/eidos/processor.py
_get_time_stamp
def _get_time_stamp(entry): """Return datetime object from a timex constraint start/end entry. Example string format to convert: 2018-01-01T00:00 """ if not entry or entry == 'Undef': return None try: dt = datetime.datetime.strptime(entry, '%Y-%m-%dT%H:%M') except Exception as e...
python
def _get_time_stamp(entry): """Return datetime object from a timex constraint start/end entry. Example string format to convert: 2018-01-01T00:00 """ if not entry or entry == 'Undef': return None try: dt = datetime.datetime.strptime(entry, '%Y-%m-%dT%H:%M') except Exception as e...
[ "def", "_get_time_stamp", "(", "entry", ")", ":", "if", "not", "entry", "or", "entry", "==", "'Undef'", ":", "return", "None", "try", ":", "dt", "=", "datetime", ".", "datetime", ".", "strptime", "(", "entry", ",", "'%Y-%m-%dT%H:%M'", ")", "except", "Exc...
Return datetime object from a timex constraint start/end entry. Example string format to convert: 2018-01-01T00:00
[ "Return", "datetime", "object", "from", "a", "timex", "constraint", "start", "/", "end", "entry", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L386-L398
sorgerlab/indra
indra/sources/eidos/processor.py
ref_context_from_geoloc
def ref_context_from_geoloc(geoloc): """Return a RefContext object given a geoloc entry.""" text = geoloc.get('text') geoid = geoloc.get('geoID') rc = RefContext(name=text, db_refs={'GEOID': geoid}) return rc
python
def ref_context_from_geoloc(geoloc): """Return a RefContext object given a geoloc entry.""" text = geoloc.get('text') geoid = geoloc.get('geoID') rc = RefContext(name=text, db_refs={'GEOID': geoid}) return rc
[ "def", "ref_context_from_geoloc", "(", "geoloc", ")", ":", "text", "=", "geoloc", ".", "get", "(", "'text'", ")", "geoid", "=", "geoloc", ".", "get", "(", "'geoID'", ")", "rc", "=", "RefContext", "(", "name", "=", "text", ",", "db_refs", "=", "{", "'...
Return a RefContext object given a geoloc entry.
[ "Return", "a", "RefContext", "object", "given", "a", "geoloc", "entry", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L401-L406
sorgerlab/indra
indra/sources/eidos/processor.py
time_context_from_timex
def time_context_from_timex(timex): """Return a TimeContext object given a timex entry.""" time_text = timex.get('text') constraint = timex['intervals'][0] start = _get_time_stamp(constraint.get('start')) end = _get_time_stamp(constraint.get('end')) duration = constraint['duration'] tc = Tim...
python
def time_context_from_timex(timex): """Return a TimeContext object given a timex entry.""" time_text = timex.get('text') constraint = timex['intervals'][0] start = _get_time_stamp(constraint.get('start')) end = _get_time_stamp(constraint.get('end')) duration = constraint['duration'] tc = Tim...
[ "def", "time_context_from_timex", "(", "timex", ")", ":", "time_text", "=", "timex", ".", "get", "(", "'text'", ")", "constraint", "=", "timex", "[", "'intervals'", "]", "[", "0", "]", "start", "=", "_get_time_stamp", "(", "constraint", ".", "get", "(", ...
Return a TimeContext object given a timex entry.
[ "Return", "a", "TimeContext", "object", "given", "a", "timex", "entry", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L409-L418
sorgerlab/indra
indra/sources/eidos/processor.py
find_args
def find_args(event, arg_type): """Return IDs of all arguments of a given type""" args = event.get('arguments', {}) obj_tags = [arg for arg in args if arg['type'] == arg_type] if obj_tags: return [o['value']['@id'] for o in obj_tags] else: return []
python
def find_args(event, arg_type): """Return IDs of all arguments of a given type""" args = event.get('arguments', {}) obj_tags = [arg for arg in args if arg['type'] == arg_type] if obj_tags: return [o['value']['@id'] for o in obj_tags] else: return []
[ "def", "find_args", "(", "event", ",", "arg_type", ")", ":", "args", "=", "event", ".", "get", "(", "'arguments'", ",", "{", "}", ")", "obj_tags", "=", "[", "arg", "for", "arg", "in", "args", "if", "arg", "[", "'type'", "]", "==", "arg_type", "]", ...
Return IDs of all arguments of a given type
[ "Return", "IDs", "of", "all", "arguments", "of", "a", "given", "type" ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L430-L437
sorgerlab/indra
indra/sources/eidos/processor.py
EidosProcessor.extract_causal_relations
def extract_causal_relations(self): """Extract causal relations as Statements.""" # Get the extractions that are labeled as directed and causal relations = [e for e in self.doc.extractions if 'DirectedRelation' in e['labels'] and 'Causal' in e['labels']]...
python
def extract_causal_relations(self): """Extract causal relations as Statements.""" # Get the extractions that are labeled as directed and causal relations = [e for e in self.doc.extractions if 'DirectedRelation' in e['labels'] and 'Causal' in e['labels']]...
[ "def", "extract_causal_relations", "(", "self", ")", ":", "# Get the extractions that are labeled as directed and causal", "relations", "=", "[", "e", "for", "e", "in", "self", ".", "doc", ".", "extractions", "if", "'DirectedRelation'", "in", "e", "[", "'labels'", "...
Extract causal relations as Statements.
[ "Extract", "causal", "relations", "as", "Statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L27-L38
sorgerlab/indra
indra/sources/eidos/processor.py
EidosProcessor.get_evidence
def get_evidence(self, relation): """Return the Evidence object for the INDRA Statment.""" provenance = relation.get('provenance') # First try looking up the full sentence through provenance text = None context = None if provenance: sentence_tag = provenance[...
python
def get_evidence(self, relation): """Return the Evidence object for the INDRA Statment.""" provenance = relation.get('provenance') # First try looking up the full sentence through provenance text = None context = None if provenance: sentence_tag = provenance[...
[ "def", "get_evidence", "(", "self", ",", "relation", ")", ":", "provenance", "=", "relation", ".", "get", "(", "'provenance'", ")", "# First try looking up the full sentence through provenance", "text", "=", "None", "context", "=", "None", "if", "provenance", ":", ...
Return the Evidence object for the INDRA Statment.
[ "Return", "the", "Evidence", "object", "for", "the", "INDRA", "Statment", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L119-L181
sorgerlab/indra
indra/sources/eidos/processor.py
EidosProcessor.get_negation
def get_negation(event): """Return negation attached to an event. Example: "states": [{"@type": "State", "type": "NEGATION", "text": "n't"}] """ states = event.get('states', []) if not states: return [] negs = [state for state in ...
python
def get_negation(event): """Return negation attached to an event. Example: "states": [{"@type": "State", "type": "NEGATION", "text": "n't"}] """ states = event.get('states', []) if not states: return [] negs = [state for state in ...
[ "def", "get_negation", "(", "event", ")", ":", "states", "=", "event", ".", "get", "(", "'states'", ",", "[", "]", ")", "if", "not", "states", ":", "return", "[", "]", "negs", "=", "[", "state", "for", "state", "in", "states", "if", "state", ".", ...
Return negation attached to an event. Example: "states": [{"@type": "State", "type": "NEGATION", "text": "n't"}]
[ "Return", "negation", "attached", "to", "an", "event", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L184-L196
sorgerlab/indra
indra/sources/eidos/processor.py
EidosProcessor.get_hedging
def get_hedging(event): """Return hedging markers attached to an event. Example: "states": [{"@type": "State", "type": "HEDGE", "text": "could"} """ states = event.get('states', []) if not states: return [] hedgings = [state for s...
python
def get_hedging(event): """Return hedging markers attached to an event. Example: "states": [{"@type": "State", "type": "HEDGE", "text": "could"} """ states = event.get('states', []) if not states: return [] hedgings = [state for s...
[ "def", "get_hedging", "(", "event", ")", ":", "states", "=", "event", ".", "get", "(", "'states'", ",", "[", "]", ")", "if", "not", "states", ":", "return", "[", "]", "hedgings", "=", "[", "state", "for", "state", "in", "states", "if", "state", "."...
Return hedging markers attached to an event. Example: "states": [{"@type": "State", "type": "HEDGE", "text": "could"}
[ "Return", "hedging", "markers", "attached", "to", "an", "event", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L199-L211
sorgerlab/indra
indra/sources/eidos/processor.py
EidosProcessor.get_groundings
def get_groundings(entity): """Return groundings as db_refs for an entity.""" def get_grounding_entries(grounding): if not grounding: return None entries = [] values = grounding.get('values', []) # Values could still have been a None entry...
python
def get_groundings(entity): """Return groundings as db_refs for an entity.""" def get_grounding_entries(grounding): if not grounding: return None entries = [] values = grounding.get('values', []) # Values could still have been a None entry...
[ "def", "get_groundings", "(", "entity", ")", ":", "def", "get_grounding_entries", "(", "grounding", ")", ":", "if", "not", "grounding", ":", "return", "None", "entries", "=", "[", "]", "values", "=", "grounding", ".", "get", "(", "'values'", ",", "[", "]...
Return groundings as db_refs for an entity.
[ "Return", "groundings", "as", "db_refs", "for", "an", "entity", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L243-L276
sorgerlab/indra
indra/sources/eidos/processor.py
EidosProcessor.get_concept
def get_concept(entity): """Return Concept from an Eidos entity.""" # Use the canonical name as the name of the Concept name = entity['canonicalName'] db_refs = EidosProcessor.get_groundings(entity) concept = Concept(name, db_refs=db_refs) return concept
python
def get_concept(entity): """Return Concept from an Eidos entity.""" # Use the canonical name as the name of the Concept name = entity['canonicalName'] db_refs = EidosProcessor.get_groundings(entity) concept = Concept(name, db_refs=db_refs) return concept
[ "def", "get_concept", "(", "entity", ")", ":", "# Use the canonical name as the name of the Concept", "name", "=", "entity", "[", "'canonicalName'", "]", "db_refs", "=", "EidosProcessor", ".", "get_groundings", "(", "entity", ")", "concept", "=", "Concept", "(", "na...
Return Concept from an Eidos entity.
[ "Return", "Concept", "from", "an", "Eidos", "entity", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L279-L285
sorgerlab/indra
indra/sources/eidos/processor.py
EidosProcessor.time_context_from_ref
def time_context_from_ref(self, timex): """Return a time context object given a timex reference entry.""" # If the timex has a value set, it means that it refers to a DCT or # a TimeExpression e.g. "value": {"@id": "_:DCT_1"} and the parameters # need to be taken from there value...
python
def time_context_from_ref(self, timex): """Return a time context object given a timex reference entry.""" # If the timex has a value set, it means that it refers to a DCT or # a TimeExpression e.g. "value": {"@id": "_:DCT_1"} and the parameters # need to be taken from there value...
[ "def", "time_context_from_ref", "(", "self", ",", "timex", ")", ":", "# If the timex has a value set, it means that it refers to a DCT or", "# a TimeExpression e.g. \"value\": {\"@id\": \"_:DCT_1\"} and the parameters", "# need to be taken from there", "value", "=", "timex", ".", "get"...
Return a time context object given a timex reference entry.
[ "Return", "a", "time", "context", "object", "given", "a", "timex", "reference", "entry", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L287-L298
sorgerlab/indra
indra/sources/eidos/processor.py
EidosProcessor.geo_context_from_ref
def geo_context_from_ref(self, ref): """Return a ref context object given a location reference entry.""" value = ref.get('value') if value: # Here we get the RefContext from the stashed geoloc dictionary rc = self.doc.geolocs.get(value['@id']) return rc ...
python
def geo_context_from_ref(self, ref): """Return a ref context object given a location reference entry.""" value = ref.get('value') if value: # Here we get the RefContext from the stashed geoloc dictionary rc = self.doc.geolocs.get(value['@id']) return rc ...
[ "def", "geo_context_from_ref", "(", "self", ",", "ref", ")", ":", "value", "=", "ref", ".", "get", "(", "'value'", ")", "if", "value", ":", "# Here we get the RefContext from the stashed geoloc dictionary", "rc", "=", "self", ".", "doc", ".", "geolocs", ".", "...
Return a ref context object given a location reference entry.
[ "Return", "a", "ref", "context", "object", "given", "a", "location", "reference", "entry", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L300-L307
sorgerlab/indra
indra/sources/eidos/processor.py
EidosDocument.time_context_from_dct
def time_context_from_dct(dct): """Return a time context object given a DCT entry.""" time_text = dct.get('text') start = _get_time_stamp(dct.get('start')) end = _get_time_stamp(dct.get('end')) duration = dct.get('duration') tc = TimeContext(text=time_text, start=start, e...
python
def time_context_from_dct(dct): """Return a time context object given a DCT entry.""" time_text = dct.get('text') start = _get_time_stamp(dct.get('start')) end = _get_time_stamp(dct.get('end')) duration = dct.get('duration') tc = TimeContext(text=time_text, start=start, e...
[ "def", "time_context_from_dct", "(", "dct", ")", ":", "time_text", "=", "dct", ".", "get", "(", "'text'", ")", "start", "=", "_get_time_stamp", "(", "dct", ".", "get", "(", "'start'", ")", ")", "end", "=", "_get_time_stamp", "(", "dct", ".", "get", "("...
Return a time context object given a DCT entry.
[ "Return", "a", "time", "context", "object", "given", "a", "DCT", "entry", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/eidos/processor.py#L369-L377
sorgerlab/indra
indra/statements/util.py
make_hash
def make_hash(s, n_bytes): """Make the hash from a matches key.""" raw_h = int(md5(s.encode('utf-8')).hexdigest()[:n_bytes], 16) # Make it a signed int. return 16**n_bytes//2 - raw_h
python
def make_hash(s, n_bytes): """Make the hash from a matches key.""" raw_h = int(md5(s.encode('utf-8')).hexdigest()[:n_bytes], 16) # Make it a signed int. return 16**n_bytes//2 - raw_h
[ "def", "make_hash", "(", "s", ",", "n_bytes", ")", ":", "raw_h", "=", "int", "(", "md5", "(", "s", ".", "encode", "(", "'utf-8'", ")", ")", ".", "hexdigest", "(", ")", "[", ":", "n_bytes", "]", ",", "16", ")", "# Make it a signed int.", "return", "...
Make the hash from a matches key.
[ "Make", "the", "hash", "from", "a", "matches", "key", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/statements/util.py#L12-L16
sorgerlab/indra
indra/sources/tees/parse_tees.py
parse_a1
def parse_a1(a1_text): """Parses an a1 file, the file TEES outputs that lists the entities in the extracted events. Parameters ---------- a1_text : str Text of the TEES a1 output file, specifying the entities Returns ------- entities : Dictionary mapping TEES identifiers to TEE...
python
def parse_a1(a1_text): """Parses an a1 file, the file TEES outputs that lists the entities in the extracted events. Parameters ---------- a1_text : str Text of the TEES a1 output file, specifying the entities Returns ------- entities : Dictionary mapping TEES identifiers to TEE...
[ "def", "parse_a1", "(", "a1_text", ")", ":", "entities", "=", "{", "}", "for", "line", "in", "a1_text", ".", "split", "(", "'\\n'", ")", ":", "if", "len", "(", "line", ")", "==", "0", ":", "continue", "tokens", "=", "line", ".", "rstrip", "(", ")...
Parses an a1 file, the file TEES outputs that lists the entities in the extracted events. Parameters ---------- a1_text : str Text of the TEES a1 output file, specifying the entities Returns ------- entities : Dictionary mapping TEES identifiers to TEESEntity objects descri...
[ "Parses", "an", "a1", "file", "the", "file", "TEES", "outputs", "that", "lists", "the", "entities", "in", "the", "extracted", "events", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/parse_tees.py#L71-L115
sorgerlab/indra
indra/sources/tees/parse_tees.py
parse_a2
def parse_a2(a2_text, entities, tees_sentences): """Extracts events from a TEES a2 output into a networkx directed graph. Parameters ---------- a2_text : str Text of the TEES a2 file output, specifying the event graph sentences_xml_gz : str Filename with the TEES sentence segmentati...
python
def parse_a2(a2_text, entities, tees_sentences): """Extracts events from a TEES a2 output into a networkx directed graph. Parameters ---------- a2_text : str Text of the TEES a2 file output, specifying the event graph sentences_xml_gz : str Filename with the TEES sentence segmentati...
[ "def", "parse_a2", "(", "a2_text", ",", "entities", ",", "tees_sentences", ")", ":", "G", "=", "nx", ".", "DiGraph", "(", ")", "event_names", "=", "set", "(", ")", "# Put entities into the graph", "for", "entity_name", "in", "entities", ".", "keys", "(", "...
Extracts events from a TEES a2 output into a networkx directed graph. Parameters ---------- a2_text : str Text of the TEES a2 file output, specifying the event graph sentences_xml_gz : str Filename with the TEES sentence segmentation in a gzipped xml format Returns ------- ...
[ "Extracts", "events", "from", "a", "TEES", "a2", "output", "into", "a", "networkx", "directed", "graph", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/parse_tees.py#L118-L224
sorgerlab/indra
indra/sources/tees/parse_tees.py
parse_output
def parse_output(a1_text, a2_text, sentence_segmentations): """Parses the output of the TEES reader and returns a networkx graph with the event information. Parameters ---------- a1_text : str Contents of the TEES a1 output, specifying the entities a1_text : str Contents of the ...
python
def parse_output(a1_text, a2_text, sentence_segmentations): """Parses the output of the TEES reader and returns a networkx graph with the event information. Parameters ---------- a1_text : str Contents of the TEES a1 output, specifying the entities a1_text : str Contents of the ...
[ "def", "parse_output", "(", "a1_text", ",", "a2_text", ",", "sentence_segmentations", ")", ":", "# Parse the sentence segmentation document", "tees_sentences", "=", "TEESSentences", "(", "sentence_segmentations", ")", "# Parse the a1 (entities) file", "entities", "=", "parse_...
Parses the output of the TEES reader and returns a networkx graph with the event information. Parameters ---------- a1_text : str Contents of the TEES a1 output, specifying the entities a1_text : str Contents of the TEES a2 output, specifying the event graph sentence_segmentatio...
[ "Parses", "the", "output", "of", "the", "TEES", "reader", "and", "returns", "a", "networkx", "graph", "with", "the", "event", "information", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/parse_tees.py#L272-L301
sorgerlab/indra
indra/sources/tees/parse_tees.py
tees_parse_networkx_to_dot
def tees_parse_networkx_to_dot(G, output_file, subgraph_nodes): """Converts TEES extractions stored in a networkx graph into a graphviz .dot file. Parameters ---------- G : networkx.DiGraph Graph with TEES extractions returned by run_and_parse_tees output_file : str Output file ...
python
def tees_parse_networkx_to_dot(G, output_file, subgraph_nodes): """Converts TEES extractions stored in a networkx graph into a graphviz .dot file. Parameters ---------- G : networkx.DiGraph Graph with TEES extractions returned by run_and_parse_tees output_file : str Output file ...
[ "def", "tees_parse_networkx_to_dot", "(", "G", ",", "output_file", ",", "subgraph_nodes", ")", ":", "with", "codecs", ".", "open", "(", "output_file", ",", "'w'", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "f", ".", "write", "(", "'digraph teesP...
Converts TEES extractions stored in a networkx graph into a graphviz .dot file. Parameters ---------- G : networkx.DiGraph Graph with TEES extractions returned by run_and_parse_tees output_file : str Output file to which to write .dot file subgraph_nodes : list[str] Only...
[ "Converts", "TEES", "extractions", "stored", "in", "a", "networkx", "graph", "into", "a", "graphviz", ".", "dot", "file", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/tees/parse_tees.py#L303-L354
sorgerlab/indra
indra/sources/cwms/processor.py
CWMSProcessor._get_event
def _get_event(self, event, find_str): """Get a concept referred from the event by the given string.""" # Get the term with the given element id element = event.find(find_str) if element is None: return None element_id = element.attrib.get('id') element_term =...
python
def _get_event(self, event, find_str): """Get a concept referred from the event by the given string.""" # Get the term with the given element id element = event.find(find_str) if element is None: return None element_id = element.attrib.get('id') element_term =...
[ "def", "_get_event", "(", "self", ",", "event", ",", "find_str", ")", ":", "# Get the term with the given element id", "element", "=", "event", ".", "find", "(", "find_str", ")", "if", "element", "is", "None", ":", "return", "None", "element_id", "=", "element...
Get a concept referred from the event by the given string.
[ "Get", "a", "concept", "referred", "from", "the", "event", "by", "the", "given", "string", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/cwms/processor.py#L115-L152
sorgerlab/indra
indra/sources/cwms/processor.py
CWMSProcessor._extract_time_loc
def _extract_time_loc(self, term): """Get the location from a term (CC or TERM)""" loc = term.find('location') if loc is None: loc_context = None else: loc_id = loc.attrib.get('id') loc_term = self.tree.find("*[@id='%s']" % loc_id) text = l...
python
def _extract_time_loc(self, term): """Get the location from a term (CC or TERM)""" loc = term.find('location') if loc is None: loc_context = None else: loc_id = loc.attrib.get('id') loc_term = self.tree.find("*[@id='%s']" % loc_id) text = l...
[ "def", "_extract_time_loc", "(", "self", ",", "term", ")", ":", "loc", "=", "term", ".", "find", "(", "'location'", ")", "if", "loc", "is", "None", ":", "loc_context", "=", "None", "else", ":", "loc_id", "=", "loc", ".", "attrib", ".", "get", "(", ...
Get the location from a term (CC or TERM)
[ "Get", "the", "location", "from", "a", "term", "(", "CC", "or", "TERM", ")" ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/cwms/processor.py#L154-L199
sorgerlab/indra
indra/assemblers/cag/assembler.py
CAGAssembler.make_model
def make_model(self, grounding_ontology='UN', grounding_threshold=None): """Return a networkx MultiDiGraph representing a causal analysis graph. Parameters ---------- grounding_ontology : Optional[str] The ontology from which the grounding should be taken (e.g. U...
python
def make_model(self, grounding_ontology='UN', grounding_threshold=None): """Return a networkx MultiDiGraph representing a causal analysis graph. Parameters ---------- grounding_ontology : Optional[str] The ontology from which the grounding should be taken (e.g. U...
[ "def", "make_model", "(", "self", ",", "grounding_ontology", "=", "'UN'", ",", "grounding_threshold", "=", "None", ")", ":", "if", "grounding_threshold", "is", "not", "None", ":", "self", ".", "grounding_threshold", "=", "grounding_threshold", "self", ".", "grou...
Return a networkx MultiDiGraph representing a causal analysis graph. Parameters ---------- grounding_ontology : Optional[str] The ontology from which the grounding should be taken (e.g. UN, FAO) grounding_threshold : Optional[float] Minimum threshold ...
[ "Return", "a", "networkx", "MultiDiGraph", "representing", "a", "causal", "analysis", "graph", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cag/assembler.py#L49-L124
sorgerlab/indra
indra/assemblers/cag/assembler.py
CAGAssembler.export_to_cytoscapejs
def export_to_cytoscapejs(self): """Return CAG in format readable by CytoscapeJS. Return ------ dict A JSON-like dict representing the graph for use with CytoscapeJS. """ def _create_edge_data_dict(e): """Return a dict from a MultiDiGr...
python
def export_to_cytoscapejs(self): """Return CAG in format readable by CytoscapeJS. Return ------ dict A JSON-like dict representing the graph for use with CytoscapeJS. """ def _create_edge_data_dict(e): """Return a dict from a MultiDiGr...
[ "def", "export_to_cytoscapejs", "(", "self", ")", ":", "def", "_create_edge_data_dict", "(", "e", ")", ":", "\"\"\"Return a dict from a MultiDiGraph edge for CytoscapeJS export.\"\"\"", "# A hack to get rid of the redundant 'Provenance' label.", "if", "e", "[", "3", "]", ".", ...
Return CAG in format readable by CytoscapeJS. Return ------ dict A JSON-like dict representing the graph for use with CytoscapeJS.
[ "Return", "CAG", "in", "format", "readable", "by", "CytoscapeJS", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cag/assembler.py#L203-L248
sorgerlab/indra
indra/assemblers/cag/assembler.py
CAGAssembler.generate_jupyter_js
def generate_jupyter_js(self, cyjs_style=None, cyjs_layout=None): """Generate Javascript from a template to run in Jupyter notebooks. Parameters ---------- cyjs_style : Optional[dict] A dict that sets CytoscapeJS style as specified in https://github.com/cytoscape...
python
def generate_jupyter_js(self, cyjs_style=None, cyjs_layout=None): """Generate Javascript from a template to run in Jupyter notebooks. Parameters ---------- cyjs_style : Optional[dict] A dict that sets CytoscapeJS style as specified in https://github.com/cytoscape...
[ "def", "generate_jupyter_js", "(", "self", ",", "cyjs_style", "=", "None", ",", "cyjs_layout", "=", "None", ")", ":", "# First, export the CAG to CyJS", "cyjs_elements", "=", "self", ".", "export_to_cytoscapejs", "(", ")", "# Load the Javascript template", "tempf", "=...
Generate Javascript from a template to run in Jupyter notebooks. Parameters ---------- cyjs_style : Optional[dict] A dict that sets CytoscapeJS style as specified in https://github.com/cytoscape/cytoscape.js/blob/master/documentation/md/style.md. cyjs_layout : O...
[ "Generate", "Javascript", "from", "a", "template", "to", "run", "in", "Jupyter", "notebooks", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cag/assembler.py#L250-L289
sorgerlab/indra
indra/assemblers/cag/assembler.py
CAGAssembler._node_name
def _node_name(self, concept): """Return a standardized name for a node given a Concept.""" if (# grounding threshold is specified self.grounding_threshold is not None # The particular eidos ontology grounding (un/wdi/fao) is present and concept.db_refs[self.grounding...
python
def _node_name(self, concept): """Return a standardized name for a node given a Concept.""" if (# grounding threshold is specified self.grounding_threshold is not None # The particular eidos ontology grounding (un/wdi/fao) is present and concept.db_refs[self.grounding...
[ "def", "_node_name", "(", "self", ",", "concept", ")", ":", "if", "(", "# grounding threshold is specified", "self", ".", "grounding_threshold", "is", "not", "None", "# The particular eidos ontology grounding (un/wdi/fao) is present", "and", "concept", ".", "db_refs", "["...
Return a standardized name for a node given a Concept.
[ "Return", "a", "standardized", "name", "for", "a", "node", "given", "a", "Concept", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cag/assembler.py#L291-L303
sorgerlab/indra
indra/sources/bel/rdf_processor.py
namespace_from_uri
def namespace_from_uri(uri): """Return the entity namespace from the URI. Examples: http://www.openbel.org/bel/p_HGNC_RAF1 -> HGNC http://www.openbel.org/bel/p_RGD_Raf1 -> RGD http://www.openbel.org/bel/p_PFH_MEK1/2_Family -> PFH """ patterns = ['http://www.openbel.org/bel/[pragm]_([A-Za-z]+)_.*...
python
def namespace_from_uri(uri): """Return the entity namespace from the URI. Examples: http://www.openbel.org/bel/p_HGNC_RAF1 -> HGNC http://www.openbel.org/bel/p_RGD_Raf1 -> RGD http://www.openbel.org/bel/p_PFH_MEK1/2_Family -> PFH """ patterns = ['http://www.openbel.org/bel/[pragm]_([A-Za-z]+)_.*...
[ "def", "namespace_from_uri", "(", "uri", ")", ":", "patterns", "=", "[", "'http://www.openbel.org/bel/[pragm]_([A-Za-z]+)_.*'", ",", "'http://www.openbel.org/bel/[a-z]+_[pr]_([A-Za-z]+)_.*'", ",", "'http://www.openbel.org/bel/[a-z]+_complex_([A-Za-z]+)_.*'", ",", "'http://www.openbel.o...
Return the entity namespace from the URI. Examples: http://www.openbel.org/bel/p_HGNC_RAF1 -> HGNC http://www.openbel.org/bel/p_RGD_Raf1 -> RGD http://www.openbel.org/bel/p_PFH_MEK1/2_Family -> PFH
[ "Return", "the", "entity", "namespace", "from", "the", "URI", ".", "Examples", ":", "http", ":", "//", "www", ".", "openbel", ".", "org", "/", "bel", "/", "p_HGNC_RAF1", "-", ">", "HGNC", "http", ":", "//", "www", ".", "openbel", ".", "org", "/", "...
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L21-L35
sorgerlab/indra
indra/sources/bel/rdf_processor.py
term_from_uri
def term_from_uri(uri): """Removes prepended URI information from terms.""" if uri is None: return None # This insures that if we get a Literal with an integer value (as we # do for modification positions), it will get converted to a string, # not an integer. if isinstance(uri, rdflib.Li...
python
def term_from_uri(uri): """Removes prepended URI information from terms.""" if uri is None: return None # This insures that if we get a Literal with an integer value (as we # do for modification positions), it will get converted to a string, # not an integer. if isinstance(uri, rdflib.Li...
[ "def", "term_from_uri", "(", "uri", ")", ":", "if", "uri", "is", "None", ":", "return", "None", "# This insures that if we get a Literal with an integer value (as we", "# do for modification positions), it will get converted to a string,", "# not an integer.", "if", "isinstance", ...
Removes prepended URI information from terms.
[ "Removes", "prepended", "URI", "information", "from", "terms", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L37-L66
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_modifications
def get_modifications(self): """Extract INDRA Modification Statements from BEL. Two SPARQL patterns are used for extracting Modifications from BEL: - q_phospho1 assumes that the subject is an AbundanceActivity, which increases/decreases a ModifiedProteinAbundance. Examples...
python
def get_modifications(self): """Extract INDRA Modification Statements from BEL. Two SPARQL patterns are used for extracting Modifications from BEL: - q_phospho1 assumes that the subject is an AbundanceActivity, which increases/decreases a ModifiedProteinAbundance. Examples...
[ "def", "get_modifications", "(", "self", ")", ":", "# Get statements where the subject is an activity", "q_phospho1", "=", "prefixes", "+", "\"\"\"\n SELECT ?enzName ?substrateName ?mod ?pos\n ?stmt ?enzyme ?substrate ?rel\n WHERE {\n ?stm...
Extract INDRA Modification Statements from BEL. Two SPARQL patterns are used for extracting Modifications from BEL: - q_phospho1 assumes that the subject is an AbundanceActivity, which increases/decreases a ModifiedProteinAbundance. Examples: kinaseActivity(proteinA...
[ "Extract", "INDRA", "Modification", "Statements", "from", "BEL", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L116-L222
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_activating_mods
def get_activating_mods(self): """Extract INDRA ActiveForm Statements with a single mod from BEL. The SPARQL pattern used for extraction from BEL looks for a ModifiedProteinAbundance as subject and an Activiy of a ProteinAbundance as object. Examples: proteinAbunda...
python
def get_activating_mods(self): """Extract INDRA ActiveForm Statements with a single mod from BEL. The SPARQL pattern used for extraction from BEL looks for a ModifiedProteinAbundance as subject and an Activiy of a ProteinAbundance as object. Examples: proteinAbunda...
[ "def", "get_activating_mods", "(", "self", ")", ":", "q_mods", "=", "prefixes", "+", "\"\"\"\n SELECT ?speciesName ?actType ?mod ?pos ?rel ?stmt ?species\n WHERE {\n ?stmt a belvoc:Statement .\n ?stmt belvoc:hasRelationship ?rel .\n ...
Extract INDRA ActiveForm Statements with a single mod from BEL. The SPARQL pattern used for extraction from BEL looks for a ModifiedProteinAbundance as subject and an Activiy of a ProteinAbundance as object. Examples: proteinAbundance(HGNC:INSR,proteinModification(P,Y)) ...
[ "Extract", "INDRA", "ActiveForm", "Statements", "with", "a", "single", "mod", "from", "BEL", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L225-L279
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_complexes
def get_complexes(self): """Extract INDRA Complex Statements from BEL. The SPARQL query used to extract Complexes looks for ComplexAbundance terms and their constituents. This pattern is distinct from other patterns in this processor in that it queries for terms, not full statem...
python
def get_complexes(self): """Extract INDRA Complex Statements from BEL. The SPARQL query used to extract Complexes looks for ComplexAbundance terms and their constituents. This pattern is distinct from other patterns in this processor in that it queries for terms, not full statem...
[ "def", "get_complexes", "(", "self", ")", ":", "q_cmplx", "=", "prefixes", "+", "\"\"\"\n SELECT ?complexTerm ?childName ?child ?stmt\n WHERE {\n {\n {?stmt belvoc:hasSubject ?complexTerm}\n UNION\n {?stmt belvoc:h...
Extract INDRA Complex Statements from BEL. The SPARQL query used to extract Complexes looks for ComplexAbundance terms and their constituents. This pattern is distinct from other patterns in this processor in that it queries for terms, not full statements. Examples: ...
[ "Extract", "INDRA", "Complex", "Statements", "from", "BEL", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L281-L344
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_activating_subs
def get_activating_subs(self): """Extract INDRA ActiveForm Statements based on a mutation from BEL. The SPARQL pattern used to extract ActiveForms due to mutations look for a ProteinAbundance as a subject which has a child encoding the amino acid substitution. The object of the statemen...
python
def get_activating_subs(self): """Extract INDRA ActiveForm Statements based on a mutation from BEL. The SPARQL pattern used to extract ActiveForms due to mutations look for a ProteinAbundance as a subject which has a child encoding the amino acid substitution. The object of the statemen...
[ "def", "get_activating_subs", "(", "self", ")", ":", "q_mods", "=", "prefixes", "+", "\"\"\"\n SELECT ?enzyme_name ?sub_label ?act_type ?rel ?stmt ?subject\n WHERE {\n ?stmt a belvoc:Statement .\n ?stmt belvoc:hasRelationship ?rel .\n ...
Extract INDRA ActiveForm Statements based on a mutation from BEL. The SPARQL pattern used to extract ActiveForms due to mutations look for a ProteinAbundance as a subject which has a child encoding the amino acid substitution. The object of the statement is an ActivityType of the same P...
[ "Extract", "INDRA", "ActiveForm", "Statements", "based", "on", "a", "mutation", "from", "BEL", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L346-L421
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_activation
def get_activation(self): """Extract INDRA Inhibition/Activation Statements from BEL. The SPARQL query used to extract Activation Statements looks for patterns in which the subject is is an ActivityType (of a ProtainAbundance) or an Abundance (of a small molecule). The object ha...
python
def get_activation(self): """Extract INDRA Inhibition/Activation Statements from BEL. The SPARQL query used to extract Activation Statements looks for patterns in which the subject is is an ActivityType (of a ProtainAbundance) or an Abundance (of a small molecule). The object ha...
[ "def", "get_activation", "(", "self", ")", ":", "q_stmts", "=", "prefixes", "+", "\"\"\"\n SELECT ?subjName ?subjActType ?rel ?objName ?objActType\n ?stmt ?subj ?obj\n WHERE {\n ?stmt a belvoc:Statement .\n ?stmt belvoc:hasRel...
Extract INDRA Inhibition/Activation Statements from BEL. The SPARQL query used to extract Activation Statements looks for patterns in which the subject is is an ActivityType (of a ProtainAbundance) or an Abundance (of a small molecule). The object has to be the ActivityType (typically o...
[ "Extract", "INDRA", "Inhibition", "/", "Activation", "Statements", "from", "BEL", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L423-L524
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_transcription
def get_transcription(self): """Extract Increase/DecreaseAmount INDRA Statements from BEL. Three distinct SPARQL patterns are used to extract amount regulations from BEL. - q_tscript1 searches for a subject which is a Transcription ActivityType of a ProteinAbundance and an ob...
python
def get_transcription(self): """Extract Increase/DecreaseAmount INDRA Statements from BEL. Three distinct SPARQL patterns are used to extract amount regulations from BEL. - q_tscript1 searches for a subject which is a Transcription ActivityType of a ProteinAbundance and an ob...
[ "def", "get_transcription", "(", "self", ")", ":", "q_tscript1", "=", "prefixes", "+", "\"\"\"\n SELECT ?tfName ?targetName ?stmt ?tf ?target ?rel\n WHERE {\n ?stmt a belvoc:Statement .\n ?stmt belvoc:hasRelationship ?rel .\n ?st...
Extract Increase/DecreaseAmount INDRA Statements from BEL. Three distinct SPARQL patterns are used to extract amount regulations from BEL. - q_tscript1 searches for a subject which is a Transcription ActivityType of a ProteinAbundance and an object which is an RNAAbundance ...
[ "Extract", "Increase", "/", "DecreaseAmount", "INDRA", "Statements", "from", "BEL", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L526-L652
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_conversions
def get_conversions(self): """Extract Conversion INDRA Statements from BEL. The SPARQL query used to extract Conversions searches for a subject (controller) which is an AbundanceActivity which directlyIncreases a Reaction with a given list of Reactants and Products. Ex...
python
def get_conversions(self): """Extract Conversion INDRA Statements from BEL. The SPARQL query used to extract Conversions searches for a subject (controller) which is an AbundanceActivity which directlyIncreases a Reaction with a given list of Reactants and Products. Ex...
[ "def", "get_conversions", "(", "self", ")", ":", "query", "=", "prefixes", "+", "\"\"\"\n SELECT DISTINCT ?controller ?controllerName ?controllerActivity\n ?product ?productName ?reactant ?reactantName ?stmt\n WHERE {\n ?stmt a belvoc:Statement...
Extract Conversion INDRA Statements from BEL. The SPARQL query used to extract Conversions searches for a subject (controller) which is an AbundanceActivity which directlyIncreases a Reaction with a given list of Reactants and Products. Examples: catalyticActivity...
[ "Extract", "Conversion", "INDRA", "Statements", "from", "BEL", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L654-L725
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_all_direct_statements
def get_all_direct_statements(self): """Get all directlyIncreases/Decreases BEL statements. This method stores the results of the query in self.all_direct_stmts as a list of strings. The SPARQL query used to find direct BEL statements searches for all statements whose predicate is eithe...
python
def get_all_direct_statements(self): """Get all directlyIncreases/Decreases BEL statements. This method stores the results of the query in self.all_direct_stmts as a list of strings. The SPARQL query used to find direct BEL statements searches for all statements whose predicate is eithe...
[ "def", "get_all_direct_statements", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Getting all direct statements...\\n\"", ")", "q_stmts", "=", "prefixes", "+", "\"\"\"\n SELECT ?stmt\n WHERE {\n ?stmt a belvoc:Statement .\n ...
Get all directlyIncreases/Decreases BEL statements. This method stores the results of the query in self.all_direct_stmts as a list of strings. The SPARQL query used to find direct BEL statements searches for all statements whose predicate is either DirectyIncreases or DirectlyDecreases.
[ "Get", "all", "directlyIncreases", "/", "Decreases", "BEL", "statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L727-L749
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_all_indirect_statements
def get_all_indirect_statements(self): """Get all indirect increases/decreases BEL statements. This method stores the results of the query in self.all_indirect_stmts as a list of strings. The SPARQL query used to find indirect BEL statements searches for all statements whose predicate i...
python
def get_all_indirect_statements(self): """Get all indirect increases/decreases BEL statements. This method stores the results of the query in self.all_indirect_stmts as a list of strings. The SPARQL query used to find indirect BEL statements searches for all statements whose predicate i...
[ "def", "get_all_indirect_statements", "(", "self", ")", ":", "q_stmts", "=", "prefixes", "+", "\"\"\"\n SELECT ?stmt\n WHERE {\n ?stmt a belvoc:Statement .\n {\n { ?stmt belvoc:hasRelationship belvoc:Increases . }\n ...
Get all indirect increases/decreases BEL statements. This method stores the results of the query in self.all_indirect_stmts as a list of strings. The SPARQL query used to find indirect BEL statements searches for all statements whose predicate is either Increases or Decreases.
[ "Get", "all", "indirect", "increases", "/", "decreases", "BEL", "statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L751-L772
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.get_degenerate_statements
def get_degenerate_statements(self): """Get all degenerate BEL statements. Stores the results of the query in self.degenerate_stmts. """ logger.info("Checking for 'degenerate' statements...\n") # Get rules of type protein X -> activity Y q_stmts = prefixes + """ ...
python
def get_degenerate_statements(self): """Get all degenerate BEL statements. Stores the results of the query in self.degenerate_stmts. """ logger.info("Checking for 'degenerate' statements...\n") # Get rules of type protein X -> activity Y q_stmts = prefixes + """ ...
[ "def", "get_degenerate_statements", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Checking for 'degenerate' statements...\\n\"", ")", "# Get rules of type protein X -> activity Y", "q_stmts", "=", "prefixes", "+", "\"\"\"\n SELECT ?stmt\n WHERE {\n ...
Get all degenerate BEL statements. Stores the results of the query in self.degenerate_stmts.
[ "Get", "all", "degenerate", "BEL", "statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L774-L827
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.print_statement_coverage
def print_statement_coverage(self): """Display how many of the direct statements have been converted. Also prints how many are considered 'degenerate' and not converted.""" if not self.all_direct_stmts: self.get_all_direct_statements() if not self.degenerate_stmts: ...
python
def print_statement_coverage(self): """Display how many of the direct statements have been converted. Also prints how many are considered 'degenerate' and not converted.""" if not self.all_direct_stmts: self.get_all_direct_statements() if not self.degenerate_stmts: ...
[ "def", "print_statement_coverage", "(", "self", ")", ":", "if", "not", "self", ".", "all_direct_stmts", ":", "self", ".", "get_all_direct_statements", "(", ")", "if", "not", "self", ".", "degenerate_stmts", ":", "self", ".", "get_degenerate_statements", "(", ")"...
Display how many of the direct statements have been converted. Also prints how many are considered 'degenerate' and not converted.
[ "Display", "how", "many", "of", "the", "direct", "statements", "have", "been", "converted", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L829-L871
sorgerlab/indra
indra/sources/bel/rdf_processor.py
BelRdfProcessor.print_statements
def print_statements(self): """Print all extracted INDRA Statements.""" logger.info('--- Direct INDRA statements ----------') for i, stmt in enumerate(self.statements): logger.info("%s: %s" % (i, stmt)) logger.info('--- Indirect INDRA statements ----------') for i, st...
python
def print_statements(self): """Print all extracted INDRA Statements.""" logger.info('--- Direct INDRA statements ----------') for i, stmt in enumerate(self.statements): logger.info("%s: %s" % (i, stmt)) logger.info('--- Indirect INDRA statements ----------') for i, st...
[ "def", "print_statements", "(", "self", ")", ":", "logger", ".", "info", "(", "'--- Direct INDRA statements ----------'", ")", "for", "i", ",", "stmt", "in", "enumerate", "(", "self", ".", "statements", ")", ":", "logger", ".", "info", "(", "\"%s: %s\"", "%"...
Print all extracted INDRA Statements.
[ "Print", "all", "extracted", "INDRA", "Statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/rdf_processor.py#L873-L880
sorgerlab/indra
indra/sources/medscan/api.py
process_directory_statements_sorted_by_pmid
def process_directory_statements_sorted_by_pmid(directory_name): """Processes a directory filled with CSXML files, first normalizing the character encoding to utf-8, and then processing into INDRA statements sorted by pmid. Parameters ---------- directory_name : str The name of a direct...
python
def process_directory_statements_sorted_by_pmid(directory_name): """Processes a directory filled with CSXML files, first normalizing the character encoding to utf-8, and then processing into INDRA statements sorted by pmid. Parameters ---------- directory_name : str The name of a direct...
[ "def", "process_directory_statements_sorted_by_pmid", "(", "directory_name", ")", ":", "s_dict", "=", "defaultdict", "(", "list", ")", "mp", "=", "process_directory", "(", "directory_name", ",", "lazy", "=", "True", ")", "for", "statement", "in", "mp", ".", "ite...
Processes a directory filled with CSXML files, first normalizing the character encoding to utf-8, and then processing into INDRA statements sorted by pmid. Parameters ---------- directory_name : str The name of a directory filled with csxml files to process Returns ------- pmid...
[ "Processes", "a", "directory", "filled", "with", "CSXML", "files", "first", "normalizing", "the", "character", "encoding", "to", "utf", "-", "8", "and", "then", "processing", "into", "INDRA", "statements", "sorted", "by", "pmid", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/api.py#L9-L30
sorgerlab/indra
indra/sources/medscan/api.py
process_directory
def process_directory(directory_name, lazy=False): """Processes a directory filled with CSXML files, first normalizing the character encodings to utf-8, and then processing into a list of INDRA statements. Parameters ---------- directory_name : str The name of a directory filled with cs...
python
def process_directory(directory_name, lazy=False): """Processes a directory filled with CSXML files, first normalizing the character encodings to utf-8, and then processing into a list of INDRA statements. Parameters ---------- directory_name : str The name of a directory filled with cs...
[ "def", "process_directory", "(", "directory_name", ",", "lazy", "=", "False", ")", ":", "# Parent Medscan processor containing extractions from all files", "mp", "=", "MedscanProcessor", "(", ")", "mp", ".", "process_directory", "(", "directory_name", ",", "lazy", ")", ...
Processes a directory filled with CSXML files, first normalizing the character encodings to utf-8, and then processing into a list of INDRA statements. Parameters ---------- directory_name : str The name of a directory filled with csxml files to process lazy : bool If True, the ...
[ "Processes", "a", "directory", "filled", "with", "CSXML", "files", "first", "normalizing", "the", "character", "encodings", "to", "utf", "-", "8", "and", "then", "processing", "into", "a", "list", "of", "INDRA", "statements", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/api.py#L33-L58
sorgerlab/indra
indra/sources/medscan/api.py
process_file_sorted_by_pmid
def process_file_sorted_by_pmid(file_name): """Processes a file and returns a dictionary mapping pmids to a list of statements corresponding to that pmid. Parameters ---------- file_name : str A csxml file to process Returns ------- s_dict : dict Dictionary mapping pmid...
python
def process_file_sorted_by_pmid(file_name): """Processes a file and returns a dictionary mapping pmids to a list of statements corresponding to that pmid. Parameters ---------- file_name : str A csxml file to process Returns ------- s_dict : dict Dictionary mapping pmid...
[ "def", "process_file_sorted_by_pmid", "(", "file_name", ")", ":", "s_dict", "=", "defaultdict", "(", "list", ")", "mp", "=", "process_file", "(", "file_name", ",", "lazy", "=", "True", ")", "for", "statement", "in", "mp", ".", "iter_statements", "(", ")", ...
Processes a file and returns a dictionary mapping pmids to a list of statements corresponding to that pmid. Parameters ---------- file_name : str A csxml file to process Returns ------- s_dict : dict Dictionary mapping pmids to a list of statements corresponding to ...
[ "Processes", "a", "file", "and", "returns", "a", "dictionary", "mapping", "pmids", "to", "a", "list", "of", "statements", "corresponding", "to", "that", "pmid", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/api.py#L61-L81
sorgerlab/indra
indra/sources/medscan/api.py
process_file
def process_file(filename, interval=None, lazy=False): """Process a CSXML file for its relevant information. Consider running the fix_csxml_character_encoding.py script in indra/sources/medscan to fix any encoding issues in the input file before processing. Attributes ---------- filename :...
python
def process_file(filename, interval=None, lazy=False): """Process a CSXML file for its relevant information. Consider running the fix_csxml_character_encoding.py script in indra/sources/medscan to fix any encoding issues in the input file before processing. Attributes ---------- filename :...
[ "def", "process_file", "(", "filename", ",", "interval", "=", "None", ",", "lazy", "=", "False", ")", ":", "mp", "=", "MedscanProcessor", "(", ")", "mp", ".", "process_csxml_file", "(", "filename", ",", "interval", ",", "lazy", ")", "return", "mp" ]
Process a CSXML file for its relevant information. Consider running the fix_csxml_character_encoding.py script in indra/sources/medscan to fix any encoding issues in the input file before processing. Attributes ---------- filename : str The csxml file, containing Medscan XML, to proces...
[ "Process", "a", "CSXML", "file", "for", "its", "relevant", "information", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/medscan/api.py#L84-L114
sorgerlab/indra
indra/explanation/reporting.py
stmts_from_path
def stmts_from_path(path, model, stmts): """Return source Statements corresponding to a path in a model. Parameters ---------- path : list[tuple[str, int]] A list of tuples where the first element of the tuple is the name of a rule, and the second is the associated polarity along ...
python
def stmts_from_path(path, model, stmts): """Return source Statements corresponding to a path in a model. Parameters ---------- path : list[tuple[str, int]] A list of tuples where the first element of the tuple is the name of a rule, and the second is the associated polarity along ...
[ "def", "stmts_from_path", "(", "path", ",", "model", ",", "stmts", ")", ":", "path_stmts", "=", "[", "]", "for", "path_rule", ",", "sign", "in", "path", ":", "for", "rule", "in", "model", ".", "rules", ":", "if", "rule", ".", "name", "==", "path_rule...
Return source Statements corresponding to a path in a model. Parameters ---------- path : list[tuple[str, int]] A list of tuples where the first element of the tuple is the name of a rule, and the second is the associated polarity along a path. model : pysb.core.Model A ...
[ "Return", "source", "Statements", "corresponding", "to", "a", "path", "in", "a", "model", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/explanation/reporting.py#L3-L29
sorgerlab/indra
indra/sources/bel/processor.py
extract_context
def extract_context(annotations, annot_manager): """Return a BioContext object extracted from the annotations. The entries that are extracted into the BioContext are popped from the annotations. Parameters ---------- annotations : dict PyBEL annotations dict annot_manager : Annotat...
python
def extract_context(annotations, annot_manager): """Return a BioContext object extracted from the annotations. The entries that are extracted into the BioContext are popped from the annotations. Parameters ---------- annotations : dict PyBEL annotations dict annot_manager : Annotat...
[ "def", "extract_context", "(", "annotations", ",", "annot_manager", ")", ":", "def", "get_annot", "(", "annotations", ",", "key", ")", ":", "\"\"\"Return a specific annotation given a key.\"\"\"", "val", "=", "annotations", ".", "pop", "(", "key", ",", "None", ")"...
Return a BioContext object extracted from the annotations. The entries that are extracted into the BioContext are popped from the annotations. Parameters ---------- annotations : dict PyBEL annotations dict annot_manager : AnnotationManager An annotation manager to get name/db ...
[ "Return", "a", "BioContext", "object", "extracted", "from", "the", "annotations", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/bel/processor.py#L492-L549
sorgerlab/indra
indra/util/plot_formatting.py
format_axis
def format_axis(ax, label_padding=2, tick_padding=0, yticks_position='left'): """Set standardized axis formatting for figure.""" ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position(yticks_position) ax.yaxis.set_tick_params(which='both', direction='out', labelsize=fontsize, ...
python
def format_axis(ax, label_padding=2, tick_padding=0, yticks_position='left'): """Set standardized axis formatting for figure.""" ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position(yticks_position) ax.yaxis.set_tick_params(which='both', direction='out', labelsize=fontsize, ...
[ "def", "format_axis", "(", "ax", ",", "label_padding", "=", "2", ",", "tick_padding", "=", "0", ",", "yticks_position", "=", "'left'", ")", ":", "ax", ".", "xaxis", ".", "set_ticks_position", "(", "'bottom'", ")", "ax", ".", "yaxis", ".", "set_ticks_positi...
Set standardized axis formatting for figure.
[ "Set", "standardized", "axis", "formatting", "for", "figure", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/util/plot_formatting.py#L17-L28
sorgerlab/indra
indra/assemblers/html/assembler.py
tag_text
def tag_text(text, tag_info_list): """Apply start/end tags to spans of the given text. Parameters ---------- text : str Text to be tagged tag_info_list : list of tuples Each tuple refers to a span of the given text. Fields are `(start_ix, end_ix, substring, start_tag, close...
python
def tag_text(text, tag_info_list): """Apply start/end tags to spans of the given text. Parameters ---------- text : str Text to be tagged tag_info_list : list of tuples Each tuple refers to a span of the given text. Fields are `(start_ix, end_ix, substring, start_tag, close...
[ "def", "tag_text", "(", "text", ",", "tag_info_list", ")", ":", "# Check to tags for overlap and if there is any, return the subsumed", "# range. Return None if no overlap.", "def", "overlap", "(", "t1", ",", "t2", ")", ":", "if", "range", "(", "max", "(", "t1", "[", ...
Apply start/end tags to spans of the given text. Parameters ---------- text : str Text to be tagged tag_info_list : list of tuples Each tuple refers to a span of the given text. Fields are `(start_ix, end_ix, substring, start_tag, close_tag)`, where substring, start_tag, ...
[ "Apply", "start", "/", "end", "tags", "to", "spans", "of", "the", "given", "text", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/html/assembler.py#L291-L346
sorgerlab/indra
indra/assemblers/html/assembler.py
HtmlAssembler.make_model
def make_model(self): """Return the assembled HTML content as a string. Returns ------- str The assembled HTML as a string. """ stmts_formatted = [] stmt_rows = group_and_sort_statements(self.statements, s...
python
def make_model(self): """Return the assembled HTML content as a string. Returns ------- str The assembled HTML as a string. """ stmts_formatted = [] stmt_rows = group_and_sort_statements(self.statements, s...
[ "def", "make_model", "(", "self", ")", ":", "stmts_formatted", "=", "[", "]", "stmt_rows", "=", "group_and_sort_statements", "(", "self", ".", "statements", ",", "self", ".", "ev_totals", "if", "self", ".", "ev_totals", "else", "None", ")", "for", "key", "...
Return the assembled HTML content as a string. Returns ------- str The assembled HTML as a string.
[ "Return", "the", "assembled", "HTML", "content", "as", "a", "string", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/html/assembler.py#L99-L142
sorgerlab/indra
indra/assemblers/html/assembler.py
HtmlAssembler.append_warning
def append_warning(self, msg): """Append a warning message to the model to expose issues.""" assert self.model is not None, "You must already have run make_model!" addendum = ('\t<span style="color:red;">(CAUTION: %s occurred when ' 'creating this page.)</span>' % msg) ...
python
def append_warning(self, msg): """Append a warning message to the model to expose issues.""" assert self.model is not None, "You must already have run make_model!" addendum = ('\t<span style="color:red;">(CAUTION: %s occurred when ' 'creating this page.)</span>' % msg) ...
[ "def", "append_warning", "(", "self", ",", "msg", ")", ":", "assert", "self", ".", "model", "is", "not", "None", ",", "\"You must already have run make_model!\"", "addendum", "=", "(", "'\\t<span style=\"color:red;\">(CAUTION: %s occurred when '", "'creating this page.)</sp...
Append a warning message to the model to expose issues.
[ "Append", "a", "warning", "message", "to", "the", "model", "to", "expose", "issues", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/html/assembler.py#L144-L150
sorgerlab/indra
indra/assemblers/html/assembler.py
HtmlAssembler.save_model
def save_model(self, fname): """Save the assembled HTML into a file. Parameters ---------- fname : str The path to the file to save the HTML into. """ if self.model is None: self.make_model() with open(fname, 'wb') as fh: fh.w...
python
def save_model(self, fname): """Save the assembled HTML into a file. Parameters ---------- fname : str The path to the file to save the HTML into. """ if self.model is None: self.make_model() with open(fname, 'wb') as fh: fh.w...
[ "def", "save_model", "(", "self", ",", "fname", ")", ":", "if", "self", ".", "model", "is", "None", ":", "self", ".", "make_model", "(", ")", "with", "open", "(", "fname", ",", "'wb'", ")", "as", "fh", ":", "fh", ".", "write", "(", "self", ".", ...
Save the assembled HTML into a file. Parameters ---------- fname : str The path to the file to save the HTML into.
[ "Save", "the", "assembled", "HTML", "into", "a", "file", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/html/assembler.py#L152-L164
sorgerlab/indra
indra/assemblers/html/assembler.py
HtmlAssembler._format_evidence_text
def _format_evidence_text(stmt): """Returns evidence metadata with highlighted evidence text. Parameters ---------- stmt : indra.Statement The Statement with Evidence to be formatted. Returns ------- list of dicts List of dictionaries cor...
python
def _format_evidence_text(stmt): """Returns evidence metadata with highlighted evidence text. Parameters ---------- stmt : indra.Statement The Statement with Evidence to be formatted. Returns ------- list of dicts List of dictionaries cor...
[ "def", "_format_evidence_text", "(", "stmt", ")", ":", "def", "get_role", "(", "ag_ix", ")", ":", "if", "isinstance", "(", "stmt", ",", "Complex", ")", "or", "isinstance", "(", "stmt", ",", "SelfModification", ")", "or", "isinstance", "(", "stmt", ",", "...
Returns evidence metadata with highlighted evidence text. Parameters ---------- stmt : indra.Statement The Statement with Evidence to be formatted. Returns ------- list of dicts List of dictionaries corresponding to each Evidence object in the ...
[ "Returns", "evidence", "metadata", "with", "highlighted", "evidence", "text", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/html/assembler.py#L167-L241
sorgerlab/indra
indra/sources/reach/api.py
process_pmc
def process_pmc(pmc_id, offline=False, output_fname=default_output_fname): """Return a ReachProcessor by processing a paper with a given PMC id. Uses the PMC client to obtain the full text. If it's not available, None is returned. Parameters ---------- pmc_id : str The ID of a PubmedCe...
python
def process_pmc(pmc_id, offline=False, output_fname=default_output_fname): """Return a ReachProcessor by processing a paper with a given PMC id. Uses the PMC client to obtain the full text. If it's not available, None is returned. Parameters ---------- pmc_id : str The ID of a PubmedCe...
[ "def", "process_pmc", "(", "pmc_id", ",", "offline", "=", "False", ",", "output_fname", "=", "default_output_fname", ")", ":", "xml_str", "=", "pmc_client", ".", "get_xml", "(", "pmc_id", ")", "if", "xml_str", "is", "None", ":", "return", "None", "fname", ...
Return a ReachProcessor by processing a paper with a given PMC id. Uses the PMC client to obtain the full text. If it's not available, None is returned. Parameters ---------- pmc_id : str The ID of a PubmedCentral article. The string may start with PMC but passing just the ID also ...
[ "Return", "a", "ReachProcessor", "by", "processing", "a", "paper", "with", "a", "given", "PMC", "id", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/api.py#L41-L74
sorgerlab/indra
indra/sources/reach/api.py
process_pubmed_abstract
def process_pubmed_abstract(pubmed_id, offline=False, output_fname=default_output_fname, **kwargs): """Return a ReachProcessor by processing an abstract with a given Pubmed id. Uses the Pubmed client to get the abstract. If that fails, None is returned. Parameters -----...
python
def process_pubmed_abstract(pubmed_id, offline=False, output_fname=default_output_fname, **kwargs): """Return a ReachProcessor by processing an abstract with a given Pubmed id. Uses the Pubmed client to get the abstract. If that fails, None is returned. Parameters -----...
[ "def", "process_pubmed_abstract", "(", "pubmed_id", ",", "offline", "=", "False", ",", "output_fname", "=", "default_output_fname", ",", "*", "*", "kwargs", ")", ":", "abs_txt", "=", "pubmed_client", ".", "get_abstract", "(", "pubmed_id", ")", "if", "abs_txt", ...
Return a ReachProcessor by processing an abstract with a given Pubmed id. Uses the Pubmed client to get the abstract. If that fails, None is returned. Parameters ---------- pubmed_id : str The ID of a Pubmed article. The string may start with PMID but passing just the ID also works...
[ "Return", "a", "ReachProcessor", "by", "processing", "an", "abstract", "with", "a", "given", "Pubmed", "id", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/api.py#L77-L115
sorgerlab/indra
indra/sources/reach/api.py
process_text
def process_text(text, citation=None, offline=False, output_fname=default_output_fname, timeout=None): """Return a ReachProcessor by processing the given text. Parameters ---------- text : str The text to be processed. citation : Optional[str] A PubMed ID passed to ...
python
def process_text(text, citation=None, offline=False, output_fname=default_output_fname, timeout=None): """Return a ReachProcessor by processing the given text. Parameters ---------- text : str The text to be processed. citation : Optional[str] A PubMed ID passed to ...
[ "def", "process_text", "(", "text", ",", "citation", "=", "None", ",", "offline", "=", "False", ",", "output_fname", "=", "default_output_fname", ",", "timeout", "=", "None", ")", ":", "if", "offline", ":", "if", "not", "try_offline", ":", "logger", ".", ...
Return a ReachProcessor by processing the given text. Parameters ---------- text : str The text to be processed. citation : Optional[str] A PubMed ID passed to be used in the evidence for the extracted INDRA Statements. This is used when the text to be processed comes from ...
[ "Return", "a", "ReachProcessor", "by", "processing", "the", "given", "text", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/api.py#L118-L187
sorgerlab/indra
indra/sources/reach/api.py
process_nxml_str
def process_nxml_str(nxml_str, citation=None, offline=False, output_fname=default_output_fname): """Return a ReachProcessor by processing the given NXML string. NXML is the format used by PubmedCentral for papers in the open access subset. Parameters ---------- nxml_str : ...
python
def process_nxml_str(nxml_str, citation=None, offline=False, output_fname=default_output_fname): """Return a ReachProcessor by processing the given NXML string. NXML is the format used by PubmedCentral for papers in the open access subset. Parameters ---------- nxml_str : ...
[ "def", "process_nxml_str", "(", "nxml_str", ",", "citation", "=", "None", ",", "offline", "=", "False", ",", "output_fname", "=", "default_output_fname", ")", ":", "if", "offline", ":", "if", "not", "try_offline", ":", "logger", ".", "error", "(", "'Offline ...
Return a ReachProcessor by processing the given NXML string. NXML is the format used by PubmedCentral for papers in the open access subset. Parameters ---------- nxml_str : str The NXML string to be processed. citation : Optional[str] A PubMed ID passed to be used in the eviden...
[ "Return", "a", "ReachProcessor", "by", "processing", "the", "given", "NXML", "string", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/api.py#L190-L261
sorgerlab/indra
indra/sources/reach/api.py
process_nxml_file
def process_nxml_file(file_name, citation=None, offline=False, output_fname=default_output_fname): """Return a ReachProcessor by processing the given NXML file. NXML is the format used by PubmedCentral for papers in the open access subset. Parameters ---------- file_name ...
python
def process_nxml_file(file_name, citation=None, offline=False, output_fname=default_output_fname): """Return a ReachProcessor by processing the given NXML file. NXML is the format used by PubmedCentral for papers in the open access subset. Parameters ---------- file_name ...
[ "def", "process_nxml_file", "(", "file_name", ",", "citation", "=", "None", ",", "offline", "=", "False", ",", "output_fname", "=", "default_output_fname", ")", ":", "with", "open", "(", "file_name", ",", "'rb'", ")", "as", "f", ":", "nxml_str", "=", "f", ...
Return a ReachProcessor by processing the given NXML file. NXML is the format used by PubmedCentral for papers in the open access subset. Parameters ---------- file_name : str The name of the NXML file to be processed. citation : Optional[str] A PubMed ID passed to be used in t...
[ "Return", "a", "ReachProcessor", "by", "processing", "the", "given", "NXML", "file", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/api.py#L264-L293
sorgerlab/indra
indra/sources/reach/api.py
process_json_file
def process_json_file(file_name, citation=None): """Return a ReachProcessor by processing the given REACH json file. The output from the REACH parser is in this json format. This function is useful if the output is saved as a file and needs to be processed. For more information on the format, see: http...
python
def process_json_file(file_name, citation=None): """Return a ReachProcessor by processing the given REACH json file. The output from the REACH parser is in this json format. This function is useful if the output is saved as a file and needs to be processed. For more information on the format, see: http...
[ "def", "process_json_file", "(", "file_name", ",", "citation", "=", "None", ")", ":", "try", ":", "with", "open", "(", "file_name", ",", "'rb'", ")", "as", "fh", ":", "json_str", "=", "fh", ".", "read", "(", ")", ".", "decode", "(", "'utf-8'", ")", ...
Return a ReachProcessor by processing the given REACH json file. The output from the REACH parser is in this json format. This function is useful if the output is saved as a file and needs to be processed. For more information on the format, see: https://github.com/clulab/reach Parameters --------...
[ "Return", "a", "ReachProcessor", "by", "processing", "the", "given", "REACH", "json", "file", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/api.py#L296-L322
sorgerlab/indra
indra/sources/reach/api.py
process_json_str
def process_json_str(json_str, citation=None): """Return a ReachProcessor by processing the given REACH json string. The output from the REACH parser is in this json format. For more information on the format, see: https://github.com/clulab/reach Parameters ---------- json_str : str Th...
python
def process_json_str(json_str, citation=None): """Return a ReachProcessor by processing the given REACH json string. The output from the REACH parser is in this json format. For more information on the format, see: https://github.com/clulab/reach Parameters ---------- json_str : str Th...
[ "def", "process_json_str", "(", "json_str", ",", "citation", "=", "None", ")", ":", "if", "not", "isinstance", "(", "json_str", ",", "basestring", ")", ":", "raise", "TypeError", "(", "'{} is {} instead of {}'", ".", "format", "(", "json_str", ",", "json_str",...
Return a ReachProcessor by processing the given REACH json string. The output from the REACH parser is in this json format. For more information on the format, see: https://github.com/clulab/reach Parameters ---------- json_str : str The json string to be processed. citation : Optional...
[ "Return", "a", "ReachProcessor", "by", "processing", "the", "given", "REACH", "json", "string", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/api.py#L325-L369
sorgerlab/indra
indra/tools/reading/wait_for_complete.py
make_parser
def make_parser(): """Generate the parser for this script.""" parser = ArgumentParser( 'wait_for_complete.py', usage='%(prog)s [-h] queue_name [options]', description=('Wait for a set of batch jobs to complete, and monitor ' 'them as they run.'), epilog=('Job...
python
def make_parser(): """Generate the parser for this script.""" parser = ArgumentParser( 'wait_for_complete.py', usage='%(prog)s [-h] queue_name [options]', description=('Wait for a set of batch jobs to complete, and monitor ' 'them as they run.'), epilog=('Job...
[ "def", "make_parser", "(", ")", ":", "parser", "=", "ArgumentParser", "(", "'wait_for_complete.py'", ",", "usage", "=", "'%(prog)s [-h] queue_name [options]'", ",", "description", "=", "(", "'Wait for a set of batch jobs to complete, and monitor '", "'them as they run.'", ")"...
Generate the parser for this script.
[ "Generate", "the", "parser", "for", "this", "script", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/wait_for_complete.py#L4-L66
sorgerlab/indra
indra/literature/__init__.py
id_lookup
def id_lookup(paper_id, idtype): """Take an ID of type PMID, PMCID, or DOI and lookup the other IDs. If the DOI is not found in Pubmed, try to obtain the DOI by doing a reverse-lookup of the DOI in CrossRef using article metadata. Parameters ---------- paper_id : str ID of the article....
python
def id_lookup(paper_id, idtype): """Take an ID of type PMID, PMCID, or DOI and lookup the other IDs. If the DOI is not found in Pubmed, try to obtain the DOI by doing a reverse-lookup of the DOI in CrossRef using article metadata. Parameters ---------- paper_id : str ID of the article....
[ "def", "id_lookup", "(", "paper_id", ",", "idtype", ")", ":", "if", "idtype", "not", "in", "(", "'pmid'", ",", "'pmcid'", ",", "'doi'", ")", ":", "raise", "ValueError", "(", "\"Invalid idtype %s; must be 'pmid', 'pmcid', \"", "\"or 'doi'.\"", "%", "idtype", ")",...
Take an ID of type PMID, PMCID, or DOI and lookup the other IDs. If the DOI is not found in Pubmed, try to obtain the DOI by doing a reverse-lookup of the DOI in CrossRef using article metadata. Parameters ---------- paper_id : str ID of the article. idtype : str Type of the ID...
[ "Take", "an", "ID", "of", "type", "PMID", "PMCID", "or", "DOI", "and", "lookup", "the", "other", "IDs", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/__init__.py#L19-L71
sorgerlab/indra
indra/literature/__init__.py
get_full_text
def get_full_text(paper_id, idtype, preferred_content_type='text/xml'): """Return the content and the content type of an article. This function retreives the content of an article by its PubMed ID, PubMed Central ID, or DOI. It prioritizes full text content when available and returns an abstract from P...
python
def get_full_text(paper_id, idtype, preferred_content_type='text/xml'): """Return the content and the content type of an article. This function retreives the content of an article by its PubMed ID, PubMed Central ID, or DOI. It prioritizes full text content when available and returns an abstract from P...
[ "def", "get_full_text", "(", "paper_id", ",", "idtype", ",", "preferred_content_type", "=", "'text/xml'", ")", ":", "if", "preferred_content_type", "not", "in", "(", "'text/xml'", ",", "'text/plain'", ",", "'application/pdf'", ")", ":", "raise", "ValueError", "(",...
Return the content and the content type of an article. This function retreives the content of an article by its PubMed ID, PubMed Central ID, or DOI. It prioritizes full text content when available and returns an abstract from PubMed as a fallback. Parameters ---------- paper_id : string ...
[ "Return", "the", "content", "and", "the", "content", "type", "of", "an", "article", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/__init__.py#L74-L244
sorgerlab/indra
indra/sources/reach/reader.py
ReachReader.get_api_ruler
def get_api_ruler(self): """Return the existing reader if it exists or launch a new one. Returns ------- api_ruler : org.clulab.reach.apis.ApiRuler An instance of the REACH ApiRuler class (java object). """ if self.api_ruler is None: try: ...
python
def get_api_ruler(self): """Return the existing reader if it exists or launch a new one. Returns ------- api_ruler : org.clulab.reach.apis.ApiRuler An instance of the REACH ApiRuler class (java object). """ if self.api_ruler is None: try: ...
[ "def", "get_api_ruler", "(", "self", ")", ":", "if", "self", ".", "api_ruler", "is", "None", ":", "try", ":", "self", ".", "api_ruler", "=", "autoclass", "(", "'org.clulab.reach.export.apis.ApiRuler'", ")", "except", "JavaException", "as", "e", ":", "raise", ...
Return the existing reader if it exists or launch a new one. Returns ------- api_ruler : org.clulab.reach.apis.ApiRuler An instance of the REACH ApiRuler class (java object).
[ "Return", "the", "existing", "reader", "if", "it", "exists", "or", "launch", "a", "new", "one", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/reach/reader.py#L55-L69
sorgerlab/indra
indra/sources/biogrid.py
_download_biogrid_data
def _download_biogrid_data(url): """Downloads zipped, tab-separated Biogrid data in .tab2 format. Parameters: ----------- url : str URL of the BioGrid zip file. Returns ------- csv.reader A csv.reader object for iterating over the rows (header has already been skipp...
python
def _download_biogrid_data(url): """Downloads zipped, tab-separated Biogrid data in .tab2 format. Parameters: ----------- url : str URL of the BioGrid zip file. Returns ------- csv.reader A csv.reader object for iterating over the rows (header has already been skipp...
[ "def", "_download_biogrid_data", "(", "url", ")", ":", "res", "=", "requests", ".", "get", "(", "biogrid_file_url", ")", "if", "res", ".", "status_code", "!=", "200", ":", "raise", "Exception", "(", "'Unable to download Biogrid data: status code %s'", "%", "res", ...
Downloads zipped, tab-separated Biogrid data in .tab2 format. Parameters: ----------- url : str URL of the BioGrid zip file. Returns ------- csv.reader A csv.reader object for iterating over the rows (header has already been skipped).
[ "Downloads", "zipped", "tab", "-", "separated", "Biogrid", "data", "in", ".", "tab2", "format", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biogrid.py#L156-L185
sorgerlab/indra
indra/sources/biogrid.py
BiogridProcessor._make_agent
def _make_agent(self, entrez_id, text_id): """Make an Agent object, appropriately grounded. Parameters ---------- entrez_id : str Entrez id number text_id : str A plain text systematic name, or None if not listed. Returns ------- ...
python
def _make_agent(self, entrez_id, text_id): """Make an Agent object, appropriately grounded. Parameters ---------- entrez_id : str Entrez id number text_id : str A plain text systematic name, or None if not listed. Returns ------- ...
[ "def", "_make_agent", "(", "self", ",", "entrez_id", ",", "text_id", ")", ":", "hgnc_name", ",", "db_refs", "=", "self", ".", "_make_db_refs", "(", "entrez_id", ",", "text_id", ")", "if", "hgnc_name", "is", "not", "None", ":", "name", "=", "hgnc_name", "...
Make an Agent object, appropriately grounded. Parameters ---------- entrez_id : str Entrez id number text_id : str A plain text systematic name, or None if not listed. Returns ------- agent : indra.statements.Agent A grounded ...
[ "Make", "an", "Agent", "object", "appropriately", "grounded", "." ]
train
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biogrid.py#L97-L121