Example program for handling errors in the Mascot results files.
#!/usr/bin/python ############################################################################## # file: resfile_error.py # # 'msparser' toolkit example code # # # ############################################################################## # COPYRIGHT NOTICE # # Copyright 1998-2010 Matrix Science Limited All Rights Reserved. # # # ############################################################################## # $Source: parser/examples/test_python/resfile_error.py $ # # $Author: villek@matrixscience.com $ # # $Date: 2018-07-30 16:23:53 +0100 $ # # $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_2_8_1-0-gea32989045 $ # # $NoKeywords:: $ # ############################################################################## import sys import msparser def main() : if len(sys.argv) < 2 : print("Must specify results filename as parameter") return 1 file = msparser.ms_mascotresfile(sys.argv[1]) if file.isValid() : checkErrorHandler(file) else : print("Invalid file: %s" % file.getLastErrorString()) def checkErrorHandler(resfile) : """ Calls a couple of functions with invalid arguments, then prints their error messages. """ print("Testing the error handling... ") print("=========================================") numQueries = resfile.getNumQueries() resfile.getObservedCharge(numQueries + 40); # Should fail print("Error number: %s" % resfile.getLastError()) print("Error string: %s" % resfile.getLastErrorString()) resfile.clearAllErrors() print("Cleared all errors - should have no errors left: %s errors left" %resfile.getNumberOfErrors()) for x in range(1, 21) : resfile.getObservedCharge(numQueries + x); # Should fail # Now, the best way, print out all errors. print("More errors added - there are now %s errors" % resfile.getNumberOfErrors()) for i in range(1, 1 + resfile.getNumberOfErrors()) : print("Error number: %s : %s" % (resfile.getErrorNumber(i), resfile.getErrorString(i))) print(" ") resfile.clearAllErrors() if __name__ == "__main__": sys.exit(main()) """ Running the program as python resfile_error.py F981123.dat will give the following output: 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) """
Copyright © 2022 Matrix Science Ltd. All Rights Reserved. Generated on Thu Mar 31 2022 01:12:29 |