Read in the masses file.
using System;
using matrix_science.msparser;
namespace MsParserExamples
{
public class config_masses
{
public static void Main(string[] argv)
{
if (argv.Length < 1)
{
Console.Error.WriteLine(@"The location of the masses file has to be specified as a parameter
The location should either be the full path to the masses file
or a URL to a Mascot server - e.g. http://mascot-searver/mascot/cgi
A Mascot security sessionID can optionally be passed as a second
parameter");
return;
}
ms_masses file;
if (argv.Length > 1)
{
ms_connection_settings cs = new ms_connection_settings();
cs.setProxyServerType(ms_connection_settings.PROXY_TYPE.PROXY_TYPE_AUTO);
cs.setSessionID(argv[1]);
file = new ms_masses(argv[0], cs);
}
else
{
file = new ms_masses(argv[0]);
}
if (!file.isValid())
{
Console.Error.WriteLine("Error when reading file {0}", file.getFileName());
checkErrorHandler(file);
return;
}
Console.WriteLine("Name of the file: {0}", file.getFileName());
Console.WriteLine("-------------------------------------------------------------");
Console.WriteLine("--- Content of masses file ---");
Console.WriteLine("-------------------------------------------------------------");
Console.WriteLine("Amino acid masses (monoisotopic and average)");
char res;
for (res = 'A'; res <= 'Z'; res++)
{
Console.WriteLine("{0}:{1:#####.00000},{2:#####.00000}", res,
file.getResidueMass(MASS_TYPE.MASS_TYPE_MONO, res),
file.getResidueMass(MASS_TYPE.MASS_TYPE_AVE, res));
}
Console.WriteLine();
Console.WriteLine("# Atomic masses used for terminus values");
Console.WriteLine("HYDROGEN:{0:#####.00000},{1:#####.00000}",
file.getHydrogenMass(MASS_TYPE.MASS_TYPE_MONO),
file.getHydrogenMass(MASS_TYPE.MASS_TYPE_AVE));
Console.WriteLine("CARBON:{0:#####.00000},{1:#####.00000}",
file.getCarbonMass(MASS_TYPE.MASS_TYPE_MONO),
file.getCarbonMass(MASS_TYPE.MASS_TYPE_AVE));
Console.WriteLine("NITROGEN:{0:#####.00000},{1:#####.00000}",
file.getNitrogenMass(MASS_TYPE.MASS_TYPE_MONO),
file.getNitrogenMass(MASS_TYPE.MASS_TYPE_AVE));
Console.WriteLine("OXYGEN:{0:#####.00000},{1:#####.00000}",
file.getOxygenMass(MASS_TYPE.MASS_TYPE_MONO),
file.getOxygenMass(MASS_TYPE.MASS_TYPE_AVE));
Console.WriteLine("ELECTRON:{0:####0.00000}",
file.getElectronMass());
}
private static void checkErrorHandler(ms_masses file)
{
Console.WriteLine("Testing the error handling... ");
Console.WriteLine("=========================================");
Console.WriteLine("Error string: {0}", file.getLastErrorString());
ms_errs errObject = file.getErrorHandler();
int numErrors = errObject.getNumberOfErrors();
Console.WriteLine("Number of errors: {0}", numErrors);
for (int i = 1; i <= numErrors; i++)
{
Console.WriteLine("Error number {0}: {1}", i, errObject.getErrorString(i));
}
file.clearAllErrors();
Console.WriteLine("Cleared all errors - should have no errors left: {0}", file.getLastErrorString());
}
}
}