Replies: 2 comments 1 reply
-
I am going to convert this to a discussion @hjb-001 |
Beta Was this translation helpful? Give feedback.
-
I'll preface that any workflow that requires writing of individual PDB files as intermediates is terribly inefficient; however, I understand that sometimes inefficient is still better than nothing. (For example, in order to run HOLE2 on a trajectory to quantify pores, the mdahole2 package has to write individual temporary PDB files.) In short: import os
import MDAnalysis as mda
u = mda.Universe(TPR, XTC)
# only take the protein
protein = u.select_atoms("protein")
#-------------------------------------------------------
# OPTIONAL:
# add various attributes so that the PDB files are fully featured
# just in case that this is important (or ignore the warnings that you get
# from the PDBWriter)
u.add_TopologyAttr("chainID")
protein.chainIDs = "A" # make protein chain A; adjust if you have multiple chains
u.add_TopologyAttr("tempfactors", u.atoms.n_atoms * [0.0])
u.add_TopologyAttr("occupancies", u.atoms.n_atoms * [1.0])
u.add_TopologyAttr("elements", [mda.topology.guessers.guess_atom_element(name) for name in u.atoms.names])
u.add_TopologyAttr("altLocs")
u.add_TopologyAttr("icodes")
#-------------------------------------------------------
for ts in u.trajectory:
filename = f"protein_{ts.frame}.pdb"
protein.write(filename)
# now run fpocket on the PDB
# ...
os.remove(filename) You can organize writing temporary files in a better way using tempfile. You could also write it to a RAM disk (or at least a SSD). If you can call fpocket as a library then you may be able to do what we're doing for propkatraj where we write the file to a memory buffer (IOStream) https://github.com/Becksteinlab/propkatraj/blob/13b7ec56fc84c9042fab95238800c087d6b83fb3/propkatraj/propkatraj.py#L110-L111 and then have propka read the "PDB" from memory. |
Beta Was this translation helpful? Give feedback.
-
Splitting protein molecular trajectory files into individual pdb files facilitates pocket extraction of proteins using fpocket.
Beta Was this translation helpful? Give feedback.
All reactions