* Transition from do_it_all_state to function2gene_state
* Fix invalidate_state function to invalidate state dependencies
git-svn-id: file:///srv/svn/function2gene/trunk@23
a0738b58-4706-0410-8799-
fb830574a030
A file which contains a newline delinated list of keywords to search
for. Can be specified multiple times. Lines starting with # or ; are
A file which contains a newline delinated list of keywords to search
for. Can be specified multiple times. Lines starting with # or ; are
+ignored. An optional weight can be specified after the keyword, which
+is separated from the keyword by a tab. (If not specified, 1 is
+assumed.)
chdir $options{results} or die "Unable to chdir to $options{results}";
chdir $options{results} or die "Unable to chdir to $options{results}";
-if (-e "do_it_all_state") {
+if (-e "function2gene_state") {
ADVISE("Using existing state information");
ADVISE("Using existing state information");
- my $state_fh = IO::File->new("do_it_all_state",'r') or die
+ my $state_fh = IO::File->new("function2gene_state",'r') or die
"Unable to open state file for reading: $!";
local $/;
my $state_file = <$state_fh>;
"Unable to open state file for reading: $!";
local $/;
my $state_file = <$state_fh>;
next if /^\s*[#;]/;
next unless /\w+/;
chomp;
next if /^\s*[#;]/;
next unless /\w+/;
chomp;
+ my ($keyword,$weight) = split /\t/, $_;
+ $weight = 1 if not defined $weight;
+ $state{keyword_weight}{$keyword} = $weight;
if (not $old_keywords{$_}) {
DEBUG("Adding new keyword '$_'");
push @new_keywords, $_;
if (not $old_keywords{$_}) {
DEBUG("Adding new keyword '$_'");
push @new_keywords, $_;
if (exists $options{invalidate_state}) {
for my $invalidate_state (@{$options{invalidate_state}}) {
my ($method,$database,$keyword) = split /,/, $invalidate_state;
if (exists $options{invalidate_state}) {
for my $invalidate_state (@{$options{invalidate_state}}) {
my ($method,$database,$keyword) = split /,/, $invalidate_state;
+ if (grep {not defined $_ } ($method,$database,$keyword) ) {
+ print STDERR "The invalidate state option '$invalidate_state' is invalid.\n";
+ next;
+ }
if (not exists $state{done_keywords}{$method}) {
print STDERR "Method '$method' does not exist, and cannot be invalidated\n";
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}) {
+ if (not exists $state{done_keywords}{$method}{$database}) {
print STDERR "Database '$database' does not exist for method '$method', and cannot be invalidated\n";
print STDERR "Database '$database' does not exist for method '$method', and cannot be invalidated\n";
+ next;
+ }
+ if (not length $keyword) {
+ delete $state{done_keywords}{$method}{$database};
+ if ($method eq 'get') {
+ delete $state{done_keywords}{parse}{$database};
+ delete $state{done_keywords}{combine}{$database};
+ }
+ if ($method eq 'parse') {
+ delete $state{done_keywords}{combine}{$database};
+ }
+ next;
- elsif (not exists $state{done_keywords}{$method}{$database}{$keyword}) {
+ if (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";
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};
+ delete $state{done_keywords}{$method}{$database}{$keyword};
+ if ($method eq 'get') {
+ delete $state{done_keywords}{parse}{$database}{$keyword};
+ delete $state{done_keywords}{combine}{$database}{$keyword};
+ }
+ if ($method eq 'parse') {
+ delete $state{done_keywords}{combine}{$database}{$keyword};
}
save_state(\%state);
if ($ERRORS) {
}
save_state(\%state);
if ($ERRORS) {
- WARN("Stoping, as there are errors");
+ WARN("Stoping, asthere are errors");
} keys %{$state{done_keywords}{parse}{$db}}
} keys %{$state{done_keywords}{parse}};
} keys %{$state{done_keywords}{parse}{$db}}
} keys %{$state{done_keywords}{parse}};
+ # create temporary file to store keyword weights
+
write_command_to_file('combined_results.txt',
"$base_dir/combine_results",
write_command_to_file('combined_results.txt',
"$base_dir/combine_results",
@parsed_results,
);
for my $result (@parsed_results) {
@parsed_results,
);
for my $result (@parsed_results) {
sub save_state{
my ($state) = @_;
sub save_state{
my ($state) = @_;
- my $state_fh = IO::File->new("do_it_all_state",'w') or die
+ my $state_fh = IO::File->new("function2gene_state",'w') or die
"Unable to open state file for writing: $!";
print {$state_fh} freeze($state) or die "Unable to freeze state file";
close $state_fh or die "Unable to close state file: $!";
"Unable to open state file for writing: $!";
print {$state_fh} freeze($state) or die "Unable to freeze state file";
close $state_fh or die "Unable to close state file: $!";