Skip to content

Instantly share code, notes, and snippets.

View keitaroyam's full-sized avatar

keitaroyam

  • MRC-LMB / UTokyo / RIKEN SPring-8
View GitHub Profile
@keitaroyam
keitaroyam / all_mon_from_pdbj.py
Last active June 15, 2024 00:59
Getting the list of monomers from PDB
import json
import urllib
import requests
def req(query):
url = "https://pdbj.org/rest/newweb/search/sql?q=" + urllib.parse.quote(query)
raw = urllib.request.urlopen(url).read()
return json.loads(raw)["results"]
# [(pdb_id, monomer_id), ...]
all_mon = req("SELECT distinct pdbid,id FROM chem_comp")
@keitaroyam
keitaroyam / solvent_fraction.py
Created September 9, 2018 13:14
calculate solvent fraction from pdb (cctbx)
import iotbx.pdb
import mmtbx.utils
from mmtbx.scaling.matthews import p_vm_calculator
def run(pdbin):
pdb_inp = iotbx.pdb.input(pdbin)
xray_structure = pdb_inp.xray_structure_simple()
print "Read from %s" % pdb_in
xray_structure.show_summary(prefix=" ")
print
@keitaroyam
keitaroyam / check_plane_esd_first_atom_ccp4.py
Created September 27, 2016 10:00
I just wanted to check if in ccp4 monomer library there is no cif file where dist_esd of the first atom of plane is zero
import mmtbx.monomer_library.server
from mmtbx import monomer_library
import glob
import os
mon_lib_srv = monomer_library.server.server()
cif_files = glob.glob(os.path.join(os.environ["CLIBD_MON"], "*/*.cif"))
for cf in cif_files:
try:
@keitaroyam
keitaroyam / put_reversephi_info.py
Created June 10, 2016 11:56
Add reverse-phi information to master h5 file of Eiger
# This code will be unnecessary when new Eiger firmware offically writes this information
import h5py
def run(h5in):
h5 = h5py.File(h5in, "a")
if "/entry/sample/depends_on" not in h5:
h5["/entry/sample/depends_on"] = "/entry/sample/transformations/omega"