Skip to content

Commit

Permalink
Finish building asu bond proxies from .geo file
Browse files Browse the repository at this point in the history
  • Loading branch information
cschlick committed Nov 11, 2024
1 parent 1248aa9 commit 934912b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
30 changes: 29 additions & 1 deletion mmtbx/geometry_restraints/geo_file_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from libtbx.utils import Sorry
from cctbx import geometry_restraints
from cctbx.geometry_restraints.linking_class import linking_class
from cctbx.array_family import flex
from cctbx import crystal
from cctbx.crystal import direct_space_asu

origin_ids = linking_class()


Expand Down Expand Up @@ -37,6 +41,7 @@ def __init__(self,lines,origin_id=0,origin_label="covalent"):
# Parsing data structures
self.lines = lines # raw .geo lines
self.i_seqs = [] # list of integer i_seqs (if possible)
self.sites_cart = None # Flex vec3 array, coord for each i_seq if available
self.atom_labels = [] # list of string atom label from .geo
self._numerical = None # a dict of numerical geo data
self.origin_id = origin_id
Expand Down Expand Up @@ -159,7 +164,19 @@ def has_sym_op(self):

def to_proxy(self):
if self.has_sym_op:
proxy = None
asu_mappings = direct_space_asu.non_crystallographic_asu_mappings(
sites_cart=self.sites_cart)
pair_generator = crystal.neighbors_fast_pair_generator(
asu_mappings=asu_mappings,
distance_cutoff=5)
pair = geometry_restraints.bond_asu_proxy(
pair=next(pair_generator),
distance_ideal=self.ideal,
weight=self.weight,
origin_id=self.origin_id)
proxy = geometry_restraints.bond_asu_proxy(pair=pair, params=pair)
return proxy

else:
proxy = geometry_restraints.bond_simple_proxy(
i_seqs=self.i_seqs,
Expand Down Expand Up @@ -482,6 +499,7 @@ def __init__(self,geo_lines,model=None,entry_config=None):
# If model present, add i_seqs
if self.model:
self._fill_labels_from_model(self.model)
self._fill_sites_cart_from_model(self.model)

@property
def proxies(self):
Expand All @@ -493,6 +511,16 @@ def has_proxies(self):
def i_seqs_are_available(self):
return all([entry.i_seqs_are_available() for entry in self.entries_list])

def _fill_sites_cart_from_model(self,model):
# Verify iseqs
if not self.i_seqs_are_available():
self._fill_labels_from_model(model)
# get sites cart
sites_cart = model.get_sites_cart()
for entry in self.entries_list:
entry.sites_cart = sites_cart.select(flex.size_t(entry.i_seqs))


def _fill_labels_from_model(self, model):
"""
Add i_seq attributes for each atom on each entry
Expand Down
4 changes: 4 additions & 0 deletions mmtbx/geometry_restraints/tst_geo_file_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from iotbx.data_manager import DataManager
from cctbx.crystal.tst_super_cell import pdb_str_1yjp
from mmtbx.geometry_restraints.geo_file_parsing import GeoParser
from cctbx import geometry_restraints
from libtbx.test_utils import show_diff

"""
Expand Down Expand Up @@ -1534,6 +1535,9 @@ def tst_06(model,printing=False):
geo_container.build_proxies()
assert geo_container.has_proxies()
assert len(geo_container.proxies_list) == len(entries)-len(geo_container.entries["Nonbonded"])
# Check for successful build of the single asu text proxy
proxy_class_list = [type(p) for p in geo_container.proxies_list]
assert geometry_restraints.bond_asu_proxy in proxy_class_list

origins = [entry.origin_label for entry in geo_container.entries_list]
expected_origins = ['covalent geometry', 'Misc.', 'link_ALPHA2-6', 'Disulphide bridge', 'link_NAG-ASN', '-like', 'Metal coordination', 'link_TRANS', 'Custom Glycosidic', 'link_BETA1-6', 'link_BETA1-3', 'User supplied', 'link_BETA1-4', 'covalent geometry', 'link_ALPHA2-6', 'Disulphide bridge', 'link_NAG-ASN', 'Secondary Structure restraints around h-bond', 'link_TRANS', 'Custom Glycosidic', 'link_BETA1-6', 'link_BETA1-3', 'link_BETA1-4', 'covalent geometry', 'C-Beta improper', 'Side chain', 'link_TRANS', 'covalent geometry', 'link_ALPHA2-6', 'link_NAG-ASN', 'link_BETA1-6', 'link_BETA1-3', 'link_BETA1-4', 'covalent geometry', 'link_NAG-ASN', 'link_TRANS', '', 'Stacking parallelity', 'Basepair parallelity']
Expand Down

0 comments on commit 934912b

Please sign in to comment.