- The molecule editor allows students to draw molecules that follow the rules for covalent bond formation and formal charge, even if the molecules are chemically impossible, are unstable, or do not exist in living systems.
* - .. image:: /Images/MoleculeViewer.png
:width: 100
:alt: Example molecule viewer
- :ref:`Molecule Viewer`
- With the molecule viewer, you can create three-dimensional representations of molecules for your students to see.
Students can use the molecule editor to learn how to create molecules. The molecule editor allows students to draw molecules that follow the rules for covalent bond formation and formal charge, even if the molecules are chemically impossible, are unstable, or do not exist in living systems. The molecule editor warns students if they try to submit a structure that is chemically impossible.
Studio offers two tools that you can use in discussions of molecules:
* With the **molecule viewer**, you can create three-dimensional representations of molecules for students to view. For more information about this tool, see :ref:`Molecule Viewer`.
* With the **molecule editor**, you can allow students to draw their own molecules.
The molecule editor incorporates two tools: the JSME molecule editor created by Peter Erl and Bruno Bienfait, and JSmol, a JavaScript-based molecular viewer from Jmol. (You don't need to download either of these tools--Studio uses them automatically.) For more information about the JSME molecule editor, see `JSME Molecule Editor <http://peter-ertl.com/jsme/index.html>`_. For more information about JSmol, see `JSmol <http://sourceforge.net/projects/jsmol/>`_.
Both tools use **JSmol**, a JavaScript-based molecular viewer from Jmol. In addition, the molecule editor problem type uses the JSME molecule editor created by Peter Erl and Bruno Bienfait. (You don't need to download either of these tools; Studio uses them automatically.) For more information about JSmol, see `JSmol <http://sourceforge.net/projects/jsmol/>`_. For more information about the JSME molecule editor, see `JSME Molecule Editor <http://peter-ertl.com/jsme/index.html>`_.
Students can use the molecule editor to learn how to create molecules. The molecule editor allows students to draw molecules that follow the rules for covalent bond formation and formal charge, even if the molecules are chemically impossible, are unstable, or do not exist in living systems. The molecule editor warns students if they try to submit a structure that is chemically impossible.
.. image:: /Images/Molecule_Editor.png
:width: 500
:alt: Image of the molecule editor
.. _Create the Molecule Editor:
...
...
@@ -17,32 +23,12 @@ The molecule editor incorporates two tools: the JSME molecule editor created by
Create the Molecule Editor
******************************
To create a molecule editor, you need the following files:
* MoleculeAnswer.png
* MoleculeEditor_HTML.png
* dopamine.mol
To download all of these files in a .zip archive, go to http://files.edx.org/MoleculeEditorFiles.zip.
.. note:: The molecule that appears when the tool starts is a dopamine molecule. To use a different molecule, download the .mol file for that molecule from the `list of molecules <http://www.biotopics.co.uk/jsmol/molecules/>`_ on the `BioTopics <http://www.biotopics.co.uk/>`_ website. Then, upload the .mol file to the **Files & Uploads** page for your course in Studio, and change "dopamine.mol" in the example code to the name of your .mol file.
To create the molecule editor that appears in the image above, you need an HTML component followed by a Problem component.
#. Upload all of the files listed above to the **Files & Uploads** page in your course.
#. Create the HTML component.
#. In the unit where you want to create the problem, click **HTML** under **Add New Component**, and then click **HTML**.
#. In the component that appears, click **Edit**.
#. In the component editor, paste the HTML component code from below.
#. Make any changes that you want, and then click **Save**.
To create a molecule editor problem:
3. Create the Problem component.
#. Under the HTML component, click **Problem** under **Add New Component**, and then click **Blank Advanced Problem**.
#. In the component that appears, click **Edit**.
#. In the component editor, paste the Problem component code from below.
#. Click **Save**.
#. Under **Add New Component**, click **Problem**, and then click **Molecular Structure**.
#. In the component that appears, click **Edit**.
#. In the component editor, modify the code to correspond to your problem.
#. Click **Save**.
.. _EMC Problem Code:
...
...
@@ -50,115 +36,79 @@ To create the molecule editor that appears in the image above, you need an HTML
Molecule Editor Code
========================
To create the molecule editor, you need an HTML component and a Problem component.
HTML Component Code
***************************
.. code-block:: xml
<h2>Molecule Editor</h2>
<p>The molecule editor makes creating and visualizing molecules easy. A chemistry professor may have you build and submit a molecule as part of an exercise.</p>
<div>
<script type="text/javascript">// <![CDATA[
function toggle2(showHideDiv, switchTextDiv) {
var ele = document.getElementById(showHideDiv);
var text = document.getElementById(switchTextDiv);
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "+ open";
}
else {
ele.style.display = "block";
text.innerHTML = "- close";
}
}
// ]]></script>
</div>
<div>
<style type="text/css"></style>
</div>
<div id="headerDiv">
<div id="titleText">Using the Molecule Editor<a id="myHeader" href="javascript:toggle2('myContent','myHeader');">+ open </a></div>
</div>
<div id="contentDiv">
<div id="myContent" style="display: none;">
<p>In this problem you will edit a molecule using the molecular drawing program shown below:</p>
<p>The chemical editor you are using ensures that the structures you draw are correct in one very narrow sense, that they follow the rules for covalent bond formation and formal charge. However, there are many structures that follow these rules that are chemically impossible, unstable, do not exist in living systems, or are beyond the scope of this course. The editor will let you draw them because, in contrast to the rules of formal charge, these properties cannot be easily and reliably predicted from structures.</p>
<p>If you submit a structure that includes atoms that are not possible or are beyond the scope of this course, the software will warn you specifically about these parts of your structure and you will be allowed to edit your structure and re-submit. Submitting an improper structure will not count as one of your tries. In general, you should try to use only the atoms most commonly cited in this course: C, H, N, O, P, and S. If you want to learn about formal charge, you can play around with other atoms and unusual configurations and look at the structures that result.</p>
</div>
</div>
<div id="ap_listener_added"> </div>
Problem Component Code
***************************
.. code-block:: xml
<problem>
<p>The dopamine molecule, as shown, cannot make ionic bonds. Edit the dopamine molecule so it can make ionic bonds.</p>
<p>When you are ready, click Check. If you need to start over, click Reset.</p>
<script type="loncapa/python">
def check1(expect, ans):
import json
mol_info = json.loads(ans)["info"]
return any(res == "Can Make Ionic Bonds" for res in mol_info)
</script>
<customresponse cfn="check1">
<editamoleculeinput file="/static/dopamine.mol">
</editamoleculeinput>
</customresponse>
<p>
A molecular structure problem lets the user use the JSME editor
component to draw a new molecule or update an existing drawing and then
submit their work. Answers are specified as SMILES strings.
</p>
<p>
I was trying to draw my favorite molecule, caffeine. Unfortunately,
I'm not a very good biochemist. Can you correct my molecule?
</p>
<jsmeresponse>
<jsme>
<!--
You can set initial state of the editor by including a molfile
inside of the jsme tag.
Take care that indentation is preserved. The molfile format is
sensitive to whitespace, so the best policy is to cut and paste
as-is on a new line without adjusting the indentation. If you
do indent the molfile data, make sure every line is indented the
same amount using space characters only, no tabs.
-->
<initial-state>
CN2Cc1[nH]cnc1N(C)C2=O
JME 2014-06-28 Wed Jul 23 13:41:18 GMT-400 2014
12 13 0 0 0 0 0 0 0 0999 V2000
3.6373 2.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.6373 3.5000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.4249 4.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.2124 3.5000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
1.2124 2.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.4249 1.4000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
4.9688 1.6674 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
5.7917 2.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.9688 3.9326 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 1.4000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 4.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.4249 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 2 0 0 0 0
2 3 1 0 0 0 0
3 4 1 0 0 0 0
4 5 1 0 0 0 0
5 6 1 0 0 0 0
6 1 1 0 0 0 0
7 8 2 0 0 0 0
8 9 1 0 0 0 0
2 9 1 0 0 0 0
1 7 1 0 0 0 0
5 10 2 0 0 0 0
4 11 1 0 0 0 0
6 12 1 0 0 0 0
M END
</initial-state>
<!-- Answers are specified as SMILES strings. -->
<answer>Cn1cnc2c1c(=O)n(C)c(=O)n2C</answer>
</jsme>
<!-- This answer is shown to the student when they click the
"Show Answer" button in the UI. It is not used for grading and
should be human readable. -->
<answer>C8H10N4O2</answer>
</jsmeresponse>
<solution>
<img src="/static/MoleculeAnswer.png"/>
<div class="detailed-solution">
<p>Explanation</p>
<p>
Some scholars have hypothesized that the renaissance was made
possible by the introduction of coffee to Italy. Likewise scholars
have linked the Enlightenment with the rise of coffee houses in
England.
</p>
</div>
</solution>
</problem>
**Problem 2**
::
<problem>
<p>The dopamine molecule, as shown, cannot make strong hydrogen bonds. Edit the dopamine molecule so that it can make strong hydrogen bonds.</p>
<script type="loncapa/python">
def grader_1(expect, ans):
import json
mol_info = json.loads(ans)["info"]
return any(res == "Cannot Make Strong Hydrogen Bonds" for res in mol_info)
</script>
<customresponse cfn="grader_1">
<editamoleculeinput file="/static/dopamine.mol">
</editamoleculeinput>
</customresponse>
</problem>
**Problem 3**
::
<problem>
<p>The dopamine molecule has an intermediate hydrophobicity. Edit the dopamine molecule so that it is more hydrophobic.</p>
Studio offers two tools that you can use in discussions of molecules:
* With the **molecule viewer** tool, you can create three-dimensional representations of molecules for students to view.
* With the **molecule editor** problem type, you can allow students to draw their own molecules. For more information about this tool, see :ref:`Molecule Editor`.
Both tools use **JSmol**, a JavaScript-based molecular viewer from Jmol. (You don't need to download this tool; Studio uses it automatically.) For more information about JSmol, see `JSmol <http://sourceforge.net/projects/jsmol/>`_.
The following image shows the molecule viewer tool in a course:
.. image:: /Images/MoleculeViewer.png
:width: 500
:alt: Image of molecule viewer showing a molecule of Ciprofloxacin
.. note:: To create a molecule viewer tool, you must have permission to upload files to a third-party file hosting site such as Amazon Web Services Simple Storage Service (AWS S3). When you create the molecule viewer, you'll upload a folder that contains a large number of files to the file hosting site.
.. _Create the Molecule Viewer:
*******************************
Create the Molecule Viewer Tool
*******************************
Creating a molecule viewer tool has several steps:
#. Download files from the `BioTopics website <http://www.biotopics.co.uk/jsmol/molecules>`_ and from edX.
#. Move or edit some of the files that you downloaded.
#. Upload a folder that contains all of the files that you downloaded and edited to your own file hosting site.
#. Create an HTML component that contains an IFrame in Studio. The IFrame references the files that you upload to the file hosting site.
================================================
Download Files from BioTopics and edX
================================================
#. Create or download a .mol file for the molecule that you want to show. You can download a variety of .mol files from the `BioTopics website <http://www.biotopics.co.uk/jsmol/molecules>`_. Save the file in a place where you can easily find it.
#. Download the `MoleculeViewerFiles.zip <http://files.edx.org/MoleculeViewerFiles.zip>`_ file from edX.
#. Unzip the `MoleculeViewerFiles.zip <http://files.edx.org/MoleculeViewerFiles.zip>`_ file that you've downloaded.
When you unzip the file, you'll see a **MoleculeViewerFiles** folder that contains the following folders and files:
#. Move the .mol file that you downloaded from BioTopics into the **data** folder that you downloaded from edX.
#. Edit the MoleculeViewer.html file:
#. In a text editor, open the MoleculeViewer.html file.
#. In line 19 of the MoleculeViewer.html file, change **Example.mol** to the name of your .mol file. For example, if you downloaded the Glucose.mol file, line 19 in your file will look like the following: