Nmrpca fix egligibility - #448
Conversation
d6aa336 to
9beb4b9
Compare
| def verify_lipid(lipid: Lipid) -> bool: | ||
| """Verify that the lipid is supported by the method.""" | ||
| __tailsn1_vars = ["sn-1", "sn1"] | ||
| __tailsn2_vars = ["sn-2", "sn2"] |
There was a problem hiding this comment.
Should this be stored elsewhere and only imported here? I believe that tail-names are universal and not class-specific.
There was a problem hiding this comment.
Also, I believe that this method can hardly be generalized when 4-tailed lipids become available. Should the Parser class have a dict of supported tail combinations
from collections import Counter
from ... import TAIL_VARS, REVERSE_TAIL_VARS # dictionary of tail alt-names
SUPPORTED_LIPIDS = {
2: ["sn1", "sn2"], # List of tail names for lipids with 2 tails
}
@classmethod
def verify_lipid(cls, lipid: Lipid) -> bool:
tails = []
for v in lipid.mapping_dict.values():
if v["FRAGMENT"] in REVERSE_TAIL_VARS:
tails.append(REVERSE_TAIL_VARS[v["FRAGMENT"]])
if len(tails) not in SUPPORTED_LIPIDS:
return False
return Counter(tails) == Counter(SUPPORTED_LIPIDS[len(tails)])
"""There was a problem hiding this comment.
I isolated the function of counting tails because it should not belong to this module. Tail naming should be documented for various types of lipids. sn-1/2 is only for glycerolipids of non-archea. It doesnt' cover the variability. Will develop the function tomorrow according to which tests I will invent.
There was a problem hiding this comment.
I've made. Not exactly this way, but something like
996c870 to
e95a061
Compare
651a2e7 to
1ce730a
Compare
…A pass some ruff complaints.
1ce730a to
3abaeb2
Compare
|
We delivered quite a large PR in the mean-while, so I rebased, force-pushed and verified integration tests. |
|
|
||
| HEADGRP = "headgroup" # locally used to gather amber lipids together | ||
| TAILSN1 = "sn-1" | ||
| TAILSN2 = "sn-2" |
There was a problem hiding this comment.
@comcon1 As you've mentioned, this is very specific for Amber and two tails. Should we add a NOTE or TODO to mark this bit to improve in the future?
pbuslaev
left a comment
There was a problem hiding this comment.
All looks really great. There is a small comment about adding a NOTE of TODO or whichever mark, but rather than that, I am happy with this change
Now, all the lipids having sn-1 and sn-2 tails are egligible. List is not hardcoded anymore.
📚 Documentation preview 📚: https://databank--448.org.readthedocs.build/