def find_loci(self, cluster_size, maxgap, locusview=False, colordict=None):
if colordict != None:<EOL><INDENT>self.search.protein_arrow_color_dict = colordict        <EOL><DEDENT>for organism in self.organisms:<EOL><INDENT>print('<STR_LIT>', organism.name)<EOL>organism.loci = []<EOL>orghits = []<EOL>for protein in organism.proteins:<EOL><INDENT>if len(protein.hmm_hit_list) > <NUM_LIT:0>:<EOL><INDENT>orghits.append((organism.accession, protein.accession, <EOL>protein.start_bp, protein.end_bp, protein))<EOL><DEDENT><DEDENT>bp_start_pooled = [hit[<NUM_LIT:2>] for hit in orghits]  <EOL>try:<EOL><INDENT>clustered_data = self.cluster_number(bp_start_pooled, maxgap)<EOL>significant_cluster_list = []<EOL>for cluster in clustered_data:<EOL><INDENT>if len(cluster) > cluster_size:<EOL><INDENT>significant_cluster_list.append(cluster)<EOL><DEDENT><DEDENT>for cluster in significant_cluster_list:<EOL><INDENT>proteins_in_locus = []<EOL>cluster.sort()<EOL>for bp_start in cluster:<EOL><INDENT>for hit in orghits:<EOL><INDENT>if bp_start == hit[<NUM_LIT:2>]:<EOL><INDENT>proteins_in_locus.append(hit[<NUM_LIT:4>])<EOL><DEDENT><DEDENT><DEDENT>organism.loci.append(Locus(proteins_in_locus, <EOL>organism, <EOL>self.search.query_names, <EOL>locusview))<EOL><DEDENT><DEDENT>except IndexError as e:<EOL><INDENT>print('<STR_LIT>', str(e), organism.name)<EOL><DEDENT>print('<STR_LIT>', str(len(organism.loci)), '<STR_LIT>', organism.name)<EOL><DEDENT>
Finds the loci of a given cluster size & maximum gap between cluster members.

Args
    cluster_size (int): minimum number of genes in the cluster.
    maxgap (int): max basepair gap between genes in the cluster.

Kwargs
    locusview (bool): whether or not a map is generated for the locus_parent_organism
    colordict (list): pass a pre-made color scheme for identified proteins