3
$\begingroup$

I am trying to render few representative structures for molecules. The requirement for the images is as follows: (1) It must be vector graphics, and (2) Atom colorings must intuitively make sense (like carbon atom being gray and nitrogen atom being blue). I have tried Chimera and Avogadro for this purpose. The last time I tried Chimera, I found that C atoms are colored in a off-white to brownish shade, which is the color that I am looking for. For Avogadro2, I have no means to export the image to an SVG or PDF file. I know that the Linux and Mac Installations for Avogadro2 supports exporting graphics to SVG and PDF files, which the Windows installation seems to be lacking. For Avogadro1, I cannot even install it on my Windows11 PC, due to MSVCP100.dll file missing error. If you know any free softwares that can do this, It would be helpful.

$\endgroup$
4
  • $\begingroup$ Can you clarify what the illustrations shall depict: atom connectivity (as in a sketcher like ChemDraw), or 3D structures (perhaps with computed surfaces such as HOMO/LUMO/some molecular orbital)? The answer equally may depend on the file format describing your structures (e.g. Platon, as in reports by checkcif/platon, for example exports structures provided as .cif to colour .ps/.pdf). $\endgroup$
    – Buttonwood
    Commented Sep 13, 2023 at 5:05
  • $\begingroup$ I want to depict the 3D structures of the molecules. $\endgroup$ Commented Sep 13, 2023 at 5:11
  • $\begingroup$ And the file format to describe the structure in first place is .xyz, .cif, .sdf, ..., or a result log file of a computation with MOPAC, Gaussian, ...? $\endgroup$
    – Buttonwood
    Commented Sep 13, 2023 at 5:16
  • $\begingroup$ It will be .sdf or.xyz $\endgroup$ Commented Sep 13, 2023 at 5:17

1 Answer 1

4
$\begingroup$

There are some issues with the "Atom coloring must intuitively". First, how can we think of an intuitive color for an atom? Second, each program has different color schemes that can be used depending on the application.

I like to use Jmol software. It is open-source and available for Linux, Mac OS X and Windows. It is translated into several languages, supports many file formats for structures and properties, and can be used via script in batch conversion jobs.

In particular, it has the following color schemes:

  • CPK colors
  • CPKnew (only to Rasmol v. 2.7.3 (or later))
  • Residues: amino acids, nucleotides
  • Chains
  • Secondary structure
  • Position along chain
  • Positional Variability

Also, it includes these palettes:

  • JavaScript colors
  • Netscape 8 bit color palette

Below is a script that I use (in my Ubuntu box) to create high definition PNG and PDF images. It uses Jmol, PovRay and img2pdf.

#!/bin/sh
# Script to create PNG image from the XYZ structure files using Jmol
# at specific frames

cat > par.ini <<!
; POV-Ray configuration file example

; common options
+SP8 ; start with every 8th pixel
+Q8 ; quality is high
+A0.3 ; anti aliasing
-P ; pause after rendering
-D ;

[lo] ; options in section ‘[lo]’
+W150 ; lo res image width
+H100 ; lo res image height

[hi] ; another section
+W732 ; hi res image width
+H616 ; hi res image height

[Big] ;
Width=2196 ;
Height=1848 ;
Antialias=On ;
Antialias_Threshold=0.3 ;
!

for file in *.xyz; do
    extension="${file##*.}"
    filename="${file%.*}"
    fig_file_t000=fig_"$filename"_t000
    fig_file_t025=fig_"$filename"_t025
    fig_file_t050=fig_"$filename"_t050
    fig_file_t075=fig_"$filename"_t075
    fig_file_t100=fig_"$filename"_t100
cat > $filename.jmol <<!
zap
load $file;
background white; frank off; #set ambient 10; set diffuse 60; set specular 70
N=1; frame @N; t=@N/10; write POVRAY $fig_file_t000.pov
N=500; frame @N; t=@N/10; write POVRAY $fig_file_t025.pov
N=1000; frame @N; t=@N/10; write POVRAY $fig_file_t050.pov
N=1500; frame @N; t=@N/10; write POVRAY $fig_file_t075.pov
N=2000; frame @N; t=@N/10; write POVRAY $fig_file_t100.pov
!

jmol -L -n -s $filename.jmol
povray par[Big] -I$fig_file_t000.pov -O$fig_file_t000.png
povray par[Big] -I$fig_file_t025.pov -O$fig_file_t025.png
povray par[Big] -I$fig_file_t050.pov -O$fig_file_t050.png
povray par[Big] -I$fig_file_t075.pov -O$fig_file_t075.png
povray par[Big] -I$fig_file_t100.pov -O$fig_file_t100.png
done

rm -f *.jmol
image2pdf.sh png

The second script, image2pdf, do a batch conversion of all files to PDF:

#!/bin/sh
# Use ./image2pdf image_extension (jpg, png, tga, etc.)
# Trim image 
# Convert to PDF

if [ -z $1 ]
then
    echo "Run as: image2pdf image_format"
else
mogrify -trim *.$1
for file in *.$1; do
  extension="${file##*.}"
  filename="${file%.*}"
  img2pdf --output $filename.pdf --border 2mm:2mm --imgsize 300dpi $file
done
fi
$\endgroup$
5
  • $\begingroup$ Unfortunately that's produces a raster output,not a vector output. $\endgroup$
    – JCRM
    Commented Sep 13, 2023 at 9:02
  • $\begingroup$ Isn't PDF a vector image format? Also, after creating, for example PNG with high resolution, you can convert it to EPS, SVG, etc. $\endgroup$
    – Camps
    Commented Sep 13, 2023 at 12:44
  • $\begingroup$ The PDF, EPS, or SVG produced in this way will contain a bitmap, not a vector representation. $\endgroup$
    – JCRM
    Commented Sep 13, 2023 at 14:36
  • 1
    $\begingroup$ @Camps If you take a PNG image and convert it to a vector format like pdf or eps, it basically just wraps up the bitmap data into an array and still can only render it pixel by pixel. It really depends on what OP wants, and most of the times a journal only check if the image format is a vector format like pdf or eps. $\endgroup$
    – Shaun Han
    Commented Sep 18, 2023 at 16:17
  • $\begingroup$ Sure! But you can create the bitmap image big enough and then converted to vector format. For publications, I think this is enough except if you need a billboard size image, then you will have pixellation at such ultra big size.. $\endgroup$
    – Camps
    Commented Sep 18, 2023 at 18:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .