def find_loci(self, cluster_size, maxgap, locusview=False, colordict=None):
        
        '''
        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

        '''

        if colordict != None:
            self.search.protein_arrow_color_dict = colordict        

        for organism in self.organisms:

            print 'finding loci for', organism.name

            #reset loci if there is something in there already
            organism.loci = []
            
            orghits = []
            for protein in organism.proteins:
                if len(protein.hmm_hit_list) > 0:
                    orghits.append((organism.accession, protein.accession, 
                                    protein.start_bp, protein.end_bp, protein))
            
            bp_start_pooled = [hit[2] for hit in orghits]  
            
            try:
                clustered_data = self.cluster_number(bp_start_pooled, maxgap)
            
                significant_cluster_list = []
                for cluster in clustered_data:
                    if len(cluster) > cluster_size:
                        significant_cluster_list.append(cluster)

                #print significant_cluster_list
                
                for cluster in significant_cluster_list:
                    proteins_in_locus = []
                    cluster.sort()
                    for bp_start in cluster:
                        for hit in orghits:
                            if bp_start == hit[2]:
                                proteins_in_locus.append(hit[4])
                    
                    organism.loci.append(Locus(proteins_in_locus, 
                                               organism, 
                                               self.search.query_names, 
                                               locusview))

            except IndexError,e:
                print 'Index error', str(e), organism.name

            print 'total of', str(len(organism.loci)), 'found for', organism.name
def find_loci ( self , cluster_size , maxgap , locusview = False , colordict = None ) : if colordict != None : self . search . protein_arrow_color_dict = colordict for organism in self . organisms : print 'finding loci for' , organism . name organism . loci = [ ] orghits = [ ] for protein in organism . proteins : if len ( protein . hmm_hit_list ) > 0 : orghits . append ( ( organism . accession , protein . accession , protein . start_bp , protein . end_bp , protein ) ) bp_start_pooled = [ hit [ 2 ] for hit in orghits ] try : clustered_data = self . cluster_number ( bp_start_pooled , maxgap ) significant_cluster_list = [ ] for cluster in clustered_data : if len ( cluster ) > cluster_size : significant_cluster_list . append ( cluster ) for cluster in significant_cluster_list : proteins_in_locus = [ ] cluster . sort ( ) for bp_start in cluster : for hit in orghits : if bp_start == hit [ 2 ] : proteins_in_locus . append ( hit [ 4 ] ) organism . loci . append ( Locus ( proteins_in_locus , organism , self . search . query_names , locusview ) ) except IndexError , e : print 'Index error' , str ( e ) , organism . name print 'total of' , str ( len ( organism . loci ) ) , 'found for' , organism . name
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