lib/macroape/exec/find_pvalue.rb in macroape-3.2.2 vs lib/macroape/exec/find_pvalue.rb in macroape-3.3.0
- old
+ new
@@ -22,11 +22,13 @@
type motifs/KLF4.pat | ruby find_pvalue.rb .stdin 7.32 4.31 5.42
or in linux
cat motifs/KLF4.pat | ruby find_pvalue.rb .stdin 7.32 4.31 5.42
}
+$:.unshift File.join(File.dirname(__FILE__),'./../../')
require 'macroape'
+require 'bioinform'
if ARGV.empty? or ARGV.include? '-h' or ARGV.include? '-help' or ARGV.include? '--help' or ARGV.include? '--h'
STDERR.puts help_string
exit
end
@@ -54,25 +56,25 @@
when '-b'
background = ARGV.shift(4).map(&:to_f)
when '-d'
discretization = ARGV.shift.to_f
when '-m'
- PWM::MaxHashSize = ARGV.shift.to_f
+ Macroape::MaxHashSizeSingle = ARGV.shift.to_f
end
end
- PWM::MaxHashSize = 1000000 unless defined? PWM::MaxHashSize
+ Macroape::MaxHashSizeSingle = 1000000 unless defined? Macroape::MaxHashSizeSingle
if filename == '.stdin'
- pwm = PWM::SingleMatrix.load_from_stdin(STDIN)
+# TODO
else
raise "Error! File #{filename} doesn't exist" unless File.exist?(filename)
- pwm = PWM::SingleMatrix.load_pat(filename)
+ pwm = Bioinform::PWM.new( File.read(filename) )
end
- pwm = pwm.with_background(background)
+ pwm.background(background)
counts = pwm.discrete(discretization).counts_by_thresholds(* thresholds.map{|count| count * discretization})
- pvalues = counts.map{|count| count.to_f / pwm.number_of_words}
+ pvalues = counts.map{|count| count.to_f / pwm.vocabulary_volume}
pvalues.zip(thresholds,counts).each{|pvalue,threshold,count|
puts "#{threshold}\t#{count}\t#{pvalue}"
}
rescue => err
STDERR.puts "\n#{err}\n#{err.backtrace.first(5).join("\n")}\n\nUse -help option for help\n"
\ No newline at end of file