Esempio n. 1
0
        /// <summary>
        /// Check if iso cyanic acid loss is present in the spectrum's MS1 scan.
        /// </summary>
        /// <param name="spectrum">The spectrum to be checked.</param>
        /// <returns>True, if isocyanic acid is present; Otherwise, false.</returns>
        private static bool IsIsoCyanicAcidLossPresentMs1(MsSpectrum spectrum)
        {
            // Get the precursor m/z value
            double precursorMz = spectrum.PreCursorMz;

            // Loop through all of the M/Z-values
            foreach (double mzVal in spectrum.ParentScan.MzValues)
            {
                // Check that the m/z is not greater than the precursor, because the code is looking for an loss i.e. a value less than the precursor
                // TODO: Maybe insert to increase speed.
                //if(mzVal > precursorMz) { break; }

                // Check if the isocyanic neutral loss is present.
                if (HelperUtilities.IsApproximately(mzVal, precursorMz - 43, ScoreSettings.CyanicLossTolerance))
                {
                    // The isocyanic netural loss ion is found
                    // If that is the case set the M/Z value of the ion
                    spectrum.IsoCyanicMzMs1 = mzVal;
                    // Return true, because the ion was found
                    return(true);
                }
            }

            // No loss was found. Set the m/z value for the loss ion to an impossible value
            spectrum.IsoCyanicMzMs1 = -1;
            // Return false, because no ion was found
            return(false);
        }
Esempio n. 2
0
 /// <summary>
 /// Check weather the spectrum has the correct mass shift.
 /// </summary>
 /// <param name="citMz">The m/z value for the citrullinated spectrum.</param>
 /// <param name="argMz">The m/z value for the arginine spectrum.</param>
 /// <param name="fragMassError">The fragment mass error. Used to calculate the tolerance.</param>
 /// <param name="containsCit">Indicates that the ion contains the citrullination.</param>
 /// <returns>True, if has correct mass shift; Otherwise, false.</returns>
 private static bool HasCorrectCitMassShift(double citMz, double argMz, double fragMassError, bool containsCit)
 {
     // Determine whether the ion contains the citrullination
     if (containsCit)
     {
         // Citrullination. The cit M/Z should be 0.984 heavier than Arg M/Z
         return(HelperUtilities.IsApproximately(citMz - 0.984, argMz, fragMassError / 5));
     }
     else
     {
         // No citrullination. The cit M/Z and Arg M/Z should be equal
         return(HelperUtilities.IsApproximately(citMz, argMz, fragMassError / 5));
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Check if list of isocyanic loss contains a certain m/z-value.
        /// </summary>
        /// <param name="cyanlossMz">The list of isocyanic losses.</param>
        /// <param name="mzVal">The M/Z-value to be checked.</param>
        /// <returns>True, if list contains the iso cyanic loss; Otherwise, false.</returns>
        private static bool IsoListContains(List <double> cyanlossMz, double mzVal)
        {
            // Loop through all of the values
            foreach (double cyanLossMz in cyanlossMz)
            {
                // If an loss m/z is approx. equal to the M/Z-value to be checked, return true
                if (HelperUtilities.IsApproximately(cyanLossMz + 43, mzVal, ScoreSettings.CyanicLossTolerance))
                {
                    return(true);
                }
            }

            // If the item is not found
            return(false);
        }
Esempio n. 4
0
 /// <summary>
 /// Update the  window
 /// </summary>
 /// <param name="result"></param>
 internal void UpdateWindow(QuantResult result)
 {
     _result = result;
     GetSpectra(_result);
     SetCitInfo();
     ValidationUIUtilities.ClearChart(chartMS1);
     ValidationUIUtilities.ClearChart(chartMS2);
     ValidationUIUtilities.CreateMS1Chart(chartMS1, citSpectrum);
     ValidationUIUtilities.CreateLoneCitMs2Chart(chartMS2, citSpectrum);
     ValidationUIUtilities.FillIonGridGeneral(metroGridCitIons, citSpectrum, HelperUtilities.CreateAAArray(_result.Sequence));
     if (Quantification.QuantificationResults.Contains(result))
     {
         metroButtonAddQuant.Enabled    = false;
         metroButtonRemoveQuant.Enabled = true;
     }
     else
     {
         metroButtonAddQuant.Enabled    = true;
         metroButtonRemoveQuant.Enabled = false;
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Update the quantification window.
        /// </summary>
        /// <param name="result">The quantification result.</param>
        internal void UpdateWindow(QuantResult result)
        {
            // Set the result
            _result = result;
            // Get the spectra
            GetSpectra(_result);
            // Add the info
            SetCitInfo();
            SetArgInfo();
            // Clear the charts
            ValidationUIUtilities.ClearChart(chartArgMS1);
            ValidationUIUtilities.ClearChart(chartCitMS1);
            ValidationUIUtilities.ClearChart(chartMS2);
            // Create the charts
            ValidationUIUtilities.CreateMS1Chart(chartArgMS1, argSpectrum);
            ValidationUIUtilities.CreateMS1Chart(chartCitMS1, citSpectrum);
            ValidationUIUtilities.CreatePairedMs2Chart(chartMS2, citSpectrum, argSpectrum);
            // Create the ion grid
            ValidationUIUtilities.FillIonGridGeneral(metroGridArgIons, argSpectrum, HelperUtilities.CreateAAArray(_result.Sequence));
            ValidationUIUtilities.FillIonGridGeneral(metroGridCitIons, citSpectrum, HelperUtilities.CreateAAArray(_result.Sequence));
            // Set the title and spectrum ID
            labelTitel.Text = string.Format("Quantification - Paired (By {0})", _result.ValidationBy);
            metroLabelCitSpectrumID.Text = _result.CitSpectrumID.ToString();
            metroLabelArgSpectrumID.Text = _result.ArgSpectrumID.ToString();

            if (Quantification.QuantificationResults.Contains(result))
            {
                metroButtonAddQuant.Enabled    = false;
                metroButtonRemoveQuant.Enabled = true;
            }
            else
            {
                metroButtonAddQuant.Enabled    = true;
                metroButtonRemoveQuant.Enabled = false;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Count the presence of isocyanic acid loss on MS2.
        /// </summary>
        /// <param name="citSpectrum">The citrullinated spectrum.</param>
        /// <param name="citIndex">The index of the citrullinated arginine.</param>
        /// <param name="aaSeq">The amino acid sequence.</param>
        /// <returns>The number of isocyanic acid losses.</returns>
        private static double CountIsoCyanicAcidLossPresentMs2(MsSpectrum citSpectrum, int citIndex, string[] aaSeq)
        {
            // Create temporay list of isocyanic loss M/Z
            List <double> cyanlossMz = new List <double>();

            // Create scores
            int aIonCount   = 0;
            int bIonCount   = 0;
            int b17IonCount = 0;
            int b18IonCount = 0;
            int yIonCount   = 0;
            int y17IonCount = 0;
            int y18IonCount = 0;

            List <double> mzValues = citSpectrum.MzValues.ToList();

            mzValues.Reverse();
            foreach (double mzVal in mzValues)
            {
                // Loop through the all of amino acid sequence.However only the index is used.
                for (int i = 0; i < aaSeq.Length; i++)
                {
                    if (IsoListContains(cyanlossMz, mzVal))
                    {
                        continue;
                    }
                    // Check that the this is the citrullinated a- or b-ions. The aa index is greater than or equal to the index of the citrullination.
                    if (i >= citIndex)
                    {
                        // Check that both spectra contains the A-ion at this specific amino acid
                        if (citSpectrum.AIonIndex.Contains(i))
                        {
                            /* Calculate A-ion */
                            // Get the M/Z value for A-ion on the complementary citrullinated spectrum
                            double citMz = citSpectrum.SpectrumPossibleAIons[i];
                            // If the spectrum has an ion that is 43 Da less than the cit spectrum, add the spectrum m/z to the list
                            if (HelperUtilities.IsApproximately(mzVal, citMz - 43, ScoreSettings.CyanicLossTolerance))
                            {
                                cyanlossMz.Add(mzVal);
                                aIonCount++;
                                continue;
                            }
                        }

                        // Check that both spectra contains the B-ion at this specific amino acid
                        if (citSpectrum.BIonIndex.Contains(i))
                        {
                            /* Calculate B-ion */
                            // Get the M/Z value for B-ion on the complementary citrullinated spectrum
                            double citMz = citSpectrum.SpectrumPossibleBIons[i];
                            // If the spectrum has an ion that is 43 Da less than the cit spectrum, add the spectrum m/z to the list
                            if (HelperUtilities.IsApproximately(mzVal, citMz - 43, ScoreSettings.CyanicLossTolerance))
                            {
                                cyanlossMz.Add(mzVal);
                                bIonCount++;
                                continue;
                            }
                        }

                        // Check that both spectra contains the B-17 ion at this specific amino acid
                        if (citSpectrum.B17IonIndex.Contains(i))
                        {
                            /* Calculate B-17 ion */
                            // Get the M/Z value for B-17 ion on the complementary citrullinated spectrum
                            double citMz = citSpectrum.SpectrumPossibleBm17Ions[i];
                            // If the spectrum has an ion that is 43 Da less than the cit spectrum, add the spectrum m/z to the list
                            if (HelperUtilities.IsApproximately(mzVal, citMz - 43, ScoreSettings.CyanicLossTolerance))
                            {
                                cyanlossMz.Add(mzVal);
                                b17IonCount++;
                                continue;
                            }
                        }

                        // Check that both spectra contains the B-18 ion at this specific amino acid
                        if (citSpectrum.B18IonIndex.Contains(i))
                        {
                            /* Calculate B-18 ion */
                            // Get the M/Z value for B-18 ion on the complementary citrullinated spectrum
                            double citMz = citSpectrum.SpectrumPossibleBm18Ions[i];
                            // If the spectrum has an ion that is 43 Da less than the cit spectrum, add the spectrum m/z to the list
                            if (HelperUtilities.IsApproximately(mzVal, citMz - 43, ScoreSettings.CyanicLossTolerance))
                            {
                                cyanlossMz.Add(mzVal);
                                b18IonCount++;
                                continue;
                            }
                        }
                    }
                    // Check that the this is the citrullinated y-ion. The aa index is less than or equal to the index of the citrullination.
                    if (i <= citIndex)
                    {
                        // Check that both spectra contains the Y-ion at this specific amino acid
                        if (citSpectrum.YIonIndex.Contains(i))
                        {
                            /* Calculate Y-ion */
                            // Get the M/Z value for Y-ion on the complementary citrullinated spectrum
                            double citMz = citSpectrum.SpectrumPossibleYIons[i];
                            // If the spectrum has an ion that is 43 Da less than the cit spectrum, add the spectrum m/z to the list
                            if (HelperUtilities.IsApproximately(mzVal, citMz - 43, ScoreSettings.CyanicLossTolerance))
                            {
                                cyanlossMz.Add(mzVal);
                                yIonCount++;
                                continue;
                            }
                        }

                        // Check that both spectra contains the Y-17 ion at this specific amino acid
                        if (citSpectrum.Y17IonIndex.Contains(i))
                        {
                            /* Calculate Y-17 ion */
                            // Get the M/Z value for Y-17 ion on the complementary citrullinated spectrum
                            double citMz = citSpectrum.SpectrumPossibleYm17Ions[i];
                            // If the spectrum has an ion that is 43 Da less than the cit spectrum, add the spectrum m/z to the list
                            if (HelperUtilities.IsApproximately(mzVal, citMz - 43, ScoreSettings.CyanicLossTolerance))
                            {
                                cyanlossMz.Add(mzVal);
                                y17IonCount++;
                                continue;
                            }
                        }

                        // Check that both spectra contains the Y-18 ion at this specific amino acid
                        if (citSpectrum.Y18IonIndex.Contains(i))
                        {
                            /* Calculate Y-18 ion */
                            // Get the M/Z value for Y-18 ion on the complementary citrullinated spectrum
                            double citMz = citSpectrum.SpectrumPossibleYm18Ions[i];
                            // If the spectrum has an ion that is 43 Da less than the cit spectrum, add the spectrum m/z to the list
                            if (HelperUtilities.IsApproximately(mzVal, citMz - 43, ScoreSettings.CyanicLossTolerance))
                            {
                                cyanlossMz.Add(mzVal);
                                y18IonCount++;
                                continue;
                            }
                        }
                    }
                }
            }

            // Set collection
            citSpectrum.IsoCyanicLossMzMs2 = cyanlossMz.ToArray();
            // Calculate score
            double score = aIonCount * ScoreSettings.MS2IsoCyanLossAScore;

            score += bIonCount * ScoreSettings.MS2IsoCyanLossBScore;
            score += b17IonCount * (ScoreSettings.MS2IsoCyanLossBScore / ScoreSettings.MS2IsoCyanOnLossScoreDivider);
            score += b18IonCount * (ScoreSettings.MS2IsoCyanLossBScore / ScoreSettings.MS2IsoCyanOnLossScoreDivider);
            score += yIonCount * ScoreSettings.MS2IsoCyanLossYScore;
            score += y17IonCount * (ScoreSettings.MS2IsoCyanLossYScore / ScoreSettings.MS2IsoCyanOnLossScoreDivider);
            score += y18IonCount * (ScoreSettings.MS2IsoCyanLossYScore / ScoreSettings.MS2IsoCyanOnLossScoreDivider);
            // TODO: Set score instead of count
            //return cyanlossMz.Count;
            return(score);
        }
Esempio n. 7
0
        /// <summary>
        /// Create the image.
        /// </summary>
        /// <param name="directory">The directory the image should be saved to.</param>
        /// <param name="result">The result the image should be created from.</param>
        private void CreateImage(string directory, KeyValuePair <QuantResult, KeyValuePair <MsSpectrum, MsSpectrum> > result)
        {
            KeyValuePair <MsSpectrum, MsSpectrum> spectraData = result.Value;
            // Get the filename
            string baseFilename = string.Format("{0}_{1}_{2}", result.Key.Protein.Split('|')[0], result.Key.Sequence, result.Key.ValidationBy);
            string filename     = FileReader.GenerateFileName(directory, baseFilename, "tiff");

            // Append the file to the annotation writer
            if (_createAnnotationFile)
            {
                _annotationWriter.AppendLine($"** {filename.Split(new string[] { @"\" }, System.StringSplitOptions.None).Last() } **");
            }

            // From the validation type, create the graph
            if (result.Key.ValidationBy == "Lone")
            {
                ValidationUIUtilities.CreateLoneCitMs2Chart(chartMS2, spectraData.Key);
                ValidationUIUtilities.AnnotateSingleSpectra(chartMS2, spectraData.Key, HelperUtilities.CreateAAArray(result.Key.Sequence), true, _createAnnotationFile, _annotationWriter);
            }
            else
            {
                ValidationUIUtilities.CreatePairedMs2Chart(chartMS2, spectraData.Key, spectraData.Value);
                ValidationUIUtilities.AnnotatePairedSpectra(chartMS2, spectraData.Key, spectraData.Value, HelperUtilities.CreateAAArray(result.Key.Sequence), _createAnnotationFile, _annotationWriter);
            }

            // Clear the old titles
            chartMS2.Titles.Clear();
            // And add a new one
            chartMS2.Titles.Add(string.Format("{0}_{1}_{2}", result.Key.Protein.Split('|')[0], result.Key.Sequence, result.Key.ValidationBy));
            chartMS2.Titles[0].Font = new Font(chartMS2.Titles[0].Font.FontFamily, 13F);
            chartMS2.Titles[0].IsDockedInsideChartArea = false;
            chartMS2.Titles[0].Docking       = Docking.Top;
            chartMS2.Titles[0].DockingOffset = 10;

            chartMS2.SaveImage(filename, ChartImageFormat.Tiff);
            ValidationUIUtilities.ClearChart(chartMS2);
            chartMS2.Annotations.Clear();
        }