tag:blogger.com,1999:blog-62639243091471968312024-03-07T23:46:27.739-08:00Ruby 1.9.2 support of BioRubyThis is a blog for Google summer of code 2010.Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-6263924309147196831.post-33733012365429522132010-07-18T08:16:00.000-07:002010-07-18T08:16:35.294-07:00Interim ReportAll of the tests for BioRuby classes in bio/, bio/db/ and bio/lib/ are executed correctly, Covering about 90% of total lines.<br />
Although Ruby 1.8.7 outputs some warning, They pass all the tests.<br />
I have skipped other classes in bio/appl/ and bio/io, because of dependency on external library or web services.<br />
I haven't worked on the tests for the classes in bio/shell/, since I don't understand how they are composed.<br />
<br />
A test in bio/, bio/db/ and bio/sequence/ with Ruby 1.9.2 says that BioRuby has some errors about Compatibility of Float, String and methods.<br />
However, almost the classes pass the tests.Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-61920562221676660482010-06-26T21:22:00.000-07:002010-06-26T21:22:09.234-07:00Bio::MEDLINEThere is a unit test for Bio::MEDLINE.<br />
I replaced it into new one.<br />
New Bio::TestMEDLINE tests all of the methods in Bio::MEDLINE and use the same sample file.<br />
It has 100% coverage to Bio::MEDLINE.Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-9503262500109471102010-06-20T15:48:00.000-07:002010-06-20T15:48:02.840-07:00Bio::KEGGThere are 5 files witch don't have the files for unit test.<br />
<br />
I skipped Bio::KEGG::Brite, It probably has the same methods as KEGGDB.<br />
<br />
Bio::TestBioKEGGEXPRESSION outputs the following result now.<br />
<pre>12 tests, 7 assertions, 6 failures, 5 errors</pre>I checked the following error of them. <br />
<pre>4) Error:
test_down_regulated(Bio::TestBioKEGGEXPRESSION):
Errno::EDOM: Numerical argument out of domain - log10
./lib/bio/db/kegg/expression.rb:128:in `log10'
./lib/bio/db/kegg/expression.rb:128:in `logy_minus_logx'
./lib/bio/db/kegg/expression.rb:127:in `each'
./lib/bio/db/kegg/expression.rb:127:in `logy_minus_logx'
./lib/bio/db/kegg/expression.rb:99:in `down_regulated'
test/unit/bio/db/kegg/test_expression.rb:77:in `test_down_regulated'
</pre>The reason is that test_down_regulated gives a negative value to Math.log10.<br />
<br />
I skipped Bio::KEGG::KGML because it is just a wrapper class of REXML.<br />
<br />
I haven't written Bio::KEGG::Common, Bio::KEGG::KEGGTAB and Bio::KEGG::Taxonomy (the latter two classes may not be so important.).Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-53658972646610745512010-06-20T15:26:00.000-07:002010-06-20T15:26:27.755-07:00Bio::GOBio::TestGo class tests almost all code in Bio::GO, Bio::GO::GeneAssociation and Bio::GO::External2GO.<br />
It doesn't cover part of dag_edit_format_parser(str).<br />
In addition, It outputs an error in "to_str" method of Bio::GO::GeneAssociation class, because the method doesn't assume empty value in each instance variable.Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-53580621717046289702010-06-20T15:16:00.000-07:002010-06-20T15:16:04.396-07:00Bio::Sequence<dl><dt><br />
Bio::Sequence::Format::Formatter<br />
</dt>
<dd>I made fake class witch has only a simple output method to test FormatterBase. The unit test class has the test for output method with the fake class. </dd>
<dt><br />
Bio::Sequence::Adapter<br />
</dt>
<dd>It has a clss for a data source class connected by the adapter and a class witch is the interface. In addition, it has adapter class witch extends an adapter module. It tests Bio::Sequence::Adapter through the interface class. </dd> </dl>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-80454569525635234782010-06-20T15:14:00.001-07:002010-06-20T15:14:43.368-07:00Bio::SQL<div style="font-family: Arial;">It has two kinds of unit test.</div><div style="font-family: Arial;">TestBiosqlIO class in ts_biosql.rb connects and accesses MySQL, so It can tests a execution environment to test whether Bio::SQL works.</div><div style="font-family: Arial;">tc_biosql.rb has only a require statement of 'tc_biosql', I'm not understand how to use it.</div><div style="font-family: Arial;">Does it need to test only the logics of the methods in Bio::SQL with the fake class of the database.?</div>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-8270889205788163902010-06-20T15:12:00.000-07:002010-06-20T15:12:35.717-07:00Bio::GenBank<dl><dt>Bio::NCBIDB::Common</dt>
<dd>It is tested in Bio::NCBIDB::TestCommon. Bio::NCBIDBCommon class includes Bio::NCBIDB::Common. Instead of Bio::NCBIDB::Common, It is used in the unit test. This class has low coverage, because a sample entry used in it lacks a lot of fields. There are all the methods except for "locus" method,which is override in the child class. </dd>
<dt><br />
Bio::GenBank<br />
</dt>
<dd>its unit test tests the methods in Bio::GenBank, including the methods returning Bio::GenBank::Locus and Bio::Feature objects Should the sample file be simpler than now? </dd>
<dt><br />
Bio::GenPept<br />
</dt>
<dd>The coverage of this class is 100% It tests only the methods descripbed in the soruce class.(It dosen't test the inherited met hods from NCBIDB) </dd>
<dt><br />
Bio::DDBJ<br />
</dt>
<dd>I didn't write the unit test, since it has the same methods as Bio::GenBank. </dd> Bio::RefSeq <dd>I didn't write the unit test, since it has the same methods as Bio::GenBank. </dd> </dl>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-28924154334892800222010-06-16T05:49:00.000-07:002010-06-16T05:49:23.746-07:00shift to Characterization test<ul><li>I have to make the unit test for the classes someone made.</li>
<li>I have been studying the classes and making the unit tests for them simultaneously.</li>
<li>Some class files have the examples of use in the comment statements</li>
</ul><div>This is why I will start to make the tests with Characterization test until now.</div><div>Basically, I will prepare a test class for a class, and test the behaviors for the methods.</div><div>I won't write tests for private methods. I will write them only for methods that can be accessed externally.</div><div>However, even if they are private methods, they should pass C0 test.(I will manage it with rcov.)</div>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-58175506362390718402010-06-14T20:41:00.000-07:002010-06-14T20:41:54.707-07:00design criteria for Unit Test<ul><li>Prepare unit tests for each class.</li>
<li>For each module, prepare the mock classes that include each the module</li>
<li>When a class is prepared only for internal use or tightly-coupled with another class, I won't prepare the unit test for the class, but prepare it for the central class. </li>
</ul>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-83307714394385163942010-06-14T08:49:00.000-07:002010-06-14T08:49:14.078-07:00What I did in the second week.There are some classes which don't have unit tests in the following directories.<br />
<pre>appl/
compat/
db/
io/
sequence/
shell/
util/
</pre>I'm making unit tests for the classes in db/, such as Bio::PDB::*, Bio::GenBank::*, Bio::KEGG::*.<br />
I'd like to create the unit test completely in the directory within this week.Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-71111043620853599152010-05-30T04:03:00.000-07:002010-05-30T04:03:38.962-07:00start making the unit testsAs I say in my proposal, I started creating the unit tests for BioRuby.<br />
<div>In BioRuby library, 142 files don't have the unit test files.</div><div>I will create the unit test for the files that don't use external libraries or softwares in them by next Sunday.</div><div>Currently I create unit tests for the files in db directry (I know I'm late..).</div><div><br />
</div>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-57491025929660140322010-05-24T04:01:00.001-07:002010-05-24T04:01:27.411-07:00rcov and hecklercov checks line coverages.<br />
<div>Heckle is a mutation tester.</div><div><br />
</div>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-64974435332328205612010-05-20T04:01:00.000-07:002010-05-24T04:02:58.894-07:00What I have to survey<dl><dt>Ruby</dt>
<dd>Difference between 1.8.7 and 1.9.2. How to overcome the difference</dd>
<dt>BioRuby</dt>
<dd>classification of the methods in terms of dependency on other libraries</dd>
<dt>The way of the test</dt>
<dd>The way of writing the unit tests. leaning what behavior I have to check and how do I check them</dd> </dl>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-27892001171875083642010-05-18T04:01:00.000-07:002010-05-24T04:03:27.574-07:00How to detect classes not having the unit tests.Only part of class files have the equivalent test files In BioRuby.<br />
In order to see a whole coverage of the unit test to the all class files with rcov, I have to develop the empty test files for the class files not having them.<br />
The process is as follows.<br />
<h3>First, make sure which files in the lib directory don't have the equivalent test files</h3><br />
<h3>Seconde, prepare each test file in witch the equivalent lib file is required.</h3><h3>Third, execute rcov to visualize the whole coverage</h3><div><br />
</div>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-40942978223665787032010-05-16T04:25:00.000-07:002010-05-16T10:37:04.808-07:00About Code Coverage<div><a href="http://eigenclass.org/hiki.rb?rcov#l15">This page</a> says that "Code Coverage" is divided into the three phases, C0, C1 and C2.</div><div>The following are the summaries of the three phases to one program.</div><div><br />
<div>C0 is How many lines the test code checked.</div><div>C1 is what percentage of the conditional statements the test code checked.</div><div>C2 is whether the test code checked all the likelihood of the procedures.</div></div><div><br />
</div><div>In the case of Ruby, you can visually check C0 with <a href="http://eigenclass.org/hiki.rb?rcov#l3">rcov</a>.</div>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-6497718399921721002010-05-15T05:45:00.000-07:002010-05-19T03:05:43.849-07:00How many tests dose BioRuby have?Bioruby has 235 files in the lib directory and 108 files for the test.<br />
<div>Result from a investigation, the 133 files in the lib directory don't have the test files which are the same names as them.</div><div>On the other hand, the 102 files in the lib directory have the test files.</div><div><div>As for the 6 test files, it is unclear which files they match.</div><div>(There are 9 .rhtml files in the BioRuby, which don't have the files for the unit tests.)</div><div><br />
</div></div>Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0tag:blogger.com,1999:blog-6263924309147196831.post-31581985143421254632010-05-04T02:30:00.000-07:002010-05-05T00:46:13.680-07:00Tips to keep compatibility between various versions<dl>For the purpose of maintaing compatibility between Ruby 1.8 and Ruby 1.9, "Ruby Best Practices" suggests better ways as follows. </dl><dl><dt><b>write codo against Ruby 1.9 first and then backport to 1.8</b></dt><br /><dd>In order to avoid writing too much legacy code, we seem to have to write code supporting the later version first. It cannot apply to my project because BioRuby has already support the earlier version.</dd><br /><dt><b>attempt to find a way to write code that runs natively n both Ruby 1.8 and 1.9</b></dt><br /><dd>Avoid implementing redundant code or modifying core Ruby code as much as possible</dd><br /><dt><b>consider backporting the necessary functionality to Ruby 1.8</b></dt><br /><dd>If a method used in the library is different between Ruby 1.8 and 1.9, you should create new methods in classes of one version for the compatibility. </dd><br /><dt><b>Introduce a helper method that behaves the same on both versions</b></dt><br /><dd>For example, you may add Enumerator to String of Ruby 1.8. That provide the same behavior as "lines" method of Ruby 1.9</dd><br /><dt><b>use brocks for the version checking</b></dt><br /><dd>Don't use a conditional statement. Use the following code<pre>def hoge(bar)<br />ruby_18 {...} || ruby_19 {...}<br />end</pre>this way centralizes incompatibility.</dd></dl><br />reference: Brown G. <i><a href="http://rubybestpractices.com/">Ruby Best Practices</a></i>. O'Reilly Media, Inc. 239-249; 2009.Hayashi Kazuhirohttp://www.blogger.com/profile/09245773117936981308noreply@blogger.com0