<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>So much to do, so little time</title>
	<atom:link href="http://blog.rguha.net/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.rguha.net</link>
	<description>Trying to squeeze sense out of chemical data</description>
	<lastBuildDate>Thu, 02 Sep 2010 02:10:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Back from Boston</title>
		<link>http://blog.rguha.net/?p=743</link>
		<comments>http://blog.rguha.net/?p=743#comments</comments>
		<pubDate>Fri, 27 Aug 2010 02:54:10 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[cheminformatics]]></category>
		<category><![CDATA[acs]]></category>
		<category><![CDATA[boston]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=743</guid>
		<description><![CDATA[Another ACS National Meeting, this time in Boston, is over and I&#8217;m finally home. I gave two talks, one on issues surrounding the data deluge in modern drug discovery and another one on structure activity landscapes. There were a number of great sessions in CINF, COMP and MEDI, with some thought-provoking talks. I especially liked a talk given [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Another ACS National Meeting, this time in Boston, is over and I&#8217;m finally home. I gave two talks, one on issues surrounding the <a href="http://www.slideshare.net/rguha/datadrivenlifesciences-thepyramidsmeetthetowerofbabel">data deluge in modern drug discovery</a> and another one on <a href="http://www.slideshare.net/rguha/guha-sali-2010">structure activity landscapes</a>. There were a number of great sessions in CINF, COMP and MEDI, with some thought-provoking talks. I especially liked a talk given by <a href="http://www.zbh.uni-hamburg.de/staff.php?mode=_details&amp;id=seebeck&amp;language=en">Birte Seebeck</a>, in which they abstracted the idea of <a href="http://dx.doi.org/10.1021/ci7004093">SALI</a> (which focuses on structural features of ligands) to one that considers interactions betwen a ligand and a receptor &#8211; thus identifying activity hotspots within a protein site that actually cause the activity cliffs. The idea is somewhat similar to <a href="http://dx.doi.org/10.1021/jm030331x">SiFT&#8217;s</a>, but differs in that it takes into account the SAR. (As a side note, I discovered that one of our landscape papers is in the <a href="http://www.drugdiscoverytoday.com/25-hottest-articles/">Top 25 in Drug Discov. Today</a>). Gerry Maggiora gave a very thought provoking talk on the topic of activity cliffs,  highlighting the fact that there&#8217;s a lot of open questions that need to be looked at in this area.  <a href="http://www.eyesopen.com/staff">Ant Nicholls</a> of spoke on the disconnect between molecular modeling in academia industry. His three suggestions: <em>rigorous statistics training</em>, <em>stop government funding for all but basic research</em> and <em>all remaining funding must have an experimental component</em>.</p>
<p style="text-align: justify;">I also met up with a number of old friends, met some people with whom I&#8217;d only had <a href="http://twitpic.com/2i667x">email or FriendFeed conversations</a> and made new friends. We had a <a href="http://www.blueobelisk.org/">Blue Obelisk</a> dinner, with Christoph <a href="http://blueobelisk.sourceforge.net/wiki/Blue_Obelisk_Awards">awarding</a> a Blue Obelisk to <a href="http://vedina.users.sourceforge.net/">Nina Jeliazkova</a>. This time round, we got a whole restaraunt to ourselves, thanks to <a href="http://www.ebi.ac.uk/steinbeck/">Christoph</a>, so conversations was much easier! Also the financial contribution towards the dinner from <a href="http://ualr.edu/rebelford/">Bob Belford</a> and <a href="http://employees.oneonta.edu/pencehe/">Harry Pence</a> was very much appreciated.</p>
<p style="text-align: justify;">At this meeting I finally got round to making use of Twitter &#8211; it turns out it was quite useful for keeping running notes during a talk, as well as keeping track of other parallel sessions. Thanks to Egon for those extra tweets (though maybe Egon and I were being a bit <a href="http://summarizr.labs.eduserv.org.uk/?hashtag=acs_boston">obssesive</a>!?). A quick <a href="http://rguha.net/atv/atv.html">hack</a> I put together just before the meeting allowed Tweeters to visualize the Twitter stream emanating from the ACS meeting as a word cloud. Obviously, it works better with more people tweeting, but cute nonetheless.</p>
<p style="text-align: justify;">As always, CINF hosts some great receptions and this meetings&#8217; ones were no exception. Though the weather didn&#8217;t cooperate, the convention center was pretty nice in providing free wireless. This came in especially useful as we had a speaker with three talks in our program but was unable to make it to the meeting. With the wireless available, we successfully connected with him over Skype, and with me switching slides, were able to have him present (audio and video) his work. Definitely not a trend we want to encourage, but for emergencies, &#8220;Skype talks&#8221; are great!</p>
<p style="text-align: justify;">At this meeting I also organized an experimental symposium consisting of <a href="http://rguha.net/cinftmp/flash.html">lightning talks</a> &#8211; 8 minutes talks on arbitrary (but hopefully interesting) topics in chemical information and cheminformatics. While we only had 5 speakers, we had a great set of talks &#8211; I&#8217;m still amazed at how <a href="http://web.mit.edu/greengp/people/rwest.html">Richard West</a> got through 24 slides in 7 minutes so smoothly! While it could have been publicized better, we got a lot of good feedback and will be running a revamped version in Denver, next fall.</p>
<p style="text-align: justify;">
<p style="text-align: justify;">Overall a pretty good meeting, and my last meeting as CINF Program Chair. I had a great time in this role, and with the help of a very capable Program Committee, I think we were able to successfully develop interesting multidisciplinary programs over the last four meetings. As I step down, <a href="http://www.linkedin.com/pub/rachelle-bienstock/5/720/912">Rachelle Bienstock</a> from the NIEHS will take over as Program Chair, and I wish her all the best. However, I&#8217;m not done with CINF just yet <img src='http://blog.rguha.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I&#8217;ve been elected as Chair-Elect of CINF for 2011 so will be switching roles (though I certainly hope to continue contributing to the CINF program in the future).</p>
<p style="text-align: justify;">I&#8217;ll end with three suggestions for the ACS: <strong>1</strong>. Seriously consider letting divisions to drop Thursdays <strong>2</strong>. Reduce registration fees &amp; do a better job on hotel rates <strong>3</strong>. Fix the meetings to one or two places (preferably San Francisco).</p>
<p style="text-align: justify;"><strong>Update: </strong>I had misstated Anthony Nicholl points from his presentation. The post is updated to the correct that.</p>
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=743</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SALI in Bulk</title>
		<link>http://blog.rguha.net/?p=738</link>
		<comments>http://blog.rguha.net/?p=738#comments</comments>
		<pubDate>Wed, 11 Aug 2010 04:31:12 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[cheminformatics]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[cdk]]></category>
		<category><![CDATA[chembl]]></category>
		<category><![CDATA[fingerprint]]></category>
		<category><![CDATA[landscape]]></category>
		<category><![CDATA[qsar]]></category>
		<category><![CDATA[sali]]></category>
		<category><![CDATA[sar]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=738</guid>
		<description><![CDATA[Sometime back John Van Drie and I had developed the Structure Activity Landscape Index (SALI), which is a way to quantify activity cliffs &#8211; pairs of compounds which are structurally very similar but have significantly different activities. In preparation for a talk on SALI at the Boston ACS, I was looking for SAR datasets that [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Sometime back <a href="http://www.vandrieresearch.com/">John Van Drie</a> and I had developed the Structure Activity Landscape Index (<a href="http://dx.doi.org/10.1021/ci7004093">SALI</a>), which is a way to quantify activity cliffs &#8211; pairs of compounds which are structurally very similar but have significantly different activities. In preparation for <a href="http://abstracts.acs.org/chem/240nm/program/divisionindex.php?act=presentations&amp;val=The+Emerging+Concepts+of+Activity+Landscapes+and+Activity+Cliffs+and+their+Role+in+Drug+Research&amp;ses=The+Emerging+Concepts+of+Activity+Landscapes+and+Activity+Cliffs+and+their+Role+in+Drug+Research&amp;prog=23771">a talk on SALI</a> at the <a href="http://portal.acs.org/portal/acs/corg/content?_nfpb=true&amp;_pageLabel=PP_SUPERARTICLE&amp;node_id=2061&amp;use_sec=false&amp;sec_url_var=region1&amp;__uuid=a07a6bc3-9f35-4b84-902a-5b91f83232c4">Boston ACS</a>, I was looking for SAR datasets that contained cliffs. It turns out that <a href="http://www.ebi.ac.uk/chembl/">ChEMBL</a> is a a great resource for SAR data. And with the EBI providing database dumps it&#8217;s very easy to query across the entire collection to find datasets of interest.</p>
<p style="text-align: justify;">For the purposes of this talk, I wanted to see what the datasets looked like in terms of the presence (or absence of cliffs). Given that the idea of an activity cliff is only sensible for ligand receptor type interactions, I only considered compound sets associated with binding assays. Furthermore, I only considered those assays which involved human targets, had a confidence score greater than 8 and contained between 75 and 500 molecules. (If you have an Oracle installation of ChEMBL then this <a href="http://gist.github.com/518455">SQL snippet</a> will get you the list of assays satisfying these constraints).</p>
<p style="text-align: justify;">This gives us 31 assays, which we can now analyze. For the purposes of this note, I evaluated the CDK hashed fingerprints and used the standardized activities to generate the pairwise SALI values for each of the datasets (performing the appropriate log transformation  of the activities when required). The matrices that represent the pairwise SALI values are plotted in the heatmap montage below (the ChEMBL assay ID is noted in each image) where black represents the minimum SALI value and white represents the maximum SALI value for that dataset. (See the <a href="http://dx.doi.org/10.1021/ci7004093">original paper</a> for more details on this representation.) Clearly, the &#8220;roughness&#8221; of the activity landscape differs from dataset to dataset.</p>
<p style="text-align: justify;">At this point I haven&#8217;t looked in depth into each dataset to characterize the landscapes in more detail, but this is a quick summary of multiple datasets. (Though a few datasets contain cliffs which are derived from stereoiomers and hence may not actually be real cliffs &#8211; since their activity difference may be small, but will look structurally identical to the fingerprint).</p>
<p style="text-align: justify;">An alternative and useful representation is to convert the SALI values for a dataset into an <a href="http://en.wikipedia.org/wiki/Empirical_distribution_function">empirical cumulative distribution function</a> to provide a more quantitative view of how cliffs are distributed within a landscape. I&#8217;ll leave those details for the talk.</p>
<p style="text-align: center;"><a href="http://blog.rguha.net/wp-content/uploads/2010/08/chembl-sali.png"><img class="aligncenter size-medium wp-image-739" title="chembl-sali" src="http://blog.rguha.net/wp-content/uploads/2010/08/chembl-sali-300x240.png" alt="" width="600" height="400" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=738</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Job Openings at the NCGC</title>
		<link>http://blog.rguha.net/?p=729</link>
		<comments>http://blog.rguha.net/?p=729#comments</comments>
		<pubDate>Tue, 03 Aug 2010 23:50:20 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[job]]></category>
		<category><![CDATA[ncgc]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=729</guid>
		<description><![CDATA[I&#8217;ve been at the NCGC for a little more than a year and I can say that it&#8217;s a great place to work &#8211; smart people, cutting edge projects in chemical genomics and chemical biology, opportunities to be involved in all aspects of HTS projects and fresh data (lots of it). Now there&#8217;s opportunities for [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;ve been at the <a href="http://ncgc.nih.gov/">NCGC</a> for a little more than a year and I can say that it&#8217;s a great place to work &#8211; smart people, cutting edge projects in chemical genomics and chemical biology, opportunities to be involved in all aspects of HTS projects and fresh data (lots of it). Now there&#8217;s opportunities for others to join the fun!</p>
<p style="text-align: justify;">Sometime back, my colleague <a href="http://tripod.nih.gov/">Trung</a> posted an ad for a <a href="http://tripod.nih.gov/?page_id=106">software engineer position</a>, primarily working on our chemogenomics data application. Now, we&#8217;re also looking for a <a href="http://www.biospace.com/jobs/job-listing/?job_id=278323">research informatics scientist</a>. See the <a href="http://www.biospace.com/jobs/job-listing/?job_id=278323">detailed ad</a> for more information. For both positions, see the ads themselves for contact details. If you&#8217;d like to chat face to face I&#8217;ll be at the ACS in Boston this month, so drop me a line and we can chat in Boston.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=729</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CINFlash Deadline Approaching</title>
		<link>http://blog.rguha.net/?p=727</link>
		<comments>http://blog.rguha.net/?p=727#comments</comments>
		<pubDate>Mon, 02 Aug 2010 14:17:53 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[acs]]></category>
		<category><![CDATA[cinf]]></category>
		<category><![CDATA[lightning]]></category>
		<category><![CDATA[talk]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=727</guid>
		<description><![CDATA[One more week to go (Aug 7 is the deadline) to put in short abstracts for the CINFlash lightning talk symposium at the fall ACS meeting in Boston this month. This is your chance for 6 minutes of fame!
]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">One more week to go (Aug 7 is the deadline) to put in short abstracts for the <a href="http://rguha.net/cinftmp/flash.html">CINFlash</a> lightning talk symposium at the fall ACS meeting in Boston this month. This is your chance for 6 minutes of fame!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=727</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Benchmarking the CDK Hybridization Fingerprinter</title>
		<link>http://blog.rguha.net/?p=718</link>
		<comments>http://blog.rguha.net/?p=718#comments</comments>
		<pubDate>Sat, 17 Jul 2010 01:59:23 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[cheminformatics]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[cdk]]></category>
		<category><![CDATA[fingerprint]]></category>
		<category><![CDATA[hybridization]]></category>
		<category><![CDATA[similarity]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=718</guid>
		<description><![CDATA[This morning Egon reported that he had implemented a new fingerprinter for the CDK, which only considered hybridization rather than looking at aromaticity. As a result this approach does not require aromaticity perception. I took a quick look to see how it performs in a virtual screening benchmark. Firstly, it&#8217;s faster than the other CDK [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">This morning <a href="http://chem-bla-ics.blogspot.com">Egon</a> <a href="http://chem-bla-ics.blogspot.com/2010/07/new-cdk-default-fingerprinter.html">reported</a> that he had implemented a new <a href="http://pele.farmbio.uu.se/nightly/cdk-javadoc-1.3.5.git/org/openscience/cdk/fingerprint/package-frame.html">fingerprinter</a> for the <a href="http://sourceforge.net/apps/mediawiki/cdk/index.php?title=Main_Page">CDK</a>, which only considered hybridization rather than looking at aromaticity. As a result this approach does not require aromaticity perception. I took a quick look to see how it performs in a virtual screening benchmark. Firstly, it&#8217;s faster than the other CDK hashed fingerprints &#8211; 15,030 fingerprint calculations took ~ 60s with the hybridization only fingerprint. In contrast the extended fingerprint took 80s for the same set of molecules. To test the utility of the fingerprint in a virtual screening scenario I evaluated enrichment curves (see <a href="http://blog.rguha.net/?p=29">here</a> for a comprehensive comparison of CDK fingerprints) using the AID 692 <a href="http://www.pharmchem.tu-bs.de/lehre/baumann/MUV.html">MUV benchmark dataset</a>. The plots below show the enrichment curves for the first 5% of the database and the entire database. The red curve corresponds to random selections. (In this experiment the database consists of 15,000 decoys and 30 actives). The enrichment factor for the standard, extended and hybiridization only fingerprints were 0.94, 1.06 and 1.38 respectively.</p>
<p style="text-align: justify;">Overall, the hybridization only fingerprint performs comparably to the extended fingerprint and better than the standard one. But at a small percentage of the database screened, it appears that this fingerprint outperforms both. Of course, this is only one dataset, and more MUV datasets should be analyzed to get a more comprehensive view.</p>
<p style="text-align: justify;"><a href="http://blog.rguha.net/wp-content/uploads/2010/07/comp5.png"><img title="comp5" src="http://blog.rguha.net/wp-content/uploads/2010/07/comp5-300x300.png" alt="" width="300" height="300" /></a>&nbsp;&nbsp;&nbsp;<a href="http://blog.rguha.net/wp-content/uploads/2010/07/compfull.png"><img title="compfull" src="http://blog.rguha.net/wp-content/uploads/2010/07/compfull-300x300.png" alt="" width="300" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=718</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTS and Message Queues</title>
		<link>http://blog.rguha.net/?p=651</link>
		<comments>http://blog.rguha.net/?p=651#comments</comments>
		<pubDate>Sun, 11 Jul 2010 21:00:21 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jms]]></category>
		<category><![CDATA[messaging]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[queue]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=651</guid>
		<description><![CDATA[In my previous post I discussed how we&#8217;d like to automate some of our screens &#8211; starting from the primary screen, going through data processing and compound selection and completing the secondary (follow up) screen. A key feature of such a workflow is the asynchronous nature of the individual steps. Messaging and Message queues (MQ) provide [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">In my <a href="http://blog.rguha.net/?p=690">previous post</a> I discussed how we&#8217;d like to automate some of our screens &#8211; starting from the primary screen, going through data processing and compound selection and completing the secondary (follow up) screen. A key feature of such a workflow is the asynchronous nature of the individual steps. Messaging and <a href="http://en.wikipedia.org/wiki/Message_queue">Message queues</a> (MQ) provide an excellent approach to handling this type of problem.</p>
<h2>Message queue systems</h2>
<p style="text-align: justify;"><span style="font-size: 13.2px;">A number of such MQ systems are available such as <a href="http://activemq.apache.org/">ActiveMQ</a>, <a href="http://www.rabbitmq.com/">RabbitMQ</a> and so on. See <a href="http://wiki.secondlife.com/wiki/Message_Queue_Evaluation_Notes">here</a> for a comparison of different MQ systems. Given that we already use Oracle for our backend databases, we use <a href="http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96587/qintro.htm">Oracle Advanced Queue</a> (AQ). One advantage of this is that we can store the messages in the database, allowing us to keep a history of a screen as well as use SQL queries to retrieve messages if desired. Such storage can obviously slows things down, but our message throughput is low enough that it doesn&#8217;t matter for us.</span></p>
<p style="text-align: justify;">In this post I&#8217;ll briefly describe how I set up a queue on the database side and show the code for a Java application to send a message to the queue and retrieve a message from the queue. The example will actually use the <a href="http://java.sun.com/products/jms/">JMS</a> API, which Oracle AQ implements. As a result, the code can trivially swap out AQ for any other JMS implementation.</p>
<h2>Creating queues &amp; tables</h2>
<p style="text-align: justify;">The first step is to create a queue table and some queues in the database. The PL/SQL to generate these is</p>
<div class="codecolorer-container plsql twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="plsql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00F;">BEGIN</span><br />
<span style="color: #00F;">DBMS_AQADM</span><span style="color: #00F;">.</span>create_queue_table<span style="color: #00F;">&#40;</span><br />
queue_table <span style="color: #00F;">=</span>&amp;gt<span style="color: #00F;">;</span> <span style="color: #F00;">'test_qt'</span><span style="color: #00F;">,</span><br />
queue_payload_type <span style="color: #00F;">=</span>&amp;gt<span style="color: #00F;">;</span> <span style="color: #F00;">'SYS.AQ$_JMS_MESSAGE'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">;</span><br />
<br />
<span style="color: #00F;">DBMS_AQADM</span><span style="color: #00F;">.</span>create_queue<span style="color: #00F;">&#40;</span><br />
queue_table <span style="color: #00F;">=</span>&amp;gt<span style="color: #00F;">;</span> <span style="color: #F00;">'test_qt'</span><span style="color: #00F;">,</span><br />
queue_name <span style="color: #00F;">=</span>&amp;gt<span style="color: #00F;">;</span> <span style="color: #F00;">'input_q'</span><span style="color: #00F;">,</span><br />
retention_time <span style="color: #00F;">=</span>&amp;gt<span style="color: #00F;">;</span> <span style="color: #00F;">DBMS_AQADM</span><span style="color: #00F;">.</span>INFINITE<span style="color: #00F;">&#41;</span><span style="color: #00F;">;</span><br />
<br />
<span style="color: #00F;">DBMS_AQADM</span><span style="color: #00F;">.</span>start_queue<span style="color: #00F;">&#40;</span><span style="color: #F00;">'input_q'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">;</span><br />
<span style="color: #00F;">END</span><span style="color: #00F;">;</span><br />
<span style="color: #00F;">/</span><br />
quit</div></td></tr></tbody></table></div>
<p style="text-align: justify;">So we&#8217;ve created a queue table called <em>test_qt</em> which will hold a queue called <em>input_q</em>. The plan is that we&#8217;ll have a process listening on this queue and processing each message as it comes and another process that will send a specified number of messages to the queue. The <em>queue_payload_type</em> argument to the create call, indicates that we can store any of the standard <a href="http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ac24862_.htm">JMS message types</a> (though we&#8217;ll be focusing on the text message type). We&#8217;ve also specified that for the <em>input_q</em> queue, messages will be retained in the database indefinitely. This is useful for debugging and auditing purposes.</p>
<h2>Message producers &amp; consumers</h2>
<p style="text-align: justify;">OK, with the queues set up, we can now write some Java code to send messages and receive them. In this example, the receiving code will actually run continuously, blocking until messages are received.</p>
<p style="text-align: justify;">This example extends <a href="http://download.oracle.com/docs/cd/E17476_01/javase/1.5.0/docs/api/java/util/TimerTask.html">TimerTask</a>. The strategy is that when the listener receives a message, it will create a new instance of this task and schedule it immediately on a new thread. As a result the message processing logic is contained within the <strong>run</strong> method. At this stage, we only consider messages that are of type <a href="http://www.apache-korea.org/cactus/api/framework-13/javax/jms/TextMessage.html">TextMessage</a>. If that&#8217;s the case we simply extract the payload of the message and print it to STDOUT.</p>
<p style="text-align: justify;">You&#8217;ll note that we also create a unique listener ID and include that in the output. This is handy when we run multiple listeners and want to check that messages are being received by all of them.</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> QueueExample <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">TimerTask</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> <span style="color: #003399;">URL</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;jdbc:oracle:thin:USER/PASSWD@HOST:PORT:SID&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Message mesg<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/* Useful to differentiate between multiple instances of the listener */</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> listenerID <span style="color: #339933;">=</span> UUID.<span style="color: #006633;">randomUUID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> schema <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;wtc&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> qTable <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;test_qt&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> qName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;input_q&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> QueueConnection con <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> QueueSession sess <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> javax.<span style="color: #006633;">jms</span>.<span style="color: #006633;">Queue</span> q <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> QueueExample<span style="color: #009900;">&#40;</span>Message m<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mesg <span style="color: #339933;">=</span> m<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>mesg <span style="color: #000000; font-weight: bold;">instanceof</span> TextMessage<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> payload <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>TextMessage<span style="color: #009900;">&#41;</span> mesg<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>listenerID <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: Got msg: &quot;</span> <span style="color: #339933;">+</span> payload<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>JMSException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p style="text-align: justify;">Before looking at sending and receiving messages we need to initialize the connection to the message queue</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> initializeQueue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JMSException <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QueueConnectionFactory queue <span style="color: #339933;">=</span> AQjmsFactory.<span style="color: #006633;">getQueueConnectionFactory</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">URL</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Properties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; QueueConnection con <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>QueueConnection<span style="color: #009900;">&#41;</span> queue.<span style="color: #006633;">createConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; con.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; sess <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>QueueSession<span style="color: #009900;">&#41;</span> con.<span style="color: #006633;">createSession</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span>, Session.<span style="color: #006633;">AUTO_ACKNOWLEDGE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; AQQueueTable qtab <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>AQjmsSession<span style="color: #009900;">&#41;</span> sess<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getQueueTable</span><span style="color: #009900;">&#40;</span>schema, qTable<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>AQjmsSession<span style="color: #009900;">&#41;</span> sess<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getQueue</span><span style="color: #009900;">&#40;</span>schema, qName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AQjmsDestinationProperty props <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AQjmsDestinationProperty<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; q <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>AQjmsSession<span style="color: #009900;">&#41;</span> sess<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">createQueue</span><span style="color: #009900;">&#40;</span>qtab, qName, props<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p style="text-align: justify;">The next step is to listen for messages and dispatch them for processing. The method below initializes the queue if it isn&#8217;t already initialized. After creating a consumer object, we simply wait for messages to come in. The <a href="http://download.oracle.com/docs/cd/E17477_01/javaee/5/api/javax/jms/MessageConsumer.html#receive()"><strong>receive</strong></a> method is blocking, so the program will wait for the next message. Once a message is received it creates an instance of this class and schedules it &#8211; when the thread starts, the <strong>run</strong> method will execute to process the message.</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> listener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JMSException <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>q <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> initializeQueue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>listenerID <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: Listening on queue &quot;</span> <span style="color: #339933;">+</span> q.<span style="color: #006633;">getQueueName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; MessageConsumer consumer <span style="color: #339933;">=</span> sess.<span style="color: #006633;">createConsumer</span><span style="color: #009900;">&#40;</span>q<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// each time we get a message, start up the message handler in a new thread</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Message m<span style="color: #339933;">;</span> <span style="color: #009900;">&#40;</span>m <span style="color: #339933;">=</span> consumer.<span style="color: #006633;">receive</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Timer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">schedule</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> QueueExample<span style="color: #009900;">&#40;</span>m<span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; sess.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; con.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p style="text-align: justify;">The final component is to send messages. For this simple example, it&#8217;s primarily boiler plate code. In this case, we specify how many messages to send. The <a href="http://download.oracle.com/docs/cd/E17477_01/javaee/5/api/javax/jms/DeliveryMode.html">DeliveryMode.PERSISTENT</a> indicates that the messages will be stored (in this case in the DB) until a consumer has received it. Note that after receipt by a consumer the message may or may not be stored in the database. See <a href="http://docs.sun.com/app/docs/doc/819-7757/6n9mar6f2?a=view">here</a> for more details.</p>
<p style="text-align: justify;">In the code below, we can set a variety of properties on the message. For example, we&#8217;ve set an &#8220;application id&#8221; (the <em>JMSXAppID</em> property) and a correlation id. Right now, we ignore this, but it can be used to link messages or even link a message to an external resource (though that could also be done via the payload itself). Another useful property that could be set is the message type via <a href="http://www.apache-korea.org/cactus/api/framework-13/javax/jms/Message.html#setJMSType(java.lang.String)">setJMSType</a>. Using this one can assign a MIME type to a message allowing the message processing code to conditionally handle the message based on the type. For more details on the various properties that can be set see <a href="http://www.apache-korea.org/cactus/api/framework-13/javax/jms/Message.html">Message</a> documentation.</p>
<div class="codecolorer-container java twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> sender<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> n<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JMSException <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>q <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> initializeQueue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; MessageProducer producer <span style="color: #339933;">=</span> sess.<span style="color: #006633;">createProducer</span><span style="color: #009900;">&#40;</span>q<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; producer.<span style="color: #006633;">setDeliveryMode</span><span style="color: #009900;">&#40;</span>DeliveryMode.<span style="color: #006633;">PERSISTENT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Message msg<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> n<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg <span style="color: #339933;">=</span> sess.<span style="color: #006633;">createTextMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg.<span style="color: #006633;">setStringProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;JMSXAppID&quot;</span>, <span style="color: #0000ff;">&quot;QueueExample&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg.<span style="color: #006633;">setJMSCorrelationID</span><span style="color: #009900;">&#40;</span>UUID.<span style="color: #006633;">randomUUID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>TextMessage<span style="color: #009900;">&#41;</span> msg<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;This is message number &quot;</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; producer.<span style="color: #006633;">send</span><span style="color: #009900;">&#40;</span>msg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; producer.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sess.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<h2>Running</h2>
<p style="text-align: justify;">The complete source code can be found <a href="http://rguha.net/code/java/QueueExample.java">here</a>. To compile it you&#8217;ll need an <a href="http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html">OJDBC jar</a> file as well as the following jar files (that come with the Oracle installation)</p>
<ul>
<li>$ORACLE_HOME/rdbms/jlib/aqapi.jar</li>
<li>$ORACLE_HOME/rdbms/jlib/jmscommon.jar</li>
<li>$ORACLE_HOME/jlib/jndi.jar</li>
<li>$ORACLE_HOME/jlib/jta.jar</li>
<li>$ORACLE_HOME/rdbms/jlib/xdb.jar</li>
<li>$ORACLE_HOME/lib/xmlparserv2.jar</li>
</ul>
<p>Once the code has been compiled to a jar file, we first start the listener:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">guhar$ java <span style="color: #660033;">-jar</span> dist<span style="color: #000000; font-weight: bold;">/</span>qex.jar listen<br />
8b9fc2a2-533c-<span style="color: #000000;">4426</span>-a368-3e6ddfb41587: Listening on queue input_q...</div></td></tr></tbody></table></div>
<p style="text-align: justify;">In another terminal we send some messages</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">guhar$ java <span style="color: #660033;">-jar</span> dist<span style="color: #000000; font-weight: bold;">/</span>qex.jar send <span style="color: #000000;">5</span></div></td></tr></tbody></table></div>
</p>
<p style="text-align: justify;">Switching to the previous terminal we should see something like</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">8b9fc2a2-533c-<span style="color: #000000;">4426</span>-a368-3e6ddfb41587: Got msg: This is message number <span style="color: #000000;">0</span><br />
8b9fc2a2-533c-<span style="color: #000000;">4426</span>-a368-3e6ddfb41587: Got msg: This is message number <span style="color: #000000;">1</span><br />
8b9fc2a2-533c-<span style="color: #000000;">4426</span>-a368-3e6ddfb41587: Got msg: This is message number <span style="color: #000000;">2</span><br />
8b9fc2a2-533c-<span style="color: #000000;">4426</span>-a368-3e6ddfb41587: Got msg: This is message number <span style="color: #000000;">3</span><br />
8b9fc2a2-533c-<span style="color: #000000;">4426</span>-a368-3e6ddfb41587: Got msg: This is message number <span style="color: #000000;">4</span></div></td></tr></tbody></table></div>
<p>The fun starts when we instantiate multiple listeners (possible on different machines). It&#8217;s simple enough to execute the first invocation above multiple times and watch the output as we send more messages. If you send 10 messages, you should see that some are handled by one listener and the remainder by another one and so on. if the actual message processing is compute intensive, this allows you to easily distribute such loads easily.</p>
<h2>Next steps</h2>
<p style="text-align: justify;">The code discussed here is a minimalistic example of sending and receiving messages from a queue. In the next post, I&#8217;ll discuss how we can represent messages in the database using a custom message type (defined in terms of an Oracle <a href="http://www.orafaq.com/wiki/ADT">ADT</a>) and send and receive such messages using Java. Such custom message types allow the Java code to remain object oriented, with the AQ libraries handling serialization and deserialization of the messages between our code and the queue.</p>
<p style="text-align: justify;">One of the downsides that I see with Oracle AQ is that the only clients supported are PL/SQL, C and Java. While AQ implements the JMS API, it employs its own wire protocol. The lack of support for  <a href="http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol">AMQP</a> means that a lot of client libraries in other languages cannot be used to send or retrieve messages from AQ. If anybody knows of Python packages that work with Oracle AQ I&#8217;d love to hear about them. (Looks like <a>stomppy</a> might support AQ?)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=651</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automating the Screening Pipeline</title>
		<link>http://blog.rguha.net/?p=690</link>
		<comments>http://blog.rguha.net/?p=690#comments</comments>
		<pubDate>Sun, 11 Jul 2010 20:31:46 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[software]]></category>
		<category><![CDATA[HTS]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jms]]></category>
		<category><![CDATA[message]]></category>
		<category><![CDATA[message queue]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=690</guid>
		<description><![CDATA[A key feature of high throughput screening (HTS) efforts is automation. The NCGC is no stranger to automation, with two Kalypsys robots and a variety of automated components such as liquid handlers and so on. But while the screen itself is automated, the transitions between subsequent steps are not. Thus, after a screen is complete, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">A key feature of high throughput screening (HTS) efforts is automation. The <a href="http://www.ncgc.nih.gov/">NCGC</a> is no stranger to automation, with two <a href="http://www.kalypsys.com/home/home01.shtml">Kalypsys</a> robots and a variety of automated components such as <a href="http://">liquid handlers</a> and so on. But while the screen itself is automated, the transitions between subsequent steps are not. Thus, after a screen is complete, I will be notified that the data is located in some directory. I&#8217;ll then load up the data, process it and end up with a set of compounds for followup. I&#8217;d then send the list of compounds to be plated which would then be screened in a follow up assay.</p>
<p style="text-align: justify;">In a number of situations, this approach is unavoidable as the data processing stage requires human intervention (plate corrections, switching controls, etc.). <span style="font-size: 13.2px;">But in some situations, we can automate the whole process &#8211; primary screen, automated analysis &amp; compound selection and secondary screen. Given that most screens at NCGC are <a href="http://www.pnas.org/content/103/31/11473.abstract?maxtoshow=&amp;HITS=10&amp;hits=10&amp;RESULTFORMAT=&amp;fulltext=qHTS&amp;searchid=1&amp;FIRSTINDEX=0&amp;resourcetype=HWCIT">dose response screens</a>, we can refine an automated pipeline by processing individual plate series (i.e. a collection of plates representing a titration series) rather than waiting for all the plates to be completed.  <span style="font-size: 13.2px;">Another important point to note is that the different steps being considered here take different times. Thus screening a plate series might take 15 minutes, processing the resultant data and making selections would take 3 minutes and performing the secondary screen might take 10 minutes. Clearly the three steps have to proceed in the given order &#8211; but we don&#8217;t necessarily want to wait for each preceding step to be complete. In other words, we need the steps to proceed asynchronously, yet maintain temporal ordering.</span></span></p>
<p style="text-align: justify;">One approach to automating such a process is the use of a <a href="http://en.wikipedia.org/wiki/Message_queue">message queue</a> (MQ). The fundamental idea behind a MQ is that one creates a queue on some machine and then starts one or more processes (likely on some other machines) to send messages to the queue. These messages can then be retrieved by one or more listener processes. MQ systems provide a number of useful features beyond the core functionality of storing and distributing messages – these include message persistence, security policy, routing, batching and so on.</p>
<p style="text-align: justify;">In our case, when a plate series is screened, the robot sends a message to the queue. Some process will be listening to the queue and when it sees a message, pulls it of the queue and processes the data from the screen for that plate series. Once processing is complete, the process sends another message to the queue (or another queue) from which yet another process (this one running on another robot) can pull it off and start the secondary screen on the selected compounds. Thus, as soon as a plate series is finished in the primary screen, we can start the processing and follow up, while the next plate series gets started. A message queue approach is also useful since messages can remain on the queue until the appropriate listener pulls them of for processing. A good queue system will ensure that such messages are delivered reliably and don&#8217;t get lost.</p>
<p style="text-align: justify;">The diagram below highlights this approach. The solid lines represent the traditional workflow. Given that we&#8217;d manually process the screening data, we&#8217;d wait till <em>all</em> plate series are run. The dashed lines represent a message based workflow, in which we can process each plate series independently.</p>
<p><a href="http://blog.rguha.net/wp-content/uploads/2010/07/automated-screening-2.png"><img class="size-medium wp-image-693 alignright" style="margin-left: 10px; margin-right: 5px;" title="automated-screening-2" src="http://blog.rguha.net/wp-content/uploads/2010/07/automated-screening-2-300x133.png" alt="" width="400" height="177" /></a></p>
<p style="text-align: justify;">
<p style="text-align: justify;">In the next few posts I&#8217;ll describe such a message queue based workflow that I&#8217;ve been working on these past few days. Currently it&#8217;s specific to a screen that we&#8217;re going to be running. The infrastructure is written in Java and makes use of Oracle <a href="http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96587/qintro.htm">Advanced Queue</a> (AQ) to provide message queues and the facilities for receiving and sending message. I&#8217;ll describe a minimal implementation that makes use of <a href="http://java.sun.com/products/jms/">Java Messaging Services</a> (JMS) and the standard JMS message types and then follow on with an example using a custom message type that maps to a Oracle user defined type, allowing for more &#8220;object oriented&#8221; messages.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">http://en.wikipedia.org/wiki/Liquid_handling_robot</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=690</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Lightning Talks at the Fall ACS (Boston)</title>
		<link>http://blog.rguha.net/?p=640</link>
		<comments>http://blog.rguha.net/?p=640#comments</comments>
		<pubDate>Wed, 30 Jun 2010 03:38:13 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[cheminformatics]]></category>
		<category><![CDATA[acs]]></category>
		<category><![CDATA[boston]]></category>
		<category><![CDATA[cinf]]></category>
		<category><![CDATA[symposium]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=640</guid>
		<description><![CDATA[Another ACS is coming up this fall in Boston. As in the past there&#8217;ll be lots of symposia in various divisions,on various topics. But common to all of them is the fact that they were submitted nearly 6 months ago and in most cases talk about work that is already published.
While the ACS meetings usually [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Another <a href="http://portal.acs.org/portal/Navigate?nodeid=395">ACS</a> is coming up this fall in Boston. As in the past there&#8217;ll be lots of symposia in various divisions,on various topics. But common to all of them is the fact that they were submitted nearly 6 months ago and in most cases talk about work that is already published.</p>
<p style="text-align: justify;">While the ACS meetings usually have some pretty interesting symposia and talks, it&#8217;s not always the best venue for getting breaking news. So to address this, <a href="http://www.acscinf.org/">CINF</a> will be holding a short session consisting of lightning talks &#8211; 6 minute talks, strictly timed (think of loud bells and maybe even a fog horn) on any topic related to cheminformatics and chemical information.</p>
<p style="text-align: justify;">Lightning talks are certainly fun (see <a href="http://ignite.oreilly.com/">Ignite</a> for example). But it wouldn&#8217;t be fun if we had to hear 6 minute synopses of old work. So, for this session, we&#8217;re not going through PACS. In fact we&#8217;re going to accept submissions from <strong>July 17 </strong>to<strong> Aug 7. </strong>The expectation being that speakers are going to talk about recent developments and not rehash old work.</p>
<p style="text-align: justify;">This is an experimental symposium, so we&#8217;ll likely have just 8 to 10 speakers. But I&#8217;m excited as this a brand new format and should be a lively session. Hopefully, the cheminformatics crowd can put on a good show! (Or as the Ignite motto states: &#8216;<em>Enlighten us, but make it quick</em>&#8216;).</p>
<p style="text-align: justify;"><span style="font-size: 13.2px;">I&#8217;ve included the <a href="http://rguha.net/cinftmp/flash.html">full announcement</a> below</span></p>
<blockquote><p>
For the 2010 Fall meeting in Boston, CINF will be running an experimental session of lightning talks &#8211; short, strictly timed talks. The session does not have a specific topic, however, all talks should be related to cheminformatics and chemical information. One of the key features of this session is that we will not be using the traditional ACS abstract submission system, since that system precludes the inclusion of recent work in the program.</p>
<p>So, since we will be accepting abstracts directly, the expectation is that they be about recent work and developments, rather than rehashes of year-old work. In addition, talks should not be verbal versions of posters submitted for this meeting. Given the short time limits we don&#8217;t expect great detail &#8211; but we are expecting compact and informative presentations.</p>
<p>That&#8217;s the challenge.</p>
<p><strong>What</strong></p>
<ul>
<li>Talks should be no longer than 6 minutes in length. At 6 minutes, you will be asked to stop.
<li>Use as many slides as you want, as long as you can finish in 6 minutes
<li>Talks should not be rehashes of poster presentations
<li>Talks will run back to back, and questions &#038; discussion will be held of off until the end
</ul>
<p>If you haven&#8217;t participated in these types of talks before here are some suggestions:</p>
<ul>
<li>No more than three slides for a 5 minute talk (but if you can pull of 20 slides in 6 minutes, more power to you)
<li>Avoid slides with too much text (and don&#8217;t paste PDF&#8217;s of papers!)
<li>A single chart per slide and make sure labels are readable at a distance
</ul>
<p><strong>When</strong></p>
<p>Aug 23, 2:45 PM </p>
<p>Submissions run from July 17 to Aug 7</p>
<p><strong>Where</strong></p>
<p>Boston Convention &#038; Exhibition Center, Room 155. You can get a map of the concourse <a href="http://www.massconvention.com/download/floorplans_bcec/BCEC_Concourse_Level1.pdf">here</a></p>
<p><strong>How</strong></p>
<ul>
<li>Send in an abstract of about 100 &#8211; 120 words to cinf.flash@gmail.com
<li>We will let you know if you will be speaking by Aug 15 and we will need slide decks by Aug 20
<li>You must be registered for the meeting
<li>Note that the usual publication/copyright rules apply
<li>We will encourage live blogging and tweets (if we have net access)
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=640</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CDKDescUI Update</title>
		<link>http://blog.rguha.net/?p=638</link>
		<comments>http://blog.rguha.net/?p=638#comments</comments>
		<pubDate>Sun, 27 Jun 2010 22:06:01 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[cheminformatics]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[cdk]]></category>
		<category><![CDATA[descriptor]]></category>
		<category><![CDATA[qsar]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=638</guid>
		<description><![CDATA[Version 1.0.5 of the CDK descriptor calculator is now available. This version updates the command line batch mode to allow one to calculate a specific set of descriptors (as opposed to all or say, topological). The selected descriptors are specified using an XML file, which can be generated in the GUI mode &#8211; fire up [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="http://www.rguha.net/code/java/cdkdesc.html">Version 1.0.5</a> of the CDK descriptor calculator is now available. This version updates the command line batch mode to allow one to calculate a specific set of descriptors (as opposed to all or say, topological). The selected descriptors are specified using an XML file, which can be generated in the GUI mode &#8211; fire up the calculator in GUI mode, check the selected descriptors and then save the selection. You can then specify the selection file via the <em><strong>-s</strong></em> option.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=638</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Update to the fingerprint Package</title>
		<link>http://blog.rguha.net/?p=635</link>
		<comments>http://blog.rguha.net/?p=635#comments</comments>
		<pubDate>Thu, 03 Jun 2010 01:07:53 +0000</pubDate>
		<dc:creator>Rajarshi Guha</dc:creator>
				<category><![CDATA[cheminformatics]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[bit density]]></category>
		<category><![CDATA[classification]]></category>
		<category><![CDATA[complexity]]></category>
		<category><![CDATA[fingerprint]]></category>
		<category><![CDATA[similarity]]></category>

		<guid isPermaLink="false">http://blog.rguha.net/?p=635</guid>
		<description><![CDATA[I&#8217;ve just uploaded a new version of the fingerprint package (v3.3) to CRAN that implements some ideas described in Nisius and Bajorath. First, the balance method generates &#8220;balanced code&#8221; fingerprints, which given an input fingerprint of N bits, returns a new fingerprint of 2N bits, such that the bit density is exactly 50%. Second, bit.importance [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;ve just uploaded a new version of the <a href="http://cran.r-project.org/web/packages/fingerprint/index.html">fingerprint</a> package (v3.3) to CRAN that implements some ideas described in <a href="http://dx.doi.org/10.1002/cmdc.201000089">Nisius and Bajorath</a>. First, the <strong>balance</strong> method generates &#8220;balanced code&#8221; fingerprints, which given an input fingerprint of N bits, returns a new fingerprint of 2N bits, such that the bit density is exactly 50%. Second, <strong>bit.importance</strong> is a method to evaluate the importance of each bit in a fingerprint, in terms of the <a href="http://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence">Kullback-Liebler divergence</a> between a collection of actives and background molecules. In other words, the method ranks the bits in terms of their ability to discriminate between the actives and the background molecules.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rguha.net/?feed=rss2&amp;p=635</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
