Example program for retrieving general search information.
import java.util.Date;
import matrix_science.msparser.*;
public class resfile_info {
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()) {
searchInformation(file);
} else {
System.out.println("Error number: "+file.getLastError());
System.out.println("Error string: "+file.getLastErrorString());
System.exit(0);
}
}
private static void searchInformation(ms_mascotresfilebase file) {
Date searchDate = null;
int seconds = file.getDate();
long milliseconds = (long) seconds * 1000;
searchDate=new Date(milliseconds);
System.out.println("Search information from ms_mascotresfilebase");
System.out.println("========================================");
System.out.println("Number of queries : "+file.getNumQueries());
System.out.println("Number of sequences : "+file.getNumSeqs());
System.out.println("Sequences after tax : "+file.getNumSeqsAfterTax());
System.out.println("Number of residues : "+(int)file.getNumResidues());
System.out.println("Execution time : "+file.getExecTime());
System.out.println("Date (seconds) : "+file.getDate());
System.out.print("Date : ");
String toPerlDate = searchDate.toString();
if(toPerlDate.indexOf("GMT ") > -1) {
String beforeGMT = toPerlDate.substring(0,toPerlDate.indexOf("GMT"));
String afterGMT = toPerlDate.substring(toPerlDate.indexOf("GMT ")+4,toPerlDate.length());
System.out.println(beforeGMT+afterGMT);
} else {
System.out.println(searchDate);
}
System.out.println("Mascot version : "+file.getMascotVer());
System.out.println("Fasta version : "+file.getFastaVer());
System.out.println("Is PMF? : "+toBinary(file.isPMF()));
System.out.println("Is MSMS? : "+toBinary(file.isMSMS()));
System.out.println("Is SQ? : "+toBinary(file.isSQ()));
System.out.println("Is Error tolerant : "+toBinary(file.isErrorTolerant()));
System.out.println("Any PMF? : "+toBinary(file.anyPMF()));
System.out.println("Any MSMS? : "+toBinary(file.anyMSMS()));
System.out.println("Any SQ? : "+toBinary(file.anySQ()));
System.out.println("Any peptides section: "+toBinary(file.doesSectionExist(ms_mascotresfilebase.SEC_PEPTIDES)));
System.out.println("Any peptide matches : "+toBinary(file.anyFastaMatches()));
System.out.println();
}
private static int toBinary(boolean bool) {
if(bool) return 1;
return 0;
}
}