openmolecules.org

 
Home » DataWarrior » Functionality » export jpg/png file from SDF file with datawarrior from command line (Used in Linux)
export jpg/png file from SDF file with datawarrior from command line [message #591] Tue, 09 July 2019 08:13 Go to next message
dongkeke is currently offline  dongkeke
Messages: 7
Registered: June 2019
Location: 中国
Junior Member

I often have to find the rules from images from 2D or 3D view in SDF files, it is troublesome to open each SDF file and save images as PNG file. It would be nice to have Datawarrior operate from the command line to export all images form each SDF file in Linux.

Dong_Keke
Re: export jpg/png file from SDF file with datawarrior from command line [message #594 is a reply to message #591] Tue, 09 July 2019 13:57 Go to previous messageGo to next message
thomas is currently offline  thomas
Messages: 646
Registered: June 2014
Senior Member
I suggest that you create a macro file that opens your sd-file with a predefined name, creates and saves the image from the view and then closes the datawarrior application. You may then run this macro from the command line with:
/opt/datawarrior/datawarrior testmacro.dwam

This would launch DataWarrior, open the ds-file, save the view, and exit DataWarrior.

Thomas
Re: export jpg/png file from SDF file with datawarrior from command line [message #596 is a reply to message #594] Tue, 09 July 2019 16:13 Go to previous message
nbehrnd is currently offline  nbehrnd
Messages: 204
Registered: June 2019
Senior Member
If your aim is to generate a visual survey about the constitution of the molecules deposit
in your .sdf, and assuming each .sdf contains only one model, I would first concatenate
the .sdf into one "container" with openbabel. Put them into one folder in common, enter
this depot via the CLI, and launch

obabel *.sdf -O container.sdf -d

To optional parameter "-d" will cause openbabel to strip-off all hydrogens except the ones
bound to either a hetero atom or on a terminal C. This simplifies the visual output quite
a bit.

Request then openbabel to access this poly-model container.sdf a twice, to create a vignette
about each molecule, put into a box of an array of all. You choose either a bitmapped .png,
or a vectorized .svg as output. The minimal instruction indicates input file type and file
name, and name of the output to be written (name including the file extension), e.g.

obabel -isdf container.sdf -O array.svg

There are optional paramers to adjust the formatting (e.g., number of columns, number of rows;
a grid, an integer counter next to the structure's original file name about the entry of the
model in the .sdf accessed).

Openabel's Dreiding-like colouring of heteroatoms may be good for a display on screen. This
however may be a potential pitfall if the structures are big (consequently, represented at low
scale) and print on paper. This is especially true for explict H bound to heteroatoms, Si, F,
Cl, S, Se; to lesser extent for O and N. You may request openbabel to use black ink only by
"-xu" (without quotation marks). Advantageously, the resolution independent crisp .svg may be
postprocessed further (cairosvg, inkscape, etc).

A recent example is https://github.com/nbehrnd/saturated_Murcko_scaffold

  • Attachment: example.png
    (Size: 12.91KB, Downloaded 415 times)
Previous Topic: Racemates showing as chiral
Next Topic: Retrieve Data from SQL database
Goto Forum:
  


Current Time: Fri Mar 29 08:40:03 CET 2024

Total time taken to generate the page: 0.07971 seconds