Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New screen19 pipeline #61

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d9639a8
Raze the old stuff
benjaminhwilliams Oct 26, 2022
f78a02d
Raze the old entry points
benjaminhwilliams Oct 26, 2022
8038d10
Set up Azure Pipelines CI (maybe?)
benjaminhwilliams Oct 26, 2022
cd951e8
Set up basic scripts and tests
benjaminhwilliams Oct 26, 2022
6a7db0b
Setuptools nonsense...
benjaminhwilliams Oct 26, 2022
b86ba39
More setuptools nonsense...
benjaminhwilliams Oct 26, 2022
20d8a90
Even more setuptools stuff ...
noemifrisina Oct 26, 2022
9f2f58d
Get correct versioning from setup.cfg
noemifrisina Oct 26, 2022
08b612f
update pre-commit to 3.8
noemifrisina Oct 31, 2022
4e1d345
Add missing bits for basic script to run. Exchange procrunner with su…
noemifrisina Oct 31, 2022
0ef17be
Correct logging levels
benjaminhwilliams Oct 31, 2022
961a61b
Avoid pytest error with argparse
noemifrisina Oct 31, 2022
6194b8a
Remove the last tristan bits from packaging
noemifrisina Oct 31, 2022
e0a3664
Add requirements file
noemifrisina Oct 31, 2022
de4baf7
Correct logging levels, properly this time
benjaminhwilliams Oct 31, 2022
2d9f569
Add libtbx dispatcher
noemifrisina Nov 18, 2022
97877fb
Get dials.import to work
noemifrisina Nov 21, 2022
e45809e
Add basic find_spots and indexing
noemifrisina Nov 21, 2022
f26d5c1
Fill in pipeline - TBC
noemifrisina Nov 21, 2022
16f867a
Add version parser, and a slightly working show_config
noemifrisina Nov 21, 2022
aa341e4
Hopefully fix imports
noemifrisina Dec 9, 2022
5a20862
Get correct scopes
noemifrisina Dec 9, 2022
ed2e3f6
Try different scope path
noemifrisina Dec 9, 2022
0187d8a
Ugly scope workaround
noemifrisina Dec 9, 2022
aa6b62d
Update parser to accept also image range as input eg. file_00.cbf:0:10
noemifrisina Dec 9, 2022
b935dfc
Workaround for additional options in dials pipeline
noemifrisina Dec 12, 2022
6175996
Fix the names
noemifrisina Dec 12, 2022
01a81a2
Get minimum exposure to run - at least for integration
noemifrisina Dec 12, 2022
ef9d52d
Add some HOWTO info
noemifrisina Dec 12, 2022
1269ba7
Get minimum exposure to work correctly for indexing
noemifrisina Dec 12, 2022
ead2b2d
Parser workaround for minimum exposure
noemifrisina Dec 12, 2022
c9cd714
Tidy up help essage
noemifrisina Dec 15, 2022
00d9b9f
Start setting up logging in screen script
noemifrisina Dec 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add some HOWTO info
  • Loading branch information
noemifrisina committed Dec 12, 2022
commit ef9d52d485c6e8a9bf4fcbdadfaefe421b785bb0
12 changes: 8 additions & 4 deletions src/screen/inputs.py
Original file line number Diff line number Diff line change
@@ -43,22 +43,26 @@
type=str,
default=[],
nargs="*",
help="Additional options for spot finding.",
help="Additional options for dials.find_spots.",
)
options_parser.add_argument(
"--index", type=str, default=[], nargs="*", help="Additional options for indexing."
"--index",
type=str,
default=[],
nargs="*",
help="Additional options for dials.index.",
)
options_parser.add_argument(
"--refine",
type=str,
default=[],
nargs="*",
help="Additional options for refinement.",
help="Additional options for dials.refine.",
)
options_parser.add_argument(
"--integrate",
type=str,
default=[],
nargs="*",
help="Additional options for integration.",
help="Additional options for dials.integrate.",
)
31 changes: 15 additions & 16 deletions src/screen/minimum_exposure.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
Perform straight-line Wilson plot fit. Draw the Wilson plot.
"""

from __future__ import annotations

help_message = """
Reflection d-spacings are determined from the crystal symmetry (from
indexing) and the Miller indices of the indexed reflections. The
@@ -40,7 +42,7 @@
import logging
import sys
from io import StringIO
from typing import Iterable, Optional, Sequence, Union
from typing import Iterable, Sequence, Union

import numpy as np
from scipy.optimize import curve_fit
@@ -51,12 +53,9 @@

from dials.array_family import flex
from dials.util import log

# from dials.util.options import ArgumentParser # OptionParser deprecated anyway
# from dials.util.version import dials_version
from dxtbx.model import ExperimentList

from screen import ( # FIXME TODO change to relative import; __version__,
from screen import ( # FIXME TODO change to relative import
config_parser,
d_ticks,
plot_intensities,
@@ -73,14 +72,6 @@

phil_scope = libtbx.phil.parse(
"""
verbosity = 0
.type = int(value_min=0)
.help = "Verbosity level of log output. Possible values:\n"
"\t• 0: Info log output to stdout/logfile\n"
"\t• 1: Info log output to stdout/logfile, logfile contains timing"
"information\n"
"\t• 2: Info & debug log output to stdout/logfile, logfile contains"
"timing information"
minimum_exposure
.caption = 'Parameters for the calculation of the lower exposure bound'
{
@@ -103,6 +94,14 @@
'ignored for the purposes of the Wilson plot.'
}
output {
verbosity = 0
.type = int(value_min=0)
.help = "Verbosity level of log output. Possible values:\n"
"\t• 0: Info log output to stdout/logfile\n"
"\t• 1: Info log output to stdout/logfile, logfile contains timing"
"information\n"
"\t• 2: Info & debug log output to stdout/logfile, logfile contains"
"timing information"
log = 'screen19.minimum_exposure.log'
.type = str
.help = 'Location for the info log'
@@ -180,7 +179,7 @@ def wilson_fit(


def wilson_plot_ascii(
miller_array: miller.array, d_ticks: Optional[Sequence] = None
miller_array: miller.array, d_ticks: Sequence | None = None
) -> None:
"""
Print an ASCII-art Wilson plot of reflection intensities.
@@ -221,8 +220,8 @@ def wilson_plot_image(
d_star_sq: FloatSequence,
intensity: FloatSequence,
fit: Fit,
max_d: Optional[float] = None,
ticks: Optional[FloatSequence] = None,
max_d: float | None = None,
ticks: FloatSequence | None = None,
output: str = "wilson_plot",
) -> None:
"""
60 changes: 52 additions & 8 deletions src/screen/screen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
"""The main screening script."""
"""Pipeline to process screening data obtained at Diamond Light Source Beamline I19."""

from __future__ import annotations

help_message = """
This program presents the user with recommendations for adjustments to beam
flux, based on a single-sweep screening data collection. It presents an
upper- and lower-bound estimate of suitable flux.\n
• The upper-bound estimate is based on a comparison of a histogram of
measured pixel intensities with the trusted intensity range of the detector.
The user is warned when the measured pixel intensities indicate that the
detector would have a significant number of overloaded or untrustworthy
pixels.\n
• The lower-bound estimate is based on a linear fit of isotropic disorder
parameter, B, to a Wilson plot of reflection intensities. From this, an estimate
is made of the minimum exposure (flux × exposure time) required to achieve a target
I/σ ratio (by default, target I/σ = 2) at one or more values of desired resolution, d,
(by default, desired d = 1 Å, 0.84 Å, 0.6 Å & 0.4 Å).\n
\n
Target I/σ and target d (in Ångström) can be set using the parameters
'min_i_over_sigma' and 'desired_d'. One can set multiple values of the latter.\n
\n
By default the disorder parameter fit is conducted on the integrated data.
This ought to provide a reasonably true fit, but requires an integration step,
which can take some time. You can achieve a quicker, dirtier answer by fitting
to the indexed data (i.e. only the stronger spots), using 'minimum_exposure.data=indexed'.\n
\n
Examples:\n

screen19 *.cbf\n

screen19 /path/to/data/\n

screen19 /path/to/data/image0001.cbf:1:100\n

screen19 min_i_over_sigma=2 desired_d=0.84 <imported_experiments.json | image_files>\n

screen19 minimum_exposure.data=indexed <image_files>\n
"""

import argparse
import re
import subprocess
@@ -30,7 +67,6 @@
"""
verbosity = 0
.type = int(value_min=0)
.multiple = True
.help = "Verbosity level of log output. Possible values:\n"
"\t• 0: Info log output to stdout/logfile\n"
"\t• 1: Info log output to stdout/logfile, logfile contains timing"
@@ -96,8 +132,14 @@ def find_import_arguments(
return in_value.as_posix(), None, None, None


usage = "%(prog)s [options] /path/to/data"

parser = argparse.ArgumentParser(
description=__doc__, parents=[version_parser, config_parser, options_parser]
usage=usage,
formatter_class=argparse.RawTextHelpFormatter,
description=__doc__,
epilog=help_message,
parents=[version_parser, config_parser, options_parser],
)
parser.add_argument(
"experiments",
@@ -119,7 +161,7 @@ def find_import_arguments(
)


def run_import(images, params: ScopeExtract):
def run_import(images: list | str | None, params: ScopeExtract):
# Ugly, but works
import_params = import_scope.format(python_object=params)

@@ -175,9 +217,10 @@ def run_integrate(params: ScopeExtract, options: list = []):
)


def run_minimum_exposure(choice):
def run_minimum_exposure(params, choice):
if choice == "indexed":
# subprocess.run
print(params.__dict__)
pass
else:
subprocess.run(
@@ -195,8 +238,9 @@ def pipeline(args: argparse.Namespace, working_phil: Scope):
args.image_range if args.image_range else None
)

print(params.minimum_exposure.desired_d) # SIGH
# print(params.minimum_exposure.desired_d) # SIGH

# This probably makes the include scope in phil_scope a bit redundant... 2 choices to do this I guess?
spot_finding_options = args.find_spots
indexing_options = args.index
refinement_options = args.refine
@@ -209,9 +253,9 @@ def pipeline(args: argparse.Namespace, working_phil: Scope):
if args.data == "integrated":
run_refine(params.dials_refine, refinement_options)
run_integrate(params.dials_integrate, integration_options)
run_minimum_exposure(args.data)
run_minimum_exposure(params.minimum_exposure, args.data)
else:
run_minimum_exposure(args.data)
run_minimum_exposure(params.minimum_exposure, args.data)


def main(args=None):