Skip to content

Instantly share code, notes, and snippets.

@kyleabeauchamp
Last active August 29, 2015 14:05
Show Gist options
  • Save kyleabeauchamp/6f0ab1a0c68eefe527b1 to your computer and use it in GitHub Desktop.
Save kyleabeauchamp/6f0ab1a0c68eefe527b1 to your computer and use it in GitHub Desktop.
Test MDTraj on PDB
import os
import mdtraj as md
import gzip
import tempfile
import glob
directories = glob.glob("./all_pdb/*")
for directory in directories:
filenames = glob.glob("%s/*.gz" % directory)
for filename in filenames:
gfile = gzip.open(filename, 'rb')
pdb_filename = tempfile.mktemp(suffix=".pdb")
fout = open(pdb_filename, 'w')
fout.write(gfile.read())
fout.close()
try:
t = md.load_pdb(pdb_filename)
top, bonds = t.top.to_dataframe()
except Exception as e:
print(e)
print(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment