Read in the enzymes file.
using System;
using System.IO;
using matrix_science.msparser;
namespace MsParserExamples
{
public class config_enzymes
{
public static void Main(string[] argv)
{
if (argv.Length < 1)
{
using (TextWriter errorWriter = Console.Error)
{
errorWriter.WriteLine(@"The location of the enzymes file has to be specified as a parameter
The location should either be the full path to the enzymes 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_enzymefile 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_enzymefile(argv[0], cs);
}
else file = new ms_enzymefile(argv[0]);
if (!file.isValid())
{
using (TextWriter errorWriter = Console.Error)
{
errorWriter.WriteLine("Error number: {0}", file.getLastError());
errorWriter.WriteLine("Error string: {0}", file.getLastErrorString());
}
return;
}
int n = file.getNumberOfEnzymes();
Console.WriteLine("There are {0} enzymes definitions available", n);
for (int i = 0; i < n; i++)
{
ms_enzyme _enzyme = file.getEnzymeByNumber(i);
Console.Write("{0}: ", _enzyme.getTitle());
for (int c = 0; c < _enzyme.getNumberOfCutters(); c++)
{
if (_enzyme.getCutterType(c) == ms_enzyme.cuttertype.NTERM_CUTTER)
{
Console.Write("nTerm - ");
}
else
{
Console.Write("cTerm - ");
}
Console.Write("{0}!{1}; ", _enzyme.getCleave(c), _enzyme.getRestrict(c));
}
Console.WriteLine();
_enzyme = null;
}
ms_enzyme enzyme = file.getEnzymeByNumber(0);
enzyme.setSemiSpecific(true);
file.updateEnzymeByNumber(0, enzyme);
file.deleteEnzymeByName("V8-DE");
if (argv[0].ToLower().StartsWith("http"))
{
file.setFileName("copy_enzymes.new");
}
else
{
file.setFileName(argv[0] + ".new");
}
file.save_file();
Console.WriteLine("Updated enzymes file saved to {0}", Path.GetFullPath(file.getFileName()));
Console.WriteLine("There are now {0} enzymes definitions available", file.getNumberOfEnzymes());
}
}
}