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