Пример #1
0
        public List <PstTagList> GeneratePeptideSequenceTags(SearchParametersDto parameters, MsPeaksDto peakData)
        {
            //Converting Peak List Data into 2D List
            var peakDatalist = new List <peakData2Dlist>();  //Making a 2D list(peakDatalist) in which Mass & Intensity includes {{FARHAN!! ITS NOT AN EFFICIENT WAY}} NOt NEEDED THIS IF ONCE MsPeaksDto.cs is modified

            for (int row = 0; row <= peakData.Mass.Count - 1; row++)
            {
                var dataforpeakDatalist = new peakData2Dlist(peakData.Mass[row], peakData.Intensity[row]);
                peakDatalist.Add(dataforpeakDatalist);
            }
            var peakDatalistsort = peakDatalist.OrderBy(n => n.Mass).ToArray();

            double[] MassPeakData      = peakDatalistsort.Select(n => n.Mass).ToArray();
            double[] IntensityPeakData = peakDatalistsort.Select(n => n.Intensity).ToArray();
            var      pstList           = new List <NewPstTagsDtoGpu>();

            GeneratePstGpu(MassPeakData, pstList, parameters.HopThreshhold, IntensityPeakData);
            //if (IsFilterPstByLength(parameters))
            //    pstList = pstList.Where(t => t.AminoAcidTag.Length >= parameters.MinimumPstLength && t.AminoAcidTag.Length <= parameters.MaximumPstLength).ToList();

            //FilterTagsWithMultipleOccurences(pstList);


            ////////////var PstTagListGpu = AccomodateIsoforms(pstList, parameters);
            //AccomodateIsoforms(pstList);


            //return pstList;
            var pstList2 = new List <PstTagList>();

            return(pstList2);
        }
Пример #2
0
        // Extracts a list Peptide Sequence Tags from the MS/MS peaklist
        public List <PstTagList> GeneratePeptideSequenceTags(SearchParametersDto parameters, MsPeaksDto peakData)
        {
            List <PstTagList> PstTagCPU = new List <PstTagList>();
            //////// ************* FARHAN!!! WHAT IF THERE WILL BE NO PST TAGS FOUND THEN, WHAT COULD HAPPENED...?????
            //////// ************* FARHAN!!! WHAT IF THERE WILL BE NO PST TAGS FOUND THEN, WHAT COULD HAPPENED...?????
            //////// ************* FARHAN!!! WHAT IF THERE WILL BE NO PST TAGS FOUND THEN, WHAT COULD HAPPENED...?????

            //Making a 2D list(peakDatalist) in which Mass & Intensity includes
            var peakDatalist = new List <peakData2Dlist>();

            for (int row = 0; row <= peakData.Mass.Count - 1; row++)
            {
                var dataforpeakDatalist = new peakData2Dlist(peakData.Mass[row], peakData.Intensity[row]);
                peakDatalist.Add(dataforpeakDatalist);
            }
            //Sort the peakDatalist with respect to the Mass in ascending order
            var peakDatalistsort = peakDatalist.OrderBy(n => n.Mass).ToList();

            var singleLengthPstTagList = GenerateSingleLengthPstList(parameters, peakDatalistsort);         // This method will extract Single Length PST Tags
            var multipleLenghtTagList  = GenerateMultipleLenghtPstList(parameters, singleLengthPstTagList); // This method will extract Multiple Length PST Tags

            //var pstTagsdata = multipleLenghtTagList; // Multiple Tags
            //////// ************* FARHAN!!! WHAT IF THERE WILL BE NO PST TAGS FOUND THEN, WHAT COULD HAPPENED...?????
            if (multipleLenghtTagList.Count != 0)                                                                                  // Here filtering out tags according to MIN & MAX threshold of PST lengths...
            {
                List <List <PstTagsDto> > TrimPstTagsList = PSTCpuGpuCombineMethod.TrimPstTags(multipleLenghtTagList, parameters); // Break the larger Tags into all possible smaller tags &&& Filtering the Tags according to Minimum-Maximum Range Length of PST
                var FinalPstTagList = PSTCpuGpuCombineMethod.PstTagInfoList(TrimPstTagsList, parameters);                          //Calculating  PST Tag Error, PST intensity, & Root Mean Square Error etc. && Finding the Unique PSTs: Remove all other redundant PSTs but keep only one having lowest Root Mean Square Error(RMSE)
                //If 2 or more Tags are same then also keep just one

                if (FinalPstTagList.Count != 0)
                {
                    //var AccoFinalPstTagList = AccomodateIsoforms(FinalPstTagList, parameters); // Its Accomodated Isoforms also, considered...  COMMENT ME MORE

                    List <PstTagList> PstTags = PSTCpuGpuCombineMethod.AccomodateIsoforms(FinalPstTagList, parameters);

                    PstTagCPU = PstTags;
                }
            }
            return(PstTagCPU);
        }
        public void TuneWholeProteinMass(MsPeaksDto peakData, double molTolerance)
        {   //Making a 2D list(peakDatalist) in which Mass & Intensity includes 
            var peakDatalist = new List<peakData2Dlist>();
            for (int row = 0; row <= peakData.Mass.Count - 1; row++)
            {
                var dataforpeakDatalist = new peakData2Dlist(peakData.Mass[row], peakData.Intensity[row]);
                peakDatalist.Add(dataforpeakDatalist);
                
            }
            //Sort the peakDatalist with respect to the Mass in ascending order
            var peakDatalistsort = peakDatalist.OrderBy(n => n.Mass).ToList();

            //FIGURE 5: STEP 2:::: SUMMATIONS FOR EACH M/Z I,J IN MS2 DATA [REF: SPCTRUM PAPER]
            //Description::: Calculate Peak Sums and shortlist those falling within user specified tolerance.
            
            var summationMassandaverageintensity = new List<peakData2Dlist>();
            for (int i = 0; i <= peakDatalistsort.Count - 2; i++) //i starts from 0 so that's why "peakDatalistsort.Count - 1" and according to Formula "n-1" gives peakDatalistsort.Count - 2
            {
                for (int j = i + 1; j <= peakDatalistsort.Count - 1; j++)//j starts from 0 so that's why peakDatalistsort.Count - 1 and according to Formula just "n"
                {
                    double cpusummationMassData = peakDatalistsort[i].Mass + peakDatalistsort[j].Mass; //Making Tuple sums of MS2 masses
                    if (peakData.WholeProteinMolecularWeight - molTolerance <= cpusummationMassData && cpusummationMassData <= peakData.WholeProteinMolecularWeight + molTolerance)//Masses & Intensities filter out due to the selected RANGE OF INTACT MASS +/- PROTEIN MASS TOLERANCE
                    {
                        double cpuaverageIntensityData = (peakDatalistsort[i].Intensity + peakDatalistsort[j].Intensity) / 2;
                        var dataforsummationMassandaverageintensity = new peakData2Dlist(cpusummationMassData, cpuaverageIntensityData);
                        summationMassandaverageintensity.Add(dataforsummationMassandaverageintensity); //Making 2D list for Mass & Intensity
                    }
                }
            }
           
            //FIGURE 5: STEP 3 Running window have size of Proton (and starts from smallest mass of FIGURE 5: STEP 2 list) [REF: SPCTRUM PAPER]
            double windowposition = summationMassandaverageintensity[0].Mass; //Smallest mass selected from Tuple Sums for creating a window positon
            const double proton = 1.00727647; //Mass of proton

            var windowcapturedelementsold = new List<peakData2Dlist>();
            var oldindex = new List<int>();   //CHANGE MY NAME...
            var count = new List<int>();   //CHANGE MY NAME...
            double olddiff = 1, newdiff = 0;
            //Add here SliderValue(BELOW)
            double SliderValue = 0.5699;  //HARD CODE NOW FOR WORKING WILL ADD THIS FEATURE INTO THE FRONTEND FOR USER DEFINED   #FutureWork3b(CPU)

            int summationMassandaverageintensityindex = summationMassandaverageintensity.Count - 1;
            while (windowposition < summationMassandaverageintensity[summationMassandaverageintensityindex].Mass)
            {
                var newindex = new List<int>();   //CHANGE MY NAME...
                var windowcapturedelementsnew = new List<peakData2Dlist>();
                for (int i = 0; i <= summationMassandaverageintensityindex; i++)
                {
                    if (windowposition <= summationMassandaverageintensity[i].Mass && summationMassandaverageintensity[i].Mass < windowposition + proton)//#DISCUSSION
                    {
                        var dataforwindowcapturedelementsnew = new peakData2Dlist(summationMassandaverageintensity[i].Mass, summationMassandaverageintensity[i].Intensity);
                        windowcapturedelementsnew.Add(dataforwindowcapturedelementsnew);
                        newindex.Add(i);
                    }
                    else if (summationMassandaverageintensity[i].Mass >= windowposition + proton)
                    {
                        break;
                    }
                }
                count.Add(windowcapturedelementsnew.Count);
                int a = oldindex.Count;//count.Count;///DEL ME AFTER TESTING!!! :)
                if (windowcapturedelementsnew.Count > windowcapturedelementsold.Count)
                {
                    windowcapturedelementsold = windowcapturedelementsnew;
                    oldindex = newindex;
                }
                else if (windowcapturedelementsnew.Count == windowcapturedelementsold.Count)
                {
                    olddiff = Math.Abs((windowcapturedelementsold[windowcapturedelementsold.Count - 1].Mass) - peakData.WholeProteinMolecularWeight);
                    newdiff = Math.Abs((windowcapturedelementsnew[windowcapturedelementsnew.Count -1].Mass) - peakData.WholeProteinMolecularWeight);

                    if (olddiff >= newdiff)
                    {
                        windowcapturedelementsold = windowcapturedelementsnew;
                        oldindex = newindex;
                    }
                }
                windowposition = windowposition + SliderValue;
                
            }

            //FIGURE 5: STEP 5:::: Applying formula [REF: SPCTRUM PAPER]
            double[] dataforsumoftunedmassesandintensities = new double[windowcapturedelementsold.Count];//Its tunedmassnominator according to SPECTRUM's formula for TunedMass

            double sumoftunedmassesandintensities = 0;
            double sumoftunedintensities = 0;

            for (int i = 0; i <= windowcapturedelementsold.Count - 1; i++)
            {
                dataforsumoftunedmassesandintensities[i] = windowcapturedelementsold[i].Mass * windowcapturedelementsold[i].Intensity;

                sumoftunedmassesandintensities = sumoftunedmassesandintensities + dataforsumoftunedmassesandintensities[i];
                //Actually, ""intensities are not tuned"" (there isn't any terminology in OUR Mass Tuner Algorithm) according to the algorithm but just for the sake of UNDERSTANDING variable names are "dataforsumoftunedintensities" & "sumoftunedintensities".
                sumoftunedintensities = sumoftunedintensities + windowcapturedelementsold[i].Intensity;//Its tunedmassdenominator according to SPECTRUM's formula for TunedMass
            }
            peakData.WholeProteinMolecularWeight = sumoftunedmassesandintensities / sumoftunedintensities;// NOW, Tuned Mass will be consider as Intact Mass(WholeProteinMolecularWeight)
        }