def __init__(self, rf: bool=False, atts: Sctids=None, eq: bool=True, ecv: Sctids=None, query=None, _mt_instance=None):
     """
     Construct a set of quads from
     :param rf: reverse flag.  If true ecv applies to source.  If false, destination
     :param atts: attributes (types)
     :param eq: If true, test for equal, if false, for not equal
     :param ecv: sources / destinations for testing
     :param query:  query to use instead of constructing.  Still need rf
     :return:
     """
     Set.__init__(self, Quads)
     _Instance.__init__(self, RF2_Quad)
     RF2_Substrate_Common.__init__(self)
     self._val = self
     self._type = Quads
     if _mt_instance:
         self._query = "SELECT id AS rid, sourceId AS id, typeId, destinationId, gid FROM %s WHERE 0" % \
                       (RelationshipDB.fname() + "_ext")
         self.rf = False
         self._len = 0
     else:
         self._len = None                # number of elements
         if query:
             self._query = query
         else:
             self._query = "SELECT id AS rid, sourceId" + (" AS id," if not rf else ",")
             self._query += " typeId, destinationId" + (" AS id," if rf else ",")
             self._query += " gid FROM %s" % RelationshipDB.fname() + '_ext'
             self._query += " WHERE "
             if atts is not None:
                 self._query += (("typeId IN (%s)" % atts.as_sql()) if eq else
                                 ("typeId NOT IN (%s)" % atts.as_sql())) + " AND "
             if ecv is not None:
                 self._query += (("sourceId IN (%s)" % ecv.as_sql()) if rf else
                                 ("destinationId IN (%s)" % ecv.as_sql())) + " AND "
             self._query += "active=1 AND locked=0"
         self.rf = rf
def ancestorsOrSelf_of(query: Sctids) -> Sctids:
    return Sctids(query=_self_query % (_transitive_query % ("parent", query.as_sql(), "child"), query.as_sql()))
def ancestors_of(query: Sctids) -> Sctids:
    return Sctids(query=_transitive_query % ("parent", query.as_sql(), "child"))
def descendantsOrSelf_of(query: Sctids) -> Sctids:
    return Sctids(query=_self_query % (_transitive_query % ("child", query.as_sql(), "parent"), query.as_sql()))
def descendants_of(query: Sctids) -> Sctids:
    return Sctids(query=_transitive_query % ("child", query.as_sql(), "parent"))