def cdhit(seqs, out_file=None, temp_dir=None, threshold=<NUM_LIT>, make_db=True, quiet=False, threads=<NUM_LIT:0>, max_memory=<NUM_LIT>, retries=<NUM_LIT:5>, debug=False):
start_time = time.time()<EOL>seqs = [Sequence(s) for s in seqs]<EOL>if not quiet:<EOL><INDENT>print('<STR_LIT>'.format(len(seqs)))<EOL><DEDENT>if out_file is None:<EOL><INDENT>out_file = tempfile.NamedTemporaryFile(dir=temp_dir, delete=False)<EOL>out_file.close()<EOL>ofile = out_file.name<EOL><DEDENT>else:<EOL><INDENT>ofile = os.path.expanduser(out_file)<EOL><DEDENT>cfile = ofile + '<STR_LIT>'<EOL>with open(ofile, '<STR_LIT:w>') as f: f.write('<STR_LIT>')<EOL>with open(cfile, '<STR_LIT:w>') as f: f.write('<STR_LIT>')<EOL>ifile = _make_cdhit_input(seqs, temp_dir)<EOL>cdhit_cmd = '<STR_LIT>'.format(ifile,<EOL>ofile,<EOL>threshold,<EOL>threads,<EOL>max_memory)<EOL>while not all([os.path.getsize(cfile), os.path.getsize(cfile)]):<EOL><INDENT>cluster = sp.Popen(cdhit_cmd,<EOL>shell=True,<EOL>stdout=sp.PIPE,<EOL>stderr=sp.PIPE)<EOL>stdout, stderr = cluster.communicate()<EOL>if not retries:<EOL><INDENT>break<EOL><DEDENT>retries -= <NUM_LIT:1><EOL><DEDENT>end_time = time.time()<EOL>if debug:<EOL><INDENT>print(stdout)<EOL>print(stderr)<EOL><DEDENT>else:<EOL><INDENT>os.unlink(ifile)<EOL><DEDENT>if not quiet:<EOL><INDENT>print('<STR_LIT>'.format(end_time - start_time))<EOL><DEDENT>if make_db:<EOL><INDENT>if not quiet:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>seq_db, db_path = _build_seq_db(seqs, direc=temp_dir)<EOL>return ofile, cfile, seq_db, db_path<EOL><DEDENT>return ofile, cfile<EOL>
Run CD-HIT.

Args:

    seqs (list): An iterable of sequences, in any format that `abutils.utils.sequence.Sequence()`
        can handle

    threshold (float): Clustering identity threshold. Default is `0.975`.

    out_file (str): Path to the clustering output file. Default is to use
        `tempfile.NamedTemporaryFile` to generate an output file name.

    temp_dir (str): Path to the temporary directory. If not provided, `'/tmp'` is used.

    make_db (bool): Whether to build a SQlite database of sequence information. Required
        if you want to calculate consensus/centroid sequences for the resulting
        clusters or if you need to access the clustered sequences (not just sequence IDs)
        Default is `True`.

    quiet (bool): If `True`, surpresses printing of output/progress info. Default is `False`.

    threads (int): Number of threads (CPU cores) to be used for clustering. Default is `0`,
        which results in all available cores being used.

    max_memory (int): Max memory (in MB) for CD-HIT. Will be passed directly to CD-HIT through
        the `-M` runtime option. Default is `800`.

    debug (bool): If `True`, print standard output and standard error from CD-HIT. Default is `False`.

Returns:

    If `make_db` is `True`, returns the CD-HIT output file path, the CD-HIT cluster file path,
        a `sqlite3` database connection object, and the database path. If `make_db` is `False`, only the
        CD-HIT output file path and CD-HIT cluster file path are returned.