Matrix Science header

resfile_error.pl

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: /vol/cvsroot/parser/examples/test_perl/resfile_error.pl,v $ #
#     $Author: villek $                                                      #
#       $Date: 2010/08/31 08:48:07 $                                         #
#   $Revision: 1.3 $                                                         #
# $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 © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Fri Jun 2 2017 01:44:50