#
# last modified: 121003
+require 'set'
+
require 'lib/evo/util/constants'
require 'lib/evo/util/util'
require 'lib/evo/util/command_line_arguments'
require 'lib/evo/io/parser/hmmscan_parser'
-require 'lib/evo/io/parser/uniprot_parser'
+require 'lib/evo/io/web/uniprotkb'
module Evoruby
PRG_NAME = "hsp"
PRG_VERSION = "2.000"
PRG_DESC = "hmmscan summary"
- PRG_DATE = "2012.10.19"
+ PRG_DATE = "2012.10.23"
COPYRIGHT = "2012 Christian M Zmasek"
CONTACT = "phylosoft@gmail.com"
WWW = "www.phylosoft.org"
def run
+
+
Util.print_program_information( PRG_NAME,
PRG_VERSION,
PRG_DESC,
allowed_opts.push( IGNORE_DUF_OPTION )
allowed_opts.push( PARSE_OUT_DESCRIPITION_OPTION )
allowed_opts.push( HMM_FOR_PROTEIN_OUTPUT )
- allowed_opts.push( UNIPROT )
+ allowed_opts.push( UNIPROT )
disallowed = cla.validate_allowed_options_as_str( allowed_opts )
if ( disallowed.length > 0 )
Util.fatal_error( PRG_NAME, "error: " + e.to_s, STDOUT )
end
end
-
+
uniprot = ""
- if ( cla.is_option_set?( UNIPROT ) )
+ if ( cla.is_option_set?( UNIPROT ) )
begin
- uniprot = cla.get_option_value( UNIPROT )
+ uniprot = cla.get_option_value( UNIPROT )
rescue ArgumentError => e
Util.fatal_error( PRG_NAME, "error: " + e.to_s, STDOUT )
end
else
puts( "column delimiter : " + column_delimiter )
end
- if fs_e_value_threshold >= 0.0
+ 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?
+ if !hmm_for_protein_output.empty?
puts( "HMM for proteins : " + hmm_for_protein_output )
end
- if !uniprot.empty?
+ if !uniprot.empty?
puts( "Uniprot : " + uniprot )
end
puts()
fs_e_value_threshold,
hmm_for_protein_output,
uniprot )
- rescue ArgumentError, IOError => e
+ rescue IOError => e
Util.fatal_error( PRG_NAME, "error: " + e.to_s, STDOUT )
end
domain_counts = get_domain_counts()
fs_e_value_threshold,
hmm_for_protein_output,
uniprot )
+
+
+
Util.check_file_for_readability( inpath )
Util.check_file_for_writability( outpath )
hmmscan_parser = HmmscanParser.new( inpath )
results = hmmscan_parser.parse
-
- uniprot_entries = nil
- if !uniprot.empty?
- uniprot_entries = read_uniprot( results, uniprot )
- end
-
+
outfile = File.open( outpath, "a" )
query = ""
hmmscan_results_per_protein = []
-
+
prev_query = ""
process_hmmscan_results_per_protein( hmmscan_results_per_protein,
fs_e_value_threshold,
hmm_for_protein_output,
- i_e_value_threshold )
+ i_e_value_threshold,
+ true )
end
hmmscan_results_per_protein.clear
end
end
end
end
- if !hmm_for_protein_output.empty?
- if !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 )
- 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 )
end
+
outfile.flush()
outfile.close()
end # def parse
-
- def read_uniprot( hmmscan_results, uniprot )
- ids = []
- hmmscan_results.each do | r |
- ids << r.query
- end
- uniprot_parser = UniprotParser.new uniprot
- uniprot_entries = uniprot_parser.parse ids
- uniprot_entries
- end
-
+ def process_id( id )
+ if id =~ /(sp|tr)\|\S+\|(\S+)/
+ id = $2
+ end
+ id
+ end
+
+
+
def count_model( model )
if ( @domain_counts.has_key?( model ) )
count = @domain_counts[ model ].to_i
def process_hmmscan_results_per_protein( hmmscan_results_per_protein,
fs_e_value_threshold,
hmm_for_protein_output,
- i_e_value_threshold )
+ i_e_value_threshold,
+ uniprotkb )
dc = 0
# filter according to i-Evalue threshold
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"
+
+
+
+
+ s << "\t"
overview = make_overview( hmmscan_results_per_protein_filtered, hmm_for_protein_output )
s << overview + "\t"