Message Boards Message Boards

See all halomethanes

Introduction:

One problem in chemistry is finding all possible molecules, as there are rotations and reflections. All the possibilities of existence of halomethanes (even unstable ones) are addressed here. This is a question similar to the sequence: Doubly triangular numbers (A002817–OEIS, N. J. A. Sloane, Apr 18, 2017): “Number of inequivalent ways to color vertices of a square using <= n colors, allowing rotations and reflections ...” , a(n)=n(n+1)(n^ 2+n+2)/8.

However as described in the sequence A002817–OEIS, only the total result of the possibilities is addressed, while here in this post I visually demonstrate all possibilities, both in list, 2D and 3D graphs and mass list.

Function Code:

With this function below it is possible to find and visualize all possibilities of halomethanes, taking into account all rotations and reflections of the molecules. I developed this function with some options (“Mode”) besides the list of terms. Examples of options: "Color", "Visual", "Visual3D", "Mass".

Here the function demonstration is done with all halogens (except radioactive halogens, by choice), but any of the possible elements can be used as an argument in the function. Example: {"H"}, {"F", "Br", "I"}, {...} ... {"H", "F", "Cl", "Br", "I" }.

Halomethanes[elem_, OptionsPattern[]] := 
 Module[{eleu, z, cc, a, a1, f, rP, ap, n, b}, z = Length@elem; 
  Options[Halomethanes] = {"Mode" -> "Table"}; eleu = elem[[1]]; 
  a = Tuples[elem, 4] /. {"Cl" -> "D", "Br" -> "B"}; n[x_] := {x}; 
  cc = {"C" -> GrayLevel[0.5], "F" -> RGBColor[1, 0.5, 0.5], 
    "Cl" -> RGBColor[0, 0.56, 0], "Br" -> RGBColor[0.6, 0.4, 0.2], 
    "I" -> RGBColor[1, 0, 0], "H" -> RGBColor[0, 1, 1]}; a1 = a[[1]]; 
  f[a_] := Module[{bt, ct, dt, e1, e2, ft, gt, r1}, 
    bt = Table[StringJoin[a[[b]]], {b, 1, Length@a}]; 
    ct = Table[StringJoin@Table[a[[c]], 2], {c, 1, Length@a}]; 
    dt = Table[
      StringJoin[a[[d]][[4]], a[[d]][[3]], a[[d]][[2]], 
       a[[d]][[1]]], {d, 1, Length@a}]; 
    e1 = Table[
      StringCases[ct[[i]], RegularExpression[bt[[1]]]], {i, 1, 
       Length@ct}]; 
    e2 = Table[
      StringCases[ct[[i]], RegularExpression[dt[[1]]]], {i, 1, 
       Length@ct}]; 
    ft = Table[{Length@(e1[[j]]), 
        Length@(e2[[j]])} /. {{2, 2} -> bt[[j]], {2, 0} -> 
         bt[[j]], {0, 2} -> {"copy"}, {0, 0} -> bt[[j]], {2, 1} -> 
         bt[[j]], {1, 2} -> {"copy"}, {1, 0} -> {"copy"}, {0, 
          1} -> {"copy"}, {1, 1} -> {"copy"}}, {j, 1, Length@ct}]; 
    gt = Table[
      StringPartition[DeleteCases[ft, {"copy"}][[o]], 1], {o, 1, 
       Length@DeleteCases[ft, {"copy"}]}]; 
    r1 = If[gt != {}, If[gt[[1]] == a[[1]], gt[[1]], {}], {}]; {rP = 
      DeleteCases[r1, {}], 
     ap = If[r1 != {}, DeleteCases[gt, r1], gt]}]; 
  Do[b = AppendTo[n[a1], {a = f[a][[2]], f[a][[1]]}[[2]]], 
   z*(z + 1)*(z^2 + z + 2)/8 - 1]; 
  OptionValue[
    "Mode"] /. {"Table" -> 
     If[z == 1, {{eleu, eleu, eleu, eleu}}, 
      b /. {"D" -> "Cl", "B" -> "Br"}], 
    "Color" -> {TableForm[{{"H", 
         Text[Style["Cyan", RGBColor[0, 1, 1], Medium]]}, {"F", 
         Text[Style["Pink", RGBColor[1, 0.5, 0.5], Medium]]}, {"Cl", 
         Text[Style["Green", RGBColor[0, 0.56, 0], Medium]]}, {"Br", 
         Text[Style["Brown", RGBColor[0.6, 0.4, 0.2], Medium]]}, {"I",
          Text[Style["Red", RGBColor[1, 0, 0], Medium]]}}, 
       TableHeadings -> {None, {"Atom", "Color"}}], 
      If[z == 1, {Flatten@Table[elem, 4]}, 
        b /. {"D" -> "Cl", "B" -> "Br"}] /. cc}, 
    "Visual" -> 
     If[z == 1, 
      MoleculePlot[
       Molecule[{"C", eleu, eleu, eleu, eleu}, {Bond[{1, 2}], 
         Bond[{1, 3}], Bond[{1, 4}], Bond[{1, 5}]}], ColorRules -> cc,
        ImageSize -> 100], 
      Table[MoleculePlot[
        Molecule[
         Join[{"C"}, (b /. {"D" -> "Cl", "B" -> "Br"})[[
           h]]], {Bond[{1, 2}], Bond[{1, 3}], Bond[{1, 4}], 
          Bond[{1, 5}]}], ColorRules -> cc, ImageSize -> 100], {h, 1, 
        Length@b}]], 
    "Visual3D" -> 
     If[z == 1, 
      MoleculePlot3D[
       Molecule[{"C", eleu, eleu, eleu, eleu}, {Bond[{1, 2}], 
         Bond[{1, 3}], Bond[{1, 4}], Bond[{1, 5}]}], ColorRules -> cc,
        ImageSize -> 100], 
      Table[MoleculePlot3D[
        Molecule[
         Join[{"C"}, (b /. {"D" -> "Cl", "B" -> "Br"})[[
           h]]], {Bond[{1, 2}], Bond[{1, 3}], Bond[{1, 4}], 
          Bond[{1, 5}]}], ColorRules -> cc, ImageSize -> 80], {h, 1, 
        Length@b}]], 
    "Mass" -> 
     If[z == 1, 
      MoleculeValue[
       Molecule[{"C", eleu, eleu, eleu, eleu}, {Bond[{1, 2}], 
         Bond[{1, 3}], Bond[{1, 4}], Bond[{1, 5}]}], "MolecularMass"],
       Table[MoleculeValue[
        Molecule[
         Join[{"C"}, (b /. {"D" -> "Cl", "B" -> "Br"})[[
           h]]], {Bond[{1, 2}], Bond[{1, 3}], Bond[{1, 4}], 
          Bond[{1, 5}]}], "MolecularMass"], {h, 1, Length@b}]]}]

Visualization:

  • TERMS TABLE:

In the simplest form, with only one argument, a list of all halomethane molecules is generated.

rp = Halomethanes[{"H", "F", "Cl", "Br", "I"}]

Length@rp

im1

  • COLOR TABLE:

Optionally, a list of molecules with their respective illustrative colors is generated with the "Mode" -> "Color" option.

Halomethanes[{"H", "F", "Cl", "Br", "I"}, "Mode" -> "Color"]

im2

  • 2D VISUAL TABLE:

Optionally, a list of molecules with 2D structural representations is generated with the "Mode" -> "Visual" option (the 2D model can better represent stereoisomerism than the 3D model).

Halomethanes[{"H", "F", "Cl", "Br", "I"}, "Mode" -> "Visual"]

im3

  • 3D VISUAL TABLE (interactive):

Optionally, a list of molecules with 3D structural representations is generated with the "Mode" -> "Visual3D" option. This list is interactive, and each molecule can be rotated for better viewing (stereoisomerism is not very well represented in these 3D models as the representations are tetrahedral, for example, the isomers {"H","F","H","F"} and {"F","F","H”,”H”} are very similar in this view).

Halomethanes[{"H", "F", "Cl", "Br", "I"}, "Mode" -> "Visual3D"]

im4

  • MASS TABLE:

Finally, a list of the masses of all halomethanes can be generated with the argument "Mode" -> "Mass" (some of them, although unstable, are mentioned in the list).

resp2 = Halomethanes[{"H", "F", "Cl", "Br", "I"}, "Mode" -> "Mass"]

im5

Illustrative graph of the mass distributions of all possible halomethanes:

ListPlot[resp2, AxesLabel -> {"n", "Mass(u)"}, 
 LabelStyle -> Directive["Subsubsection", RGBColor[0.07, 0.5, 0.5]], 
 PlotLabel -> "Halomethanes Mass", PlotRange -> {{0, 130}, {0, 550}}, 
 PlotStyle -> Directive[RGBColor[0.91, 0.08, 0.5], PointSize[Large]], 
 ImageSize -> Large]

im6

Link: (Doubly triangular numbers, A002817–OEIS, sequence):

https://oeis.org/A002817

Thanks.

POSTED BY: Claudio Chaib
13 Replies

Thanks Hans!...I fixed the code and it is now ready for the use with halogens (+H) from hydrogen to iodine with all the options of the function.

POSTED BY: Claudio Chaib
Posted 4 years ago

I won't be able to make a further look at this topic, but let me just suggest something about one of your inner loops, with your variable names retained for clarity:

Do[g = DeleteCases[Table[If[Signature[g[[l]]] != 0,
                            g[[l]] /. {g[[q]] -> g[[l]],
                                       g[[q, {1, 2, 4, 3}]] -> g[[l]], 
                                       g[[q, {1, 3, 2, 4}]] -> {}},
                            g[[l]] /. {g[[q]] -> g[[l]],
                                       g[[q, {1, 2, 4, 3}]] -> {}, 
                                       g[[q, {1, 3, 2, 4}]] -> {}}],
                         {l, Length[g]}], {}],
   {q, z^2 (z^2 + 11)/12}]

Also, you really should look into using the group theory stuff to shorten your code. Here is a variation of the approach in my first post:

{achiral, chiral} =
GatherBy[DeleteDuplicatesBy[Tuples[{"H", "F", "Cl", "Br", "I"}, {4}], 
                            DeleteDuplicates[Permute[Sort[#],
                                                     AlternatingGroup[4]]] &],
         Abs @* Signature];

halomethanes = Join[achiral, chiral, chiral[[All, {1, 4, 3, 2}]]];

then you can get your color swatches like so:

halomethanes /. Thread[{"H", "F", "Cl", "Br", "I"} -> {Cyan, Pink, Green, Brown, Red}]

color swatches

Finally, you don't need the overhead of building a Molecule[] object just to compute the molar mass afterwards:

ElementData["C", "AtomicMass"] + Sum[ElementData[e, "AtomicMass"], {e, #}] & /@ halomethanes
POSTED BY: J. M.
Posted 4 years ago

This short note ought to be of interest.

-- from my first post in this thread, at the bottom ;)

POSTED BY: J. M.

(# FIXED CODE #)

I corrected the code to generate the correct sequence of halomethanes (+ methane). The sequence is: "Number of inequivalent ways to color vertices of a tetrahedron using <= n colors (A006008-OEIS, N. J. A. Sloane, Jul 11, 1991)."

The function continues with the same options: list, color list, 2D and 3D graphics and mass list.

Halomethanes[elem_, OptionsPattern[]] := 
 Module[{eleu, z, cc, a, a1, f, rP, ap, n, b, g}, z = Length@elem; 
  Options[Halomethanes] = {"Mode" -> "Table"}; eleu = elem[[1]]; 
  a = Tuples[elem, 4] /. {"Cl" -> "D", "Br" -> "B"}; n[x_] := {x}; 
  cc = {"C" -> GrayLevel[0.5], "F" -> RGBColor[1, 0.5, 0.5], 
    "Cl" -> RGBColor[0, 0.56, 0], "Br" -> RGBColor[0.6, 0.4, 0.2], 
    "I" -> RGBColor[1, 0, 0], "H" -> RGBColor[0, 1, 1]}; a1 = a[[1]]; 
  f[a_] := Module[{bt, ct, dt, e1, e2, ft, gt, r1}, 
    bt = Table[StringJoin[a[[b]]], {b, 1, Length@a}]; 
    ct = Table[StringJoin@Table[a[[c]], 2], {c, 1, Length@a}]; 
    dt = Table[
      StringJoin[a[[d]][[4]], a[[d]][[3]], a[[d]][[2]], 
       a[[d]][[1]]], {d, 1, Length@a}]; 
    e1 = Table[
      StringCases[ct[[i]], RegularExpression[bt[[1]]]], {i, 1, 
       Length@ct}]; 
    e2 = Table[
      StringCases[ct[[i]], RegularExpression[dt[[1]]]], {i, 1, 
       Length@ct}]; 
    ft = Table[{Length@(e1[[j]]), 
        Length@(e2[[j]])} /. {{2, 2} -> bt[[j]], {2, 0} -> 
         bt[[j]], {0, 2} -> {"copy"}, {0, 0} -> bt[[j]], {2, 1} -> 
         bt[[j]], {1, 2} -> {"copy"}, {1, 0} -> {"copy"}, {0, 
          1} -> {"copy"}, {1, 1} -> {"copy"}}, {j, 1, Length@ct}]; 
    gt = Table[
      StringPartition[DeleteCases[ft, {"copy"}][[o]], 1], {o, 1, 
       Length@DeleteCases[ft, {"copy"}]}]; 
    r1 = If[gt != {}, If[gt[[1]] == a[[1]], gt[[1]], {}], {}]; {rP = 
      DeleteCases[r1, {}], 
     ap = If[r1 != {}, DeleteCases[gt, r1], gt]}]; 
  Do[b = AppendTo[n[a1], {a = f[a][[2]], f[a][[1]]}[[2]]], 
   z*(z + 1)*(z^2 + z + 2)/8 - 1]; g = DeleteCases[b, {}]; 
  Do[g = DeleteCases[
     Table[If[(g[[l]][[1]] != g[[l]][[2]] != g[[l]][[3]] != 
         g[[l]][[4]]), 
       g[[l]] /. {{g[[q]][[1]], g[[q]][[2]], g[[q]][[3]], 
           g[[q]][[4]]} -> 
          g[[l]], {g[[q]][[1]], g[[q]][[2]], g[[q]][[4]], 
           g[[q]][[3]]} -> 
          g[[l]], {g[[q]][[1]], g[[q]][[3]], g[[q]][[2]], 
           g[[q]][[4]]} -> {}}, 
       g[[l]] /. {{g[[q]][[1]], g[[q]][[2]], g[[q]][[3]], 
           g[[q]][[4]]} -> 
          g[[l]], {g[[q]][[1]], g[[q]][[2]], g[[q]][[4]], 
           g[[q]][[3]]} -> {}, {g[[q]][[1]], g[[q]][[3]], g[[q]][[2]],
            g[[q]][[4]]} -> {}}], {l, 1, Length@g}], {}], {q, 
    1, (z^4 + 11 z^2)/12}]; 
  OptionValue[
    "Mode"] /. {"Table" -> 
     If[z == 1, {{eleu, eleu, eleu, eleu}}, 
      g /. {"D" -> "Cl", "B" -> "Br"}], 
    "Color" -> {TableForm[{{"H", 
         Text[Style["Cyan", RGBColor[0, 1, 1], Medium]]}, {"F", 
         Text[Style["Pink", RGBColor[1, 0.5, 0.5], Medium]]}, {"Cl", 
         Text[Style["Green", RGBColor[0, 0.56, 0], Medium]]}, {"Br", 
         Text[Style["Brown", RGBColor[0.6, 0.4, 0.2], Medium]]}, {"I",
          Text[Style["Red", RGBColor[1, 0, 0], Medium]]}}, 
       TableHeadings -> {None, {"Atom", "Color"}}], 
      If[z == 1, {Flatten@Table[elem, 4]}, 
        g /. {"D" -> "Cl", "B" -> "Br"}] /. cc}, 
    "Visual" -> 
     If[z == 1, 
      MoleculePlot[
       Molecule[{"C", eleu, eleu, eleu, eleu}, {Bond[{1, 2}], 
         Bond[{1, 3}], Bond[{1, 4}], Bond[{1, 5}]}], ColorRules -> cc,
        ImageSize -> 100], 
      Table[MoleculePlot[
        Molecule[
         Join[{"C"}, (g /. {"D" -> "Cl", "B" -> "Br"})[[
           h]]], {Bond[{1, 2}], Bond[{1, 3}], Bond[{1, 4}], 
          Bond[{1, 5}]}], ColorRules -> cc, ImageSize -> 100], {h, 1, 
        Length@g}]], 
    "Visual3D" -> 
     If[z == 1, 
      MoleculePlot3D[
       Molecule[{"C", eleu, eleu, eleu, eleu}, {Bond[{1, 2}], 
         Bond[{1, 3}], Bond[{1, 4}], Bond[{1, 5}]}], ColorRules -> cc,
        ImageSize -> 100], 
      Table[MoleculePlot3D[
        Molecule[
         Join[{"C"}, (g /. {"D" -> "Cl", "B" -> "Br"})[[
           h]]], {Bond[{1, 2}], Bond[{1, 3}], Bond[{1, 4}], 
          Bond[{1, 5}]}], ColorRules -> cc, ImageSize -> 80], {h, 1, 
        Length@g}]], 
    "Mass" -> 
     If[z == 1, 
      MoleculeValue[
       Molecule[{"C", eleu, eleu, eleu, eleu}, {Bond[{1, 2}], 
         Bond[{1, 3}], Bond[{1, 4}], Bond[{1, 5}]}], "MolecularMass"],
       Table[MoleculeValue[
        Molecule[
         Join[{"C"}, (g /. {"D" -> "Cl", "B" -> "Br"})[[
           h]]], {Bond[{1, 2}], Bond[{1, 3}], Bond[{1, 4}], 
          Bond[{1, 5}]}], "MolecularMass"], {h, 1, Length@g}]]}]
  • Using the function:

    Halomethanes[{"H", "F", "Cl", "Br", "I"}]
    
    Halomethanes[{"H", "F", "Cl", "Br", "I"}, "Mode" -> "Color"]
    
    Halomethanes[{"H", "F", "Cl", "Br", "I"}, "Mode" -> "Visual"]
    
    Halomethanes[{"H", "F", "Cl", "Br", "I"}, "Mode" -> "Visual3D"]
    
    resp2 = Halomethanes[{"H", "F", "Cl", "Br", "I"}, "Mode" -> "Mass"]
    
    ListPlot[resp2, AxesLabel -> {"n", "Mass(u)"}, 
     LabelStyle -> Directive["Subsubsection", RGBColor[0.07, 0.5, 0.5]], 
     PlotLabel -> "Halomethanes Mass", PlotRange -> {{0, 80}, {0, 550}}, 
     PlotStyle -> Directive[RGBColor[0.91, 0.08, 0.5], PointSize[Large]], 
     ImageSize -> Large]
    

i1

i2

i3

i4

i5

i6

Thanks, J.M., for letting me know that I was using the planar form instead of the tetrahedric.

Link: "Number of inequivalent ways to color vertices of a tetrahedron (A006008-OEIS)":

https://oeis.org/A006008

Thanks.

POSTED BY: Claudio Chaib

OK. The notebook I attached gives 74 halomethanes as well. That looks fine.

the article I linked to corroborates this.

Sorry. Which article?

I attach an article of Markus van Almsick, Helmut Hoenig and me and a zip-file prepared by Markus (I never used it, because (and that is an outing) I simply don't know how to do it).

Sorry, attaching a zip-file is not supported. If you like to get it just send me an email:

h.dolhaine@gmx.de

Perhaps that zip-file is helpful for dealing with substiutional isomers.

Attachments:
POSTED BY: Hans Dolhaine
Posted 4 years ago

SInce this has been made a "Staff Pick", I should perhaps demonstrate how to depict the halomethanes the way it is done in some textbooks. Only a little more work than what I did in my last post is necessary (and using the same variables):

tetCoords = RotationTransform[-Pi/4, {0, 0, 1}] @
            PolyhedronData["Tetrahedron", "Vertices"];
tetCoords = Prepend[N[Normalize[Delete[#, 2]/(1 - #[[2]])] & /@
                      tetCoords][[{1, 2, 4, 3}]], {0., 0.}];

makeTet[a_?VectorQ, opts___] := With[{cent = tetCoords[[1]], h1 = 0.2, h2 = 0.8},
    Graphics[{Line[{{1 - h1, h1}, {1 - h2, h2}}.{cent, #}] & /@ Rest[tetCoords],
              MapThread[Text[Style[#1, ColorData["Atoms", #1], 10], #2] &,
                        {Prepend[a, "C"], tetCoords}]}, opts,
             ImageMargins -> 0.2, ImageSize -> Large,
             PlotRange -> All, PlotRangePadding -> None]]

GraphicsGrid[Partition[makeTet /@
                       Join[achiral,
                            Flatten[{#, #[[{1, 4, 3, 2}]]} & /@ chiral, 1]],
                       5], Spacings -> 0., Frame -> All]

halomethanes

(I had really wanted to use MoleculePlot[], but it was very annoying with how it places hash and wedge bonds, so I abandoned that approach.)

POSTED BY: J. M.

Hello Hans, as J.M. pointed out, in the beginning I assumed that there was steriometry between e.g.: HFHF/HHFF..., but I was wrong, because halomethanes are tetrahedric in space and not planar, I'm already working on a code update to fix this.

POSTED BY: Claudio Chaib
Posted 4 years ago

My post already implies the true count of 74 (the count was 75 there because I did not remove methane, which is not itself a halomethane by definition); the article I linked to corroborates this. It is exactly because of the pure rotation group that I used the group theory functionality in my post.

POSTED BY: J. M.

This is a great post.

However I am somewhat lost: how many different halomethanes are there?

I attach a notebook which was written long time ago to cope with the number of substitutional isomers. Note that in the real world only the pure rotation-group of a molecule accounts for the number of possible isomers.

In the notebook the pure rotation-group T of a tetrahedron is generated by two generating elements, a C2 and a C3-axis.

Then an isomer counting algorithm is applied and a list of isomers with different numbers of substituents is given. The halomethanes are found at the very end (nsubs = 4 ). It says that for the halomethane of structural type a2b2 there is exactly one isomer, but the cofactor says that there are 6 combinations of halogens possible, giving a total of 6 halomethanes of this structural type.

The structural type abcd yields 2 isomers (2 enantiomers), but only one combination (cofactor) of 4 different halogens.

Attachments:
POSTED BY: Hans Dolhaine

enter image description here - Congratulations! This post is now featured in our Staff Pick column as distinguished by a badge on your profile of a Featured Contributor! Thank you, keep it coming, and consider contributing your work to the The Notebook Archive!

POSTED BY: Moderation Team
Posted 4 years ago

The "irregularity" you might be thinking of is because the C-X bond lengths (generally) increase with increasing atomic number of the ligand, so e.g. a C-I bond is considerably longer than a C-F bond. Nevertheless, VSEPR will still ensure the sp3 hybridized carbon atom has a tetrahedral configuration. From my limited experience with trying MoleculePlot3D[] on Wolfram Cloud, it at least knows this aspect of VSEPR.

I did account for enantiomers in the ugly solution I posted; that's why I split the count into "chiral" and "achiral" sets.

The analysis of the "square planar" configuration you initially considered does apply for e.g. metal complexes; in there, you can have cis-trans isomerism, and thus two isomers of a substance where two of each ligand is attached to the center.

POSTED BY: J. M.

Thanks so much for the feedback Jan M.

I now realize that some halomethanes are exactly the same, as they exist only in tetrahedral form; so naturally the molecules, e.g.: HFHF/HHFF or HHBrBr/HBrHBr .. are the same, as they have no other form of spatial structure. Therefore, we cannot rely on stereoisomerism in such cases.

I also noticed that in the spatial representation, the angles between atoms don't look very accurate the way I did (I may be mistaken, it was just an impression I had), as some of the compounds tend to be irregular tetrahedrals (in real form, while all these 3D models appear to be regular tetrahedrals), depending on the halogens of the molecule ... Is there a more realistic way to take these variables into account in the spatial representation of halomethanes, or was it just my impression and these factors are already inherent in the MoleculePlot3D?

The way you built these codes is very interesting, I will try to make the most of learning. It is very gratifying to know that you had time to prepare this feedback for me, so I am extremely grateful!

POSTED BY: Claudio Chaib
Posted 4 years ago

Looking at your list rp, it seems you double-counted a few of the halomethanes; e.g. difluoromethane is counted twice.

Here's a rather inefficient count:

halInit = DeleteDuplicates[Sort /@ Tuples[{"H", "F", "Cl", "Br", "I"}, {4}]];
chiral = Select[halInit, Signature[#] != 0 &];
(* use achiral = Complement[halInit, chiral] instead
   if you don't care about scrambling *)
achiral = Select[halInit, Signature[#] == 0 &];

Length[achiral] + 2 Length[chiral]
   75

(I am certain there is a neat combinatorial trick that would eliminate the need to throw out dupes, but sadly, my already limited mathematical and programming skills escape me currently.)


(added during afternoon tea time)

It turns out that if one recalls that the group of symmetries of the tetrahedron correspond to the degree 4 alternating group, you get a pretty quick filtering scheme:

halInit =
DeleteDuplicatesBy[Tuples[{"H", "F", "Cl", "Br", "I"}, {4}], 
                   Sort /@ Union[PermutationReplace[#, AlternatingGroup[4]]] &];
chiral = Select[halInit, Signature[#] != 0 &];
achiral = Complement[halInit, chiral];

(Certainly, there ought to be a nicer way to leverage the permutation group functionality of Mathematica, but my knowledge of group theory has gone rusty.)


With that, here's some ugly code written during a quick lunch break, like the one I am having right now:

makeCX4SMILESAchiral[a_?VectorQ] :=
ToString[StringForm["`1`C(`2`)(`3`)`4`", ##] & @@ (a /. "H" -> "[H]")]

makeCX4SMILESChiral[a_?VectorQ] :=
ToString[StringForm["`1`[C@](`2`)(`3`)`4`",
                    Sequence @@ ((a /. "H" -> "[H]")[[#]])]] & /@
                    {{1, 2, 3, 4}, {1, 4, 3, 2}}

mols = Molecule /@ Join[makeCX4SMILESAchiral /@ achiral,
                        Flatten[makeCX4SMILESChiral /@ chiral]];

Length[mols] == Length[Union[mols, SameTest -> MoleculeEquivalentQ]]
   True

after which you can just map over MoleculePlot(3D)[]* if you actually want the pictures.

* - Users of older Mathematica versions can use something like MoleculeViewer[] instead.


This short note ought to be of interest.

POSTED BY: J. M.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract