glasgowcompbio / vimms

A programmable and modular LC/MS simulator in Python
MIT License
19 stars 6 forks source link

Add negative mode into ViMMS mass spec #152

Closed vinnydavies closed 4 years ago

sdrogers commented 4 years ago

At the moment, chemicals have a single adduct attribute which includes a list of adducts. E.g: https://github.com/sdrogers/vimms/blob/a8c62288e3f204b8815cba31518769909563691d/vimms/Chemicals.py#L162 This can be generated by the adducts class.

I suggest we make the following change: Turn this into a dictionary with two keys: 'POSITIVE' and 'NEGATIVE' By default, the 'NEGATIVE' one will be an empty list.

This will require a change in the adducts class, to produce the dictionary instead of list, and a change in the UnknownChemical class...and a change in the simulated MS class here: https://github.com/sdrogers/vimms/blob/a8c62288e3f204b8815cba31518769909563691d/vimms/MassSpec.py#L596-L599 Or, maybe better, a change here: https://github.com/sdrogers/vimms/blob/a8c62288e3f204b8815cba31518769909563691d/vimms/MassSpec.py#L652-L656 so that it just returns the list from the relevant dictionary key (i.e. which mode the MS is in)

sdrogers commented 4 years ago

This: https://github.com/sdrogers/vimms/blob/a8c62288e3f204b8815cba31518769909563691d/vimms/Chemicals.py#L71-L102 Will need some changes. adduct_names and adduct_prior need to be dictionaries with keys 'POSITIVE' and 'NEGATIVE'. If nothing is passed, the default will be a dictionary with just a POSITIVE key. If an adduct_prior_dict is provided, it will use whatever keys are in there.

So in Chemicals.py, when making an UnknownChemical we just need to change self.adducts = [("M+H", 1)] to self.adducts = {POSITIVE: [("M+H", 1)], NEGATIVE: [("M-H", 1)]} and for the KnownChemical: line 162: self.adducts ={POSITIVE: [("M+H", 1)], NEGATIVE: [("M-H", 1)]}`

MS class will need to check if the mode it is in is present in the dictionary. If not, return an empty list (assuming this will be ok for things upstream?) and if it is present, return the adducts in the list.

sdrogers commented 4 years ago

and need at least one negative transformation in a neg tranformation dict in Common