system

This module classes and functions which a given set of hits and a model compute if this set satisfy the model or not

The object which check the compliance of hits to a model is MatchMaker which have 2 sub-classes for ordered and unordered replicons

MatchMaker.match method link hit to a model (macsypy.hit.ValidHit) and then check if these valid hit satisfy the quorum constraints defined in the model. According this it instanciate a macsypy.system.System or macsypy.system.RejectedClusters for ordered replicons or macsypy.system.LikelySystem or macsypy.system.UnlikelySystem for unordered replicons

below the inheritance diagram:

Inheritance diagram of macsypy.system.System, macsypy.system.RejectedClusters, macsypy.system.LikelySystem, macsypy.system.UnlikelySystem

Warning

The abstract class macsypy.system.AbstractSetOfHits is controlled by the metaclass macsypy.system.MetaSetOfHits which inject on the fly several private attributes and public properties (see more in macsypy.system.MetaSetOfHits documentation)

System

class macsypy.system.AbstractSetOfHits(model, replicon_name)[source]

Is the mother class of System, RejectedCluster, LikelySystems UnlikelySystem, …

__init__(model, replicon_name)[source]

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

count()[source]

fill structures one for supported status mandatory, accessory, … each structure count how many hit for each gene of the model mandatory_occ = { gene_name : [ValidHit, …] :return: None

position
Returns:The position of the first and last hit, excluded the hit coding for loners. If the system is composed only by loners, used loners to compute position
Return type:tuple (start: int, end:int)
replicon_name
Returns:The name of the replicon
Return type:str
wholeness
Returns:a score indicating the genes ratio of the model which have at least one hit by default full system is mandatory + accessory (‘neutral’ genes do not count) but for special corner case it can be sepcified in model definition (xml) or on the command line
Return type:float
class macsypy.system.AbstractUnordered(model, mandatory_hits, accessory_hits, neutral_hits, forbidden_hits)[source]

Technical abstract class to factorize code share between LikelySystem and UnlikelySystem

__init__(model, mandatory_hits, accessory_hits, neutral_hits, forbidden_hits)[source]

Initialize self. See help(type(self)) for accurate signature.

accessory_hits
Returns:The list of accesory hits
Return type:list of macsypy.hit.ValidHit objects
allowed_hits
Returns:The list of allowed (mandatory, accessory, neutral) hits
Return type:list of macsypy.hit.ValidHit objects
forbidden_hits
Returns:The list of forbidden hits
Return type:list of macsypy.hit.ValidHit objects
hits
Returns:The list of all hits sorted by their position
Return type:list of macsypy.hit.ValidHit objects
mandatory_hits
Returns:The list of mandatory hits
Return type:list of macsypy.hit.ValidHit objects
neutral_hits
Returns:The list of neutral hits
Return type:list of macsypy.hit.ValidHit objects
class macsypy.system.ClusterSystemTracker(systems)[source]

track in which system is implied each cluster

__init__(systems)[source]

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

class macsypy.system.HitSystemTracker(systems)[source]

track in which system is implied each hit

__init__(systems)[source]

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

class macsypy.system.LikelySystem(model, mandatory_hits, accessory_hits, neutral_hits, forbidden_hits)[source]

” Handle components that fill the quorum requirements defined in model. with no idea about genetic organization (gene cluster) so we cannot take in account forbidden genes

__str__()[source]
Returns:a string representation of this LikelySystem
class macsypy.system.MatchMaker(model)[source]

Is an abstract class for (Odered/Unordered)MatchMaker the match class method must be implemented in concrete classes

__init__(model)[source]

Initialize self. See help(type(self)) for accurate signature.

__weakref__

list of weak references to the object (if defined)

_create_exchangeable_map(genes)[source]

create a map between an exchangeable (formly homolog or analog) gene name and it’s gene reference

Parameters:genes (list of macsypy.gene.ModelGene objects) – The genes to get the exchangeable genes
Return type:a dict with keys are the exchangeable gene_name and the value the reference gene name
present_genes()[source]
Returns:the lists of genes name in model which are present replicon (included exchangeable)
Return type:tuple of 4 lists for mandatory, accessory, neutral and forbidden ([str gene_name, ..], [str gene_name], [str gene_name], [str gene_name])
sort_hits_by_status(hits)[source]

sort macsypy.hit.Hit according the the status of the gene the hit code for.

Parameters:hits – list of macsypy.hit.Hit object
Returns:the valid hits according their status
Return type:a tuple of 4 lists
class macsypy.system.MetaSetOfHits[source]

This metaclass control the AbstractSetOfHits class creation. In this metaclass we inject on the fly several attributes and properties two private attributes and one public property corresponding to each value of _supported_status class attribute defined in the concrete classes. for instance for System class

  • the attributes
    • self._mandatory
    • self._mandatory_occ
    • self._accessory
    • self._accessory_occ
    • self._neutral
    • self._neutral_occ
  • and the properties
    • mandatory
    • accessory
    • neutral

are automatically injected

The value for attributes _<status>_occ are filled by the count method which is defined in AbstractSetOfHits

__call__(*args, **kwargs)[source]

Call self as a function.

getter_maker()[source]

Create a property which allow to access to the gene corresponding of the cat of the model

Parameters:cat (str) – the type of gene category to which we create the getter
Returns:unbound method
class macsypy.system.OrderedMatchMaker(model, redundancy_penalty)[source]

check if a set of hits match the quorum for ordered replicons (ordered_replicon or gembase)

__init__(model, redundancy_penalty)[source]

Initialize self. See help(type(self)) for accurate signature.

match(clusters)[source]

Check a set of clusters fill model constraints. If yes create a macsypy.system.System otherwise create a macsypy.cluster.RejectedClusters.

Parameters:clusters (list of macsypy.cluster.Cluster objects) – The list of cluster to check if fit the model
Returns:either a System or a RejectedClusters
Return type:macsypy.system.System or macsypy.cluster.RejectedClusters object
class macsypy.system.RejectedClusters(model, clusters, reasons)[source]

Handle a set of clusters which has been rejected during the macsypy.system.match() step This clusters (can be one) does not fill the requirements or contains forbidden genes.

__init__(model, clusters, reasons)[source]
Parameters:
__str__()[source]
Returns:a string representation of this RejectedCluster
hits
Returns:The list of all hits that compose this system
Return type:[macsypy.hit.ValidHits , … ]
class macsypy.system.System(model, clusters, redundancy_penalty=1.5)[source]

Modelize as system. a system is an occurrence of a given model on a replicon.

__init__(model, clusters, redundancy_penalty=1.5)[source]
Parameters:
hits
Returns:The list of all hits that compose this system
Return type:[macsypy.hit.ValidHits , … ]
is_compatible(other)[source]
Parameters:other (macsypy.system.System object) – the other systems to test compatibility
Returns:True if other system is compatible with this one. False otherwise. Two systems are compatible if they do not share macsypy.hit.Hit except hit corresponding to a multi_system gene in the model.

Note

This method is used to compute the best combination of systems.

loci_nb
Returns:The number of loci of this system (loners are not considered)
Return type:int >= 0
loci_num
Returns:the number of the corresponding locus for each cluster the cluster made of only one hit reprenting a loner is not considered as a loci so these clusters have the locus_num = 0
Return type:list of int
multi_loci
Returns:True if the systems is encoded in multiple loci. False otherwise
Return type:bool
occurrence()[source]

sometimes several systems collocates so they form only one cluster so macsyfinder build only one system the occurrence is an indicator of how many systems are it’s based on the number of occurrence of each mandatory genes The multi_system genes are not take in account.

Returns:a predict number of biologic systems
score
Returns:a score take in account * if a hit match for the gene or it is an exchangeable gene * if a hit is duplicated and already present in the system or the cluster * if a hit match for mandatory/accessory gene of the model
Return type:float
class macsypy.system.UnlikelySystem(model, mandatory_hits, accessory_hits, neutral_hits, forbidden_hits, reasons)[source]

Handle components that not fill the quorum requirements defined in model.

__init__(model, mandatory_hits, accessory_hits, neutral_hits, forbidden_hits, reasons)[source]
Parameters:
  • model (macsypy.model.Model object) – The model which has ben used to build this system
  • allowed_hits (list of macsypy.hit.ValidHit objects) – The list of hits that form this potential system this hits status must be MANDATORY, ACCESSORY or NEUTRAL
  • forbidden_hits (list of macsypy.hit.ValidHit objects) – The list of hits that are forbidden
  • reasons (List of str) – the reasons why this set of hits has been rejected
__str__()[source]
Returns:a string representation of this UnlikelySystem
reasons
Returns:The reasons why it probably not a system
Return type:list of string
class macsypy.system.UnorderedMatchMaker(model)[source]
match(hits)[source]
Parameters:hits
Returns: