X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fruby%2Fevoruby%2Flib%2Fevo%2Ftool%2Fphylogenies_decorator.rb;h=1eea808704e646c8b56b43306940e43f07f4ff79;hb=2d569f0ff0e0c8fa5d21ca6b3446a152132ff1de;hp=85e247830d746ebd01fb8f0775e5d770cd70c358;hpb=156517428746b21481eb815bf860ffb6cb0314ef;p=jalview.git diff --git a/forester/ruby/evoruby/lib/evo/tool/phylogenies_decorator.rb b/forester/ruby/evoruby/lib/evo/tool/phylogenies_decorator.rb index 85e2478..1eea808 100644 --- a/forester/ruby/evoruby/lib/evo/tool/phylogenies_decorator.rb +++ b/forester/ruby/evoruby/lib/evo/tool/phylogenies_decorator.rb @@ -30,8 +30,8 @@ module Evoruby #DECORATOR_OPTIONS_DOMAINS = '-r=1' DECORATOR_OPTIONS_DOMAINS = '-p -t' IDS_MAPFILE_SUFFIX = '.nim' - DOMAINS_MAPFILE_SUFFIX = '.dff' - SLEEP_TIME = 0.1 + DOMAINS_MAPFILE_SUFFIX = '_hmmscan_10.dff' + SLEEP_TIME = 0.05 REMOVE_NI = true TMP_FILE_1 = '___PD1___' TMP_FILE_2 = '___PD2___' @@ -40,10 +40,10 @@ module Evoruby JAVA_HOME = ENV[Constants::JAVA_HOME_ENV_VARIABLE] PRG_NAME = "phylogenies_decorator" - PRG_DATE = "2012.10.11" + PRG_DATE = "2013.11.15" PRG_DESC = "decoration of phylogenies with sequence/species names and domain architectures" PRG_VERSION = "1.02" - COPYRIGHT = "2012 Christian M Zmasek" + COPYRIGHT = "2013 Christian M Zmasek" CONTACT = "phylosoft@gmail.com" WWW = "https://sites.google.com/site/cmzmasek/home/software/forester" @@ -166,6 +166,12 @@ module Evoruby log << counter.to_s + ': ' + phylogeny_file + ' -> ' + outfile + NL phylogeny_id = get_id( phylogeny_file ) + if phylogeny_id == nil || phylogeny_id.size < 1 + Util.fatal_error( PRG_NAME, 'could not get id from ' + phylogeny_file.to_s ) + end + puts + Util.print_message( PRG_NAME, "id: " + phylogeny_id ) + log << "id: " + phylogeny_id + NL ids_mapfile_name = nil domains_mapfile_name = nil @@ -175,7 +181,6 @@ module Evoruby domains_mapfile_name = get_file( files, phylogeny_id, DOMAINS_MAPFILE_SUFFIX ) seqs_file_name = get_seq_file( files, phylogeny_id ) - begin Util.check_file_for_readability( domains_mapfile_name ) rescue ArgumentError @@ -195,22 +200,34 @@ module Evoruby end cmd = decorator + - ' -p -f=m ' + phylogeny_file + ' ' + + ' -t -p -f=m ' + phylogeny_file + ' ' + seqs_file_name + ' ' + TMP_FILE_1 puts cmd - execute_cmd( cmd, log ) + begin + execute_cmd( cmd, log ) + rescue Error + Util.fatal_error( PRG_NAME, 'error: ' + $! ) + end cmd = decorator + ' ' + DECORATOR_OPTIONS_DOMAINS + ' ' + '-f=d ' + TMP_FILE_1 + ' ' + domains_mapfile_name + ' ' +TMP_FILE_2 puts cmd - execute_cmd( cmd, log ) + begin + execute_cmd( cmd, log ) + rescue Error + Util.fatal_error( PRG_NAME, 'error: ' + $! ) + end cmd = decorator + ' ' + DECORATOR_OPTIONS_SEQ_NAMES + ' ' + '-f=n ' + TMP_FILE_2 + ' ' + ids_mapfile_name + ' ' + outfile puts cmd - execute_cmd( cmd, log ) + begin + execute_cmd( cmd, log ) + rescue Error + Util.fatal_error( PRG_NAME, 'error: ' + $! ) + end File.delete( TMP_FILE_1 ) File.delete( TMP_FILE_2 ) @@ -236,13 +253,17 @@ module Evoruby def get_id( phylogeny_file_name ) - phylogeny_file_name =~ /^([^_]+)/ - $1 + if phylogeny_file_name =~ /^(.+?)__/ + return $1 + elsif phylogeny_file_name =~ /^(.+?)_/ + return $1 + end + nil end def get_file( files_in_dir, phylogeny_id, suffix_pattern ) matching_files = Array.new - matching_suffix_files = Array.new + files_in_dir.each { | file | if ( !File.directory?( file ) && @@ -251,24 +272,14 @@ module Evoruby file =~ /^#{phylogeny_id}.*#{suffix_pattern}$/ ) matching_files << file end - if ( !File.directory?( file ) && - file !~ /^\./ && - file !~ /^00/ && - file =~ /#{suffix_pattern}$/ ) - matching_suffix_files << file - end } - if matching_files.length < 1 && matching_suffix_files.length == 1 - return matching_suffix_files[ 0 ] - end - - if matching_files.length < 1 && matching_suffix_files.length < 1 + if matching_files.length < 1 Util.fatal_error( PRG_NAME, 'no file matching [' + phylogeny_id + - '_] [' + suffix_pattern + '] present in current directory' ) + '...' + suffix_pattern + '] present in current directory' ) end if matching_files.length > 1 - Util.fatal_error( PRG_NAME, 'more than one file matching [' + phylogeny_id + - '_] [' + suffix_pattern + '] present in current directory' ) + Util.fatal_error( PRG_NAME, 'more than one file matching [' + + phylogeny_id + '...' + suffix_pattern + '] present in current directory' ) end matching_files[ 0 ] end @@ -281,17 +292,18 @@ module Evoruby if ( !File.directory?( file ) && file !~ /^\./ && file !~ /^00/ && - file =~ /^#{phylogeny_id}.+\d$/ ) + ( file =~ /^#{phylogeny_id}__.+\d$/ || file =~ /^#{phylogeny_id}_.*\.fasta$/ ) ) matching_files << file end - } if matching_files.length < 1 - Util.fatal_error( PRG_NAME, 'no seq file matching [' + phylogeny_id + '] present in current directory' ) + Util.fatal_error( PRG_NAME, 'no seq file matching [' + + phylogeny_id + '_] present in current directory' ) end if matching_files.length > 1 - Util.fatal_error( PRG_NAME, 'more than one seq file matching [' + phylogeny_id + '] present in current directory' ) + Util.fatal_error( PRG_NAME, 'more than one seq file matching [' + + phylogeny_id + '_] present in current directory' ) end matching_files[ 0 ] end