Thursday, July 14, 2011

Practical Tips on using Google Apps Scripts for Chemistry Applications

A few weeks ago I described our use of Google Apps Scripts, developed by Rich Apodaca and Andrew Lang, as an intuitive interface to information related to a chemistry laboratory notebook. Since then we have been using these tools to actively plan and record experiments (e.g. UC-EXP269) and we have learned their strengths and weaknesses.

The most problematic aspect of Google Apps Scripts running within Google Spreadsheets turns out to be the way caching and refreshing operate. There does not appear to be an obvious way to refresh a single cell. So if a script times out or fails, Google stores that failed output on their servers and will not run it again until some time has elapsed (which seems to be on the order of about an hour). Typing in a new input for that cell will cause the script to run again but entering a previously entered input will only retrieve the cached output, even a failed output. For example, if you have a cell calculating the MW from "benzene" entered in another cell and the script fails for any reason, typing in "ethanol" will get it to run again for the new input, but going back to "benzene" will just pull up the cached output of "Failed".

Nevertheless, I did come across some tricks to force a refresh indirectly. If you insert a row or column then re-enter the desired scripts in the new cells, they will run again. You simply need to then delete the old column with failed outputs. This is fine for simple sheets but it can be a headache for sheets that have several calculation dependencies between cells.

To avoid these complications, simply refresh the entire sheet by duplicating it, deleting the old sheet and then renaming the new one to the original name. The problem now is that it will refresh all the cells, not just those that had failed outputs. And if there are a large number of scripts on that sheet the odds are good that at least one will fail on that particular attempt, especially if several are hitting the same web server.

As a result of all these problems, I would not recommend using these services as I had initially hoped, where a researcher would enter data into a template sheet loaded with scripts to automatically generate a series of calculated outputs. There is a way to achieve this end but it requires thinking about the scripts in a slightly different way.

As I mentioned above, there are tricks for refreshing an entire sheet or a column or row. In order to avoid re-running the scripts that already returned desired outputs, we need to lock them in. This can be done by highlighting the completed cells, copying them (either control-c or Edit->Copy) then pasting them as values (from the Edit menu). Now refreshing will only be done on the cells with failed outputs and these can be locked in as well as soon as they complete.

The downside of this approach is that you lose the information about which script was run to generate the output values. And to change an input requires re-selecting the desired script. But in practice it is so convenient to hit a dropdown menu and hit getMW (for example) that this downside is quite minimal, especially when contrasted with the upside of knowing that others will see your information reliably, independent of how the services are running at a particular time.

Over the past few weeks we have found that some services fail more often than others and it would be advantageous to have some redundancies. This has been particularly problematic for the cactus services recently, which we often use for resolving common names. By using ChemSpiderIDs (CSIDs), the cactus services can be bypassed for several of the gONS services. So a good practice for any application is to generate and lock in SMILES and CSIDs right away from the common name. CAS numbers can be used too but the gChem service that Rich has created sometimes yields multiple CAS numbers and these will fail as input for a subsequent script.

We now have a chemistry Google Apps Scripts spreadsheet to keep track of which inputs are allowed for all the available services, along with information about the output, creator and description. We also keep track of requests and plans for new scripts, marked as "pending" under the status field.


Surprisingly, pasting images "as values" within a Google Spreadsheet cell does not ensure that they will appear consistently - often the cells are just blank upon loading. This makes the idea of using an embedded sheet to display reaction schemes within a wiki lab notebook page not practical. However, using the scripts and a template to generate the scheme by just typing the name, SMILES or CSID for the reactants and product is a very efficient way to generate a consistent look for schemes within a notebook. It only requires a final step of taking the image of the screen and cropping using Paint. For example, here is a scheme thus generated for UC-EXP269.


Taking into account all of these factors, the reaction template sheet we provide does not have by default any scripts running within cells (except for the images). However, it is set up to quickly adapt to other reactions for planning amounts of reactants (by weight or volume), calculating concentrations, yields, melting points (experimental and predicted), solubilities, links to ChemSpider, 2D rendering of structures (including full schemes) and links to interactive NMR spectra using ChemDoodle. It simply requires users to hit one of the 3 drop-down menus (gChem, gCDK or gONS) and select the appropriate script for a particular cell.

Even if the user does not want to use this particular reaction template it still makes sense to make a copy of the template sheet because it is an easy way to copy all of the necessary Google Script without opening the editor.

Labels: , , ,

Friday, February 26, 2010

Robert Grubbs Webinar on March 2, 2010

Honeywell Nobel Interactive Studio will host an interactive seminar with Robert Grubbs at 11:00 ET on March 2, 2010. Sign up here. Questions can be submitted via email, Twitter, Facebook or Orkut.
2005 Nobel Laureate in Chemistry, Robert Grubbs, will discuss how the availability of a catalyst that promotes scrambling of the fragments of a carbon-carbon double bond by a metathesis reaction has led to a variety of commercial applications including the production of tough polymers and highly functionalized pharmaceuticals.

Labels: , , , ,

Thursday, August 20, 2009

My talk at ACS FA09 on Social Networking Tools and Teaching Chemistry

Yesterday (August 19, 2009) I gave my last talk at the American Chemical Society meeting in Washington. I presented on Using social networking tools a la carte for organic chemistry education: Wikis, blogs, Second Life, and more for the Symposium on Using Social Networking Tools to Teach Chemistry, organized by Laura and Henry Pence:
12:05 PM Wikis in chemical education: The best of two worlds
Laura E. Pence
12:25 PM ChemPaths: Learning to meander — an online portal to ChemEd DL resources for intrinsically linked learning
Justin M. Shorb, John W. Moore
12:45 PM ChemEd DL WikiHyperGlossary
Robert E. Belford, J. W. Moore, Daniel Berleant, Michael Bauer, Jon L Holmes, Kyle E. Yancey
1:05 PM Social media: Immersion and its discontents
Elizabeth M. Dorland
1:35 PM Using social networking tools a la carte for organic chemistry education: Wikis, blogs, Second Life, and more
Jean-Claude Bradley, Andrew Lang
1:55 PM SNS, IM, and textng vs. traditional e-mail and voice messaging as a means of facilitating instructor-student contact: Trends and habits of student usage, and techniques to avoid electronic overload (or withdrawal)
Robert B. Gregory
2:15 PM Faculty development, collaborative inquiry, and Web 2.0
Joanne L. Stewart
2:35 PM Are netbooks the next big thing in the chemistry classroom?
Harry E. Pence
2:55 PM Managing laboratory research data using cloud computing as an organizational tool
Harry E. Pence, Jacqueline Bennett
It was a really entertaining symposium. Laura Pence talked about using Wikispaces (the same platform I use) for student projects and emphasized how helpful it is to compare wiki page versions to evaluate each student's contributions. Justin Shorb presented on his work to wikify a chemistry textbook. Despite a broken arm, Bob Belford did a great job in presenting his Wikihyperglossary project. It marks up chemistry terms on web pages, similar to the approach taken by ChemMantis.

Liz Dorland provided a wonderful overview of how Second Life can be used from an educational standpoint, very much complimentary to the content I had on my slides. There is just so much content and so many projects now on that virtual world that it is difficult to appreciate without actually going in and taking a tour but sometimes a good talk can motivate people to give it a closer look.

Robert Gregory's talk was very funny and somewhat shocking: he gave out his cell phone and asked his students to contact him 24/7 - including 2:00 AM when he was sleeping. Joanne Stewart gave an overview of how inorganic teachers kept in contact using various social networking tools and valuable it was for both collaboration and support.

Harry Pence
gave two very humorous talks at the end. The most interesting point for me was his collaboration with Jacqueline Bennett, who used Google Spreadsheets to collect experimental results from her students. An example of that work recently appeared in Green Chemistry, 2009, 11, 166 - 168. This is especially relevant for our research - because we also use Google Spreadsheets to aggregate results - but her reaction involves finding the right solvent for mixing an aldehyde and amine and obtaining a pure imine as a precipitate, exactly the same approach for our preparation of Ugi products. Perhaps there is a future collaboration there.

All of the presentations were recorded and I will post a link when available.

Here is the summary of my talk and the recording:

Jean-Claude Bradley describes the use of social networking tools to teach undergraduate organic chemistry. Public free wikis can be used effectively to manage class information as well as serve as a versatile platforms to process student assignments and provide rapid feedback. Examples of using Second Life to deliver quizzes, play games and offer students an environment to create projects involving 3D molecules, spectra and posters are detailed. The continuously evolving role of blogs, podcasting, screencasting and newer faster interactive platforms such as FriendFeed will be outlined. New technologies create the need for new skills to be taught to students - some relating to networking and some involving knowlege of the language to navigate the chemical webspace (such as SMILES and InChI).


Labels: , , , , , ,

Tuesday, August 18, 2009

Spectral Game talk at ACS Fall 09

Yesterday (August 17, 2009) I gave my talk on the Spectral Game at the Using Technology to Enhance Learning in Organic Chemistry symposium at the American Chemical Society meeting. I was not able to attend the entire symposium but luckily I did catch David Soulby's talk on using Google groups to distribute NMRs for labs that require many students to submit samples. I am a fan of using free and hosted services to simplify workflows of all types.

Also in attendance at the symposium were Liz Dorland and Bob Hanson. It was good to catch up with them. Bob shared a story of how he has been assigning his students tasks in his organic chemistry class which lead to updating Wikipedia. There is so much potential for using the educational infrastructure to create better scientific content for everyone.

My talk on the Spectral Game highlighted the role of openness in teaching and research to create new educational tools, especially for learning NMR. Tony Williams said a few words at the end about ChemSpider, RSC and some upcoming opportunities to publish synthesis articles on ChemSpider.

Labels: , , , , , , , ,

Thursday, April 02, 2009

The ChemTiles Game

In another example of code and content re-mixing for educational purposes, Andrew Lang and I have adapted many of the elements of the Spectral Game and tiles from the Second Life quizzes I traditionally gave for my introductory organic chemistry course. Many of these tiles were originally created for use in Unreal Tournament.

The concept is simple: tiles represent images or statements that are either true or false in any context. By marking them as true or false and ensuring that one true tile is present in a mix of a number of false ones, games can be designed that vary from rooms within a maze to obelisks offering a selection of floating images in Second Life.

In the current implementation, the tiles appear in a web browser. Clicking on the correct tile produces a new random selection. Clicking on a false tile stops the game and records the player's score. Following the same structure as the most recent implementation of the Spectral Game, the first 10 queries present only two tiles. As the game progresses the difficulty level increases and more tiles are included.

Whereas the Spectral Game obtained spectra and molecules from ChemSpider, this game taps into a set of 256 x 256 pixel images in a Flickr group. Using Flickr lets us leverage the ability to easily tag images, which can then be used by players to select different topics to practice.

I'll be giving a prize to the student in my current CHEM241 class who scores highest by 10:50 ET April 10, 2009. The student must play under the "all tags" option, which covers all the material before test 1, given the following week. Students can also practice different modules by selecting tags like Lewis Structures, Hybridization, Nomenclature, Newman Projections, etc.

I think that this approach of rapid remixing of code and content on free hosted platforms (like Flickr or ChemSpider) is really the future of technology in education. It will be difficult for heavy top down - and expensive - systems to compete against the incredible flexibility of these lighweight and loosely connected initiatives led by educators with the simple motivation of just experimenting with teaching in a better way.


Labels: , ,

Sunday, December 14, 2008

Crowds, Solubility and the Future of Organic Chemistry

This week I participated in a Social Media Day at NIST. During my talk I provided an overview of our current work in using Web2.0 tools for doing Open Notebook Science in fields related to chemical synthesis and drug discovery.

During my talks I generally try to place our work in context and give the audience a sense of where I see science evolving. I often start with the increasingly important role of openness and at some point follow up with this slide showing the shift of scientific communication from human-to-human to machine-to-machine. My position is that we are entering a middle phase of human-to-machine and machine-to-human communication. This is essentially what the semantic web (Web3.0) is all about and the social web (Web2.0) is the natural gateway.


Giving a talk at NIST was particularly meaningful for me as an organic chemist. This is an organization that has always been associated with authoritative and reliable measurements. In chemistry, many properties of compounds are deemed important enough to be measured and recorded in databases.

Given that the vast majority of organic chemistry reactions are carried out in non-aqueous solvents, isn't it surprising that the solubility of readily commercially available compounds in common solvents is not considered a basic property, like melting point or density? You won't routinely find these values in NIST databases or ChemSpider or even toll-access databases like Beilstein and SciFinder. Tim Bohinsky has reviewed the literature to provide an idea of what is available for a few classes of compounds.

I think that the reason for this lack of interest in solubility measurements relates to the way synthetic organic chemists have learned to think about their workflows. Generally, the researcher sets up an experiment with the intention of preparing and isolating a specific compound. The role of the solvent is usually just to solubilize the reactants - it is then commonly evaporated for chromatographic purification of the product. Even in combinatorial chemistry experiments where products are not purified for a rough screening, the expectation is that compounds of interest will be purified and characterized at some point.

The advantage of this approach is that it is relatively reliable. Column chromatography and HPLC may be time consuming and expensive but these purification techniques will work most of the time. However, they are difficult to scale up and are not environmentally friendly.

Sometimes, during the course of a synthesis, a compound crystallizes either from the reaction itself or by a recrystallization attempt. When this happens, it is a lucky day. The problem is that you can't routinely guarantee purification of compounds this way. In the academic labs where I worked, that was always the case, although there were rumors of gurus with magic hands that could get crystals more often than most. Before chromatography became widely adopted I am sure chemists were much more adept at recrystallization by necessity.


But now technology is allowing for different ways of thinking about organic chemistry. Instead of attempting to make a specific compound, why not think about making any compound that meets certain criteria? If the objective is to inhibit an enzyme, then docking or QSAR predictions would be the first criterion. But we can add to that the requirement for the compound to be made from cheap starting materials using convenient reaction conditions and that it be purifiable by crystallization.

This last requirement would be predictable if we had robust models for non-aqueous solubility. We can only do that if we gather enough solubility measurements - and that is the point of the Open Notebook Science solubility challenge. We want it to become as easy to look up or predict the solubility of any compound in any solvent at any temperature as it is to Google. For a taste of things to come, play with Rajarshi Guha's chemistry Google Spreadsheet that calls web services to calculate weights and volumes of compounds based only on the common name and number of desired millimoles.


In thinking about what the future will look like it is tempting to imagine complex extrapolations of current concepts caught in the first part of the hype cycle - nanotechnology and artificial intelligence are good recent examples.

But much of the real progress is reflected by a simplification that is almost invisible and underestimated in its power to change the way things are done. Blogs, wikis and RSS are a wonderful example of that. Technically, these are very simple software components - probably not something people in the 1980s would have predicted to be the "advanced technology" to explode in the 21rst century. But it is precisely that simplicity, coupled with reliable free hosted services, that accounts for the explosive adoption of these tools.

Similarly, as a graduate student in the late 1980's, I imagined complex chemical reactions in academia by now to be carried out routinely by robots and synthetic strategies to be designed by advanced AI. From a purely technical standpoint, academic research probably could have evolved in that way but it didn't. That vision simply was not a priority for funding agencies, researchers and companies.

But now the Open Science movement, fueled by near zero communication costs, can add diversity to the way research is done. I'm predicting it will favor simplification in organic chemistry. Here's why:

In a fully Open Crowdsourcing initiative, where all responses and requested tasks are made public in real time, the numbers will dictate what gets done. There will always be more people with access to minimal resources than people with access to the most well equipped labs. Thus contributions to the solution of a task will likely be dominated by clever use of simple technology. This is what we expect to see for the ONS solubility project. As long as competent judges are available to evaluate the contributions and strictly rely on proof, the quality of the generated dataset should remain high.

Note that this may not be the expected outcome for crowdsourcing projects where the responses are closed (e.g. Innocentive). Responses to RFP's from traditional funding agencies, where funds are allocated to specific groups before work is done, are also unlikely to yield simplicity. Even to be eligible to receive those funds generally requires being part of an institution with a sizeable infrastructure. I'm not saying that traditional funding will disappear - just that new mechanisms will sprout to fund Open Science. The sponsorship of our ONS challenge with prizes from Submeta and Nature is a good example.

For synthetic organic chemistry, it doesn't get much simpler than mix and filter. We've already shown that such simple workflows can be automated with relatively low-cost solutions, with the results posted in real time to the public. Add to this crowdsourcing of the modeling of these reactions and we start to approach the right side of the diagram at the top of this post. See Rajarshi's initial model of our solubility data to date to see how it adds one more piece to the puzzle.

Labels: , , ,

Wednesday, January 09, 2008

Campus Technology Article about Molecules in Second Life

Linda Briggs wrote a nice article in Campus Technology about using Second Life to teach and highlighted the chemistry application that I used last term:
Creating Life-Size Molecules in Second Life

A Conversation with Drexel University's Jean-Claude Bradley

1/9/2008

By Linda L Briggs

CT: Conversely, what are some things that work really well in Second Life?

JCB: One thing new that I've done this term is have students do a project in Second Life.

CT: Yes, you recently wrote in your blog that one of your students created a life-size model of a molecule as part of that. That sounded really cool.

JCB: Right. To be able to stand next to a molecule that is as tall as you are, and to have your teacher be able to walk around it with you and comment,... that's pretty useful.

[....]

CT: Do you have advice for instructors who want to integrate Second Life into their course?

JCB: You should have a really good reason to do it. The best advice is to find another teacher who is actually using it, and try to experience what the student is experiencing. You'll get some ideas and advice from that. I was just talking to another teacher an hour ago who might be doing some things in Second Life. She's also an organic chemistry teacher. I told her, just send your students to Drexel Island; have them interact with my students, click around on the quizzes, and if you think it might make sense, you can spawn off from that.

A lot of people have bad experiences in Second Life because they don't have a good reason for going there. It's like having people go to the Internet without a Web address. You want to be guided. That's the best possible scenario.

It's just another tool. I wouldn't teach exclusively on Second Life. We have WebCT Blackboard; I have my wiki; I have my blogs; and those things all have their strengths. You've got to leverage them all.
Drexel Island also got a mention in Matt Villano's article in Campus Technology: 13 Tips for Virtual World Teaching

Labels: , ,

Monday, March 26, 2007

Second Life at the ACS and Quizzes

Yesterday, I gave my first talk at the March07 ACS meeting on Teaching Organic Chemistry with Blogs and Wikis. The screencast is now available.

It was part of a symposium on Using Social Networking Tools to Teach Chemistry organized by Harry Pence and Andrea Gay. Joanna Scott gave a most interesting talk about Nature's experimentation with Second Life and the great possibilities for communicating research work. Harry is also involved with Second Life. Indeed I met him in world by accident a few days ago!

Largely because of Beth Ritter-Guth's tireless dedication to implementing educational opportunities in Second Life, I am finally coming around and seeing the potential for teaching and research. With the help of Eloise Pasteur (SL name), Beth has created an adaptation of the EduFrag quizzes for second life.

The rules are the same but the interface is very different from Unreal Tournament. Click on the obelisk to get the quiz started. Four images will appear and only one will be correct. Click on the correct one to go to the next set. Clicking on an incorrect image will make you start over. If you make it past the 20th room you will be a rewarded with a picture of my cat yawning.

The material in the current quiz is on introductory organic chemistry (Lewis structures, Newman projections, nomenclature, etc.) and I will make good use of it in the class I am teaching next week.

Give it a try and let me know how it works. The quiz is located in the Open Notebook Science building on Eduisland (slurl). We'll be adding more material related to UsefulChem there shortly (thus the use of the Blue Obelisk).

Labels: , , , ,

Creative Commons Attribution Share-Alike 2.5 License