test/test_bfr.rb in bio-polyploid-tools-0.7.3 vs test/test_bfr.rb in bio-polyploid-tools-0.8.0

- old
+ new

@@ -1,14 +1,19 @@ + $: << File.expand_path(File.dirname(__FILE__) + '/../lib') $: << File.expand_path('.') path= File.expand_path(File.dirname(__FILE__) + '/../lib/bioruby-polyploid-tools.rb') +tmp_verb = $VERBOSE +$VERBOSE=nil #puts path require path require 'bio-samtools' require "test/unit" +$VERBOSE=tmp_verb + class TestPolyploidTools < Test::Unit::TestCase #Set up the paths def setupre @@ -38,11 +43,11 @@ setupre reg="gnl|UG|Ta#S22380157" region = @fasta_db.index.region_for_entry(reg).to_region min_cov=20 - puts region.to_s + #puts region.to_s #puts @bam_a.methods ref_seq=@fasta_db.fetch_sequence(region) reg_a = @bam_a.fetch_region({:region=>region, :min_cov=>min_cov, :A=>1}) reg_b = @bam_b.fetch_region({:region=>region, :min_cov=>min_cov, :A=>1}) @@ -54,31 +59,18 @@ called_1 = reg_a.called called_2 = reg_b.called snps_tot = Bio::Sequence.snps_between(cons_1, cons_2) - block_size = 1000 - snps_per_1k_1 = (block_size * snps_1.to_f ) / region.size - snps_per_1k_2 = (block_size * snps_2.to_f ) / region.size - snps_per_1k_tot = (block_size * snps_tot.to_f ) / region.size - - - - #puts "#{region.entry}\t#{region.size}\t" - #puts "#{snps_1}\t#{called_1}\t#{snps_per_1k_1}\t" - #puts "#{snps_2}\t#{called_2}\t#{snps_per_1k_2}\t" - #puts "#{snps_tot}\t#{snps_per_1k_tot}\n" - - + #block_size = 1000 + #snps_per_1k_1 = (block_size * snps_1.to_f ) / region.size + #snps_per_1k_2 = (block_size * snps_2.to_f ) / region.size + #snps_per_1k_tot = (block_size * snps_tot.to_f ) / region.size + snps_tot = Bio::Sequence.snps_between(cons_1, cons_2) snps_to_ref = Bio::Sequence.snps_between(cons_1, ref_seq) - #puts ">ref\n#{ref_seq}" - #puts ">a\n#{cons_1}" - #puts ">b\n#{cons_2}" - #puts "SNPS between: #{snps_tot}" - #puts "SNPS ref: #{snps_to_ref}" - #puts "SNPS call: #{snps_to_ref}" + assert_equal(ref_seq.to_s, "acgcttgaccttaggcctatttaggtgacactatagaacaagtttgtacaaaaaagcaggctggtaccggtccggaattcccgggatatcgtcgacccacgcgtccgcgtccgaccagcacaaacaagactgtactctgggctcctctgactccgtgtcttgctaaaatatctttggtcgactcgttgcgaggttgatcagatggcggaggaagcgaagcaggatgtggcgccacccgcgccggagccgaccgaggacgtcgcggacgagaaggtggcggttccgtcgccggaggagtctaaggccctcgttgtcgccgagaatgacgctgagaagcctgcagctacagggggctcacacgaacgagatgctctgctcacgagggtcgcgaccgagaagaggatttcgctgatcaaggcatgggaggagaacgagaaggccaaagccgagaacaaggccgtgaagttgctggcggacatcacctcgtgggagaactccaaggccgcggaactggaagccgagctcaagaagatgcaagagcagctggagaagaagaaggcgcgctgcgtggagaagctcaagaacagcgccgcgacggtgcacaaagaggcggaangagaagcgtgccgcggcggaagcgcggcacggcgaggagatcgtcgcggcggaggagaccgccgccaagtaccgcgccaagggtgaagcgccgaagaagctgctcttcggcagaagatagatatcgcttcatcttcagcttctctctgtttgaccgnttgcatgtctcctgcccatggcatcacttgtgtatttatctttgggggngatcttagtttgtatggtatcatcaaatgcgtcgtga") assert_equal(cons_1.to_s , "acgcttgaccttaggcctatttaggtgacactatagaacaagtttgtacaaaaaagcaggctggtaccggtccggaattcccgggatatcgtcgacccacgcgtccgcgtccgaccagcacaaacaagactgtactctgggctcctctgactccgtgtcttgctaaaatatytttggtcgactcgttgcgaggttgatcagatggcggaggaagcgaagcaggatgtggcgccacccgcgccggagccgaccgaggacgtcgcggacgagaaggcggcggttccgtcgccggaggagtctaaggccctsgttgtcgccgagaatgacgcygagaagcctgcagctacagggggctcacacgaacgagatgctctgctcacgagggtygcgaccgagaagaggatttcgctgatcaaggcatgggaggagaaygagaaggccaaagccgagaacaaggccgtgaagttgctggcggacatcacctcgtgggagaactccaaggccgcggaactggaagccgagctcaagaagatgcaagagcagctggagaagaagaaggcgcgctgcgtggagaagctcaagaacagcgccgcgacggtgcacaaagaggcgraaggagaagcgtgccgcggcggaagygcggcrcggcgaggagatcgtcgcggcggaggagaccgccgccaagtaccgcgccaagggtgaggcgccgaagaagctgctcttcggcagaggatagatatcgcttcatcttcagcttctctctgtttgaccgnttgcatgtctcctgcccatggcatcacttgtgtatttatctttgggggngatcttagtttgtatggtatcatcaaatgcgtcgtga") assert_equal(cons_2.to_s , "acgcttgaccttaggcctatttaggtgacactatagaacaagtttgtacaaaaaagcaggctggtaccggtccggaattcccgggatatcgtcgacccacgcgtccgcgtccgaccagcacaaacaagactgtactctgggctcctctgactccgtgtcttgctaaaatatytttggtcgactcgttgcgaggttgatcagatggcggasgaagcgaagcaggatgtggcgccacccgcgccggagccgaccgaggacgtcgcggacgagaaggcggcggttccgtcgccggaggartcyaaggccctsgttgtcgccgagaatgacgcygagaagcctgcagctacagggggctcacacgaacgagatgctctgctcacgagggtygcgaccgagaagaggatttcgctgatcaaggcatgggaggagaaygagaaggccaaagccgagaacaaggccgtgaagttgctggcggacatcacctcgtgggagaactccaaggccgcggaactggaagccgagctcaagaagatgcaagagcagctggagaagaagaaggcgcgctgcgtggagaagctcaagaacagcgccgcgacggtgcacaaagaggcgraaggagaagcgtgccgcggcggaagygcggcgcggcgaggagatcgtcgcggcggaggagrccgccgccaagtaccgcgccaagggtgaggcgccgaagaagctgctcttcggcagaagatagatatcgcttcatcttcagcttctctctgtttgaccgnttgcatgtctcctgcccatggcatcacttgtgtatttatctttgggggngatcttagtttgtatggtatcatcaaatgcgtcgtga") assert_equal(snps_tot , 6) assert_equal(snps_to_ref , 12) @@ -106,32 +98,32 @@ assert_equal(@fasta_db.index.entries.size,1) reg = nil @fasta_db.index.entries.each do | r | i = i + 1 - reg = container.process_region({:region => r.get_full_region.to_s,:output_file => output_file , :min_cov => 5} ) + reg = container.process_region({:A => true, :q => 37, :region => r.get_full_region.to_s,:output_file => output_file , :min_cov => 5} ) #puts reg.inspect end with_bfr = [210, 297, 300, 645, 674] bases_1 = Array.new bases_2 = Array.new - bases_1 << {:A=>0, :C=>24, :G=>120, :T=>0} - bases_2 << {:A=>0, :C=>24, :G=>112, :T=>0} - bases_1 << {:A=>34, :C=>0, :G=>138, :T=>0} - bases_2 << {:A=>26, :C=>0, :G=>138, :T=>0} - bases_1 << {:A=>0, :C=>32, :G=>0, :T=>141} - bases_2 << {:A=>0, :C=>26, :G=>0, :T=>142} - bases_1 << {:A=>22, :C=>0, :G=>56, :T=>0} - bases_2 << {:A=>62, :C=>0, :G=>25, :T=>0} - bases_1 << {:A=>27, :C=>0, :G=>22, :T=>0} - bases_2 << {:A=>46, :C=>0, :G=>9, :T=>0} + bases_1 << {:A=>0, :C=>24, :G=>147, :T=>0} + bases_2 << {:A=>0, :C=>33, :G=>142, :T=>0} + bases_1 << {:A=>35, :C=>0, :G=>142, :T=>0} + bases_2 << {:A=>25, :C=>0, :G=>149, :T=>0} + bases_1 << {:A=>0, :C=>32, :G=>0, :T=>146} + bases_2 << {:A=>0, :C=>24, :G=>0, :T=>152} + bases_1 << {:A=>22, :C=>0, :G=>38, :T=>0} + bases_2 << {:A=>49, :C=>0, :G=>20, :T=>0} + bases_1 << {:A=>26, :C=>0, :G=>16, :T=>0} + bases_2 << {:A=>36, :C=>0, :G=>10, :T=>0} i = 0 with_bfr.each do | pos | - puts pos - assert_equal(reg.bases_bulk_1[pos - 1 ] , bases_1[i] ) - assert_equal(reg.bases_bulk_2[pos - 1 ] , bases_2[i] ) + #puts pos + assert_equal(bases_1[i], reg.bases_bulk_1[pos - 1 ] ) + assert_equal(bases_2[i], reg.bases_bulk_2[pos - 1 ] ) i += 1 end \ No newline at end of file