def convert(value): if value == 'Projection neuron': e = ilxtr.ProjectionPhenotype else: e = value id = OntId(e.strip()) if ':' in e else e.strip() if id.prefix == 'ILX': t = id.asInstrumented() id = t.asPreferred() return id
def things(self): def process(k, v): if ',' in v: return [rdflib.Literal(_.strip()) for _ in v.split(',')] elif k == 'synonyms': return [rdflib.Literal(v)] else: return rdflib.Literal(v) lexical = 'synonyms', 'molecule', 'comments', 'hiddenlabel' for row in self.byCol.rows: if not any(row): continue idents = {k:OntTerm(v) for k, v in row._asdict().items() if v and k not in lexical} lex = {k:process(k, v) for k, v in row._asdict().items() if v and k in lexical} members = set(idents.values()) mol = lex['molecule'] hl = lex['hiddenlabel'] if 'hiddenlabel' in lex else mol label = f'{mol} (indicator)' id = OntId('TEMPIND:' + mol) thing = {'id': id, 'label': rdflib.Literal(label), 'hiddenLabel': hl, 'synonyms': lex['synonyms'], 'members': members,} yield thing
def convert(value): if value == 'Projection neuron': e = ilxtr.ProjectionPhenotype else: e = value return OntId(e.strip()) if ':' in e else e.strip()
def triples_data(self): s = ilxtr.PhenotypeIndicator yield s, a, owl.Class yield s, rdfs.label, rdflib.Literal('phenotype indicator') for thing in self.things: yield from self.indicator(thing) # FIXME rework the sheet and move this stuff to it # or start editing the indicators file directly # making use of OntGraph diff utilities sst = OntId('TEMPIND:Sst').u yield sst, a, owl.Class yield sst, rdfs.subClassOf, ilxtr.PhenotypeIndicator yield sst, rdfs.label, rdflib.Literal('somatostatin (indicator)') yield sst, skos.hiddenLabel, rdflib.Literal('Sst') yield sst, NIFRID.synonym, rdflib.Literal('Sst') yield sst, NIFRID.synonym, rdflib.Literal('SOM') yield sst, NIFRID.synonym, rdflib.Literal('somatostatin') sst_members = (OntId('ilxtr:SST-flp'), OntId('PTHR:10558'), OntId('NIFEXT:5116'), OntId('NCBIGene:20604'), OntId('PR:000015665'), OntId('JAX:013044'), OntId('JAX:028579'),) for i in sst_members: yield i.u, rdfs.subClassOf, sst # pv fix pheno = rdflib.Namespace(ilxtr[''] + 'Phenotype/') pv = OntId('TEMPIND:Pvalb').u yield pv, rdfs.label, rdflib.Literal('parvalbumin (indicator)') yield pv, skos.hiddenLabel, rdflib.Literal('PV') yield pv, NIFRID.synonym, rdflib.Literal('PV') yield pv, NIFRID.synonym, rdflib.Literal('Pvalb') yield pv, NIFRID.synonym, rdflib.Literal('parvalbumin') #yield pv, ilxtr.indicatesDisplayOfPhenotype, pheno.parvalbumin # as restriction ... yield from ((pv, rdf.type, owl.Class), (pv, rdfs.subClassOf, ilxtr.PhenotypeIndicator),) pv_members = (OntId('JAX:008069'), OntId('JAX:021189'), OntId('JAX:021190'), OntId('JAX:022730'), OntId('JAX:017320'), ilxtr.Pvalb, OntId('PTHR:11653'), ilxtr['PV-cre'], OntId('PR:000013502'), OntId('NCBIGene:19293'), OntId('NIFEXT:6'),) for i in pv_members: s = i.u if isinstance(i, OntId) else i yield s, rdfs.subClassOf, pv