[BioRuby] Reading ab1 files in bioruby

Naohisa GOTO ngoto at gen-info.osaka-u.ac.jp
Sun Jul 8 10:25:47 UTC 2012


Hi,

It seems that the Bio::Abif.open opens file with ASCII mode.
With Ruby 1.9 and/or on Windows, with ASCII mode, conversions
of encoding and/or line ending characters may break binary data.

Simple workaround is to open the file with binary mode.

 f = File.open(filename, 'rb')
 chromatogram_ff = Bio::Abif.open(f)
 chromatogram_ff.each do |ch|
   ch.to_seq
 end

With the latest git version, Bio::FlatFile opens file with
binary modde by default, and the problem would not occur. 

Related topic:
http://lists.open-bio.org/pipermail/bioruby/2012-June/002342.html

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

On Sat, 7 Jul 2012 06:35:59 +0300
George Githinji <georgkam at gmail.com> wrote:

> Dear list,
> Is there a Bioruby best practice way of reading an ab1 chromatogram file?
> I am processing a long list of  ab1 chromatogram files like this
> 
> file= "filename"
> chromatogram_ff = Bio::Abif.open(filename)
> chromatogram_ff.each do |ch|
>   ch.to_seq
> end
> 
> however I came across this error with some files
> 
> /Users/george/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bio-1.4.2/lib/bio/db/sanger_chromatogram/abif.rb:107:in
> `get_entry_data': undefined method `match' for nil:NilClass
> (NoMethodError)
> 	from /Users/george/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bio-1.4.2/lib/bio/db/sanger_chromatogram/abif.rb:83:in
> `block in get_directory_entries'
> 	from /Users/george/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bio-1.4.2/lib/bio/db/sanger_chromatogram/abif.rb:77:in
> `times'
> 	from /Users/george/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bio-1.4.2/lib/bio/db/sanger_chromatogram/abif.rb:77:in
> `get_directory_entries'
> 	from /Users/george/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bio-1.4.2/lib/bio/db/sanger_chromatogram/abif.rb:42:in
> `initialize'
> 	from /Users/george/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bio-1.4.2/lib/bio/io/flatfile/splitter.rb:55:in
> `new'
> 	from /Users/george/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bio-1.4.2/lib/bio/io/flatfile/splitter.rb:55:in
> `get_parsed_entry'
> 	from /Users/george/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bio-1.4.2/lib/bio/io/flatfile.rb:288:in
> `next_entry'
> 	from /Users/george/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bio-1.4.2/lib/bio/io/flatfile.rb:335:in
> `each_entry'
> 	from parse_ab1.rb:11:in `<main>'
> 
> 
> When I read the files that generated the error with convert_trace to
> attempt to transform  to scf trace, they are parsed properly meaning
> their is an issue with the way the  abif package works or the
> bio::flatfile iteration procedure in bioruby. Are there known bugs?
> some solution?
> 
> 
> -- 
> ---------------
> Sincerely
> George
> Skype: george_g2
> Blog: http://biorelated.wordpress.com/
> Twitter: http://twitter.com/#!/george_l
> _______________________________________________
> BioRuby Project - http://www.bioruby.org/
> BioRuby mailing list
> BioRuby at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioruby





More information about the BioRuby mailing list