[BioRuby] Problems with Bl2seq parser

GOTO Naohisa ngoto at gen-info.osaka-u.ac.jp
Sun Sep 11 09:20:46 EDT 2005


Hi,

On Thu, 08 Sep 2005 17:10:54 -0500
Trevor Wennblom <trevor at corevx.com> wrote:

> Hi, I seem to be running into some problems with the new Bl2seq parser.
> 
> Ideally I'd like to be able to read the report the same way as blast 
> reports:
>  Bio::Blast::Bl2seq::Report.xmlparser(filename_bl2seq_output).each do |hit|
>    a = hit.identity
>  end
> 
> xmlparser is undefined however, so we can try this:
>  Bio::Blast::Bl2seq::Report.new(filename_bl2seq_output).each do |hit|
>    a = hit.identity
>  end
> 
> This doesn't give an error, but it wont read the report either.  This 
> can be double checked with:
> Bio::Blast::Bl2seq::Report.new(filename_bl2seq_output).to_yaml


Because Report.new gets string (not filename), you can write as follows
on Ruby 1.8.0 or later:

  Bio::Blast::Bl2seq::Report.new(IO.read(filename_bl2seq_output)).each do |hit|
    a = hit.identity
  end

> What I have to do is the following:
>  Bio::FlatFile.open(Bio::Blast::Bl2seq::Report, filename_bl2seq_output) 
> do |ff|
>    ff.each do |rep|
>      rep.iterations.each do |itr|
>        itr.hits.each do |hit|
>          a = hit.identity
>        end
>      end
>    end
>  end

In Bio::Blast::Bl2seq::Report, Iteration is prepared only for compatibility. 
You can skip iterations. In addition, rep.each works nearly same as
rep.hits.each.

  Bio::FlatFile.open(Bio::Blast::Bl2seq::Report, filename_bl2seq_output) do |ff|
    ff.each do |rep|
      rep.each do |hit|
        a = hit.identity
      end
    end
  end

> That's an awful lot of work for what should be a one-liner.  Am I doing 
> something wrong here?
> 
> Thanks,
> Trevor

We're sorry for lack of documents.

-- 
Naohisa GOTO
ngoto at gen-info.osaka-u.ac.jp
Department of Genome Informatics, Genome Information Research Center,
Research Institute for Microbial Diseases, Osaka University, Japan


More information about the BioRuby mailing list