X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fruby%2Fevoruby%2Flib%2Fevo%2Ftool%2Fhmmscan_summary.rb;h=bb32da53ffc2b38470d5347f45c2ea97ca9d5935;hb=2f17bcaa7c1b364b5dd8ba7109dea5e5c0575b1e;hp=485da20e4bda1400b1b27ccccef9c5dcfd643170;hpb=9e45dc6637c155a7f44931798e79fa2976256a98;p=jalview.git diff --git a/forester/ruby/evoruby/lib/evo/tool/hmmscan_summary.rb b/forester/ruby/evoruby/lib/evo/tool/hmmscan_summary.rb index 485da20..bb32da5 100644 --- a/forester/ruby/evoruby/lib/evo/tool/hmmscan_summary.rb +++ b/forester/ruby/evoruby/lib/evo/tool/hmmscan_summary.rb @@ -6,7 +6,6 @@ # # $Id: hmmscan_parser.rb,v 1.5 2010/12/13 19:00:11 cmzmasek Exp $ # -# last modified: 121003 require 'set' @@ -21,14 +20,15 @@ module Evoruby class HmmscanSummary PRG_NAME = "hsp" - PRG_VERSION = "2.000" + PRG_VERSION = "2.001" PRG_DESC = "hmmscan summary" - PRG_DATE = "2012.10.23" - COPYRIGHT = "2012 Christian M Zmasek" - CONTACT = "phylosoft@gmail.com" - WWW = "www.phylosoft.org" + PRG_DATE = "2013.10.23" + COPYRIGHT = "2013 Christian M Zmasek" + CONTACT = "phyloxml@gmail.com" + WWW = "https://sites.google.com/site/cmzmasek/home/software/forester" DELIMITER_OPTION = "d" + SPECIES_OPTION = "s" I_E_VALUE_THRESHOLD_OPTION = "ie" FS_E_VALUE_THRESHOLD_OPTION = "pe" HMM_FOR_PROTEIN_OUTPUT = "m" @@ -48,16 +48,14 @@ module Evoruby def run - - - Util.print_program_information( PRG_NAME, - PRG_VERSION, - PRG_DESC, - PRG_DATE, - COPYRIGHT, - CONTACT, - WWW, - STDOUT ) + # Util.print_program_information( PRG_NAME, + # PRG_VERSION, + # PRG_DESC, + # PRG_DATE, + # COPYRIGHT, + # CONTACT, + # WWW, + # STDOUT ) begin cla = CommandLineArguments.new( ARGV ) @@ -66,7 +64,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 +82,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 +115,8 @@ module Evoruby end end + + fs_e_value_threshold = -1.0 if ( cla.is_option_set?( FS_E_VALUE_THRESHOLD_OPTION ) ) begin @@ -146,6 +147,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 @@ -156,41 +166,42 @@ module Evoruby parse_descriptions = true end - puts() - puts( "hmmpfam outputfile : " + inpath ) - puts( "outputfile : " + outpath ) - if ( i_e_value_threshold >= 0.0 ) - puts( "i-E-value threshold : " + i_e_value_threshold.to_s ) - else - puts( "i-E-value threshold : no threshold" ) - end - if ( parse_descriptions ) - puts( "parse descriptions : true" ) - else - puts( "parse descriptions : false" ) - end - if ( ignore_dufs ) - puts( "ignore DUFs : true" ) - else - puts( "ignore DUFs : false" ) - end - if ( column_delimiter == "\t" ) - puts( "column delimiter : TAB" ) - else - puts( "column delimiter : " + column_delimiter ) - end - if fs_e_value_threshold >= 0.0 - puts( "E-value threshold : " + fs_e_value_threshold.to_s ) - else - puts( "E-value threshold : no threshold" ) - end - if !hmm_for_protein_output.empty? - puts( "HMM for proteins : " + hmm_for_protein_output ) - end - if !uniprot.empty? - puts( "Uniprot : " + uniprot ) - end - puts() +# 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 +# puts( "i-E-value threshold : no threshold" ) +# end +# if ( parse_descriptions ) +# puts( "parse descriptions : true" ) +# else +# puts( "parse descriptions : false" ) +# end +# if ( ignore_dufs ) +# puts( "ignore DUFs : true" ) +# else +# puts( "ignore DUFs : false" ) +# end +# if ( column_delimiter == "\t" ) +# puts( "column delimiter : TAB" ) +# else +# puts( "column delimiter : " + column_delimiter ) +# end +# if fs_e_value_threshold >= 0.0 +# puts( "E-value threshold : " + fs_e_value_threshold.to_s ) +# else +# puts( "E-value threshold : no threshold" ) +# end +# if !hmm_for_protein_output.empty? +# puts( "HMM for proteins : " + hmm_for_protein_output ) +# end +# if !uniprot.empty? +# puts( "Uniprot : " + uniprot ) +# end +# puts() begin parse( inpath, @@ -201,21 +212,21 @@ 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 domain_counts = get_domain_counts() - - puts - puts( "domain counts (considering potential i-E-value threshold and ignoring of DUFs):" ) - puts( "(number of different domains: " + domain_counts.length.to_s + ")" ) - puts - puts( Util.draw_histogram( domain_counts, "#" ) ) - puts - Util.print_message( PRG_NAME, 'OK' ) - puts +# puts +# puts( "domain counts (considering potential i-E-value threshold and ignoring of DUFs):" ) +# puts( "(number of different domains: " + domain_counts.length.to_s + ")" ) +# puts +# puts( Util.draw_histogram( domain_counts, "#" ) ) +# puts +# Util.print_message( PRG_NAME, 'OK' ) +# puts end # def run @@ -230,9 +241,8 @@ module Evoruby get_descriptions, fs_e_value_threshold, hmm_for_protein_output, - uniprot ) - - + uniprot, + species ) Util.check_file_for_readability( inpath ) Util.check_file_for_writability( outpath ) @@ -251,8 +261,6 @@ module Evoruby hmmscan_results_per_protein = [] - - prev_query = "" results.each do | r | @@ -263,21 +271,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 +296,8 @@ module Evoruby fs_e_value_threshold, hmm_for_protein_output, i_e_value_threshold, - true ) + uniprot, + species ) end hmmscan_results_per_protein.clear end @@ -303,17 +312,18 @@ 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 ) + uniprot, + species ) end outfile.flush() outfile.close() - end # def parse def process_id( id ) @@ -323,8 +333,6 @@ module Evoruby id end - - def count_model( model ) if ( @domain_counts.has_key?( model ) ) count = @domain_counts[ model ].to_i @@ -339,7 +347,8 @@ 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,12 +356,14 @@ module Evoruby hmmscan_results_per_protein_filtered = [] hmmscan_results_per_protein.each do | r | + + if r.model == hmm_for_protein_output - if r.fs_e_value > fs_e_value_threshold + if fs_e_value_threshold > 0.0 && r.fs_e_value > fs_e_value_threshold return end end - if r.i_e_value <= i_e_value_threshold + if i_e_value_threshold <= 0 || r.i_e_value <= i_e_value_threshold hmmscan_results_per_protein_filtered << r if r.model == hmm_for_protein_output dc += 1 @@ -376,7 +387,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,11 +396,14 @@ module Evoruby s << r.model + " " end s << "\t" - e = UniprotKB::get_entry_by_id( process_id( own.query ) ) - if e != nil - s << uniprot_annotation( e ) - s << "\uniprot_annotationt" + if !uniprotkb.empty? + #e = UniprotKB::get_entry_by_id( process_id( own.query ) ) + + #if e != nil + # s << uniprot_annotation( e ) + # # s << "\uniprot_annotationt" + #end end overview = make_overview( hmmscan_results_per_protein_filtered, hmm_for_protein_output ) @@ -485,7 +499,6 @@ module Evoruby end - def print_help() puts( "Usage:" ) puts() @@ -497,6 +510,7 @@ module Evoruby puts( " -" + IGNORE_DUF_OPTION + ": ignore DUFs" ) puts( " -" + FS_E_VALUE_THRESHOLD_OPTION + ": E-value threshold for full protein sequences, only for protein summary" ) puts( " -" + HMM_FOR_PROTEIN_OUTPUT + ": HMM for protein summary" ) + puts( " -" + SPECIES_OPTION + ": species for protein summary" ) puts() end