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

Refactor get handling of chemical formular #20

Open
2 of 5 tasks
viktorht opened this issue Jan 6, 2023 · 0 comments
Open
2 of 5 tasks

Refactor get handling of chemical formular #20

viktorht opened this issue Jan 6, 2023 · 0 comments

Comments

@viktorht
Copy link
Collaborator

viktorht commented Jan 6, 2023

The following lines extract the molecular formula from the fragment IDs which is unexpected behaviour and makes the reimport fail if the fragment ID does not contain a valid formula.

# parse the id
id_list = rxn_id[cnt].split(" ")
expt = id_list[0]
fragment_id = id_list[1]
fragment_string = id_list[2]
units = id_list[3]
# parse the id into fragment_id and mass
fragment_string = re.sub("_DASH_", "-", fragment_string)
fragment_string = re.sub(
"_LPARANTHES_", "[(]", fragment_string
)
fragment_string = re.sub(
"_RPARANTHES_", "[)]", fragment_string
)
fragment_list = fragment_string.split("_")
if not len(fragment_list) > 5 or not (
"MRM" in fragment_list or "EPI" in fragment_list
):
fragment_mass = Formula(fragment_list[2]).mass + float(
fragment_list[3]
)
time_point = fragment_list[4]
else:
fragment_mass = Formula(fragment_list[2]).mass + float(
fragment_list[4]
)
time_point = fragment_list[5]

The molecular formula should instead be handled through the .more attribute of the fragments (defined through the msdata()-function). The information can then be exported through the model-matlab object (usually called m in the reimport notebooks), which should contain the information in the .more attribute. An issue is that the .more attribute contains the formula for all unlabelled atoms, thus to obtain the full formula one should add the .more attribute with the .atoms attribute (that contains the labelled atoms) for each fragment.

TODO

  • Make a function that imports the fragment_formula from the measuredFragments file and write the unlabelled atoms in the .more attribute in the matlab script.
    • Make a helper function which takes subtracts the labelled atoms from the full formula
  • Make a function which extracts the full formula (.more + .atoms) from the model matlab-object
  • Calculate the molar mass from the formula
  • Save formula, and molar mass to the out dataframe in reimport workflow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant