MarvinView Example - Molecular property calculations with Chemical Terms

Select a molecule, and choose a Chemical Terms expression from the list, or enter one. Press the Evaluate button to evaluate the expression on the selected molecule.

Chemical Terms expression:

Result:

<script type="text/javascript" type="text/javascript" SRC="../../../marvin.js">
</script>
<script type="text/javascript" type="text/javascript">
<!--
function evaluateChemicalTerms() {
    if(document.MView != null) {
        var e = document.CTForm.Expression.value;
        var result = document.MView.evaluateChemicalTerms(e, getSelectedIndex());
        document.CTForm.Result.value = result;
    } else {
        alert("Cannot evaluate expression on molecule:\n"+
              "no JavaScript to Java communication in your browser.\n");
    }
}

function getSelectedIndex() {
    if(document.MView != null) {
        var index = document.MView.getSelectedIndex();
        if(index < 0) {
            alert("Please select a molecule first.");
        } else {
            return index;
        }
    } else {
        alert("Cannot get index of selected molecule:\n"+
              "no JavaScript to Java communication in your browser.\n");
    }
}

function setCTExpression(expression) {
    document.CTForm.Expression.value = expression;
    document.CTForm.Result.value = "";
}

mview_name = "MView";
mview_begin("../../..", 600, 200);
mview_param("tabScale", "25");
mview_param("background", "#ffffff");
mview_param("molbg", "#ffffff");
mview_param("rows", "1");
mview_param("cols", "3");
mview_param("cell0", "|../../../mols-2d/l-tryptophan.csmol");
mview_param("cell1", "|../../../mols-2d/caffeine.csmol");
mview_param("cell2", "|../../../mols-2d/vitaminc.csmol");
mview_end();
//-->
</script>
<p>
<form NAME="CTForm">
<table BORDER=0>
    <tr>
        <td><a href="../../../help/applications/ChemicalTerms.html">Chemical Terms</a> expression:</td>
        <td ALIGN="right">
            <select NAME="ExpressionSelector" onChange="javascript:setCTExpression(this.value)">
                <option VALUE=""> --- Select expression --- </option>
                <option VALUE="mass()">Molecular weight</option>
                <option VALUE="atomCount()">Atom count</option>
                <option VALUE="bondCount()">Bond count</option>
                <option VALUE="rotatableBondCount()">Rotatable bond count</option>
                <option VALUE="ringCount()">Ring count</option>
                <option VALUE="pKa('acidic', '1')">Strongest acidic pKa</option>
                <option VALUE="pKa('basic', '1')">Strongest basic pKa</option>
                <option VALUE="logP()">logP</option>
                <option VALUE="topologicalPolarSurfaceArea()">Polar surface area</option>
                <option VALUE="acceptorCount()">H bond acceptor count</option>
                <option VALUE="donorCount()">H bond donor count</option>
                <option VALUE="mostStableTautomer()">Most stable tautomer</option>
                <option VALUE="tautomers()">Tautomers</option>
                <option VALUE="name()">IUPAC name</option>
                <option VALUE="molString('smiles')">SMILES</option>
                <option VALUE="(mass() <= 500) &&
                               (logP() <= 5) &&
                               (donorCount() <= 5) &&
                               (acceptorCount() <= 10)">Lipinski rule of 5</option>
                <option VALUE="(mass() <= 300) && 
                               (logP() <= 3) && 
                               (donorCount() <= 3) && 
                               (acceptorCount() <= 3) && 
                               (rotatableBondCount() <= 3) && 
                               (topologicalPolarSurfaceArea() <= 60)">Rule of 3</option>
            </select>
        </td>
    </tr>
    <tr>
        <td COLSPAN=2><textarea NAME="Expression" ROWS=5 COLS=80></textarea></td>
    </tr>
</table>
<p>
<input TYPE=BUTTON VALUE="Evaluate" onClick="evaluateChemicalTerms()">
</p>
<table>
    <tr>
        <td>Result:</td>
    </tr>
    <tr>
        <td><textarea NAME="Result" ROWS=5 COLS=80></textarea></td>
    </tr>
</table>
</form>