the methanol molecule in sw format

Relatively short one this time. Just representing a molecule in sw format. Here, methanol, but the idea should generalize to other molecules easily enough. This is just an example representation. There are probably better ones, depending on what you are trying to do.

|context> => |context: methanol>

molecular-pieces |molecule: methanol> => |methanol: 1> + |methanol: 2> + |methanol: 3> + |methanol: 4> + |methanol: 5> + |methanol: 6>

atom-type |methanol: 1> => |atom: H>
bonds-to |methanol: 1> => |methanol: 4>

atom-type |methanol: 2> => |atom: H>
bonds-to |methanol: 2> => |methanol: 4>

atom-type |methanol: 3> => |atom: H>
bonds-to |methanol: 3> => |methanol: 4>

atom-type |methanol: 4> => |atom: C>
bonds-to |methanol: 4> => |methanol: 1> + |methanol: 2> + |methanol: 3> + |methanol: 5>

atom-type |methanol: 5> => |atom: O>
bonds-to |methanol: 5> => |methanol: 4> + |methanol: 6>

atom-type |methanol: 6> => |atom: H>
bonds-to |methanol: 6> => |methanol: 5>
Not much to say, really. I guess a mildly interesting observation is we can auto-count the atom types:
sa: load methanol.sw
sa: atom-type molecular-pieces |molecule: methanol>
4|atom: H> + |atom: C> + |atom: O>
That's it for now!

Update: now with the magic of tables:
sa: load methanol.sw
sa: table[piece,atom-type,bonds-to] molecular-pieces |molecule: methanol>
+-------+-----------+------------+
| piece | atom-type | bonds-to   |
+-------+-----------+------------+
| 1     | H         | 4          |
| 2     | H         | 4          |
| 3     | H         | 4          |
| 4     | C         | 1, 2, 3, 5 |
| 5     | O         | 4, 6       |
| 6     | H         | 5          |
+-------+-----------+------------+
Pretty!


Home
previous: some general people rules
next: the merge labels function

updated: 19/12/2016
by Garry Morrison
email: garry -at- semantic-db.org