]> git.donarmstrong.com Git - function2gene.git/blobdiff - bin/function2gene
update svn ignore
[function2gene.git] / bin / function2gene
index f3bd3ddfd7364a89afac2c4d391e43b3787e8b8d..962be188411a6a59d31b893001924bcedba161ec 100755 (executable)
@@ -53,8 +53,8 @@ the system
 =item B<--database>
 
 Databases to search, can be specified multiple times. [Defaults to
-NCBI, GeneCards and Harvester, the only currently supported
-databases.]
+NCBI, GeneCards and Harvester, but ensembl and uniprot are also
+supported currently.]
 
 =item B<--restart-at>
 
@@ -130,7 +130,7 @@ $ERRORS.="restart-at must be one of get, parse or combine\n" if
 
 $ERRORS.="unknown database(s)" if
      @{$options{databases}} and
-     grep {$_ !~ /^(?:ncbi|genecard|harvester)$/i} @{$options{databases}};
+     grep {$_ !~ /^(?:ncbi|genecard|harvester|ensembl|uniprot)$/i} @{$options{databases}};
 
 if (not length $options{results}) {
      $ERRORS.="results directory not specified";
@@ -192,6 +192,7 @@ if (@{$options{keywords}}) {
               next if /^\s*[#;]/;
               next unless /\w+/;
               chomp;
+              s/\r$//;
               my ($keyword,$weight) = split /\t/, $_;
               $weight = 1 if not defined $weight;
               $state{keyword_weight}{$keyword} = $weight;
@@ -296,6 +297,9 @@ for my $keyword (@{$state{keywords}}) {
      }
 }
 
+$SIG{INT} = sub {
+     save_state(\%state);
+};
 
 for my $state (qw(get parse)) {
      my %databases;
@@ -339,13 +343,18 @@ if ($actions{combine}) {
                           } keys %{$state{done_keywords}{parse}};
 
      # create temporary file to store keyword weights
-
-     write_command_to_file('combined_results.txt',
-                          "$base_dir/combine_results",
-                          '--keywords',
-                          
-                          @parsed_results,
-                         );
+     my $file = IO::File->new('combined_keywords.txt','w') or
+         die "Unable to open combined_keywords.txt for writing: $!";
+     for my $keyword (keys %{$state{keyword_weight}}) {
+         print {$file} "$keyword\t$state{keyword_weight}{$keyword}\n";
+     }
+     system("$base_dir/combine_results",
+           '--keywords','combined_keywords.txt',
+           '--results','combined_results.txt',
+           '--results-table','combined_results_table.txt',
+           @parsed_results,
+          ) == 0
+               or die "combine_results failed with ".($?>>8);
      for my $result (@parsed_results) {
          $result =~ s/^parsed_results_//;
          $result =~ s/\.txt$//;
@@ -353,10 +362,6 @@ if ($actions{combine}) {
          $state{done_keywords}{combined}{$db}{$keyword} = 1;
      }
      save_state(\%state);
-     write_command_to_file('combined_results_table.txt',
-                          "$base_dir/results_to_table",
-                          'combined_results.txt',
-                         );
      ADVISE("Finished; results in $options{results}/combined_results.txt");
 }
 else {