/// <summary> /// Return Remove contaminant peak is Enabled. /// </summary> /// <param name="clrParams"></param> /// <returns></returns> public ClrVariant RemoveContaminantPeakIsEnabled(ClrParameters clrParams) { ClrVariant ret = new ClrVariant(); ret.type = ClrVariant.DataType.BOOL; ret.obj = false; try { ClrMsDataVariant msObj = new ClrMsDataVariant(ClrPluginCallTool.getActiveObject(clrParams)); SampleWrapper sw = msObj.getSample(); if (sw != null) { DataGroupNodeWrapper dgnw = sw.getRootDataGroupNode(); if (1 < dgnw.getNumberOfSpectra()) { ret.obj = true; } } } catch { ret.obj = false; } return(ret); }
/// <summary> /// Submit latest result to sample tree. /// </summary> public void SubmitResultToTree() { // No Result if (Result == null) { return; } ClrMsDataVariant msObj = new ClrMsDataVariant(_clrVariant); DataGroupNodeWrapper dgnw = msObj.getSample().getRootDataGroupNode(); //Add result to sample tree. SampleSetResampling sampleSet = new SampleSetResampling(); SampleResampling sample = new SampleResampling(sampleSet); sample.openSample(); DataGroupNodeWrapper root = sample.getRootDataGroupNode(); sample.setName("Contaminant peak removed " + msObj.getSample().getName()); root.setName("Contaminant peak removed " + dgnw.getName()); int cnt = 0; for (int i = 0; i < Result.Spectrums.Count(); i++) { ClrDataPoints pts = Result.DataPoints[i]; SpectrumWrapper sw = Result.Spectrums[i]; XYDataWrapper xyd; SpectrumResampling spec; if (Result.Spectrums.Count == 1) { spec = new SpectrumResampling(sample, sw.getName()); } else { cnt++; spec = new SpectrumResampling(sample, Result.Spectrums[i].getName() + " (" + cnt.ToString() + ")"); } xyd = spec.getXYData(); spec.SetData(pts); spec.onGetXYData(xyd, -1.0, -1.0); spec.setMinX(pts.getMinX()); spec.setMaxX(pts.getMaxX()); spec.setMaxIntensity(pts.getMaxY()); spec.setMsStage((int)sw.getMsStage()); sample.setSampleIndex((int)0); root.addSpectrum(spec); } sampleSet.addSample(sample); ClrPluginCallTool.onOpenSample(sample); }
/// <summary> /// Display Calculation Results on tree view /// </summary> public void DisplayCalculationResult() { // No Result if (_resultSpecCal == null) { return; } //Add result to sample tree. SampleSetResampling sampleSet = new SampleSetResampling(); SampleResampling sample = new SampleResampling(sampleSet); sample.openSample(); DataGroupNodeWrapper root = sample.getRootDataGroupNode(); sample.setName(_resultSpecCal.Spectrums[0].getName() + " Sample"); root.setName(_resultSpecCal.Spectrums[0].getName() + " Sample"); 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"); } else { cnt++; spec = new SpectrumResampling(sample, sr.getName() + " Spectrum_" + 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); ClrPluginCallTool.onOpenSample(sample); }
/// <summary> /// Remove contaminant peak is Enabled. /// </summary> /// <param name="clrParams">parameters for C# plug-in from Mass++</param> /// <returns></returns> public ClrVariant RemoveContaminantPeak(ClrParameters clrParams) { // Return value (Success: true, Failure: false) ClrVariant ret = new ClrVariant(); // We initially set ret.prim.boolVal to false so that we can return a false // result easily using "return ret" if a failure condition occurs. ret.type = ClrVariant.DataType.BOOL; ret.obj = false; // Convert clrParams to ActiveObject ClrVariant clrVar = ClrPluginCallTool.getActiveObject(clrParams); // Display main window. RemoveContaminantPeakManager.DisplayDlgRemovContamiPeak(clrVar); ret.obj = true; return(ret); }
private bool CreateBaselineSubtractedXIC( PluginFunctionItemWrapper pfiw, List <ClrDataPoints> resamplingList, List <SpectrumWrapper> ms1List, SettingParameterValuesWrapper spvw, ref ClrDataPoints[] subtractLowerXICList, ref ClrDataPoints[] subtractHigherXICList, ref ClrDataPoints subtractHighestXICList ) { uint resamplingLength = resamplingList[0].getLength(); int lowerIndex = (resamplingLength < int.MaxValue) ? (int)resamplingLength : int.MaxValue; int higherIndex = (0 < (int)(resamplingLength - lowerIndex))? (int)(resamplingLength - lowerIndex) : 0; subtractLowerXICList = new ClrDataPoints[lowerIndex]; subtractHigherXICList = new ClrDataPoints[higherIndex]; for (uint i = 0; i < resamplingLength; i++) { //Update message. if (UpdateProgress != null) { UpdateProgress( PROGRESS_REMOVECONTAMINANT_PHASE.REMOVE_CONTAMINANT_PEAK, (int)i, (int)resamplingLength); } //Cancel. if (StopFlag) { break; } //Create XIC. ClrDataPoints pts = new ClrDataPoints(); for (int j = 0; j < resamplingList.Count; j++) { //Cancel. if (StopFlag) { break; } pts.addPoint(ms1List[j].getRt(), resamplingList[j].getY(i)); } //Cancel. if (StopFlag) { pts.clearPoints(); pts.Dispose(); break; } //Baseline Subtraction ClrParameters param = new ClrParameters(); ClrDataPoints baseline = new ClrDataPoints(); ClrPluginCallTool.setXYData(param, pts); ClrPluginCallTool.setBaseline(param, baseline); ClrPluginCallTool.setSettingValues(param, spvw); pfiw.getCall().invoke(param); //Cancel. if (StopFlag) { param.Dispose(); baseline.clearPoints(); baseline.Dispose(); } //Resampling baseline. ClrDataPoints subtracted = new ClrDataPoints(); ResamplingParameter resamplingParam = new ResamplingParameter(); ResamplingCalculation resamplingCalc = new ResamplingCalculation(resamplingParam); resamplingParam.ResamplingMode = ResamplingParameter.SamplingMode.FIRST; resamplingParam.Interpolation = _resamplingParam.Interpolation; resamplingParam.AddXYData(pts); resamplingParam.AddXYData(baseline); resamplingCalc.Execute(); ClrDataPoints resampledBaseline = resamplingCalc.Result.getResultData(1); for (uint j = 0; j < resampledBaseline.getLength(); j++) { double intensity = Math.Max(pts.getY(j) - resampledBaseline.getY(j), 0); subtracted.addPoint(pts.getX(j), intensity); } // Countermeasure to OutOfBoundsException. if (i < int.MaxValue) { subtractLowerXICList[i] = subtracted; } else if (int.MaxValue < i && i < (uint)int.MaxValue * 2) { subtractHigherXICList[i - int.MaxValue] = subtracted; } else { subtractHighestXICList = subtracted; } resamplingParam.ClearXYDataList(); resamplingCalc.Result.ClearXYDataList(); } return(!StopFlag); }
/// <summary> /// Graph ChangeSelectItem event handler /// </summary> /// <param name="sender">sender</param> /// <param name="e">event args</param> private void Graph_ChangeSelectItem(object sender, UserControlSimcaGraph.SelectItemEventArgs e) { if (!_checkBoxSyncQuant.Checked) { return; } bool activeTab = false; switch ((TAB_ID)_tabControlPlot.SelectedIndex) { case TAB_ID.SCORE_PLOT: if ((UserControlSimcaGraph)sender == _graphScore) { activeTab = true; } break; case TAB_ID.LOADING_PLOT: if ((UserControlSimcaGraph)sender == _graphLoading) { activeTab = true; } break; case TAB_ID.S_PLOT: if ((UserControlSimcaGraph)sender == _graphSPlot) { activeTab = true; } break; default: break; } if (!activeTab) { return; } // Renewal of an emphasis display IdentificationManagerWrapper managerWrapper = IdentificationManagerWrapper.getInstance(); managerWrapper.clearFocusedPeaks(); // clear if (e.SelectItemArray != null) { foreach (int peakId in e.SelectItemArray) { managerWrapper.addFocusedPeak(peakId); if (e.DoubleClick) { managerWrapper.activatePeak(peakId); } } } ClrPluginCallTool.refresh(); }