Example program for handling errors in the Mascot results files.
#!/usr/local/bin/perl ############################################################################## # file: resfile_error_handling.pl # # 'msparser' toolkit example code # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1998-2010 Matrix Science Limited All Rights Reserved. # # # ############################################################################## # $Source: parser/examples/test_perl/resfile_error.pl $ # # $Author: villek@matrixscience.com $ # # $Date: 2018-07-30 16:23:53 +0100 $ # # $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_2_8_1-0-gea32989045 $ # # $NoKeywords:: $ # ############################################################################## use strict; ############################################################################## use msparser; if (!defined($ARGV[0])) { die "Must specify results filename as parameter"; } my $file = new msparser::ms_mascotresfile($ARGV[0]); if ($file->isValid) { checkErrorHandler($file); } ############################################################################## # checkErrorHandler # # - parameter 0 ms_mascotresfile # # Calls a couple of functions with invalid arguments # ############################################################################## sub checkErrorHandler { my ($resfile) = @_; print "Testing the error handling... \n"; print "=========================================\n"; my $numQueries = $resfile->getNumQueries(); $resfile->getObservedCharge($numQueries + 40); # Should fail print "Error number: ", $resfile->getLastError(), "\n"; print "Error string: ", $resfile->getLastErrorString(), "\n"; $resfile->clearAllErrors(); print "Cleared all errors - should have no errors left: ", $resfile->getNumberOfErrors(); print " errors left\n\n"; for my $x (1 .. 20) { $resfile->getObservedCharge($numQueries + $x); # Should fail } # Now, the best way, print out all errors. print "More errors added - there are now ", $resfile->getNumberOfErrors(); print " errors\n"; for my $i (1 .. $resfile->getNumberOfErrors) { print "Error number: ", $resfile->getErrorNumber($i); print " : ", $resfile->getErrorString($i); print "\n"; } print "\n"; $resfile->clearAllErrors(); } =pod Running the program as 'perl resfile_error.pl ../data/F981123.dat' will give the following output under Mascot Server 2.3: Testing the error handling... ========================================= Error number: 4 Error string: Query out of range. In function getObservedCharge. Request query 107, num queries: 67 Cleared all errors - should have no errors left: 0 errors left More errors added - there are now 2 errors Error number: 4 : Query out of range. In function getObservedCharge. Request query 68, num queries: 67 Error number: 4 : Query out of range. In function getObservedCharge. Request query 69, num queries: 67 (Error repeated 19 times) =cut
Copyright © 2022 Matrix Science Ltd. All Rights Reserved. Generated on Thu Mar 31 2022 01:12:29 |