From 7e8ba7c1388204daa5245d2128d01f6f40298185 Mon Sep 17 00:00:00 2001 From: Naohisa Goto Date: Thu, 18 Aug 2011 00:08:51 +0900 Subject: [PATCH] In Fastq formatter, default width value changed to nil * In Bio::Sequence#output(:fastq) (Fastq output formatter), default width value is changed from 70 to nil, which means "without wrapping". close [Feature #3191] (https://redmine.open-bio.org/issues/3191) --- RELEASE_NOTES.rdoc | 8 ++++++-- lib/bio/db/fastq/format_fastq.rb | 4 ++-- test/unit/bio/db/test_fastq.rb | 12 ++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/RELEASE_NOTES.rdoc b/RELEASE_NOTES.rdoc index 40111373d..8c31b0f6a 100644 --- a/RELEASE_NOTES.rdoc +++ b/RELEASE_NOTES.rdoc @@ -56,9 +56,13 @@ Google Summer of Code 2010. == Incompatible changes -=== Bio::SPTR +=== Bio::Sequence#output(:fastq) -==== CC line topic "WEB RESOURCE" +In Fastq output formatter, default width value is changed from 70 to nil. +The nil means "without wrapping". The new default behavior without wrapping +is generally good with many recent applications that read fastq. + +=== Bio::SPTR CC line topic "WEB RESOURCE" In the return value of Bio::SPTR#cc('WEB RESOURCE'), "NAME" and "NOTE" are now renamed to "Name" and "Note", respectively. The change is due to diff --git a/lib/bio/db/fastq/format_fastq.rb b/lib/bio/db/fastq/format_fastq.rb index 520b37a9c..10bf235c0 100644 --- a/lib/bio/db/fastq/format_fastq.rb +++ b/lib/bio/db/fastq/format_fastq.rb @@ -26,7 +26,7 @@ class Fastq < Bio::Sequence::Format::FormatterBase # *Arguments*: # * _sequence_: Bio::Sequence object # * (optional) :repeat_title => (true or false) if true, repeating title in the "+" line; if not true, "+" only (default false) - # * (optional) :width => _width_: (Fixnum) width to wrap sequence and quality lines; nil to prevent wrapping (default 70) + # * (optional) :width => _width_: (Fixnum) width to wrap sequence and quality lines; nil to prevent wrapping (default nil) # * (optional) :title => _title_: (String) completely replaces title line with the _title_ (default nil) # * (optional) :default_score => _score_: (Integer) default score for bases that have no valid quality scores or error probabilities; false or nil means the lowest score, true means the highest score (default nil) def initialize; end if false # dummy for RDoc @@ -43,7 +43,7 @@ def initialize; end if false # dummy for RDoc # *Returns*:: String object def output title = @options[:title] - width = @options.has_key?(:width) ? @options[:width] : 70 + width = @options.has_key?(:width) ? @options[:width] : nil seq = @sequence.seq.to_s entry_id = @sequence.entry_id || "#{@sequence.primary_accession}.#{@sequence.sequence_version}" diff --git a/test/unit/bio/db/test_fastq.rb b/test/unit/bio/db/test_fastq.rb index 90c68f1f7..9e09ae66b 100644 --- a/test/unit/bio/db/test_fastq.rb +++ b/test/unit/bio/db/test_fastq.rb @@ -369,6 +369,18 @@ def test_to_biosequence end end + def test_to_biosequence_and_output + @ff.each_with_index do |e, i| + id_line = IDLINES[i] + seq_line = SEQS[i] + qual_line = QUALITY_STRINGS[i] + # Changed default width to nil (no wrapping) + expected = "@#{id_line}\n#{seq_line}\n+\n#{qual_line}\n" + actual = e.to_biosequence.output(:fastq_sanger) + assert_equal(expected, actual) + end + end + def test_roundtrip @ff.each_with_index do |e, i| str_orig = @ff.entry_raw