]> git.donarmstrong.com Git - biopieces.git/commitdiff
added Class method Seq.new_bp to seq.rb
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 13 Oct 2011 09:23:37 +0000 (09:23 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 13 Oct 2011 09:23:37 +0000 (09:23 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1559 74ccb610-7750-0410-82ae-013aeee3265d

code_ruby/lib/maasha/seq.rb
code_ruby/test/maasha/test_seq.rb

index a724339694f27558504f427c31fedcd95167d744..2919cfcba21d1c035d9e03d88b75780f0f30204d 100644 (file)
@@ -46,7 +46,18 @@ class Seq
 
   attr_accessor :seq_name, :seq, :type, :qual
 
-  # Method that generates all possible oligos of a specifed length and type.
+  # Class method to instantiate a new Sequence object given
+  # a Biopiece record.
+  def self.new_bp(record)
+    seq_name = record[:SEQ_NAME]
+    seq      = record[:SEQ]
+    type     = record[:SEQ_TYPE]
+    qual     = record[:SCORES]
+
+    self.new(seq_name, seq, type, qual)
+  end
+
+  # Class method that generates all possible oligos of a specifed length and type.
   def self.generate_oligos(length, type)
     raise SeqError, "Cannot generate negative oligo length: #{length}" if length <= 0
 
index cda1f94045b0752b89deedf75329a7d37803cb94..78a6543792350dd7692c37137b34ea1532c8d86e 100755 (executable)
@@ -14,6 +14,15 @@ class TestSeq < Test::Unit::TestCase
   #    dna.seq = "A\tT\r\tC\nG  "
   #    assert_equal(dna.seq, "ATCG")
   #  end
+  
+  def test_Seq_new_bp_returns_correctly
+    record = {:SEQ_NAME => "test", :SEQ => "ATCG", :SEQ_TYPE => "dna", :SCORES => "hhhh"}
+    seq    = Seq.new_bp(record)
+    assert_equal("test", seq.seq_name)
+    assert_equal("ATCG", seq.seq)
+    assert_equal("dna",  seq.type)
+    assert_equal("hhhh", seq.qual)
+  end
 
   def test_Seq_is_dna_with_no_sequence_type_returns_false
     assert(@entry.is_dna? == false)