Skip to content

Instantly share code, notes, and snippets.

@yangkky
Created June 21, 2018 22:57
Show Gist options
  • Save yangkky/e5b4797072a216621f0ddce405395573 to your computer and use it in GitHub Desktop.
Save yangkky/e5b4797072a216621f0ddce405395573 to your computer and use it in GitHub Desktop.
from Bio.Seq import Seq
import Bio.PDB
import Bio.SeqUtils
pdb_filename = '../inputs/1qo7.pdb'
structure = Bio.PDB.PDBParser().get_structure(pdb_code, pdb_filename)
model = structure[0]
pdb_seq = [residue.resname for residue in model['B']]
pdb_seq = ''.join([Bio.SeqUtils.seq1(s) for s in pdb_seq])
ca_coord = np.array([residue['CA'].coord for residue in model['A'] if 'CA' in residue])
def get_contacts(d, cutoff):
contacts = np.argwhere(d < cutoff)
lower = np.array([c[0] < c[1] for c in contacts])
contacts = contacts[lower]
return [tuple(c) for c in contacts]
c50 = get_contacts(d, 5.0)
c45 = get_contacts(d, 4.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment