Reputation:
I want to print all atoms except H (hydrogen) from the pdb file. Here is the file
https://github.com/mahesh27dx/molecular_phys.git
Following code prints the objects of the file
import numpy as np
import mdtraj as md
coord = md.load('alanine-dipeptide-nowater.pdb')
atoms, bonds = coord.topology.to_dataframe()
atoms
From this table I want to print all the elements except H . I think it can be done in python using the list slicing. Could someone have any idea how it can be done? Thanks!
Upvotes: 0
Views: 69
Reputation: 663
You probably should clarify that you want help with mdtraj
or pandas
specifically.
Anyway, it's as simple as atoms.loc[atoms.element != 'H']
.
Upvotes: 2
Reputation: 10624
You can do the following:
print(*list(df[df.element!='H']['element']))
If you want the unique elements, you can do this:
print(*set(df[df.element!='H']['element']))
Upvotes: 0