Exemplo n.º 1
0
        /// <summary>
        /// Add result data points(added data is clone).
        /// </summary>
        /// <param name="points"></param>
        public void AddResult(ClrDataPoints points, SpectrumWrapper baseSpectrum, string name)
        {
            SpectrumResampling spectrum = new SpectrumResampling(baseSpectrum.getSample(), name);

            spectrum.SetData(points);
            _list.Add(spectrum);
        }
Exemplo n.º 2
0
        SpectrumWrapper InitChannel(int channel, int spectrumSize, Transform parent)
        {
            SpectrumWrapper result = new SpectrumWrapper();

            result.channel          = channel;
            result.spectrumBuff     = new float[spectrumSize];
            result.transforms       = new Transform[spectrumSize];
            result.currentSpectrums = new NativeArray <float>(spectrumSize, Allocator.Persistent);
            result.prevSpectrums    = new NativeArray <float>(spectrumSize, Allocator.Persistent);
            result.origins          = new NativeArray <Vector3>(spectrumSize, Allocator.Persistent);

            for (int index = 0;
                 index < spectrumSize;
                 ++index)
            {
                GameObject obj = Object.Instantiate(cubePrefab);

                SpiralPos pos = Utils.GetSpiralPos(index);

                obj.transform.parent        = parent;
                obj.transform.localPosition = new Vector3(pos.x, 0, pos.z);

                result.transforms[index] = obj.transform;
                result.origins[index]    = obj.transform.localPosition;
            }

            result.transformsAccess = new TransformAccessArray(result.transforms);

            return(result);
        }
        /// <summary>
        /// Read Spectrum
        /// </summary>
        /// <param name="node">DataGroupNodeWrapper</param>
        /// <param name="descendant">descendant of node(child or grandchild.....</param>
        /// <param name="childNum">child number</param>
        /// <param name="listReadSpec">ReadSpectrumData List</param>
        /// <param name="descendantList">descendant List</param>
        private void ReadSpectrum(DataGroupNodeWrapper node, uint descendant,
                                  uint childNum, ref List <ReadSpectrumData> listReadSpec, List <uint> descendantList)
        {
            uint numSpec = node.getNumberOfSpectra();

            for (uint n = 0; n < numSpec; n++)
            {
                SpectrumWrapper  spec    = node.getSpectrum(n);
                ReadSpectrumData tmpData = new ReadSpectrumData(spec, descendantList, descendant, childNum, n);
                listReadSpec.Add(tmpData);
            }

            uint numChild = node.getNumberOfChildren();

            for (uint n = 0; n < numChild; n++)
            {
                DataGroupNodeWrapper child = node.getChild(n);
                if (child != null)
                {
                    List <uint> tmpDescendant = new List <uint>();
                    for (int cnt = 0; cnt < descendantList.Count; cnt++)
                    {
                        tmpDescendant.Add(descendantList[cnt]);
                    }
                    tmpDescendant.Add(n);
                    ReadSpectrum(child, descendant + 1, n, ref listReadSpec, tmpDescendant);
                }
                else
                {
                    Debug.Assert(false);
                }
            }
        }
Exemplo n.º 4
0
        void Start()
        {
            int spectrumSize = settings.spectrumSize;

            left  = InitChannel(0, spectrumSize, parentLeft);
            right = InitChannel(1, spectrumSize, parentRight);
        }
 /// <summary>
 /// Initialize ReadSpectrumData structure.
 /// </summary>
 /// <param name="spec">Spectrum is read from file</param>
 /// <param name="descendantList">Descendant List</param>
 /// <param name="descendant">Descendant</param>
 /// <param name="childNum">Child number</param>
 /// <param name="specNum">Spectrum number</param>
 internal ReadSpectrumData(SpectrumWrapper spec, List <uint> descendantList, uint descendant, uint childNum, uint specNum)
 {
     Spec           = spec;
     DescendantList = descendantList;
     Descendant     = descendant;
     ChildNum       = childNum;
     SpecNum        = specNum;
 }
        /// <summary>
        /// Get Spectrum Data(selected by File and Spectrum Name and RT value and Precusor value)
        /// </summary>
        /// <param name="nameDataListIndex">index number of file name combobox</param>
        /// <param name="specName">Spectrum Name(selected combobox or determinded by selected RT and Precusor combobox) </param>
        /// <param name="rt">RT value (selected combobox or determinded by selected Spectrum Name combobox) </param>
        /// <param name="precusor">Precusor value (selected combobox or determinded by selected Spectrum Name combobox) </param>
        /// <returns>SpectrumWrapper</returns>
        public SpectrumWrapper GetSpectrumWrapperData(int nameDataListIndex, string specName, string rt, string precusor)
        {
            string folder    = _fileNameDataList[nameDataListIndex].Folder;
            string fileName  = _fileNameDataList[nameDataListIndex].FileName;
            int    sampleNum = _fileNameDataList[nameDataListIndex].SampleTabNo;

            var pred = new Predicate <SelSpectrum>(x =>
                                                   (x.Folder == folder &&
                                                    x.FileName == fileName &&
                                                    x.SpecName == specName &&
                                                    x.RT == rt &&
                                                    x.Precusor == precusor &&
                                                    x.SampleTabNo == sampleNum));
            int find = _selSpectrum.FindIndex(pred);

            // error
            if (find < 0)
            {
                return(null);
            }

            string             tfp     = Path.Combine(folder, fileName);
            FileFactoryWrapper factory = FileFactoryWrapper.getInstance();
            SampleSetWrapper   set     = factory.openFile(tfp);
            SampleWrapper      sample  = set.getSample((uint)_selSpectrum[find].SampleTabNo - 1);

            sample.openSample();
            DataGroupNodeWrapper targetNode = sample.getRootDataGroupNode();

            int listcount = _selSpectrum[find].DescendantList.Count;

            for (int cnt = 0; cnt < listcount; cnt++)
            {
                targetNode = targetNode.getChild(_selSpectrum[find].DescendantList[cnt]);
            }

            SpectrumWrapper spec = targetNode.getSpectrum(_selSpectrum[find].SpecNum);

            var predfn = new Predicate <FileManage>(x => (x.FileName == tfp));

            find = _listFileManage.FindIndex(predfn);

            if (find < 0)
            {
                FileManage fmanage;
                fmanage.FileFactory = factory;
                fmanage.SampleSet   = set;
                fmanage.FileName    = tfp;
                _listFileManage.Add(fmanage);
            }
            // Not closed File,because stocked spectrum data read from file not used when file is closed
            return(spec);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Read Spectrum(only ms1)
        /// </summary>
        /// <param name="node">DataGroupNodeWrapper</param>
        /// <param name="listReadSpec">SpectrumWrapper List</param>
        private void ReadSpectrum(DataGroupNodeWrapper node, ref List <SpectrumWrapper> listReadSpec)
        {
            uint numSpec = node.getNumberOfSpectra();

            for (uint n = 0; n < numSpec; n++)
            {
                SpectrumWrapper spec = node.getSpectrum(n);
                if (spec.getMsStage() == 1)
                {
                    listReadSpec.Add(spec);
                }
            }

            uint numChild = node.getNumberOfChildren();

            for (uint n = 0; n < numChild; n++)
            {
                DataGroupNodeWrapper child = node.getChild(n);
                if (child != null)
                {
                    ReadSpectrum(child, ref listReadSpec);
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Add result data points.
 /// </summary>
 /// <param name="points"></param>
 public void AddResult(ClrDataPoints points, SpectrumWrapper baseSpectrum)
 {
     _ptsList.Add(points);
     _specList.Add(baseSpectrum);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Read MSB Data File
        /// </summary>
        /// <param name="filepath">MSB file Path</param>
        /// <returns></returns>
        public int ReadMSBData(string filepath)
        {
            string folder   = Path.GetDirectoryName(filepath);
            string fileName = Path.GetFileName(filepath);

            var pred = new Predicate <SelSpectrum>(x => (x.Folder == folder && x.FileName == fileName));
            int find = _selSpectrum.FindIndex(pred);

            if (find >= 0)
            {
                return(-1);
            }

            FileFactoryWrapper factory = FileFactoryWrapper.getInstance();
            SampleSetWrapper   set     = factory.openFile(filepath);

            if (set == null)
            {
                return(-1);
            }

            for (int num = 0; num < set.getNumberOfSamples(); num++)
            {
                FileData _tmpFileNameData = new FileData(num + 1, folder, fileName);

                SampleWrapper sample = set.getSample((uint)num);
                sample.openSample();
                Debug.WriteLine(sample.getSampleSet().getFileName());

                DataGroupNodeWrapper    root           = sample.getRootDataGroupNode();
                List <ReadSpectrumData> listReadSpec   = new List <ReadSpectrumData>();
                List <uint>             DescendantList = new List <uint>();
                ReadSpectrum(root, 0, 0, ref listReadSpec, DescendantList);

                for (uint n = 0; n < listReadSpec.Count; n++)
                {
                    SpectrumWrapper spec = listReadSpec[(int)n].Spec;

                    string precursor = "";
                    if (spec.getMsStage() == 1)
                    {
                        precursor = "-----";
                    }
                    else if (spec.getMsStage() == 2)
                    {
                        precursor = spec.getPrecursor().ToString();
                    }
                    else
                    {
                        precursor = "\"" + spec.getPrecursor(1).ToString();
                        for (int pcnt = 2; pcnt < spec.getMsStage(); pcnt++)
                        {
                            precursor += ("," + spec.getPrecursor(pcnt).ToString());
                        }
                        precursor += "\"";
                    }
                    SelSpectrum selSpec = new SelSpectrum(num + 1,
                                                          folder, fileName, spec.getName(), spec.getRt().ToString(), precursor,
                                                          n, listReadSpec[(int)n].DescendantList, listReadSpec[(int)n].Descendant,
                                                          listReadSpec[(int)n].ChildNum, listReadSpec[(int)n].SpecNum);

                    selSpec.TotalSpecNum = n;

                    _selSpectrum.Add(selSpec);

                    SpectrumData tmpSpectrumNameData = new SpectrumData();
                    tmpSpectrumNameData.SpectrumName = spec.getName();
                    tmpSpectrumNameData.RT           = spec.getRt();

                    if (spec.getMsStage() == 1)
                    {
                        tmpSpectrumNameData.Precusor = "-----";
                    }
                    else if (spec.getMsStage() == 2)
                    {
                        tmpSpectrumNameData.Precusor = spec.getPrecursor().ToString();
                    }
                    else
                    {
                        tmpSpectrumNameData.Precusor = "\"" + spec.getPrecursor(1).ToString();;
                        for (int pcnt = 2; pcnt < spec.getMsStage(); pcnt++)
                        {
                            tmpSpectrumNameData.Precusor = tmpSpectrumNameData.Precusor + "," + spec.getPrecursor(pcnt).ToString();
                        }
                        tmpSpectrumNameData.Precusor = tmpSpectrumNameData.Precusor + "\"";
                    }

                    _tmpFileNameData.SpectrumNameDataList.Add(tmpSpectrumNameData);
                    _tmpFileNameData.SpectrumNameList.Add(spec.getName());
                }

                _fileNameDataList.Add(_tmpFileNameData);

                _bindFileName.Add("[" + _tmpFileNameData.SampleTabNo.ToString() + "] " + _tmpFileNameData.FileName);

                _bindFileNameLastRow.Insert(_bindFileNameLastRow.Count - 1, "["
                                            + _tmpFileNameData.SampleTabNo.ToString() + "] " + _tmpFileNameData.FileName);
            }

            factory.closeFile(set);
            return(0);
        }
Exemplo n.º 11
0
 /// <summary>
 /// add spec to SpectrumWrapper list
 /// </summary>
 /// <param name="spec">SpectrumWrapper</param>
 public void AddSpecData(SpectrumWrapper spec)
 {
     _specList.Add(spec);
 }