in progress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 28 Sep 2012 01:52:24 +0000 (01:52 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 28 Sep 2012 01:52:24 +0000 (01:52 +0000)
forester/ruby/evoruby/exe/run_phylo_pipeline.rb

index d09655f..3c6d0fe 100755 (executable)
@@ -5,35 +5,24 @@
 # Copyright::  Copyright (C) 2010 Christian M. Zmasek
 # License::    GNU Lesser General Public License (LGPL)
 #
-# $Id: run_phylo_pipeline.rb,v 1.15 2010/10/09 02:35:42 cmzmasek Exp $
+# $Id Exp $
 #
 #
 
 
-#  hmmscan --nobias --domtblout <BACTH_CHIPI>_hmmscan_250_10 -E 10 /home/czmasek/DATA/PFAM/PFAM250/Pfam-A.hmm <BACTH_CHIPI>.fasta
-
-#  hsp <BACTH_CHIPI>_hmmscan_250_10 <BACTH_CHIPI>_hmmscan_250_10_domain_table
-
-#  d2f -e=10 <BACTH_CHIPI>_hmmscan_250_10_domain_table <BACTH_CHIPI>.fasta <BACTH_CHIPI>_hmmscan_250_10.dff
-
-# hmmsearch --nobias -E 1000 --domtblout <BACTH_CHIPI>.hmmsearch_SusD  <~/DATA/PFAM/PFAM250/PFAM_A_HMMs/SusD.hmm> BACTH_CHIPI.fasta
+module Evoruby
 
-# dsx -dd -e=<1e-2> -l=<200> <BACTH_CHIPI>.hmmsearch_SusD <BACTH_CHIPI>.fasta BACTH_CHIPI_e2_200
+  class RunPhyloPipeline
 
+    PFAM      = "/home/czmasek/DATA/PFAM/PFAM260X/"
 
-module Evoruby
 
-  class RunPhyloPipeline
 
     def run
       unless ARGV.length == 4
-        puts
-        puts "arguments are: [inputfile].fasta [hmm-name] [min-length] [neg e-value exponent]"
-        puts
-        exit
+        error "arguments are: <fasta formatted inputfile> <hmm-name> <min-length> <neg e-value exponent>"
       end
 
-      pfam      = "/home/czmasek/DATA/PFAM/PFAM260X/"
       hmmscan   = "/home/czmasek/SOFTWARE/HMMER/hmmer-3.0/src/hmmscan"
       hmmsearch = "/home/czmasek/SOFTWARE/HMMER/hmmer-3.0/src/hmmsearch"
       hsp       = "/home/czmasek/SOFTWARE/FORESTER/DEV/forester/forester/ruby/evoruby/exe/hsp.rb"
@@ -46,24 +35,47 @@ module Evoruby
       e_value_exp = ARGV[ 3 ]
       do_domain_combination_analysis = true
 
+      if e_value_exp < 0
+        error "e-value exponent cannot be negative"
+      end
+      if length <= 1
+        error "length exponent cannot be smaller than or equal to 1"
+      end
+
+      if base_name.downcase.end_with?( ".fasta" )
+        base_name = base_name[ 0 .. base_name.length - 7 ]
+      elsif base_name.downcase.end_with?( ".fsa" )
+        base_name = base_name[ 0 .. base_name.length - 5 ]
+      end
+
       if do_domain_combination_analysis
 
-        cmd = "#{hmmscan} --nobias --domtblout #{base_name}_hmmscan_10 -E 10 #{pfam}Pfam-A.hmm #{base_name}.fasta"
+        puts "hmmscan:"
+        cmd = "#{hmmscan} --nobias --domtblout #{base_name}_hmmscan_10 -E 10 #{PFAM}Pfam-A.hmm #{base_name}.fasta"
         run_command( cmd )
+        puts
 
+        puts "hmmscan to simple domain table:"
         cmd = "#{hsp} #{base_name}_hmmscan_10 #{base_name}_hmmscan_10_domain_table"
         run_command( cmd )
+        puts
 
+        puts "domain table to forester format:"
         cmd = "#{d2f} -e=10 #{base_name}_hmmscan_10_domain_table #{base_name}.fasta #{base_name}_hmmscan_10.dff"
         run_command( cmd )
+        puts
 
       end
 
-      cmd = "#{hmmsearch} --nobias -E 1000 --domtblout #{base_name}.hmmsearch_#{hmm}  #{pfam}PFAM_A_HMMs/#{hmm}.hmm #{base_name}.fasta"
+      puts "hmmsearch:"
+      cmd = "#{hmmsearch} --nobias -E 1000 --domtblout #{base_name}.hmmsearch_#{hmm}  #{PFAM}PFAM_A_HMMs/#{hmm}.hmm #{base_name}.fasta"
       run_command( cmd )
+      puts
 
-      cmd = "#{dsx} -dd -e=1e-#{e_value_exp.to_s} -l=#{length} #{base_name}.hmmsearch_#{hmm} #{base_name}.fasta #{base_name}_#{hmm}_e#{e_value_exp.to_s}_#{length}"
+      puts "dsx:"
+      cmd = "#{dsx} -d -e=1e-#{e_value_exp.to_s} -l=#{length} #{hmm} #{base_name}.hmmsearch_#{hmm} #{base_name}.fasta #{base_name}_#{hmm}_e#{e_value_exp.to_s}_#{length}"
       run_command( cmd )
+      puts
 
     end
 
@@ -72,6 +84,13 @@ module Evoruby
       `#{cmd}`
     end
 
+    def error msg
+      puts
+      puts msg
+      puts
+      exit
+    end
+
   end
 
   p = RunPhyloPipeline.new()