Example #1
0
        private static void PostExperimentProcessing(Experiment e)
        {
            //WriterClass.writeln(exclusionProfile.ReportFailedCometSearchStatistics());
            WriterClass.Flush();

            if (GlobalVar.IsSimulation)
            {
                ProteinProphetResult ppr;
                if (GlobalVar.isSimulationForFeatureExtraction)
                {
                    ppr = ProteinProphetEvaluator.getProteinProphetResult(InputFileOrganizer.OriginalProtXMLFile);
                }
                else
                {
                    String proteinProphetResultFileName = e.experimentNumber + GlobalVar.experimentName;
                    ppr = PostProcessingScripts.postProcessing(e.exclusionProfile, proteinProphetResultFileName, true);
                }
                e.totalRunTime = getCurrentTime() - e.experimentStartTime;
                String result = e.exclusionProfile.getPerformanceVector(e.experimentName, e.exclusionProfile.getAnalysisType().getDescription()
                                                                        , e.analysisTime, e.totalRunTime, ppr, 12, e.exclusionProfile);
                Console.WriteLine(result);
                Console.WriteLine("Protein groups: " + ppr.getFilteredProteinGroups().Count);
                WriterClass.writeln(result);
                //WriterClass.writeln("Protein groups: "+ ppr.getFilteredProteinGroups().Count) ;
                e.ppr = ppr;
            }
            else
            {
                WriterClass.writeln(e.exclusionProfile.GetPerformanceEvaluator().outputPerformance());
            }
        }
Example #2
0
        protected bool processMS2(Spectra spec)
        {
            performanceEvaluator.countMS2();
            log.Debug(spec);
            IDs id = performDatabaseSearch(spec);

            Boolean isExcluded = false;

            if (id != null)
            {
                Peptide pep = getPeptideFromIdentification(id);
                isExcluded = exclusionList.containsPeptide(pep);
            }
            if (isExcluded)
            {
#if SIMULATION
                //log.Debug("Mass " + spectraMass + " is on the exclusion list. Scan " + spec.getScanNum() + " excluded.");
                evaluateExclusion(id);
                WriterClass.LogScanTime("Excluded", (int)spec.getIndex());
#endif
                performanceEvaluator.countExcludedSpectra();
                excludedSpectra.Add(spec.getScanNum());
                return(false);
            }
            else
            {
                performanceEvaluator.countAnalyzedSpectra();
                //log.Debug("Mass " + spectraMass + " was not on the exclusion list. Scan " + spec.getScanNum() + " analyzed.");
                evaluateIdentification(id);
                includedSpectra.Add(spec.getScanNum());
                // calibrate peptide if the observed retention time doesn't match the predicted
                //WriterClass.LogScanTime("Processed", (int)spec.getIndex());
                return(true);
            }
        }
Example #3
0
        private static void OutputCrossedHeaderNames(List <String> crs)
        {
            String header         = String.Join("\t", crs);
            String outputFileName = "CrossedHeaderName.txt";

            WriterClass.QuickWrite(header, outputFileName);
            return;
        }
        public static void CometSingleSearchTest()
        {
            String idx = "C:\\Coding\\2019LavalleeLab\\GitProjectRealTimeMS\\TestData\\PreComputedFiles\\uniprot_SwissProt_Human_1_11_2017_decoyConcacenated.fasta.idx";
            //String idx = "C:\\temp\\comet_2019015\\comet_source_2019015\\IDXMake\\uniprot_SwissProt_Human_1_11_2017_decoyConcacenated.fasta.idx";
            String param = "C:\\Coding\\2019LavalleeLab\\temp2\\ExampleDataSet\\2019.comet.params";

            CometSingleSearch.InitializeComet(idx, param);
            CometSingleSearch.QualityCheck();
            Program.ExitProgram(1);
            String dataRoot   = "C:\\Users\\LavalleeLab\\Documents\\JoshTemp\\MealTimeMS_APITestRun\\Data\\";
            String outputRoot = "C:\\Users\\LavalleeLab\\Documents\\JoshTemp\\MealTimeMS_APITestRun\\Output\\";
            //String mzmlPath = dataRoot+"60minMZMLShrink.csv";
            String   mzmlPath   = dataRoot + "8001.ms2.txt";
            String   dbPath     = dataRoot + "tinyDB.fasta.idx"; //
            String   outputPath = outputRoot + "output.txt";
            String   paramsPath = dataRoot + "comet.params";
            MZMLFile mzml       = Loader.parseMS2File(mzmlPath);

            //MZMLFile mzml = null;
            CometSingleSearch.InitializeComet(dbPath, paramsPath);
            var watch   = System.Diagnostics.Stopwatch.StartNew();
            int counter = 0;

            Console.WriteLine("Starting comet search");
            WriterClass.initiateWriter(outputPath);

            for (int i = 0; i < 1; i++)
            {
                if (i % 1 == 0)
                {
                    Spectra spec = mzml.getSpectraArray()[i];
                    if (spec.getMSLevel() != 2)
                    {
                        continue;
                    }
                    Console.WriteLine("scanNum {0} RT {2} Mass {2} MSLevel {3}", spec.getScanNum(), spec.getStartTime(),
                                      spec.getCalculatedPrecursorMass(), spec.getMSLevel());
                    IDs id = null;
                    if (CometSingleSearch.Search(spec, out id))
                    {
                        String outLine = String.Format("{0}\t{1}\txcorr\t{2}\tdcn\t{3}", id.getScanNum(), id.getPeptideSequence(), id.getXCorr(), id.getDeltaCN());
                        Console.WriteLine(outLine);
                        WriterClass.writeln(outLine);
                    }
                    else
                    {
                        Console.WriteLine("Spectrum cannot be matched\n");
                    }
                    counter++;
                }
            }
            watch.Stop();
            Console.WriteLine("Comet search of " + counter + " spectra took " + watch.ElapsedMilliseconds + " milliseconds");
            WriterClass.CloseWriter();
        }
Example #5
0
        private static void WriteScanArrivalProcessedTime(List <double[]> list)
        {
            String header = "ScanNum\tArrival\tProcessed";

            WriterClass.writeln(header, writerClassOutputFile.scanArrivalAndProcessedTime);
            foreach (double[] scan in list)
            {
                String data = "";
                foreach (double d in scan)
                {
                    data = data + d + "\t";
                }
                WriterClass.writeln(data, writerClassOutputFile.scanArrivalAndProcessedTime);
            }
        }
Example #6
0
        protected bool processMS2(Spectra spec)
        {
            performanceEvaluator.countMS2();

            log.Debug(spec);
            IDs id = performDatabaseSearch(spec);

            // check if mass is on exclusion list

            Boolean isExcluded = false;

            if (id != null)
            {
                Peptide pep = getPeptideFromIdentification(id);
                isExcluded = exclusionList.containsPeptide(pep);                  //checks if the mass should've been excluded,
                //in a real experiment, this should never equal to true
                //since the mass should not have been scanned in the first place
                //if MS exclusion table was updated correctly through API
                if (!peptideRT.Keys.Contains(pep.getSequence()))
                {
                    peptideRT.Add(pep.getSequence(), spec.getStartTime());
                }
            }



            if (isExcluded)
            {
#if SIMULATION
                //log.Debug("Mass " + spectraMass + " is on the exclusion list. Scan " + spec.getScanNum() + " excluded.");
                evaluateExclusion(id);
                WriterClass.LogScanTime("Excluded", (int)spec.getIndex());
#endif
                performanceEvaluator.countExcludedSpectra();
                excludedSpectra.Add(spec.getScanNum());
                return(false);
            }
            else
            {
                performanceEvaluator.countAnalyzedSpectra();
                //log.Debug("Mass " + spectraMass + " was not on the exclusion list. Scan " + spec.getScanNum() + " analyzed.");
                evaluateIdentification(id);
                includedSpectra.Add(spec.getScanNum());
                // calibrate peptide if the observed retention time doesn't match the predicted
                //WriterClass.LogScanTime("Processed", (int)spec.getIndex());
                return(true);
            }
        }
Example #7
0
        public static void DoJob(String fileIn, String fileOut, int start, int num)
        {
            WriterClass.initiateWriter(fileOut);
            StreamReader reader = new StreamReader(fileIn);

            WriterClass.writeln(reader.ReadLine());
            for (int i = 0; i < start - 1; i++)
            {
                reader.ReadLine();
            }
            for (int i = 0; i < num; i++)
            {
                WriterClass.writeln(reader.ReadLine());
            }

            WriterClass.CloseWriter();
        }
Example #8
0
        //actual experiment hooked up to the mass spec
        public static void RunRealTimeExperiment()
        {
            PreExperimentSetUp();
            Console.WriteLine("Running real time experiment");

            double startTime = getCurrentTime();

            GlobalVar.ppmTolerance            = 5.0 / 1000000.0;
            GlobalVar.retentionTimeWindowSize = 1.0;
            GlobalVar.AccordThreshold         = 0.5;

            Console.WriteLine("Creating exclusion profile");
            ExclusionProfile exclusionProfile = new MachineLearningGuidedExclusion(InputFileOrganizer.AccordNet_LogisticRegressionClassifier_WeightAndInterceptSavedFile, database, GlobalVar.ppmTolerance, GlobalVar.retentionTimeWindowSize);
            String           experimentName   = GlobalVar.experimentName + String.Format("_MLGE:ppmTol_{0}_rtWin_{1}_prThr_{2}", GlobalVar.ppmTolerance, GlobalVar.retentionTimeWindowSize, GlobalVar.AccordThreshold);
            Experiment       experiment       = new Experiment(exclusionProfile, experimentName, 1, ExclusionProfileEnum.MACHINE_LEARNING_GUIDED_EXCLUSION_PROFILE, startTime);


            new DataReceiver().DoJob(exclusionProfile);

            double analysisTime = getCurrentTime() - startTime;

            try
            {
                WriteUnusedSpectra(experiment);
                WriteScanArrivalProcessedTime(DataProcessor.scanArrivalAndProcessedTimeList);
                WriteScanArrivalProcessedTime(DataProcessor.spectraNotAdded);
                WriteUsedSpectra(experiment);
                WriterClass.writeln("ExclusionList size: " + exclusionProfile.getExclusionList().getExclusionList().Count);
                WriterClass.writeln("Number of exclusion: " + exclusionProfile.getUnusedSpectra().Count);
                WriterClass.writeln("Final rtoffset: " + RetentionTime.getRetentionTimeOffset());
            }
            catch (Exception e)
            {
                Console.WriteLine("Writing exception catched at end of experiment");
            }
            finally
            {
                WriterClass.CloseWriter();
            }
            exclusionProfile.reset();
            reset();
        }
Example #9
0
        protected virtual bool processMS2(Spectra spec)
        {
            performanceEvaluator.countMS2();

            log.Debug(spec);


            // check if mass is on exclusion list
            double  spectraMass = spec.getCalculatedPrecursorMass();
            Boolean isExcluded  = exclusionList.isExcluded(spectraMass); //checks if the mass should've been excluded,

            //in a real experiment, this should never equal to true
            //since the mass should not have been scanned in the first place
            //if MS exclusion table was updated correctly through API


            if (isExcluded)
            {
#if (SIMULATION)
                IDs id = performDatabaseSearch(spec);

                log.Debug("Mass " + spectraMass + " is on the exclusion list. Scan " + spec.getScanNum() + " excluded.");
                evaluateExclusion(id);
                WriterClass.LogScanTime("Excluded", (int)spec.getIndex());
#endif
                performanceEvaluator.countExcludedSpectra();
                excludedSpectra.Add(spec.getScanNum());
                return(false);
            }
            else
            {
                IDs id = performDatabaseSearch(spec);
                performanceEvaluator.countAnalyzedSpectra();
                log.Debug("Mass " + spectraMass + " was not on the exclusion list. Scan " + spec.getScanNum() + " analyzed.");
                evaluateIdentification(id);
                includedSpectra.Add(spec.getScanNum());
                // calibrate peptide if the observed retention time doesn't match the predicted
                //WriterClass.LogScanTime("Processed", (int)spec.getIndex());
                return(true);
            }
        }
Example #10
0
        ////MLGE parameters:
        //static readonly List<double> PPM_TOLERANCE_LIST = new List<double>(new double[] { 10.0 / 1000000.0 });
        //static readonly List<double> RETENTION_TIME_WINDOW_LIST = new List<double>(new double[] { 0.75, 1.0, 2.0 });
        //static readonly List<double> LR_PROBABILITY_THRESHOLD_LIST = new List<double>(new double[] { 0.3, 0.5, 0.7, 0.9 });

        ////Nora parameters:
        //static readonly List<double> XCORR_THRESHOLD_LIST = new List<double>(new double[] { 1.5, 2, 2.5 });
        ////static readonly List<double> XCORR_THRESHOLD_LIST = new List<double>(new double[] {1.5, 2.0 });
        //static readonly List<int> NUM_DB_THRESHOLD_LIST = new List<int>(new int[] { 2 });

        public static void RunExclusionExplorer(ExclusionProfileEnum exclusionType)
        {
            PreExperimentSetUp();
            WriterClass.writeln(new PerformanceEvaluator().getHeader());
            int experimentNumber = 0;

            if (exclusionType == ExclusionProfileEnum.MACHINE_LEARNING_GUIDED_EXCLUSION_PROFILE)
            {
                foreach (double ppmTol in GlobalVar.PPM_TOLERANCE_LIST)
                {
                    foreach (double rtWin in GlobalVar.RETENTION_TIME_WINDOW_LIST)
                    {
                        foreach (double prThr in GlobalVar.LR_PROBABILITY_THRESHOLD_LIST)
                        {
                            experimentNumber++;
                            double startTime = getCurrentTime();
                            GlobalVar.ppmTolerance            = ppmTol;
                            GlobalVar.retentionTimeWindowSize = rtWin;
                            GlobalVar.AccordThreshold         = prThr;

                            ExclusionProfile exclusionProfile = new MachineLearningGuidedExclusion(InputFileOrganizer.AccordNet_LogisticRegressionClassifier_WeightAndInterceptSavedFile, database, GlobalVar.ppmTolerance, GlobalVar.retentionTimeWindowSize);
                            String           experimentName   = "EXP_" + experimentNumber + GlobalVar.experimentName + String.Format("_MachineLearningGuidedExclusion:ppmTol_{0}_rtWin_{1}_prThr_{2}", ppmTol, rtWin, prThr);
                            Experiment       experiment       = new Experiment(exclusionProfile, experimentName, experimentNumber, exclusionType, startTime);
                            RunSimulationAndPostProcess(experiment);
                        }
                    }
                }
            }
            else if (exclusionType == ExclusionProfileEnum.NORA_EXCLUSION_PROFILE)
            {
                foreach (double xCorr in GlobalVar.XCORR_THRESHOLD_LIST)
                {
                    foreach (int numDB in GlobalVar.NUM_DB_THRESHOLD_LIST)
                    {
                        foreach (double ppmTol in GlobalVar.PPM_TOLERANCE_LIST)
                        {
                            foreach (double rtWin in GlobalVar.RETENTION_TIME_WINDOW_LIST)
                            {
                                experimentNumber++;
                                double startTime = getCurrentTime();
                                GlobalVar.ppmTolerance            = ppmTol;
                                GlobalVar.retentionTimeWindowSize = rtWin;
                                GlobalVar.XCorr_Threshold         = xCorr;
                                GlobalVar.NumDBThreshold          = numDB;

                                ExclusionProfile exclusionProfile = new NoraExclusion(database, GlobalVar.XCorr_Threshold, GlobalVar.ppmTolerance, GlobalVar.NumDBThreshold, GlobalVar.retentionTimeWindowSize);
                                String           experimentName   = "EXP_" + experimentNumber + GlobalVar.experimentName + String.Format("_HeuristicExclusion:xCorr_{0}_numDB_{1}_ppmTol_{2}_rtWin_{3}", xCorr, numDB, ppmTol, rtWin) + "_expNum" + experimentNumber;
                                Experiment       experiment       = new Experiment(exclusionProfile, experimentName, experimentNumber, exclusionType, startTime);
                                RunSimulationAndPostProcess(experiment);
                            }
                        }
                    }
                }
            }
            else if (exclusionType == ExclusionProfileEnum.COMBINED_EXCLUSION)
            {
                foreach (double rtWin in GlobalVar.RETENTION_TIME_WINDOW_LIST)
                {
                    foreach (double prThr in GlobalVar.LR_PROBABILITY_THRESHOLD_LIST)
                    {
                        foreach (int numDB in GlobalVar.NUM_DB_THRESHOLD_LIST)
                        {
                            foreach (double xCorr in GlobalVar.XCORR_THRESHOLD_LIST)
                            {
                                foreach (double ppmTol in GlobalVar.PPM_TOLERANCE_LIST)
                                {
                                    experimentNumber++;
                                    double startTime = getCurrentTime();
                                    GlobalVar.ppmTolerance            = ppmTol;
                                    GlobalVar.retentionTimeWindowSize = rtWin;
                                    GlobalVar.AccordThreshold         = prThr;
                                    GlobalVar.XCorr_Threshold         = xCorr;
                                    GlobalVar.NumDBThreshold          = numDB;

                                    ExclusionProfile exclusionProfile = new CombinedExclusion(InputFileOrganizer.AccordNet_LogisticRegressionClassifier_WeightAndInterceptSavedFile, database, GlobalVar.ppmTolerance, GlobalVar.retentionTimeWindowSize, xCorr, numDB);
                                    String           experimentName   = "EXP_" + experimentNumber + GlobalVar.experimentName + String.Format("_CombinedExclusion:xCorr_{0}_numDB_{1}_ppmTol_{2}_rtWin_{3}_prThr_{4}",
                                                                                                                                             xCorr, numDB, GlobalVar.ppmTolerance, GlobalVar.retentionTimeWindowSize, GlobalVar.AccordThreshold);
                                    Experiment experiment = new Experiment(exclusionProfile, experimentName, experimentNumber, exclusionType, startTime);
                                    RunSimulationAndPostProcess(experiment);
                                }
                            }
                        }
                    }
                }
            }
            else if (exclusionType == ExclusionProfileEnum.SVMEXCLUSION)
            {
                foreach (double ppmTol in GlobalVar.PPM_TOLERANCE_LIST)
                {
                    foreach (double rtWin in GlobalVar.RETENTION_TIME_WINDOW_LIST)
                    {
                        experimentNumber++;
                        double startTime = getCurrentTime();
                        GlobalVar.ppmTolerance            = ppmTol;
                        GlobalVar.retentionTimeWindowSize = rtWin;

                        ExclusionProfile exclusionProfile = new SVMExclusion(InputFileOrganizer.SVMSavedFile, database, GlobalVar.ppmTolerance, GlobalVar.retentionTimeWindowSize);
                        String           experimentName   = "EXP_" + experimentNumber + GlobalVar.experimentName + String.Format("_SVM:ppmTol_{0}_rtWin_{1}", ppmTol, rtWin);
                        Experiment       experiment       = new Experiment(exclusionProfile, experimentName, experimentNumber, exclusionType, startTime);
                        RunSimulationAndPostProcess(experiment);
                    }
                }
            }
            else if (exclusionType == ExclusionProfileEnum.NO_EXCLUSION_PROFILE)
            {
                foreach (double rtWin in GlobalVar.RETENTION_TIME_WINDOW_LIST)
                {
                    experimentNumber++;
                    double startTime = getCurrentTime();
                    GlobalVar.ppmTolerance            = 0;
                    GlobalVar.retentionTimeWindowSize = rtWin;

                    ExclusionProfile exclusionProfile = new NoExclusion(database, GlobalVar.retentionTimeWindowSize);
                    String           experimentName   = "EXP_" + experimentNumber + GlobalVar.experimentName + String.Format("_NoExclusion:ppmTol_rtWin_{0}", rtWin);
                    Experiment       experiment       = new Experiment(exclusionProfile, experimentName, experimentNumber, exclusionType, startTime);
                    RunSimulationAndPostProcess(experiment);

                    if (exclusionType == ExclusionProfileEnum.NO_EXCLUSION_PROFILE)
                    {
                        List <ObservedPeptideRtTrackerObject> peptideIDRT = ((NoExclusion)exclusionProfile).peptideIDRT;

                        //actual arrival time, xcorr, rtCalc predicted RT, corrected RT, offset
                        //WriterClass.writeln("pepSeq\tarrivalTime\txcorr\trtPeak\tcorrectedRT\toffset\trtCalcPredicted\tisPredicted1", writerClassOutputFile.peptideRTTime);
                        //foreach (ObservedPeptideRtTrackerObject observedPeptracker in peptideIDRT)
                        //{

                        //	WriterClass.writeln(observedPeptracker.ToString(), writerClassOutputFile.peptideRTTime);
                        //}
                        WriterClass.writeln("peptideSequence\tObservedRetentionTime", writerClassOutputFile.peptideRTTime);
                        foreach (ObservedPeptideRtTrackerObject observedPeptracker in peptideIDRT)
                        {
                            WriterClass.writeln(String.Format("{0}\t{1}", observedPeptracker.peptideSequence, observedPeptracker.arrivalTime), writerClassOutputFile.peptideRTTime);
                        }
                    }
                    break;
                }
            }
            else if (exclusionType == ExclusionProfileEnum.RANDOM_EXCLUSION_PROFILE)
            {
                List <ExperimentResult> resultList = ParseExperimentResult(InputFileOrganizer.SummaryFileForRandomExclusion);
                foreach (ExperimentResult expResult in resultList)
                {
                    //Do 5 random experiments per normal experiment
                    for (int i = 0; i < GlobalVar.randomRepeatsPerExperiment; i++)
                    {
                        experimentNumber++;
                        double startTime = getCurrentTime();
                        String originalExperimentName = expResult.experimentName;
                        int    numExcluded            = expResult.numSpectraExcluded;
                        int    numAnalyzed            = expResult.numSpectraAnalyzed;

                        ExclusionProfile exclusionProfile = new RandomExclusion_Fast(database, ms2SpectraList, numExcluded, numAnalyzed, 12);
                        String           experimentName   = "EXP_" + experimentNumber + String.Format("Random:originalExperiment_{0}", originalExperimentName);

                        Experiment experiment = new Experiment(exclusionProfile, experimentName, experimentNumber, exclusionType, startTime);
                        RunSimulationAndPostProcess(experiment);
                    }
                }
            }
        }
Example #11
0
        public static ExclusionProfile SingleSimulationRun(ExclusionProfileEnum expType)
        {
            PreExperimentSetUp();
            int    experimentNumber = 1;
            double startTime        = getCurrentTime();

            //parameters:
            //GlobalVar.ppmTolerance = 5.0 / 1000000.0;
            //GlobalVar.retentionTimeWindowSize = 1.0;
            //GlobalVar.AccordThreshold = 0.5;
            //GlobalVar.XCorr_Threshold = 1.5;
            //GlobalVar.NumDBThreshold = 2;
            if (GlobalVar.isSimulationForFeatureExtraction == false)
            {
                GlobalVar.ppmTolerance            = GlobalVar.PPM_TOLERANCE_LIST[0];
                GlobalVar.retentionTimeWindowSize = GlobalVar.RETENTION_TIME_WINDOW_LIST[0];
                GlobalVar.AccordThreshold         = GlobalVar.LR_PROBABILITY_THRESHOLD_LIST[0];
                GlobalVar.XCorr_Threshold         = GlobalVar.XCORR_THRESHOLD_LIST[0];
                GlobalVar.NumDBThreshold          = GlobalVar.NUM_DB_THRESHOLD_LIST[0];
            }
            //random
            int numExcluded = 14826;
            int numAnalyzed = 22681;

            //end parameters

            ExclusionProfile exclusionProfile = null;

            switch (expType)
            {
            case ExclusionProfileEnum.NORA_EXCLUSION_PROFILE:
                exclusionProfile = new NoraExclusion(database, GlobalVar.XCorr_Threshold, GlobalVar.ppmTolerance, GlobalVar.NumDBThreshold, GlobalVar.retentionTimeWindowSize);
                break;

            case ExclusionProfileEnum.MACHINE_LEARNING_GUIDED_EXCLUSION_PROFILE:
                exclusionProfile = new MachineLearningGuidedExclusion(InputFileOrganizer.AccordNet_LogisticRegressionClassifier_WeightAndInterceptSavedFile, database, GlobalVar.ppmTolerance, GlobalVar.retentionTimeWindowSize);
                break;

            case ExclusionProfileEnum.RANDOM_EXCLUSION_PROFILE:

                exclusionProfile = new RandomExclusion_Fast(database, ms2SpectraList, numExcluded, numAnalyzed, 12);

                break;

            case ExclusionProfileEnum.NO_EXCLUSION_PROFILE:
                exclusionProfile = new NoExclusion(database, GlobalVar.retentionTimeWindowSize);
                break;

            case ExclusionProfileEnum.MLGE_SEQUENCE_EXCLUSION_PROFILE:
                exclusionProfile = new MLGESequenceExclusion(InputFileOrganizer.AccordNet_LogisticRegressionClassifier_WeightAndInterceptSavedFile, database, GlobalVar.ppmTolerance, GlobalVar.retentionTimeWindowSize);
                break;

            case ExclusionProfileEnum.NORA_SEQUENCE_EXCLUSION_PROFILE:
                exclusionProfile = new NoraSequenceExclusion(database, GlobalVar.XCorr_Threshold, GlobalVar.ppmTolerance, GlobalVar.NumDBThreshold, GlobalVar.retentionTimeWindowSize);
                break;

            case ExclusionProfileEnum.SVMEXCLUSION:
                exclusionProfile = new SVMExclusion(InputFileOrganizer.SVMSavedFile, database, GlobalVar.ppmTolerance, GlobalVar.retentionTimeWindowSize);
                break;
            }

            WriterClass.writeln(exclusionProfile.GetPerformanceEvaluator().getHeader());
            String     experimentName = "EXP_" + experimentNumber + GlobalVar.experimentName;
            Experiment experiment     = new Experiment(exclusionProfile, experimentName, 1, expType, startTime);

            new DataReceiverSimulation().DoJob(exclusionProfile, ms2SpectraList);
            double analysisTime = getCurrentTime() - startTime;

            //WriteScanArrivalProcessedTime(DataProcessor.scanArrivalAndProcessedTimeList);
            //WriteExcludedProteinList(exclusionProfile.getDatabase().getExcludedProteins());

#if IGNORE
            WriteScanArrivalProcessedTime(DataProcessor.spectraNotAdded);

            foreach (double[] ignoredSpectra in DataProcessor.spectraNotAdded)
            {
                int scanNum = ms2SpectraList[(int)ignoredSpectra[0] - 1].getScanNum();
                exclusionProfile.getSpectraUsed().Add(scanNum);
            }
#endif

            //if (expType == ExclusionProfileEnum.NO_EXCLUSION_PROFILE)
            //{
            //	List<ObservedPeptideRtTrackerObject> peptideIDRT = ((NoExclusion)exclusionProfile).peptideIDRT;

            //	//actual arrival time, xcorr, rtCalc predicted RT, corrected RT, offset
            //	WriterClass.writeln("pepSeq\tarrivalTime\txcorr\trtPeak\tcorrectedRT\toffset\trtCalcPredicted\tisPredicted1", writerClassOutputFile.peptideRTTime);
            //	foreach (ObservedPeptideRtTrackerObject observedPeptracker in peptideIDRT)
            //	{

            //		WriterClass.writeln(observedPeptracker.ToString(), writerClassOutputFile.peptideRTTime);
            //	}
            //}
            //if (expType == ExclusionProfileEnum.MACHINE_LEARNING_GUIDED_EXCLUSION_PROFILE)
            //{
            //	List<double[]> peptideIDRT = ((MachineLearningGuidedExclusion)exclusionProfile).peptideIDRT;

            //	//actual arrival time, xcorr, rtCalc predicted RT, corrected RT, offset
            //	WriterClass.writeln("arrivalTime\txcorr\trtPeak\tcorrectedRT\toffset\trtCalcPredicted\tisPredicted1", writerClassOutputFile.peptideRTTime);
            //	foreach(double[] id in peptideIDRT)
            //	{
            //		String str = "";
            //		foreach(double d in id)
            //		{
            //			str = str + "\t" + d;
            //		}
            //		str= str.Trim();
            //		WriterClass.writeln(str, writerClassOutputFile.peptideRTTime);
            //	}
            //}

#if TRACKEXCLUDEDPROTEINFEATURE
            if (expType == ExclusionProfileEnum.MACHINE_LEARNING_GUIDED_EXCLUSION_PROFILE)
            {
                List <object[]> excludedProteinFeatures = ((MachineLearningGuidedExclusion)exclusionProfile).excludedProteinFeatureList;
                WriterClass.writeln("Accession\tCardinality\tHighestXCorr\tMeanXCorr\tMedianXCorr\tStDev", writerClassOutputFile.ExcludedSpectraScanNum);
                foreach (object[] feature in excludedProteinFeatures)
                {
                    String featureStr = "";
                    foreach (object o in feature)
                    {
                        featureStr = featureStr + o.ToString() + "\t";
                    }
                    featureStr = featureStr.Trim();
                    WriterClass.writeln(featureStr, writerClassOutputFile.ExcludedSpectraScanNum);
                }
            }
#endif
            //WriteUnusedSpectra(exclusionProfile);
            //WriteUsedSpectra(exclusionProfile);
            PostExperimentProcessing(experiment);
            //WriteUnusedSpectra(exclusionProfile);

            return(exclusionProfile);
        }
Example #12
0
 private void WriteRetention(String str)
 {
     WriterClass.writeln(str, writerClassOutputFile.peptideRTTime);
 }
Example #13
0
        static String mzml = "C:\\Coding\\2019LavalleeLab\\RealTest_Results_20200219\\MSQC_QE_200ng_HEK_2hr_to_run_200219172225.mzML";        //"C:\\Coding\\2019LavalleeLab\\GoldStandardData\\MZML_Files\\MS_QC_120min.mzml";
        public static void DoJob()
        {
            //comet
            Console.WriteLine("Performing Comet search on full ms2 data");
            String fullCometFile = PostProcessingScripts.CometStandardSearch(ms2File, InputFileOrganizer.OutputFolderOfTheRun, true);

            InputFileOrganizer.OriginalCometOutput = fullCometFile;


            //protein prophet
            Console.WriteLine("Perform a protein prophet search on full pepxml");
            String fullProteinProphetFile = PostProcessingScripts.ProteinProphetSearch(fullCometFile, InputFileOrganizer.OutputFolderOfTheRun, true);

            InputFileOrganizer.OriginalProtXMLFile = fullProteinProphetFile;

            ProteinProphetResult baseLinePpr = ProteinProphetEvaluator.getProteinProphetResult(InputFileOrganizer.OriginalProtXMLFile);

            //load spectra
            Console.WriteLine("loading spectra array");
            List <Spectra> ls = Loader.parseMS2File(ms2File).getSpectraArray();

            List <int> includedSpectra = new List <int>();
            List <int> excludedSpectra = new List <int>();

            StreamReader sr   = new StreamReader(excludedSpectraFile);
            String       line = sr.ReadLine();

            while (line != null)
            {
                int excluded = int.Parse(line);
                excludedSpectra.Add(excluded);
                line = sr.ReadLine();
            }

            foreach (Spectra sp in ls)
            {
                if (!excludedSpectra.Contains(sp.getScanNum()))
                {
                    includedSpectra.Add(sp.getScanNum());
                }
            }
            String outputCometFile = Path.Combine(InputFileOrganizer.OutputFolderOfTheRun, "realTestpartialOut.pep.xml"); //"C:\\Coding\\2019LavalleeLab\\GoldStandardData\\pepxml\\MS_QC_120min_partial.pep.xml";
            String fastaFile       = InputFileOrganizer.FASTA_FILE;                                                       //"C:\\Coding\\2019LavalleeLab\\GoldStandardData\\Database\\uniprot_SwissProt_Human_1_11_2017.fasta";

            PartialPepXMLWriter.writePartialPepXMLFile(fullCometFile, includedSpectra,
                                                       outputCometFile, mzml, fastaFile, outputCometFile);

            String partialProt = PostProcessingScripts.ProteinProphetSearch(outputCometFile, InputFileOrganizer.OutputFolderOfTheRun, true);
            ProteinProphetResult partialPpr = ProteinProphetEvaluator.getProteinProphetResult(partialProt);

            double partialNum = partialPpr.getNum_proteins_identified();
            double totalNum   = baseLinePpr.getNum_proteins_identified();
            double idSens     = partialNum / totalNum * 100.0;

            double includedScanNum = includedSpectra.Count;
            double totalScanNum    = ls.Count;
            double usedResource    = includedScanNum / totalScanNum * 100;
            String line1           = String.Format("includedScans {0} \t totalScanNum {1} \tUsedResources {2}", includedScanNum, totalScanNum, usedResource);
            String line2           = String.Format("partialNum {0} \t totalNum {1} \tidsens {2}", partialNum, totalNum, idSens);

            Console.WriteLine(line1);
            Console.WriteLine(line2);
            WriterClass.writeln(line1);
            WriterClass.writeln(line2);
            WriterClass.CloseWriter();
        }