inprogress
[jalview.git] / forester / ruby / evoruby / lib / evo / tool / hmmscan_summary.rb
index db82d4a..92bceb2 100644 (file)
@@ -29,6 +29,7 @@ module Evoruby
     WWW            = "www.phylosoft.org"
 
     DELIMITER_OPTION              = "d"
+    SPECIES_OPTION                = "s"
     I_E_VALUE_THRESHOLD_OPTION    = "ie"
     FS_E_VALUE_THRESHOLD_OPTION   = "pe"
     HMM_FOR_PROTEIN_OUTPUT        = "m"
@@ -66,7 +67,7 @@ module Evoruby
       end
 
       if ( cla.is_option_set?( HELP_OPTION_1 ) ||
-           cla.is_option_set?( HELP_OPTION_2 ) )
+            cla.is_option_set?( HELP_OPTION_2 ) )
         print_help
         exit( 0 )
       end
@@ -84,6 +85,7 @@ module Evoruby
       allowed_opts.push( PARSE_OUT_DESCRIPITION_OPTION )
       allowed_opts.push( HMM_FOR_PROTEIN_OUTPUT )
       allowed_opts.push( UNIPROT )
+      allowed_opts.push( SPECIES_OPTION )
 
       disallowed = cla.validate_allowed_options_as_str( allowed_opts )
       if ( disallowed.length > 0 )
@@ -116,6 +118,8 @@ module Evoruby
         end
       end
 
+      
+
       fs_e_value_threshold = -1.0
       if ( cla.is_option_set?( FS_E_VALUE_THRESHOLD_OPTION ) )
         begin
@@ -146,6 +150,15 @@ module Evoruby
         end
       end
 
+      species = "HUMAN"
+       if ( cla.is_option_set?( SPECIES_OPTION ) )
+        begin
+          species = cla.get_option_value( SPECIES_OPTION )
+        rescue ArgumentError => e
+          Util.fatal_error( PRG_NAME, "error: " + e.to_s, STDOUT )
+        end
+      end
+
       ignore_dufs = false
       if ( cla.is_option_set?( IGNORE_DUF_OPTION ) )
         ignore_dufs = true
@@ -159,6 +172,7 @@ module Evoruby
       puts()
       puts( "hmmpfam outputfile  : " + inpath )
       puts( "outputfile          : " + outpath )
+      puts( "species             : " + species )
       if ( i_e_value_threshold >= 0.0 )
         puts( "i-E-value threshold : " + i_e_value_threshold.to_s )
       else
@@ -201,7 +215,8 @@ module Evoruby
           parse_descriptions,
           fs_e_value_threshold,
           hmm_for_protein_output,
-          uniprot )
+          uniprot,
+          species )
       rescue IOError => e
         Util.fatal_error( PRG_NAME, "error: " + e.to_s, STDOUT )
       end
@@ -230,7 +245,8 @@ module Evoruby
         get_descriptions,
         fs_e_value_threshold,
         hmm_for_protein_output,
-        uniprot )
+        uniprot,
+        species )
 
 
 
@@ -263,21 +279,21 @@ module Evoruby
         env_to    = r.env_to
 
         if ( ( i_e_value_threshold < 0.0 ) || ( i_e_value <= i_e_value_threshold ) ) &&
-           ( !ignore_dufs || ( model !~ /^DUF\d+/ ) )
+            ( !ignore_dufs || ( model !~ /^DUF\d+/ ) )
           count_model( model )
           outfile.print( query +
-             column_delimiter )
+              column_delimiter )
           if ( get_descriptions )
             outfile.print( desc +
-               column_delimiter )
+                column_delimiter )
           end
           outfile.print( model +
-             column_delimiter +
-             env_from.to_s +
-             column_delimiter +
-             env_to.to_s +
-             column_delimiter +
-             i_e_value.to_s )
+              column_delimiter +
+              env_from.to_s +
+              column_delimiter +
+              env_to.to_s +
+              column_delimiter +
+              i_e_value.to_s )
           outfile.print( Constants::LINE_DELIMITER )
         end
 
@@ -288,7 +304,8 @@ module Evoruby
                 fs_e_value_threshold,
                 hmm_for_protein_output,
                 i_e_value_threshold,
-                true )
+                false,
+                species )
             end
             hmmscan_results_per_protein.clear
           end
@@ -303,12 +320,14 @@ module Evoruby
           end
         end
       end
+    
       if !hmm_for_protein_output.empty? && !hmmscan_results_per_protein.empty?
         process_hmmscan_results_per_protein( hmmscan_results_per_protein,
           fs_e_value_threshold,
           hmm_for_protein_output,
           i_e_value_threshold,
-          true )
+          false,
+          species )
       end
 
       outfile.flush()
@@ -339,7 +358,10 @@ module Evoruby
         fs_e_value_threshold,
         hmm_for_protein_output,
         i_e_value_threshold,
-        uniprotkb )
+        uniprotkb,
+        species      )
+      
+    
 
       dc = 0
       # filter according to i-Evalue threshold
@@ -347,6 +369,9 @@ module Evoruby
       hmmscan_results_per_protein_filtered = []
 
       hmmscan_results_per_protein.each do | r |
+        
+        puts r
+        
         if r.model == hmm_for_protein_output
           if r.fs_e_value > fs_e_value_threshold
             return
@@ -376,7 +401,7 @@ module Evoruby
 
       s = ""
       s << own.query + "\t"
-      s << "HUMAN" + "\t"
+      s << species + "\t"
       s << own.fs_e_value.to_s + "\t"
       s << own.qlen.to_s + "\t"
       s << dc.to_s + "\t"
@@ -385,37 +410,17 @@ module Evoruby
         s << r.model + " "
       end
       s << "\t"
-      e = UniprotKB::get_entry_by_id( process_id( own.query ) )
-      # if e != nil && e.de != nil
-      #   e.de.each do |i|
-      #
-      #   end
-      # else
-      #   s << "-"
-      # end
-      s << "\t"
-      if e != nil && e.dr != nil
-        e.dr.each do | dr |
-          if dr != nil
-            if dr =~ /PDB;\s+([A-Z0-9]{4});/
-              s << $1
-
-            end
-          end
-        end
-      else
-        s << "-"
-      end
-      s << "\t"
-
-
-
+      puts s
+      #e = UniprotKB::get_entry_by_id( process_id( own.query ) )
 
+      #if e != nil
+      #  s << uniprot_annotation( e )
+      # # s << "\uniprot_annotationt"
+      #end
 
-      s << "\t"
       overview = make_overview( hmmscan_results_per_protein_filtered, hmm_for_protein_output )
 
-      s << overview   + "\t"
+      s << overview  + "\t"
 
       s << calc_linkers(  hmmscan_results_per_protein_filtered, hmm_for_protein_output )  + "\t"
 
@@ -439,6 +444,18 @@ module Evoruby
       puts s
     end
 
+    def uniprot_annotation( e )
+      s = ""
+      pdb_ids = e.get_pdb_ids
+      if !pdb_ids.empty?
+        pdb_ids.each do | pdb |
+          s << pdb << ", "
+        end
+      else
+        s << "-"
+      end
+      s
+    end
 
     def calc_linkers(  hmmscan_results_per_protein_filtered, hmm_for_protein_output )
       linkers = ""