From c10572040e209047afd5b964f9f91c4f49d50528 Mon Sep 17 00:00:00 2001 From: martinahansen Date: Fri, 15 Oct 2010 09:17:51 +0000 Subject: [PATCH] add tests for analyze_seq git-svn-id: http://biopieces.googlecode.com/svn/trunk@1136 74ccb610-7750-0410-82ae-013aeee3265d --- bp_bin/analyze_seq | 10 ++++++---- bp_test/in/analyze_seq.in | 4 ++++ bp_test/out/analyze_seq.out.1 | 16 ++++++++++++++++ bp_test/test/test_analyze_seq | 7 +++++++ code_ruby/Maasha/lib/seq.rb | 2 +- 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 bp_test/in/analyze_seq.in create mode 100644 bp_test/out/analyze_seq.out.1 create mode 100755 bp_test/test/test_analyze_seq diff --git a/bp_bin/analyze_seq b/bp_bin/analyze_seq index 81ad0e1..f79d94a 100755 --- a/bp_bin/analyze_seq +++ b/bp_bin/analyze_seq @@ -31,6 +31,7 @@ require 'biopieces' require 'seq' +require 'pp' casts = [] @@ -44,18 +45,19 @@ bp.each_record do |record| comp = seq.composition comp.each_pair do |key,val| - record["RES_#{key}"] = val + record["RES[#{key}]"] = val end - record["HARD_MASK"] = seq.hard_mask - record["SOFT_MASK"] = seq.soft_mask - record["GC"] = ((comp["G"] + comp["C"]).to_f / (seq.len - seq.indels).to_f * 100.0).round(2) + record["SOFT_MASK%"] = seq.soft_mask + record["HARD_MASK%"] = (comp["N"].to_f / (seq.len - seq.indels).to_f * 100.0).round(2) + record["GC%"] = ((comp["G"] + comp["C"]).to_f / (seq.len - seq.indels).to_f * 100.0).round(2) end bp.puts record end + # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< diff --git a/bp_test/in/analyze_seq.in b/bp_test/in/analyze_seq.in new file mode 100644 index 0000000..f956b3f --- /dev/null +++ b/bp_test/in/analyze_seq.in @@ -0,0 +1,4 @@ +SEQ_NAME: test1 +SEQ: ATCGNatcgn-._~ +SEQ_LEN: 14 +--- diff --git a/bp_test/out/analyze_seq.out.1 b/bp_test/out/analyze_seq.out.1 new file mode 100644 index 0000000..8812816 --- /dev/null +++ b/bp_test/out/analyze_seq.out.1 @@ -0,0 +1,16 @@ +SEQ_NAME: test1 +SEQ: ATCGNatcgn-._~ +SEQ_LEN: 14 +RES[A]: 2 +RES[T]: 2 +RES[C]: 2 +RES[G]: 2 +RES[N]: 2 +RES[-]: 1 +RES[.]: 1 +RES[_]: 1 +RES[~]: 1 +SOFT_MASK%: 50.0 +HARD_MASK%: 20.0 +GC%: 40.0 +--- diff --git a/bp_test/test/test_analyze_seq b/bp_test/test/test_analyze_seq new file mode 100755 index 0000000..61c5709 --- /dev/null +++ b/bp_test/test/test_analyze_seq @@ -0,0 +1,7 @@ +#!/bin/bash + +source "$BP_DIR/bp_test/lib/test.sh" + +run "$bp -I $in -O $tmp" +assert_no_diff $tmp $out.1 +clean diff --git a/code_ruby/Maasha/lib/seq.rb b/code_ruby/Maasha/lib/seq.rb index 039c4ce..a8decdb 100644 --- a/code_ruby/Maasha/lib/seq.rb +++ b/code_ruby/Maasha/lib/seq.rb @@ -2,7 +2,7 @@ DNA = %w[a t c g] RNA = %w[a u c g] PROTEIN = %w[f l s y c w p h q r i m t n k v a d e g] -INDELS = %w[.- _ ~] +INDELS = %w[. - _ ~] # Quality scores bases SCORE_PHRED = 33 -- 2.39.5