Mercurial > repos > fgiacomoni > hmdb_ms_search
diff lib/hmdb.pm @ 22:453fbe98925a draft
" master branch Updating with tag :CI_COMMIT_TAG - - Fxx"
author | fgiacomoni |
---|---|
date | Fri, 20 Nov 2020 17:29:18 +0000 |
parents | 63ba1cb240b7 |
children | 2d8a310e86ce |
line wrap: on
line diff
--- a/lib/hmdb.pm Thu Feb 14 08:36:52 2019 -0500 +++ b/lib/hmdb.pm Fri Nov 20 17:29:18 2020 +0000 @@ -222,6 +222,55 @@ } ## END of SUB + +=head2 METHOD checkHmdbUrlEntries + + ## Description : check a list of HMDB_IDs by testing what is the status of their uri (HTTP 200 or not) + ## Input : $urlRoot, $entries + ## Output : $validEntries + ## Usage : my ( $validEntries ) = checkHmdbUrlEntries ( $entries ) ; + +=cut +## START of SUB +sub checkHmdbUrlEntries { + ## Retrieve Values + my $self = shift ; + my ( $urlRoot, $clusters, $maxQuery ) = @_; + my ( @ValidResults, @validFeature ) = ( (), () ) ; + + foreach my $resultsByMass (@{$clusters}) { + my $currentQuery = 0 ; + foreach my $feature (@{$resultsByMass}) { + + if ($feature->{ENTRY_ENTRY_ID}) { + + my $url = $urlRoot.$feature->{ENTRY_ENTRY_ID} ; + if ( get($url)) { + $currentQuery ++ ; + if ($currentQuery > $maxQuery) { + last ; + } + else { + push (@validFeature, $feature) ; +# print "Url is valid ($url) - - add to final results\n" ; + } + } + else { +# print "Url is NOT valid ($url) - - Deleting to final results\n" ; + next ; + } + } + } # END FOREACH FEATURE + my @tmp = @validFeature ; + push (@ValidResults, \@tmp) ; + @validFeature = () ; + } # END FOREACH RESULTS + + return (\@ValidResults) ; +} +### END of SUB + + =head2 METHOD testMatchesFromHmdbWithUA ## Description : test a single query with tests parameters on hmdb - get the status of the complete server infra.