Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong mass for 2M-H+2NH4 #4

Open
mapio opened this issue Mar 24, 2023 · 0 comments
Open

Wrong mass for 2M-H+2NH4 #4

mapio opened this issue Mar 24, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mapio
Copy link

mapio commented Mar 24, 2023

I suspect there is a problem in the parsing of the ion part of the adduct leading to an error in the computation of the mass for 2M-H+2NH4.

Steps to reproduce, if you run

import pandas as pd 
from msac.calculate_adduct_mz import *

adducts = pd.read_csv('msac/example_data/adduct_list_full.csv')
bug = adducts[adducts.adduct == '2M-H+2NH4']
atom_dict, mass_dict, all_atoms = get_atom_masses(bug)
ions2mass = get_adduct_masses(None, mass_dict, all_atoms)

then ions2mass contains {'-H+2NH4': 29.01397304109} that is incorrect. Looking at intermediate results, mass_dict contains

{'e': 0.00054857990924, 'H': 1.00782503223, 'NH': 15.01089903666}

even if NH mass is correct, in the ion the formula is actually NH4. So the mass in ions2mass corresponds to

- mass_dict['H'] + 2 * mass_dict['NH']

that is a wrong computation. It should be

- Formula('H').monoisotopic_mass + 2 * Formula('NH4').monoisotopic_mass

which leads to 35.060923234469996 instead of 29.01397304109.

The same error happens also in just another case (from adduct_list_full.csv), namely M-H+2H2O where mass_dict again reports just O instead of O2.

I'm working on a complete overhaul of the parsing code that should fix this. As soon as I'll be ready I'll submit a pull request.

@christinehc christinehc self-assigned this Nov 20, 2024
@christinehc christinehc added the bug Something isn't working label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants