Skip to content

Simulation Overview

This page summarises the typical workflow when using ViMMS to create new LC--MS/MS data. A simulation involves the following main components:

  1. Chemicals – virtual representations of compounds to be ionised. See Creating Chemicals for more details.
  2. Mass Spectrometer – either an in silico model (IndependentMassSpectrometer) or a real instrument.
  3. Controller – defines the fragmentation strategy, for example Top‑N DDA.
  4. Environment – orchestrates interaction between the mass spectrometer and the controller.

Typical Workflow

from vimms.Chemicals import ChemicalMixtureCreator
from vimms.ChemicalSamplers import UniformMZFormulaSampler
from vimms.MassSpec import IndependentMassSpectrometer
from vimms.Controller import TopNController
from vimms.Environment import Environment

# 1. Generate chemicals
formula_sampler = UniformMZFormulaSampler(min_mz=100, max_mz=600)
cmc = ChemicalMixtureCreator(formula_sampler)
chemicals = cmc.sample(100, ms_levels=2)

# 2. Set up a virtual mass spectrometer
ms = IndependentMassSpectrometer(polarity="positive", chemicals=chemicals)

# 3. Choose a controller
controller = TopNController("positive", N=5, isolation_width=1)

# 4. Create and run the environment
env = Environment(ms, controller, min_time=0, max_time=1200)
env.run()

Running the environment produces a list of scans that can be written to mzML using Environment.write_mzML(). Evaluation data can also be stored by setting save_eval=True on the environment.

Adding Noise

The mass spectrometer accepts peak noise objects from vimms.Noise to make simulated spectra more realistic. For example:

from vimms.Noise import GaussianPeakNoise
ms = IndependentMassSpectrometer("positive", chemicals, peak_noise=GaussianPeakNoise(0.01))

Further Reading