Representing paint molecules with JChemPaint

Molecule Editor

Article from Issue 265/2022
Author(s):

Drawings of molecules can be made with a graphics program like Inkscape. But structural formulas turn out even better if you use the JChemPaint professional molecule editor.

Every now and then, students need a tool for chemistry classes that makes it easy to put chemical structural formulas on digital paper. This not only makes it easier to work on homework but also helps to document experiments by drawing the chemical reactions. The free molecule editor JChemPaint [1] supports the (budding) chemist here.

The LGPL Java program is only available from the package sources of a few distributions. Arch Linux maintains the program in the Arch User Repository, but JChemPaint can easily be downloaded from the homepage and run at the command line (Listing 1). The settings let you change the language and appearance of the application, among other things. To do this, select Edit | Settings and switch to the Other settings tab.

Listing 1

Setting Up JChemPaint

$ wget https://github.com/downloads/JChemPaint/jchempaint/jchempaint-<Version>.jar
$ java -jar jchempaint-<Version>.jar

Drawing Molecules

There are two different ways to create drawings in JChemPaint. To represent a chemical compound as a structural formula, you would start with a central atom such as carbon. Alternatively, you can start from the edge of the structural formula. For carbonic acid, for example, first draw the functional group (a small collection of atoms that determines how a molecule works), that is, carboxylic acid R-C=O-OH. Click on the C icon in the lower toolbar and then on the drawing board to transfer the carbon atom to the drawing area.

JChemPaint automatically inserts hydrogen atoms next to the carbon atom so that the carbon atom does not have a charge. As soon as you continue with the drawing, you will notice that the program replaces the hydrogen atoms with the molecules or bonds you have inserted.

To add the double bond C=O, click on the O icon representing the oxygen atom and then on the bond type, in this case a double bond. Hold down the left mouse button and drag a line upwards starting at the carbon atom. JChemPaint then replaces the two hydrogen atoms with the double bond (Figure 1). Continue with this until you have drawn the structural formula of the chemical compound.

Figure 1: Thanks to the autocomplete feature, chemical compounds can be created without any risk of error.

Chemical compounds consisting of less common atoms can also be represented, but the atoms needed for this are not easy to find. Pressing the periodic table button in the lower toolbar reveals a dialog with all atoms contained in the periodic table (Figure 2). Like previously done, you can transfer these atoms to the drawing with a single click. It is worth mentioning at this point that the drawings in JChemPaint are not black and white. Instead, the atom colors follow accepted standards. An oxygen atom is typically shown in red, for example, while a chlorine atom has a green background.

Figure 2: Pressing the button that resembles a periodic table displays all the atoms in the periodic table.

Multichain carbons are nothing unusual in carbon chemistry. For example, fatty acids such as palmitate have a string of 16 carbon atoms. To draw the molecular formula of palmitate, CH3(CH2)14COO-, without too much hard work, first select the icon with the C on it and then click on the icon that resembles a zigzag line. Now hold down the left mouse button and drag a line until the number 16 appears on the drawing board – this is the number of carbon atoms. When you release the left mouse button, you'll notice that you drew 16 carbon atoms in one fell swoop.

The remaining part of the fatty acid contains the ionized form COO- of carboxylic acid. Apart from the oxygen double bond, the second oxygen atom has a negative charge. You need to remove the hydrogen atom that JChemPaint automatically inserts when drawing the simple oxygen bond to make way for the negative charge. To do this, select the OH anion by clicking on the selection tool in the upper area of the toolbar and then clicking on the anion. In Atom | Charge, then insert a positive or negative charge as appropriate. This tells JChemPaint to remove the hydrogen atom from the oxygen atom.

If the zigzag lines look a bit unusual, you can also display the implicit hydrogen atoms. They are typically used to avoid the carbon atom having negative charges. In Atom | Implicit hydrogen atoms, you can display or hide the implicit hydrogen atoms after previously marking the chemical compound (Figure 3).

Figure 3: JChemPaint does not normally represent implicit hydrogen atoms because they are a matter of course in carbon chemistry.

JChemPaint not only helps users draw structural formulas, but also lets you create Valence Shell Electron Pair Repulsion (VSEPR) drawings [2] that highlight the spatial geometry of a molecule (according to VSEPR, a molecule's geometry is based on the electron pairs, which want to be as far apart as possible). For example, an isolated water molecule has two pairs of electrons. The program does not offer users a function for this. You have to replace the electron pairs by residual groups (R icon) or use other symbols instead of the residual groups.

To do this, use the selection tool to select the residual group and, in Atom | Pseudo-atom | Other…, enter the symbol that you want to appear instead of the residual group. You can use either a colon or two dots for an electron pair. JChemPaint provides the appropriate functions for bonds that indicate whether an atom is at the front or rear. In Figure 4, you can see black or black-shaded bond symbols that look like triangles.

Figure 4: Black or black-shaded bond symbols indicate whether an atom is located at the front or rear.

However, JChemPaint does not have a function for drawing electron pairs. What it does have is a function for inserting radicals (atoms or molecules with an unpaired electron). In addition to a double bond, nitric oxide (N=O) has a radical belonging to the nitrogen atom. To add it, you just need to select the atom in question and add the radical via Atom | Radical | Add Unpaired Electron.

Operations on the Molecule

JChemPaint's eraser icon lets you erase bonds or atoms. Once delete mode is enabled, hover the mouse cursor over the atom or compound in question until the arrow turns into a circle. Then press the left mouse button to remove the content.

You can also copy molecules in JChemPaint. Unfortunately, a typical copy and paste action causes a Java exception to be thrown that the developers apparently failed to catch. The workaround is to select the whole or a part of the molecule first with the selection icon and then to copy the Simplified Molecular Input Line Entry Specification (SMILES) representation of the molecule into the clipboard using Edit | Copy as SMILES. (SMILES is proprietary format controlled by Daylight Inc. for representing a molecule as a string.) Then press Ctrl+V to insert the SMILES string [3] into the upper input bar and confirm the input by pressing Insert (Figure 5).

Figure 5: JChemPaint creates drawings based on SMILES strings.

On top of this, molecules or rings can mirrored, and rotated around their own axes to change the angle of view. To do this, first click on the selection tool and then select the chemical compound in question. Using the toolbar, you can now flip the molecule in question horizontally or vertically at the push of a button. The arrow icon that suggests a circular movement rotates the chemical compound vertically when you press the mouse button. Pressing the Rotate spatially button (an arrow pointing around a sphere) lets you rotate the molecule horizontally (Figure 6).

Figure 6: Horizontal rotation around the molecular axis changes the compound's angle of view.

More Aroma

Aromatic compounds consist of rings with alternating double bonds. Rings here can be equated with geometric shapes such as triangles, pentagons, or hexagons. On the right side of the toolbar, JChemPaint provides tools for the required shapes. If you are drawing several adjacent rings, the program facilitates this tasks by showing you where to place the next ring when you insert it (Figure 7).

Figure 7: When inserting additional elements or atoms, you can let them snap into place. This means that JChemPaint places them right next to each other.

You can also normalize aromatic compounds in JChemPaint. For example, you can improve the arrangement of two triangles drawn side by side by selecting the structures and then using Tools | Clean Up Structure to align the arrangement neatly.

However, there are far more complicated aromatic compounds than those shown here. This is why it's a good idea to first browse through JChemPaint's library. You may discover that the aromatic compound you need already exists in the library as a template. In which case you only need to click and insert. You can access the library by pressing the bottom multi-ring button in the toolbar on the right.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • 3D Molecular Visualizer

    Modern chemistry and biochemistry are hard to understand without 3D models. In this article, we look at programs that bring order to the chaos of connected atoms by arranging them in functional sections and in three dimensions.

  • Free Software Projects

    Graphics can facilitate research into chemical compounds. The chemistry software, Avogadro, has no trouble handling the third dimension and has an intuitive interface that offers more than its share of functionality.

  • carbonOS: A New Linux Distro with a User Experience Focus

    CarbonOS is a brand new, built-from-scratch Linux distribution that uses the Gnome desktop and has a special feature that makes it appealing to all types of users.

  • mtPaint

    You can create pixel art in just a few mouse clicks with the paint program mtPaint, and it can even teach your works of art how to walk.

  • Krita Vs. MyPaint

    If you are looking for an open source drawing program, Krita and MyPaint both offer graphic tablet support and brushes. Deciding which one works best depends on your specific needs.

comments powered by Disqus