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

Add showing of model connectivity #996

Merged
merged 15 commits into from
Dec 12, 2019
Merged

Add showing of model connectivity #996

merged 15 commits into from
Dec 12, 2019

Conversation

graeme-winter
Copy link
Contributor

Shows how models are related to experiments e.g.

Experiment / Models

Detector:
              0  1
Experiment 0  X  /
Experiment 1  X  /
Experiment 2  X  /
Experiment 3  /  X

Crystal:
              0  1  2  3
Experiment 0  X  /  /  /
Experiment 1  /  X  /  /
Experiment 2  /  /  X  /
Experiment 3  /  /  /  X

Beam:
              0
Experiment 0  X
Experiment 1  X
Experiment 2  X
Experiment 3  X

Seemed useful to me... make an option?

@graeme-winter
Copy link
Contributor Author

N.B. allows clearer view of what options do e.g. with and without split_experiments in dials.index

Experiment / Models

Detector:
              0  1  2  3
Experiment 0  X  /  /  /
Experiment 1  /  X  /  /
Experiment 2  /  /  X  /
Experiment 3  /  /  /  X

Crystal:
              0  1  2  3
Experiment 0  X  /  /  /
Experiment 1  /  X  /  /
Experiment 2  /  /  X  /
Experiment 3  /  /  /  X

Beam:
              0  1  2  3
Experiment 0  X  /  /  /
Experiment 1  /  X  /  /
Experiment 2  /  /  X  /
Experiment 3  /  /  /  X

vs.

Experiment / Models

Detector:
              0  1
Experiment 0  X  /
Experiment 1  X  /
Experiment 2  X  /
Experiment 3  /  X

Crystal:
              0
Experiment 0  X
Experiment 1  X
Experiment 2  X
Experiment 3  X

Beam:
              0
Experiment 0  X
Experiment 1  X
Experiment 2  X
Experiment 3  X

@graeme-winter
Copy link
Contributor Author

Does not show anything if len(experiments) == 1 as obviously the connectivity is trivial.

Should we have a limit for e.g. > 20 experiments or something? Can see this being useful for indexing > 1 lattice across > 1 sweep though.

Also welcome bikeshedding on X vs. / etc. - what are better symbols? - should we have --- and | to make ersatz ASCII art table? If you feel yes, please feel free to add 😉

Copy link
Contributor

@rjgildea rjgildea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a useful addition, but at a risk of making the output of dials.show even more verbose than it already is (especially for multiple experiments, which is the intended use case of this PR). Perhaps it would be worth adding an option to switch it on/off (no strong opinion on the default)?
Could we add a test for this new output? I'm not sure that we have a multi-experiment test case for dials.show - probably a gap in the existing test coverage.

text.append("")
text.append("Detector:")
text.append(" " + " ".join([str(j) for j in range(len(detectors))]))
for j, e in enumerate(experiments):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to use e.g. tabulate here instead of manually formatting the tables. We already use tabulate in xia2, so it should be available in a dials installation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know about tabulate however sounds like a good thing so 100% on board.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you end up using dependencies in dials please add them explicitly to dials (ie. libtbx_config) even if they are already available indirectly

command_line/show.py Outdated Show resolved Hide resolved
@@ -209,6 +209,8 @@ def run(args):
)
)

print(show_connectivity(experiments))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly a comment on this review, but a reminder that we should probably convert dials.show to use logging instead of print.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

text.append("Detector:")
text.append(" " + " ".join([str(j) for j in range(len(detectors))]))
for j, e in enumerate(experiments):
tmp = ["Experiment %d" % j]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect if j >= 10 then it would mess up the table alignment - using tabulate should alleviate this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

@graeme-winter
Copy link
Contributor Author

Test case data added to #995

@graeme-winter
Copy link
Contributor Author

Added show_experiment_has_model bool param.

Re: tabulate; no idea; not learning but would very much welcome someone else dropping this in there modulo comments made by @Anthchirp re: dependencies

@dagewa
Copy link
Member

dagewa commented Nov 4, 2019

tabulate looks interesting, but we have lots of uses of simple_table in the codebase at the moment. If we are going to include tabulate I suggest it is done outside this PR while converting the existing simple_tables for consistency.

@@ -26,6 +27,9 @@
show_scan_varying = False
.type = bool
.help = "Whether or not to show the crystal at each scan point."
show_experiment_has_model = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this would be a better parameter (and relevant function) name?

Suggested change
show_experiment_has_model = False
show_model_connectivity = False

@graeme-winter
Copy link
Contributor Author

Am happy for anyone to take this one forward to close off :)

@rjgildea rjgildea self-requested a review November 4, 2019 15:28
expt = location.join("indexed.expt").strpath
result = procrunner.run(["dials.show", expt, "show_model_connectivity=True"])
assert not result.returncode and not result.stderr
assert "Experiment / Models" in result.stdout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert "Experiment / Models" in result.stdout
assert b"Experiment / Models" in result.stdout

if getattr(e, model) is m:
row.append("X")
else:
row.append("/")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
row.append("/")
row.append(".")

my :bikeshed: contribution.

Call command line run() function directly instead of using procrunner.run().
X -> x
/ -> .
@rjgildea
Copy link
Contributor

rjgildea commented Nov 7, 2019

@graeme-winter I think dials.find_shared_models is relevant to this (although it doesn't appear to be tested) - perhaps given that similar functionality exists elsewhere then this PR is not needed?

$ dials.find_shared_models $(dials.data get -q l_cysteine_dials_output)/indexed.expt
DIALS (2018) Acta Cryst. D74, 85-97. https://doi.org/10.1107/S2059798317017235
DIALS 2.dev.1067-g89d664ba9
The following parameters have been modified:

input {
  experiments = /Users/rjgildea/software/cctbx/build/dials_data/l_cysteine_dials_output/indexed.expt
}

Number of sequences = 4
Sorting sequences based on timestamp
4 datasets collected on 2016-03-05
=====================================================  ====  ======  ==========  ============  ==========  ========
Sequence                                                 ID    Beam    Detector    Goniometer  Date        Time
=====================================================  ====  ======  ==========  ============  ==========  ========
/Users/graeme/data/i19-1-l-cys/l-cyst_04_#####.cbf.gz     0       0           0             0  2016-03-05  08:58:02
/Users/graeme/data/i19-1-l-cys/l-cyst_01_#####.cbf.gz     1       0           1             1  2016-03-05  09:01:45
/Users/graeme/data/i19-1-l-cys/l-cyst_02_#####.cbf.gz     2       0           1             2  2016-03-05  09:04:57
/Users/graeme/data/i19-1-l-cys/l-cyst_03_#####.cbf.gz     3       0           1             3  2016-03-05  09:08:09
=====================================================  ====  ======  ==========  ============  ==========  ========

@dagewa
Copy link
Member

dagewa commented Dec 1, 2019

I think dials.show is a good home for this, but I prefer show_shared_models as a parameter name over show_model_connectivity Perhaps the behaviour of dials.find_shared_models and this PR can be merged, and dials.find_shared_models then retired?

@graeme-winter
Copy link
Contributor Author

@dagewa show_shared_models - fine with this - I'll try to get this cleaned up though looks like we've acquired some conflicts along the way.

@graeme-winter graeme-winter mentioned this pull request Dec 3, 2019
@Anthchirp Anthchirp added this to the DIALS 2.1 milestone Dec 4, 2019
@rjgildea
Copy link
Contributor

@graeme-winter any comment on #996 (comment)? It seems that this essentially does the same thing as this PR, albeit in a different form. If this PR is merged, then I suggest that dials.find_shared_models should be removed as it is then duplicate (and untested) functionality.

@Anthchirp
Copy link
Member

I will spin that out as a separate issue to follow up at some point in the indefinite future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants