Ejemplo n.º 1
0
        public void TestMods()
        {
            PsmCross PSM = new PsmCross();

            PSM.BaseSequence           = "DMHGDSEYNIMFGPDICGPGTK";
            PSM.FullSequence           = "DM[Common Variable:Oxidation of M]HGDSEYNIM[Common Variable:Oxidation of M]FGPDIC[Common Fixed:Carbamidomethyl of C]GPGTK";
            PSM.PeptideMonisotopicMass = 2472.0032;

            var mods = TsvResultReader.GetMods(PSM);

            Dictionary <int, ModificationWithMass> allModsOneIsNterminus = new Dictionary <int, ModificationWithMass>();

            foreach (var item in mods)
            {
                ModificationMotif.TryGetMotif(item.Value, out ModificationMotif modificationMotif);

                ModificationWithMass mod = new ModificationWithMass("mod", null, modificationMotif, TerminusLocalization.Any, 10);

                allModsOneIsNterminus.Add(item.Key, mod);
            }

            PepWithSetModForCompactPep pepWithSetModForCompactPep = new PepWithSetModForCompactPep();

            pepWithSetModForCompactPep.allModsOneIsNterminus = allModsOneIsNterminus;
            pepWithSetModForCompactPep.BaseSequence          = PSM.BaseSequence;
            pepWithSetModForCompactPep.Length           = PSM.BaseSequence.Length;
            pepWithSetModForCompactPep.MonoisotopicMass = (double)PSM.PeptideMonisotopicMass;

            var compactPeptide = new CompactPeptide(pepWithSetModForCompactPep, TerminusType.None);

            PSM.CompactPeptide = compactPeptide;

            var lp = new List <ProductType> {
                ProductType.BnoB1ions, ProductType.Y
            };
            Tolerance productMassTolerance = new PpmTolerance(10);

            var pmm = PsmCross.XlCalculateTotalProductMassesForSingle(PSM, lp, false);

            var matchedIonMassesListPositiveIsMatch = new MatchedIonInfo(pmm.ProductMz.Length);
            //double pmmScore = PsmCross.XlMatchIons(theScan.TheScan, productMassTolerance, pmm.ProductMz, pmm.ProductName, matchedIonMassesListPositiveIsMatch);
        }
Ejemplo n.º 2
0
        public static List <PsmCross> ReadTsv(string filePath)
        {
            List <PsmCross> PSMs = new List <PsmCross>();

            Dictionary <string, int> ids = new Dictionary <string, int>();

            //Empty array. Is this correct?
            string[][] resultArray = new string[][] { };
            try
            {
                resultArray = File.ReadLines(filePath).Select(p => p.Split('\t')).ToArray();
            }
            catch (Exception)
            {
                MessageBox.Show("Please check the file.");
                return(null);
            }


            for (int i = 0; i < resultArray[0].Length; i++)
            {
                ids.Add(resultArray[0][i], i);
            }

            for (int i = 1; i < resultArray.Length; i++)
            {
                PsmCross PSM = new PsmCross();
                PSM.ScanNumber = Convert.ToInt32(resultArray[i][ids["Scan Number"]]);
                var baseSeq     = resultArray[i][ids["Base Sequence"]];
                var chargeState = resultArray[i][ids["Precursor Charge"]];
                var fullSeq     = resultArray[i][ids["Full Sequence"]];
                if (baseSeq.Contains("|"))
                {
                    baseSeq = baseSeq.Split('|').First();
                    fullSeq = fullSeq.Split('|').First();
                }
                PSM.BaseSequence           = baseSeq;
                PSM.ScanPrecursorCharge    = Convert.ToInt32(chargeState);
                PSM.FullSequence           = fullSeq;
                PSM.IsDecoy                = (resultArray[i][ids["Decoy"]] == "N" ? false :true);
                PSM.PeptideMonisotopicMass = Convert.ToDouble(resultArray[i][ids["Precursor Mass"]]);

                var mods = GetMods(PSM);

                Dictionary <int, ModificationWithMass> allModsOneIsNterminus = new Dictionary <int, ModificationWithMass>();

                foreach (var item in mods)
                {
                    //I don't really know why use as here.
                    var theMod = GlobalVariables.AllModsKnown.Where(p => p.id == item.Value).First() as ModificationWithMass;

                    allModsOneIsNterminus.Add(item.Key, theMod);
                }

                PepWithSetModForCompactPep pepWithSetModForCompactPep = new PepWithSetModForCompactPep();
                pepWithSetModForCompactPep.allModsOneIsNterminus = allModsOneIsNterminus;
                pepWithSetModForCompactPep.BaseSequence          = PSM.BaseSequence;
                pepWithSetModForCompactPep.Length           = PSM.BaseSequence.Length;
                pepWithSetModForCompactPep.MonoisotopicMass = (double)PSM.PeptideMonisotopicMass;

                var compactPeptide = new CompactPeptide(pepWithSetModForCompactPep, TerminusType.None);

                PSM.CompactPeptide = compactPeptide;
                PSMs.Add(PSM);
            }

            return(PSMs);
        }