コード例 #1
0
ファイル: SpectrumListForm.cs プロジェクト: zjjyyang/ftdr
        public void Add(MassSpectrum spectrum)
        {
            SpectrumDataSet.SpectrumTableRow row = spectrumDataSet.SpectrumTable.NewSpectrumTableRow();
            row.Id = spectrum.Id;

            if (nativeIdFormat != CVID.CVID_Unknown)
            {
                gridView.Columns["Id"].Visible = false;

                string[] nameValuePairs = spectrum.Id.Split(" ".ToCharArray());
                foreach (string nvp in nameValuePairs)
                {
                    string[] nameValuePair = nvp.Split("=".ToCharArray());
                    row[nameValuePair[0]] = nameValuePair[1];
                }
            }

            row.Index = spectrum.Index;
            updateRow(row, spectrum);
            spectrumDataSet.SpectrumTable.AddSpectrumTableRow(row);

            //int rowIndex = gridView.Rows.Add();
            //gridView.Rows[rowIndex].Tag = spectrum;
            spectrum.Tag = this;

            if (spectrum.Element.spotID.Length > 0)
            {
                gridView.Columns["SpotId"].Visible = true;
            }

            //UpdateRow( rowIndex );
        }
コード例 #2
0
        public void Add(MassSpectrum spectrum)
        {
            SpectrumDataSet.SpectrumTableRow row = spectrumDataSet.SpectrumTable.NewSpectrumTableRow();
            row.Id = spectrum.Id;

            if (nativeIdFormat != CVID.CVID_Unknown)
            {
                gridView.Columns["Id"].Visible = false;

                // guard against case where input is mzXML which
                // is identified as, say, Agilent-derived, but
                // which uses "scan" (as mzXML must) instead
                // of the Agilent "scanID" (as this mzML-centric code expects)
                bool foundit = false;

                string[] nameValuePairs = spectrum.Id.Split(' ');
                foreach (string nvp in nameValuePairs)
                {
                    string[] nameValuePair = nvp.Split('=');
                    if (row.Table.Columns.Contains(nameValuePair[0]))
                    {
                        row[nameValuePair[0]] = nameValuePair[1];
                        foundit = true;
                    }
                }
                if (!foundit)
                {
                    // mismatch between nativeID format and actual (probably mzXML) format
                    // better to show an ill-fit match - eg "scan" (mzXML) and "scanID" (Agilent)
                    // than no info at all
                    string   nativeIdDefinition = new CVTermInfo(nativeIdFormat).def;
                    string[] idPair             = nativeIdDefinition.Split('=');
                    if (row.Table.Columns.Contains(idPair[0]))
                    {
                        string[] valPair = spectrum.Id.Split('=');
                        row[idPair[0]] = (valPair.Length > 1) ? valPair[1] : spectrum.Id;
                        foundit        = true;
                    }
                }
            }

            row.Index = spectrum.Index;
            updateRow(row, spectrum);
            spectrumDataSet.SpectrumTable.AddSpectrumTableRow(row);

            //int rowIndex = gridView.Rows.Add();
            //gridView.Rows[rowIndex].Tag = spectrum;
            spectrum.Tag = this;

            if (spectrum.Element.spotID.Length > 0)
            {
                gridView.Columns["SpotId"].Visible = true;
            }

            //UpdateRow( rowIndex );
        }
コード例 #3
0
        public void UpdateRow(int rowIndex, SpectrumList spectrumList)
        {
            SpectrumDataSet.SpectrumTableRow row = (spectraSource[rowIndex] as DataRowView).Row as SpectrumDataSet.SpectrumTableRow;

            if (spectrumList != null)
            {
                this.spectrumList[row.Index].SpectrumList = spectrumList;
                updateRow(row, this.spectrumList[row.Index]);
                //dp = rowSpectrum.DataProcessing;
                //row.Tag = rowSpectrum = new MassSpectrum( rowSpectrum, s );
                //rowSpectrum.DataProcessing = dp;
            }
            else
            {
                updateRow(row, this.spectrumList[row.Index]);
                //s = rowSpectrum.Element;
                //dp = rowSpectrum.DataProcessing;
            }
        }
コード例 #4
0
        public void updateRow(SpectrumDataSet.SpectrumTableRow row, MassSpectrum spectrum)
        {
            spectrumList[spectrum.Index] = spectrum;

            Spectrum                s    = spectrum.Element; //GetElement(false);
            DataProcessing          dp   = spectrum.DataProcessing;
            Scan                    scan = null;
            InstrumentConfiguration ic   = null;

            if (s.scanList.scans.Count > 0)
            {
                scan = s.scanList.scans[0];
                ic   = scan.instrumentConfiguration;
            }

            if (dp == null)
            {
                dp = s.dataProcessing;
            }

            CVParam param;

            param       = s.cvParam(CVID.MS_ms_level);
            row.MsLevel = !param.empty() ? (int)param.value : 0;

            param = scan != null?scan.cvParam(CVID.MS_scan_start_time) : new CVParam();

            row.ScanTime = !param.empty() ? (double)param.value : 0;

            param          = s.cvParam(CVID.MS_base_peak_m_z);
            row.BasePeakMz = !param.empty() ? (double)param.value : 0;

            param = s.cvParam(CVID.MS_base_peak_intensity);
            row.BasePeakIntensity = !param.empty() ? (double)param.value : 0;

            param = s.cvParam(CVID.MS_total_ion_current);
            row.TotalIonCurrent = !param.empty() ? (double)param.value : 0;

            var precursorInfo    = new StringBuilder();
            var isolationWindows = new StringBuilder();

            if (row.MsLevel == 1 || s.precursors.Count == 0)
            {
                precursorInfo.Append("n/a");
                isolationWindows.Append("n/a");
            }
            else
            {
                foreach (Precursor p in s.precursors)
                {
                    foreach (SelectedIon si in p.selectedIons)
                    {
                        if (precursorInfo.Length > 0)
                        {
                            precursorInfo.Append(",");
                        }
                        precursorInfo.AppendFormat("{0:G8}", (double)si.cvParam(CVID.MS_selected_ion_m_z).value);
                    }

                    var     iw = p.isolationWindow;
                    CVParam isolationTarget = iw.cvParam(CVID.MS_isolation_window_target_m_z);
                    if (!isolationTarget.empty())
                    {
                        double iwMz = (double)isolationTarget.value;

                        if (isolationWindows.Length > 0)
                        {
                            isolationWindows.Append(",");
                        }

                        CVParam lowerOffset = iw.cvParam(CVID.MS_isolation_window_lower_offset);
                        CVParam upperOffset = iw.cvParam(CVID.MS_isolation_window_upper_offset);
                        if (lowerOffset.empty() || upperOffset.empty())
                        {
                            isolationWindows.AppendFormat("{0:G8}", iwMz);
                        }
                        else
                        {
                            isolationWindows.AppendFormat("[{0:G8}-{1:G8}]", iwMz - (double)lowerOffset.value, iwMz + (double)upperOffset.value);
                        }
                    }
                }
            }

            if (precursorInfo.Length == 0)
            {
                precursorInfo.Append("unknown");
            }
            row.PrecursorInfo = precursorInfo.ToString();

            if (isolationWindows.Length == 0)
            {
                isolationWindows.Append("unknown");
            }
            row.IsolationWindows = isolationWindows.ToString();

            StringBuilder scanInfo = new StringBuilder();

            foreach (Scan scan2 in s.scanList.scans)
            {
                if (scan2.scanWindows.Count > 0)
                {
                    foreach (ScanWindow sw in scan2.scanWindows)
                    {
                        if (scanInfo.Length > 0)
                        {
                            scanInfo.Append(",");
                        }
                        scanInfo.AppendFormat("[{0:G8}-{1:G8}]",
                                              (double)sw.cvParam(CVID.MS_scan_window_lower_limit).value,
                                              (double)sw.cvParam(CVID.MS_scan_window_upper_limit).value);
                    }
                }
            }

            if (scanInfo.Length == 0)
            {
                scanInfo.Append("unknown");
            }
            row.ScanInfo = scanInfo.ToString();

            row.IonMobility = scan != null ? (double)scan.cvParam(CVID.MS_ion_mobility_drift_time).value : 0;
            if (row.IonMobility == 0 && scan != null)
            {
                row.IonMobility = (double)scan.cvParam(CVID.MS_inverse_reduced_ion_mobility).value;
                if (row.IonMobility == 0)
                {
                    // Early version of drift time info, before official CV params
                    var userparam = scan.userParam("drift time");
                    if (!userparam.empty())
                    {
                        row.IonMobility = userparam.timeInSeconds() * 1000.0;
                    }
                }
            }
            row.SpotId       = s.spotID;
            row.SpectrumType = s.cvParamChild(CVID.MS_spectrum_type).name;
            row.DataPoints   = s.defaultArrayLength;
            row.IcId         = (ic == null || ic.id.Length == 0 ? "unknown" : ic.id);
            row.DpId         = (dp == null || dp.id.Length == 0 ? "unknown" : dp.id);
        }
コード例 #5
0
        public void updateRow(SpectrumDataSet.SpectrumTableRow row, MassSpectrum spectrum)
        {
            spectrumList[spectrum.Index] = spectrum;

            Spectrum                s    = spectrum.Element; //GetElement(false);
            DataProcessing          dp   = spectrum.DataProcessing;
            Scan                    scan = null;
            InstrumentConfiguration ic   = null;

            if (s.scanList.scans.Count > 0)
            {
                scan = s.scanList.scans[0];
                ic   = scan.instrumentConfiguration;
            }

            if (dp == null)
            {
                dp = s.dataProcessing;
            }

            CVParam param;

            param       = s.cvParam(CVID.MS_ms_level);
            row.MsLevel = !param.empty() ? (int)param.value : 0;

            param = scan != null?scan.cvParam(CVID.MS_scan_start_time) : new CVParam();

            row.ScanTime = !param.empty() ? (double)param.value : 0;

            param          = s.cvParam(CVID.MS_base_peak_m_z);
            row.BasePeakMz = !param.empty() ? (double)param.value : 0;

            param = s.cvParam(CVID.MS_base_peak_intensity);
            row.BasePeakIntensity = !param.empty() ? (double)param.value : 0;

            param = s.cvParam(CVID.MS_total_ion_current);
            row.TotalIonCurrent = !param.empty() ? (double)param.value : 0;

            StringBuilder precursorInfo = new StringBuilder();

            if (row.MsLevel == 1 || s.precursors.Count == 0)
            {
                precursorInfo.Append("n/a");
            }
            else
            {
                foreach (Precursor p in s.precursors)
                {
                    foreach (SelectedIon si in p.selectedIons)
                    {
                        if (precursorInfo.Length > 0)
                        {
                            precursorInfo.Append(",");
                        }
                        precursorInfo.Append((double)si.cvParam(CVID.MS_selected_ion_m_z).value);
                    }
                }
            }

            if (precursorInfo.Length == 0)
            {
                precursorInfo.Append("unknown");
            }
            row.PrecursorInfo = precursorInfo.ToString();

            StringBuilder scanInfo = new StringBuilder();

            foreach (Scan scan2 in s.scanList.scans)
            {
                if (scan2.scanWindows.Count > 0)
                {
                    foreach (ScanWindow sw in scan2.scanWindows)
                    {
                        if (scanInfo.Length > 0)
                        {
                            scanInfo.Append(",");
                        }
                        scanInfo.AppendFormat("[{0}-{1}]",
                                              (double)sw.cvParam(CVID.MS_scan_window_lower_limit).value,
                                              (double)sw.cvParam(CVID.MS_scan_window_upper_limit).value);
                    }
                }
            }

            if (scanInfo.Length == 0)
            {
                scanInfo.Append("unknown");
            }
            row.ScanInfo = scanInfo.ToString();

            row.SpotId       = s.spotID;
            row.SpectrumType = s.cvParamChild(CVID.MS_spectrum_type).name;
            row.DataPoints   = s.defaultArrayLength;
            row.IcId         = (ic == null || ic.id.Length == 0 ? "unknown" : ic.id);
            row.DpId         = (dp == null || dp.id.Length == 0 ? "unknown" : dp.id);
        }