FragSelector
Fragment selector with a 2D diagram and the 3D structure side by side. Pick atoms in either panel; both views, the index lists and the copy buttons stay in sync.
See the Fragment Selector example for a walkthrough.
CLI
aseview molecule.xyz -v frag
aseview molecule.xyz -v frag --bond-threshold 1.4
aseview molecule.xyz -v frag -o selector.html
frag is never chosen automatically; pass -v frag. With a multi-frame file
only the first frame is used.
Constructor
| Parameter | Type | Description | Default |
|---|---|---|---|
data |
Atoms, str, ... |
One structure (anything MolecularViewer accepts; only the first frame is used) | Required |
selected |
list[int] |
Atom indices selected initially | None |
theme |
str |
Viewer theme; None uses get_theme() |
None |
**settings |
Viewer settings, e.g. bond_threshold, style, hide_hydrogens, copy_format |
copy_format (xyz, extxyz, cif, vasp-poscar) is the format of the copy
buttons. extxyz and POSCAR keep the cell and fixed/move-mask constraints;
cif keeps the cell but has no constraint field.
Methods
show(), get_html(), save_html() and save_png() work as in
MolecularViewer.
In the viewer
Tools
| Tool | Key | 2D panel | 3D panel |
|---|---|---|---|
| Navigate | N | Drag pans, wheel zooms, double-click refits | Drag rotates, right-drag pans, wheel zooms |
| Click | C | Click an atom to toggle it | Click an atom to toggle it (drag still rotates) |
| Rect | R | Drag a rectangle | Drag a rectangle over the projected atoms |
| Lasso | L | Draw a free-form region | Draw a free-form region |
Hold Shift while releasing to add to the selection instead of replacing it. In the grid layout, rectangle and lasso use the panel you drag in.
2D diagram
The layout is computed from the 3D coordinates: bonds from covalent radii, connected components separated, each projected with PCA and refined with a force-directed pass, bond lengths normalised, and fragments placed left to right, largest first. Bond halves take their atom's color.
Selection panel
| Control | Description |
|---|---|
| Selected / Unselected | Live [i, j, ...] index lists with counts and copy buttons |
| All / Clear / Invert | Change the whole selection |
| Expand H | Add hydrogens bonded to selected atoms |
| Copy by fragment | Selected and unselected atoms as separate frames in copy_format |
| Copy reindexed | One structure with the selected atoms first |