/// <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> /// 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); }
/// <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); }