<jupyter_start><jupyter_text>8. Fixed Scan Controller This notebook shows how to run the Top-N DDA method on a ViMMS dataset<jupyter_code>%matplotlib inline
%load_ext autoreload
%autoreload 2
import sys
sys.path.append('../..')
from pathlib import Path
import pandas as pd
from vimms.MassSpec import IndependentMassSpectrometer
from vimms.Controller import FixedScansController
from vimms.Environment import Environment
from vimms.Common import *<jupyter_output><empty_output><jupyter_text>Load the data<jupyter_code>data_dir = os.path.abspath(os.path.join(os.getcwd(),'..','..','tests','fixtures'))
dataset = load_obj(os.path.join(data_dir, 'QCB_22May19_1.p'))<jupyter_output><empty_output><jupyter_text>Run Top N Controller<jupyter_code>rt_range = [(0, 10)]
min_rt = rt_range[0][0]
max_rt = rt_range[0][1]
ionisation_mode = POSITIVE
ms_level_schedule = [1,2,2,2,2,1,2,2,2,2,1,2,2,2,2]
mz_schedule = [None,100,200,300,400,None,100,200,300,400,None,100,200,300,400]
dict_schedule = {'ms_level': ms_level_schedule, 'precursor_mz': mz_schedule}
schedule = pd.DataFrame(dict_schedule)
mass_spec = IndependentMassSpectrometer(ionisation_mode, dataset)
controller = FixedScansController(ionisation_mode, schedule)
# create an environment to run both the mass spec and controller
env = Environment(mass_spec, controller, min_rt, max_rt, progress_bar=True)

# set the log level to WARNING so we don't see too many messages when environment is running
set_log_level_warning()

# run the simulation
env.run()<jupyter_output><empty_output><jupyter_text>Simulated results are saved to the following .mzML file and can be viewed in tools like ToppView or using other mzML file viewers.<jupyter_code>set_log_level_debug()
mzml_filename = 'fixedscan_controller.mzML'
out_dir = os.path.join(os.getcwd(), 'results')
env.write_mzML(out_dir, mzml_filename)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11081370449678801, 'fraction_numerical': 0.034796573875803, 'mean_word_length': 8.072815533980583, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '77498', 'license': 'MIT', 'n_tokens_mistral': 703, 'n_tokens_neox': 662, 'n_words': 152, 'path': 'experimental/05. Fixed Scan.ipynb', 'repo_name': 'hechth/vimms', 'size': '1868'}