Example program for retrieving input spectrum data.
import java.util.Date;
import matrix_science.msparser.*;
public class resfile_input {
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("Must specify results filename as parameter");
System.exit(0);
}
ms_mascotresfilebase file = ms_mascotresfilebase.createResfile(argv[0], 0, "");
if (file.isValid()) {
inputData(file);
} else {
System.out.println("Error number: "+file.getLastError());
System.out.println("Error string: "+file.getLastErrorString());
System.exit(0);
}
}
private static void inputData(ms_mascotresfilebase file) {
int i;
int j;
int num_peaks;
for(i=1; i <=1; i++) {
System.out.println("Input data for query number "+i);
System.out.println("=========================================");
ms_inputquery q=new ms_inputquery(file,i);
System.out.println(" title : "+q.getStringTitle(true));
System.out.println(" mass_min : "+q.getMassMin());
System.out.println(" mass_max : "+q.getMassMax());
System.out.println(" int_min : "+q.getIntMin());
System.out.println(" int_max : "+q.getIntMax());
System.out.println(" num_vals : "+q.getNumVals());
System.out.println(" num_used1 : "+q.getNumUsed());
System.out.println(" ions1 : "+q.getStringIons1());
System.out.println(" ions2 : "+q.getStringIons2());
System.out.println(" ions3 : "+q.getStringIons3());
System.out.println(" peptol : "+q.getPepTol());
System.out.println(" peptol units: "+q.getPepTolUnits());
System.out.println(" peptol str : "+q.getPepTolString());
System.out.println(" INSTRUMENT : "+q.getINSTRUMENT());
System.out.println(" RULES : "+q.getRULES());
System.out.println(" IT_MODS : "+q.getIT_MODS());
System.out.println(" repeat srch : "+file.getRepeatSearchString(i));
num_peaks = q.getNumberOfPeaks(1);
for(j=1; j <= num_peaks; j++) {
System.out.println(roundWholeNumber(q.getPeakMass(1,j))+", "+roundWholeNumber(q.getPeakIntensity(1,j)));
}
}
System.out.println("\n");
}
private static int toBinary(boolean bool) {
if(bool) return 1;
return 0;
}
private static String roundWholeNumber (double toRound) {
String myInt = ""+toRound;
myInt += "\n";
if(myInt.indexOf(".0\n")>-1) {
return myInt.substring(0,myInt.indexOf(".0\n"));
}
return ""+toRound;
}
}