[BioRuby] New Bio::Sequence and Handlers

Raoul Jean Pierre Bonnal raoul.bonnal at itb.cnr.it
Tue Mar 4 10:08:48 UTC 2008


Hi Goto-San,
my mail was referred to a previous Toshiaki's e-mail (reported below):

By the way, I forgot to tell you but Raoul and me have discussed
about the new Bio::Sequence design in a cafe on Sunday evening
after the hackathon.

Now, we take a way to copy all properties from Bio::GenBank/EMBL/SQL
to Bio::Sequence, it is better if we can retain lazy loading for
Bio::GenBank/EMBL and also keep access to the Bio::SQL database
even after the Bio::Sequence is created (for performance).

class Bio::Sequence

  def initialize
    @entry = Bio::GenBank/EMBL/SQL/Mock object
  end

  def method_missing(arg)
    @entry.__send__(arg)
  end

end

class Bio::Sequence::Mock
  attr_accessor :entry_id, :definition, ....
end

Actually I know that is not wonderful my initialize method, however the
problem about concat is due to the fact in Bio::Sequence coders refer to
@seq(variable) not to seq(method)

Regards,
Toshiaki Katayama


I my example I called Bio::SequenceScratch but if I understood well
perhaps it should be named Mock.

Il giorno mar, 04/03/2008 alle 01.58 +0900, Naohisa GOTO ha scritto:
>    s3 = Bio::Sequence.new(XXXX) # from some object or duck typing?
>    s3.concat(s1)
>    s3.definition = 'this is test'
>    p s3
>    # => ???


connection=Bio::SQL.establish_connection('config/database.yml','development') 
  Bio::SQL.list_entries.each{|entry| entry.each_pair{|key,value| puts
"#{key}=>#{value}"}; puts "---"}
  seq_sql=Bio::SQL.fetch_accession("AJ224122") #returns a Bio::Sequence
obj Bio::Sequence.new(Bio::SQL.new(:entry =>
Bioentry.find_by_accession(accession)))
  seq_standard=Bio::Sequence.new('cccccccccc')
  seq_standard1=Bio::Sequence.new('aaaa')
  pp seq_sql.entry_id
  pp seq_sql.seq
  pp '-------------------------------------'
  pp seq_standard
  pp seq_standard.seq 
  pp '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
  pp seq_standard.concat(seq_sql)
  pp seq_sql.concat(seq_standard) #this doesn't work because concat is
not implemented in Bio::SQL


Console output:
accession=>NC_003098
id=>37
---
accession=>NM_001113246
id=>38
---
accession=>AJ224122
id=>57
---
true
"AJ224122"
"aattaaaacgccacgcaagg..."
"-------------------------------------"
#<Bio::Sequence:0xb7870ac0
 @handler=#<Bio::SequenceScratch:0xb7870a84 @seq="cccccccccc">>
"cccccccccc"
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
"ccccccccccaattaaaacgccacgcaagg..."
/home/febo/Work/Projects/Ruby/bioruby/lib/bio/sequence.rb:82:in `send': undefined method `concat' for #<Bio::SQL:0xb787b2f4> (NoMethodError)
	from /home/febo/Work/Projects/Ruby/bioruby/lib/bio/sequence.rb:82:in `method_missing'
	from lib/biosql.rb:170


--
Ra


More information about the BioRuby mailing list