silvio.extensions.modules package¶
Submodules¶
silvio.extensions.modules.genome_expression module¶
TODO: GenomeExpression needs to be reviewed.
-
class
silvio.extensions.modules.genome_expression.GenomeExpression[source]¶ Bases:
silvio.module.Module-
_abc_impl= <_abc._abc_data object>¶
-
bind(host: silvio.host.Host, genome: Union[silvio.extensions.modules.genome_library.GenomeLibrary, silvio.extensions.modules.genome_list.GenomeList]) → None[source]¶ Bind this module to its host and deps (dependent modules). Here, the event listeners should also be set.
Extending Modules should have the following structure on their method:
def bind ( self, host, req_mod_1, req_mod_2, ... ) -> None : self.host = host self.req_mod_1 = req_mod_1 self.req_mod_2 = req_mod_2 self.host.observe( EventTypeA, self.listen_event_a ) self.host.observe( EventTypeB, self.listen_event_b )
-
calc_fast_wrong_prom_expr(prom: Bio.Seq.Seq) → float[source]¶ This method executes a wrong calculation of the promoter expression. It serves to demonstrate how editing a promoter can affect the expression value. That expression value can then change the metabolic models. TODO: Only for demonstration purpose of chained events.
-
copy(ref: silvio.extensions.modules.genome_expression.GenomeExpression) → None[source]¶ Make a copy of the module params by using another similar Module as a reference. The code inside this method should provide a good copy where shallow and deep copies are used appropriately.
Extending Modules should have the following structure on their method:
def copy ( self, ref ) -> None : self.simple_param_1 = ref.simple_param_1 self.complex_model_1 = copy(ref.complex_model_1)
-
listen_alter_gene_promoter(event: silvio.extensions.all_events.AlterGenePromoterEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ When a gene promoter is altered, we recalculate the expression and update it.
-
make(opt_primer_len: int, infl_prom_str: float, species_prom_str: float, regressor_file: str, addparams_file: str) → None[source]¶ Make a new module from scratch with the help of arguments. This will only set the params.
Extending Modules should have the following structure on their method:
def make ( self, param_1, param_2, ... ) -> None : self.param_1 = param_1 self.model_1 = load_model(param1) self.param_2 = param_2
-
sync(emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ Run the sync procedure on this module. This usually means dispatching some events after the module is made and all other modules have been bound and are listening to event emitters.
Extending Modules should have the following structure on their method:
def sync ( self, emit, log ) -> None : log("ModuleX: start sync") emit( EventTypeA( event_args ) ) for i in self.items : emit( EventTypeB( event_args_i ) )
-
silvio.extensions.modules.genome_library module¶
- GenomeLibrary is a more complex version of GenomeList:
- support for genome sequences
- genes are located inside the sequence
-
class
silvio.extensions.modules.genome_library.GenomeLibrary[source]¶ Bases:
silvio.module.ModuleGenomeLibrary is a module that models the genome in a simplified way to ease interpretation. It stores a sequence of base pairs and provides a Gene interface that reads from the sequence at the gene’s locus.
The Sequence is stored as a base-pair list, whereas genes are stored as locations inside that sequence.
-
_abc_impl= <_abc._abc_data object>¶
-
bind(host: silvio.host.Host) → None[source]¶ Bind this module to its host and deps (dependent modules). Here, the event listeners should also be set.
Extending Modules should have the following structure on their method:
def bind ( self, host, req_mod_1, req_mod_2, ... ) -> None : self.host = host self.req_mod_1 = req_mod_1 self.req_mod_2 = req_mod_2 self.host.observe( EventTypeA, self.listen_event_a ) self.host.observe( EventTypeB, self.listen_event_b )
-
calc_primer_matches(primer: Bio.Seq.Seq) → List[silvio.extensions.modules.genome_library.PrimerMatch][source]¶ Return the insertion sites a primer can have, alongside with success rate. The insertion site is located right after a primer match.
-
copy(ref: silvio.extensions.modules.genome_library.GenomeLibrary) → None[source]¶ Make a copy of the module params by using another similar Module as a reference. The code inside this method should provide a good copy where shallow and deep copies are used appropriately.
Extending Modules should have the following structure on their method:
def copy ( self, ref ) -> None : self.simple_param_1 = ref.simple_param_1 self.complex_model_1 = copy(ref.complex_model_1)
-
genes¶
-
insert_gene(gene: silvio.extensions.records.gene.gene.Gene, loc: int)[source]¶ Insert a gene and its sequence at a specific location in the sequence.
-
listen_alter_gene_promoter(event: silvio.extensions.all_events.AlterGenePromoterEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ When a gene promoter is altered, we replace the associated part in the sequence. TODO: No knock-outs are being made on this operation.
-
listen_insert_gene(event: silvio.extensions.all_events.InsertGeneEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶
-
listen_remove_gene(event: silvio.extensions.all_events.RemoveGeneEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ Remove a gene from the library and sequence.
-
make(sequence: Optional[Bio.Seq.Seq] = None, bg_size: Optional[int] = None, bg_gc_content: Optional[float] = None, bg_rnd: Optional[numpy.random._generator.Generator] = None, locgenes: List[silvio.extensions.records.gene.localized_gene.LocalizedGene] = []) → None[source]¶ Make a new module from scratch with the help of arguments. This will only set the params.
Extending Modules should have the following structure on their method:
def make ( self, param_1, param_2, ... ) -> None : self.param_1 = param_1 self.model_1 = load_model(param1) self.param_2 = param_2
-
sync(emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ Run the sync procedure on this module. This usually means dispatching some events after the module is made and all other modules have been bound and are listening to event emitters.
Extending Modules should have the following structure on their method:
def sync ( self, emit, log ) -> None : log("ModuleX: start sync") emit( EventTypeA( event_args ) ) for i in self.items : emit( EventTypeB( event_args_i ) )
-
-
class
silvio.extensions.modules.genome_library.PrimerMatch(loc_start, loc_end, success)[source]¶ Bases:
tuple-
_asdict()¶ Return a new dict which maps field names to their values.
-
_field_defaults= {}¶
-
_fields= ('loc_start', 'loc_end', 'success')¶
-
classmethod
_make(iterable)¶ Make a new PrimerMatch object from a sequence or iterable
-
_replace(**kwds)¶ Return a new PrimerMatch object replacing specified fields with new values
-
loc_end¶ Alias for field number 1
-
loc_start¶ Alias for field number 0
-
success¶ Alias for field number 2
-
-
silvio.extensions.modules.genome_library.check_primer_integrity(primer: Bio.Seq.Seq) → bool[source]¶ Non-deterministic check if the primer itself is well built.
-
silvio.extensions.modules.genome_library.find_best_primer_match(sequence: Bio.Seq.Seq, primer: Bio.Seq.Seq) → Optional[silvio.extensions.modules.genome_library.PrimerMatch][source]¶ Find best match for a template sequence. TODO: Primer matching is dependent on host. algo_params:Optional[Dict] = None
silvio.extensions.modules.genome_list module¶
GenomeList is a module that stores the multiple genes an Host may have.
TODO: Add support for adding the same gene twice (probably multisets)
-
class
silvio.extensions.modules.genome_list.GenomeList[source]¶ Bases:
silvio.module.Module-
_abc_impl= <_abc._abc_data object>¶
-
bind(host: silvio.host.Host) → None[source]¶ Bind this module to its host and deps (dependent modules). Here, the event listeners should also be set.
Extending Modules should have the following structure on their method:
def bind ( self, host, req_mod_1, req_mod_2, ... ) -> None : self.host = host self.req_mod_1 = req_mod_1 self.req_mod_2 = req_mod_2 self.host.observe( EventTypeA, self.listen_event_a ) self.host.observe( EventTypeB, self.listen_event_b )
-
copy(ref: silvio.extensions.modules.genome_list.GenomeList) → None[source]¶ Make a copy of the module params by using another similar Module as a reference. The code inside this method should provide a good copy where shallow and deep copies are used appropriately.
Extending Modules should have the following structure on their method:
def copy ( self, ref ) -> None : self.simple_param_1 = ref.simple_param_1 self.complex_model_1 = copy(ref.complex_model_1)
-
listen_alter_gene_promoter(event: silvio.extensions.all_events.AlterGenePromoterEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ When a gene promoter is altered, we recalculate the expression and update it.
-
listen_insert_gene(event: silvio.extensions.all_events.InsertGeneEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶
-
listen_remove_gene(event: silvio.extensions.all_events.RemoveGeneEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶
-
make(genes: set = {}) → None[source]¶ Make a new module from scratch with the help of arguments. This will only set the params.
Extending Modules should have the following structure on their method:
def make ( self, param_1, param_2, ... ) -> None : self.param_1 = param_1 self.model_1 = load_model(param1) self.param_2 = param_2
-
sync(emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ Run the sync procedure on this module. This usually means dispatching some events after the module is made and all other modules have been bound and are listening to event emitters.
Extending Modules should have the following structure on their method:
def sync ( self, emit, log ) -> None : log("ModuleX: start sync") emit( EventTypeA( event_args ) ) for i in self.items : emit( EventTypeB( event_args_i ) )
-
silvio.extensions.modules.growth_behaviour module¶
-
class
silvio.extensions.modules.growth_behaviour.GrowthBehaviour[source]¶ Bases:
silvio.module.Module-
Make_ProductionExperiment(gene: silvio.extensions.records.gene.gene.Gene, CultTemp, GrowthRate, Biomass, ref_prom: str, accuracy_Test=0.9) → silvio.outcome.Outcome[source]¶ Return an outcome with the expression rate.
-
Make_TempGrowthExp(CultTemps: list, exp_suc_rate: float) → Tuple[pandas.core.frame.DataFrame, List[Tuple]][source]¶ TODO: Ideally, growth should return a table with enough information to contain the biomass results and to infer the loading times. Loading times is a synthetic construct that should be contained in a catalog Host, while the Module should only contain efficient calculations. The Host is an API for the User and may add interaction such as Resource management and loading times.
TODO: If loading time should really be calculated here, then think about returning an additional record-oriented dataframe with columns (exp, temp, loading_len).
TODO: I’m not sure oh the nuances but propose the following changes to make this conforming: - Remove the Experiment Success Rate and only use it at the “catalog.recexpsim.Host” level. - Make each simulation call use a single temperature. (though, some calculations use all temps) - Each simulation returns a Series with the mass-over-time values. - Rename this method to “sim_cultivation” with renamed arguments.
- [ mass_over_time_for_temp, pauses ]
- mass_over_time_for_temp
- Dataframe holding the mass over time for each temperature in a column.
- pauses
- List of tuples containing loading time information.
-
_abc_impl= <_abc._abc_data object>¶
-
bind(host: silvio.host.Host, genexpr: silvio.extensions.modules.genome_expression.GenomeExpression) → None[source]¶ Bind this module to its host and deps (dependent modules). Here, the event listeners should also be set.
Extending Modules should have the following structure on their method:
def bind ( self, host, req_mod_1, req_mod_2, ... ) -> None : self.host = host self.req_mod_1 = req_mod_1 self.req_mod_2 = req_mod_2 self.host.observe( EventTypeA, self.listen_event_a ) self.host.observe( EventTypeB, self.listen_event_b )
-
copy(ref: silvio.extensions.modules.growth_behaviour.GrowthBehaviour) → None[source]¶ Make a copy of the module params by using another similar Module as a reference. The code inside this method should provide a good copy where shallow and deep copies are used appropriately.
Extending Modules should have the following structure on their method:
def copy ( self, ref ) -> None : self.simple_param_1 = ref.simple_param_1 self.complex_model_1 = copy(ref.complex_model_1)
-
make(opt_growth_temp: int, max_biomass: int) → None[source]¶ Make a new module from scratch with the help of arguments. This will only set the params.
Extending Modules should have the following structure on their method:
def make ( self, param_1, param_2, ... ) -> None : self.param_1 = param_1 self.model_1 = load_model(param1) self.param_2 = param_2
-
sync(emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ Run the sync procedure on this module. This usually means dispatching some events after the module is made and all other modules have been bound and are listening to event emitters.
Extending Modules should have the following structure on their method:
def sync ( self, emit, log ) -> None : log("ModuleX: start sync") emit( EventTypeA( event_args ) ) for i in self.items : emit( EventTypeB( event_args_i ) )
-
silvio.extensions.modules.metabolic_flux module¶
- GenomeLibrary is a more complex version of GenomeList:
- support for genome sequences
- genes are located inside the sequence
-
class
silvio.extensions.modules.metabolic_flux.MetabolicFlux[source]¶ Bases:
silvio.module.ModuleMetabolicFlux can handle cobrapy models and interfaces them with module events.
This module can start with an non-existing model, which can then be integrated as an event.
TODO: Its probably not elegant to allow non-existing models, but this makes it easier to add all genes in that model later on (as events). If we would be really pedantic and needed a strictly-existinging model we could implement an initialization step where a module calls multiple events on the host in order to “initialize” the module properly. To achieve that, modules themselves need to be able to generate events (right now only a Host can send events down to modules, events never go up the chain) and prevent infinite event loops. But maybe there are better alternatives altogether.
-
_abc_impl= <_abc._abc_data object>¶
-
bind(host: silvio.host.Host) → None[source]¶ Bind this module to its host and deps (dependent modules). Here, the event listeners should also be set.
Extending Modules should have the following structure on their method:
def bind ( self, host, req_mod_1, req_mod_2, ... ) -> None : self.host = host self.req_mod_1 = req_mod_1 self.req_mod_2 = req_mod_2 self.host.observe( EventTypeA, self.listen_event_a ) self.host.observe( EventTypeB, self.listen_event_b )
-
copy(ref: silvio.extensions.modules.metabolic_flux.MetabolicFlux) → None[source]¶ Make a copy of the module params by using another similar Module as a reference. The code inside this method should provide a good copy where shallow and deep copies are used appropriately.
Extending Modules should have the following structure on their method:
def copy ( self, ref ) -> None : self.simple_param_1 = ref.simple_param_1 self.complex_model_1 = copy(ref.complex_model_1)
-
listen_alter_gene_expression(event: silvio.extensions.all_events.AlterGeneExpressionEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ When a gene expression changes, we adapt the bounds. TODO: This method should be wrong. Please rewrite logic on how gene expression affects the
metabolic model.
-
listen_insert_gene(event: silvio.extensions.all_events.InsertGeneEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶
-
listen_remove_gene(event: silvio.extensions.all_events.RemoveGeneEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ When a gene is removed we perform a knockout in the model.
-
make(model: cobra.core.model.Model) → None[source]¶ Make a new module from scratch with the help of arguments. This will only set the params.
Extending Modules should have the following structure on their method:
def make ( self, param_1, param_2, ... ) -> None : self.param_1 = param_1 self.model_1 = load_model(param1) self.param_2 = param_2
-
sync(emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ Run the sync procedure on this module. This usually means dispatching some events after the module is made and all other modules have been bound and are listening to event emitters.
Extending Modules should have the following structure on their method:
def sync ( self, emit, log ) -> None : log("ModuleX: start sync") emit( EventTypeA( event_args ) ) for i in self.items : emit( EventTypeB( event_args_i ) )
-
silvio.extensions.modules.phenotype_size module¶
This is a TESTING module to showcase Host events. The number inside this module (example: a size of a cell) will increase with the number of genes.
-
class
silvio.extensions.modules.phenotype_size.PhenotypeSize[source]¶ Bases:
silvio.module.Module-
_abc_impl= <_abc._abc_data object>¶
-
bind(host: silvio.host.Host) → None[source]¶ Bind this module to its host and deps (dependent modules). Here, the event listeners should also be set.
Extending Modules should have the following structure on their method:
def bind ( self, host, req_mod_1, req_mod_2, ... ) -> None : self.host = host self.req_mod_1 = req_mod_1 self.req_mod_2 = req_mod_2 self.host.observe( EventTypeA, self.listen_event_a ) self.host.observe( EventTypeB, self.listen_event_b )
-
copy(ref: silvio.extensions.modules.phenotype_size.PhenotypeSize) → None[source]¶ Make a copy of the module params by using another similar Module as a reference. The code inside this method should provide a good copy where shallow and deep copies are used appropriately.
Extending Modules should have the following structure on their method:
def copy ( self, ref ) -> None : self.simple_param_1 = ref.simple_param_1 self.complex_model_1 = copy(ref.complex_model_1)
-
listen_insert_gene(event: silvio.extensions.all_events.InsertGeneEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶
-
listen_remove_gene(event: silvio.extensions.all_events.RemoveGeneEvent, emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶
-
make(size: int = 0) → None[source]¶ Make a new module from scratch with the help of arguments. This will only set the params.
Extending Modules should have the following structure on their method:
def make ( self, param_1, param_2, ... ) -> None : self.param_1 = param_1 self.model_1 = load_model(param1) self.param_2 = param_2
-
sync(emit: Callable[[silvio.events.Event], None], log: Callable[[str], None]) → None[source]¶ Run the sync procedure on this module. This usually means dispatching some events after the module is made and all other modules have been bound and are listening to event emitters.
Extending Modules should have the following structure on their method:
def sync ( self, emit, log ) -> None : log("ModuleX: start sync") emit( EventTypeA( event_args ) ) for i in self.items : emit( EventTypeB( event_args_i ) )
-