Example program for handling errors in the Mascot results files.
using System;
using matrix_science.msparser;
namespace MsParserExamples
{
public class resfile_error
{
public static void Main(string[] argv)
{
if (argv.Length < 1)
{
Console.WriteLine("Must specify results filename as parameter");
return;
}
ms_mascotresfilebase file = ms_mascotresfilebase.createResfile(argv[0], 0, "");
if (file.isValid())
{
checkErrorHandler(file);
}
else
{
Console.WriteLine("Error number: {0}", file.getLastError());
Console.WriteLine("Error string: {0}", file.getLastErrorString());
return;
}
}
private static void checkErrorHandler(ms_mascotresfilebase file)
{
int numberOfQueries, loop, loopTwo;
Console.WriteLine("Testing the error handling... ");
Console.WriteLine("=========================================");
numberOfQueries = file.getNumQueries();
file.getObservedCharge(numberOfQueries + 40);
Console.WriteLine("Error number: {0}", file.getLastError());
Console.WriteLine("Error string: {0}", file.getLastErrorString());
file.clearAllErrors();
Console.WriteLine("Cleared all errors - should have no errors left: {0} errors left", file.getNumberOfErrors());
for (loop = 1; loop <= 20; loop++)
{
file.getObservedCharge(numberOfQueries + loop);
}
Console.WriteLine("More errors added - there are now {0} errors", file.getNumberOfErrors());
for (loopTwo = 1; loopTwo <= file.getNumberOfErrors(); loopTwo++)
{
Console.WriteLine("Error number: {0} : {1}", file.getErrorNumber(loopTwo), file.getErrorString(loopTwo));
}
Console.WriteLine();
file.clearAllErrors();
}
}
}