def create_db_links(txt_tuple_iter, link_format):
    """
    From an iterable containing DB info for records in DB or 'not in DB' if no
    records were found, returns info formatted as url links to detail pages of
    the records.

    :param txt_tuple_iter: an iterable of strings and tuples where the 0
                           element of the tuple is the gene/residue and element
                           1 is the DB key of the record
                           (iter of tuples and strs)
    :link_format: a tuple where the 0th element is the detail page relevant for
                  the records passed and element 1 is a tuple of the position
                  of the txt to display in the txt_tuple_iter and the position
                  of the DB key in the txt_tuple_iter
                  ('page', (txt, position, key position)) (len 2 tuple)
    :return: string containing URL links to each entry (str)
    """
    if txt_tuple_iter != 'not in DB':
        detail_page = link_format[0]
        line_links = []
        for info in txt_tuple_iter:
            key = info[link_format[1][1]]
            txt = info[link_format[1][0]]
            line_links.append('<a target="_blank" href="/%s/%s">%s</a>'
                               % (detail_page, key, txt))
        line = ', '.join(line_links)
    else:
        line = 'not in DB'
    return line