use of de.ipbhalle.metfraglib.candidatefilter.PreProcessingCandidateSuspectListFilter in project MetFragRelaunched by ipb-halle.
the class IndividualMoNASpectralSimilarityInitialiser method initScoreParameters.
@Override
public void initScoreParameters(Settings settings) throws Exception {
/*
*
*/
// initialise inchikey list of present substances in MoNA
java.io.InputStream is = null;
String inChIKeyFileName = "";
PreProcessingCandidateSuspectListFilter MoNAPresentInChIKeys = null;
if (settings.containsKey(VariableNames.MONA_PRESENT_INCHIKEYS_FILE_NAME) && settings.get(VariableNames.MONA_PRESENT_INCHIKEYS_FILE_NAME) != null)
inChIKeyFileName = (String) settings.get(VariableNames.MONA_PRESENT_INCHIKEYS_FILE_NAME);
else
is = IndividualMoNASpectralSimilarity.class.getResourceAsStream("/MoNA_InChIKeys.txt");
if (inChIKeyFileName.length() != 0)
MoNAPresentInChIKeys = new PreProcessingCandidateSuspectListFilter(inChIKeyFileName, settings);
else
MoNAPresentInChIKeys = new PreProcessingCandidateSuspectListFilter(is, "MoNA_InChIKeys", settings);
// initialise MoNA web service
MoNARestWebService webService = new MoNARestWebService(settings);
settings.set(VariableNames.INDIVIDUAL_MONA_SPECTRAL_SIMILARITY_INCHIKEY_LIST_NAME, MoNAPresentInChIKeys);
settings.set(VariableNames.INDIVIDUAL_MONA_SPECTRAL_SIMILARITY_WEB_SERVICE_NAME, webService);
}
use of de.ipbhalle.metfraglib.candidatefilter.PreProcessingCandidateSuspectListFilter in project MetFragRelaunched by ipb-halle.
the class IndividualMoNASpectralSimilarity method calculate.
public void calculate() throws Exception {
final PreProcessingCandidateSuspectListFilter MoNAPresentInChIKeys = (PreProcessingCandidateSuspectListFilter) this.settings.get(VariableNames.INDIVIDUAL_MONA_SPECTRAL_SIMILARITY_INCHIKEY_LIST_NAME);
final MoNARestWebService webService = (MoNARestWebService) this.settings.get(VariableNames.INDIVIDUAL_MONA_SPECTRAL_SIMILARITY_WEB_SERVICE_NAME);
if (MoNAPresentInChIKeys == null || MoNAPresentInChIKeys.passesFilter(this.candidate, false)) {
SortedTandemMassPeakList peakList = (SortedTandemMassPeakList) settings.get(VariableNames.PEAK_LIST_NAME);
String inchikey1 = (String) this.candidate.getProperty(VariableNames.INCHI_KEY_1_NAME);
DefaultPeakList[] monaPeakList = webService.retrievePeakListByInChIKey(inchikey1, peakList.getMeasuredPrecursorMass());
if (monaPeakList == null || monaPeakList.length == 0) {
this.value = 0.0;
} else {
double max = 0.0;
for (int i = 0; i < monaPeakList.length; i++) {
double cs = ((SortedTandemMassPeakList) monaPeakList[i]).cosineSimilarity(peakList, (Double) this.settings.get(VariableNames.RELATIVE_MASS_DEVIATION_NAME), (Double) this.settings.get(VariableNames.ABSOLUTE_MASS_DEVIATION_NAME));
if (cs > max)
max = cs;
}
this.value = max;
}
} else
this.value = 0.0;
this.calculationFinished = true;
}
Aggregations