inprogress
[jalview.git] / forester / ruby / evoruby / lib / evo / tool / phylogenies_decorator.rb
index 1128be6..6006729 100644 (file)
@@ -10,7 +10,7 @@
 # $Id: phylogenies_decorator.rb,v 1.34 2010/12/13 19:00:11 cmzmasek Exp $
 #
 # Environment variable FORESTER_HOME needs to point to the appropriate
-# directory (e.g. setenv FORESTER_HOME $HOME/SOFTWARE_DEV/ECLIPSE_WORKSPACE/forester-atv/)
+# directory (e.g. setenv FORESTER_HOME $HOME/SOFTWARE_DEV/ECLIPSE_WORKSPACE/forester/)
 
 require 'lib/evo/util/constants'
 require 'lib/evo/util/util'
@@ -24,7 +24,7 @@ module Evoruby
 
     #DECORATOR_OPTIONS_SEQ_NAMES = '-r=1 -mdn'
     #DECORATOR_OPTIONS_SEQ_NAMES = '-p -t -sn'
-    DECORATOR_OPTIONS_SEQ_NAMES = '-p -t -c -tc'
+    DECORATOR_OPTIONS_SEQ_NAMES = '-p -t -c -tc -mp -or'
     # -mdn is a hidden expert option to rename e.g. "6_ORYLA3" to "6_[3]_ORYLA"
     #DECORATOR_OPTIONS_SEQ_NAMES = '-sn -r=1'
     #DECORATOR_OPTIONS_DOMAINS = '-r=1'
@@ -44,7 +44,7 @@ module Evoruby
     PRG_VERSION    = "1.02"
     COPYRIGHT      = "2012 Christian M Zmasek"
     CONTACT        = "phylosoft@gmail.com"
-    WWW            = "www.phylosoft.org"
+    WWW            = "https://sites.google.com/site/cmzmasek/home/software/forester"
 
     IDS_ONLY_OPTION     = "n"
     DOMAINS_ONLY_OPTION = "d"
@@ -224,6 +224,7 @@ module Evoruby
             cmd = decorator + ' ' + DECORATOR_OPTIONS_DOMAINS + ' ' +
              '-f=d ' + phylogeny_file + ' ' +
              domains_mapfile_name + ' ' + my_outfile
+            puts cmd
             execute_cmd( cmd, log )
           end
 
@@ -236,6 +237,7 @@ module Evoruby
             cmd = decorator + ' ' +  DECORATOR_OPTIONS_SEQ_NAMES + ' ' +
              '-f=n ' + my_infile + ' ' +
              ids_mapfile_name + ' ' + outfile
+            puts cmd
             execute_cmd( cmd, log )
           end
 
@@ -269,6 +271,7 @@ module Evoruby
 
     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 ) &&
@@ -277,11 +280,22 @@ 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
+      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
         Util.fatal_error( PRG_NAME, 'no file matching [' + phylogeny_id +
            '_] [' + suffix_pattern + '] present in current directory' )
-      elsif matching_files.length > 1
+      end
+      if matching_files.length > 1
         Util.fatal_error( PRG_NAME, 'more than one file matching [' + phylogeny_id +
            '_] [' + suffix_pattern + '] present in current directory' )
       end
@@ -294,7 +308,7 @@ module Evoruby
       puts( "  " + PRG_NAME + ".rb [options] <suffix of intrees to be decorated> <suffix for decorated outtrees> " )
       puts()
       puts( "  options: -" + IDS_ONLY_OPTION + ": decorate with sequence/species names only" )
-      puts( "           -" + DOMAINS_ONLY_OPTION + ": decorate with domain structures" )
+      puts( "           -" + DOMAINS_ONLY_OPTION + ": decorate with domain structures only" )
       puts()
     end
   end # class PhylogenyiesDecorator