Gene API

The Gene object represents genes encoding the protein components of a System. See The Gene object for an overview of the implementation.

Warning

To optimize computation and to avoid concurrency problems when we search several systems, each gene must be instanciated only once, and stored in gene_bank. gene_bank is a macsypy.gene.GeneBank object. The gene_bank and system_bank (macsypy.system.SystemBank object) are filled by a system_parser (macsypy.system_parser.SystemParser)

Example to get a gene object:

from macsypy.system import system_bank
from macsypy.config import Config
from macsypy.gene import gene_bank


#get a system
t2ss =  system_bank["T2SS"]

#get of a gene
pilO = gene_bank["pilO"]

GeneBank API reference

class macsypy.gene.GeneBank[source]

Store all Gene objects. Ensure that genes are instanciated only once.

__contains__(gene)[source]

Implement the membership test operator

Parameters:gene (macsypy.gene.Gene object) – the gene to test
Returns:True if the gene is in, False otherwise
Return type:boolean
__getitem__(name)[source]
Parameters:name (string) – the name of the Gene
Returns:return the Gene corresponding to the name. If the Gene already exists, return it, otherwise, build it and return it
Return type:macsypy.gene.Gene object
__iter__()[source]

Return an iterator object on the genes contained in the bank

__weakref__

list of weak references to the object (if defined)

add_gene(gene)[source]

Add a gene in the bank

Parameters:gene (macsypy.gene.Gene object) – the gene to add
Raise:KeyError if a gene with the same name is already registered

Note

Don’t instanciate your own GeneFactory use the gene_bank at the top level of the module.

from macsypy.gene import gene_bank

Gene API reference

class macsypy.gene.Gene(cfg, name, system, profiles_registry, loner=False, exchangeable=False, multi_system=False, inter_gene_max_space=None)[source]

Handle Gene of a (secretion) System

__eq__(gene)[source]
Returns:True if the gene names (gene.name) are the same, False otherwise.
Parameters:gene (macsypy.gene.Gene object.) – the query of the test
Return type:boolean.
__init__(cfg, name, system, profiles_registry, loner=False, exchangeable=False, multi_system=False, inter_gene_max_space=None)[source]

handle gene

Parameters:
  • cfg (macsypy.config.Config object) – the configuration object.
  • name (string.) – the name of the Gene.
  • system (macsypy.system.System object.) – the system that owns this Gene
  • profiles_registry (macsypy.registries.ProfilesRegistry object.) – where all the paths profiles where register.
  • loner (boolean.) – True if the Gene can be isolated on the genome (with no contiguous genes), False otherwise.
  • exchangeable (boolean.) – True if this Gene can be replaced with one of its homologs or analogs without any effects on the system assessment, False otherwise.
  • multi_system (boolean.) – True if this Gene can belong to different occurrences of this System.
  • inter_gene_max_space (integer) – the maximum space between this Gene and another gene of the System.
__str__()[source]

Print the name of the gene and of its homologs/analogs.

__weakref__

list of weak references to the object (if defined)

add_analog(analog)[source]

Add an analogous gene to the Gene

Parameters:analog (macsypy.gene.Analog object) – analog to add
add_homolog(homolog)[source]

Add a homolog gene to the Gene

Parameters:homolog (macsypy.gene.Homolog object) – homolog to add
exchangeable
Returns:True if this gene can be replaced with one of its homologs or analogs whithout any effects on the system, False otherwise.
Return type:boolean.
get_analogs()[source]
Returns:the Gene analogs
Type:list of macsypy.gene.Analog object
get_compatible_systems(system_list, include_forbidden=True)[source]

Test every system in system_list for compatibility with the gene using the is_authorized function.

Parameters:
  • system_list (list of strings) – a list of system names to test
  • include_forbidden (boolean) – tells if forbidden genes should be considered as defining a compatible systems or not
Returns:

the list of compatible systems

Return type:

list of string, or void list if none compatible

get_homologs()[source]
Returns:the Gene homologs
Type:list of macsypy.gene.Homolog object
inter_gene_max_space
Returns:The maximum distance allowed between this gene and another gene for them to be considered co-localized. If the value is not set at the Gene level, return the value set at the System level.
Return type:integer.
is_accessory(system)[source]
Returns:True if the gene is within the accessory genes of the system, False otherwise.
Parameters:system (macsypy.system.System object.) – the query of the test
Return type:boolean.
is_analog(gene)[source]
Returns:True if the two genes are analogs, False otherwise.
Parameters:gene (macsypy.gene.Gene object.) – the query of the test
Return type:boolean.
is_authorized(system, include_forbidden=True)[source]
Returns:

True if the genes are found in the System definition file (.xml), False otherwise.

Parameters:
  • system (macsypy.system.System object.) – the query of the test
  • include_forbidden (boolean) – tells if forbidden genes should be considered as “authorized” or not
Return type:

boolean.

is_forbidden(system)[source]
Returns:True if the gene is within the forbidden genes of the system, False otherwise.
Parameters:system (macsypy.system.System object.) – the query of the test
Return type:boolean.
is_homolog(gene)[source]
Returns:True if the two genes are homologs, False otherwise.
Parameters:gene (macsypy.gene.Gene object.) – the query of the test
Return type:boolean.
is_mandatory(system)[source]
Returns:True if the gene is within the mandatory genes of the system, False otherwise.
Parameters:system (macsypy.system.System object.) – the query of the test
Return type:boolean.
loner
Returns:True if the gene can be isolated on the genome, False otherwise
Return type:boolean
multi_system
Returns:True if this Gene can belong to different occurrences of this System (and can be used for multiple System assessments), False otherwise.
Return type:boolean.
profile = None
Variables:profile – The HMM protein Profile corresponding to this gene macsypy.gene.Profile object
system
Returns:the System that owns this Gene
Return type:macsypy.system.System object

Note

All attributes/methods which are not directly implemented in Homolog are redirected to that of the encapsulated Gene.

Homolog API reference

class macsypy.gene.Homolog(gene, gene_ref, aligned=False)[source]

Handle homologs, encapsulate a Gene

__init__(gene, gene_ref, aligned=False)[source]
Parameters:
  • gene (macsypy.gene.Gene object.) – the gene
  • gene_ref (macsypy.gene.Gene object.) – the gene to which the current is homolog.
  • aligned (boolean) – if True, the profile of this gene overlaps totally the sequence of the reference gene profile. Otherwise, only partial overlapping between the profiles.
__weakref__

list of weak references to the object (if defined)

gene = None
Variables:gene – gene
gene_ref
Returns:the gene to which this one is homolog to (reference gene)
Return type:macsypy.gene.Gene object
is_aligned()[source]
Returns:True if this gene homolog is aligned to its homolog, False otherwise.
Return type:boolean

Analog API reference

class macsypy.gene.Analog(gene, gene_ref)[source]

Handle analogs, encapsulate a Gene

__init__(gene, gene_ref)[source]
Parameters:
__weakref__

list of weak references to the object (if defined)

gene = None
Variables:gene – gene
gene_ref
Returns:the gene to which this one is analog to (reference gene)
Return type:macsypy.gene.Gene object