Exemplo n.º 1
0
        /// <summary>
        /// This function trigges when an interpretation is double clicked.
        /// It prepares the annotation and spectrum viewer panels.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void triggerSpectrumViewer(object sender, EventArgs e)
        {
            // Get the current row
            DataGridViewRow row = spectraGrid.CurrentRow;

            if (row != null)
            {
                // Get the result and variant objects associated with this row
                Object[]     tags     = row.Tag as Object[];
                SpectrumInfo spectrum = tags[0] as SpectrumInfo;
                VariantInfo  variant  = tags[1] as VariantInfo;
                if (spectrum != null && currentSpectraGridSelection != row)
                {
                    try {
                        // Resolve the spectrum source
                        var source  = Path.GetFileNameWithoutExtension(spectrum.id.source.name);
                        var paths   = Properties.Settings.Default.SourcePath.Split(";".ToCharArray());
                        var matches = Util.FindFileInSearchPath(source, new string[] { "mzXML", "mzML", "mgf", "RAW" }, paths.ToArray(), true);
                        if (matches.Length == 0)
                        {
                            MessageBox.Show("Can't find source. Set the source folder path.");
                        }
                        else
                        {
                            // Convert the interpretation for seems compatibility
                            var interpetation = variant.ToSimpleString();
                            interpetation = interpetation.Replace('(', '[');
                            interpetation = interpetation.Replace(')', ']');
                            splitContainer4.Panel2.Hide();
                            splitContainer1.Panel2.Hide();
                            splitContainer5.Panel1.Hide();
                            splitContainer5.Panel2.Hide();
                            Application.DoEvents();
                            UniqueSpectrumID uniqueSpectrumID;
                            // Create a spectrum viewer and add its components
                            if (spectrum.nativeID != null && spectrum.nativeID.Length > 0)
                            {
                                currentSpectrumViewer = new SpectrumViewer(matches[0], spectrum.nativeID, interpetation);
                                uniqueSpectrumID      = new UniqueSpectrumID(source, spectrum.nativeID, spectrum.id.charge);
                            }
                            else
                            {
                                currentSpectrumViewer = new SpectrumViewer(matches[0], spectrum.id.index, interpetation);
                                uniqueSpectrumID      = new UniqueSpectrumID(source, spectrum.id.index, spectrum.id.charge);
                            }
                            splitContainer4.Panel2.Controls.Clear();
                            splitContainer4.Panel2.Controls.Add(currentSpectrumViewer.annotationPanel);
                            splitContainer5.Panel1.Controls.Clear();
                            splitContainer5.Panel1.Controls.Add(currentSpectrumViewer.spectrumPanel);
                            splitContainer5.Panel2.Controls.Clear();
                            splitContainer5.Panel2.Controls.Add(currentSpectrumViewer.fragmentationPanel);
                            splitContainer5.Panel2.AutoScroll = true;
                            splitContainer1.Panel2.Controls.Add(splitContainer5);
                            splitContainer1.Panel2.Show();
                            splitContainer4.Panel2.Show();
                            splitContainer5.Panel1.Show();
                            splitContainer5.Panel2.Show();
                            Application.DoEvents();
                            // If we have a seconday result associated with this spectrum,
                            // set the mechanism in spectrum viewer to see it.
                            if (alternativeInterpretations != null)
                            {
                                if (alternativeInterpretations.Contains(uniqueSpectrumID))
                                {
                                    VariantInfo alt = alternativeInterpretations[uniqueSpectrumID];
                                    interpetation = alt.ToSimpleString();
                                    interpetation = interpetation.Replace('(', '[');
                                    interpetation = interpetation.Replace(')', ']');
                                    currentSpectrumViewer.setSecondarySequence(interpetation);
                                }
                            }
                            currentSpectraGridSelection = row;
                        }
                    } catch (Exception exp) {
                        MessageBox.Show(exp.StackTrace);
                        MessageBox.Show("Failed to show spectrum. Check raw data path.");
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// This function trigges when an interpretation is double clicked. 
 /// It prepares the annotation and spectrum viewer panels.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void triggerSpectrumViewer(object sender, EventArgs e)
 {
     // Get the current row
     DataGridViewRow row = spectraGrid.CurrentRow;
     if(row != null) 
     {
         // Get the result and variant objects associated with this row
         Object[] tags = row.Tag as Object[];
         SpectrumInfo spectrum = tags[0] as SpectrumInfo;
         VariantInfo variant = tags[1] as VariantInfo;
         if (spectrum != null && currentSpectraGridSelection != row) 
         {
             try {
                 // Resolve the spectrum source
                 var source = Path.GetFileNameWithoutExtension(spectrum.id.source.name);
                 var paths = Properties.Settings.Default.SourcePath.Split(";".ToCharArray());
                 var matches = Util.FindFileInSearchPath(source, new string[] { "mzXML", "mzML", "mgf", "RAW" }, paths.ToArray(), true);
                 if(matches.Length == 0)
                     MessageBox.Show("Can't find source. Set the source folder path.");
                 else 
                 {
                     // Convert the interpretation for seems compatibility
                     var interpetation = variant.ToSimpleString();
                     interpetation = interpetation.Replace('(', '[');
                     interpetation = interpetation.Replace(')', ']');
                     splitContainer4.Panel2.Hide();
                     splitContainer1.Panel2.Hide();
                     splitContainer5.Panel1.Hide();
                     splitContainer5.Panel2.Hide();
                     Application.DoEvents();
                     UniqueSpectrumID uniqueSpectrumID;
                     // Create a spectrum viewer and add its components
                     if(spectrum.nativeID!=null && spectrum.nativeID.Length>0) 
                     {
                         currentSpectrumViewer = new SpectrumViewer(matches[0],spectrum.nativeID,interpetation);
                         uniqueSpectrumID = new UniqueSpectrumID(source, spectrum.nativeID, spectrum.id.charge);
                     }
                     else
                     {
                         currentSpectrumViewer = new SpectrumViewer(matches[0], spectrum.id.index, interpetation);
                         uniqueSpectrumID = new UniqueSpectrumID(source, spectrum.id.index, spectrum.id.charge);
                     }
                     splitContainer4.Panel2.Controls.Clear();
                     splitContainer4.Panel2.Controls.Add(currentSpectrumViewer.annotationPanel);
                     splitContainer5.Panel1.Controls.Clear();
                     splitContainer5.Panel1.Controls.Add(currentSpectrumViewer.spectrumPanel);
                     splitContainer5.Panel2.Controls.Clear();
                     splitContainer5.Panel2.Controls.Add(currentSpectrumViewer.fragmentationPanel);
                     splitContainer5.Panel2.AutoScroll = true;
                     splitContainer1.Panel2.Controls.Add(splitContainer5);
                     splitContainer1.Panel2.Show();
                     splitContainer4.Panel2.Show();
                     splitContainer5.Panel1.Show();
                     splitContainer5.Panel2.Show();
                     Application.DoEvents();
                     // If we have a seconday result associated with this spectrum, 
                     // set the mechanism in spectrum viewer to see it.
                     if(alternativeInterpretations != null)
                     {
                         if (alternativeInterpretations.Contains(uniqueSpectrumID))
                         {
                             VariantInfo alt = alternativeInterpretations[uniqueSpectrumID];
                             interpetation = alt.ToSimpleString();
                             interpetation = interpetation.Replace('(', '[');
                             interpetation = interpetation.Replace(')', ']');
                             currentSpectrumViewer.setSecondarySequence(interpetation);
                         }
                     }
                     currentSpectraGridSelection = row;
                 }
             } catch(Exception exp) { 
                 MessageBox.Show(exp.StackTrace);
                 MessageBox.Show("Failed to show spectrum. Check raw data path.");
             }
         }
     }
 }