コード例 #1
0
        protected float parseRT(Scan scan)
        {
            CVParam cv   = scan.cvParamChild(CVID.MS_scan_start_time);
            float   time = float.Parse(cv.value.ToString());

            rtUnit = cv.unitsName;

            return(Convert.ToSingle(Math.Round(time, 5)));
        }
コード例 #2
0
        public CV(CVParam param)
        {
            this.cvid  = ((int)param.cvid) + ":" + param.name;
            this.value = param.value.ToString();
            int unitsId = (int)param.units;

            if (unitsId != -1)
            {
                this.units = (int)param.units + ":" + param.unitsName;
            }
        }
コード例 #3
0
ファイル: PTMDiggerTypes.cs プロジェクト: zrolfs/pwiz
        /// <summary>
        /// add precursor and non-matched annotations
        /// </summary>
        public override void AddAnnotations(pwiz.MSGraph.MSGraphPane graphPane, Graphics g, pwiz.MSGraph.MSPointList pointList, ZedGraph.GraphObjList annotations)
        {
            base.AddAnnotations(graphPane, g, pointList, annotations);
            //using( Spectrum element = Element )
            {
                foreach (Precursor p in Element.precursors)
                {
                    foreach (SelectedIon si in p.selectedIons)
                    {
                        double  precursorMz          = (double)si.cvParam(CVID.MS_selected_ion_m_z).value;
                        int     precursorCharge      = 0;
                        CVParam precursorChargeParam = si.cvParam(CVID.MS_charge_state);
                        if (precursorChargeParam.empty())
                        {
                            precursorChargeParam = si.cvParam(CVID.MS_possible_charge_state);
                        }
                        if (!precursorChargeParam.empty())
                        {
                            precursorCharge = (int)precursorChargeParam.value;
                        }


                        double           stickLength  = 0.1;
                        ZedGraph.LineObj stickOverlay = new ZedGraph.LineObj(precursorMz, 1, precursorMz, stickLength);
                        stickOverlay.Location.CoordinateFrame = ZedGraph.CoordType.XScaleYChartFraction;
                        stickOverlay.Line.Width = 3;
                        stickOverlay.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                        stickOverlay.Line.Color = Color.Green;

                        annotations.Add(stickOverlay);

                        // Create a text label from the X data value
                        string precursorLabel;
                        if (precursorCharge > 0)
                        {
                            precursorLabel = String.Format("{0}\n(+{1} precursor)", precursorMz.ToString("f3"), precursorCharge);
                        }
                        else
                        {
                            precursorLabel = String.Format("{0}\n(precursor of unknown charge)", precursorMz.ToString("f3"));
                        }
                        ZedGraph.TextObj text = new ZedGraph.TextObj(precursorLabel, precursorMz, stickLength,
                                                                     ZedGraph.CoordType.XScaleYChartFraction, ZedGraph.AlignH.Center, ZedGraph.AlignV.Bottom);
                        text.ZOrder                    = ZedGraph.ZOrder.A_InFront;
                        text.FontSpec.FontColor        = stickOverlay.Line.Color;
                        text.FontSpec.Border.IsVisible = false;
                        text.FontSpec.Fill.IsVisible   = false;
                        //text.FontSpec.Fill = new Fill( Color.FromArgb( 100, Color.White ) );
                        text.FontSpec.Angle = 0;
                        annotations.Add(text);
                    }
                }
            }
        }
コード例 #4
0
 /// <summary>
 ///     Object hash code
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Charge;
         hashCode = (hashCode * 397) ^ (FragmentArrays != null ? FragmentArrays.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Index != null ? Index.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CVParam != null ? CVParam.GetHashCode() : 0);
         return(hashCode);
     }
 }
コード例 #5
0
ファイル: ProcessingListView.cs プロジェクト: zrolfs/pwiz
        public override Spectrum spectrum(int index, bool getBinaryData)
        {
            Spectrum s = base.spectrum(index, true);

            if (s.cvParam(CVID.MS_MSn_spectrum).empty() ||
                (int)s.cvParam(CVID.MS_ms_level).value == 1)
            {
                if (!getBinaryData)
                {
                    s.binaryDataArrays.Clear();
                }
                return(s);
            }

            PrecursorList pl = s.precursors;

            BinaryData            mzArray        = s.getMZArray().data;
            BinaryData            intensityArray = s.getIntensityArray().data;
            PointDataMap <double> mziMap         = new PointDataMap <double>();

            for (int i = 0; i < (int)s.defaultArrayLength; ++i)
            {
                mziMap.Insert(mzArray[i], intensityArray[i]);
            }

            Set <double> pointsToRemove = new Set <double>();

            foreach (Precursor p in pl)
            {
                foreach (SelectedIon si in p.selectedIons)
                {
                    double mz = (double)si.cvParam(CVID.MS_selected_ion_m_z).value;
                    PointDataMap <double> .Enumerator itr = mziMap.LowerBound(mz - 4.0);
                    if (itr != null && itr.IsValid)
                    {
                        while (itr.IsValid && itr.Current.Key - mz < 4.0)
                        {
                            pointsToRemove.Add(itr.Current.Key);
                            itr.MoveNext();
                        }
                    }

                    CVParam chargeParam = si.cvParam(CVID.MS_charge_state);
                    if (!chargeParam.empty())
                    {
                        int z = (int)chargeParam.value;
                        for (int i = 1; i < z; ++i)
                        {
                            double strippedMz = (mz * z) / (z - i);
                            itr = mziMap.LowerBound(strippedMz - 4.0);
                            if (itr != null && itr.IsValid)
                            {
                                while (itr.IsValid && itr.Current.Key - strippedMz < 4.0)
                                {
                                    pointsToRemove.Add(itr.Current.Key);
                                    itr.MoveNext();
                                }
                            }
                        }
                    }
                }
            }

            if (getBinaryData)
            {
                mzArray.Clear();
                intensityArray.Clear();
                foreach (PointDataMap <double> .MapPair pair in mziMap)
                {
                    if (pointsToRemove.Contains(pair.Key))
                    {
                        continue;
                    }

                    mzArray.Add(pair.Key);
                    intensityArray.Add(pair.Value);
                }
                s.defaultArrayLength = (ulong)mzArray.Count;
            }
            else
            {
                s.binaryDataArrays.Clear();
                s.defaultArrayLength -= (ulong)pointsToRemove.Count;
            }

            return(s);
        }
コード例 #6
0
ファイル: ProcessingListView.cs プロジェクト: zrolfs/pwiz
 public SpectrumList_Preexisting_ListViewItem(ProcessingMethod method)
     : base(method.cvParamChild(CVID.MS_data_processing_action).name)
 {
     methodParam = method.cvParamChild(CVID.MS_data_processing_action);
 }
コード例 #7
0
        private void gridView_ShowCellToolTip(DataGridViewCell cell)
        {
            MassSpectrum spectrum = cell.OwningRow.Tag as MassSpectrum;
            Spectrum     s        = spectrum.Element;

            TreeViewForm treeViewForm = new TreeViewForm(spectrum);
            TreeView     tv           = treeViewForm.TreeView;

            if (gridView.Columns[cell.ColumnIndex].Name == "PrecursorInfo")
            {
                treeViewForm.Text = "Precursor Details";
                if (s.precursors.Count == 0)
                {
                    tv.Nodes.Add("No precursor information available.");
                }
                else
                {
                    foreach (Precursor p in s.precursors)
                    {
                        string pNodeText = "Precursor scan";
                        if (p.sourceFile != null && p.externalSpectrumID.Length > 0)
                        {
                            pNodeText += String.Format(": {0}:{1}", p.sourceFile.name, p.externalSpectrumID);
                        }
                        else if (p.spectrumID.Length > 0)
                        {
                            pNodeText += String.Format(": {0}", p.spectrumID);
                        }

                        TreeNode pNode = tv.Nodes.Add(pNodeText);
                        addParamsToTreeNode(p as ParamContainer, pNode);

                        if (p.selectedIons.Count == 0)
                        {
                            pNode.Nodes.Add("No selected ion list available.");
                        }
                        else
                        {
                            foreach (SelectedIon si in p.selectedIons)
                            {
                                TreeNode siNode = pNode.Nodes.Add("Selected ion");
                                //siNode.ToolTipText = new CVTermInfo(CVID.MS_selected_ion); // not yet in CV
                                addParamsToTreeNode(si as ParamContainer, siNode);
                            }
                        }

                        if (p.activation.empty())
                        {
                            pNode.Nodes.Add("No activation details available.");
                        }
                        else
                        {
                            TreeNode actNode = pNode.Nodes.Add("Activation");
                            addParamsToTreeNode(p.activation as ParamContainer, actNode);
                        }

                        if (p.isolationWindow.empty())
                        {
                            pNode.Nodes.Add("No isolation window details available.");
                        }
                        else
                        {
                            TreeNode iwNode = pNode.Nodes.Add("Isolation Window");
                            addParamsToTreeNode(p.isolationWindow as ParamContainer, iwNode);
                        }
                    }
                }
            }
            else if (gridView.Columns[cell.ColumnIndex].Name == "ScanInfo")
            {
                treeViewForm.Text = "Scan Configuration Details";
                if (s.scanList.empty())
                {
                    tv.Nodes.Add("No scan details available.");
                }
                else
                {
                    TreeNode slNode = tv.Nodes.Add("Scan List");
                    addParamsToTreeNode(s.scanList as ParamContainer, slNode);

                    foreach (Scan scan in s.scanList.scans)
                    {
                        TreeNode scanNode = slNode.Nodes.Add("Acquisition");
                        addParamsToTreeNode(scan as ParamContainer, scanNode);

                        foreach (ScanWindow sw in scan.scanWindows)
                        {
                            TreeNode swNode = scanNode.Nodes.Add("Scan Window");
                            addParamsToTreeNode(sw as ParamContainer, swNode);
                        }
                    }
                }
            }
            else if (gridView.Columns[cell.ColumnIndex].Name == "InstrumentConfigurationID")
            {
                treeViewForm.Text = "Instrument Configuration Details";
                InstrumentConfiguration ic = s.scanList.scans[0].instrumentConfiguration;
                if (ic == null || ic.empty())
                {
                    tv.Nodes.Add("No instrument configuration details available.");
                }
                else
                {
                    TreeNode icNode = tv.Nodes.Add(String.Format("Instrument Configuration ({0})", ic.id));
                    addParamsToTreeNode(ic as ParamContainer, icNode);

                    if (ic.componentList.Count == 0)
                    {
                        icNode.Nodes.Add("No component list available.");
                    }
                    else
                    {
                        TreeNode clNode = icNode.Nodes.Add("Component List");
                        foreach (pwiz.CLI.msdata.Component c in ic.componentList)
                        {
                            string cNodeText;
                            switch (c.type)
                            {
                            case ComponentType.ComponentType_Source:
                                cNodeText = "Source";
                                break;

                            case ComponentType.ComponentType_Analyzer:
                                cNodeText = "Analyzer";
                                break;

                            default:
                            case ComponentType.ComponentType_Detector:
                                cNodeText = "Detector";
                                break;
                            }
                            TreeNode cNode = clNode.Nodes.Add(cNodeText);
                            addParamsToTreeNode(c as ParamContainer, cNode);
                        }
                    }

                    Software sw = ic.software;
                    if (sw == null || sw.empty())
                    {
                        icNode.Nodes.Add("No software details available.");
                    }
                    else
                    {
                        TreeNode swNode        = icNode.Nodes.Add(String.Format("Software ({0})", sw.id));
                        CVParam  softwareParam = sw.cvParamChild(CVID.MS_software);
                        TreeNode swNameNode    = swNode.Nodes.Add("Name: " + softwareParam.name);
                        swNameNode.ToolTipText = new CVTermInfo(softwareParam.cvid).def;
                        swNode.Nodes.Add("Version: " + sw.version);
                    }
                }
            }
            else if (gridView.Columns[cell.ColumnIndex].Name == "DataProcessing")
            {
                treeViewForm.Text = "Data Processing Details";
                DataProcessing dp = s.dataProcessing;
                if (dp == null || dp.empty())
                {
                    tv.Nodes.Add("No data processing details available.");
                }
                else
                {
                    TreeNode dpNode = tv.Nodes.Add(String.Format("Data Processing ({0})", dp.id));

                    if (dp.processingMethods.Count == 0)
                    {
                        dpNode.Nodes.Add("No component list available.");
                    }
                    else
                    {
                        TreeNode pmNode = dpNode.Nodes.Add("Processing Methods");
                        foreach (ProcessingMethod pm in dp.processingMethods)
                        {
                            addParamsToTreeNode(pm as ParamContainer, pmNode);
                        }
                    }
                }
            }
            else
            {
                return;
            }

            tv.ExpandAll();
            treeViewForm.StartPosition = FormStartPosition.CenterParent;
            treeViewForm.AutoSize      = true;
            //treeViewForm.DoAutoSize();
            treeViewForm.Show(this.DockPanel);
            //leaveTimer.Start();
            this.Focus();
        }
コード例 #8
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);
        }
コード例 #9
0
ファイル: MzMLReader.cs プロジェクト: javamng/GitHUB
        /// <summary>
        /// Handle the cvParam element
        /// </summary>
        /// <param name="reader">XmlReader that is only valid for the scope of the single "cvParam" element</param>
        private CVParam ReadCvParam(XmlReader reader)
        {
            reader.MoveToContent();
            CVParam cvParam = new CVParam();
            cvParam.Accession = reader.GetAttribute("accession");
            cvParam.CVRef = reader.GetAttribute("cvRef");
            cvParam.Name = reader.GetAttribute("name");
            cvParam.Value = reader.GetAttribute("value");
            cvParam.UnitAccession = reader.GetAttribute("unitAccession");
            cvParam.UnitCVRef = reader.GetAttribute("unitCVRef");
            cvParam.UnitName = reader.GetAttribute("unitName");

            reader.Close();
            return cvParam;
        }