def generateWhereClause(self,queryPattern):
        whereClauses = []
        whereParameters = []
        asserted = dereferenceQuad(CONTEXT,queryPattern) is None
        for idx in SlotPrefixes.keys():
            queryTerm = dereferenceQuad(idx,queryPattern)
            lookupAlias = 'rt_'+SlotPrefixes[idx]
            if idx == CONTEXT and asserted:
                whereClauses.append("%s.%s_term != 'F'" % \
                                            (self,self.columnNames[idx]))
            
            if idx < len(POSITION_LIST) and isinstance(queryTerm,REGEXTerm):
                whereClauses.append("%s.lexical REGEXP "%lookupAlias+"%s")
                whereParameters.append(queryTerm)
            elif idx == CONTEXT \
                    and isinstance(queryTerm,Graph) \
                    and isinstance(queryTerm.identifier,REGEXTerm):
                whereClauses.append("%s.lexical REGEXP "%lookupAlias+"%s")
                whereParameters.append(queryTerm.identifier)
            elif idx < len(POSITION_LIST) and queryTerm is not Any:
                if self.columnNames[idx]:
                    
                    if isinstance(queryTerm,list):
                        whereClauses.append("%s.%s" % \
                                (self,self.columnNames[idx])+" in (%s)" % \
                                    ','.join([
                                        '%s' for item in range(len(queryTerm))
                                        ]))
                        whereParameters.extend(
                          [normalizeValue(item, term2Letter(item),
                                          self.useSignedInts)
                           for item in queryTerm])
                    else:
                        whereClauses.append("%s.%s" % \
                                        (self,self.columnNames[idx])+" = %s")
                        whereParameters.append(normalizeValue(
                          queryTerm, term2Letter(queryTerm),
                          self.useSignedInts))
                
                if not idx in self.hardCodedResultTermsTypes \
                        and self.termEnumerations[idx] \
                        and not isinstance(queryTerm,list):
                    whereClauses.append("%s.%s_term" % \
                                (self,self.columnNames[idx])+" = %s")
                    whereParameters.append(term2Letter(queryTerm))
            elif idx >= len(POSITION_LIST) \
                    and len(self.columnNames) > len(POSITION_LIST) \
                    and queryTerm is not None:
                compVal = idx == DATATYPE_INDEX and normalizeValue(
                  queryTerm, term2Letter(queryTerm),
                  self.useSignedInts) or queryTerm
                whereClauses.append("%s.%s" % \
                                    (self,self.columnNames[idx][0])+" = %s")
                whereParameters.append(compVal)
        
        return ' AND '.join(whereClauses),whereParameters
                            # + "#{%s}\n"%(str(queryPattern)),whereParameters
Takes a query pattern (a list of quad terms -
dataset/ETHPy150Open RDFLib/rdfextras/rdfextras/store/FOPLRelationalModel/BinaryRelationPartition.py/BinaryRelationPartition.generateWhereClause