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: robertog@matrixscience.com $ #
# $Date: 2024-09-04 10:23:46 +0100 $ #
# $Revision: 526921a73137894bb1eae0b0fc8ccb4bb52ea662 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $ #
# $NoKeywords:: $ #
##############################################################################
use strict;
##############################################################################
use msparser;
if (!defined($ARGV[0])) { die "Must specify results filename as parameter"; }
my $file = msparser::ms_mascotresfilebase::createResfile($ARGV[0]);
if ($file->isValid) {
checkErrorHandler($file);
}
##############################################################################
# checkErrorHandler #
# - parameter 0 ms_mascotresfilebase #
# 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