/// <summary> /// Set Spectrum calculation result to active object. /// </summary> /// <param name="resultSpecCal">Spectrum calculation result</param> private static void SetResultToActiveObject(SpectrumCalculationResult resultSpecCal) { // Preparing Output files. SampleSetResampling sampleSet = new SampleSetResampling(); SampleResampling sample = new SampleResampling(sampleSet); sample.openSample(); DataGroupNodeWrapper root = sample.getRootDataGroupNode(); // _resultSpecCal.Spectrums[0].getName() returns // "Average" or "Summed" or "Subtracted" or "Divided". sample.setName(resultSpecCal.Spectrums[0].getName() + " " + SAMPLE_STRING); root.setName(resultSpecCal.Spectrums[0].getName() + " " + SAMPLE_STRING); int cnt = 0; foreach (SpectrumResampling sr in resultSpecCal.Spectrums) { ClrDataPoints xyd = new ClrDataPoints(); SpectrumResampling spec; if (resultSpecCal.Spectrums.Count == 1) { spec = new SpectrumResampling(sample, sr.getName() + " " + SPECTRUM_STRING); } else { cnt++; spec = new SpectrumResampling(sample, sr.getName() + " " + SPECTRUM_STRING + "_" + cnt.ToString()); } ClrDataPoints pts = new ClrDataPoints(); sr.getXYData(pts, false); spec.getXYData(xyd, false); spec.SetData(pts); spec.setMinX(pts.getMinX()); spec.setMaxX(pts.getMaxX()); spec.setMaxIntensity(pts.getMaxY()); spec.onGetXYData(xyd, -1.0, -1.0); spec.setMsStage((int)sr.getMsStage()); sample.setSampleIndex((int)0); root.addSpectrum(spec); } sampleSet.addSample(sample); // -out kome.clr.ActiveObjectsManagerWrapper aoMgr = kome.clr.ActiveObjectsManagerWrapper.getInstance(); aoMgr.setActiveSample(sample); }
/// <summary> /// Search Spectrum from spectrum file name and spectrum name /// </summary> /// <param name="strFilename">file name</param> /// <param name="strSpectrum">spectrum name</param> /// <returns>Spectrum</returns> /// private static SpectrumWrapper SearchSpectrum(string strFilename, string strSpectrum) { string strFilenameLower = strFilename.ToLower(); // get the rawdata that specified by -in option. kome.clr.ActiveObjectsManagerWrapper aoMgr = kome.clr.ActiveObjectsManagerWrapper.getInstance(); uint uNumberOfOpenedSamples = aoMgr.getNumberOfOpenedSamples(); for (uint i = 0; i < uNumberOfOpenedSamples; i++) { kome.clr.SampleWrapper opend_sample = aoMgr.getOpenedSample(i); kome.clr.SampleSetWrapper sample_set = opend_sample.getSampleSet(); string strOpendFilePathOrg = sample_set.getFilePath(); string strOpendFileNameOrg = sample_set.getFileName(); // To lower. string strOpendFilePathLower = strOpendFilePathOrg.ToLower(); string strOpendFileNameLower = strOpendFileNameOrg.ToLower(); // Compair strOpendFilePathLower and strFilenameLower. if (strOpendFilePathLower != strFilenameLower) { continue; } int nSampleID = opend_sample.getSampleId(); string strName = opend_sample.getName(); uint uGroups = opend_sample.getNumberOfGroups(); for (uint j = 0; j < uGroups; j++) { kome.clr.DataGroupNodeWrapper node = opend_sample.getGroup(j); uint numberOfSpectra = node.getNumberOfSpectra(); for (uint k = 0; k < numberOfSpectra; k++) { kome.clr.SpectrumWrapper spec = node.getSpectrum(k); string strNameSpec = spec.getName(); double dRt = spec.getRt(); // Use first spectrum when specname is null string. bool flgUseFirstSpectrum = (strSpectrum == null) || strSpectrum.Length == 0 || strSpectrum.All((s) => (s == ' ')); if ((strNameSpec != strSpectrum) && !flgUseFirstSpectrum) { continue; } return(spec); } } // Spectrum names not matches. throw new ArgumentException("message", "SpecName"); } // File names not matches. throw new ArgumentException("message", "FileName"); }