def get_clauses(id_dict, db):
    """Get a list of clauses to be passed to a db query.

    Note that an empty condition will be returned if id_dict has no ids in it
    (either the dict is empty or all the lists within the dict are empty),
    which will in general have the unexpected effect of selecting everything,
    rather than nothing.

    Parameters
    ----------
    id_dict : dict {id_type: [int or str]}
        A dictionary indexed by the type of id, containing lists of id's of
        that the respective type. If all the lists are empty, or the dict is
        empty, returns an empty condition. Note that id types of 'trid' and
        'tcid' will be mapped to text ref ids and text content ids,
        respectively.
    db : indra.db.DatabaseManager instance
        This instance is only used for forming the query, and will not be
        accessed or queried.

    Returns
    -------
    clause_list : list [sqlalchemy clauses]
        A list of sqlalchemy clauses to be used in query in the form:
        `db.filter_query(<table>, <other clauses>, *clause_list)`.
        If the id_dict has no ids, an effectively empty condition is returned.
    """
    # Handle all id types but text ref ids (trid) and text content ids (tcid).
    id_condition_list = [getattr(db.TextRef, id_type).in_(id_list)
                         for id_type, id_list in id_dict.items()
                         if len(id_list) and id_type not in ['tcid', 'trid']]

    # Handle the special id types trid and tcid.
    for id_type, table in [('trid', db.TextRef), ('tcid', db.TextContent)]:
        if id_type in id_dict.keys() and len(id_dict[id_type]):
            int_id_list = [int(i) for i in id_dict[id_type]]
            id_condition_list.append(table.id.in_(int_id_list))
    return id_condition_list