Beispiel #1
0
        public static void DumpTotalTime(ExecutionTimeDto time)
        {
            Application xlApp = new Application();

            if (xlApp == null)
            {
                return;
            }

            string      excelFile = _directory + "\\Times.xls";
            Application oXL;
            _Workbook   oWB;
            _Worksheet  oSheet;
            Range       oRng;
            object      misvalue = System.Reflection.Missing.Value;

            try
            {
                //Start Excel and get Application object.
                oXL = new Microsoft.Office.Interop.Excel.Application();
                //oXL.Visible = true;

                //Get a new workbook.
                oWB    = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(""));
                oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;

                //Add table headers going cell by cell.
                oSheet.Cells[1, 1] = "TotalTime";
                oSheet.Cells[1, 2] = "FileReadingTime";
                oSheet.Cells[1, 3] = "InsilicoTime";
                oSheet.Cells[1, 4] = "MwFilterTime";
                oSheet.Cells[1, 5] = "PstTime";
                oSheet.Cells[1, 6] = "PtmTime";
                oSheet.Cells[1, 7] = "TunerTime";


                oSheet.Cells[2, 1] = time.TotalTime;
                oSheet.Cells[2, 2] = time.FileReadingTime;
                oSheet.Cells[2, 3] = time.InsilicoTime;
                oSheet.Cells[2, 4] = time.MwFilterTime;
                oSheet.Cells[2, 5] = time.PstTime;
                oSheet.Cells[2, 6] = time.PtmTime;
                oSheet.Cells[2, 7] = time.TunerTime;



                oXL.Visible     = false;
                oXL.UserControl = false;
                oWB.SaveAs(excelFile, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault,
                           Type.Missing, Type.Missing,
                           false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
                           Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

                oWB.Close();
            }
            catch (Exception)
            {
            }
            //...
        }
Beispiel #2
0
        //PST: Peptide Sequence Tags
        private void ExecuteDenovoModule(SearchParametersDto parameters, MsPeaksDto massSpectrometryData, List <ProteinDto> candidateProteins,
                                         ExecutionTimeDto executionTimes)
        {
            Stopwatch moduleTimer = Stopwatch.StartNew();

            var pstTags = _pstGenerator.GeneratePeptideSequenceTags(parameters, massSpectrometryData);

            //Logging.DumpPstTags(pstTags);

            if (candidateProteins.Count > 0)
            {
                _pstFilter.ScoreProteinsByPst(pstTags, candidateProteins);
            }

            //Logging.DumpPstScores(candidateProteins);
            pstTags.Clear();
            moduleTimer.Stop();
            executionTimes.PstTime = moduleTimer.Elapsed.ToString();
        }
Beispiel #3
0
        //Peak List: Extracting from data file
        private MsPeaksDto PeakListFileReaderModuleModule(SearchParametersDto parameters, int fileNumber, ExecutionTimeDto executionTimes)
        {
            var moduleTimer = new Stopwatch();

            moduleTimer.Start();
            var peakData = _peakListFileReader.PeakListReader(parameters, fileNumber);

            double maxIntensity = peakData.Intensity.Max();

            //DEL ME////Discuss it with Sir. Because during first time reading file I am protonating (FOR MASSES) & normalizing intensities .. #DISCUSSION1(This discussion is Necessary)
            //DEL ME//Yehi data hr jagha use hona ha to ... humma hr jgha m/z or nomralized intensities he chahya...??? ---#Compare kr lo with SPECTRUM---
            ////*************m/z & normalizing for MS2*************////
            ////After reading peaks(Masses & Intensities) from data file. We converted "*"MS2"*" Masses(monoisotopic masses) into m/z.
            //Formula of m/z: m/z = (M+z)/z  where M is the monoisotopic mass & z is the mass of proton.
            //// Maximum Intensity selected from the peak data file & Intensities of "*"MS2"*" are normalized by dividing the selected maximum intensity
            for (int peakDataindex = 1; peakDataindex <= peakData.Mass.Count - 1; peakDataindex++)    //Loop will run only for MS2 so that why its starting from "1".
            {
                peakData.Mass[peakDataindex]      = peakData.Mass[peakDataindex] + 1.00727647;        //monoisotopic to m/z value
                peakData.Intensity[peakDataindex] = peakData.Intensity[peakDataindex] / maxIntensity; //Normalized by dividing the selected maximum intensity
            }

            moduleTimer.Stop();
            executionTimes.FileReadingTime = moduleTimer.Elapsed.ToString();
            return(peakData);
        }
Beispiel #4
0
        //Mass Tunner
        private void ExecuteMassTunerModule(SearchParametersDto parameters, MsPeaksDto peakData, ExecutionTimeDto executionTimes)
        {
            Stopwatch moduleTimer = Stopwatch.StartNew();

            if (parameters.Autotune == 1)
            {
                //double a = parameters.NeutralLoss;
                _wholeProteinMassTuner.TuneWholeProteinMass(peakData, parameters.MwTolerance);
            }
            moduleTimer.Stop();
            executionTimes.TunerTime = moduleTimer.Elapsed.ToString();
        }
Beispiel #5
0
        private List <ProteinDto> ExecutePostTranslationalModificationsModule(SearchParametersDto parameters, List <ProteinDto> candidateProteins,
                                                                              MsPeaksDto massSpectrometryData, ExecutionTimeDto executionTimes)
        {
            Stopwatch         moduleTimer = Stopwatch.StartNew();
            List <ProteinDto> proteoformsList;

            if (parameters.PtmAllow == 1)
            {
                proteoformsList = _postTranslationalModificationModule.ExecutePtmModule(candidateProteins,
                                                                                        massSpectrometryData, parameters);

                _insilicoFilter.ComputeInsilicoScore(proteoformsList, massSpectrometryData.Mass, parameters.HopThreshhold);

                _molecularWeightModule.FilterModifiedProteinsByWholeProteinMass(parameters, proteoformsList,
                                                                                massSpectrometryData);
            }

            else
            {
                proteoformsList = candidateProteins;
                foreach (var protein in proteoformsList)
                {
                    protein.PtmParticulars = new List <PostTranslationModificationsSiteDto>();
                }
            }

            moduleTimer.Stop();
            executionTimes.PtmTime = moduleTimer.Elapsed.ToString();
            return(proteoformsList);
        }
Beispiel #6
0
        //SPECTRAL COMPARISON ALGORITHM:
        private void ExecuteSpectralComparisonModule(SearchParametersDto parameters, List <ProteinDto> candidateProteins,
                                                     MsPeaksDto massSpectrometryData, ExecutionTimeDto executionTimes)
        {
            Stopwatch moduleTimer = Stopwatch.StartNew();

            /////Starting From Here !!!!

            _insilicoFragmentsAdjustment.adjustForFragmentTypeAndSpecialIons(candidateProteins, parameters.InsilicoFragType, parameters.HandleIons);



            ////
            //if (parameters.PtmAllow == 0) // (parameters.PtmAllow == 0)
            //    _insilicoFragmentsAdjustment.adjustForFragmentTypeAndSpecialIons(candidateProteins, parameters.InsilicoFragType,
            //        parameters.HandleIons);

            ////"Module 7 of 9:  Insilico Filteration.";                                  //FARHAN
            //if (true)   // (parameters.PtmAllow == 0)
            //    _insilicoFilter.ComputeInsilicoScore(candidateProteins, massSpectrometryData.Mass, parameters.HopThreshhold);

            moduleTimer.Stop();
            executionTimes.InsilicoTime = moduleTimer.Elapsed.ToString();
        }
Beispiel #7
0
        private void StoreSearchResults(SearchParametersDto parameters, List <ProteinDto> candidateProteins, ExecutionTimeDto executionTimes,
                                        int fileNumber)
        {
            if (candidateProteins.Count > Constants.NumberOfResultsToStore)
            {
                candidateProteins = candidateProteins.Take(Constants.NumberOfResultsToStore).ToList <ProteinDto>();
            }

            var final = new SearchResultsDto(parameters.Queryid, candidateProteins, executionTimes);

            _dataLayer.StoreResults(final, parameters.PeakListFileName[fileNumber], fileNumber);
        }
Beispiel #8
0
        private void PerformSearch(SearchParametersDto parameters)
        {
            //Logging.CreateDirectory();
            //Logging.DumpParameters(parameters);

            //var counter = 0;
            var numberOfPeaklistFiles = parameters.PeakListFileName.Length;  //Number of files uploaded by user

            for (var fileNumber = 0; fileNumber < numberOfPeaklistFiles; fileNumber++)
            {
                //Logging.CreatePeakFileDirectory(fileNumber);

                try
                {
                    var executionTimes = new ExecutionTimeDto();
                    var pipeLineTimer  = new Stopwatch();
                    pipeLineTimer.Start();

                    //Step 0 - Read the Peaklist File
                    var massSpectrometryData = PeakListFileReaderModuleModule(parameters, fileNumber, executionTimes);
                    //  Logging.DumpMsData(massSpectrometryData);


                    //Step 1 - 1st Algorithm - Mass Tuner
                    var old = massSpectrometryData.WholeProteinMolecularWeight;
                    ExecuteMassTunerModule(parameters, massSpectrometryData, executionTimes);
                    if (massSpectrometryData.WholeProteinMolecularWeight == 0)
                    {
                        massSpectrometryData.WholeProteinMolecularWeight = old;
                    }
                    //Logging.DumpMwTunerResult(massSpectrometryData);


                    //Step 2 - 1st Candidate Protein List  --- (In SPECTRUM: Score_Mol_Weight)
                    var    candidateProteins = GetCandidateProtein(parameters, massSpectrometryData);
                    double mass, error, mw_score;
                    for (var i = 0; i < candidateProteins.Count; ++i)
                    {
                        mass  = candidateProteins[i].Mw;
                        error = Math.Abs(mass - massSpectrometryData.WholeProteinMolecularWeight);
                        if (error == 0)
                        {
                            mw_score = 1;
                        }
                        else
                        {
                            mw_score = 1 / (Math.Pow(2, error));
                        }
                        candidateProteins[i].MwScore = mw_score;
                    }
                    //Logging.DumpCandidateProteins(candidateProteins);



                    //Step 3 - 2nd Algorithm - Peptide Sequence Tags (PSTs)
                    if (parameters.DenovoAllow == 1)
                    {
                        ExecuteDenovoModule(parameters, massSpectrometryData, candidateProteins, executionTimes);
                    }
                    var    t = 0;
                    double score = 0;
                    string lol;
                    //Logging.DumpModifiedProteins(candidateProteins);



                    //Step X - ??? Algorithm - Post Translational Modifications (PTMs)    {{*****FARHAN!!! FOR THE TIME BEING ITS PTM IS AFTER INSILICO COMPARISON*****}}
                    //string candidateProteins = "xyz";
                    candidateProteins = ExecutePostTranslationalModificationsModule(parameters, candidateProteins, massSpectrometryData, executionTimes);
                    for (var i = 0; i < candidateProteins.Count; ++i)
                    {
                        if (candidateProteins[i].PstScore > score)
                        {
                            score = candidateProteins[i].PstScore;
                            lol   = candidateProteins[i].Header;
                            t     = i;
                        }
                    }



                    //Step 4 - ??? Algorithm - Spectral Comparison
                    ExecuteSpectralComparisonModule(parameters, candidateProteins, massSpectrometryData, executionTimes);

                    //Logging.DumpInsilicoScores(candidateProteins);
                    score = 0;
                    for (var i = 0; i < candidateProteins.Count; ++i)
                    {
                        if (candidateProteins[i].PstScore + candidateProteins[i].MwScore + candidateProteins[i].PtmScore > score)
                        {
                            score = candidateProteins[i].PstScore + candidateProteins[i].MwScore + candidateProteins[i].PtmScore;
                            lol   = candidateProteins[i].Header;
                            t     = i;
                        }
                    }



                    candidateProteins = ExecuteProteoformScoringModule(parameters, candidateProteins);
                    //Logging.DumpTotalScores(candidateProteins);



                    pipeLineTimer.Stop();
                    executionTimes.TotalTime = pipeLineTimer.Elapsed.ToString();
                    StoreSearchResults(parameters, candidateProteins, executionTimes, fileNumber);
                }
                catch (Exception r)
                {
                    string k = r.Message;
                    System.Diagnostics.Debug.WriteLine(r.Message);
                }

                //Logging.DumpTotalTime(executionTimes);
                //Logging.ExitPeakFileDirectory();
            }

            Send_Results_Link(parameters);
            _dataLayer.Set_Progress(parameters.Queryid, 100);
        }