A cluster is an ordered set of hits related to a model which satisfy the model distance constraints.


class macsypy.cluster.Cluster(hits, model, hit_wheights)[source]

Handle hits relative to a model which collocates

Parameters:v_hit (macsypy.hit.ValidHit object) – The hit to test
Returns:True if the hit is in the cluster hits, False otherwise
__init__(hits, model, hit_wheights)[source]
Returns:a string representation of this cluster

list of weak references to the object (if defined)

Raise:MacsypyError if all hits of a cluster are NOT related to the same replicon
Parameters:gene (macsypy.gene.Gene object) – The gene which must be tested.
Returns:True if the cluster contains one hit which fulfill the function corresponding to the gene (the gene hitself or an exchageable)
Returns:True if this cluster is made of only one hit representing a loner gene
merge(cluster, before=False)[source]

merge the cluster in this one. (do it in place)

  • cluster (macsypy.cluster.Cluster object) –
  • before (bool) – If False the hits of the cluster will be add at the end of this one, Otherwise the cluster hits will be inserted before the hits of this one.



MacsypyError – if the two clusters have not the same model

macsypy.cluster.build_clusters(hits, rep_info, model, hit_weights)[source]

From a list of filtered hits, and replicon information (topology, length), build all lists of hits that satisfied the constraints:

  • max_gene_inter_space
  • loner
  • multi_system

If Yes create a cluster A cluster contains at least two hits separated by less or equal than max_gene_inter_space Except for loner genes which are allowed to be alone in a cluster

  • hits (list of macsypy.hit.Hit objects) – list of filtered hits
  • rep_info (macsypy.Indexes.RepliconInfo object) – the replicon to analyse
  • model (macsypy.model.Model object) – the model to study

list of clusters

Return type:

List of Cluster objects

macsypy.cluster.filter_loners(cluster, loners)[source]

filter loners to remove those which are already in the cluster


list of loners which are not already in the cluster

Return type:

[Clsuter, ..]

macsypy.cluster.get_loners(hits, model, hit_weights)[source]

Create a list of Clusters each cluster is build with one hit matching a loner

  • hits – The list of hits to filter
  • model (macsypy.model.Model object) – the model which will used to build the clusters

The list of cluster which each element is build at least with one loner

Return type:

[Cluster, ..]