['4AKE' 'CORE'] # there are two segments now for testing, as expected
# Analyze the hbonds
hbonds = HBA(universe=u)
hbonds.run()
# build a dataframe based on the tutorial
FRAME = 0
DONOR = 1
HYDROGEN = 2
ACCEPTOR = 3
DISTANCE = 4
ANGLE = 5
df = pd.DataFrame(hbonds.results.hbonds[:, :DISTANCE].astype(int),
columns=["frame", "donor_ix", "hydrogen_ix", "acceptor_ix",])
df["distances"] = hbonds.results.hbonds[:, DISTANCE]
df["angles"] = hbonds.results.hbonds[:, ANGLE]
df["donorResname"] = u.atoms[df.donor_ix].resnames
df["acceptorResname"] = u.atoms[df.acceptor_ix].resnames
df["donorResid"] = u.atoms[df.donor_ix].resids
df["acceptorResid"] = u.atoms[df.acceptor_ix].resids
df["donorName"] = u.atoms[df.donor_ix].names
df["acceptorName"] = u.atoms[df.acceptor_ix].names
# up till here works fine based on the tutorial, but the code below focused on defining the # segment the atoms is in is where the problem arises. Both of these assignments below # lead to '<Segment 4AKE>, <Segment CORE>' in the dataframe, not 1 segment or the
# other. In short, I can't figure out how to assign only the segment that the donor or acceptor atom # is in.
df['donorSegment'] = u.atoms[df.donor_ix].segments
df['acceptorSegment'] = u.atoms[df.acceptor_ix].segments
#And its clear that I'm using segments incorrectly since .names or .resnames or .resids
# is a list for each and all Hbonds
print(len(u.atoms[df.acceptor_ix].names))
10858
# but I only get 2 segments below when I examine the .segments, though
# I'd expect 10858 like .names or .resnames or .resids results in
print(len(u.atoms[df.acceptor_ix].residues.segments))
2
Any help would be appreciated.
Cheers,
Jason