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

Added LipidSelection class #4302

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions package/MDAnalysis/core/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,28 @@
return group[np.isin(nmidx, matches)]


class LipidSelection(Selection):
token = 'lipid'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment from where you got the residue names — you explained it to me during the hackathon and that was very useful information, so capture it here in a comment!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orbeckst I'd be happy to continue working on this PR. I have currently added the lipid names for the charmm 36 ff from the list of lipids in charmm top_all36_lipid.rtf . The selection needs to be extended to other force fields too.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like some help with the tests, happy to discuss more in the developer channel on discord.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add some more general comments on testing in the PR below.

Add your sources as a comment in the code, along the lines of

# Lipid residue names from CHARMM's top_all36_lipid.rtf.
# NOTE: need to add names from other FFs.

lipid_res = {
'LPPC', 'DLPC', 'DLPE', 'DLPS', 'DLPA', 'DLPG', 'DMPC', 'DMPE', 'DMPS',
'DMPA', 'DMPG', 'DPPC', 'DPPE', 'DPPS', 'DPPA', 'DPPG', 'DSPC', 'DSPE',
'DSPS', 'DSPA', 'DSPG', 'DOPC', 'DOPE', 'DOPS', 'DOPA', 'DOPG', 'POPC',
'POPE', 'POPS', 'POPA', 'POPG', 'SAPC', 'SDPC', 'SOPC', 'DAPC'
}

def _apply(self, group):
resnames = group.universe._topology.resnames
nmidx = resnames.nmidx[group.resindices]

Check warning on line 1071 in package/MDAnalysis/core/selection.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/core/selection.py#L1070-L1071

Added lines #L1070 - L1071 were not covered by tests

matches = [ix for (nm, ix) in resnames.namedict.items()
if nm in self.lipid_res]
mask = np.isin(nmidx, matches)

Check warning on line 1075 in package/MDAnalysis/core/selection.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/core/selection.py#L1075

Added line #L1075 was not covered by tests

return group[mask]

Check warning on line 1077 in package/MDAnalysis/core/selection.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/core/selection.py#L1077

Added line #L1077 was not covered by tests



class NucleicSelection(Selection):
"""All atoms in nucleic acid residues with recognized residue names.

Expand Down
Loading