diff --git a/cctbx/geometry_restraints/auto_linking_types.py b/cctbx/geometry_restraints/auto_linking_types.py index 2328eadd70..ac4af2275f 100644 --- a/cctbx/geometry_restraints/auto_linking_types.py +++ b/cctbx/geometry_restraints/auto_linking_types.py @@ -29,7 +29,7 @@ def __repr__(self): "Bond angle", "Dihedral angle", "Chirality", - "Plane", + "Planarity", "Parallelity", ] @@ -43,7 +43,7 @@ def __repr__(self): starting_id = 0 for link_info in [ - ['covalent geometry', [0,1,2,3,4,5]], # 0 + ['covalent geometry', 'covalent geometry', [0,1,2,3,4,5]], # 0 ['SS BOND', # short desc. # complete desc. 'Disulphide bond for CYS-like sulphur atoms within 3A (default) using ' diff --git a/cctbx/geometry_restraints/linking_class.py b/cctbx/geometry_restraints/linking_class.py index f42a762c1e..0d202189b1 100644 --- a/cctbx/geometry_restraints/linking_class.py +++ b/cctbx/geometry_restraints/linking_class.py @@ -113,7 +113,10 @@ def get_geo_file_header(self, origin_id_label, internals=None): else: return info[0] def parse_geo_file_header(self, origin_id_label, subheader=None, internals=None): - if not origin_id_label in covalent_headers: + if origin_id_label in ['Nonbonded']: + # special case for Nonbonded + return 0, origin_id_label + elif not origin_id_label in covalent_headers: assert 0, 'origin_id_label "%s" not in %s' % (origin_id_label, covalent_headers) info = self.data.get(origin_id_label, None) if info: @@ -136,37 +139,54 @@ def get_origin_label_and_internal(self, query_header, verbose=False): if verbose: for origin_label, info in self.data.items(): print('origin_label, info',origin_label,info) + if query_header.find('|')==-1: return None tmp = query_header.split('|') - if len(tmp)==1: - oi = 0 # default - rc = 'covalent' - else: - header=tmp[0].strip() - subheader=tmp[1].strip() - oi, rc = self.parse_geo_file_header(header, subheader=subheader) - return oi, rc + header=tmp[0].strip() + subheader=tmp[1].strip() + oi, rc = self.parse_geo_file_header(header, subheader=subheader) + tmp = query_header.split(':') + num = int(tmp[-1]) + return oi, rc, num if __name__=='__main__': lc = linking_class() print(lc) - for line in [ 'Bond restraints', - 'Bond | Misc. | restraints', - 'Bond | link_BETA1-4 | restraints', - 'Bond | link_TRANS | restraints', - 'Bond angle restraints', - 'Bond angle | link_BETA1-4 | restraints', - 'Bond angle | link_TRANS | restraints', - 'Dihedral angle restraints', - 'Dihedral angle | C-Beta improper | restraints', - 'Dihedral angle | link_TRANS | restraints', - 'Chirality restraints', - 'Chirality | link_BETA1-4 | restraints', - 'Planarity restraints', - 'Plane | link_TRANS | restraints', - - "Bond | Bond-like | restraints", - "Bond angle | Secondary Structure restraints around h-bond | restraints", - "Parallelity | Stacking parallelity | restraints", - "Parallelity | Basepair parallelity | restraints", + for line in [ 'Bond | covalent geometry | restraints: -1', + 'Bond | Misc. | restraints: -1', + 'Bond | link_BETA1-4 | restraints: -1', + 'Bond | link_TRANS | restraints: -1', + 'Bond angle | covalent geometry | restraints: -1', + 'Bond angle | link_BETA1-4 | restraints: -1', + 'Bond angle | link_TRANS | restraints: -1', + 'Dihedral angle | covalent geometry | restraints: -1', + 'Dihedral angle | C-Beta improper | restraints: -1', + 'Dihedral angle | link_TRANS | restraints: -1', + 'Chirality | covalent geometry | restraints: -1', + 'Chirality | link_BETA1-4 | restraints: -1', + 'Planarity | covalent geometry | restraints: -1', + 'Planarity | link_TRANS | restraints: -1', + + "Bond | Bond-like | restraints: -1", + "Bond angle | Secondary Structure restraints around h-bond | restraints: -1", + "Parallelity | Stacking parallelity | restraints: -1", + "Parallelity | Basepair parallelity | restraints: -1", + 'random line', + + #148L + 'Bond | covalent geometry | restraints: 1390', + 'Bond | Misc. | restraints: 4', + 'Bond | link_BETA1-4 | restraints: 1', + 'Bond | link_TRANS | restraints: 1', + 'Bond angle | covalent geometry | restraints: 1868', + 'Bond angle | link_BETA1-4 | restraints: 3', + 'Bond angle | link_TRANS | restraints: 3', + 'Dihedral angle | covalent geometry | restraints: 563', + 'Dihedral angle | C-Beta improper | restraints: 308', + 'Dihedral angle | link_TRANS | restraints: 3', + 'Chirality | covalent geometry | restraints: 210', + 'Chirality | link_BETA1-4 | restraints: 1', + 'Planarity | covalent geometry | restraints: 238', + 'Planarity | link_TRANS | restraints: 1', + 'Nonbonded | unspecified | interactions: 15086', ]: print('.........',line, lc.get_origin_label_and_internal(line)) diff --git a/cctbx/geometry_restraints/manager.py b/cctbx/geometry_restraints/manager.py index 5d2a5f24f5..2b0af0fdd5 100644 --- a/cctbx/geometry_restraints/manager.py +++ b/cctbx/geometry_restraints/manager.py @@ -1633,7 +1633,8 @@ def show_sorted(self, f=None): from cctbx.geometry_restraints.auto_linking_types import covalent_headers from cctbx.geometry_restraints.auto_linking_types import internal_labels - default_origin_id = origin_ids.get_origin_id('covalent geometry') + covalent_key = 'covalent geometry' + default_origin_id = origin_ids.get_origin_id(covalent_key) if (f is None): f = sys.stdout pair_proxies = self.pair_proxies(flags=flags, sites_cart=sites_cart) if (sites_cart is None): @@ -1643,7 +1644,7 @@ def show_sorted(self, # # write covalent bonds # - label=covalent_headers[0] + label='%s | %s |' % (covalent_headers[0], covalent_key) tempbuffer = StringIO() pair_proxies.bond_proxies.show_sorted( by_value="residual", @@ -1656,6 +1657,7 @@ def show_sorted(self, # # write bonds with other origin_id # + label=covalent_headers[0] for key in origin_ids.get_bond_origin_id_labels(): origin_id=origin_ids.get_origin_id(key) if origin_id==default_origin_id: continue @@ -1673,51 +1675,54 @@ def show_sorted(self, # # write of the other internals for each origin_id # - for i, (proxies, i_label, keys, start) in enumerate([ + for i, (proxies, keys, start) in enumerate([ ( self.angle_proxies, # self.get_all_angle_proxies(), - '', origin_ids.get_angle_origin_id_labels(), 11), ( self.dihedral_proxies, # self.get_dihedral_proxies(), - '', #'torsion', origin_ids.get_dihedral_origin_id_labels(), 15), ( self.chirality_proxies, - '', origin_ids.get_chiral_origin_id_labels(), 10), ( self.planarity_proxies, - '', origin_ids.get_plane_origin_id_labels(), 10), ( self.parallelity_proxies, - '', origin_ids.get_parallelity_origin_id_labels(), 12), ]): p_label=covalent_headers[i+1] internals=internal_labels[i+1] if (proxies is not None): + # + # "covalent" original ids + # if p_label not in ['Parallelity']: # not default origin for parallelity + tempbuffer = StringIO() proxies.show_sorted( by_value="residual", sites_cart=sites_cart, site_labels=site_labels, - f=f, + f=tempbuffer, origin_id=default_origin_id) - print(file=f) - for key in keys: #origin_ids.get_dihedral_origin_id_labels(): + print('%s | %s | %s' % (tempbuffer.getvalue()[:start-1], + covalent_key, + tempbuffer.getvalue()[start:]), + file=f) + # + # other origin ids + # + for key in keys: origin_id=origin_ids.get_origin_id(key) if origin_id==default_origin_id: continue label=origin_ids.get_geo_file_header(key, internals=internals) if label is None: continue - # label = '%s - %s' % (p_label, label) - if i_label: label = '%s %s' % (label, i_label) tempbuffer = StringIO() proxies.show_sorted( by_value="residual", @@ -1748,11 +1753,17 @@ def show_sorted(self, # Here should be showing DEN manager... # if (pair_proxies.nonbonded_proxies is not None): + tempbuffer = StringIO() pair_proxies.nonbonded_proxies.show_sorted( by_value="delta", - sites_cart=sites_cart, site_labels=site_labels, f=f, + sites_cart=sites_cart, site_labels=site_labels, + f=tempbuffer, suppress_model_minus_vdw_greater_than=None) - print(file=f) + start=10 + print('%s| unspecified | %s' % (tempbuffer.getvalue()[:start], + tempbuffer.getvalue()[start:] + ), + file=f) # This should be in model class? # def nb_overlaps_info( diff --git a/cctbx/regression/tst_geometry_restraints_2.py b/cctbx/regression/tst_geometry_restraints_2.py index 84a2fd9691..4cb89e7f23 100644 --- a/cctbx/regression/tst_geometry_restraints_2.py +++ b/cctbx/regression/tst_geometry_restraints_2.py @@ -395,7 +395,7 @@ def exercise_non_crystallographic_conserving_bonds_and_angles(): sio = StringIO() geo.show_sorted(sites_cart=sites_cart_noise, f=sio) expected_first_part = """\ -Bond restraints: 5 +Bond | covalent geometry | restraints: 5 Sorted by residual: bond 2 3 @@ -420,7 +420,7 @@ def exercise_non_crystallographic_conserving_bonds_and_angles(): """ assert not show_diff(sio.getvalue(), expected_first_part + """\ -Nonbonded interactions: 0 +Nonbonded | unspecified | interactions: 0 """) # @@ -438,7 +438,7 @@ def exercise_non_crystallographic_conserving_bonds_and_angles(): sio = StringIO() geo.show_sorted(sites_cart=sites_cart_noise, f=sio) assert not show_diff(sio.getvalue(), expected_first_part + """\ -Nonbonded interactions: 2 +Nonbonded | unspecified | interactions: 2 Sorted by model distance: nonbonded 0 4 @@ -598,10 +598,11 @@ def exercise_na_restraints_output_to_geo(verbose=False): print("This portion was not found:\n%s\n=====End of portion." % portion) assert 0, "the portion above does not match expected portion." # check .geo output - geo_identical_portions = ["Bond restraints: 87", - "Bond angle restraints: 130", "Dihedral angle restraints: 33", - "Chirality restraints: 15", - "Planarity restraints: 4"] + geo_identical_portions = ["Bond | covalent geometry | restraints: 87", + "Bond angle | covalent geometry | restraints: 130", + "Dihedral angle | covalent geometry | restraints: 33", + "Chirality | covalent geometry | restraints: 15", + "Planarity | covalent geometry | restraints: 4"] ss_geo_portions = [ # "Bond-like restraints: 6", "Bond | Bond-like | restraints: 6", @@ -611,12 +612,12 @@ def exercise_na_restraints_output_to_geo(verbose=False): # 'Basepair parallelity restraints: 2', 'Parallelity | Stacking parallelity | restraints: 2', 'Parallelity | Basepair parallelity | restraints: 2', - "Nonbonded interactions: 504"] + "Nonbonded | unspecified | interactions: 504"] non_ss_geo_portions = [ #"Bond-like restraints: 0", #'Secondary Structure restraints around h-bond angle restraints: 0', # "Parallelity restraints: 0", removed because zero - "Nonbonded interactions: 526"] + "Nonbonded | unspecified | interactions: 526"] acp = processed_pdb_file.all_chain_proxies sites_cart = acp.sites_cart_exact() site_labels = [atom.id_str() for atom in acp.pdb_atoms] diff --git a/mmtbx/monomer_library/tst_linking.py b/mmtbx/monomer_library/tst_linking.py index 742cde6fa1..8013506e64 100644 --- a/mmtbx/monomer_library/tst_linking.py +++ b/mmtbx/monomer_library/tst_linking.py @@ -2441,7 +2441,8 @@ "linking_test_CD_GHE_A_B.pdb" : [0,0], #4], "linking_test_XYP_XYP.pdb" : [18,19], "linking_test_ALY_MCM.pdb" : [11,12], # links AA with quasi-AA - "linking_test_cyclic_side_chain.pdb" : [67,68], # side chain cross link + # cross link not working + "linking_test_cyclic_side_chain.pdb" : [67,67], # side chain cross link "linking_test_cyclic_main_chain.pdb" : [34,35], # main chain cyclic "linking_test_over_valence.pdb" : [6,6], "linking_test_c2_c6.pdb" : [21,22], @@ -2481,7 +2482,7 @@ def run_and_test(cmd, pdb, i, skip_links=False): assert lines.find('link_TRANS | restraints: 1')>-1 bonds = 0 for line in lines.splitlines(): - for bond_like in ["Bond restraints:", + for bond_like in ["Bond | covalent geometry | restraints:", 'Bond-like restraints:', 'Bond | Metal coordination | restraints', 'Bond | User supplied | restraints', diff --git a/mmtbx/monomer_library/tst_paral_geo.py b/mmtbx/monomer_library/tst_paral_geo.py index 6a147a07b9..747edaf3f5 100644 --- a/mmtbx/monomer_library/tst_paral_geo.py +++ b/mmtbx/monomer_library/tst_paral_geo.py @@ -704,7 +704,7 @@ def test_geo(result, opposite=False): def main(): write_and_run(large_pdb) - result = '''Plane | Basepair planarity | restraints: 5 + result = '''Planarity | Basepair planarity | restraints: 5 Sorted by residual: delta sigma weight rms_deltas residual plane pdb=" C1' DC C 7 " -0.366 1.76e-01 3.23e+01 1.84e-01 2.28e+01 diff --git a/mmtbx/regression/tst_origin_ids.py b/mmtbx/regression/tst_origin_ids.py index 7108d6e85e..d463f2ca04 100644 --- a/mmtbx/regression/tst_origin_ids.py +++ b/mmtbx/regression/tst_origin_ids.py @@ -3,13 +3,13 @@ from iotbx.data_manager import DataManager count_1yjp = { - 'Bond restraints': 59, - 'Bond angle restraints': 79, - 'Dihedral angle restraints': 22, + 'Bond | covalent geometry | restraints': 59, + 'Bond angle | covalent geometry | restraints': 79, + 'Dihedral angle | covalent geometry | restraints': 22, ' harmonic': 7, ' sinusoidal': 15, - 'Planarity restraints': 13, - 'Chirality restraints': 6, + 'Planarity | covalent geometry | restraints': 13, + 'Chirality | covalent geometry | restraints': 6, # 'C-Beta improper torsion angle restraints': 12, 'Dihedral angle | C-Beta improper | restraints': 12, # 'Parallelity restraints': 0, @@ -24,12 +24,12 @@ #'Metal coordination restraints': 0, #'Disulphide bridge angle restraints': 0, #'Disulphide bridge restraints': 0, - 'Nonbonded interactions': 990, + 'Nonbonded | unspecified | interactions': 990, # # 'Bond | User supplied | restraints': -1, } count_1yjp_with_waters = count_1yjp.copy() -count_1yjp_with_waters['Nonbonded interactions'] = 1178 +count_1yjp_with_waters['Nonbonded | unspecified | interactions'] = 1178 edits = ''' refinement.geometry_restraints.edits { @@ -76,7 +76,7 @@ def main(): model = dm.get_model() rc = model.restraints_as_geo(force=True) rc = check_geo(rc) - assert rc == count_1yjp_with_waters, rc + assert rc == count_1yjp_with_waters, '%s != %s' % (count_1yjp_with_waters, rc) params = model.get_default_pdb_interpretation_params() edits_1yjp = params.geometry_restraints.edits @@ -93,7 +93,7 @@ def main(): current = count_1yjp_with_waters.copy() # current['User supplied restraints'] = 1 current['Bond | User supplied | restraints'] = 1 - current['Nonbonded interactions'] = 1176 + current['Nonbonded | unspecified | interactions'] = 1176 assert rc == current, check_diff(rc, current) edits_1yjp.angle[0].action='add' @@ -109,7 +109,7 @@ def main(): current = count_1yjp_with_waters.copy() current['Bond | User supplied | restraints'] = 1 current['Bond angle | User supplied | restraints'] = 1 - current['Nonbonded interactions'] = 1176 + current['Nonbonded | unspecified | interactions'] = 1176 assert rc == current, check_diff(rc, current) edits_1yjp.dihedral[0].action='add' @@ -129,7 +129,7 @@ def main(): current['Bond angle | User supplied | restraints'] = 1 current['Dihedral angle | User supplied | restraints'] = 1 #current[' sinusoidal'] = 16 - current['Nonbonded interactions'] = 1176 + current['Nonbonded | unspecified | interactions'] = 1176 assert rc == current, check_diff(rc, current) print('OK')