How do I select only the phosphate group from my phospholipids and oxygen from cholesterol and then club all the phosphates and oxygens into one group in an index file? Kindly help.
Open the gro/pdb file to identify the names of the atoms you are interested in. For example, let's say these are O7, P8, O9, O10, and O11 (the PO4 group from an all-atom phospholipid)
Open index.ndx and add a group name such as [ phosphate_atoms ]
The basic idea here is to use grep to grab the atoms you are interested in, and then use awk to get the column of interest. Using this way, you should be able to get the phosphate + cholesterol oxygen at the same time.
There are multiple ways to do this, this is just one such way.