servalcat 0.4.72__cp312-cp312-macosx_11_0_arm64.whl → 0.4.88__cp312-cp312-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of servalcat might be problematic. Click here for more details.
- servalcat/__init__.py +2 -2
- servalcat/ext.cpython-312-darwin.so +0 -0
- servalcat/refine/refine.py +28 -26
- servalcat/refine/refine_geom.py +8 -2
- servalcat/refine/refine_spa.py +21 -12
- servalcat/refine/refine_xtal.py +27 -8
- servalcat/refine/spa.py +3 -0
- servalcat/refine/xtal.py +142 -96
- servalcat/refmac/exte.py +7 -5
- servalcat/refmac/refmac_keywords.py +11 -9
- servalcat/refmac/refmac_wrapper.py +89 -54
- servalcat/spa/fofc.py +11 -0
- servalcat/spa/fsc.py +3 -1
- servalcat/spa/run_refmac.py +11 -1
- servalcat/utils/fileio.py +5 -2
- servalcat/utils/hkl.py +20 -8
- servalcat/utils/model.py +13 -0
- servalcat/utils/refmac.py +19 -0
- servalcat/utils/restraints.py +19 -9
- servalcat/xtal/french_wilson.py +34 -28
- servalcat/xtal/sigmaa.py +338 -130
- servalcat/xtal/twin.py +115 -0
- {servalcat-0.4.72.dist-info → servalcat-0.4.88.dist-info}/METADATA +3 -3
- servalcat-0.4.88.dist-info/RECORD +45 -0
- {servalcat-0.4.72.dist-info → servalcat-0.4.88.dist-info}/WHEEL +1 -1
- servalcat-0.4.72.dist-info/RECORD +0 -44
- {servalcat-0.4.72.dist-info → servalcat-0.4.88.dist-info}/entry_points.txt +0 -0
- {servalcat-0.4.72.dist-info → servalcat-0.4.88.dist-info}/licenses/LICENSE +0 -0
servalcat/__init__.py
CHANGED
|
Binary file
|
servalcat/refine/refine.py
CHANGED
|
@@ -40,7 +40,12 @@ class Geom:
|
|
|
40
40
|
self.atom_pos = list(range(len(self.atoms)))
|
|
41
41
|
self.n_refine_atoms = max(self.atom_pos) + 1
|
|
42
42
|
self.lookup = {x.atom: x for x in self.st[0].all()}
|
|
43
|
-
|
|
43
|
+
try:
|
|
44
|
+
self.geom = ext.Geometry(self.st, self.atom_pos, monlib.ener_lib)
|
|
45
|
+
except TypeError as e:
|
|
46
|
+
raise SystemExit(f"An error occurred while creating the Geometry object:\n{e}\n\n"
|
|
47
|
+
"This likely indicates an installation issue. "
|
|
48
|
+
"Please verify that you have the correct version of gemmi installed and that both gemmi and servalcat were compiled in the same environment.")
|
|
44
49
|
self.specs = utils.model.find_special_positions(self.st)
|
|
45
50
|
#cs_count = len(self.st.find_spacegroup().operations())
|
|
46
51
|
for atom, images, matp, mata in self.specs:
|
|
@@ -58,7 +63,6 @@ class Geom:
|
|
|
58
63
|
self.calc_kwds = {"use_nucleus": self.use_nucleus}
|
|
59
64
|
if params is None:
|
|
60
65
|
params = {}
|
|
61
|
-
exte.read_external_restraints(params.get("exte", []), self.st, self.geom)
|
|
62
66
|
for k in ("wbond", "wangle", "wtors", "wplane", "wchir", "wvdw", "wncs"):
|
|
63
67
|
if k in params:
|
|
64
68
|
self.calc_kwds[k] = params[k]
|
|
@@ -70,26 +74,13 @@ class Geom:
|
|
|
70
74
|
self.group_occ = GroupOccupancy(self.st, params.get("occu"))
|
|
71
75
|
if not self.unrestrained:
|
|
72
76
|
self.geom.load_topo(topo)
|
|
73
|
-
|
|
77
|
+
exte.read_external_restraints(params.get("exte", []), self.st, self.geom)
|
|
74
78
|
self.geom.finalize_restraints()
|
|
75
79
|
self.outlier_sigmas = dict(bond=5, angle=5, torsion=5, vdw=5, ncs=5, chir=5, plane=5, staca=5, stacd=5, per_atom=5)
|
|
76
80
|
self.parents = {}
|
|
77
81
|
self.ncslist = ncslist
|
|
78
82
|
# __init__()
|
|
79
83
|
|
|
80
|
-
def check_chemtypes(self, enerlib_path, topo):
|
|
81
|
-
block = gemmi.cif.read(enerlib_path).sole_block()
|
|
82
|
-
all_types = set(block.find_values("_lib_atom.type"))
|
|
83
|
-
for ci in topo.chain_infos:
|
|
84
|
-
for ri in ci.res_infos:
|
|
85
|
-
cc_all = {x: ri.get_final_chemcomp(x) for x in set(a.altloc for a in ri.res)}
|
|
86
|
-
for a in ri.res:
|
|
87
|
-
cca = cc_all[a.altloc].find_atom(a.name)
|
|
88
|
-
if cca is None: # I believe it won't happen..
|
|
89
|
-
logger.writeln("WARNING: restraint for {} not found.".format(self.lookup[a]))
|
|
90
|
-
elif cca.chem_type not in all_types:
|
|
91
|
-
raise RuntimeError("Energy type {} of {} not found in ener_lib.".format(cca.chem_type,
|
|
92
|
-
self.lookup[a]))
|
|
93
84
|
def set_h_parents(self):
|
|
94
85
|
self.parents = {}
|
|
95
86
|
for bond in self.geom.bonds:
|
|
@@ -176,15 +167,16 @@ class Geom:
|
|
|
176
167
|
logger.writeln(df.to_string(float_format="{:.3f}".format, index=False) + "\n")
|
|
177
168
|
|
|
178
169
|
# Per-atom score
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
df.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
170
|
+
if 0:
|
|
171
|
+
peratom = self.geom.reporting.per_atom_score(len(self.atoms), self.use_nucleus, "mean")
|
|
172
|
+
df = pandas.DataFrame(peratom)
|
|
173
|
+
df.insert(0, "atom", [str(self.lookup[x]) for x in self.atoms])
|
|
174
|
+
df = df[df["total"] >= self.outlier_sigmas["per_atom"]]
|
|
175
|
+
if show_outliers and len(df.index) > 0:
|
|
176
|
+
df.sort_values("total", ascending=False, inplace=True)
|
|
177
|
+
ret["outliers"]["per_atom"] = df
|
|
178
|
+
logger.writeln(" *** Per-atom violations (Z >= {}) ***\n".format(self.outlier_sigmas["per_atom"]))
|
|
179
|
+
logger.writeln(df.to_string(float_format="{:.2f}".format, index=False) + "\n")
|
|
188
180
|
|
|
189
181
|
df = pandas.DataFrame(self.geom.reporting.get_summary_table(self.use_nucleus))
|
|
190
182
|
df = df.set_index("Restraint type").rename_axis(index=None)
|
|
@@ -556,6 +548,8 @@ class Refine:
|
|
|
556
548
|
self.geom.setup_nonbonded(self.refine_xyz) # if refine_xyz=False, no need to do it every time
|
|
557
549
|
self.geom.geom.setup_target(self.refine_xyz, self.adp_mode, self.refine_occ, self.use_occr)
|
|
558
550
|
logger.writeln("vdws = {}".format(len(self.geom.geom.vdws)))
|
|
551
|
+
logger.writeln(f"atoms = {self.geom.geom.target.n_atoms()}")
|
|
552
|
+
logger.writeln(f"pairs = {self.geom.geom.target.n_pairs()}")
|
|
559
553
|
|
|
560
554
|
def get_x(self):
|
|
561
555
|
n_atoms = self.geom.n_refine_atoms
|
|
@@ -675,6 +669,8 @@ class Refine:
|
|
|
675
669
|
self.geom.setup_nonbonded(self.refine_xyz)
|
|
676
670
|
self.geom.geom.setup_target(self.refine_xyz, self.adp_mode, self.refine_occ, self.use_occr)
|
|
677
671
|
logger.writeln("vdws = {}".format(len(self.geom.geom.vdws)))
|
|
672
|
+
logger.writeln(f"atoms = {self.geom.geom.target.n_atoms()}")
|
|
673
|
+
logger.writeln(f"pairs = {self.geom.geom.target.n_pairs()}")
|
|
678
674
|
stats[-1]["geom"] = self.geom.show_model_stats(refine_xyz=self.refine_xyz and not self.unrestrained,
|
|
679
675
|
adp_mode=self.adp_mode,
|
|
680
676
|
use_occr=self.refine_occ,
|
|
@@ -683,9 +679,12 @@ class Refine:
|
|
|
683
679
|
self.ll.update_fc()
|
|
684
680
|
self.ll.overall_scale()
|
|
685
681
|
self.ll.update_ml_params()
|
|
682
|
+
self.ll.prepare_target()
|
|
686
683
|
llstats = self.ll.calc_stats(bin_stats=True)
|
|
687
684
|
stats[-1]["data"] = {"summary": llstats["summary"],
|
|
688
685
|
"binned": llstats["bin_stats"].to_dict(orient="records")}
|
|
686
|
+
if "twin_alpha" in llstats:
|
|
687
|
+
stats[-1]["twin_alpha"] = llstats["twin_alpha"]
|
|
689
688
|
show_binstats(llstats["bin_stats"], 0)
|
|
690
689
|
if self.adp_mode > 0:
|
|
691
690
|
utils.model.adp_analysis(self.st)
|
|
@@ -713,12 +712,15 @@ class Refine:
|
|
|
713
712
|
self.ll.overall_scale()
|
|
714
713
|
f0 = self.ll.calc_target()
|
|
715
714
|
self.ll.update_ml_params()
|
|
715
|
+
self.ll.prepare_target()
|
|
716
716
|
llstats = self.ll.calc_stats(bin_stats=True)#(i==ncycles-1))
|
|
717
717
|
if llstats["summary"]["-LL"] > f0:
|
|
718
718
|
logger.writeln("WARNING: -LL has increased after ML parameter optimization:"
|
|
719
719
|
"{} to {}".format(f0, llstats["summary"]["-LL"]))
|
|
720
720
|
stats[-1]["data"] = {"summary": llstats["summary"],
|
|
721
721
|
"binned": llstats["bin_stats"].to_dict(orient="records")}
|
|
722
|
+
if "twin_alpha" in llstats:
|
|
723
|
+
stats[-1]["twin_alpha"] = llstats["twin_alpha"]
|
|
722
724
|
show_binstats(llstats["bin_stats"], i+1)
|
|
723
725
|
if self.adp_mode > 0:
|
|
724
726
|
utils.model.adp_analysis(self.st)
|
|
@@ -734,7 +736,7 @@ class Refine:
|
|
|
734
736
|
weight /= 1.1
|
|
735
737
|
if self.st_traj is not None:
|
|
736
738
|
self.st_traj.add_model(self.st[0])
|
|
737
|
-
self.st_traj[-1].name = str(
|
|
739
|
+
self.st_traj[-1].name = str(len(self.st_traj))
|
|
738
740
|
if stats_json_out:
|
|
739
741
|
write_stats_json_safe(stats, stats_json_out)
|
|
740
742
|
|
servalcat/refine/refine_geom.py
CHANGED
|
@@ -44,6 +44,8 @@ def add_arguments(parser):
|
|
|
44
44
|
help="refmac keyword file(s)")
|
|
45
45
|
parser.add_argument('-o','--output_prefix',
|
|
46
46
|
help="Output prefix")
|
|
47
|
+
parser.add_argument("--write_trajectory", action='store_true',
|
|
48
|
+
help="Write all output from cycles")
|
|
47
49
|
|
|
48
50
|
# add_arguments()
|
|
49
51
|
|
|
@@ -150,7 +152,8 @@ def refine_geom(model_in, monomer_dir, cif_files, h_change, ncycle, output_prefi
|
|
|
150
152
|
cif_files=cif_files,
|
|
151
153
|
stop_for_unknowns=True,
|
|
152
154
|
params=params)
|
|
153
|
-
utils.restraints.find_and_fix_links(st, monlib,
|
|
155
|
+
utils.restraints.find_and_fix_links(st, monlib, find_metal_links=find_links,
|
|
156
|
+
add_found=find_links) # should remove unknown id here?
|
|
154
157
|
try:
|
|
155
158
|
topo, _ = utils.restraints.prepare_topology(st, monlib, h_change=h_change,
|
|
156
159
|
check_hydrogen=(h_change==gemmi.HydrogenChange.NoChange),
|
|
@@ -163,11 +166,13 @@ def refine_geom(model_in, monomer_dir, cif_files, h_change, ncycle, output_prefi
|
|
|
163
166
|
else:
|
|
164
167
|
ncslist = False
|
|
165
168
|
geom = Geom(st, topo, monlib, shake_rms=randomize, params=params, ncslist=ncslist)
|
|
166
|
-
refiner = Refine(st, geom)
|
|
169
|
+
refiner = Refine(st, geom, params=params)
|
|
167
170
|
stats = refiner.run_cycles(ncycle,
|
|
168
171
|
stats_json_out=output_prefix + "_stats.json")
|
|
169
172
|
refiner.st.name = output_prefix
|
|
170
173
|
utils.fileio.write_model(refiner.st, output_prefix, pdb=True, cif=True)
|
|
174
|
+
if params["write_trajectory"]:
|
|
175
|
+
utils.fileio.write_model(refiner.st_traj, output_prefix + "_traj", cif=True)
|
|
171
176
|
# refine_geom()
|
|
172
177
|
|
|
173
178
|
def main(args):
|
|
@@ -177,6 +182,7 @@ def main(args):
|
|
|
177
182
|
decide_prefix = lambda f: utils.fileio.splitext(os.path.basename(f))[0] + "_refined"
|
|
178
183
|
if args.model:
|
|
179
184
|
params = refmac_keywords.parse_keywords(keywords)
|
|
185
|
+
params["write_trajectory"] = args.write_trajectory
|
|
180
186
|
if not args.output_prefix:
|
|
181
187
|
args.output_prefix = decide_prefix(args.model)
|
|
182
188
|
if args.ligand:
|
servalcat/refine/refine_spa.py
CHANGED
|
@@ -53,8 +53,10 @@ def add_arguments(parser):
|
|
|
53
53
|
help="Monomer library path. Default: $CLIBD_MON")
|
|
54
54
|
parser.add_argument('--ligand', nargs="*", action="append",
|
|
55
55
|
help="restraint dictionary cif file(s)")
|
|
56
|
+
parser.add_argument('--newligand_continue', action='store_true',
|
|
57
|
+
help="Make ad-hoc restraints for unknown ligands (not recommended)")
|
|
56
58
|
parser.add_argument('--hydrogen', default="all", choices=["all", "yes", "no"],
|
|
57
|
-
help="all:
|
|
59
|
+
help="all: (re)generate hydrogen atoms, yes: use hydrogen atoms if present, no: remove hydrogen atoms in input. "
|
|
58
60
|
"Default: %(default)s")
|
|
59
61
|
parser.add_argument('--hout', action='store_true', help="write hydrogen atoms in the output model")
|
|
60
62
|
parser.add_argument('--jellybody', action='store_true',
|
|
@@ -65,15 +67,15 @@ def add_arguments(parser):
|
|
|
65
67
|
parser.add_argument('--jellyonly', action='store_true',
|
|
66
68
|
help="Jelly body only (experimental, may not be useful)")
|
|
67
69
|
utils.symmetry.add_symmetry_args(parser) # add --pg etc
|
|
68
|
-
parser.add_argument('--contacting_only', action="store_true", help="Filter out non-contacting NCS")
|
|
70
|
+
parser.add_argument('--contacting_only', action="store_true", help="Filter out non-contacting strict NCS copies")
|
|
69
71
|
parser.add_argument('--ignore_symmetry',
|
|
70
72
|
help='Ignore symmetry information (MTRIX/_struct_ncs_oper) in the model file')
|
|
71
73
|
parser.add_argument('--find_links', action='store_true',
|
|
72
74
|
help='Automatically add links')
|
|
73
75
|
parser.add_argument('--no_check_ncs_overlaps', action='store_true',
|
|
74
|
-
help='Disable model overlap
|
|
76
|
+
help='Disable model overlap test due to strict NCS')
|
|
75
77
|
parser.add_argument('--no_check_ncs_map', action='store_true',
|
|
76
|
-
help='Disable map
|
|
78
|
+
help='Disable map symmetry test due to strict NCS')
|
|
77
79
|
parser.add_argument('--no_check_mask_with_model', action='store_true',
|
|
78
80
|
help='Disable mask test using model')
|
|
79
81
|
parser.add_argument('--keywords', nargs='+', action="append",
|
|
@@ -81,7 +83,7 @@ def add_arguments(parser):
|
|
|
81
83
|
parser.add_argument('--keyword_file', nargs='+', action="append",
|
|
82
84
|
help="refmac keyword file(s)")
|
|
83
85
|
parser.add_argument('--randomize', type=float, default=0,
|
|
84
|
-
help='Shake coordinates with specified rmsd')
|
|
86
|
+
help='Shake coordinates with the specified rmsd value')
|
|
85
87
|
parser.add_argument('--ncycle', type=int, default=10,
|
|
86
88
|
help="number of CG cycles (default: %(default)d)")
|
|
87
89
|
parser.add_argument('--weight', type=float,
|
|
@@ -91,20 +93,22 @@ def add_arguments(parser):
|
|
|
91
93
|
parser.add_argument('--target_bond_rmsz_range', nargs=2, type=float, default=[0.5, 1.],
|
|
92
94
|
help='Bond rmsz range for weight adjustment (default: %(default)s)')
|
|
93
95
|
parser.add_argument('--adpr_weight', type=float, default=1.,
|
|
94
|
-
help="ADP restraint weight
|
|
96
|
+
help="ADP restraint weight (default: %(default)f)")
|
|
95
97
|
parser.add_argument('--ncsr', action='store_true',
|
|
96
98
|
help='Use local NCS restraints')
|
|
97
99
|
parser.add_argument('--bfactor', type=float,
|
|
98
|
-
help="reset all atomic B values to specified value")
|
|
99
|
-
parser.add_argument('--fix_xyz', action="store_true"
|
|
100
|
-
|
|
100
|
+
help="reset all atomic B values to the specified value")
|
|
101
|
+
parser.add_argument('--fix_xyz', action="store_true",
|
|
102
|
+
help="Fix atomic coordinates")
|
|
103
|
+
parser.add_argument('--adp', choices=["fix", "iso", "aniso"], default="iso",
|
|
104
|
+
help="ADP parameterization")
|
|
101
105
|
parser.add_argument('--refine_all_occ', action="store_true")
|
|
102
106
|
parser.add_argument('--max_dist_for_adp_restraint', type=float, default=4.)
|
|
103
107
|
parser.add_argument('--adp_restraint_power', type=float)
|
|
104
108
|
parser.add_argument('--adp_restraint_exp_fac', type=float)
|
|
105
109
|
parser.add_argument('--adp_restraint_no_long_range', action='store_true')
|
|
106
110
|
parser.add_argument('--adp_restraint_mode', choices=["diff", "kldiv"], default="diff")
|
|
107
|
-
parser.add_argument('--refine_h', action="store_true", help="Refine hydrogen (default: restraints
|
|
111
|
+
parser.add_argument('--refine_h', action="store_true", help="Refine hydrogen against data (default: only restraints apply)")
|
|
108
112
|
parser.add_argument("--source", choices=["electron", "xray", "neutron"], default="electron")
|
|
109
113
|
parser.add_argument('-o','--output_prefix', default="refined")
|
|
110
114
|
parser.add_argument('--cross_validation', action='store_true',
|
|
@@ -140,7 +144,8 @@ def main(args):
|
|
|
140
144
|
st = utils.fileio.read_structure(args.model)
|
|
141
145
|
try:
|
|
142
146
|
monlib = utils.restraints.load_monomer_library(st, monomer_dir=args.monlib, cif_files=args.ligand,
|
|
143
|
-
stop_for_unknowns=
|
|
147
|
+
stop_for_unknowns=not args.newligand_continue,
|
|
148
|
+
params=params)
|
|
144
149
|
except RuntimeError as e:
|
|
145
150
|
raise SystemExit("Error: {}".format(e))
|
|
146
151
|
if not args.keep_entities:
|
|
@@ -161,7 +166,8 @@ def main(args):
|
|
|
161
166
|
st.spacegroup_hm = hkldata.sg.xhm()
|
|
162
167
|
st.setup_cell_images()
|
|
163
168
|
info = {}
|
|
164
|
-
utils.restraints.find_and_fix_links(st, monlib,
|
|
169
|
+
utils.restraints.find_and_fix_links(st, monlib, find_metal_links=args.find_links,
|
|
170
|
+
add_found=args.find_links)
|
|
165
171
|
else:
|
|
166
172
|
if args.halfmaps:
|
|
167
173
|
maps = utils.fileio.read_halfmaps(args.halfmaps, pixel_size=args.pixel_size)
|
|
@@ -316,6 +322,9 @@ Weight used: {final_weight:.3e}
|
|
|
316
322
|
Open refined model and {diffmap_prefix}.mtz with COOT:
|
|
317
323
|
coot --script {prefix}_coot.py
|
|
318
324
|
|
|
325
|
+
Open refined model, map and difference map with ChimeraX/ISOLDE:
|
|
326
|
+
chimerax {prefix}_chimerax.cxc
|
|
327
|
+
|
|
319
328
|
{map_peaks_msg}
|
|
320
329
|
=============================================================================
|
|
321
330
|
""".format(rmsbond=rmsbond,
|
servalcat/refine/refine_xtal.py
CHANGED
|
@@ -8,15 +8,17 @@ Mozilla Public License, version 2.0; see LICENSE.
|
|
|
8
8
|
from __future__ import absolute_import, division, print_function, generators
|
|
9
9
|
import gemmi
|
|
10
10
|
import numpy
|
|
11
|
+
import pandas
|
|
11
12
|
import os
|
|
12
13
|
import shutil
|
|
13
14
|
import argparse
|
|
14
15
|
from servalcat.utils import logger
|
|
15
16
|
from servalcat import utils
|
|
16
|
-
from servalcat.xtal.sigmaa import decide_mtz_labels, process_input, calculate_maps, calculate_maps_int
|
|
17
|
+
from servalcat.xtal.sigmaa import decide_mtz_labels, process_input, calculate_maps, calculate_maps_int, calculate_maps_twin
|
|
17
18
|
from servalcat.refine.xtal import LL_Xtal
|
|
18
19
|
from servalcat.refine.refine import Geom, Refine
|
|
19
20
|
from servalcat.refmac import refmac_keywords
|
|
21
|
+
from servalcat import ext
|
|
20
22
|
b_to_u = utils.model.b_to_u
|
|
21
23
|
|
|
22
24
|
def add_arguments(parser):
|
|
@@ -35,6 +37,8 @@ def add_arguments(parser):
|
|
|
35
37
|
help="Monomer library path. Default: $CLIBD_MON")
|
|
36
38
|
parser.add_argument('--ligand', nargs="*", action="append",
|
|
37
39
|
help="restraint dictionary cif file(s)")
|
|
40
|
+
parser.add_argument('--newligand_continue', action='store_true',
|
|
41
|
+
help="Make ad-hoc restraints for unknown ligands (not recommended)")
|
|
38
42
|
parser.add_argument('--hydrogen', default="all", choices=["all", "yes", "no"],
|
|
39
43
|
help="all: add riding hydrogen atoms, yes: use hydrogen atoms if present, no: remove hydrogen atoms in input. "
|
|
40
44
|
"Default: %(default)s")
|
|
@@ -76,6 +80,7 @@ def add_arguments(parser):
|
|
|
76
80
|
parser.add_argument('--adp_restraint_mode', choices=["diff", "kldiv"], default="kldiv")
|
|
77
81
|
parser.add_argument('--unrestrained', action='store_true', help="No positional restraints")
|
|
78
82
|
parser.add_argument('--refine_h', action="store_true", help="Refine hydrogen (default: restraints only)")
|
|
83
|
+
parser.add_argument('--twin', action="store_true", help="Turn on twin refinement")
|
|
79
84
|
parser.add_argument("-s", "--source", choices=["electron", "xray", "neutron"], required=True)
|
|
80
85
|
parser.add_argument('--no_solvent', action='store_true',
|
|
81
86
|
help="Do not consider bulk solvent contribution")
|
|
@@ -83,9 +88,12 @@ def add_arguments(parser):
|
|
|
83
88
|
help="Use work reflections in ML parameter estimates")
|
|
84
89
|
parser.add_argument('--keep_charges', action='store_true',
|
|
85
90
|
help="Use scattering factor for charged atoms. Use it with care.")
|
|
91
|
+
parser.add_argument('--allow_unusual_occupancies', action="store_true", help="Allow negative or more than one occupancies")
|
|
86
92
|
parser.add_argument('-o','--output_prefix')
|
|
87
93
|
parser.add_argument("--write_trajectory", action='store_true',
|
|
88
94
|
help="Write all output from cycles")
|
|
95
|
+
parser.add_argument("--vonmises", action='store_true',
|
|
96
|
+
help="Experimental: von Mises type restraint for angles")
|
|
89
97
|
# add_arguments()
|
|
90
98
|
|
|
91
99
|
def parse_args(arg_list):
|
|
@@ -140,7 +148,8 @@ def main(args):
|
|
|
140
148
|
n_per_bin=n_per_bin,
|
|
141
149
|
use=use_in_est,
|
|
142
150
|
max_bins=30,
|
|
143
|
-
keep_charges=args.keep_charges
|
|
151
|
+
keep_charges=args.keep_charges,
|
|
152
|
+
allow_unusual_occupancies=args.allow_unusual_occupancies)
|
|
144
153
|
except RuntimeError as e:
|
|
145
154
|
raise SystemExit("Error: {}".format(e))
|
|
146
155
|
|
|
@@ -159,11 +168,13 @@ def main(args):
|
|
|
159
168
|
else:
|
|
160
169
|
try:
|
|
161
170
|
monlib = utils.restraints.load_monomer_library(st, monomer_dir=args.monlib, cif_files=args.ligand,
|
|
162
|
-
stop_for_unknowns=
|
|
171
|
+
stop_for_unknowns=not args.newligand_continue,
|
|
172
|
+
params=params)
|
|
163
173
|
except RuntimeError as e:
|
|
164
174
|
raise SystemExit("Error: {}".format(e))
|
|
165
175
|
utils.model.setup_entities(st, clear=True, force_subchain_names=True, overwrite_entity_type=True)
|
|
166
|
-
utils.restraints.find_and_fix_links(st, monlib,
|
|
176
|
+
utils.restraints.find_and_fix_links(st, monlib, find_metal_links=args.find_links,
|
|
177
|
+
add_found=args.find_links)
|
|
167
178
|
h_change = {"all":gemmi.HydrogenChange.ReAddKnown,
|
|
168
179
|
"yes":gemmi.HydrogenChange.NoChange,
|
|
169
180
|
"no":gemmi.HydrogenChange.Remove}[args.hydrogen]
|
|
@@ -191,6 +202,7 @@ def main(args):
|
|
|
191
202
|
geom = Geom(st, topo, monlib, shake_rms=args.randomize, adpr_w=args.adpr_weight, params=params,
|
|
192
203
|
unrestrained=args.unrestrained or args.jellyonly, use_nucleus=(args.source=="neutron"),
|
|
193
204
|
ncslist=ncslist)
|
|
205
|
+
geom.geom.angle_von_mises = args.vonmises
|
|
194
206
|
geom.geom.adpr_max_dist = args.max_dist_for_adp_restraint
|
|
195
207
|
if args.adp_restraint_power is not None: geom.geom.adpr_d_power = args.adp_restraint_power
|
|
196
208
|
if args.adp_restraint_exp_fac is not None: geom.geom.adpr_exp_fac = args.adp_restraint_exp_fac
|
|
@@ -201,7 +213,8 @@ def main(args):
|
|
|
201
213
|
if args.jellyonly: geom.geom.ridge_exclude_short_dist = False
|
|
202
214
|
|
|
203
215
|
ll = LL_Xtal(hkldata, centric_and_selections, args.free, st, monlib, source=args.source,
|
|
204
|
-
use_solvent=not args.no_solvent, use_in_est=use_in_est, use_in_target=use_in_target
|
|
216
|
+
use_solvent=not args.no_solvent, use_in_est=use_in_est, use_in_target=use_in_target,
|
|
217
|
+
twin=args.twin)
|
|
205
218
|
refiner = Refine(st, geom, ll=ll,
|
|
206
219
|
refine_xyz=not args.fix_xyz,
|
|
207
220
|
adp_mode=dict(fix=0, iso=1, aniso=2)[args.adp],
|
|
@@ -218,7 +231,11 @@ def main(args):
|
|
|
218
231
|
if params["write_trajectory"]:
|
|
219
232
|
utils.fileio.write_model(refiner.st_traj, args.output_prefix + "_traj", cif=True)
|
|
220
233
|
|
|
221
|
-
if
|
|
234
|
+
if ll.twin_data:
|
|
235
|
+
# replace hkldata
|
|
236
|
+
hkldata = calculate_maps_twin(ll.hkldata, ll.b_aniso, ll.fc_labs, ll.D_labs, ll.twin_data,
|
|
237
|
+
centric_and_selections, use=use_in_target)
|
|
238
|
+
elif is_int:
|
|
222
239
|
calculate_maps_int(ll.hkldata, ll.b_aniso, ll.fc_labs, ll.D_labs, centric_and_selections,
|
|
223
240
|
use=use_in_target)
|
|
224
241
|
else:
|
|
@@ -226,7 +243,9 @@ def main(args):
|
|
|
226
243
|
use=use_in_target)
|
|
227
244
|
|
|
228
245
|
# Write mtz file
|
|
229
|
-
if
|
|
246
|
+
if ll.twin_data:
|
|
247
|
+
labs = ["F_est"]
|
|
248
|
+
elif is_int:
|
|
230
249
|
labs = ["I", "SIGI", "FOM"]
|
|
231
250
|
else:
|
|
232
251
|
labs = ["FP", "SIGFP", "FOM"]
|
|
@@ -239,7 +258,7 @@ def main(args):
|
|
|
239
258
|
labs.append("FREE")
|
|
240
259
|
labs += ll.D_labs + ["S"] # for debugging, for now
|
|
241
260
|
mtz_out = args.output_prefix+".mtz"
|
|
242
|
-
hkldata.write_mtz(mtz_out, labs=labs, types={"FOM": "W", "FP":"F", "SIGFP":"Q", "I":"J", "SIGI":"Q"})
|
|
261
|
+
hkldata.write_mtz(mtz_out, labs=labs, types={"FOM": "W", "FP":"F", "SIGFP":"Q", "I":"J", "SIGI":"Q", "F_est": "F"})
|
|
243
262
|
|
|
244
263
|
# main()
|
|
245
264
|
|
servalcat/refine/spa.py
CHANGED
|
@@ -58,6 +58,9 @@ class LL_SPA:
|
|
|
58
58
|
mott_bethe=self.mott_bethe,
|
|
59
59
|
miller_array=self.hkldata.miller_array())
|
|
60
60
|
|
|
61
|
+
def prepare_target(self):
|
|
62
|
+
pass
|
|
63
|
+
|
|
61
64
|
def overall_scale(self, min_b=0.5):
|
|
62
65
|
k, b = self.hkldata.scale_k_and_b(lab_ref=self.lab_obs, lab_scaled="FC")
|
|
63
66
|
min_b_iso = self.st[0].calculate_b_aniso_range()[0] # actually min of aniso too
|