From: martinahansen Date: Tue, 1 Oct 2013 18:33:22 +0000 (+0000) Subject: changed Seq.new argument to hash X-Git-Url: https://git.donarmstrong.com/?p=biopieces.git;a=commitdiff_plain;h=a30677c14f1738f6a76e8c12f2e732cdef9958d6 changed Seq.new argument to hash git-svn-id: http://biopieces.googlecode.com/svn/trunk@2223 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/bp_bin/analyze_seq b/bp_bin/analyze_seq index c2b96a5..2c38a27 100755 --- a/bp_bin/analyze_seq +++ b/bp_bin/analyze_seq @@ -39,7 +39,7 @@ options = Biopieces.options_parse(ARGV, casts) Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| input.each_record do |record| if record[:SEQ] - seq = Seq.new(record[:SEQ_NAME], record[:SEQ], record[:SEQ_TYPE], record[:SCORE]) + seq = Seq.new_bp(record) comp = seq.composition comp.each_pair do |key,val| diff --git a/bp_bin/blast_seq_pair b/bp_bin/blast_seq_pair index 73c7415..854ee42 100755 --- a/bp_bin/blast_seq_pair +++ b/bp_bin/blast_seq_pair @@ -175,14 +175,14 @@ Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| end got1 = true - type1 = Seq.new(nil, record[:SEQ][0 ... 100]).type_guess + type1 = Seq.new(seq: record[:SEQ][0 ... 100]).type_guess elsif got2.nil? Fasta.open(infile2, "w") do |fasta_io| fasta_io.puts seq.to_fasta end got2 = true - type2 = Seq.new(nil, record[:SEQ][0 ... 100]).type_guess + type2 = Seq.new(seq: record[:SEQ][0 ... 100]).type_guess end if got1 and got2 diff --git a/bp_bin/find_adaptor b/bp_bin/find_adaptor index f2f593d..c4df418 100755 --- a/bp_bin/find_adaptor +++ b/bp_bin/find_adaptor @@ -53,11 +53,11 @@ casts << {:long=>'deletions', :short=>'d', :type=>'uint', :mandatory=>false, options = Biopieces.options_parse(ARGV, casts) if options[:forward_rc] - options[:forward] = Seq.new("test", options[:forward_rc], :dna).reverse.complement.seq + options[:forward] = Seq.new(seq: options[:forward_rc], type: :dna).reverse.complement.seq end if options[:reverse_rc] - options[:reverse] = Seq.new("test", options[:reverse_rc], :dna).reverse.complement.seq + options[:reverse] = Seq.new(seq: options[:reverse_rc], type: :dna).reverse.complement.seq end raise ArgumentError, "no adaptor specified" unless options[:forward] or options[:reverse] diff --git a/bp_bin/find_homopolymers b/bp_bin/find_homopolymers index c0885e3..c7c98f0 100755 --- a/bp_bin/find_homopolymers +++ b/bp_bin/find_homopolymers @@ -45,7 +45,7 @@ options = Biopieces.options_parse(ARGV, casts) Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| input.each_record do |record| if record[:SEQ] - seq = Seq.new(nil, record[:SEQ]) + seq = Seq.new(seq: record[:SEQ]) longest = Seq::Homopolymer.new("", 0, 0) got_one = false diff --git a/bp_bin/join_seq b/bp_bin/join_seq index b2749e9..5804624 100755 --- a/bp_bin/join_seq +++ b/bp_bin/join_seq @@ -38,7 +38,7 @@ casts << {:long=>'delimiter', :short=>'d', :type=>'string', :mandatory=>true, :d options = Biopieces.options_parse(ARGV, casts) sequences = [] -seq = Seq.new(nil, "") +seq = Seq.new(seq: "") Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| input.each_record do |record| diff --git a/bp_bin/shred_seq b/bp_bin/shred_seq index 94d5835..3229164 100755 --- a/bp_bin/shred_seq +++ b/bp_bin/shred_seq @@ -84,7 +84,7 @@ options = Biopieces.options_parse(ARGV, casts) Biopieces.open(options[:stream_in], options[:stream_out]) do |input, output| input.each_record do |record| if record[:SEQ] and record[:SEQ].length >= options[:size] - entry = Seq.new(record[:SEQ_NAME], record[:SEQ], record[:SCORES]) + entry = Seq.new_bp(record) entry.type = :dna entry.shred(options[:size], options[:coverage]) do |subentry| diff --git a/code_ruby/lib/maasha/embl.rb b/code_ruby/lib/maasha/embl.rb index 66a53c0..80bafee 100644 --- a/code_ruby/lib/maasha/embl.rb +++ b/code_ruby/lib/maasha/embl.rb @@ -87,7 +87,7 @@ class EMBL < Filesys seq = @entry[j + 1 .. i].join.delete(" 0123456789") - Seq.new(nil, seq, :dna) if seq + Seq.new(seq: seq, type: :dna) if seq end # Method to get the base keys from EMBL entry and return these diff --git a/code_ruby/lib/maasha/genbank.rb b/code_ruby/lib/maasha/genbank.rb index 795de75..9635efd 100644 --- a/code_ruby/lib/maasha/genbank.rb +++ b/code_ruby/lib/maasha/genbank.rb @@ -87,7 +87,7 @@ class Genbank < Filesys seq = @entry[j + 1 .. i].join.delete(" 0123456789") - Seq.new(nil, seq, :dna) if seq + Seq.new(seq: seq, type: :dna) if seq end # Method to get the base keys from Genbank entry and return these diff --git a/code_ruby/lib/maasha/locator.rb b/code_ruby/lib/maasha/locator.rb index 70aa861..f9fae94 100644 --- a/code_ruby/lib/maasha/locator.rb +++ b/code_ruby/lib/maasha/locator.rb @@ -35,7 +35,7 @@ class Locator def initialize(locator, seq) @locator = locator @seq = seq - @subseq = Seq.new(nil, "", :dna) + @subseq = Seq.new(seq: "", type: :dna) parse_locator(locator) end @@ -107,7 +107,7 @@ class Locator int_beg = $1.to_i - 1 int_end = $2.to_i - 1 - newseq = Seq.new(nil, @seq.seq[int_beg..int_end], :dna) + newseq = Seq.new(seq: @seq.seq[int_beg..int_end], type: :dna) unless newseq.seq.nil? newseq.reverse!.complement! if comp @@ -117,7 +117,7 @@ class Locator when /^(\d+)$/ pos = $1.to_i - 1 - newseq = Seq.new(nil, @seq.seq[pos], :dna) + newseq = Seq.new(seq: @seq.seq[pos], type: :dna) unless newseq.seq.nil? newseq.reverse!.complement! if comp diff --git a/code_ruby/lib/maasha/sam.rb b/code_ruby/lib/maasha/sam.rb index 074b999..14a910f 100644 --- a/code_ruby/lib/maasha/sam.rb +++ b/code_ruby/lib/maasha/sam.rb @@ -393,7 +393,7 @@ class Sam < Filesys entry[:RNEXT] = rnext entry[:PNEXT] = pnext entry[:TLEN] = tlen - entry[:SEQ] = (qual == '*') ? Seq.new(qname, seq) : Seq.new(qname, seq, qual) + entry[:SEQ] = (qual == '*') ? Seq.new(seq_name: qname, seq: seq) : Seq.new(seq_name: qname, seq: seq, qual: qual) entry[:QUAL] = qual # Optional fields - where some are really important! HATE HATE HATE SAM!!! diff --git a/code_ruby/lib/maasha/seq.rb b/code_ruby/lib/maasha/seq.rb index fd83ba3..a2d5bba 100644 --- a/code_ruby/lib/maasha/seq.rb +++ b/code_ruby/lib/maasha/seq.rb @@ -93,7 +93,7 @@ class Seq type = record[:SEQ_TYPE].to_sym if record[:SEQ_TYPE] qual = record[:SCORES] - self.new(seq_name, seq, type, qual) + self.new(seq_name: seq_name, seq: seq, type: type, qual: qual) end # Class method that generates all possible oligos of a specifed length and type. @@ -125,19 +125,19 @@ class Seq oligos end - # Initialize a sequence object with the following arguments: - # - seq_name: Name of the sequence. - # - seq: The sequence. - # - type: The sequence type - DNA, RNA, or protein - # - qual: An Illumina type quality scores string. - def initialize(seq_name = nil, seq = nil, type = nil, qual = nil) - @seq_name = seq_name - @seq = seq - @type = type - @qual = qual + # Initialize a sequence object with the following options: + # - :seq_name Name of the sequence. + # - :seq The sequence. + # - :type The sequence type - DNA, RNA, or protein + # - :qual An Illumina type quality scores string. + def initialize(options = {}) + @seq_name = options[:seq_name] + @seq = options[:seq] + @type = options[:type] + @qual = options[:qual] - if @qual - raise SeqError, "Sequence length and score length mismatch: #{@seq.length} != #{@qual.length}" if @seq.length != @qual.length + if @qual and @seq.length != @qual.length + raise SeqError, "Sequence length and score length mismatch: #{@seq.length} != #{@qual.length}" end end @@ -343,7 +343,12 @@ class Seq # Method to reverse the sequence. def reverse - Seq.new(self.seq_name, self.seq.reverse, self.type, self.qual ? self.qual.reverse : self.qual) + Seq.new( + seq_name: self.seq_name, + seq: self.seq.reverse, + type: self.type, + qual: (self.qual ? self.qual.reverse : self.qual) + ) end # Method to reverse the sequence. @@ -357,10 +362,11 @@ class Seq def complement raise SeqError, "Cannot complement 0 length sequence" if self.length == 0 - entry = Seq.new - entry.seq_name = self.seq_name - entry.type = self.type - entry.qual = self.qual + entry = Seq.new( + seq_name: self.seq_name, + type: self.type, + qual: self.qual + ) if self.is_dna? entry.seq = self.seq.tr('AGCUTRYWSMKHDVBNagcutrywsmkhdvbn', 'TCGAAYRWSKMDHBVNtcgaayrwskmdhbvn') @@ -424,7 +430,12 @@ class Seq # Method to return a new Seq object with shuffled sequence. def shuffle - Seq.new(self.seq_name, self.seq.split('').shuffle!.join, self.type, self.qual) + Seq.new( + seq_name: self.seq_name, + seq: self.seq.split('').shuffle!.join, + type: self.type, + qual: self.qual + ) end # Method to shuffle a sequence randomly inline. @@ -491,7 +502,7 @@ class Seq seq_name = self.seq_name.nil? ? nil : self.seq_name.dup - Seq.new(seq_name, seq, self.type, qual) + Seq.new(seq_name: seq_name, seq: seq, type: self.type, qual: qual) end # Method that replaces a sequence with a subsequence from a given start position diff --git a/code_ruby/test/maasha/seq/test_assemble.rb b/code_ruby/test/maasha/seq/test_assemble.rb index b5ddb7d..bd1baf0 100755 --- a/code_ruby/test/maasha/seq/test_assemble.rb +++ b/code_ruby/test/maasha/seq/test_assemble.rb @@ -8,34 +8,34 @@ require 'pp' class TestAssemble < Test::Unit::TestCase test "Assemble.pair without overlap returns nil" do - assert_nil(Assemble.pair(Seq.new("test1", "aaaa"), Seq.new("test2", "tttt"))) + assert_nil(Assemble.pair(Seq.new(seq: "aaaa"), Seq.new(seq: "tttt"))) end - test "Assemble.pair with overlap returns the correctly" do - assert_equal("atcGatc", Assemble.pair(Seq.new("test1", "atcg"), Seq.new("test2", "gatc")).seq) - assert_equal("atCGat", Assemble.pair(Seq.new("test1", "atcg"), Seq.new("test2", "cgat")).seq) - assert_equal("aTCGa", Assemble.pair(Seq.new("test1", "atcg"), Seq.new("test2", "tcga")).seq) - assert_equal("ATCG", Assemble.pair(Seq.new("test1", "atcg"), Seq.new("test2", "atcg")).seq) + test "Assemble.pair with overlap returns correctly" do + assert_equal("atcGatc", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "gatc")).seq) + assert_equal("atCGat", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "cgat")).seq) + assert_equal("aTCGa", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "tcga")).seq) + assert_equal("ATCG", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "atcg")).seq) end test "Assemble.pair with overlap and overlap_min returns correctly" do - assert_nil(Assemble.pair(Seq.new("test1", "atcg"), Seq.new("test2", "gatc"), :overlap_min => 2)) - assert_equal("atCGat", Assemble.pair(Seq.new("test1", "atcg"), Seq.new("test2", "cgat"), :overlap_min => 2).seq) + assert_nil(Assemble.pair(Seq.new(seq: "atcg"), Seq.new(seq: "gatc"), :overlap_min => 2)) + assert_equal("atCGat", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "cgat"), :overlap_min => 2).seq) end test "Assemble.pair with overlap and overlap_max returns correctly" do - assert_equal("aTCGa", Assemble.pair(Seq.new("test1", "atcg"), Seq.new("test2", "tcga"), :overlap_max => 3).seq) - assert_nil(Assemble.pair(Seq.new("test1", "atcg"), Seq.new("test2", "atcg"), :overlap_max => 3)) + assert_equal("aTCGa", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg"), Seq.new(seq_name: "t2", seq: "tcga"), :overlap_max => 3).seq) + assert_nil(Assemble.pair(Seq.new(seq: "atcg"), Seq.new(seq: "atcg"), :overlap_max => 3)) end test "Assemble.pair with overlap returns correct quality" do - assert_equal("?", Assemble.pair(Seq.new("test1", "a", :dna, "I"), Seq.new("test2", "a", :dna, "5")).qual) - assert_equal("GH??43", Assemble.pair(Seq.new("test1", "atcg", :dna, "GHII"), Seq.new("test2", "cgat", :dna, "5543")).qual) - assert_equal("I???5", Assemble.pair(Seq.new("test1", "atcg", :dna, "IIII"), Seq.new("test2", "tcga", :dna, "5555")).qual) + assert_equal("?", Assemble.pair(Seq.new(seq_name: "t1", seq: "a", qual: "I"), Seq.new(seq_name: "t2", seq: "a", qual: "5")).qual) + assert_equal("GH??43", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg", qual: "GHII"), Seq.new(seq_name: "t2", seq: "cgat", qual: "5543")).qual) + assert_equal("I???5", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcg", qual: "IIII"), Seq.new(seq_name: "t2", seq: "tcga", qual: "5555")).qual) end test "Assemble.pair with mismatch returns the highest scoring" do - assert_equal("ATCGA", Assemble.pair(Seq.new("t1", "atcga", :dna, "IIIII"), Seq.new("t2", "attga", :dna, "55555"), :mismatches_max => 20).seq) - assert_equal("ATTGA", Assemble.pair(Seq.new("t1", "atcga", :dna, "55555"), Seq.new("t2", "attga", :dna, "IIIII"), :mismatches_max => 20).seq) + assert_equal("ATCGA", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcga", qual: "IIIII"), Seq.new(seq_name: "t2", seq: "attga", qual: "55555"), :mismatches_max => 20).seq) + assert_equal("ATTGA", Assemble.pair(Seq.new(seq_name: "t1", seq: "atcga", qual: "55555"), Seq.new(seq_name: "t2", seq: "attga", qual: "IIIII"), :mismatches_max => 20).seq) end end diff --git a/code_ruby/test/maasha/seq/test_backtrack.rb b/code_ruby/test/maasha/seq/test_backtrack.rb index f244aab..6000dc0 100644 --- a/code_ruby/test/maasha/seq/test_backtrack.rb +++ b/code_ruby/test/maasha/seq/test_backtrack.rb @@ -31,9 +31,9 @@ require 'maasha/seq' class BackTrackTest < Test::Unit::TestCase def setup - # 0 1 - # 01234567890123456789 - @seq = Seq.new("test", "tacgatgctagcatgcacgg") + # 0 1 + # 01234567890123456789 + @seq = Seq.new(seq: "tacgatgctagcatgcacgg") @seq.extend(BackTrack) end diff --git a/code_ruby/test/maasha/seq/test_digest.rb b/code_ruby/test/maasha/seq/test_digest.rb index ca59042..8cb75ad 100755 --- a/code_ruby/test/maasha/seq/test_digest.rb +++ b/code_ruby/test/maasha/seq/test_digest.rb @@ -36,17 +36,17 @@ class TestDigest < Test::Unit::TestCase end test "#each_digest dont raise on ok pattern residue" do - entry = Seq.new("test", "atcg") + entry = Seq.new(seq: "atcg") assert_nothing_raised { entry.each_digest("AGCUTRYWSMKHDVBNagcutrywsmkhdvbn", 4) } end test "#each_digest with no match returns correctly" do - entry = Seq.new("test", "aaaaaaaaaaa") + entry = Seq.new(seq: "aaaaaaaaaaa") assert_equal(entry.seq, entry.each_digest("CGCG", 1).first.seq) end test "#each_digest with matches returns correctly" do - entry = Seq.new("test", "TTTTaaaaTTTTbbbbTTTT") + entry = Seq.new(seq: "TTTTaaaaTTTTbbbbTTTT") seqs = entry.each_digest("TTNT", 1) assert_equal("T", seqs[0].seq) assert_equal("TTTaaaaT", seqs[1].seq) diff --git a/code_ruby/test/maasha/seq/test_dynamic.rb b/code_ruby/test/maasha/seq/test_dynamic.rb index 417b1b2..9879c75 100755 --- a/code_ruby/test/maasha/seq/test_dynamic.rb +++ b/code_ruby/test/maasha/seq/test_dynamic.rb @@ -31,7 +31,7 @@ require 'test/helper' class TestDynamic < Test::Unit::TestCase def setup - @p = Seq.new("test", "atcg") + @p = Seq.new(seq_name: "test", seq: "atcg") @p.extend(Dynamic) end @@ -120,13 +120,13 @@ class TestDynamic < Test::Unit::TestCase end test "#patscan locates three patterns ok" do - p = Seq.new("test", "ataacgagctagctagctagctgactac") + p = Seq.new(seq_name: "test", seq: "ataacgagctagctagctagctgactac") p.extend(Dynamic) assert_equal(3, p.patscan("tag").count) end test "#patscan with pos locates two patterns ok" do - p = Seq.new("test", "ataacgagctagctagctagctgactac") + p = Seq.new(seq_name: "test", seq: "ataacgagctagctagctagctgactac") p.extend(Dynamic) assert_equal(2, p.patscan("tag", 10).count) end diff --git a/code_ruby/test/maasha/seq/test_homopolymer.rb b/code_ruby/test/maasha/seq/test_homopolymer.rb index a574fd8..cae533e 100755 --- a/code_ruby/test/maasha/seq/test_homopolymer.rb +++ b/code_ruby/test/maasha/seq/test_homopolymer.rb @@ -31,9 +31,9 @@ require 'maasha/seq' class HomopolymerTest < Test::Unit::TestCase def setup - # 0 1 - # 01234567890123456789 - @entry = Seq.new("test", "tacgatgctagcatgcacgg") + # 0 1 + # 01234567890123456789 + @entry = Seq.new(seq: "tacgatgctagcatgcacgg") @entry.extend(Homopolymer) end diff --git a/code_ruby/test/maasha/test_locator.rb b/code_ruby/test/maasha/test_locator.rb index dc0fe14..7517417 100755 --- a/code_ruby/test/maasha/test_locator.rb +++ b/code_ruby/test/maasha/test_locator.rb @@ -32,7 +32,7 @@ require 'test/helper' class TestLocator < Test::Unit::TestCase def setup - @seq = Seq.new(nil, "tcatgatcaagatctaacagcagaagtacacttctattta", :dna) + @seq = Seq.new(seq: "tcatgatcaagatctaacagcagaagtacacttctattta", type: :dna) end test "#new with single position returns correctly" do diff --git a/code_ruby/test/maasha/test_seq.rb b/code_ruby/test/maasha/test_seq.rb index d773ae2..e50271d 100755 --- a/code_ruby/test/maasha/test_seq.rb +++ b/code_ruby/test/maasha/test_seq.rb @@ -35,7 +35,7 @@ class TestSeq < Test::Unit::TestCase end test "Seq.new with differnet length SEQ and SCORES raises" do - assert_raise(SeqError) { Seq.new("test", "ATCG", "dna", "hhh") } + assert_raise(SeqError) { Seq.new(seq_name: "test", seq: "ATCG", type: :dna, qual: "hhh") } end test "Seq.new_bp returns correctly" do @@ -218,7 +218,7 @@ class TestSeq < Test::Unit::TestCase end test "#to_fasta wraps correctly" do - entry = Seq.new("test", "ATCG") + entry = Seq.new(seq_name: "test", seq: "ATCG") assert_equal(">test\nAT\nCG\n", entry.to_fasta(2)) end @@ -230,12 +230,12 @@ class TestSeq < Test::Unit::TestCase end test "#to_key with bad residue raises" do - entry = Seq.new("test", "AUCG") + entry = Seq.new(seq_name: "test", seq: "AUCG") assert_raise(SeqError) { entry.to_key } end test "#to_key returns correctly" do - entry = Seq.new("test", "ATCG") + entry = Seq.new(seq_name: "test", seq: "ATCG") assert_equal(54, entry.to_key) end @@ -303,22 +303,22 @@ class TestSeq < Test::Unit::TestCase end test "#hamming_distance returns correctly" do - seq1 = Seq.new("test1", "ATCG") - seq2 = Seq.new("test2", "atgg") + seq1 = Seq.new(seq: "ATCG") + seq2 = Seq.new(seq: "atgg") assert_equal(1, seq1.hamming_distance(seq2)) end test "#hamming_distance with ambiguity codes return correctly" do - seq1 = Seq.new("test1", "ATCG") - seq2 = Seq.new("test2", "atng") + seq1 = Seq.new(seq: "ATCG") + seq2 = Seq.new(seq: "atng") assert_equal(1, seq1.hamming_distance(seq2)) assert_equal(0, seq1.hamming_distance(seq2, ambiguity: true)) end test "#edit_distance returns correctly" do - seq1 = Seq.new("test1", "ATCG") - seq2 = Seq.new("test2", "tgncg") + seq1 = Seq.new(seq: "ATCG") + seq2 = Seq.new(seq: "tgncg") assert_equal(2, seq1.edit_distance(seq2)) end @@ -351,7 +351,7 @@ class TestSeq < Test::Unit::TestCase end test "#+ without qual returns correctly" do - entry = Seq.new("test1", "at") + Seq.new("test2", "cg") + entry = Seq.new(seq_name: "test1", seq: "at") + Seq.new(seq_name: "test2", seq: "cg") assert_nil(entry.seq_name) assert_equal("atcg", entry.seq) assert_nil(entry.type) @@ -359,7 +359,7 @@ class TestSeq < Test::Unit::TestCase end test "#+ with qual returns correctly" do - entry = Seq.new("test1", "at", :dna, "II") + Seq.new("test2", "cg", :dna, "JJ") + entry = Seq.new(seq_name: "test1", seq: "at", type: :dna, qual: "II") + Seq.new(seq_name: "test2", seq: "cg", type: :dna, qual: "JJ") assert_nil(entry.seq_name) assert_equal("atcg", entry.seq) assert_equal(:dna, entry.type) @@ -368,32 +368,32 @@ class TestSeq < Test::Unit::TestCase test "#<< with different types raises" do @entry.seq = "atcg" - assert_raise(SeqError) { @entry << Seq.new("test", "atcg", :dna) } + assert_raise(SeqError) { @entry << Seq.new(seq_name: "test", seq: "atcg", type: :dna) } end test "#<< with missing qual in one entry raises" do @entry.seq = "atcg" @entry.type = :dna - assert_raise(SeqError) { @entry << Seq.new("test", "atcg", :dna, "IIII") } + assert_raise(SeqError) { @entry << Seq.new(seq_name: "test", seq: "atcg", type: :dna, qual: "IIII") } @entry.qual = "IIII" - assert_raise(SeqError) { @entry << Seq.new("test", "atcg", :dna) } + assert_raise(SeqError) { @entry << Seq.new(seq_name: "test", seq: "atcg", type: :dna) } end test "#<< with nil qual in both entries dont raise" do @entry.seq = "atcg" - assert_nothing_raised { @entry << Seq.new("test", "atcg") } + assert_nothing_raised { @entry << Seq.new(seq_name: "test", seq: "atcg") } end test "#<< with qual in both entries dont raise" do @entry.seq = "atcg" @entry.type = :dna @entry.qual = "IIII" - assert_nothing_raised { @entry << Seq.new("test", "atcg", :dna, "IIII") } + assert_nothing_raised { @entry << Seq.new(seq_name: "test", seq: "atcg", type: :dna, qual: "IIII") } end test "#<< without qual returns correctly" do @entry.seq = "atcg" - @entry << Seq.new("test", "ATCG") + @entry << Seq.new(seq_name: "test", seq: "ATCG") assert_equal("atcgATCG", @entry.seq) end @@ -401,13 +401,13 @@ class TestSeq < Test::Unit::TestCase @entry.seq = "atcg" @entry.type = :dna @entry.qual = "HHHH" - @entry << Seq.new("test", "ATCG", :dna, "IIII") + @entry << Seq.new(seq_name: "test", seq: "ATCG", type: :dna, qual: "IIII") assert_equal("atcgATCG", @entry.seq) assert_equal("HHHHIIII", @entry.qual) end test "#[] with qual returns correctly" do - entry = Seq.new("test", "atcg", :dna, "FGHI") + entry = Seq.new(seq_name: "test", seq: "atcg", type: :dna, qual: "FGHI") e = entry[2] @@ -420,7 +420,7 @@ class TestSeq < Test::Unit::TestCase end test "#[] without qual returns correctly" do - entry = Seq.new("test", "atcg") + entry = Seq.new(seq_name: "test", seq: "atcg") e = entry[2] @@ -431,9 +431,9 @@ class TestSeq < Test::Unit::TestCase end test "[]= with qual returns correctly" do - entry = Seq.new("test", "atcg", :dna, "FGHI") + entry = Seq.new(seq_name: "test", seq: "atcg", type: :dna, qual: "FGHI") - entry[0] = Seq.new("foo", "T", :dna, "I") + entry[0] = Seq.new(seq_name: "foo", seq: "T", type: :dna, qual: "I") assert_equal("test", entry.seq_name) assert_equal("Ttcg", entry.seq) @@ -442,9 +442,9 @@ class TestSeq < Test::Unit::TestCase end test "[]= without qual returns correctly" do - entry = Seq.new("test", "atcg") + entry = Seq.new(seq_name: "test", seq: "atcg") - entry[0] = Seq.new("foo", "T") + entry[0] = Seq.new(seq_name: "foo", seq: "T") assert_equal("test", entry.seq_name) assert_equal("Ttcg", entry.seq)