Read in the masses file.
import java.util.Date;
import matrix_science.msparser.*;
public class config_masses {
static {
try {
System.loadLibrary("msparserj");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. "
+ "Is msparserj.dll on the path?\n" + e);
System.exit(0);
}
}
public static void main(String argv[])
{
if (argv.length < 1)
{
System.out.println("The location of masses file has to be specified as a parameter");
System.out.println("The location should either be the full path to the masses file");
System.out.println("or a URL to a Mascot server - e.g. http://mascot-server/mascot/cgi");
System.exit(0);
}
ms_masses file;
if (argv.length > 1)
{
ms_connection_settings cs = new ms_connection_settings();
cs.setSessionID(argv[1]);
file = new ms_masses(argv[0], cs);
}
else
{
file = new ms_masses(argv[0]);
}
if (!file.isValid())
{
System.out.println("Error when reading file: " + file.getFileName());
checkErrorHandler(file);
System.exit(0);
}
System.out.println("Name of the file: " + file.getFileName());
System.out.println("-------------------------------------------------------------");
System.out.println("--- Content of masses file ---");
System.out.println("-------------------------------------------------------------");
System.out.println("Amino acid masses (monoisotopic and average)");
String doubleFormat = "#####.#####";
java.text.DecimalFormat formatted = new java.text.DecimalFormat(doubleFormat);
char res;
for(res='A'; res <= 'Z'; res++)
{
System.out.print(res + ":");
System.out.print(formatted.format(file.getResidueMass(msparser.MASS_TYPE_MONO, res)));
System.out.print("," + formatted.format(file.getResidueMass(msparser.MASS_TYPE_AVE, res)));
System.out.println();
}
System.out.println();
System.out.println("# Atomic masses used for terminus values");
System.out.println("HYDROGEN:"
+ formatted.format(file.getHydrogenMass(msparser.MASS_TYPE_MONO))
+ ","
+ formatted.format(file.getHydrogenMass(msparser.MASS_TYPE_AVE)));
System.out.println("CARBON:"
+ formatted.format(file.getCarbonMass(msparser.MASS_TYPE_MONO))
+ ","
+ formatted.format(file.getCarbonMass(msparser.MASS_TYPE_AVE)));
System.out.println("NITROGEN:"
+ formatted.format(file.getNitrogenMass(msparser.MASS_TYPE_MONO))
+ ","
+ formatted.format(file.getNitrogenMass(msparser.MASS_TYPE_AVE)));
System.out.println("OXYGEN:"
+ formatted.format(file.getOxygenMass(msparser.MASS_TYPE_MONO))
+ ","
+ formatted.format(file.getOxygenMass(msparser.MASS_TYPE_AVE)));
System.out.println("ELECTRON:"
+ formatted.format(file.getElectronMass()));
}
static void checkErrorHandler(ms_masses file)
{
System.out.println("Testing the error handling... ");
System.out.println("=========================================");
System.out.println("Error string: " + file.getLastErrorString());
ms_errs errObject = file.getErrorHandler();
int numErrors = errObject.getNumberOfErrors();
System.out.println("Number of errors: " + numErrors);
int i;
for(i=1; i <= numErrors; i++)
{
System.out.println("Error number " + i + ": " + errObject.getErrorString(i));
}
file.clearAllErrors();
System.out.println("Cleared all errors - should have no errors left: " + file.getLastErrorString());
}
}