| 1 |
""" |
| 2 |
Generate a grown (complete molecule) .res file from tests/resources/p-31c.res |
| 3 |
and write it to ./test_grow.res. |
| 4 |
|
| 5 |
The script calls :meth:`Shelxfile.write_grown_file` which: |
| 6 |
1. Reads p-31c.res with ShelXFile. |
| 7 |
2. Calls shx.grow() to complete the molecular fragments using crystal symmetry. |
| 8 |
3. Changes the space group to P1 (LATT -1, no SYMM cards) so that SHELXL / |
| 9 |
fastmolwidget does not re-apply symmetry to the already-grown atoms. |
| 10 |
4. Preserves disorder parts (PART cards) so the bond graph has no wrong bonds. |
| 11 |
5. Adds a REM warning that the file is not suited for refinement. |
| 12 |
6. Writes the result to ./test_grow.res. |
| 13 |
""" |
| 14 |
|
| 15 |
from pathlib import Path |
| 16 |
from shelxfile import Shelxfile |
| 17 |
|
| 18 |
──────────────────────────────────────── |
| 19 |
shx = Shelxfile(verbose=True) |
| 20 |
shx.read_file('tests/resources/p-31c.res') |
| 21 |
|
| 22 |
print(f"Asymmetric unit: {shx.atoms.number} atoms " |
| 23 |
f"({len(shx.atoms.q_peaks)} Q-peaks)") |
| 24 |
|
| 25 |
──────────────────────────────────────── |
| 26 |
out = Path('./test_grow.res') |
| 27 |
shx.write_grown_file(out) |
| 28 |
|
| 29 |
|
| 30 |
atom_lines = [ |
| 31 |
line for line in out.read_text().splitlines() |
| 32 |
if Shelxfile.is_atom(line) |
| 33 |
] |
| 34 |
print(f"\nOutput written to: {out.resolve()}") |
| 35 |
print(f"Atom lines in output: {len(atom_lines)}") |
| 36 |
print(f"\nFirst 5 atom lines:") |
| 37 |
for line in atom_lines[:5]: |
| 38 |
print(" ", line.rstrip()) |
| 39 |
print(f"\nLast 5 atom lines:") |
| 40 |
for line in atom_lines[-5:]: |
| 41 |
print(" ", line.rstrip()) |