Search in sources :

Example 1 with MoNARestWebService

use of de.ipbhalle.metfraglib.functions.MoNARestWebService in project MetFragRelaunched by ipb-halle.

the class MetFusionMoNASpectralSimilarityInitialiser method initScoreParameters.

@Override
public void initScoreParameters(Settings settings) throws Exception {
    /*
		 * 
		 */
    // initialise MoNA web service
    MoNARestWebService webService = new MoNARestWebService(settings);
    ((ProcessingStatus) settings.get(VariableNames.PROCESS_STATUS_OBJECT_NAME)).setProcessStatusString("Retrieving Results from MoNA");
    CandidateList candidatesFromMoNA = null;
    try {
        candidatesFromMoNA = webService.performSpectrumSimilaritySearch();
    } catch (Exception e) {
        settings.set(VariableNames.METFUSION_MONA_SPECTRAL_SIMILARITY_CANDIDATES_NAME, new CandidateList());
        e.printStackTrace();
        return;
    }
    for (int i = 0; i < candidatesFromMoNA.getNumberElements(); i++) {
        IBitFingerprint fingerprint = TanimotoSimilarity.calculateFingerPrint(candidatesFromMoNA.getElement(i).getAtomContainer());
        candidatesFromMoNA.getElement(i).setProperty("Fingerprint", fingerprint);
    }
    settings.set(VariableNames.METFUSION_MONA_SPECTRAL_SIMILARITY_CANDIDATES_NAME, candidatesFromMoNA);
}
Also used : IBitFingerprint(org.openscience.cdk.fingerprint.IBitFingerprint) MoNARestWebService(de.ipbhalle.metfraglib.functions.MoNARestWebService) CandidateList(de.ipbhalle.metfraglib.list.CandidateList) ProcessingStatus(de.ipbhalle.metfraglib.process.ProcessingStatus) IBitFingerprint(org.openscience.cdk.fingerprint.IBitFingerprint)

Example 2 with MoNARestWebService

use of de.ipbhalle.metfraglib.functions.MoNARestWebService in project MetFragRelaunched by ipb-halle.

the class ExactMoNASpectralSimilarityInitialiser method initScoreParameters.

@Override
public void initScoreParameters(Settings settings) throws Exception {
    /*
		 * Initialises the online mona query and retrieves candidates by spectral 
		 * similarity. The candidates retrieved from the MoNA database are stored 
		 * in the settings object and can be used within the ExactMoNASpectralSimilarity
		 * class.
		 */
    MoNARestWebService webService = new MoNARestWebService(settings);
    try {
        CandidateList candidateList = webService.performSpectrumSimilaritySearch();
        settings.set(VariableNames.EXACT_MONA_SPECTRAL_SIMILARITY_CANDIDATES_NAME, candidateList);
    } catch (Exception e) {
        settings.set(VariableNames.EXACT_MONA_SPECTRAL_SIMILARITY_CANDIDATES_NAME, new CandidateList());
        e.printStackTrace();
        return;
    }
}
Also used : MoNARestWebService(de.ipbhalle.metfraglib.functions.MoNARestWebService) CandidateList(de.ipbhalle.metfraglib.list.CandidateList)

Example 3 with MoNARestWebService

use of de.ipbhalle.metfraglib.functions.MoNARestWebService 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);
}
Also used : PreProcessingCandidateSuspectListFilter(de.ipbhalle.metfraglib.candidatefilter.PreProcessingCandidateSuspectListFilter) MoNARestWebService(de.ipbhalle.metfraglib.functions.MoNARestWebService)

Example 4 with MoNARestWebService

use of de.ipbhalle.metfraglib.functions.MoNARestWebService 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;
}
Also used : PreProcessingCandidateSuspectListFilter(de.ipbhalle.metfraglib.candidatefilter.PreProcessingCandidateSuspectListFilter) MoNARestWebService(de.ipbhalle.metfraglib.functions.MoNARestWebService) SortedTandemMassPeakList(de.ipbhalle.metfraglib.list.SortedTandemMassPeakList) DefaultPeakList(de.ipbhalle.metfraglib.list.DefaultPeakList)

Aggregations

MoNARestWebService (de.ipbhalle.metfraglib.functions.MoNARestWebService)4 PreProcessingCandidateSuspectListFilter (de.ipbhalle.metfraglib.candidatefilter.PreProcessingCandidateSuspectListFilter)2 CandidateList (de.ipbhalle.metfraglib.list.CandidateList)2 DefaultPeakList (de.ipbhalle.metfraglib.list.DefaultPeakList)1 SortedTandemMassPeakList (de.ipbhalle.metfraglib.list.SortedTandemMassPeakList)1 ProcessingStatus (de.ipbhalle.metfraglib.process.ProcessingStatus)1 IBitFingerprint (org.openscience.cdk.fingerprint.IBitFingerprint)1