Tag Archives: ruby

The Life Scientists at FriendFeed: 2009 summary

The Life Scientists

The Life Scientists 2009


It’s Christmas Eve tomorrow and so I declare the year over. My Christmas gift to you is a summary of activity in 2009 at the FriendFeed Life Scientists group. It’s crafted using R + Ruby, with raw data and some code snippets available. If you want to see the most popular items from the group this year, head down to the bottom of this post.

(Note: this post is a work in progress)
Read the rest…

Good software, data and your brain

I recently asked the FriendFeed community about wiki usage and was struck by a comment from Allyson:

I think we’re on our third incarnation of various bits of wiki software, and we’ve finally hit on the right software for both our wet lab and bioinformaticians

By “the right software”, she means software that makes sense to the people who use it. When faced with several software alternatives, we often find there is one which for some reason, “makes sense” – it meshes naturally with the way our brains work. When you find a program that you like, it’s not only a joy to use but can enable understanding of data and processes that previously eluded you. In other words, good software doesn’t shield you from the fundamentals – it illuminates them.
Here are three examples of software that made me say: “Oh right! Now I get it.” These are not recommendations and opinions expressed are highly subjective: the point is, I like them because they work for me.
Read the rest…

DokuWiki, PubMed and Ruby

I recently built a wiki for a research group using DokuWiki, one of my favourite wiki packages. As with many other wikis, developers have extended its functionality by writing plugins. Some of these are excellent, allowing users to generate lots of content with a minimum of syntax. For example, using the PubMed plugin, you type this:

{{pubmed>long:15595725}}

and the result is this:
pubmed

Which got me thinking. Assuming that you’ve searched PubMed and retrieved a bunch of references in XML format, how might you generate text in DokuWiki syntax, to paste into your wiki? Here’s the small parser that I wrote in ruby:

#!/usr/bin/ruby
require 'rubygems'
require 'hpricot'

h = {}
d = Hpricot.XML(open('pubmed_result.xml'))

(d/:PubmedArticle).each do |a|
  (h["=== #{a.at('DateCreated/Year').inner_html} ==="] ||= []) << "{{pubmed>long:#{a.at('PMID').inner_html}}}"
end

puts h.sort {|a,b| b<=>a}

Nine lines – how cool is that? It uses Hpricot to parse the XML and creates a hash of arrays. Hash key is the year, formatted to show a level 4 headline in DokuWiki; hash value is an array of PMIDs, formatted with PubMed plugin syntax. At the end we just print it all out, sorting by year from newest – oldest.

As Pierre would say – that’s it.

Thoughts on other programming languages

With respect to their potential for bioinformatics web applications:

Feature Python Ruby
Modern, clean syntax, object-oriented Yes Yes
Web framework Django (and others) Rails (and others)
Bio library BioPython BioRuby
Extensive Bio graphics library Not really – any more than this? Kind of – Bio::Graphics
Use with App Engine Yes Not yet
Well-regarded by scientific programmers Yes M. Wood, J. Badger, ??

To the novice, it looks like “much of a muchness”. Thoughts?