Hi Jennifer,

The code in the updated version of 'ChemInteractive' is listed below.  It
also includes a SMARTS search, and a search for the number of C atoms in
the user-drawn structure.  The code for dealing with the backslash
characters in the SMILES strings was suggested by Otis in response to a
request for help on this forum - thanks Otis - and was described by Otis in
an earlier message in this thread.

    JMEsmiles = editor.smiles();
    JMEsmiles = JMEsmiles.replace(/\\/g, '\\\\');   // Necessary to escape
the backslash character
    problemSet[probIndex].smiles =
problemSet[probIndex].smiles.replace(/\\/g, '\\\\');
    // problemSet[probIndex].smiles contains the correct SMILES code,
retrieved from the database (problemSet[probIndex] is a JSON object, and
'smiles' and 'smarts' are columns in the database table)

    // SMILES check for the correct structure.
    var match = Jmol.evaluateVar(myJSmol, '"' + JMEsmiles +
'".find("SMILES","' + problemSet[probIndex].smiles + '")');     // 'match'
is 0 if the SMILES strings don't match, or is the number of matching atoms
if there is a match.

    // SMARTS search for the functional group
    funcGroup = Jmol.evaluateVar(myJSmol, '"' + JMEsmiles +
'".find("SMARTS","' + problemSet[probIndex].smarts + '", false, true)');
 // 'funcGroup' is an array containing the numbers of each atom that
matches the SMARTS expression, or an empty array if there is no match.

    // SMARTS search for the number of C atoms in the structure in the JSME
editor
    var carbons = Jmol.evaluateVar(myJSmol, '"' + JMEsmiles +
'".find("SMARTS","[#6]")');    // 'carbons' is an array containing the
numbers of each carbon atom present.

I hope this helps, if it is not what you wanted, please get back to me.

Mike


Dr Mike Casey
School of Chemistry
UCD
Dublin
01 716 2420

On 20 July 2016 at 22:31, Jennifer L. Muzyka <jennifer.muz...@centre.edu>
wrote:

> Thanks for this encryption code, Otis!
>
> All along I've been skeptical about issues comparing strings, especially
> since I would get them from JSME. Now I figured out how to get JSME to spit
> out SMILES with slashes for E/Z stereochem. And I see that comparing those
> strings is a big problem.  Even JavaScript hiccups on the backslashes.
>
> Mike, if you're willing to share hidden div Jmol SMILES comparison code
> with me, I'd appreciate it. And I'm psyched to see the cool stuff you're
> doing with ChemDoodle and curly mechanism arrows on your site.
> Jennifer
>
> Sent from my iPhone
>
> > On Jul 20, 2016, at 5:12 PM, Otis Rothenberger <osrot...@icloud.com>
> wrote:
> >
> > Mike and Jennifer,
> >
> > Previous chain getting too long (bounce long!), and none of us truncated
> - sorry!
> >
> > Re Quiz Answers, Shhhh, tell no one...
> >
> > This is a classic encryption technique that’s weak and easy for
> cryptographers to break. Your students will never figure it out! It makes
> use of the obscure (and obtuse) XOR logic operator (^). Basically, it
> diddles ascii character binary bits in such a way that the encryption and
> decryption functions are one and the same. The encrypted data (see code
> below) is stored in globalAnswerHolder. While this is a string, don’t try
> to view it. It can contain many non-printable characters. The intKey
> argument is simply an integer encryption key - e.g. 100. Actually, it’s the
> integer’s binary equivalent that is the key.
> >
> > var globalAnswerHolder;
> > function encryptAndDecrypt(strDataToProcess, intKey) {
> >    var strBuilder = "";
> >    for(i=0;i < strDataToProcess.length;i++) {
> >        strBuilder += String.fromCharCode(intKey ^
> strDataToProcess.charCodeAt(i));
> >    }
> >    globalAnswerHolder = strBuilder;
> > }
> >
> > Just pass globalAnswerHolder through the function again to decrypt.
> >
> > Of course your students could do this also, so obscure the function:
> >
> > var theBoyCouldPlay;
> > function Ish(Mark, Knopfler) {
> >    var Kabbible = "";
> >    for(i=0;i < Mark.length;i++) {
> >        Kabbible += String.fromCharCode(Knopfler ^ Mark.charCodeAt(i));
> >    }
> >    theBoyCouldPlay = Kabbible;
> > }
> >
> > Your students will be in Comedic Dire Straits (ouch)!
> >
> > Otis
> > --
> > Otis Rothenberger
> > o...@chemagic.org
> > http://chemagic.org
> >
> >
> >
> ------------------------------------------------------------------------------
> > What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> > patterns at an interface-level. Reveals which users, apps, and protocols
> are
> > consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> > J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning
> > reports.http://sdm.link/zohodev2dev
> > _______________________________________________
> > Jmol-users mailing list
> > Jmol-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic
> patterns at an interface-level. Reveals which users, apps, and protocols
> are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning
> reports.http://sdm.link/zohodev2dev
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to