From 46cf4e23403a86316829f79bcaeccdd55fe64f9b Mon Sep 17 00:00:00 2001 From: Isaak Date: Fri, 21 Jul 2023 16:41:48 +0200 Subject: [PATCH] speed up cached training data check --- lib/SGN/Controller/solGS/CachedResult.pm | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/SGN/Controller/solGS/CachedResult.pm b/lib/SGN/Controller/solGS/CachedResult.pm index f18865d02a..8d9d5f6f27 100644 --- a/lib/SGN/Controller/solGS/CachedResult.pm +++ b/lib/SGN/Controller/solGS/CachedResult.pm @@ -375,13 +375,8 @@ sub check_cached_genotype_data { $c->controller('solGS::Files')->genotype_file_name( $c, $pop_id ); my $file = $c->stash->{genotype_file_name}; - my $cached; - if ( -s $file ) { - my @rows = read_file( $file, { binmode => ':utf8' } ); - $cached = 1 if $rows[1]; - } - - return $cached; + my $count = $c->controller('solGS::Utils')->count_data_rows($file); + return $count; } @@ -391,13 +386,8 @@ sub check_cached_phenotype_data { $c->controller('solGS::Files')->phenotype_file_name( $c, $pop_id ); my $file = $c->stash->{phenotype_file_name}; - my $cached; - if ( -s $file ) { - my @rows = read_file( $file, { binmode => ':utf8' } ); - $cached = 1 if $rows[1]; - } - - return $cached; + my $count = $c->controller('solGS::Utils')->count_data_rows($file); + return $count; }