Skip to content

Instantly share code, notes, and snippets.

@keitaroyam
Created September 9, 2018 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keitaroyam/7a06528b81a2f7eb86853adc27bec8fd to your computer and use it in GitHub Desktop.
Save keitaroyam/7a06528b81a2f7eb86853adc27bec8fd to your computer and use it in GitHub Desktop.
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
print "Mask-based calculation"
print " Solvent Content:", mmtbx.utils.f_000(xray_structure=xray_structure).solvent_fraction
print
hierarchy = pdb_inp.construct_hierarchy()
counts = hierarchy.overall_counts()
num_aa = counts.resname_classes.get("common_amino_acid", 0)
num_na = counts.resname_classes.get("common_rna_dna", 0)
print "Sequence-based calculation"
print " Number of amino acids: %d" % num_aa
print " Number of bases: %d" % num_na
vm_calc = p_vm_calculator(xray_structure.crystal_symmetry(), n_residues=num_aa, n_bases=num_na)
print " Solvent Content: ", vm_calc.solc(vm=vm_calc.vm(copies=1))
# run()
if __name__ == "__main__":
import sys
pdb_in = sys.argv[1]
run(pdb_in)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment