]> git.donarmstrong.com Git - function2gene.git/commitdiff
* Add --invalidate-state option to specifically invalidate a state
authorDon Armstrong <don@donarmstrong.com>
Wed, 12 Dec 2007 00:42:08 +0000 (00:42 +0000)
committerDon Armstrong <don@donarmstrong.com>
Wed, 12 Dec 2007 00:42:08 +0000 (00:42 +0000)
git-svn-id: file:///srv/svn/function2gene/trunk@21 a0738b58-4706-0410-8799-fb830574a030

bin/function2gene

index ed9a38ca23a3b948c7c07913c62efde34d1949a5..c407047418332d93c80fac96b7712dae31a611e3 100755 (executable)
@@ -28,6 +28,7 @@ use Storable;
   --results directory to store results in
   --database databases to search
   --restart-at mode to start searching at
+  --invalidate-state state to invalidate
   --debug, -d debugging level (Default 0)
   --help, -h display this help
   --man, -m display manual
@@ -59,6 +60,14 @@ If you need to restart the process at a particular state (which has
 already been completed) specify this option. Valid values are get,
 parse, or combine.
 
+=item B<--invalidate-state>
+
+This is a more powerful version of --restart-at, which can
+specifically invalidate a certain method,database,keyword combination.
+
+For example, you can request that the keyword foo be retreived again
+from ncbi using --invalidate-state 'get,ncbi,foo'
+
 =item B<--debug, -d>
 
 Debug verbosity. (Default 0)
@@ -99,10 +108,12 @@ my %options = (databases       => [],
               help            => 0,
               man             => 0,
               results         => '',
+              invalidate_state => [],
               );
 
 GetOptions(\%options,'keywords=s@','databases=s@',
           'restart_at|restart-at=s','results=s',
+          'invalidate_state|invalidate-state=s@',
           'debug|d+','help|h|?','man|m');
 
 pod2usage() if $options{help};
@@ -206,6 +217,24 @@ if (exists $options{restart_at} and length $options{restart_at}) {
      }
 }
 
+if (exists $options{invalidate_state}) {
+     for my $invalidate_state (@{$options{invalidate_state}}) {
+         my ($method,$database,$keyword) = split /,/, $invalidate_state;
+         if (not exists $state{done_keywords}{$method}) {
+              print STDERR "Method '$method' does not exist, and cannot be invalidated\n";
+         }
+         elsif (not exists $state{done_keywords}{$method}{$database}) {
+              print STDERR "Database '$database' does not exist for method '$method', and cannot be invalidated\n";
+         }
+         elsif (not exists $state{done_keywords}{$method}{$database}{$keyword}) {
+              print STDERR "Keyword '$keyword' does not exist for database '$database' and method '$method', and cannot be invalidated\n";
+         }
+         else {
+              delete $state{done_keywords}{$method}{$database}{$keyword};
+         }
+     }
+}
+
 # now we need to figure out what has to happen
 # for each keyword, we check to see if we've got results, parsed
 # results, and combined it. If not, we queue up those actions.