
Running combinations (e.g. assigning chemical formulas to molar masses)
Hi,
I have a list of molecular masses (accurate to four places after decimal) to which I need to assign chemical formulas. Lets call this list A. I want to write a program that can do this. Basically, I will have a list of elements CHNOS with their molar masses (in list B), and my program needs to pick a combination of elements that gets me closest to the molecular masses in list A.
I am wondering what is the best way to do this without involving a bunch of for loops going in circles to narrow down on the mass. Fundamentally, it is just about trying out different combinations of elements to get closest to the measured mass. Is there a library in IGOR that can perform this kind of a task? Or a simpler technique?
As an idea, I am thinking whether writing something like C(x) + H(y) + N(z) + O(z1) + S(z2) = mass where each of x,y,z,z1 and z2 are generated by random seed generator abs(enoise) could do this.
Thanks a ton,
Peeyush
I don't know of a cunning function to do this, but if it is just a few calculations then running loops is not too bad.
For example, run the following with:
FindBestCombo(1000)
EDIT: Deleted my nonsense comment about isotopes.
May 16, 2022 at 08:35 am - Permalink
The problem seems to me to be prone to fail either by finding non-sense local minima (e.g. CH32 instead of CS) or by taking an inordinate amount of time through what amounts to about a 5^N search grid.
Have you considered generating the sets of possible combinations of masses in advance, sorting them by mass, and then doing a simple find level operation.
M value
1 H
2 H2
12 C
13 CH
14 CH2
...
You can always continue to "improve upon" (expand) the M (numeric molar mass) and value (text) waves in a spreadsheet, import that sheet, and work with it in Igor Pro. I imagine this is how most library searches work -- Not by searching over a space using a random walk with enoise in a multi-parameter function fit but rather by searching on a manually pre-built library.
May 16, 2022 at 10:18 am - Permalink
Thank you so much for these great suggestions. I'll try them out and see what works for me.. really appreciate the help!
May 19, 2022 at 04:01 pm - Permalink