Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <summary>
        /// Divide Operation
        /// </summary>
        /// <param name="result">ResultResampling Class</param>
        /// <returns>ResultSpectrumCalculation</returns>
        private SpectrumCalculationResult OperationDivide(ResamplingResult result)
        {
            if (!ValidateResult(result))
            {
                return(null);
            }
            SpectrumCalculationResult spectrumResult = new SpectrumCalculationResult();
            ClrDataPoints             basePts        = new ClrDataPoints();
            ClrDataPoints             firstPts       = result.GetResultData(0);
            double threshold = firstPts.getMaxY() * Math.Pow(10, -6);

            for (uint i = 0; i < firstPts.getLength(); i++)
            {
                if (_stopFlag == true)
                {
                    return(null);
                }
                double value = Math.Max(firstPts.getY(i), threshold);
                basePts.addPoint(firstPts.getX(i), value);
            }

            List <ClrDataPoints> subtract = new List <ClrDataPoints>();

            for (int i = 1; i < result.GetXYDataNum(); i++)
            {
                ClrDataPoints temp = new ClrDataPoints();
                for (uint j = 0; j < basePts.getLength(); j++)
                {
                    if (_stopFlag == true)
                    {
                        return(null);
                    }
                    temp.addPoint(basePts.getX(j),
                                  result.GetResultData(i).getY(j) / basePts.getY(j));
                }
                subtract.Add(temp);
            }
            //2013/11/26 - del
            //spectrumResult.AddResult(basePts, _specList[0], SPECTRUMNAME_DIVIDED);
            //enddel
            for (int i = 0; i < subtract.Count; i++)
            {
                if (_stopFlag == true)
                {
                    return(null);
                }
                spectrumResult.AddResult(subtract[i], _specList[i + 1], SPECTRUMNAME_DIVIDED);
            }
            return(spectrumResult);
        }
Beispiel #3
0
        /// <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>
        /// 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);
        }