Images for a Whole Directory

one more question is there a xyz file viewer something that would display a picture of all of my xyz files in a folder.

There are some Mac tools for creating thumbnails / preview images. I should revisit including ChemSpotlight in Avogadro sometime.

But in the latest 1.98 nightly builds I added a Python method to load a bunch of files and save PNG images because it was useful for a research project.

  • Launch Avogadro2 (latest nightly builds)
  • Run the script in a directory of .xyz files
  • It will load the files one-by-one into Avogadro and save a PNG image

Suggestions welcome…

@GeOFF Assuming you already have an installation of openbabel, a call in pattern of

obabel *.xyz -O survey.svg -xc 5 -xl -d

writes a svg file you can scale/zoom for a display in a web browser like Firefox. Or display in inkview one can start from the CLI (at least in Linux Debian) if there is an installation of inkscape. The instruction compiles all .xyz models into one .svg in common. Then, format options modify the output to use 5 columns separated by grid lines. By -d, the hydrogens’ representation is less verbose/explicit. Below each structure’s model, the name of the corresponding file read is displayed.

Tangential (as .sdf files’ organization differs from .xyz, and constrained to the Windows operating system), thumbfish is a helpful addition to the file browser. The program is open source (C++) with a repository on GitHub.
If there is a meaningful description of the structures in xyz by SMILES strings (i.e., mirrored by file structure01.smi) and the computer used already includes Python, RDKit, and eog, then smi2png allows you to flip through the folder’s content accessing the later/smi files.

@ghutchis For a quick survey of a folder’s content, could one have an optional display without some of the hydrogens?

This does not intend to replace the approach displayed here. However, with growing structural complexity of the molecule displayed and because the depiction is static, I assume dropping hydrogens around phenyl groups, methylene units etc would be an omission to improve clarity in a picture used only to decide “not what I look for” / “the structure I would like to work on”. Removing all hydrogen atoms (an option in CCDC’s mercury) could be too much, retaining H’s on hetero atoms and terminal C (methyl group, acetylene) possibly is a compromise.

As I brought up last summer (Tasks for Automation) the intent is certainly to have a set of scriptable commands.

Basically, you want something like:

from avogadro import sendMessage

for filename in glob.glob(*.xyz):
        path = cwd + "/" + filename
        sendMessage("openFile", path)
        sendMessage("selectElement", 1)
        sendMessage("showSelectedAtoms", False)
        sendMessage("saveGraphic", path[:-4] + ".png")

And yes, your point would be to select for example based on a SMARTS pattern.