Command line¶
The cage-vertex-name command converts isomers between site names and
vertex names, and cage-vertex-table tabulates the vertex labels of every
isomer of an ideal cage: cage_isomer_builder.cli. Run either with --help
for every option.
Command-line tools.
cage-vertex-name converts between the site name of an isomer
(0-4-9-13-16-22) and its vertex name (000-100-141-401, see
:mod:cage_isomer_builder.utils.vertex_codes), for names or for isomer
files written by
:meth:~cage_isomer_builder.cage.base.CageBuilder.enumerate_isomers::
cage-vertex-name 0-4-9-13-16-22.xyz # writes 000-100-141-401.xyz
cage-vertex-name 000-100-141-401.xyz # writes 0-4-9-13-16-22.xyz
cage-vertex-name isomers/*.xyz -o by_vertex # a whole folder
cage-vertex-name --ref isomers/0-4-8-12-16-20.xyz 0-4-9-13-16-22 000-100-141-401
With --ref, any isomer file of the cage supplies the vertex scheme and
the names are converted and printed; nothing is written.
cage-vertex-table writes every symmetry-unique isomer of an ideal cage
with its vertex name and labels (see
:mod:cage_isomer_builder.utils.vertex_table)::
cage-vertex-table octahedron -o octahedron.tsv.gz
cage-vertex-table --xyz my_polyhedron.xyz -o table.tsv # vertices from any xyz file
cage-vertex-table icosahedron --count # too many to list: count them
cage-vertex-table icosahedron --environments # exact environment counts, any size
cage-vertex-table icosahedron --sample 1000000 -o ico.tsv # sampled label distribution
cage-vertex-table tetrahedron --groups AB -o tet_ab.tsv # one A and one B per linker
cage-vertex-table octahedron --linker biphenyl --count # eight-site linkers
cage-vertex-table tetrahedron --linker-patterns A:3,:3 # three linkers bare
cage-vertex-table --list
vertex_name_main ¶
The cage-vertex-name command: convert isomer files, or with
--ref isomer names, between site names and vertex names. Returns
the exit status: 0, or 1 if any file or name failed.
Examples:
An isomer file of a toy cage (two vertices joined by two linkers, sites
0-3 and 4-7) with the vertex scheme in its info:
>>> import os, tempfile
>>> from ase import Atoms
>>> from cage_isomer_builder.cli import vertex_name_main
>>> from cage_isomer_builder.utils.sites import write_isomer
>>> from cage_isomer_builder.utils.vertex_codes import VertexScheme
>>> scheme = VertexScheme(((0, 1), (0, 1)), ((0, 1, 2, 3), (4, 5, 6, 7)),
... {0: (0, 1), 1: (0, 4), 2: (1, 1), 3: (1, 4),
... 4: (0, 1), 5: (0, 4), 6: (1, 1), 7: (1, 4)})
>>> atoms = Atoms("H2", positions=[[0, 0, 0], [0, 0, 1]])
>>> atoms.info.update(isomer="1-6", **scheme.to_info())
>>> os.chdir(tempfile.mkdtemp())
>>> _ = write_isomer("1-6.xyz", atoms)
A file named by its sites gets a copy named by its vertex name, and back:
>>> vertex_name_main(["1-6.xyz"])
1-6.xyz -> 40-01.xyz
0
>>> vertex_name_main(["40-01.xyz", "-o", "back"])
40-01.xyz -> back/1-6.xyz
0
With --ref, names are converted either way:
>>> vertex_name_main(["--ref", "1-6.xyz", "0-4", "40-01"])
0-4 -> 11-00 labels 11-00
40-01 -> 1-6 labels 40-10
0
Source code in cage_isomer_builder/cli.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
vertex_table_main ¶
The cage-vertex-table command: the symmetry-unique isomers of an
ideal cage (a named polyhedron, or the vertices in an xyz file) with
their vertex names and labels, written as a table; a summary goes to
standard output. Returns the exit status.
Examples:
>>> import os, tempfile
>>> from cage_isomer_builder.cli import vertex_table_main
>>> os.chdir(tempfile.mkdtemp())
>>> vertex_table_main(["tetrahedron", "-o", "tet.tsv"])
tetrahedron: Td, 4 vertices, 6 linkers, 176 isomers (0 achiral) -> tet.tsv
0
>>> print(open("tet.tsv").read().splitlines()[1])
0-4-8-12-16-20 111-011-001-000 111-110-100-000 444-440-400-000 Y
>>> vertex_table_main(["icosahedron", "--count"])
icosahedron: Ih, 12 vertices, 30 linkers, 9607679214180672 isomers (19215358410465280 counting mirror images apart)
0
Any polyhedron, from the vertex coordinates of an xyz file:
>>> from ase.io import write
>>> from ase import Atoms
>>> write("prism.xyz", Atoms("X6", positions=[[1, 0, 1], [-0.5, 0.866, 1], [-0.5, -0.866, 1],
... [1, 0, -1], [-0.5, 0.866, -1], [-0.5, -0.866, -1]]))
>>> vertex_table_main(["--xyz", "prism.xyz", "--count"])
prism.xyz: D3h, 6 vertices, 9 linkers, 21856 isomers (43712 counting mirror images apart)
0
Cages too big to list: exact environment counts (both hands), and the distribution of label multisets estimated from random placements:
>>> vertex_table_main(["icosahedron", "--environments"])
icosahedron: Ih, 12 vertices, 30 linkers, 9607679214180672 isomers (...)
11111 225179981581120
...
0
>>> vertex_table_main(["octahedron", "--sample", "20000", "-o", "oct_sample.tsv"])
octahedron: Oh, 6 vertices, 12 linkers, 349928 isomers; 20000 samples, 7018 label multisets -> oct_sample.tsv
0
Several groups per linker, several kinds, longer linkers, fixed numbers of linkers per pattern:
>>> vertex_table_main(["tetrahedron", "--groups", "AB", "-o", "tet_ab.tsv"])
tetrahedron: Td, 4 vertices, 6 linkers, 124464 isomers (0 achiral) -> tet_ab.tsv
0
>>> print(open("tet_ab.tsv").read().splitlines()[1])
A-2-6-10-14-18-22_B-3-7-11-15-19-23 00.00.00-AB.00.00-AB.AB.00-AB.AB.AB AB.AB.AB-AB.AB.00-AB.00.00-00.00.00 BA.BA.BA-BA.BA.00-BA.00.00-00.00.00 Y
>>> vertex_table_main(["octahedron", "--linker", "biphenyl", "--count"])
octahedron: Oh, 6 vertices, 12 linkers, 1431678432 isomers (2863345792 counting mirror images apart)
0
>>> vertex_table_main(["tetrahedron", "--linker-patterns", "A:3,:3", "--count"])
tetrahedron: Td, 4 vertices, 6 linkers, 56 isomers (112 counting mirror images apart)
0
Source code in cage_isomer_builder/cli.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |