コード例 #1
0
        /// <summary>
        /// Get the orignal scan ID.
        /// </summary>
        /// <param name="scanMS2">The spectrum.</param>
        /// <returns>The spectrum with the original scan ID.</returns>
        private static XTSpectrum GetOriginalScanID(XTSpectrum scanMS2)
        {
            int orgID = int.Parse(scanMS2.SpectrumDescription.Split(';').First().Split(' ').Last());

            scanMS2.ID = orgID;
            return(scanMS2);
        }
コード例 #2
0
        /// <summary>
        /// Calculate the spectrum ions.
        /// </summary>
        /// <param name="scanMS2">The spectrum.</param>
        /// <returns></returns>
        internal static XTSpectrum CalcSpecIons(XTSpectrum scanMS2)
        {
            // Get all of the amino acids as a char array
            char[] aaSeq = scanMS2.Proteins[0].DoaminSeq.ToCharArray();
            // Convert the char array to a string array
            string[] aaSeqArray = aaSeq.Select(a => a.ToString()).ToArray();
            // Set the string array to the spectrum's amino acid sequence
            scanMS2.SpectrumAminoAcidSequence = aaSeqArray;
            // Create a temporary list of amino acid masses
            var aaMasses = new List <double>();

            // Loop through all of the amino acid sequence
            foreach (string aa in aaSeqArray)
            {
                // Try to get the amino acid mass
                if (massDictAminoAcids.TryGetValue(aa, out double aaMass))
                {
                    // If possible, add the mass to the list of amino acid masses
                    aaMasses.Add(aaMass);
                }
            }
            // Set the mass array to the array of spectrum's amino acid sequence masses
            scanMS2.SpectrumAaMasses = aaMasses.ToArray();
            return(scanMS2);
        }
コード例 #3
0
        /// <summary>
        /// Add the info for a potential citrullination.
        /// </summary>
        /// <param name="index">The index of the potential citrullination.</param>
        private void AddPotCitInfo(int index)
        {
            // Set the parent mass
            double pMass = 1.007276470;
            // Get the spectrum
            XTSpectrum argSpec = valKVP.Key;
            // Get the scan
            RawScan potCitScan    = valKVP.Value[index];
            string  scanIDProtein = string.Format("{0} / {1}", potCitScan.ScanNumber, argSpec.SpectrumLabel.Split('|')[1]);

            // Set the scan id
            metroLabelCitID.Text = scanIDProtein;
            // Set the parent mass
            metroLabelCitPMass.Text = Math.Round((potCitScan.PreCursorMz * potCitScan.Charge) - ((potCitScan.Charge - 1) * pMass), 3).ToString();
            // Set the charge
            metroLabelCitCharge.Text = potCitScan.Charge.ToString();
            // Set the sequence
            metroLabelCitSeq.Text = string.Format("({0})", argSpec.Proteins[0].DoaminSeq);
            // Set the retention time for the arginine spectrum
            metroLabelCitRTime.Text = string.Format("{0} sec.", potCitScan.RetentionTime);
            // Set the retention time for the MS1 Serie spectrum
            metroLabelPotCitMS1RTime.Text = string.Format("{0} sec.", potCitScan.RetentionTime);
            // Set the filename
            metroLabelPotCitFileName.Text = potCitScan.OriginalFileName.Split('.')[0];
            // Set the scores
            metroLabelCitScore.Text   = potCitScan.CitScore.ToString();
            metroLabelMatchScore.Text = potCitScan.MatchScore.ToString();
        }
コード例 #4
0
        /// <summary>
        /// Find the possible Y-ions.
        /// </summary>
        /// <param name="scanMS2">The spectrum</param>
        /// <returns>The spectrum with the possible Y-ions.</returns>
        internal static XTSpectrum FindPossibleYIons(XTSpectrum scanMS2)
        {
            // Set the proton, hydrogen and oxygen mass and calculate the mass for the hydroxyl-group
            double pMass  = 1.007276470;
            double hMass  = 1.007825035;
            double oMass  = 15.994914630;
            double ohMass = hMass + oMass;
            // Reverse the amino acid masses
            var aaMasses = scanMS2.SpectrumAaMasses.Reverse().ToArray();
            // Create a temporary list of B-ions
            List <double> yIons = new List <double>();
            // The temporary variable for the y-ion
            double yIon = 0;

            // Loop through all of the amino acid. TODO: Reformat so same code for much as possible
            for (int i = 0; i <= aaMasses.Length - 1; i++)
            {
                // Try to get the modification mass and add it to the y-ion.
                if (scanMS2.SpectrumYIonModDict.TryGetValue(i, out double modMass))
                {
                    yIon += modMass;
                }
                // Add the amino acid mass and the mass qnd the mass of the proton, hydrogen and hydroxyl-group to the y-ion+
                double extraMass = (i == 0) ? (ohMass + hMass + pMass) : 0;
                yIon += aaMasses[i] + extraMass;
                // Add the y-ion value to the list
                yIons.Add(yIon);
            }
            // Set the array of y-ions to spectrum's possible y-ions
            scanMS2.SpectrumPossibleYIons = yIons.ToArray();
            // Return the spectrum
            return(scanMS2);
        }
コード例 #5
0
        /// <summary>
        /// Score the main citrullinated spectrum.
        /// </summary>
        /// <param name="spectrum">The spectrum to be scored.</param>
        /// <returns></returns>
        private static XTSpectrum ScoreCitMainSpectrum(XTSpectrum spectrum)
        {
            // The main spectrum does not have a match score
            spectrum.MatchScore = 0;
            // Validate the fragmentation.
            if (ValidateSpectrumFragmentation(spectrum, spectrum.SpectrumAminoAcidSequence) == false)
            {
                // If the fragmentation is invalid, set CitScore to 0 and return spectrum
                spectrum.CitScore           = 0;
                spectrum.IsoCyanicLossMzMs2 = new double[0];
                return(spectrum);
            }

            // Calculate the score
            double citScore = IsIsoCyanicAcidLossPresentMs1(spectrum) ? ScoreSettings.MS1IsoCyanicLossScore : 0;

            citScore += CountIsoCyanicAcidLossPresentMs2(spectrum) * 1;
            citScore += -Math.Log10(spectrum.SpectrumEVal);

            // Set the score
            spectrum.CitScore = Math.Round(citScore, 1);

            // Return the scored spectrum
            return(spectrum);
        }
コード例 #6
0
        /// <summary>
        /// Find the possible B-ions.
        /// </summary>
        /// <param name="scanMS2">The spectrum</param>
        /// <returns>The spectrum with the possible B-ions.</returns>
        internal static XTSpectrum FindPossibleBIons(XTSpectrum scanMS2)
        {
            // Set the proton masses
            double pMass = 1.007276470;
            // Create a temporary list of B-ions
            List <double> bIons = new List <double>();
            // The temporary variable for the b-ion
            double bIon = 0;

            // Loop through all of the amino acid. TODO: Reformat so same code for much as possible
            for (int i = 0; i <= scanMS2.SpectrumAaMasses.Length - 1; i++)
            {
                // Try to get the modification mass and add it to the b-ion.
                if (scanMS2.SpectrumBIonModDict.TryGetValue(i, out double modMass))
                {
                    bIon += modMass;
                }
                // Add the amino acid mass and the mass qnd the mass of the proton to the b-ion
                double extraMass = (i == 0) ? pMass : 0;
                bIon += scanMS2.SpectrumAaMasses[i] + extraMass;
                // Add the b-ion value to the list
                bIons.Add(bIon);
            }
            // Set the array of b-ions to spectrum's possible b-ions
            scanMS2.SpectrumPossibleBIons = bIons.ToArray();
            // Return the spectrum
            return(scanMS2);
        }
コード例 #7
0
        /// <summary>
        /// Score the lone citrullinated spectra.
        /// </summary>
        /// <param name="inputSpectra">>The list with the citrullinated spectra to be scored.</param>
        /// <returns>The list of scored spectra.</returns>
        internal static List <XTSpectrum> ScoreLoneCitrullinationSpectra(List <XTSpectrum> inputSpectra)
        {
            // Create a temporary list of scored spectra
            List <XTSpectrum> scoredSpectra = new List <XTSpectrum>();

            // Loop through all of the spectra
            foreach (XTSpectrum spectrum in inputSpectra)
            {
                // Score the spectrum
                XTSpectrum scoredSpectrum = ScoreCitMainSpectrum(spectrum);
                // Add it to the list of scored spectra
                scoredSpectra.Add(scoredSpectrum);
            }

            // Sort the scored spectra after its score
            var scoredSpectraSorted = (from x in scoredSpectra
                                       orderby x.MatchScore descending
                                       select x).ToList();

            // Add spectra above cut-off if set to do so.
            if (ScoreSettings.IncludeCutOff)
            {
                // Add to quantification
                AddLoneCitSpectraAboveCutoffToQunatification(scoredSpectraSorted);
            }
            // Return the list of scored spectra
            return(scoredSpectraSorted);
        }
コード例 #8
0
        /// <summary>
        /// Add the arginine information.
        /// </summary>
        /// <param name="index">The index of the scan.</param>
        private void AddArgInfo(int index)
        {
            // Get the spectrum
            XTSpectrum argSpec       = valKVP.Value[index];
            string     scanIDProtein = string.Format("{0} / {1}", argSpec.ID, argSpec.SpectrumLabel.Split('|')[1]);

            // Set the scan id
            metroLabelArgID.Text = scanIDProtein;
            // Set the parent mass
            metroLabelArgPMass.Text = Math.Round(argSpec.ParentMass, 3).ToString();
            // Set the charge
            metroLabelArgCharge.Text = argSpec.ParentIonCharge.ToString();
            // Set the sequence
            metroLabelArgSeq.Text = argSpec.Proteins[0].DoaminSeq;
            // Set the spectrum e-value
            metroLabelArgEval.Text = argSpec.SpectrumEVal.ToString();
            // Set the retention time for the arginine spectrum
            metroLabelArgRTime.Text = string.Format("{0} sec.", argSpec.RetentionTime);
            // Set the retention time for the MS1 citrullinated spectrum
            metroLabelArgMS1RTime.Text = string.Format("{0} sec.", argSpec.ParentScan.RetentionTime);
            // Set the filename
            metroLabelArgFileName.Text = argSpec.OriginalFileName.Split('.')[0];;
            // Set the score:
            metroLabelMatchScore.Text = argSpec.MatchScore.ToString();
        }
コード例 #9
0
        /// <summary>
        /// Add the citrullination information.
        /// </summary>
        private void AddCitInfo()
        {
            // Get the spectrum
            XTSpectrum citSpec = valKVP.Key;
            // Get and set the scan id and protein
            string scanIDProtein = string.Format("{0} / {1}", citSpec.ID, citSpec.SpectrumLabel.Split('|')[1]);

            metroLabelCitID.Text = scanIDProtein;
            // Set the parent mass
            metroLabelCitPMass.Text = Math.Round(citSpec.ParentMass, 3).ToString();
            // Set the charge
            metroLabelCitCharge.Text = citSpec.ParentIonCharge.ToString();
            // Set the sequence
            metroLabelCitSeq.Text = citSpec.Proteins[0].DoaminSeq;
            // Set the spectrum e-value
            metroLabelCitEval.Text = citSpec.SpectrumEVal.ToString();
            // Set the retention time
            metroLabelCitRTime.Text = string.Format("{0} sec.", citSpec.RetentionTime);
            // Set the retention time
            metroLabelCitMS1RTime.Text = string.Format("{0} sec.", citSpec.ParentScan.RetentionTime);
            // Set the filename
            metroLabelCitFileName.Text = citSpec.OriginalFileName.Split('.')[0];;
            // Set the CitScore
            metroLabelCitScore.Text = citSpec.CitScore.ToString();
        }
コード例 #10
0
        /// <summary>
        /// Calculate CitScore and MatchScore for the complementary cit scan.
        /// </summary>
        /// <param name="mainArgSpectrum">The main arginine spectrum.</param>
        /// <param name="complCitScan">The complementary cit scan.</param>
        /// <returns>The scored scan.</returns>
        private static RawScan ScoreCitComplSpectrum(XTSpectrum mainArgSpectrum, RawScan complCitScan)
        {
            double citScore;

            //Validate the fragmentation.
            if (ValidateSpectrumFragmentation(complCitScan, mainArgSpectrum.SpectrumAminoAcidSequence))
            {
                // Calculate CitScore
                citScore = IsIsoCyanicAcidLossPresentMs1(complCitScan) ? 10 : 0;
                //citScore += CountIsoCyanicAcidLossPresentMs2(mainArgSpectrum, complCitScan) * 1;
                citScore  = -Math.Log10(0.05);
                citScore += CountIsoCyanicAcidLossPresentMs2(complCitScan, GetIndexOfCitrullinationFromArg(mainArgSpectrum), mainArgSpectrum.SpectrumAminoAcidSequence);
            }
            else
            {
                // If the fragmentation is invalid, set CitScore to 0
                citScore = 0;
                complCitScan.IsoCyanicLossMzMs2 = new double[0];
            }


            // Set the CitScore
            complCitScan.CitScore = Math.Round(citScore, 1);
            // Score match between spectra
            complCitScan = ScoreMatchMainArgComplCit(mainArgSpectrum, complCitScan);
            // Return spectra
            return(complCitScan);
        }
コード例 #11
0
ファイル: FindMS1.cs プロジェクト: Citrullia-SDU/Citrullia
        /// <summary>
        /// Find the original MS1 information such as retention time, orgininal scan number and the parent MS1 scan.
        /// </summary>
        /// <param name="spectrumMS2">The MS2 spectrum.</param>
        /// <returns>The MS2 spectrum with the MS1 data.</returns>
        internal static XTSpectrum FindOriginalMS1Info(XTSpectrum spectrumMS2)
        {
            // Get the scan number
            string description = spectrumMS2.SpectrumDescription;
            int    scanNumb    = int.Parse(description.Split(';').First().Split(' ').Last());

            // Loop through each of the input files
            foreach (Input input in FileReader.inputFiles)
            {
                // Get the input file name
                string inputFileName = input.FilePath.Split('\\').Last();
                // Check if the original filename matches the name of the input file
                if (spectrumMS2.OriginalFileName == inputFileName)
                {
                    // If the filename matches the input filename
                    // Loop through all of the MS2 scans in the input
                    foreach (RawScan scan in input.MS2Scans)
                    {
                        // Check if the scan number matches the scan number of the MS2 spectrum
                        if (scanNumb == scan.ScanNumber)
                        {
                            // If so.
                            // Set the retention time
                            spectrumMS2.RetentionTime = scan.RetentionTime;
                            // Set the parent scan number
                            spectrumMS2.ParentScanNumber = scan.ParentScanNumber;
                            // Set the precursor MZ-value
                            spectrumMS2.PreCursorMz = scan.PreCursorMz;
                        }
                    }

                    // Loop through each of the MS1 scans
                    foreach (RawScan s in input.MS1Scans)
                    {
                        // Check if the MS2 spectrum parent scan number matches the MS1 scan
                        if (spectrumMS2.ParentScanNumber == s.ScanNumber)
                        {
                            // If so
                            // Set the parent scan
                            spectrumMS2.ParentScan = s;
                            // Set it to be an non-orphan
                            spectrumMS2.Orphan = false;
                            // Break and continue with the next scan
                            break;
                        }
                        else
                        {
                            // If not
                            // Set the scan to be an orphan
                            spectrumMS2.Orphan = true;
                        }
                    }
                }
            }
            // Return the spectrum with the new information
            return(spectrumMS2);
        }
コード例 #12
0
        /// <summary>
        /// Add the arginine spectra to the quantififcation dictionary.
        /// </summary>
        /// <param name="argSpec">The arginine spectra.</param>
        /// <param name="citScan">The citrullinated scan.</param>
        /// <returns>The dictionary containing the new spectra.</returns>
        internal static Dictionary <XTSpectrum, RawScan> AddTokvpArgSpecScanDict(XTSpectrum argSpec, RawScan citScan)
        {
            if (argSpecScanDict.ContainsKey(argSpec) == false)
            {
                argSpecScanDict.Add(argSpec, citScan);
            }

            return(argSpecScanDict);
        }
コード例 #13
0
        /// <summary>
        /// Add the citrullinated spectra to the quantififcation dictionary.
        /// </summary>
        /// <param name="citSpec">The citrullinated spectra.</param>
        /// <param name="argSpec">The arginine spectra.</param>
        /// <returns>The dictionary containing the new spectra.</returns>
        internal static Dictionary <XTSpectrum, XTSpectrum> AddTokvpCitSpecSpecDict(XTSpectrum citSpec, XTSpectrum argSpec)
        {
            if (citSpecSpecDict.ContainsKey(citSpec) == false)
            {
                citSpecSpecDict.Add(citSpec, argSpec);
            }

            return(citSpecSpecDict);
        }
コード例 #14
0
        /// <summary>
        /// Find citrullinated spectra.
        /// </summary>
        internal static void FindCitrullinatedSpectra()
        {
            // Create an empty list of validation results
            var vResultList = new List <ValResult>();
            // Set the search parameters. Amino acid and mass change
            string residue = "R";
            double mChange = 0.984;

            // Loop through the list of X!Tandem search results
            foreach (XTResult res in FileReader.XTandemSearchResults)
            {
                // Create an empty instance of validation result
                ValResult vResult = new ValResult();
                // Create a empty list of spectra
                var specModPeptides = new List <XTSpectrum>();
                // Set the current X!Tandem result as the parent result of the validation result
                vResult.ParentResult = res;

                // Loop through each of the spectra in the result
                foreach (XTSpectrum spec in res.XSpectrums)
                {
                    // Loop through each of the proteins in the spectrum
                    foreach (XTProtein prot in spec.Proteins)
                    {
                        // Loop through each of the modification in the protein
                        foreach (XTModification mod in prot.Modifications)
                        {
                            // Check that the modification matches the citrullination
                            if (mod.AminoAcid == residue & mod.MassChange == mChange)
                            {
                                // If so.
                                // Calculate the ions
                                XTSpectrum scanMS2 = IonCalculation.CalculateAllIons(spec);
                                // Get the original filename
                                scanMS2 = ReturnOriginalFileNameSpectrum(scanMS2, vResult);
                                // Get the original scan ID
                                scanMS2 = GetOriginalScanID(scanMS2);
                                // Find the original MS1 informaton
                                scanMS2 = FindMS1.FindOriginalMS1Info(scanMS2);
                                // Handle orphan spectra
                                scanMS2 = FindMS1.HandleOrphanSpecs(scanMS2);
                                // Add the spectra to the list of modified spectra
                                specModPeptides.Add(scanMS2);
                            }
                        }
                    }
                }
                // Set the modified spectra to the temporary list filled with data
                vResult.ModifiedSpectra = specModPeptides;
                // Add the result to the result list
                vResultList.Add(vResult);
            }
            // Set the result
            ReturnVResultCit(vResultList);
        }
コード例 #15
0
        /// <summary>
        /// Add the spectrum to quantification.
        /// </summary>
        private void MetroButtonAddQuant_Click(object sender, EventArgs e)
        {
            // Get the spectrum
            XTSpectrum spectrumCit = valSpec;

            // Add the spectrum to the dictionary
            Quantification.AddToLoneCitSpecList(spectrumCit);
            // Update the quantification id list
            UpdateChosenForQuant(valSpec.ID, true);

            // Enable and disable the button
            metroButtonAddQuant.Enabled    = false;
            metroButtonRemoveQuant.Enabled = true;
        }
コード例 #16
0
        /// <summary>
        /// Add the citrullination information.
        /// </summary>
        private void AddCitInfo()
        {
            XTSpectrum citSpec = valSpec;

            metroLabelID.Text          = citSpec.ID.ToString();
            metroLabelCitPMass.Text    = Math.Round(citSpec.ParentMass, 3).ToString();
            metroLabelCitCharge.Text   = citSpec.ParentIonCharge.ToString();
            metroLabelCitSeq.Text      = citSpec.Proteins[0].DoaminSeq;
            metroLabelCitEval.Text     = citSpec.SpectrumEVal.ToString();
            metroLabelCitRTime.Text    = string.Format("{0} sec.", citSpec.RetentionTime);
            metroLabelCitMS1RTime.Text = string.Format("{0} sec.", citSpec.ParentScan.RetentionTime);
            metroLabelCitFileName.Text = citSpec.OriginalFileName.Split('.')[0];
            metroLabelCitScore.Text    = citSpec.CitScore.ToString();
        }
コード例 #17
0
 /// <summary>
 /// Get the index of the citrullination in a citrullinated spectrum.
 /// </summary>
 /// <param name="spectrum">The spectrum.</param>
 /// <returns>The index of the citrullination.</returns>
 private static int GetIndexOfCitrullination(XTSpectrum spectrum)
 {
     // Loop trough all of the modifications in the spectrum
     foreach (KeyValuePair <int, double> mod in spectrum.SpectrumBIonModDict)
     {
         // Check that the modification mass change equals the citrullination. If it does, return the key
         if (mod.Value == 0.984)
         {
             return(mod.Key);
         }
     }
     // If no citrullinations was found, return -1
     return(-1);
 }
コード例 #18
0
        /// <summary>
        /// Score the Citrullinated spectra.
        /// </summary>
        /// <param name="inputSpectra">The dictionary with the citrullinated spectra to be scored and their complementary arginine spectra.</param>
        /// <returns>The dictionary with the scored citrullinated spectra an their complementary scored arginine spectra.</returns>
        internal static Dictionary <XTSpectrum, List <XTSpectrum> > ScoreCitrullinationSpectra(Dictionary <XTSpectrum, List <XTSpectrum> > inputSpectra)
        {
            // Create a temporary list of scored spectra.
            Dictionary <XTSpectrum, List <XTSpectrum> > scoredSpectra = new Dictionary <XTSpectrum, List <XTSpectrum> >();

            // Loop through all of the spectra keyvaluepairs.
            foreach (KeyValuePair <XTSpectrum, List <XTSpectrum> > spectrum in inputSpectra)
            {
                // Score the main spectrum
                XTSpectrum scoredSpectrum = ScoreCitMainSpectrum(spectrum.Key);

                // Score all of the complementary spectra
                // Create a temporary list of scored complementary spectra
                List <XTSpectrum> scoredComplSpectra = new List <XTSpectrum>();

                // Loop through all of the complementary spectra
                foreach (XTSpectrum complSpectrum in spectrum.Value)
                {
                    // Score the complementary spectrum
                    XTSpectrum scoredComplSpectrum = ScoreMatchMainCitComplArg(scoredSpectrum, complSpectrum);
                    scoredComplSpectrum.IsoCyanicLossMzMs2 = new double[0];
                    // Add the scored spectrum to the list
                    scoredComplSpectra.Add(scoredComplSpectrum);
                }


                // Sort the list
                var scoredCompSpectraSorted = from x in scoredComplSpectra
                                              orderby x.MatchScore descending
                                              select x;
                scoredComplSpectra = scoredCompSpectraSorted.ToList();

                // Add the main spectrum and the complementary spectra to the dictionary
                scoredSpectra.Add(scoredSpectrum, scoredComplSpectra);
            }

            var sortedScoredSpectra = (from x in scoredSpectra
                                       orderby x.Key.CitScore descending
                                       select x).ToDictionary(x => x.Key, x => x.Value);

            // Add spectra above cut-off if set to do so.
            if (ScoreSettings.IncludeCutOff)
            {
                // Add to quantification
                AddCitSpectraAboveCutoffToQuantification(sortedScoredSpectra);
            }

            // Return the sorted scored spectra
            return(sortedScoredSpectra);
        }
コード例 #19
0
        /// <summary>
        /// Add the spectrum to quantification.
        /// </summary>
        private void MetroButtonAddQuant_Click(object sender, EventArgs e)
        {
            // Get the spectra
            XTSpectrum spectrumCit = valKVP.Key;
            XTSpectrum spectrumArg = valKVP.Value[argIndex];

            // Add the spectrum to the dictionary
            Quantification.AddTokvpCitSpecSpecDict(spectrumCit, spectrumArg);
            // Update the quantification id list
            UpdateChosenForQuant(valKVP.Key.ID, true);
            // Prevent moving back and forth through the complementary spectra
            metroButtonNextArgScan.Enabled = false;
            metroButtonPrevArgScan.Enabled = false;
            // Enable and disable the button
            metroButtonAddQuant.Enabled    = false;
            metroButtonRemoveQuant.Enabled = true;
        }
コード例 #20
0
        /// <summary>
        /// Score the arginine spectra.
        /// </summary>
        /// <param name="inputSpectra">The dictionary with the arginine spectra to be scored and their complementary citrullinated spectra.</param>
        /// <returns>he dictionary with the scored spectra an their complementary citrullinated spectra.</returns>
        internal static Dictionary <XTSpectrum, List <RawScan> > ScoreArginineSpectra(Dictionary <XTSpectrum, List <RawScan> > inputSpectra)
        {
            // Create a temporary dictionary of scored spectra
            Dictionary <XTSpectrum, List <RawScan> > scoredSpectra = new Dictionary <XTSpectrum, List <RawScan> >();

            // Loop throguh all of the spectra keyvaluepairs
            foreach (KeyValuePair <XTSpectrum, List <RawScan> > spectrum in inputSpectra)
            {
                // Get the arginine spectrum and set the array of isocyanic loss m/z in order to prevent error
                XTSpectrum argSpectrum = spectrum.Key;
                argSpectrum.IsoCyanicLossMzMs2 = new double[0];
                List <RawScan> scoredCompCitScans = new List <RawScan>();
                // Loop trough all of the complementary cit spectra
                foreach (RawScan citScan in spectrum.Value)
                {
                    // Calculate the score
                    RawScan scoredScan = ScoreCitComplSpectrum(argSpectrum, citScan);
                    // Add the score to the list of cit scans
                    scoredCompCitScans.Add(scoredScan);
                }

                // Sort the list
                var scoredCompSpectraSorted = from x in scoredCompCitScans
                                              orderby x.MatchScore descending
                                              select x;
                scoredCompCitScans = scoredCompSpectraSorted.ToList();


                scoredSpectra.Add(argSpectrum, scoredCompCitScans);
            }

            // Sort dictionary
            var sortedScoredSpectra = (from x in scoredSpectra
                                       orderby x.Key.CitScore descending
                                       select x).ToDictionary(x => x.Key, x => x.Value);

            // Add spectra above cut-off if set to do so.
            if (ScoreSettings.IncludeCutOff)
            {
                // Add to quantification
                AddArgSpectraAboveCutOffToQuantification(sortedScoredSpectra);
            }
            // Return the sorted scored spectra
            return(sortedScoredSpectra);
        }
コード例 #21
0
        /// <summary>
        /// Add the next arginine MS1 series to the chart.
        /// </summary>
        /// <param name="scanMS2">The MS2 spectrum.</param>
        private void AddNextArgMS1Series(XTSpectrum scanMS2)
        {
            //Removes old series:
            chartArgMS1.Series.Remove(chartArgMS1.Series["Serie"]);
            //Add Data:
            chartArgMS1.Series.Add("Serie");
            chartArgMS1.Series["Serie"].ChartType          = SeriesChartType.StackedColumn;
            chartArgMS1.Series["Serie"].AxisLabel          = "m/z";
            chartArgMS1.Series["Serie"]["PixelPointWidth"] = "2";
            double[] mzVals  = scanMS2.ParentScan.MzValues;
            double[] intVals = scanMS2.ParentScan.Intencities;
            for (int i = 0; i <= mzVals.Length - 1; i++)
            {
                chartArgMS1.Series["Serie"].Points.AddXY(mzVals[i], intVals[i]);
            }
            chartArgMS1.Series["Serie"].ChartArea = "ChartArea";

            chartArgMS1.Legends.Clear();

            double tolerance         = 0.05;
            double ms2PrecursorMzVal = scanMS2.PreCursorMz;

            for (int i = 0; i <= chartArgMS1.Series["Serie"].Points.Count() - 1; i++)
            {
                double error = Math.Abs(chartArgMS1.Series["Serie"].Points[i].XValue - ms2PrecursorMzVal);
                if (error <= tolerance)
                {
                    chartArgMS1.Series["Serie"].Points[i].Color = Color.Blue;
                }
            }

            //Add X-Axis Maximum to chart:
            int xAxisMax = (int)Math.Ceiling(mzVals.Last() / 100) * 100;

            chartArgMS1.ChartAreas["ChartArea"].AxisX.Maximum = xAxisMax;

            //Make Custom Labels for X-Axis, interval 100:
            int endIndex = xAxisMax / 100;

            for (int i = 1; i <= endIndex; i++)
            {
                int index = i * 100;
                chartArgMS1.ChartAreas["ChartArea"].AxisX.CustomLabels.Add(index - 25, index + 25, string.Format("{0}", index), 2, LabelMarkStyle.None, GridTickTypes.TickMark);
            }
        }
コード例 #22
0
 /// <summary>
 /// Check what state the quantificaation buttons should be in.
 /// </summary>
 /// <param name="spec">The spectrum.</param>
 private void EnableQuantButtons(XTSpectrum spec)
 {
     // Check if the quantification list contains the spectrum.
     if (Validation.loneCitChosenForQuantList.Contains(spec.ID))
     {
         // If so, disable the add button
         metroButtonAddQuant.Enabled = false;
         // Enable the remove button
         metroButtonRemoveQuant.Enabled = true;
     }
     else
     {
         // If not, enable the add button
         metroButtonAddQuant.Enabled = true;
         // Disable the remove button
         metroButtonRemoveQuant.Enabled = false;
     }
 }
コード例 #23
0
 /// <summary>
 /// Calculate all of the ions in the spectrum.
 /// </summary>
 /// <param name="scanMS2">The MS2 spectrum.</param>
 /// <returns>The MS2 spectrum with the ion information.</returns>
 internal static XTSpectrum CalculateAllIons(XTSpectrum scanMS2)
 {
     // Calculate the spectrum ions
     scanMS2 = CalcSpecIons(scanMS2);
     // Get the domain range
     scanMS2 = GetDomainRange(scanMS2);
     // Get the correct modification index for the b-ions
     scanMS2 = GetCorrectBIonModificationIndex(scanMS2);
     // Get the correct modification index for the y-ions
     scanMS2 = GetCorrectYIonModificationIndex(scanMS2);
     // Find the possible b-ions
     scanMS2 = FindPossibleBIons(scanMS2);
     // Find the possible ytions
     scanMS2 = FindPossibleYIons(scanMS2);
     // Find the correct existing ions
     scanMS2 = FindExistingIons(scanMS2);
     return(scanMS2);
 }
コード例 #24
0
        /// <summary>
        /// Get the domain range.
        /// </summary>
        /// <param name="scanMS2">The spectrum.</param>
        /// <returns>The spectrum with domain ranges.</returns>
        internal static XTSpectrum GetDomainRange(XTSpectrum scanMS2)
        {
            // Get the domain start position
            int dStart = scanMS2.Proteins[0].DomainStartPos;
            // Get the domain end position
            int dEnd = scanMS2.Proteins[0].DomainEndPos;
            // Get the range length
            int rangeLength = dEnd - dStart + 1;

            // Get the domain range
            int[] domainRange = Enumerable.Range(scanMS2.Proteins[0].DomainStartPos, rangeLength).ToArray();
            // Get the reverse domain range
            int[] domainRangeReverse = domainRange.Reverse().ToArray();
            // Set the normal and reverse domain range to the spectrum
            scanMS2.SpectrumDomainRange        = domainRange;
            scanMS2.SpectrumDomainRangeReverse = domainRangeReverse;
            // Return the scan.
            return(scanMS2);
        }
コード例 #25
0
        /// <summary>
        /// Get the quantified complementary arginine spectrum index.
        /// </summary>
        /// <param name="citMainSpectrum">The quantified main citrullination spectrum.</param>
        /// <param name="complArgSpectra">The list of complementary arginine spectra.</param>
        /// <returns>The index of the quantified complementary spectra in <paramref name="complArgSpectra"/>.</returns>
        internal static int GetQuantifiedComplementaryArgSpectrumId(XTSpectrum citMainSpectrum, List <XTSpectrum> complArgSpectra)
        {
            // Get the ID of the complementary cit spectrum
            if (citSpecSpecDict.TryGetValue(citMainSpectrum, out XTSpectrum complSpectrum))
            {
                // Get the compl spectrum ID
                int spectrumId = complSpectrum.ID;

                for (int i = 0; i < complArgSpectra.Count - 1; i++)
                {
                    if (complArgSpectra[i].ID == spectrumId)
                    {
                        return(i);
                    }
                }
            }
            // If no spectra is found, return 0
            return(0);
        }
コード例 #26
0
        /// <summary>
        /// Get the quantified complementary citrullinated spectrum index.
        /// </summary>
        /// <param name="argMainSpectrum">The quantified main arginine spectrum.</param>
        /// <param name="complCitSpectra">The list of complementary arginine scans.</param>
        /// <returns>The index of the quantified complementary spectra in <paramref name="complCitSpectra"/>.</returns>
        internal static int GetQuantifiedComplementaryCitSpectrumIndex(XTSpectrum argMainSpectrum, List <RawScan> complCitSpectra)
        {
            // Get the ID of the complementary cit spectrum
            if (argSpecScanDict.TryGetValue(argMainSpectrum, out RawScan complSpectrum))
            {
                // Get the compl spectrum ID
                int spectrumId = complSpectrum.ScanNumber;

                for (int i = 0; i < complCitSpectra.Count - 1; i++)
                {
                    if (complCitSpectra[i].ScanNumber == spectrumId)
                    {
                        return(i);
                    }
                }
            }

            // If no spectra is found, return 0
            return(0);
        }
コード例 #27
0
ファイル: FindMS1.cs プロジェクト: Citrullia-SDU/Citrullia
        /// <summary>
        /// Handle orphan spectra.
        /// </summary>
        /// <param name="spectrumMS2">The MS2 spectrum.</param>
        /// <returns>The MS2 spectrum with a "false" parent.</returns>
        internal static XTSpectrum HandleOrphanSpecs(XTSpectrum spectrumMS2)
        {
            // Create an array of MZ-values
            double[] valMZ = { 100, 300, 500, 700, 900, 1100, 1300, spectrumMS2.PreCursorMz };
            // Create an array of intensities
            double[] valInt = { 30, 50, 100, 70, 40, 10, 20, 60 };
            // Create a parent scan
            var scanParent = new RawScan {
                MzValues = valMZ, RetentionTime = 0, Intencities = valInt, TotalIonCount = 0
            };

            // If the spectrum is an orphan set the newly created scan to be the parent
            if (spectrumMS2.Orphan == true)
            {
                spectrumMS2.ParentScan = scanParent;
            }

            // The spectrum with a parent
            return(spectrumMS2);
        }
コード例 #28
0
 /// <summary>
 /// Check what state the quantificaation buttons should be in.
 /// </summary>
 /// <param name="spec">The spectrum.</param>
 private void EnableQuantButtons(XTSpectrum spec)
 {
     // Check if the quantification list contains the spectrum.
     if (Validation.argChosenForQuantList.Contains(spec.ID))
     {
         // If so, disable the add button
         metroButtonAddQuant.Enabled = false;
         // Enable the remove button
         metroButtonRemoveQuant.Enabled = true;
         // Prevent moving back and forth through the complementary spectra
         metroButtonNextPotCitScan.Enabled = false;
         metroButtonPrevPotCitScan.Enabled = false;
     }
     else
     {
         // If not, enable the add button
         metroButtonAddQuant.Enabled = true;
         // Disable the remove button
         metroButtonRemoveQuant.Enabled = false;
     }
 }
コード例 #29
0
        /// <summary>
        /// Get the correct modification index for the y-ions.
        /// </summary>
        /// <param name="scanMS2">The spectrum.</param>
        /// <returns>The spectrum with the new information</returns>
        internal static XTSpectrum GetCorrectYIonModificationIndex(XTSpectrum scanMS2)
        {
            // Create a new temporary list of modification indexes and their mass change
            Dictionary <int, double> modDictY = new Dictionary <int, double>();

            // Loop through all of the modifications
            foreach (XTModification mod in scanMS2.Proteins[0].Modifications)
            {
                // Get the modification position and mass
                int    pos        = mod.AtPosition;
                double massChange = mod.MassChange;
                // Get the index of the position in the reverse domain range
                int index = Array.IndexOf(scanMS2.SpectrumDomainRangeReverse, pos);
                // Check if the modification index already contains the index
                if (modDictY.ContainsKey(index))
                {
                    // If so.
                    // Get the old modification mass
                    modDictY.TryGetValue(index, out double oldMod);
                    // Add the old modification mass and the mass change
                    massChange = oldMod + massChange;
                    // Remove the old modification
                    modDictY.Remove(index);
                    // And add the new index with the new mass change
                    modDictY.Add(index, massChange);
                }
                else
                {
                    // If no index already, add the mass charge.
                    modDictY.Add(index, massChange);
                }
            }
            // Set the dictionary to the spectrum.
            scanMS2.SpectrumYIonModDict = modDictY;
            // Return the spectrum
            return(scanMS2);
        }
コード例 #30
0
 private static XTSpectrum ReturnSpec(XTSpectrum spec)
 {
     valSpec = spec;
     return(valSpec);
 }