Example #1
0
    def test_equivalent_to_union_of_complement(self):
        Restriction = cmb.Restriction(None)
        combinator = cmb.ObjectCombinator.full_combinator(
            cmb.Class,
            cmb.Pair(owl.complementOf, Restriction(ilxtr.property,
                                                   ilxtr.value)))
        print(combinator)
        gen = combinator(ilxtr.subject)
        self._doit(gen)

        combinator = cmb.unionOf(combinator)
        print(combinator)
        gen = combinator(ilxtr.subject, owl.equivalentClass)
        self._doit(gen)
Example #2
0
    def test_predicate(self):
        pc = cmb.PredicateCombinator(ilxtr.predicate)
        objects1 = ilxtr.object1, ilxtr.object2
        gen = pc(ilxtr.subject, *objects1)
        self._doit(gen)

        Restriction = cmb.Restriction(None)
        objects2 = (cmb.unionOf(Restriction(ilxtr.property, ilxtr.value1)),
                    cmb.intersectionOf(
                        Restriction(ilxtr.property, ilxtr.value2)))
        gen = pc(ilxtr.subject, *objects2)
        self._doit(gen)

        gen = pc(ilxtr.subject, *objects1, *objects2)
        self._doit(gen)
Example #3
0
    def test_equivalent_to_union_of(self):
        Restriction = cmb.Restriction(None)
        #combinator = cmb.ObjectCombinator.full_combinator(  # broken but don't need ..
        #cmb.Class,
        #cmb.unionOf(Restriction(ilxtr.property, ilxtr.value)))
        combinator = cmb.unionOf(Restriction(ilxtr.property, ilxtr.value))
        #ec = cmb.List({owl.Restriction, rf})
        #combinator = ec(rf(ilxtr.a, ilxtr.b))
        #combinator = ec(cmb.restriction(ilxtr.a, ilxtr.b))
        print(combinator)

        pos1 = combinator(ilxtr.subject, owl.equivalentClass)
        pos2 = combinator(ilxtr.subject)
        pos3 = combinator(ilxtr.subject, ilxtr.thisCanOverwrite)
        self._doit(pos1)
        self._doit(pos2)
        self._doit(pos3)
Example #4
0
    def nodes(self):
        a = rdf.type
        for id, style_type, style_width, label, desc, url in super().nodes():
            s = None
            if desc == 'legend':
                continue
            if url:
                if url.startswith('exact'):
                    s = workflow[url]
                    yield s, a, workflow.exact
                elif url.startswith('RRIDscibot'):
                    s = workflow[url]
                    yield s, a, workflow.tagScibot
                elif any(
                        url.startswith(prefix)
                        for prefix in ('release', 'resolver')):
                    s = wf[url]
                else:
                    s = TEMP[url]
            else:
                if label == 'RRID:':
                    s = workflow['RRID']
                elif label.startswith('RRIDCUR:'):
                    s = RRIDCUR[label.split(':')[-1]]
                    self.different_tags.add(s)
                elif ' + ' in label:
                    suffixes = label.split(' + ')  # FIXME
                    s = BNode()
                    # union of is the right way to go here I think, because union
                    # implies that both must be present, not either or ...
                    yield from unionOf(*(workflow[sfx] for sfx in suffixes))(s)
                    #self.node_name_lookup[id] = s
                    #self.types[s] = wf.tag
                    #continue  # can't yield the type this node
                elif label in ('DOI', 'PMID'):
                    s = wf[label]
                    yield s, a, wf.tag
                else:
                    s = TEMP[label]

            if s is None:  # FIXME if this happens this late we don't get the error message
                raise ValueError(f'unhandled node {id} {lable}')
            else:
                self.node_name_lookup[id] = s

            #yield s, rdf.type, owl.Class
            if isinstance(s, BNode):
                #yield s, a, owl.NamedIndividual  # FIXME apparently this doesn't serializer properly ...
                yield s, a, wf.tag
            elif style_type == 'dashed':
                yield s, a, workflow.state
            elif (style_type, style_width) == ('line', '1.0'):
                pass
            elif (style_type, style_width) == ('line', '2.0'):
                pass
            elif (style_type, style_width) == ('dashed_dotted', '2.0'):
                #yield s, wf.isAttachedTo, wf.pageNote
                self.insert_object(id, wf.pageNoteInstance)
                yield wf.pageNoteInstance, wf.hasTag, s
                if s not in self.types:
                    yield s, a, wf.tagCurator
            elif (style_type, style_width) == ('dotted', '2.0'):
                # yield s, wf.isAttachedTo, wf.pageNote
                self.insert_object(id, wf.pageNoteInstance)
                yield wf.pageNoteInstance, wf.hasTag, s
                if s not in self.types:
                    yield s, a, wf.tagScibot
            else:
                msg = f'{id} {label} has unhandled type {style_type} {style_width}'
                raise ValueError(msg)
Example #5
0
    oc(OntTerm('SO:0000234', label='mRNA'),
       OntId('CHEBI:33697')),  # FIXME not right ...
    (ilxtr.mRNA, owl.equivalentClass, OntTerm('SO:0000234',
                                              label='mRNA')),  # FIXME role?
    (OntTerm('GO:0005575', label='cellular_component'), rdfs.subClassOf,
     ilxtr.physiologicalSystem),
    # FIXME owl:sameAs is NOT for generic iris >_<
    #oc(ilxtr.physiologicalSystem, ilxtr.materialEntity),
    # FIXME what about things that were synthesized entirely?
    # how about... constrainedBy _information_ derived from some organism?
    # a protein is indeed constrained by that information regardless of
    # whether it was synthesized or not...
    #oc(OntTerm('NCBITaxon:1'), ilxtr.materialEntity),  # needed to accomodate deadness?
    oc(ilxtr.physiologicalSystem, ilxtr.materialEntity),
    oc_(ilxtr.physiologicalSystem,
        unionOf(OntTerm('NCBITaxon:1'), restN(partOf,
                                              OntTerm('NCBITaxon:1')))),
    #oec(ilxtr.materialEntity,  # FIXME in vitro...
    #restN(partOf, OntTerm('NCBITaxon:1'))
    #)),
    oc(OntTerm('NCBITaxon:1'),
       ilxtr.physiologicalSystem),  # needed to accomodate deadness?

    #oc_(ilxtr.physiologicalSystemDisjointWithOrganism,
    #oec(ilxtr.physiologicalSystem)
    #),
    #(ilxtr.physiologicalSystemDisjointWithOrganism, owl.disjointWith, OntTerm('NCBITaxon:1')),
    oc(ilxtr.viralParticle, ilxtr.physiologicalSystem),
    oc(ilxtr.AAVretro, ilxtr.viralParticle),
    oc(OntTerm('UBERON:0000465'), ilxtr.materialEntity),
    oc(OntTerm('UBERON:0000955'), OntTerm('UBERON:0000465')),
    oc(OntTerm('UBERON:0007798'), OntTerm('UBERON:0000465')),