<?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>Cognitive Consonance &#187; Tips</title>
	<atom:link href="http://tiago.org/cc/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://tiago.org/cc</link>
	<description>Software engineering in a computational biology environment</description>
	<lastBuildDate>Thu, 02 Feb 2012 13:12:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Making subplots (multiple charts) with Python and matplotlib</title>
		<link>http://tiago.org/cc/2011/04/30/making-subplots-multiple-charts-with-python-and-matplotlib/</link>
		<comments>http://tiago.org/cc/2011/04/30/making-subplots-multiple-charts-with-python-and-matplotlib/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 23:54:43 +0000</pubDate>
		<dc:creator>tiago</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[matplotlib]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://tiago.org/cc/?p=327</guid>
		<description><![CDATA[Python&#8217;s matplotlib rocks. It is, by itself, the fundamental reason I stay with Python (JVM-based JFreeChart is powerful but &#8211; as most JVM libraries &#8211; an over-engineered, complex piece of software). Doing multiple charts in matplotlib is not trivial, though. Well, it is trivial, but the end result is not perfect. Here I will present [...]]]></description>
			<content:encoded><![CDATA[<p>Python&#8217;s matplotlib rocks. It is, by itself, the fundamental reason I stay with Python (JVM-based JFreeChart is powerful but &#8211; as most JVM libraries &#8211; an over-engineered, complex piece of software).</p>
<p>Doing multiple charts in matplotlib is not trivial, though. Well, it is trivial, but the end result is not perfect. Here I will present a step-by-step guide to creating better subplots. &#8220;Better&#8221; is, of course, a matter of taste, therefore every change will be presented separately, so that you can pick and chose whichever you prefer.</p>
<p>We start with this (as with all charts presented here, you will need to click to enlarge):</p>
<p><a href="http://tiago.org/cc/wp-content/uploads/2011/04/g1.png"><img src="http://tiago.org/cc/wp-content/uploads/2011/04/g1-300x167.png" alt="" width="300" height="167" class="aligncenter size-medium wp-image-328" /></a></p>
<p>OK, the space between charts is wasted. Also the outside border is too big. Outside borders are less of a problem with a single chart, but when you have lots of stuff to present, then all space that you can get is important. So, we add this:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">fig = pylab.<span style="color: black;">figure</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
fig.<span style="color: black;">subplots_adjust</span><span style="color: black;">&#40;</span>hspace=<span style="color: #ff4500;">0.0001</span>, wspace=<span style="color: #ff4500;">0.0001</span>,
                    bottom=<span style="color: #ff4500;">0.07</span>, top=<span style="color: #ff4500;">0.96</span>,
                    left=<span style="color: #ff4500;">0.04</span>, right=<span style="color: #ff4500;">0.96</span><span style="color: black;">&#41;</span></pre></div></div>

<p>The fig variable might have been initialized before, so use your own.  Notice that subplots_adjust allows you to control both external borders (left, right, bottom, top) and space between charts (hspace, wspace). The result is this:</p>
<p><a href="http://tiago.org/cc/wp-content/uploads/2011/04/g2.png"><img src="http://tiago.org/cc/wp-content/uploads/2011/04/g2-300x167.png" alt="" width="300" height="167" class="aligncenter size-medium wp-image-330" /></a></p>
<p>Before we discuss what obviously looks bad, we need to discuss something that looks good but is, in fact, problematic: The fonts. The fonts look of a proper size and (at least some of them) appear properly positioned. This apparent &#8220;goodness&#8221; is dependent on figure size and resolution (check the parameters of figure). If you develop this on screen and then want to generate an eps version at the end (say, to publish a scientific paper) you might be going for a rough ride and just detect the problem way later (when you generate the final, production version)! <strong>Suggestion:</strong> Try adjusting the figure parameters from the start (use both pylab.show and pylab.savefig &#8211; png and eps &#8211; to test the results). Here I will not spend time with more details about this (the same applies to line thickness, by the way).</p>
<p>OK, irrespective of the point above, the figure clearly has other problems. I opt to remove all titles (just remove the title lines) and remove the unnecessary X and Y axis labels. Note that we have 2 Y axis (one on the left, and one on the right). So, we apply the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#We assume that sp comes from</span>
<span style="color: #808080; font-style: italic;">#sp = pylab.subplot()...</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#You should have this line if you have an extra Y-axis</span>
<span style="color: #808080; font-style: italic;">#Ignore this if you do not have one (most cases won't have one)</span>
par1 = sp.<span style="color: black;">twinx</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#Apply this line to all subplots NOT on the extreme left</span>
pylab.<span style="color: black;">setp</span><span style="color: black;">&#40;</span>sp.<span style="color: black;">get_yticklabels</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, visible=<span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#Apply this line to all subplots NOT on the bottom</span>
pylab.<span style="color: black;">setp</span><span style="color: black;">&#40;</span>sp.<span style="color: black;">get_xticklabels</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>, visible=<span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#Apply this line to all subplots NOT on the extreme right</span>
pylab.<span style="color: black;">setp</span><span style="color: black;">&#40;</span>par1, visible=<span style="color: #008000;">False</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Remember that we also removed the titles, so the result is:</p>
<p><a href="http://tiago.org/cc/wp-content/uploads/2011/04/g3.png"><img src="http://tiago.org/cc/wp-content/uploads/2011/04/g3-300x226.png" alt="" width="300" height="226" class="aligncenter size-medium wp-image-333" /></a></p>
<p>Before we re-instate the titles (and put some legends), notice that the Y-axis labels slightly overlap from one chart to the other (this also happens with the X-axis labels, but it is less visible). For this we will redo the labels:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#if left and not bottom:</span>
    pylab.<span style="color: black;">yticks</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>,.2,.4,.6,.8,<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>,<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;</span>,<span style="color: #483d8b;">&quot;0.2&quot;</span>,<span style="color: #483d8b;">&quot;0.4&quot;</span>,<span style="color: #483d8b;">&quot;0.6&quot;</span>, <span style="color: #483d8b;">&quot;0.8&quot;</span>,<span style="color: #483d8b;">&quot;1.0&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
...
<span style="color: #808080; font-style: italic;">#if right and not bottom:</span>
    pylab.<span style="color: black;">yticks</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">0.5</span>,<span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">1.5</span>,<span style="color: #ff4500;">2</span>,<span style="color: #ff4500;">2.5</span>,<span style="color: #ff4500;">3</span>,<span style="color: #ff4500;">3.5</span>,<span style="color: #ff4500;">4</span>,<span style="color: black;">&#41;</span>,
                 <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;</span>, <span style="color: #483d8b;">&quot;0.5&quot;</span>, <span style="color: #483d8b;">&quot;1&quot;</span>, <span style="color: #483d8b;">&quot;1.5&quot;</span>, <span style="color: #483d8b;">&quot;2&quot;</span>, <span style="color: #483d8b;">&quot;2.5&quot;</span> , <span style="color: #483d8b;">&quot;3&quot;</span>, <span style="color: #483d8b;">&quot;3.5&quot;</span>, <span style="color: #483d8b;">&quot;4&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;">#if bottom and not left:</span>
    pylab.<span style="color: black;">xticks</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>,<span style="color: #ff4500;">20</span>,<span style="color: #ff4500;">40</span>,<span style="color: #ff4500;">60</span>,<span style="color: #ff4500;">80</span>,<span style="color: #ff4500;">100</span><span style="color: black;">&#41;</span>,<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;&quot;</span>,<span style="color: #483d8b;">&quot;20&quot;</span>,<span style="color: #483d8b;">&quot;40&quot;</span>,<span style="color: #483d8b;">&quot;60&quot;</span>, <span style="color: #483d8b;">&quot;08&quot;</span>,<span style="color: #483d8b;">&quot;100&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Now, you might be confused: Lines 2 and 5 call the same function. Well line 2 is called before the creation of the second axe, line 5 after. There might be a more general way of doing this, but I was lazy enough to try and discover it. Result:</p>
<p><a href="http://tiago.org/cc/wp-content/uploads/2011/04/g4.png"><img src="http://tiago.org/cc/wp-content/uploads/2011/04/g4-300x226.png" alt="" width="300" height="226" class="aligncenter size-medium wp-image-339" /></a></p>
<p>OK, now titles and axis labels. I will do this in a non-standard way: By hard-coding everything! You can, if you prefer activate the calls to .set_xlabel, and .title in the right position. In any case, the following example might serve to illustrate fig.text:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">fig.<span style="color: black;">text</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.5</span>, <span style="color: #ff4500;">0.01</span>, <span style="color: #483d8b;">&quot;Generations&quot;</span>, ha=<span style="color: #483d8b;">&quot;center&quot;</span>, va=<span style="color: #483d8b;">&quot;bottom&quot;</span>, size=<span style="color: #483d8b;">&quot;medium&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
fig.<span style="color: black;">text</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.20</span>, <span style="color: #ff4500;">0.99</span>, <span style="color: #483d8b;">&quot;Full epistasis&quot;</span>, ha=<span style="color: #483d8b;">&quot;center&quot;</span>, va=<span style="color: #483d8b;">&quot;top&quot;</span>, size=<span style="color: #483d8b;">&quot;medium&quot;</span><span style="color: black;">&#41;</span>
fig.<span style="color: black;">text</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.52</span>, <span style="color: #ff4500;">0.99</span>, <span style="color: #483d8b;">&quot;Mixed mode&quot;</span>, ha=<span style="color: #483d8b;">&quot;center&quot;</span>, va=<span style="color: #483d8b;">&quot;top&quot;</span>, size=<span style="color: #483d8b;">&quot;medium&quot;</span><span style="color: black;">&#41;</span>
fig.<span style="color: black;">text</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.83</span>, <span style="color: #ff4500;">0.99</span>, <span style="color: #483d8b;">&quot;DGF&quot;</span>, ha=<span style="color: #483d8b;">&quot;center&quot;</span>, va=<span style="color: #483d8b;">&quot;top&quot;</span>, size=<span style="color: #483d8b;">&quot;medium&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
fig.<span style="color: black;">text</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.015</span>, <span style="color: #ff4500;">0.52</span>, <span style="color: #483d8b;">&quot;Fst / LD(r)&quot;</span>, ha=<span style="color: #483d8b;">&quot;right&quot;</span>, va=<span style="color: #483d8b;">&quot;center&quot;</span>, size=<span style="color: #483d8b;">&quot;medium&quot;</span>, rotation=<span style="color: #483d8b;">&quot;vertical&quot;</span><span style="color: black;">&#41;</span>
fig.<span style="color: black;">text</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0.99</span>, <span style="color: #ff4500;">0.52</span>, <span style="color: #483d8b;">&quot;Ratio&quot;</span>, ha=<span style="color: #483d8b;">&quot;right&quot;</span>, va=<span style="color: #483d8b;">&quot;center&quot;</span>, size=<span style="color: #483d8b;">&quot;medium&quot;</span>, rotation=<span style="color: #ff4500;">270</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>ha is horizontal alignment (I will leave up to you to discover what va is <img src='http://tiago.org/cc/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ). Note that the last 2 texts have different rotations. It is possible to put math notation in the text (LaTeX). Something like this: $\frac{1}{n}$. You need 2 things for this to work: add matplotlib.rc(&#8216;text&#8217;, usetex = True) and have LaTex installed.</p>
<p>The end result is then:</p>
<p><a href="http://tiago.org/cc/wp-content/uploads/2011/04/g6.png"><img src="http://tiago.org/cc/wp-content/uploads/2011/04/g6-300x167.png" alt="" title="g6" width="300" height="167" class="aligncenter size-medium wp-image-342" /></a></p>
<p>Not fantastic, but you now have the techniques to alter at will. Just a final reminder that changing size and resolution will have a strong impact on font and line thickness. You might want to check your chart with all final media (screen, eps to print, &#8230;). For instance the example above would clearly benefit from thicker lines and larger fonts.</p>
<div class='sociable'><div><span class='sociable-tagline'>Share and Enjoy:</span></div><ul><li><a rel="nofollow"   href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F&amp;title=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib&amp;bodytext=Python%27s%20matplotlib%20rocks.%20It%20is%2C%20by%20itself%2C%20the%20fundamental%20reason%20I%20stay%20with%20Python%20%28JVM-based%20JFreeChart%20is%20powerful%20but%20-%20as%20most%20JVM%20libraries%20-%20an%20over-engineered%2C%20complex%20piece%20of%20software%29.%0D%0A%0D%0ADoing%20multiple%20charts%20in%20matplotlib%20is%20not%20trivi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/digg.png" class="sociable-img sociable-hovers" title="Digg" alt="Digg" /></a></li><li><a rel="nofollow"   href="http://delicious.com/post?url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F&amp;title=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib&amp;notes=Python%27s%20matplotlib%20rocks.%20It%20is%2C%20by%20itself%2C%20the%20fundamental%20reason%20I%20stay%20with%20Python%20%28JVM-based%20JFreeChart%20is%20powerful%20but%20-%20as%20most%20JVM%20libraries%20-%20an%20over-engineered%2C%20complex%20piece%20of%20software%29.%0D%0A%0D%0ADoing%20multiple%20charts%20in%20matplotlib%20is%20not%20trivi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/delicious.png" class="sociable-img sociable-hovers" title="del.icio.us" alt="del.icio.us" /></a></li><li><a rel="nofollow"   href="http://www.facebook.com/share.php?u=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F&amp;t=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/facebook.png" class="sociable-img sociable-hovers" title="Facebook" alt="Facebook" /></a></li><li><a rel="nofollow"   href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F&amp;title=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib&amp;annotation=Python%27s%20matplotlib%20rocks.%20It%20is%2C%20by%20itself%2C%20the%20fundamental%20reason%20I%20stay%20with%20Python%20%28JVM-based%20JFreeChart%20is%20powerful%20but%20-%20as%20most%20JVM%20libraries%20-%20an%20over-engineered%2C%20complex%20piece%20of%20software%29.%0D%0A%0D%0ADoing%20multiple%20charts%20in%20matplotlib%20is%20not%20trivi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/googlebookmark.png" class="sociable-img sociable-hovers" title="Google Bookmarks" alt="Google Bookmarks" /></a></li><li><a rel="nofollow"   href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F&amp;title=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/dzone.png" class="sociable-img sociable-hovers" title="DZone" alt="DZone" /></a></li><li><a rel="nofollow"   href="http://reddit.com/submit?url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F&amp;title=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/reddit.png" class="sociable-img sociable-hovers" title="Reddit" alt="Reddit" /></a></li><li><a rel="nofollow"   href="http://technorati.com/faves?add=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/technorati.png" class="sociable-img sociable-hovers" title="Technorati" alt="Technorati" /></a></li><li><a rel="nofollow"   href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F&amp;title=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib&amp;source=Cognitive+Consonance+Software+engineering+in+a+computational+biology+environment&amp;summary=Python%27s%20matplotlib%20rocks.%20It%20is%2C%20by%20itself%2C%20the%20fundamental%20reason%20I%20stay%20with%20Python%20%28JVM-based%20JFreeChart%20is%20powerful%20but%20-%20as%20most%20JVM%20libraries%20-%20an%20over-engineered%2C%20complex%20piece%20of%20software%29.%0D%0A%0D%0ADoing%20multiple%20charts%20in%20matplotlib%20is%20not%20trivi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/linkedin.png" class="sociable-img sociable-hovers" title="LinkedIn" alt="LinkedIn" /></a></li><li><a rel="nofollow"   href="http://www.connotea.org/addpopup?continue=confirm&amp;uri=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F&amp;title=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib&amp;description=Python%27s%20matplotlib%20rocks.%20It%20is%2C%20by%20itself%2C%20the%20fundamental%20reason%20I%20stay%20with%20Python%20%28JVM-based%20JFreeChart%20is%20powerful%20but%20-%20as%20most%20JVM%20libraries%20-%20an%20over-engineered%2C%20complex%20piece%20of%20software%29.%0D%0A%0D%0ADoing%20multiple%20charts%20in%20matplotlib%20is%20not%20trivi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/connotea.png" class="sociable-img sociable-hovers" title="connotea" alt="connotea" /></a></li><li><a rel="nofollow"   href="http://www.friendfeed.com/share?title=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib&amp;link=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/friendfeed.png" class="sociable-img sociable-hovers" title="FriendFeed" alt="FriendFeed" /></a></li><li><a rel="nofollow"   href="http://twitter.com/home?status=Making%20subplots%20%28multiple%20charts%29%20with%20Python%20and%20matplotlib%20-%20http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F04%2F30%2Fmaking-subplots-multiple-charts-with-python-and-matplotlib%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/twitter.png" class="sociable-img sociable-hovers" title="Twitter" alt="Twitter" /></a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://tiago.org/cc/2011/04/30/making-subplots-multiple-charts-with-python-and-matplotlib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>xtranormal rocks!</title>
		<link>http://tiago.org/cc/2011/01/26/xtranormal-rocks/</link>
		<comments>http://tiago.org/cc/2011/01/26/xtranormal-rocks/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 17:34:47 +0000</pubDate>
		<dc:creator>tiago</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://tiago.org/cc/?p=255</guid>
		<description><![CDATA[xtranormal is a company/service which allows you to produce movies just from text. Essentially you choose one or two characters, get a scenario and some music and then you create your script. The script is mostly the test spoken by the charater(s), but also camera changes, sounds, and character behaviour. All this wrapped up in [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.xtranormal.com/index">xtranormal</a> is a company/service which allows you to produce movies just from text. Essentially you choose one or two characters, get a scenario and some music and then you create your script. The script is mostly the test spoken by the charater(s), but also camera changes, sounds, and character behaviour. All this wrapped up in a clever and easy web interface (they also have a desktop application by I did not use that). From a techy perspective the technology seems uber cool: text-to-speech (very good quality), 3D character animation and a nice interface on top. Adding to this their business model seems quite fair.</p>
<p>So that you can see what you can do with just one hour of work, here is an example that now sits in my <a href="http://tiago.org">home page</a>  (feel free to laugh at my expense, I do not mind <img src='http://tiago.org/cc/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<p><object width="480" height="390"><param name="movie" value="http://www.xtranormal.com/site_media/players/jwplayer.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="flashvars"value="height=390&#038;width=480&#038;file=http://newvideos.xtranormal.com/web_final_lo/3ba5dee2-28d0-11e0-8951-003048d6740d_28.mp4&#038;image=http://newvideos.xtranormal.com/web_final_lo/3ba5dee2-28d0-11e0-8951-003048d6740d_28.jpg&#038;link=http://www.xtranormal.com/watch/8290745&#038;searchbar=false&#038;autostart=false"/><embed src="http://www.xtranormal.com/site_media/players/jwplayer.swf" width="480" height="390" allowscriptaccess="always" allowfullscreen="true" flashvars="height=390&#038;width=480&#038;file=http://newvideos.xtranormal.com/web_final_lo/3ba5dee2-28d0-11e0-8951-003048d6740d_28.mp4&#038;image=http://newvideos.xtranormal.com/web_final_lo/3ba5dee2-28d0-11e0-8951-003048d6740d_28.jpg&#038;link=http://www.xtranormal.com/watch/8290745&#038;searchbar=false&#038;autostart=false"></embed></object><object width="480" height="390"><param name="movie" value="http://www.xtranormal.com/site_media/players/embedded-xnl-stats.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.xtranormal.com/site_media/players/embedded-xnl-stats.swf" width="1" height="1" allowscriptaccess="always"></embed></object></p>
<p>Go there, and just try to make a video of your own to get the feel for the technology.</p>
<p>PS &#8211; no relationship with the company, just a delighted user here.</p>
<div class='sociable'><div><span class='sociable-tagline'>Share and Enjoy:</span></div><ul><li><a rel="nofollow"   href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F&amp;title=xtranormal%20rocks%21&amp;bodytext=xtranormal%20is%20a%20company%2Fservice%20which%20allows%20you%20to%20produce%20movies%20just%20from%20text.%20Essentially%20you%20choose%20one%20or%20two%20characters%2C%20get%20a%20scenario%20and%20some%20music%20and%20then%20you%20create%20your%20script.%20The%20script%20is%20mostly%20the%20test%20spoken%20by%20the%20charater%28s%29%2C%20b" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/digg.png" class="sociable-img sociable-hovers" title="Digg" alt="Digg" /></a></li><li><a rel="nofollow"   href="http://delicious.com/post?url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F&amp;title=xtranormal%20rocks%21&amp;notes=xtranormal%20is%20a%20company%2Fservice%20which%20allows%20you%20to%20produce%20movies%20just%20from%20text.%20Essentially%20you%20choose%20one%20or%20two%20characters%2C%20get%20a%20scenario%20and%20some%20music%20and%20then%20you%20create%20your%20script.%20The%20script%20is%20mostly%20the%20test%20spoken%20by%20the%20charater%28s%29%2C%20b" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/delicious.png" class="sociable-img sociable-hovers" title="del.icio.us" alt="del.icio.us" /></a></li><li><a rel="nofollow"   href="http://www.facebook.com/share.php?u=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F&amp;t=xtranormal%20rocks%21" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/facebook.png" class="sociable-img sociable-hovers" title="Facebook" alt="Facebook" /></a></li><li><a rel="nofollow"   href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F&amp;title=xtranormal%20rocks%21&amp;annotation=xtranormal%20is%20a%20company%2Fservice%20which%20allows%20you%20to%20produce%20movies%20just%20from%20text.%20Essentially%20you%20choose%20one%20or%20two%20characters%2C%20get%20a%20scenario%20and%20some%20music%20and%20then%20you%20create%20your%20script.%20The%20script%20is%20mostly%20the%20test%20spoken%20by%20the%20charater%28s%29%2C%20b" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/googlebookmark.png" class="sociable-img sociable-hovers" title="Google Bookmarks" alt="Google Bookmarks" /></a></li><li><a rel="nofollow"   href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F&amp;title=xtranormal%20rocks%21" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/dzone.png" class="sociable-img sociable-hovers" title="DZone" alt="DZone" /></a></li><li><a rel="nofollow"   href="http://reddit.com/submit?url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F&amp;title=xtranormal%20rocks%21" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/reddit.png" class="sociable-img sociable-hovers" title="Reddit" alt="Reddit" /></a></li><li><a rel="nofollow"   href="http://technorati.com/faves?add=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/technorati.png" class="sociable-img sociable-hovers" title="Technorati" alt="Technorati" /></a></li><li><a rel="nofollow"   href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F&amp;title=xtranormal%20rocks%21&amp;source=Cognitive+Consonance+Software+engineering+in+a+computational+biology+environment&amp;summary=xtranormal%20is%20a%20company%2Fservice%20which%20allows%20you%20to%20produce%20movies%20just%20from%20text.%20Essentially%20you%20choose%20one%20or%20two%20characters%2C%20get%20a%20scenario%20and%20some%20music%20and%20then%20you%20create%20your%20script.%20The%20script%20is%20mostly%20the%20test%20spoken%20by%20the%20charater%28s%29%2C%20b" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/linkedin.png" class="sociable-img sociable-hovers" title="LinkedIn" alt="LinkedIn" /></a></li><li><a rel="nofollow"   href="http://www.connotea.org/addpopup?continue=confirm&amp;uri=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F&amp;title=xtranormal%20rocks%21&amp;description=xtranormal%20is%20a%20company%2Fservice%20which%20allows%20you%20to%20produce%20movies%20just%20from%20text.%20Essentially%20you%20choose%20one%20or%20two%20characters%2C%20get%20a%20scenario%20and%20some%20music%20and%20then%20you%20create%20your%20script.%20The%20script%20is%20mostly%20the%20test%20spoken%20by%20the%20charater%28s%29%2C%20b" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/connotea.png" class="sociable-img sociable-hovers" title="connotea" alt="connotea" /></a></li><li><a rel="nofollow"   href="http://www.friendfeed.com/share?title=xtranormal%20rocks%21&amp;link=http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/friendfeed.png" class="sociable-img sociable-hovers" title="FriendFeed" alt="FriendFeed" /></a></li><li><a rel="nofollow"   href="http://twitter.com/home?status=xtranormal%20rocks%21%20-%20http%3A%2F%2Ftiago.org%2Fcc%2F2011%2F01%2F26%2Fxtranormal-rocks%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/twitter.png" class="sociable-img sociable-hovers" title="Twitter" alt="Twitter" /></a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://tiago.org/cc/2011/01/26/xtranormal-rocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cool Links</title>
		<link>http://tiago.org/cc/2010/08/17/cool-links/</link>
		<comments>http://tiago.org/cc/2010/08/17/cool-links/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 03:37:17 +0000</pubDate>
		<dc:creator>tiago</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://tiago.org/cc/?p=144</guid>
		<description><![CDATA[Nice reads mostly older: [jvm] YouDebug &#8211; A debug with a scriptable UI (not a GUI). Allowing for automated debugging. The main justification for this is e.g. on costumer sites where you cannot fire a graphical debugger. But an automated debugging framework can be the ground for some cool debugging tools. Furthermore it is scriptable [...]]]></description>
			<content:encoded><![CDATA[<p>Nice reads mostly older:</p>
<ul>
<li>[jvm] <a href="http://youdebug.kenai.com/">YouDebug</a> &#8211; A debug with a scriptable UI (not a GUI). Allowing for automated debugging. The main justification for this is e.g. on costumer sites where you cannot fire a graphical debugger. But an automated debugging framework can be the ground for some cool debugging tools. Furthermore it is scriptable in Groovy!</li>
<li>[general]<a href="http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey">Are we there yet?</a> &#8211; &#8220;Rich Hickey advocated for the reexamination of basic principles like state, identity, value, time, types, genericity, complexity, as they are used by OOP today, to be able to create the new constructs and languages to deal with the massive parallelism and concurrency of the future&#8221;. This is a 1 hour video (with synchronized slides). While I disagree with the basic premise that concurrency is fundamental in the future, this presentation is one of the most invaluable videos about the design of programming languages.
	</li>
<li>[lisp] <a href="http://www.google.com/calendar/embed?src=pm55j8kg30dnm54ib2if9fuocc%40group.calendar.google.com&#038;ctz=Europe/London">A Lisp User-group meetings calendar</a> (Google based)</li>
<li>[clojure] <a href="http://muckandbrass.com/web/display/~cemerick/2009/11/03/Be+mindful+of+Clojure%27s+binding">Be mindful of Clojure&#8217;s binding</a> &#8211; Pitfalls of lazy sequences and thread bindings. The lazy sequence stuff seems more of an example of global variables are bad thing, as the example is dependent on an external symbol evaluation, but clearly one has to be mindful of lazy versus non-lazy evaluation.</li>
</ul>
<div class='sociable'><div><span class='sociable-tagline'>Share and Enjoy:</span></div><ul><li><a rel="nofollow"   href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F&amp;title=Cool%20Links&amp;bodytext=Nice%20reads%20mostly%20older%3A%0D%0A%0D%0A%09%5Bjvm%5D%20YouDebug%20-%20A%20debug%20with%20a%20scriptable%20UI%20%28not%20a%20GUI%29.%20Allowing%20for%20automated%20debugging.%20The%20main%20justification%20for%20this%20is%20e.g.%20on%20costumer%20sites%20where%20you%20cannot%20fire%20a%20graphical%20debugger.%20But%20an%20automated%20debugging" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/digg.png" class="sociable-img sociable-hovers" title="Digg" alt="Digg" /></a></li><li><a rel="nofollow"   href="http://delicious.com/post?url=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F&amp;title=Cool%20Links&amp;notes=Nice%20reads%20mostly%20older%3A%0D%0A%0D%0A%09%5Bjvm%5D%20YouDebug%20-%20A%20debug%20with%20a%20scriptable%20UI%20%28not%20a%20GUI%29.%20Allowing%20for%20automated%20debugging.%20The%20main%20justification%20for%20this%20is%20e.g.%20on%20costumer%20sites%20where%20you%20cannot%20fire%20a%20graphical%20debugger.%20But%20an%20automated%20debugging" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/delicious.png" class="sociable-img sociable-hovers" title="del.icio.us" alt="del.icio.us" /></a></li><li><a rel="nofollow"   href="http://www.facebook.com/share.php?u=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F&amp;t=Cool%20Links" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/facebook.png" class="sociable-img sociable-hovers" title="Facebook" alt="Facebook" /></a></li><li><a rel="nofollow"   href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F&amp;title=Cool%20Links&amp;annotation=Nice%20reads%20mostly%20older%3A%0D%0A%0D%0A%09%5Bjvm%5D%20YouDebug%20-%20A%20debug%20with%20a%20scriptable%20UI%20%28not%20a%20GUI%29.%20Allowing%20for%20automated%20debugging.%20The%20main%20justification%20for%20this%20is%20e.g.%20on%20costumer%20sites%20where%20you%20cannot%20fire%20a%20graphical%20debugger.%20But%20an%20automated%20debugging" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/googlebookmark.png" class="sociable-img sociable-hovers" title="Google Bookmarks" alt="Google Bookmarks" /></a></li><li><a rel="nofollow"   href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F&amp;title=Cool%20Links" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/dzone.png" class="sociable-img sociable-hovers" title="DZone" alt="DZone" /></a></li><li><a rel="nofollow"   href="http://reddit.com/submit?url=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F&amp;title=Cool%20Links" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/reddit.png" class="sociable-img sociable-hovers" title="Reddit" alt="Reddit" /></a></li><li><a rel="nofollow"   href="http://technorati.com/faves?add=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/technorati.png" class="sociable-img sociable-hovers" title="Technorati" alt="Technorati" /></a></li><li><a rel="nofollow"   href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F&amp;title=Cool%20Links&amp;source=Cognitive+Consonance+Software+engineering+in+a+computational+biology+environment&amp;summary=Nice%20reads%20mostly%20older%3A%0D%0A%0D%0A%09%5Bjvm%5D%20YouDebug%20-%20A%20debug%20with%20a%20scriptable%20UI%20%28not%20a%20GUI%29.%20Allowing%20for%20automated%20debugging.%20The%20main%20justification%20for%20this%20is%20e.g.%20on%20costumer%20sites%20where%20you%20cannot%20fire%20a%20graphical%20debugger.%20But%20an%20automated%20debugging" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/linkedin.png" class="sociable-img sociable-hovers" title="LinkedIn" alt="LinkedIn" /></a></li><li><a rel="nofollow"   href="http://www.connotea.org/addpopup?continue=confirm&amp;uri=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F&amp;title=Cool%20Links&amp;description=Nice%20reads%20mostly%20older%3A%0D%0A%0D%0A%09%5Bjvm%5D%20YouDebug%20-%20A%20debug%20with%20a%20scriptable%20UI%20%28not%20a%20GUI%29.%20Allowing%20for%20automated%20debugging.%20The%20main%20justification%20for%20this%20is%20e.g.%20on%20costumer%20sites%20where%20you%20cannot%20fire%20a%20graphical%20debugger.%20But%20an%20automated%20debugging" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/connotea.png" class="sociable-img sociable-hovers" title="connotea" alt="connotea" /></a></li><li><a rel="nofollow"   href="http://www.friendfeed.com/share?title=Cool%20Links&amp;link=http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/friendfeed.png" class="sociable-img sociable-hovers" title="FriendFeed" alt="FriendFeed" /></a></li><li><a rel="nofollow"   href="http://twitter.com/home?status=Cool%20Links%20-%20http%3A%2F%2Ftiago.org%2Fcc%2F2010%2F08%2F17%2Fcool-links%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/twitter.png" class="sociable-img sociable-hovers" title="Twitter" alt="Twitter" /></a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://tiago.org/cc/2010/08/17/cool-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reading newick/nexus phylogenetic trees with BioJava</title>
		<link>http://tiago.org/cc/2009/11/17/reading-newicknexus-phylogenetic-trees-with-biojava/</link>
		<comments>http://tiago.org/cc/2009/11/17/reading-newicknexus-phylogenetic-trees-with-biojava/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 18:02:11 +0000</pubDate>
		<dc:creator>tiago</dc:creator>
				<category><![CDATA[Bioinformatics]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[biojava]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[phylogenetics]]></category>

		<guid isPermaLink="false">http://tiago.org/cc/?p=183</guid>
		<description><![CDATA[Addendum: This requires biojava 1.8, no more, no less! BioJava has a parser for the nexus file format. While Nexus supports quite a lot of information (like DNA sequences), the most complex part to process is the phylogenetic tree descriptions based on the Newick format. Below you can find a small tutorial on how to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Addendum:</strong> This requires biojava 1.8, no more, no less!</p>
<p>BioJava has a parser for the <a href="http://hydrodictyon.eeb.uconn.edu/eebedia/index.php/Phylogenetics:_NEXUS_Format">nexus file format</a>. While Nexus supports quite a lot of information (like DNA sequences), the most complex part to process is the phylogenetic tree descriptions based on the <a href="http://en.wikipedia.org/wiki/Newick_format">Newick format</a>. Below you can find a small tutorial on how to process these.</p>
<p>BioJava&#8217;s parser relies on <a href="http://jgrapht.sourceforge.net/">JGraphT</a> to create a representation of the &#8220;tree&#8221;. The tree is actually really more an acyclic graph than a tree, though some trees are rooted (and therefore trees in the proper sense). Manipulating the JGraphT weighted graph is the complicated part, not really the BioJava interface. Note that JGraphT objects can be easily rendered using the <a href="http://www.jgraph.com/jgraph.html">JGraph</a> library (yeah, it is confusing: there is one lib with graph algorithms called JGraphT and another, for vizualisation, called JGraph).</p>
<p>In this small tutorial, we will only try to write a textual representation of a tree.</p>
<p>Imagine this simple nexus file:</p>
<pre>
#NEXUS

Begin TREES;
	tree test1 = (1,2);
	tree test4 = (1:0.1,(2:0.2,3:0.3):0.4);
End;
</pre>
<p>We just want to draw this:</p>
<pre>
coder@move-on:~/development/biobug/test$ java Test test1.nex test1
Will process file test1.nex tree test1
p0
  1: 1.0
  2: 1.0
coder@move-on:~/development/biobug/test$ java Test test1.nex test4
Will process file test1.nex tree test4
p0
  1: 0.1
  p1: 0.4
    2: 0.2
    3: 0.3
</pre>
<p>So, tree 1 is composed of nodes (leaves) 1 and 2 and the inner node which was named p1. Tree 2 has distances.</p>
<p>By the way, we will also want to know which trees are in the file.</p>
<p>Lets start!.</p>
<p>So, we start by loading and parsing the file:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.biojavax.bio.phylo.io.nexus.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#91;</span>...<span style="color: #009900;">&#93;</span>
        <span style="color: #666666; font-style: italic;">//file is a String with the name of the file to be processed</span>
        NexusFileBuilder builder <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NexusFileBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        NexusFileFormat.<span style="color: #006633;">parseFile</span><span style="color: #009900;">&#40;</span>builder, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>file<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        NexusFile nexus <span style="color: #339933;">=</span> builder.<span style="color: #006633;">getNexusFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Nexus files have several blocks (Taxa, Data, Tree, Set). We are interested in getting the Tree block, lets do a function for that:</p>
<pre language="java">
    TreesBlock getTreeNode(NexusFile nexus) {
        Iterator it = nexus.blockIterator();
        NexusBlock block;
        while(it.hasNext()) {
                block = (NexusBlock)it.next();
                if (block.getBlockName().equals("TREES")) {
                        return (TreesBlock)block;
                }
            }
            return null;
    }
</pre>
<p>We get the nexus block iterator and go through it until we find a block whose name is TREES, and return that block.</p>
<p>No that we have the TREES block, lets print the names of all trees:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000066; font-weight: bold;">void</span> printTrees<span style="color: #009900;">&#40;</span>NexusFile nexus<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            TreesBlock node <span style="color: #339933;">=</span> getTreeNode<span style="color: #009900;">&#40;</span>nexus<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">Map</span> trees <span style="color: #339933;">=</span> node.<span style="color: #006633;">getTrees</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">Set</span> keys <span style="color: #339933;">=</span> trees.<span style="color: #006633;">keySet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Trees:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> obj <span style="color: #339933;">:</span> keys<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>We get a map, where the key is the name of the tree and the value would be the tree as, essentially, a String based (but with some annotated info) representation (not  a graph). Now, given a certain name, lets get the graph:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.biojava.bio.seq.io.ParseException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jgrapht.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jgrapht.graph.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#91;</span>...<span style="color: #009900;">&#93;</span>
&nbsp;
    WeightedGraph<span style="color: #339933;">&lt;</span>string , DefaultWeightedEdge<span style="color: #339933;">&gt;</span> getTree<span style="color: #009900;">&#40;</span>NexusFile nexus, <span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">ParseException</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">String</span> topNode<span style="color: #339933;">;</span>
        TreesBlock node <span style="color: #339933;">=</span> getTreeNode<span style="color: #009900;">&#40;</span>nexus<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        WeightedGraph<span style="color: #339933;">&lt;/</span>string<span style="color: #339933;">&gt;&lt;</span>string , DefaultWeightedEdge<span style="color: #339933;">&gt;</span> graph <span style="color: #339933;">=</span> node.<span style="color: #006633;">getTreeAsWeightedJGraphT</span><span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        topNode <span style="color: #339933;">=</span> node.<span style="color: #006633;">getTopNode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;The top node is: &quot;</span> <span style="color: #339933;">+</span> topNode<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> graph<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>string<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Note that getTreeAsWeightedJGraphT will do some parsing, so ParsingException can be raised. Note also that the top node name can be retrieved (in the case of tree test1, that will be named p1). Some considerations: You can change the rules to create internal nodes; if there are clashes of names inner nodes will be renamed (not leaves!).</p>
<p>Regarding the top node, we call it top node and not root node. While from a data structure perspective the tree has a root, from a phylogenetic perspective the tree might be rooted or not (in which case being root has no meaning, and it is really just a simple weighted acyclic graph). How to know if the tree is rooted? Remember the function to get all trees (getTrees)? The value of the map has a method called getRootType. So, to know if is rooted, you need to use that function. Not the best design&#8230; but at least works.</p>
<p>Ok, now we just need to print a tree&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> dump<span style="color: #009900;">&#40;</span>WeightedGraph<span style="color: #339933;">&lt;</span>string , DefaultWeightedEdge<span style="color: #339933;">&gt;</span> graph,
            <span style="color: #003399;">String</span> parent, <span style="color: #003399;">String</span> node, <span style="color: #003399;">String</span> depth<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Set<span style="color: #339933;">&lt;/</span>string<span style="color: #339933;">&gt;&lt;</span>string<span style="color: #339933;">&gt;</span> verts <span style="color: #339933;">=</span> graph.<span style="color: #006633;">vertexSet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">String</span> vertex <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> candidate <span style="color: #339933;">:</span> verts<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>candidate.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                vertex <span style="color: #339933;">=</span> candidate<span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span> <span style="color: #009900;">&#40;</span>depth <span style="color: #339933;">+</span> vertex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>parent <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;: &quot;</span> <span style="color: #339933;">+</span> graph.<span style="color: #006633;">getEdgeWeight</span><span style="color: #009900;">&#40;</span>graph.<span style="color: #006633;">getEdge</span><span style="color: #009900;">&#40;</span>parent, vertex<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>DefaultWeightedEdge e<span style="color: #339933;">:</span> graph.<span style="color: #006633;">edgesOf</span><span style="color: #009900;">&#40;</span>vertex<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>graph.<span style="color: #006633;">getEdgeSource</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                dump<span style="color: #009900;">&#40;</span>graph, vertex, graph.<span style="color: #006633;">getEdgeTarget</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>, <span style="color: #0000ff;">&quot;  &quot;</span><span style="color: #339933;">+</span> depth<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span> 
<span style="color: #339933;">&lt;/</span>string<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Ok, this is the complicated part. Note the following:</p>
<ul>
<li>The complexity has to do with processing graphs</li>
<li>dump is a recursive function</li>
<li>Node is synonym with Vertex</li>
<li>Notice the <strong>important bit</strong>, if you know that there is a node called &#8220;bla&#8221;, it is not enough to do graph.containsVertex(&#8220;bla&#8221;). The answer will probably be false. Remember that one thing is reference (which we have here, i.e. ==) and not content equality (.equals). See below, a remainder</li>
<li>Finally we go through all edges referencing the current vertex and choose the ones that start on the current one. Again, if the tree is unrooted, the notion of direction does not apply, but it is still good to do a &#8220;tree&#8221; traversal</li>
</ul>
<p>We end here.</p>
<p>Regarding the &#8220;equal&#8221; issue remember that:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a&quot;</span> <span style="color: #339933;">==</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Returns false, true. By this order. This is important when traversing the graph. If you know that the reference is equal (and it is when we getEdgeTarget) than one could use it. If you don&#8217;t know (like you pass a String that you have constructed yourself or got from some other place), then one needs to go through the vertex/node list and do a .equals to get the correct vertex.</p>
<p>A small example with all the above, <a href="http://tiago.org/cc/wp-content/uploads/2009/11/Test.java">is here</a>, ready to use.</p>
<div class='sociable'><div><span class='sociable-tagline'>Share and Enjoy:</span></div><ul><li><a rel="nofollow"   href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F&amp;title=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava&amp;bodytext=Addendum%3A%20This%20requires%20biojava%201.8%2C%20no%20more%2C%20no%20less%21%0D%0A%0D%0ABioJava%20has%20a%20parser%20for%20the%20nexus%20file%20format.%20While%20Nexus%20supports%20quite%20a%20lot%20of%20information%20%28like%20DNA%20sequences%29%2C%20the%20most%20complex%20part%20to%20process%20is%20the%20phylogenetic%20tree%20descriptions%20bas" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/digg.png" class="sociable-img sociable-hovers" title="Digg" alt="Digg" /></a></li><li><a rel="nofollow"   href="http://delicious.com/post?url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F&amp;title=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava&amp;notes=Addendum%3A%20This%20requires%20biojava%201.8%2C%20no%20more%2C%20no%20less%21%0D%0A%0D%0ABioJava%20has%20a%20parser%20for%20the%20nexus%20file%20format.%20While%20Nexus%20supports%20quite%20a%20lot%20of%20information%20%28like%20DNA%20sequences%29%2C%20the%20most%20complex%20part%20to%20process%20is%20the%20phylogenetic%20tree%20descriptions%20bas" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/delicious.png" class="sociable-img sociable-hovers" title="del.icio.us" alt="del.icio.us" /></a></li><li><a rel="nofollow"   href="http://www.facebook.com/share.php?u=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F&amp;t=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/facebook.png" class="sociable-img sociable-hovers" title="Facebook" alt="Facebook" /></a></li><li><a rel="nofollow"   href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F&amp;title=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava&amp;annotation=Addendum%3A%20This%20requires%20biojava%201.8%2C%20no%20more%2C%20no%20less%21%0D%0A%0D%0ABioJava%20has%20a%20parser%20for%20the%20nexus%20file%20format.%20While%20Nexus%20supports%20quite%20a%20lot%20of%20information%20%28like%20DNA%20sequences%29%2C%20the%20most%20complex%20part%20to%20process%20is%20the%20phylogenetic%20tree%20descriptions%20bas" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/googlebookmark.png" class="sociable-img sociable-hovers" title="Google Bookmarks" alt="Google Bookmarks" /></a></li><li><a rel="nofollow"   href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F&amp;title=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/dzone.png" class="sociable-img sociable-hovers" title="DZone" alt="DZone" /></a></li><li><a rel="nofollow"   href="http://reddit.com/submit?url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F&amp;title=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/reddit.png" class="sociable-img sociable-hovers" title="Reddit" alt="Reddit" /></a></li><li><a rel="nofollow"   href="http://technorati.com/faves?add=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/technorati.png" class="sociable-img sociable-hovers" title="Technorati" alt="Technorati" /></a></li><li><a rel="nofollow"   href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F&amp;title=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava&amp;source=Cognitive+Consonance+Software+engineering+in+a+computational+biology+environment&amp;summary=Addendum%3A%20This%20requires%20biojava%201.8%2C%20no%20more%2C%20no%20less%21%0D%0A%0D%0ABioJava%20has%20a%20parser%20for%20the%20nexus%20file%20format.%20While%20Nexus%20supports%20quite%20a%20lot%20of%20information%20%28like%20DNA%20sequences%29%2C%20the%20most%20complex%20part%20to%20process%20is%20the%20phylogenetic%20tree%20descriptions%20bas" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/linkedin.png" class="sociable-img sociable-hovers" title="LinkedIn" alt="LinkedIn" /></a></li><li><a rel="nofollow"   href="http://www.connotea.org/addpopup?continue=confirm&amp;uri=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F&amp;title=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava&amp;description=Addendum%3A%20This%20requires%20biojava%201.8%2C%20no%20more%2C%20no%20less%21%0D%0A%0D%0ABioJava%20has%20a%20parser%20for%20the%20nexus%20file%20format.%20While%20Nexus%20supports%20quite%20a%20lot%20of%20information%20%28like%20DNA%20sequences%29%2C%20the%20most%20complex%20part%20to%20process%20is%20the%20phylogenetic%20tree%20descriptions%20bas" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/connotea.png" class="sociable-img sociable-hovers" title="connotea" alt="connotea" /></a></li><li><a rel="nofollow"   href="http://www.friendfeed.com/share?title=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava&amp;link=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/friendfeed.png" class="sociable-img sociable-hovers" title="FriendFeed" alt="FriendFeed" /></a></li><li><a rel="nofollow"   href="http://twitter.com/home?status=Reading%20newick%2Fnexus%20phylogenetic%20trees%20with%20BioJava%20-%20http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F17%2Freading-newicknexus-phylogenetic-trees-with-biojava%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/twitter.png" class="sociable-img sociable-hovers" title="Twitter" alt="Twitter" /></a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://tiago.org/cc/2009/11/17/reading-newicknexus-phylogenetic-trees-with-biojava/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More clojure N00b tips</title>
		<link>http://tiago.org/cc/2009/11/04/more-clojure-n00b-tips/</link>
		<comments>http://tiago.org/cc/2009/11/04/more-clojure-n00b-tips/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 16:16:20 +0000</pubDate>
		<dc:creator>tiago</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[clojure]]></category>

		<guid isPermaLink="false">http://tiago.org/cc/?p=139</guid>
		<description><![CDATA[Having read Tim Bray&#8217;s tips for Clojure newbies from a newbie, I decided to write a version of my own. First, I generally agree with Tim&#8217;s observations, so this post is more like minor extension. In fact I recommend reading Tim&#8217;s version first. My background so that you know my point of view: Added to [...]]]></description>
			<content:encoded><![CDATA[<p>Having read Tim Bray&#8217;s <a href="http://www.tbray.org/ongoing/When/200x/2009/11/03/Clojure-N00b-Advice">tips for Clojure newbies from a newbie</a>, I decided to write a version of my own.</p>
<p>First, I generally agree with Tim&#8217;s observations, so this post is more like minor extension. In fact I recommend reading Tim&#8217;s version first.</p>
<p>My background so that you know my point of view: Added to Java, C and Python experience I have lots of exposure to Prolog (which is, like Clojure, homoiconic) and some experience with OCaml (a functional language). I have had some practical contact with other &#8220;modern languages over JVM&#8221;: Scala and Groovy. No Lisp experience (other than basic elisp).</p>
<p>Reading suggestions: Other than Tim&#8217;s comments I would add: The clojure site information is really not very useful as a starting point, the reference part assumes that you already know quite a bit and it is though on newbies, the only thing that I tend to use is the <a href="http://clojure.org/api">API section</a>. Like Tim, I also use Mark Volkmann&#8217;s <a href="http://java.ociweb.com/mark/clojure/article.html">introduction</a> (It is my main documentation, and I would be a bit more positive than Tim about it. For an intro article it is great. I strongly recommend it as a starting point and as the reading anchor during the first weeks). Next week I plan to order Stuart Halloway&#8217;s book, so I still cannot comment on that.</p>
<p>On a more general note, while learning Clojure, I&#8217;ve found Paul Graham&#8217;s <a href="http://www.paulgraham.com/onlisp.html">On Lisp</a> (available for free), a gem and I would strongly recommend it. It is not an easy read, it probably takes months to digest the content. But it is really a great book.</p>
<p>Clojure is a fast moving target. Documentation of many modules and functions might not be up to date with the current code. I have noticed that sometimes the best &#8220;documentation&#8221; ends up being reading the code (clojure is hosted on github and so are many satellite projects &#8211; In fact getting familiar with github is probably another recommendation).</p>
<p>Some of the contrib stuff is a bit too green, and I would recommend inspection of some of the modules before using them. Just because it is accepted on clojure.contrib it does not mean it is production quality, has even bare functionality or the exposed API is stable. As an example the <a href="http://richhickey.github.com/clojure-contrib/graph-api.html">graph API</a> is minimal and I question if the graph structure directed-graph is enough to represent a general directed graph (future changes to it will probably break existing code built on top of it). This is not a criticism, a new product is bound to be fast changing, and agile methods of development will entail lots of instability at the beginning. But a caveat should be added to the stability and completeness of parts of clojure-contrib.</p>
<p>Regarding editors and IDEs, I would probably recommend for you to stick with what you feel more comfortable with (vi, emacs, netbeans, eclipse, &#8230;). Note that Clojure, being a Lisp derivative has a big share of its user base on emacs. I mainly use Netbeans using the wonderful <a href="http://www.enclojure.org/">enclojure</a> plug-in. I can only say that encloure is stable enough for usage and I recommend it if you are a Netbeans type of person.</p>
<p>I also second Tim&#8217;s comments on namespace hell. Uses/imports/requires can be quite confusing. Hell is too harsh of a word, but purgatory seems an accurate description <img src='http://tiago.org/cc/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  . Also, as Tim says, the clojure mailing list and IRC channels are very, very helpful.</p>
<p>One of the most annoying kinds of bugs come from typing problems, things like this:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>defn hiddenBug <span style="color: #66cc66;">&#91;</span>a b<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span>println a<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;lets do a println for debug purposes</span>
  <span style="color: #66cc66;">&#40;</span>println b<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;lets do a println for debug purposes</span>
  <span style="color: #66cc66;">&#40;</span>if-<span style="color: #b1b100;">not</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">=</span> a b<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>println <span style="color: #ff0000;">&quot;they are different!&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Now lets call this:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>hiddenBug 'x <span style="color: #ff0000;">&quot;x&quot;</span><span style="color: #66cc66;">&#41;</span>
x
x
they are different<span style="color: #66cc66;">!</span></pre></div></div>

<p>Notice that, when you are debugging a and b will <i>seem</i> equal on a println, but they are not (one is a symbol, another a string)!</p>
<p>The biggest gotcha that I have been getting is the expectation (Java based) that stupid things raise exceptions, but sometimes they don&#8217;t. Here is an example:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp" style="font-family:monospace;">user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>contains? '<span style="color: #66cc66;">&#40;</span>a b<span style="color: #66cc66;">&#41;</span> 'a<span style="color: #66cc66;">&#41;</span>
false
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>contains? 'blab 'a<span style="color: #66cc66;">&#41;</span>
false
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>contains? <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list</span> 'a 'b<span style="color: #66cc66;">&#41;</span> 'a<span style="color: #66cc66;">&#41;</span>
false
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>contains? <span style="color: #66cc66;">&#91;</span>'a 'b<span style="color: #66cc66;">&#93;</span> 'a<span style="color: #66cc66;">&#41;</span>
false
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>contains? '<span style="color: #66cc66;">&#40;</span>a b<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">a</span><span style="color: #66cc66;">&#41;</span>
false
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>contains? '<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">:</span><span style="color: #555;">a</span> b<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">:</span><span style="color: #555;">a</span><span style="color: #66cc66;">&#41;</span>
false</pre></div></div>

<p>In all these cases, the Java-expecting gnome inside me was hoping something of a throw (as the first argument is not of the type required by contains? ) . It is not clear to me if this is a design issue with contains? only, or it is something that is standard along the whole API. But I notice this from the API reference:</p>
<pre>
(even? n)
Returns true if n is even, throws an exception if n is not an integer
</pre>
<p>So it seems that the design is not homogeneous throughout the API as some functions throw exceptions. I would probably prefer a throw when the type of arguments is wrong, but people with lots of Lisp experience might have a different view on the issue. Anyway I would like to understand if the lack of homogeneity is a feature or a bug.</p>
<div class='sociable'><div><span class='sociable-tagline'>Share and Enjoy:</span></div><ul><li><a rel="nofollow"   href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F&amp;title=More%20clojure%20N00b%20tips&amp;bodytext=Having%20read%20Tim%20Bray%27s%20tips%20for%20Clojure%20newbies%20from%20a%20newbie%2C%20I%20decided%20to%20write%20a%20version%20of%20my%20own.%0D%0A%0D%0AFirst%2C%20I%20generally%20agree%20with%20Tim%27s%20observations%2C%20so%20this%20post%20is%20more%20like%20minor%20extension.%20In%20fact%20I%20recommend%20reading%20Tim%27s%20version%20first.%0D%0A%0D" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/digg.png" class="sociable-img sociable-hovers" title="Digg" alt="Digg" /></a></li><li><a rel="nofollow"   href="http://delicious.com/post?url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F&amp;title=More%20clojure%20N00b%20tips&amp;notes=Having%20read%20Tim%20Bray%27s%20tips%20for%20Clojure%20newbies%20from%20a%20newbie%2C%20I%20decided%20to%20write%20a%20version%20of%20my%20own.%0D%0A%0D%0AFirst%2C%20I%20generally%20agree%20with%20Tim%27s%20observations%2C%20so%20this%20post%20is%20more%20like%20minor%20extension.%20In%20fact%20I%20recommend%20reading%20Tim%27s%20version%20first.%0D%0A%0D" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/delicious.png" class="sociable-img sociable-hovers" title="del.icio.us" alt="del.icio.us" /></a></li><li><a rel="nofollow"   href="http://www.facebook.com/share.php?u=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F&amp;t=More%20clojure%20N00b%20tips" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/facebook.png" class="sociable-img sociable-hovers" title="Facebook" alt="Facebook" /></a></li><li><a rel="nofollow"   href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F&amp;title=More%20clojure%20N00b%20tips&amp;annotation=Having%20read%20Tim%20Bray%27s%20tips%20for%20Clojure%20newbies%20from%20a%20newbie%2C%20I%20decided%20to%20write%20a%20version%20of%20my%20own.%0D%0A%0D%0AFirst%2C%20I%20generally%20agree%20with%20Tim%27s%20observations%2C%20so%20this%20post%20is%20more%20like%20minor%20extension.%20In%20fact%20I%20recommend%20reading%20Tim%27s%20version%20first.%0D%0A%0D" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/googlebookmark.png" class="sociable-img sociable-hovers" title="Google Bookmarks" alt="Google Bookmarks" /></a></li><li><a rel="nofollow"   href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F&amp;title=More%20clojure%20N00b%20tips" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/dzone.png" class="sociable-img sociable-hovers" title="DZone" alt="DZone" /></a></li><li><a rel="nofollow"   href="http://reddit.com/submit?url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F&amp;title=More%20clojure%20N00b%20tips" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/reddit.png" class="sociable-img sociable-hovers" title="Reddit" alt="Reddit" /></a></li><li><a rel="nofollow"   href="http://technorati.com/faves?add=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/technorati.png" class="sociable-img sociable-hovers" title="Technorati" alt="Technorati" /></a></li><li><a rel="nofollow"   href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F&amp;title=More%20clojure%20N00b%20tips&amp;source=Cognitive+Consonance+Software+engineering+in+a+computational+biology+environment&amp;summary=Having%20read%20Tim%20Bray%27s%20tips%20for%20Clojure%20newbies%20from%20a%20newbie%2C%20I%20decided%20to%20write%20a%20version%20of%20my%20own.%0D%0A%0D%0AFirst%2C%20I%20generally%20agree%20with%20Tim%27s%20observations%2C%20so%20this%20post%20is%20more%20like%20minor%20extension.%20In%20fact%20I%20recommend%20reading%20Tim%27s%20version%20first.%0D%0A%0D" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/linkedin.png" class="sociable-img sociable-hovers" title="LinkedIn" alt="LinkedIn" /></a></li><li><a rel="nofollow"   href="http://www.connotea.org/addpopup?continue=confirm&amp;uri=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F&amp;title=More%20clojure%20N00b%20tips&amp;description=Having%20read%20Tim%20Bray%27s%20tips%20for%20Clojure%20newbies%20from%20a%20newbie%2C%20I%20decided%20to%20write%20a%20version%20of%20my%20own.%0D%0A%0D%0AFirst%2C%20I%20generally%20agree%20with%20Tim%27s%20observations%2C%20so%20this%20post%20is%20more%20like%20minor%20extension.%20In%20fact%20I%20recommend%20reading%20Tim%27s%20version%20first.%0D%0A%0D" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/connotea.png" class="sociable-img sociable-hovers" title="connotea" alt="connotea" /></a></li><li><a rel="nofollow"   href="http://www.friendfeed.com/share?title=More%20clojure%20N00b%20tips&amp;link=http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/friendfeed.png" class="sociable-img sociable-hovers" title="FriendFeed" alt="FriendFeed" /></a></li><li><a rel="nofollow"   href="http://twitter.com/home?status=More%20clojure%20N00b%20tips%20-%20http%3A%2F%2Ftiago.org%2Fcc%2F2009%2F11%2F04%2Fmore-clojure-n00b-tips%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/twitter.png" class="sociable-img sociable-hovers" title="Twitter" alt="Twitter" /></a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://tiago.org/cc/2009/11/04/more-clojure-n00b-tips/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Method references and Output redirection in Groovy</title>
		<link>http://tiago.org/cc/2008/12/30/method-references-and-output-redirection-in-groovy/</link>
		<comments>http://tiago.org/cc/2008/12/30/method-references-and-output-redirection-in-groovy/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 12:49:34 +0000</pubDate>
		<dc:creator>tiago</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[groovy]]></category>

		<guid isPermaLink="false">http://tiago.org/cc/?p=36</guid>
		<description><![CDATA[When doing Groovy scripts I sometimes have the need to redirect the output of a part of the computation that is going to standard out.. A possible solution would be to open a new Writer and change the code to write to it (i.e. replacing all prints with newStream.prints), this, of course requires changing all [...]]]></description>
			<content:encoded><![CDATA[<p>When doing Groovy scripts I sometimes have the need to redirect the output of a part of the computation that is going to standard out.. A possible solution would be to open a new Writer and change the code to write to it (i.e. replacing all prints with newStream.prints), this, of course requires changing all prints, which is cumbersome and boring. There is a lazy alternative, using method references:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy" style="font-family:monospace;">s <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">PrintStream</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">FileOutputStream</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/tmp/myOut&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #000000; font-weight: bold;">def</span> <span style="color: #993399;">print</span> <span style="color: #66cc66;">=</span> s.<span style="color: #66cc66;">&amp;</span>print
<span style="color: #993399;">print</span> <span style="color: #ff0000;">&quot;a&quot;</span>
<span style="color: #993399;">print</span> <span style="color: #66cc66;">=</span> <span style="color: #aaaadd; font-weight: bold;">System</span>.<span style="color: #006600;">out</span>.<span style="color: #66cc66;">&amp;</span>print
<span style="color: #993399;">print</span> <span style="color: #ff0000;">&quot;b&quot;</span></pre></div></div>

<p>In this case the a is written to /tmp/myOut and b gets back to the standard output again. The big gain: all those prints in a script (and printlns) don&#8217;t need to be changed! Lazy me is happy.</p>
<p>Caveat: I would be careful in using this strategy a lot, it is be very easy to loose track of what is happening to the output. But it can be quite an expedient way to redirect prints on simple scripts.</p>
<div class='sociable'><div><span class='sociable-tagline'>Share and Enjoy:</span></div><ul><li><a rel="nofollow"   href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F&amp;title=Method%20references%20and%20Output%20redirection%20in%20Groovy&amp;bodytext=When%20doing%20Groovy%20scripts%20I%20sometimes%20have%20the%20need%20to%20redirect%20the%20output%20of%20a%20part%20of%20the%20computation%20that%20is%20going%20to%20standard%20out..%20A%20possible%20solution%20would%20be%20to%20open%20a%20new%20Writer%20and%20change%20the%20code%20to%20write%20to%20it%20%28i.e.%20replacing%20all%20prints%20wi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/digg.png" class="sociable-img sociable-hovers" title="Digg" alt="Digg" /></a></li><li><a rel="nofollow"   href="http://delicious.com/post?url=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F&amp;title=Method%20references%20and%20Output%20redirection%20in%20Groovy&amp;notes=When%20doing%20Groovy%20scripts%20I%20sometimes%20have%20the%20need%20to%20redirect%20the%20output%20of%20a%20part%20of%20the%20computation%20that%20is%20going%20to%20standard%20out..%20A%20possible%20solution%20would%20be%20to%20open%20a%20new%20Writer%20and%20change%20the%20code%20to%20write%20to%20it%20%28i.e.%20replacing%20all%20prints%20wi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/delicious.png" class="sociable-img sociable-hovers" title="del.icio.us" alt="del.icio.us" /></a></li><li><a rel="nofollow"   href="http://www.facebook.com/share.php?u=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F&amp;t=Method%20references%20and%20Output%20redirection%20in%20Groovy" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/facebook.png" class="sociable-img sociable-hovers" title="Facebook" alt="Facebook" /></a></li><li><a rel="nofollow"   href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F&amp;title=Method%20references%20and%20Output%20redirection%20in%20Groovy&amp;annotation=When%20doing%20Groovy%20scripts%20I%20sometimes%20have%20the%20need%20to%20redirect%20the%20output%20of%20a%20part%20of%20the%20computation%20that%20is%20going%20to%20standard%20out..%20A%20possible%20solution%20would%20be%20to%20open%20a%20new%20Writer%20and%20change%20the%20code%20to%20write%20to%20it%20%28i.e.%20replacing%20all%20prints%20wi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/googlebookmark.png" class="sociable-img sociable-hovers" title="Google Bookmarks" alt="Google Bookmarks" /></a></li><li><a rel="nofollow"   href="http://www.dzone.com/links/add.html?url=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F&amp;title=Method%20references%20and%20Output%20redirection%20in%20Groovy" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/dzone.png" class="sociable-img sociable-hovers" title="DZone" alt="DZone" /></a></li><li><a rel="nofollow"   href="http://reddit.com/submit?url=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F&amp;title=Method%20references%20and%20Output%20redirection%20in%20Groovy" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/reddit.png" class="sociable-img sociable-hovers" title="Reddit" alt="Reddit" /></a></li><li><a rel="nofollow"   href="http://technorati.com/faves?add=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/technorati.png" class="sociable-img sociable-hovers" title="Technorati" alt="Technorati" /></a></li><li><a rel="nofollow"   href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F&amp;title=Method%20references%20and%20Output%20redirection%20in%20Groovy&amp;source=Cognitive+Consonance+Software+engineering+in+a+computational+biology+environment&amp;summary=When%20doing%20Groovy%20scripts%20I%20sometimes%20have%20the%20need%20to%20redirect%20the%20output%20of%20a%20part%20of%20the%20computation%20that%20is%20going%20to%20standard%20out..%20A%20possible%20solution%20would%20be%20to%20open%20a%20new%20Writer%20and%20change%20the%20code%20to%20write%20to%20it%20%28i.e.%20replacing%20all%20prints%20wi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/linkedin.png" class="sociable-img sociable-hovers" title="LinkedIn" alt="LinkedIn" /></a></li><li><a rel="nofollow"   href="http://www.connotea.org/addpopup?continue=confirm&amp;uri=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F&amp;title=Method%20references%20and%20Output%20redirection%20in%20Groovy&amp;description=When%20doing%20Groovy%20scripts%20I%20sometimes%20have%20the%20need%20to%20redirect%20the%20output%20of%20a%20part%20of%20the%20computation%20that%20is%20going%20to%20standard%20out..%20A%20possible%20solution%20would%20be%20to%20open%20a%20new%20Writer%20and%20change%20the%20code%20to%20write%20to%20it%20%28i.e.%20replacing%20all%20prints%20wi" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/connotea.png" class="sociable-img sociable-hovers" title="connotea" alt="connotea" /></a></li><li><a rel="nofollow"   href="http://www.friendfeed.com/share?title=Method%20references%20and%20Output%20redirection%20in%20Groovy&amp;link=http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/friendfeed.png" class="sociable-img sociable-hovers" title="FriendFeed" alt="FriendFeed" /></a></li><li><a rel="nofollow"   href="http://twitter.com/home?status=Method%20references%20and%20Output%20redirection%20in%20Groovy%20-%20http%3A%2F%2Ftiago.org%2Fcc%2F2008%2F12%2F30%2Fmethod-references-and-output-redirection-in-groovy%2F" ><img src="http://tiago.org/cc/wp-content/plugins/sociable-30/images/default/16/twitter.png" class="sociable-img sociable-hovers" title="Twitter" alt="Twitter" /></a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://tiago.org/cc/2008/12/30/method-references-and-output-redirection-in-groovy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

