Create Marvin JS Questions That Use Canonical or Combinatorial SMILES Strings

Sometimes, you want to display a randomly selected molecule in your question. Or, you might even want to combine molecules — for example, in condensation reactions or peptide sequences. Specifying the chemical structure using SMILES (Simplified Molecular Input Line Entry System) strings instead of the native Marvin JS XML lets you combine or otherwise change the chemical structure programmatically, and offers a space-efficient method for defining arrays of chemical structures that can be used in your question.

Canonical SMILES strings uniquely identify a particular molecule. The canonical SMILES representation of any molecule is dependent on the software program's canonicalization algorithm. For this reason, the canonical SMILES string for a molecule in Marvin JS might be different from the canonical SMILES string generated by another application.

Combinatorial SMILES strings identify a discrete structure in a molecule, and can be combined to form canonical SMILES strings.

Important  
  • Always use canonical or combinatorial SMILES strings.
  • Only a subset of SMILES notation is supported for use in Marvin JS questions.
  • Do not use SMILES strings for reactions or to specify atom mapping.
  • Other formats, such as molfile formats, protein data bank files, InChi strings, and IUPAC names, are not supported for use in WebAssign questions. You might be able to use one of these formats to display a structure in your question, but you should never use them to define answer keys that your students must draw, as this could result in scoring problems with your students' responses.
  • You can't specify the orientation of the drawing when using SMILES.

Although the native Marvin JS XML format provides the most comprehensive description of your chemical structures, it is long, difficult to read, and cannot be manipulated by your question code. With SMILES, your question code can easily combine or change SMILES strings, for example, to reflect a chemical process or to randomize your question.

For example, you could use either Marvin JS XML or SMILES to display an ethanol molecule: 

Marvin JS XML

SMILES

<?xml version="1.0" encoding="UTF-8"?><cml version="ChemAxon file format v5.10.0, generated by v15.8.9"><MDocument><MChemicalStruct><molecule molID="m1"><atomArray><atom id="a1" elementType="C" x2="-1.3336791218280353" y2="0.3849999999999998"/><atom id="a2" elementType="C" x2="4.440892098500626e-16" y2="-0.38500000000000023"/><atom id="a3" elementType="O" x2="1.3336791218280357" y2="0.38500000000000023"/></atomArray><bondArray><bond atomRefs2="a1 a2" order="1"/><bond atomRefs2="a2 a3" order="1"/></bondArray></molecule></MChemicalStruct></MDocument></cml>
CCO

The best way to ensure that your SMILES string works correctly in Marvin JS is to use Marvin JS to generate SMILES.

  1. Create your drawing using the Marvin JS Key Generation tool.
    1. Click Marvin under Page Tools.
    2. For Marvin Type, select the drawing mode to use.
      Important Always draw your chemical structure using the same mode you want to use in your question. See Marvin JS Drawing Modes.
    3. Draw the chemical structure or reaction.
  2. In the Marvin JS Key Generation tool, export the drawing to the ChemAxon SMILES format.
    1. Click export.
    2. For Format, select ChemAxon SMILES.
    3. Select and copy the SMILES string that is displayed.

    You don't need to download the SMILES string.

  3. Paste the SMILES string that you copied into your question.
    You can use the SMILES string in your questions instead of Marvin JS XML to display the chemical structure drawing in a question, to specify a Marvin JS answer key, or to define a Marvin JS template.

Example Displaying Chemical Structures Using SMILES

The following table summarizes an actual question.

QID

1534322

Name

Template2 5.MARVIN.06.

Mode

Multiple-Choice

Question

<eqn>
# ----------------------------------------------------
#    Select 1 of 8 molecules to identify
# ----------------------------------------------------
@dat = (["ethanol", "CCO"],
        ["isopropanol", "CC(O)C"],
        ["methanol", "CO"],
        ["n-propanol", "CCCO"],
        ["n-butanol", "CCCCO"],
        ["isobutanol", "CC(C)CO"],
        ["propene", "C=CC"],
        ["ethylene", "C=C"]);
@choices = pick(5, 0..$#dat);
''
</eqn>
Identify the molecule.
<table><tr><td width="250"><_></td>
<td><MARVIN type='condensed'><EQN 
$dat[$choices[0]][1]></MARVIN></td></tr></table>

Answer

<EQN $dat[$choices[0]][0]>
<EQN $dat[$choices[1]][0]>
<EQN $dat[$choices[2]][0]>
<EQN $dat[$choices[3]][0]>
<EQN $dat[$choices[4]][0]>

Display to Students

Question as displayed to students

Example Marvin JS Question Using SMILES Answer Key

The following table summarizes an actual question.

QID

1534328

Name

Template2 5.MARVIN.07.

Mode

Fill-in-the-Blank

Question

<eqn>
# ----------------------------------------------------
#    Set $mykey to one of 2730 possible tripeptides
# ----------------------------------------------------
@dat = (["Ala", "NC(C)C(=O)"],
        ["Arg", "NC(CCCNC(N)=N)C(=O)"],
        ["Asn", "NC(CC(N)=O)C(=O)"],
        ["Asp", "NC(CC(O)=O)C(=O)"],
        ["Cys", "NC(CS)C(=O)"],
        ["Gln", "NC(CCC(N)=O)C(=O)"],
        ["Glu", "NC(CCC(O)=O)C(=O)"],
        ["Gly", "NCC(=O)"],
        ["Ile", "NC(C(C)CC)C(=O)"],
        ["Leu", "NC(CC(C)C)C(=O)"],
        ["Lys", "NC(CCCCN)C(=O)"],
        ["Met", "NC(CCSC)C(=O)"],
        ["Ser", "NC(CO)C(=O)"],
        ["Thr", "NC(C(C)O)C(=O)"],
        ["Val", "NC(C(C)C)C(=O)"]);
($a, $b, $c) = pick(3, 0..$#dat);
$label = $dat[$a][0] . '-' . $dat[$b][0] . '-' . $dat[$c][0];
$mykey = $dat[$a][1] . $dat[$b][1] . $dat[$c][1] . 'O';
''
</eqn> 
Draw the structure of the tripeptide <eqn $label>. <br> <_>

Answer

<EQN $MARVIN='condensed'; $mykey>

Display to Students

Question as displayed to students