Esempio n. 1
0
    def combinator(self):
        Restriction = cmb.Restriction(None)
        combinator = cmb.ObjectCombinator.full_combinator(
            cmb.Class,
            cmb.Pair(owl.complementOf, Restriction(self.predicate,
                                                   self.object)))

        return combinator
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
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)
Esempio n. 5
0
 def getRestSubjects(predicate, object, g):
     """ invert restriction """
     rsco = cmb.Restriction(rdfs.subClassOf)
     for rt in rsco.parse(graph=g):
         if rt.p == predicate and rt.o == object:
             yield from g.transitive_subjects(rdfs.subClassOf, rt.s)
Esempio n. 6
0
 def combinator(self):
     """ yes, this is a property that returns a function """
     # NOTE a surrounding combinator is needed at the phenotype
     # collection level
     combinator = cmb.Restriction(None)
     return combinator(self.predicate, self.object)
Esempio n. 7
0
 def triples(self):
     list_ = cmb.List({owl.Restriction: cmb.Restriction(rdf.first)})
     yield self.identifier, a, owl.Class
     conbinators = (p.combinator for p in self)
     yield from list_.serialize(self.identifier, self.operator,
                                *combinators)