<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Biorelated &#187; algorithms</title>
	<atom:link href="http://biorelated.com/category/algorithms/feed/" rel="self" type="application/rss+xml" />
	<link>http://biorelated.com</link>
	<description>[bioinformatics,biology,ruby,rails].each do &#124;b&#124; puts b.blog end</description>
	<lastBuildDate>Thu, 17 Dec 2009 14:02:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='biorelated.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/41054b22bbe7debbf1d63972772e21fa?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Biorelated &#187; algorithms</title>
		<link>http://biorelated.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://biorelated.com/osd.xml" title="Biorelated" />
	<atom:link rel='hub' href='http://biorelated.com/?pushpress=hub'/>
		<item>
		<title>Approximate string matching metrics with amatch</title>
		<link>http://biorelated.com/2009/01/06/approximate-string-matching-metrics-with-amatch/</link>
		<comments>http://biorelated.com/2009/01/06/approximate-string-matching-metrics-with-amatch/#comments</comments>
		<pubDate>Tue, 06 Jan 2009 14:18:49 +0000</pubDate>
		<dc:creator>biorelated</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[bioinformatics]]></category>
		<category><![CDATA[bioruby]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://biorelated.wordpress.com/?p=75</guid>
		<description><![CDATA[Most often in sequence analysis we want to compare how  similar two sequences are. How can we quantify similarity by using a metric? That was my question yesterday and I went hunting for a ruby implementation for such metrics. Luckily I got a library called amatch which is an approximate string matching extension for ruby! [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=biorelated.com&amp;blog=1167040&amp;post=75&amp;subd=biorelated&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Most often in sequence analysis we want to compare how  similar two sequences are. How can we quantify similarity by using a metric? That was my question yesterday and I went hunting for a ruby implementation for such metrics. Luckily I got a library called <a title="amatch" href="http://amatch.rubyforge.org/" target="_blank">amatch</a> which is an approximate string matching extension for ruby! amatch implements the following metrics:</p>
<p>Hamming distance,  Levenshtein edit distance,longest subsequence common to two strings,longest substring common to two strings,sellers distance and pair distance which is based on the number of adjacent character pairs, that are contained in two  strings.</p>
<p><strong>Hamming distance</strong></p>
<p>This is the number of characters that are different between two strings. This is not recommended for the majority of string based information retrieval. Very similar strings can sometimes be given high hamming distances.</p>
<p><strong>Leveshtein edit distance </strong></p>
<p>Is defined as the minimal costs involved in transforming one string into another by using  deletion, insertion and substitution of a character to one of the strings. The algorithm can associate a cost for performing each of the operations and for this metric it is usually 1.</p>
<p><strong>Longest common substring</strong></p>
<p>This is define as the contiguous chain of characters that exists in both strings. The longer the substring the better the match between the two strings. The problem with this approach is that if a difference was introduced in the middle of one string, the distance will be longer that if the same difference was introduced at the beginning of one of the strings.</p>
<p><strong>Longest common Subsequence</strong></p>
<p>The longer the common sub sequence is, the more similar the two strings will be. In this case a sub sequence does not have to be contiguous.</p>
<p>Look at the <a title="amatch documentation" href="http://amatch.rubyforge.org/doc/index.html" target="_blank">documentation</a> for more explanations of the metrics and algorithms.</p>
<p>To use the library you need to first install the gem. I installed it on my Linux box running Ubuntu and ruby 1.8.6.</p>
<pre><span style="color:#993366;">sudo gem install amatch</span></pre>
<p>Then in script,</p>
<pre><span style="color:#993366;">require 'rubygems'
</span>
<span style="color:#993366;">require 'amatch'</span></pre>
<pre><span style="color:#993366;">include Amatch</span><span style="color:#993366;">
require  'bio'</span></pre>
<pre><span style="color:#993366;">#with bioruby it would be easy to compare two sequence entries  for example</span></pre>
<pre><span style="color:#993366;">seq_obj1 = Bio::Sequence.auto("actagatatttgat")
seq_obj2 = Bio::Sequence.auto("gccagatagttaat")

#calculate the hamming distance
 m = Hamming.new(seq_obj1.to_seq)
 m.match(seq_obj2.to_seq)</span>
<span style="color:#993366;">#=&gt; 

#calculate pair-distances between the two sequences
</span><span style="color:#993366;">pair_distance_obj = PairDistance.new(seq_obj1.seq)
pair_distance_obj.match(seq_obj2.seq)</span>
 <span style="color:#993366;">#=&gt;</span>
<span style="color:#993366;"># note that you can just substitute the strings directly to the metric object creation method
without creating the sequence objects!
</span></pre>
<p>Note that amatch  failed to install on windows XP with the following error</p>
<p><span style="color:#ff6600;">B</span><span style="color:#ff6600;"><span style="color:#ff6600;">uilding</span> native extensions.  This could take a while&#8230;<br />
ERROR:  Error installing amatch:<br />
ERROR: Failed to build gem native extension.</span></p>
<p><span style="color:#ff6600;">C:/ruby-1.8.6/ruby/bin/ruby.exe extconf.rb install amatch<br />
creating Makefile</span></p>
<p><span style="color:#ff6600;">nmake<br />
&#8216;nmake&#8217; is not recognized as an internal or external command,<br />
operable program or batch file.</span></p>
<p>Although i have nmake installed on my windows machine. I will look at that later.</p>
<p>Happy string matching!</p>
<pre><span style="color:#993366;">
</span></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/biorelated.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/biorelated.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/biorelated.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/biorelated.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/biorelated.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/biorelated.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/biorelated.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/biorelated.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/biorelated.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/biorelated.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/biorelated.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/biorelated.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/biorelated.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/biorelated.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=biorelated.com&amp;blog=1167040&amp;post=75&amp;subd=biorelated&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://biorelated.com/2009/01/06/approximate-string-matching-metrics-with-amatch/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e14f1be0972ff1f393cc87dbd072e1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">george_g</media:title>
		</media:content>
	</item>
		<item>
		<title>A Ruby algorithms resource</title>
		<link>http://biorelated.com/2007/11/17/a-ruby-algorithms-resource/</link>
		<comments>http://biorelated.com/2007/11/17/a-ruby-algorithms-resource/#comments</comments>
		<pubDate>Sat, 17 Nov 2007 08:50:20 +0000</pubDate>
		<dc:creator>biorelated</dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://biorelated.wordpress.com/2007/11/17/a-ruby-algorithms-resource/</guid>
		<description><![CDATA[An algorithm is a procedure to accomplish a specific task. They solve general well specified problems and are the ideas behind computer programs. Rubyquiz is an interesting repository for ruby programs that implement queit interesting algorithms. Even though the programs may not have anything to do with biology, some of the algorithms definitely do. It [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=biorelated.com&amp;blog=1167040&amp;post=19&amp;subd=biorelated&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://biorelated.wordpress.com/2007/11/17/a-ruby-algorithms-resource/ruby-quiz-resource/" target="_blank" rel="attachment wp-att-20" title="Ruby quiz resource"><img src="http://biorelated.files.wordpress.com/2007/11/ruby_quiz_logo.thumbnail.jpg" alt="Ruby quiz resource" /></a>An algorithm is a procedure to accomplish a specific task. They solve general well specified problems and are the ideas behind computer programs.</p>
<p><a href="http://www.rubyquiz.com/index.html" title="Ruby Quiz" target="_blank">Rubyquiz</a> is an interesting repository for ruby programs  that implement queit interesting algorithms. Even though the programs may not  have anything to do with biology, some of the algorithms definitely do.  It is a good place to a find a start point for your ruby algorithm implementation. Browsing the different sets of problems can give a lot of insight on how to approach some common programming problems eg. writing an <a href="http://www.rubyquiz.com/quiz37.html" title="inference engine" target="_blank">inference engine</a>, <a href="http://www.rubyquiz.com/quiz74.html" title="hidden markov" target="_blank">a hidden markov</a> chain , <a href="http://www.rubyquiz.com/quiz103.html" target="_blank">dictionary matcher</a> etc</p>
<p>The site has about 147 quizzes as of this writing.  <a href="http://www.rubyquiz.com/index.html" title="Ruby Quiz" target="_blank">Take a look!</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/biorelated.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/biorelated.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/biorelated.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/biorelated.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/biorelated.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/biorelated.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/biorelated.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/biorelated.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/biorelated.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/biorelated.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/biorelated.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/biorelated.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/biorelated.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/biorelated.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/biorelated.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/biorelated.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=biorelated.com&amp;blog=1167040&amp;post=19&amp;subd=biorelated&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://biorelated.com/2007/11/17/a-ruby-algorithms-resource/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d9e14f1be0972ff1f393cc87dbd072e1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">george_g</media:title>
		</media:content>

		<media:content url="http://biorelated.files.wordpress.com/2007/11/ruby_quiz_logo.thumbnail.jpg" medium="image">
			<media:title type="html">Ruby quiz resource</media:title>
		</media:content>
	</item>
	</channel>
</rss>