def get_flagella_initial_state(ports={}): flagella_data = FlagellaChromosome() chromosome_config = flagella_data.chromosome_config molecules = {} for nucleotide in nucleotides.values(): molecules[nucleotide] = 5000000 for amino_acid in amino_acids.values(): molecules[amino_acid] = 1000000 return { ports.get('molecules', 'molecules'): molecules, ports.get('transcripts', 'transcripts'): {gene: 0 for gene in chromosome_config['genes'].keys()}, ports.get('proteins', 'proteins'): { 'CpxR': 10, 'CRP': 10, 'Fnr': 10, 'endoRNAse': 1, 'flagella': 8, UNBOUND_RIBOSOME_KEY: 200, # e. coli has ~ 20000 ribosomes UNBOUND_RNAP_KEY: 200 } }
def run_flagella_compartment( compartment, initial_state=None, out_dir='out'): # get flagella data flagella_data = FlagellaChromosome() # run simulation settings = { # a cell cycle of 2520 sec is expected to express 8 flagella. # 2 flagella expected in approximately 630 seconds. 'total_time': 2520, 'emit_step': COMPARTMENT_TIMESTEP, 'verbose': True, 'initial_state': initial_state} timeseries = simulate_compartment_in_experiment(compartment, settings) # save reference timeseries save_timeseries(timeseries, out_dir) plot_config = { 'name': 'flagella_expression', 'ports': { 'transcripts': 'transcripts', 'proteins': 'proteins', 'molecules': 'molecules'}} plot_gene_expression_output( timeseries, plot_config, out_dir) # just-in-time figure plot_config2 = plot_config.copy() plot_config2.update({ 'name': 'flagella', 'plot_ports': { 'transcripts': list(flagella_data.chromosome_config['genes'].keys()), 'proteins': flagella_data.complexation_monomer_ids + flagella_data.complexation_complex_ids, 'molecules': list(nucleotides.values()) + list(amino_acids.values())}}) plot_timeseries_heatmaps( timeseries, plot_config2, out_dir) # make a basic sim output plot_settings = { 'max_rows': 30, 'remove_zeros': True, 'skip_ports': ['chromosome', 'ribosomes']} plot_simulation_output( timeseries, plot_settings, out_dir)
def test_gene_expression(total_time=10): # load the compartment compartment_config = { 'external_path': ('external', ), 'global_path': ('global', ), 'agents_path': ( '..', '..', 'cells', ), 'transcription': { 'sequence': toy_chromosome_config['sequence'], 'templates': toy_chromosome_config['promoters'], 'genes': toy_chromosome_config['genes'], 'promoter_affinities': toy_chromosome_config['promoter_affinities'], 'transcription_factors': ['tfA', 'tfB'], 'elongation_rate': 10.0 }, # 'complexation': { # 'monomer_ids': [], # 'complex_ids': [], # 'stoichiometry': {}} } compartment = GeneExpression(compartment_config) molecules = {nt: 1000 for nt in nucleotides.values()} molecules.update({aa: 1000 for aa in amino_acids.values()}) proteins = { polymerase: 100 for polymerase in [UNBOUND_RNAP_KEY, UNBOUND_RIBOSOME_KEY] } proteins.update({factor: 1 for factor in ['tfA', 'tfB']}) # simulate settings = { 'timestep': 1, 'total_time': total_time, 'initial_state': { 'proteins': proteins, 'molecules': molecules } } return simulate_compartment_in_experiment(compartment, settings)
def __init__(self, initial_parameters=None): if not initial_parameters: initial_parameters = {} super(RnaDegradation, self).__init__(initial_parameters) self.derive_defaults('sequences', 'transcript_order', keys_list) self.derive_defaults('catalysis_rates', 'protein_order', keys_list) self.sequences = self.parameters['sequences'] self.catalysis_rates = self.parameters['catalysis_rates'] self.degradation_rates = self.parameters['degradation_rates'] self.transcript_order = self.parameters['transcript_order'] self.protein_order = self.parameters['protein_order'] self.molecule_order = list(nucleotides.values()) self.partial_transcripts = { transcript: 0 for transcript in self.transcript_order } self.global_deriver_key = self.or_default(initial_parameters, 'global_deriver_key')
def plot_gene_expression_output(timeseries, config, out_dir='out'): name = config.get('name', 'gene_expression') ports = config.get('ports', {}) molecules = timeseries[ports['molecules']] transcripts = timeseries[ports['transcripts']] proteins = timeseries[ports['proteins']] time = timeseries['time'] # make figure and plot n_cols = 1 n_rows = 5 plt.figure(figsize=(n_cols * 6, n_rows * 1.5)) # define subplots ax1 = plt.subplot(n_rows, n_cols, 1) ax2 = plt.subplot(n_rows, n_cols, 2) ax3 = plt.subplot(n_rows, n_cols, 3) ax4 = plt.subplot(n_rows, n_cols, 4) ax5 = plt.subplot(n_rows, n_cols, 5) polymerase_ids = [UNBOUND_RNAP_KEY, UNBOUND_RIBOSOME_KEY] amino_acid_ids = list(amino_acids.values()) nucleotide_ids = list(nucleotides.values()) # plot polymerases for poly_id in polymerase_ids: ax1.plot(time, proteins[poly_id], label=poly_id) ax1.legend(loc='center left', bbox_to_anchor=(1.0, 0.5)) ax1.title.set_text('polymerases') # plot nucleotides for nuc_id in nucleotide_ids: ax2.plot(time, molecules[nuc_id], label=nuc_id) ax2.legend(loc='center left', bbox_to_anchor=(1.0, 0.5)) ax2.title.set_text('nucleotides') # plot molecules for aa_id in amino_acid_ids: ax3.plot(time, molecules[aa_id], label=aa_id) ax3.legend(loc='center left', bbox_to_anchor=(2.0, 0.5)) ax3.title.set_text('amino acids') # plot transcripts for transcript_id, series in transcripts.items(): ax4.plot(time, series, label=transcript_id) ax4.legend(loc='center left', bbox_to_anchor=(1.0, 0.5)) ax4.title.set_text('transcripts') # plot proteins for protein_id in sorted(proteins.keys()): if protein_id != UNBOUND_RIBOSOME_KEY: ax5.plot(time, proteins[protein_id], label=protein_id) ax5.legend(loc='center left', bbox_to_anchor=(1.5, 0.5)) ax5.title.set_text('proteins') # adjust axes for axis in [ax1, ax2, ax3, ax4, ax5]: axis.spines['right'].set_visible(False) axis.spines['top'].set_visible(False) ax1.set_xticklabels([]) ax2.set_xticklabels([]) ax3.set_xticklabels([]) ax4.set_xticklabels([]) ax5.set_xlabel('time (s)', fontsize=12) # save figure fig_path = os.path.join(out_dir, name) plt.subplots_adjust(wspace=0.3, hspace=0.5) plt.savefig(fig_path, bbox_inches='tight')
from vivarium.core.composition import process_in_experiment from vivarium.states.chromosome import Chromosome, Rnap, Promoter, frequencies, add_merge, toy_chromosome_config from vivarium.library.polymerize import Elongation, build_stoichiometry, template_products from vivarium.data.nucleotides import nucleotides def choose_element(elements): if elements: choice = np.random.choice(len(elements), 1) return list(elements)[int(choice)] #: Variable name for unbound RNA polymerase UNBOUND_RNAP_KEY = 'RNA Polymerase' monomer_ids = list(nucleotides.values()) #: The default configuration parameters for :py:class:`Transcription` class Transcription(Process): name = 'transcription' defaults = { 'promoter_affinities': {}, 'transcription_factors': [], 'sequence': '', 'templates': {}, 'genes': {}, 'elongation_rate': 1.0, 'polymerase_occlusion': 5, 'symbol_to_monomer': nucleotides,