4
$\begingroup$

I am aware that there are many many things that we can do in Mathematica, but I am wondering if it is also possible to construct chemical compunds such as for example the one below?:

enter image description here

EDIT:

Using @MarcoB suggestions I get the following:

MoleculePlot@ Molecule["FC1=CC(F)=C(C2OCC(COC3=CC=C(N4CCN(C5=CC=C(N6C=NN(C(C(O)C)\ CC)C6=O)C=C5)CC4)C=C3)C2CN7C=NC=N7)C=C1"]

which gives:

enter image description here

Why are some molecules red and some others blue? Is there a way to control the color so that all are black for example?

Another possibility I just found was to used something simple like:

MoleculePlot@Molecule["C37H42F2N8O4"]

which gives:

enter image description here

In this case, it also gives me automatically different colors for each molecule and also additionally the bonds out and in plane. How can I make normal bonds and tune the color?

$\endgroup$
6
  • 1
    $\begingroup$ What do you mean by construct? If you want to draw chemical structures, then the industry standards are ChemDraw or similar programs. Have you seen the Molecular structure and computation guide? $\endgroup$ – MarcoB Jan 4 at 22:52
  • 2
    $\begingroup$ Something like this? MoleculePlot@ Molecule["FC1=CC(F)=C(C2OCC(COC3=CC=C(N4CCN(C5=CC=C(N6C=NN(C(C(O)C)CC)C6=O)C=C5)CC4)C=C3)C2CN7C=NC=N7)C=C1"] $\endgroup$ – MarcoB Jan 4 at 22:58
  • 2
    $\begingroup$ If you have version 12.2 you can try MoleculeDraw@MoleculeRecognize@Import["https://i.stack.imgur.com/ZL8dr.png"] $\endgroup$ – Jason B. Jan 4 at 23:02
  • $\begingroup$ @MarcoB I am aware of ChemDraw but I was just wondering about the capabilities of Mathematica regarding this. Your code is great by the way $\endgroup$ – John Jan 4 at 23:17
  • $\begingroup$ @JasonB. I have the version 12.1 and it looks like it gets the formula but I am not sure how to get it like in a picture or Tiff $\endgroup$ – John Jan 4 at 23:18
10
$\begingroup$
ClearAll["Global`*"]

Assuming that you are starting with a chemical formula

Interpreter["Chemical"]["C37H42F2N8O4"] // InputForm

(* Entity["Chemical", "Posaconazole"] *)

Several forms of diagrams are available:

Entity["Chemical", "Posaconazole"][#] & /@ {"BlackStructureDiagram", 
   "CHBlackStructureDiagram", "ColorStructureDiagram", 
   "CHColorStructureDiagram", "LewisDotStructureDiagram", "MoleculePlot", 
   "StickMoleculePlot", "SpaceFillingMoleculePlot"} // Column

enter image description here

EDIT: To increase (double) the font size

Entity["Chemical", "Posaconazole"]["BlackStructureDiagram"] /. 
 Rule[FontSize, Scaled[s_]] :> Rule[FontSize, Scaled[2 s]]

enter image description here

$\endgroup$
2
  • $\begingroup$ Bob Hanlon what a fantastic program Mathematica is! Thank you for this. One quick questions if you don't mind. Do you know if it is possible to make the molecules a little bit bigger (change the font of the molecules)? I am accepting your answer. Thanks $\endgroup$ – John Jan 4 at 23:54
  • 1
    $\begingroup$ Use ImageSize with Show to change the size of the diagram: Show[diagram, ImageSize -> Large]. I do not know how to just change the FontSize. $\endgroup$ – Bob Hanlon Jan 5 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.