solution
MacSyFinder find lot of potential systems for the same model, all these systems are saved in “all_systems.xxx” files. This module allow to explore among of all systems which combination seems to be more probable.
solution API reference
Solution
- class macsypy.solution.Solution(systems: list[System])[source]
Handle Solution, a solution is a set of compatible Systems
when compare solutions we check the following criteria
The number of hits
The number of systems
The average of wholeness
The hits position (is used ti give predictable output for unit tests)
- __hash__ = None
- __init__(systems: list[System]) None [source]
- Parameters:
systems – The list of system that composed this solution
- __weakref__
list of weak references to the object (if defined)
- _sorted_systems(systems: list[System]) list[System] [source]
sort the systems following the positions of th hits that composed the systems
- Parameters:
systems (list of
mcsypy.system.System
objects) – the systems to sort- Returns:
a sorted copy of the systems
- Return type:
list of
mcsypy.system.System
objects
- property average_wholeness: float
The average of the systems wholeness
- property hits_number: int
The sum of the hits of each system in this solution
- property hits_positions: list[int]
The list of position of all hits of the solution
- property score: float
The score of this solution
combine_clusters
- macsypy.solution.combine_clusters(clusters: list[~macsypy.cluster.Cluster], true_loners: dict[slice(<class 'str'>, macsypy.hit.Loner | macsypy.hit.LonerMultiSystem, None)], multi_loci: bool = False) list[tuple[Cluster]] [source]
generate the combinations of clusters, with loners and multi systems
- Parameters:
clusters – the clusters to combines
true_loners (dict the name of the function code by hit gene_ref.alternate_of as key and 1
macsypy.cluster.Cluster
with the best amacsypy.hit.Loner
ormacsypy.hit.LonerMultiSystem
hit as value) – the multi-systems hitsmulti_loci – True if the model is multi_loci false otherwise
- Returns:
all available combination of clusters
- Return type:
List of combination. a combination is a tuple of
macsypy.cluster.Cluster
objects
combine_multisystems
- macsypy.solution.combine_multisystems(rejected_candidates: list[RejectedCandidate], multi_systems: list[Cluster])[source]
- Parameters:
rejected_candidates –
multi_systems – sequence of
macsypy.cluster.Cluster
each cluster must be composed of only onemacsypy.hit.MultiSystem
object
- Returns:
list of cluster combination with the multisystem
- Return type:
[(
macsypy.cluster.Cluster
cluster1, cluster2, …), (macsypy.cluster.Cluster
cluster3, cluster4, …)]
find_best_solutions
- macsypy.solution.find_best_solutions(systems: list[System]) tuple[list[Solution], float] [source]
Among the systems choose the combination of systems which does not share
macsypy.hit.CoreHit
and maximize the sum of systems scores- Parameters:
systems – the systems to analyse
- Returns:
the list of
macsypy.solution.Solution
which represent one best solution then it’s score.- Return type:
tuple of 2 elements the best solutions and it’s score