1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! A molecule table: its representation, its header, and an unordered set of
//! rows under them.
//!
//! The ordinary rule, not the ranked sibling's exception. The order compounds
//! came off whatever assembled the table is not a fact about the chemistry,
//! so each row is passed to [`Digest::record`](super::Digest::record) and
//! sorted with the rest. For the kind where the order *is* the answer, see
//! [`molecule_ranking`](super::molecule_ranking).
//!
//! # Why the representation is hashed, and why that is not optional
//!
//! A step key is hash(function code, parameters, input content hashes, tool
//! versions). **Dimensions are not in it.** So two tables holding a
//! byte-identical InChIKey column and differing only in what was done to
//! produce it would have the same content hash, and the cache would serve
//! one when the pipeline asked for the other — in silence, which is the one
//! failure semantic hashing exists to be incapable of.
//!
//! Twelve of thirty ordinary drugs change key under a different
//! standardisation, so this is not a corner. Everywhere else in this module
//! a field is hashed because it is part of what a file says; here it is
//! hashed because leaving it out would be a correctness bug.
//!
//! # Nothing is dropped
//!
//! The other leading `#` lines are hashed too, in order, as somebody's own
//! words about their own file. A canonicaliser that dropped them would make
//! two files that differ compare equal, and there is no volatile set to
//! appeal to here: unlike a served JSON document, a table nobody fetched
//! carries no serving system's signature.
//!
//! # Why this checks the identity column where `entity_set` does not
//!
//! [`entity_set`](super::entity_set) deliberately does not check which
//! column holds the identifiers, because it is not told: a canonical form is
//! computed from a path and a kind, and the identifier column is a loader
//! argument. Here the column's name is fixed by the kind — `inchikey`, or
//! `smiles` — so this *can* check, and therefore must. Without the check any
//! one-column text file parses as a molecule table and hashes as the
//! canonical form of something it is not, which is the opposite of the
//! conservative direction [`super::hash`] takes everywhere else. A JSON
//! document is one such file: every line is a row of one field.
use BufRead;
use Path;
use Digest;
use crateIdentity;
use crate;
/// A molecule table being read, and the comment lines above it.
///
/// A named type because the two canonical forms share the reader and clippy
/// is right that the tuple is a mouthful.
type Opened = ;
/// Hash a molecule table's canonical form, rows unordered.
pub
/// Open a molecule table and read past its comment block.
///
/// Shared with [`molecule_ranking`](super::molecule_ranking), because the
/// two kinds must agree about where the header starts and what the
/// representation says. They differ in one call, and this is not it.
pub
/// The parts of a molecule table that are fields rather than records.
///
/// The representation first and by itself, so that a reader of the hash
/// stream sees the dimension being hashed rather than finding it inside a
/// block of comments.
pub