[BioRuby] GFF3 Record Equality Method

Naohisa GOTO ngoto at gen-info.osaka-u.ac.jp
Fri Jun 24 12:41:29 UTC 2011


On Thu, 23 Jun 2011 11:05:48 -0400
Michael Barton <mail at michaelbarton.me.uk> wrote:

> As far as I can tell the GFF3 record in bioruby uses Object#== for comparison.
> I'm implementing a Bio::GFF::GFF3::Record#== method based on comparison of the
> GFF3 fields. Would this this be a useful addition to bioruby library?
> 
> Cheers
> 
> Michael Barton

Bio::GFF::GFF3::Record inherits Bio::GFF::GFF2::Record, and
the GFF2::Record already has its own == method. GFF2::Record#==
gives enough functionality for comparing GFF3 records, in
addition to GFF2 records.

#sample code
#-----------------------------------------------------------
 require 'bio'
 str1 = "chrI\tSGD\tcentromere\t151467\t151584\t.\t+\t.\t" +
        "ID=CEN1;Name=CEN1;gene=CEN1;Alias=CEN1,test%3B0001;" +
        "Note=Chromosome I centromere;dbxref=SGD:S000006463;" +
        "Target=test%2002 123 456 -,test%2C03 159 314;" +
        "memo%3Dtest%3Battr=99.9%25%09match"
 str2 = str1.dup
 str3 = str1.gsub(/CEN1/, 'CEN2')
 obj0 = Bio::GFF::GFF3::Record.new(str1)
 obj1 = Bio::GFF::GFF3::Record.new(str1)
 obj2 = Bio::GFF::GFF3::Record.new(str2)
 obj3 = Bio::GFF::GFF3::Record.new(str3)

 p obj0==obj1
 p obj1==obj2
 p obj1==obj3
#-----------------------------------------------------------

--
Naohisa Goto
ngoto at gen-info.osaka-u.ac.jp / ng at bioruby.org



More information about the BioRuby mailing list