def _add_component_pathway_association(self, gene_curie, pathway_curie, pathway_label, eco_curie): pathway = Pathway(self.graph) pathway.addPathway(pathway_curie, pathway_label) pathway.addComponentToPathway(gene_curie, pathway_curie) association = Assoc(self.graph, self.name) association.sub = gene_curie association.rel = self.globaltt['involved in'] association.obj = pathway_curie association.set_association_id() association.add_evidence(eco_curie) association.add_association_to_graph()
def _add_component_pathway_association( self, eco_map, component, component_prefix, pathway_id, pathway_prefix, pathway_label, go_ecode): pathway = Pathway(self.graph) pathway_curie = "{}:{}".format(pathway_prefix, pathway_id) gene_curie = "{}:{}".format(component_prefix, component.strip()) eco_curie = eco_map[go_ecode] pathway.addPathway(pathway_curie, pathway_label) pathway.addComponentToPathway(gene_curie, pathway_curie) association = Assoc(self.graph, self.name) association.sub = gene_curie association.rel = pathway.object_properties['involved_in'] association.obj = pathway_curie association.set_association_id() association.add_evidence(eco_curie) association.add_association_to_graph() return
def _add_component_pathway_association( self, eco_map, component, component_prefix, pathway_id, pathway_prefix, pathway_label, go_ecode): pathway = Pathway(self.graph) pathway_curie = "{}:{}".format(pathway_prefix, pathway_id) gene_curie = "{}:{}".format(component_prefix, component.strip()) eco_curie = eco_map[go_ecode] pathway.addPathway(pathway_curie, pathway_label) pathway.addComponentToPathway(gene_curie, pathway_curie) association = Assoc(self.graph, self.name) association.sub = gene_curie association.rel = self.globaltt['involved in'] association.obj = pathway_curie association.set_association_id() association.add_evidence(eco_curie) association.add_association_to_graph() return
def _parse_aeolus_data(self, document, or_limit=None): model = Model(self.graph) rxcui_curie = "RXCUI:{}".format(document['aeolus']['rxcui']) uni_curie = "UNII:{}".format(document['aeolus']['unii']) model.addLabel(rxcui_curie, document['aeolus']['drug_name']) model.addLabel(uni_curie, document['aeolus']['drug_name']) model.addSameIndividual(rxcui_curie, uni_curie) self.graph.addTriple(rxcui_curie, model.annotation_properties['inchi_key'], document['unii']['inchikey'], object_is_literal=True) if or_limit is not None: outcomes = (outcome for outcome in document['aeolus']['outcomes'] if 'ror' in outcome and outcome['ror'] >= or_limit) else: outcomes = (outcome for outcome in document['aeolus']['outcomes']) for outcome in outcomes: drug2outcome_assoc = Assoc(self.graph, self.name) meddra_curie = "MEDDRA:{}".format(outcome['code']) model.addLabel(meddra_curie, outcome['name']) drug2outcome_assoc.sub = rxcui_curie drug2outcome_assoc.obj = meddra_curie drug2outcome_assoc.rel = Assoc.object_properties[ 'causes_or_contributes'] drug2outcome_assoc.description = \ "A proportional reporting ratio or odds " \ "ratio greater than or equal to {} in the " \ "AEOLUS data was the significance cut-off " \ "used for creating drug-outcome associations".format(or_limit) drug2outcome_assoc.add_association_to_graph() drug2outcome_assoc.add_predicate_object( Assoc.annotation_properties['probabalistic_quantifier'], outcome['ror'], 'Literal') self._add_outcome_evidence(drug2outcome_assoc.assoc_id, outcome) self._add_outcome_provenance(drug2outcome_assoc.assoc_id, outcome)
def _add_gene_anatomy_association(self, gene_id, anatomy_curie, rank): """ :param gene_id: str Non curified ID :param gene_label: str Gene symbol :param anatomy_curie: str curified anatomy term :param rank: str rank :return: None """ g2a_association = Assoc(self.graph, self.name) model = Model(self.graph) gene_curie = "ENSEMBL:{}".format(gene_id) rank = re.sub(r',', '', str(rank)) # ? can't do RE on a float ... model.addIndividualToGraph(gene_curie, None) g2a_association.sub = gene_curie g2a_association.obj = anatomy_curie g2a_association.rel = self.globaltt['expressed in'] g2a_association.add_association_to_graph() g2a_association.add_predicate_object( self.globaltt['has_quantifier'], float(rank), 'Literal', 'xsd:float')
def _add_gene_anatomy_association(self, gene_id, anatomy_curie, rank): """ :param gene_id: str Non curified ID :param gene_label: str Gene symbol :param anatomy_curie: str curified anatomy term :param rank: str rank :return: None """ g2a_association = Assoc(self.graph, self.name) model = Model(self.graph) gene_curie = "ENSEMBL:{}".format(gene_id) rank = re.sub(r',', '', str(rank)) # ? can't do RE on a float ... model.addIndividualToGraph(gene_curie, None) g2a_association.sub = gene_curie g2a_association.obj = anatomy_curie g2a_association.rel = self.globaltt['expressed in'] g2a_association.add_association_to_graph() g2a_association.add_predicate_object( self.globaltt['has_quantifier'], float(rank), 'Literal', 'xsd:float') return
def _parse_aeolus_data(self, document, or_limit=None): model = Model(self.graph) rxcui_curie = "RXCUI:{}".format(document['aeolus']['rxcui']) uni_curie = "UNII:{}".format(document['aeolus']['unii']) model.addLabel(rxcui_curie, document['aeolus']['drug_name']) model.addLabel(uni_curie, document['aeolus']['drug_name']) model.addSameIndividual(rxcui_curie, uni_curie) self.graph.addTriple( rxcui_curie, self.globaltt['inchi_key'], document['unii']['inchikey'], object_is_literal=True) if or_limit is not None: outcomes = (outcome for outcome in document['aeolus']['outcomes'] if 'ror' in outcome and outcome['ror'] >= or_limit) else: outcomes = (outcome for outcome in document['aeolus']['outcomes']) for outcome in outcomes: drug2outcome_assoc = Assoc(self.graph, self.name) meddra_curie = "MEDDRA:{}".format(outcome['code']) model.addLabel(meddra_curie, outcome['name']) drug2outcome_assoc.sub = rxcui_curie drug2outcome_assoc.obj = meddra_curie drug2outcome_assoc.rel = self.globaltt['causes_or_contributes'] drug2outcome_assoc.description = \ "A proportional reporting ratio or odds " \ "ratio greater than or equal to {} in the " \ "AEOLUS data was the significance cut-off " \ "used for creating drug-outcome associations".format(or_limit) drug2outcome_assoc.add_association_to_graph() drug2outcome_assoc.add_predicate_object( self.globaltt['probabalistic_quantifier'], outcome['ror'], 'Literal') self._add_outcome_evidence(drug2outcome_assoc.assoc_id, outcome) self._add_outcome_provenance(drug2outcome_assoc.assoc_id, outcome)
def _add_gene_anatomy_association(self, gene_id, anatomy_curie, rank): """ :param gene_id: str Non curified ID :param gene_label: str Gene symbol :param anatomy_curie: str curified anatomy term :param rank: str rank :return: None """ g2a_association = Assoc(self.graph, self.name) genotype = Genotype(self.graph) model = Model(self.graph) gene_curie = "ENSEMBL:{}".format(gene_id) rank = re.sub(r',', '', rank) model.addIndividualToGraph(ind_id=gene_curie, label=None, ind_type=genotype.genoparts['gene']) g2a_association.sub = gene_curie g2a_association.obj = anatomy_curie g2a_association.rel = Assoc.object_properties['expressed_in'] g2a_association.add_association_to_graph() g2a_association.add_predicate_object( Assoc.datatype_properties['has_quantifier'], float(rank), 'Literal', 'xsd:float') return