levitsky / pyteomics

Pyteomics is a collection of lightweight and handy tools for Python that help to handle various sorts of proteomics data. Pyteomics provides a growing set of modules to facilitate the most common tasks in proteomics data analysis.
http://pyteomics.readthedocs.io
Apache License 2.0
105 stars 34 forks source link

Calculate m/z for proforma in calculate_mass #137

Closed levitsky closed 6 months ago

levitsky commented 6 months ago

This PR adds a new optional argument to mass.calculate_mass, proforma. If specified, it should be a ProForma string or a proforma.ProForma object. Its mass property is then converted to m/z if needed.

mobiusklein commented 6 months ago

This looks good to me, thank you for catching that duplicate water constant.

levitsky commented 6 months ago

Thank you for checking it @mobiusklein !

LoponteHF commented 4 months ago

Hello. So, I`ve been using your package for a while now, and after this update it seems like something broke with the mass.calculate_mass(composition) function.

On 4.6.2 I could just do this: from pyteomics import mass mass.calculate_mass(composition={'H' : 1})

and it would return me: 1.00782503207

but now, on 4.7, when I type the same things I get: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\analyst\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyteomics\mass\mass.py", line 654, in calculate_mass return composition.mass(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\analyst\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyteomics\mass\mass.py", line 485, in mass return self._mass_to_mz(mass, self, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: Composition._mass_to_mz() got multiple values for argument 'composition'

Is this intended behavior? If so, how should I adapt my code?

levitsky commented 4 months ago

Hi @FrangoST, thank you for reaching out! This was not an intended change, I'm sorry for the inconvenience. I made a change to fix this in master, and if everything works as expected now, I will make a release shortly.