コード例 #1
0
ファイル: seems.cs プロジェクト: tomas-pluskal/pwiz
        private void peptideFragmentationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PeptideFragmentationForm peptideFragmentationForm = new PeptideFragmentationForm();

            peptideFragmentationForm.ShowDialog(this);
            if (peptideFragmentationForm.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            if (peptideFragmentationForm.MsProductReportXml != null)
            {
                Map <string, List <Pair <double, int> > > pointAnnotations = new Map <string, List <Pair <double, int> > >();

                XmlTextReader reader = new XmlTextReader(new StringReader(peptideFragmentationForm.MsProductReportXml));

                string ionSeriesName      = "immonium";
                string ionSeriesIndex     = "";
                int    previousLabelCount = CurrentGraphForm.CurrentPointAnnotations.Count;
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (reader.Name == "mz")
                        {
                            string[] ionMzChargeStr = reader.ReadElementContentAsString().Split(",".ToCharArray());
                            double   ionMz          = Convert.ToDouble(ionMzChargeStr[0]);
                            int      ionCharge      = Convert.ToInt32(ionMzChargeStr[1]);
                            pointAnnotations[ionSeriesName + ionSeriesIndex].Add(new Pair <double, int>(ionMz, ionCharge));
                        }
                        else if (reader.Name[0] == 'i')
                        {
                            Int32 test;
                            if (Int32.TryParse(reader.Name.Substring(1), out test))
                            {
                                ionSeriesIndex = " " + reader.Name.Substring(1);
                            }
                        }
                        else if (reader.Name == "name")
                        {
                            ionSeriesName = reader.ReadElementContentAsString();
                        }
                        break;
                    }
                }

                if (CurrentGraphForm.CurrentScan.IsMassSpectrum)
                {
                    CurrentGraphForm.AnnotationSettings.setScanLabels(pointAnnotations);
                    if (CurrentGraphForm.CurrentPointAnnotations.Count > previousLabelCount)
                    {
                        CurrentGraphForm.updateGraph();
                    }
                }
            }
        }
コード例 #2
0
ファイル: seems.cs プロジェクト: pombredanne/BICEPS
        private void peptideFragmentationToolStripMenuItem_Click( object sender, EventArgs e )
        {
            PeptideFragmentationForm peptideFragmentationForm = new PeptideFragmentationForm();
            peptideFragmentationForm.ShowDialog( this );
            if( peptideFragmentationForm.DialogResult == DialogResult.Cancel )
                return;

            if( peptideFragmentationForm.MsProductReportXml != null )
            {
                Map<string, List<Pair<double, int>>> pointAnnotations = new Map<string, List<Pair<double, int>>>();

                XmlTextReader reader = new XmlTextReader( new StringReader( peptideFragmentationForm.MsProductReportXml ) );

                string ionSeriesName = "immonium";
                string ionSeriesIndex = "";
                int previousLabelCount = CurrentGraphForm.CurrentPointAnnotations.Count;
                while( reader.Read() )
                {
                    switch( reader.NodeType )
                    {
                        case XmlNodeType.Element:
                            if( reader.Name == "mz" )
                            {
                                string[] ionMzChargeStr = reader.ReadElementContentAsString().Split( ",".ToCharArray() );
                                double ionMz = Convert.ToDouble( ionMzChargeStr[0] );
                                int ionCharge = Convert.ToInt32( ionMzChargeStr[1] );
                                pointAnnotations[ionSeriesName + ionSeriesIndex].Add( new Pair<double, int>( ionMz, ionCharge ) );
                            } else if( reader.Name[0] == 'i' )
                            {
                                Int32 test;
                                if( Int32.TryParse( reader.Name.Substring( 1 ), out test ) )
                                {
                                    ionSeriesIndex = " " + reader.Name.Substring( 1 );
                                }
                            } else if( reader.Name == "name" )
                            {
                                ionSeriesName = reader.ReadElementContentAsString();
                            }
                            break;
                    }
                }

                CurrentGraphForm.ScanAnnotationSettings.setScanLabels( pointAnnotations );
                if( CurrentGraphForm.CurrentPointAnnotations.Count > previousLabelCount )
                    CurrentGraphForm.updateGraph();
            }
        }