Beispiel #1
0
        /*
         * These are from the experiment and will be removed if you call reset on the
         * graph
         */
        public Peptide addPeptideFromIdentification(IDs id, double currentTime)
        {
            String           peptideSequence         = id.getPeptideSequence();
            double           peptideMass             = id.getPeptideMass();
            HashSet <String> parentProteinAccessions = id.getParentProteinAccessions();
            Peptide          pep;

            if (containsPeptide(peptideSequence))
            {
                return(getPeptide(peptideSequence));
            }
            else
            {
                // Adds the peptide from the identification into the database
                pep = new Peptide(peptideSequence, peptideMass, false);
                // these peptides will be removed if reset() is called
                SequenceToPeptide.Add(peptideSequence, pep);
                peptides.Add(pep);

                if (includeRetentionTime)
                {
                    // TODO right now this takes the current time as the peak retention time...
                    // should we run it through RTCalc so we can better estimate our RT alignment?
                    // 2019-04-29 No, do not. Observed times are better than predicted
                    // pep.setRetentionTime(RetentionTimeUtil.convertDoubleToRetentionTime(rt,
                    // retentionTimeWindow,
                    // retentionTimeWindow));
                    RetentionTime rt = new RetentionTime(currentTime + retentionTimeWindow, retentionTimeWindow,
                                                         retentionTimeWindow, false);
                    pep.setRetentionTime(rt);
                }
            }
            // update its parent proteins
            foreach (String acc in parentProteinAccessions)
            {
                Protein parentProtein = AccesstionToProtein[acc];
                if (parentProtein != null)
                {
                    pep.addProtein(parentProtein);
                }
                else if (acc.Contains(GlobalVar.DecoyPrefix))
                {
                    log.Info("WARNINGin Decoy parent protein for this peptide was not found!!");
                    log.Info(acc);
                }
                else
                {
                    log.Warn("WARNINGin Non-decoy parent protein for this peptide was not found!!");
                    log.Warn(acc);
                }
            }

            return(pep);
        }
Beispiel #2
0
        protected Peptide getPeptideFromIdentification(IDs id)
        {
            String  peptideSequence = id.getPeptideSequence();
            Peptide pep             = database.getPeptide(peptideSequence);

            if (pep == null)
            {
                log.Debug("Adding peptide...");
                pep = database.addPeptideFromIdentification(id, currentTime);
                log.Debug("Added peptide " + peptideSequence + ".");
                performanceEvaluator.countPeptidesAdded();
            }
            else
            {
                log.Debug("Peptide found.");
                performanceEvaluator.countPeptidesIdentified();
            }
            return(pep);
        }
 public static void WritePSM(IDs id)
 {
     IDWriter.WriteLine(String.Join("\t", id.getScanNum().ToString(), id.getScanTime().ToString(), id.getPeptideSequence().ToString(),
                                    id.getPeptideMass().ToString(), id.getXCorr().ToString(), id.getDeltaCN().ToString(), String.Join(",", id.getParentProteinAccessions())));
 }
Beispiel #4
0
        /*
         * Writes the result database to a file, to make it faster to re-initialize the
         * software
         */
        //public static void writeResultDatabaseToFile(String file_path, ResultDatabase rd)
        //{
        //    log.Debug("Writing Result Database to a file...");
        //    try
        //    {
        //        StreamWriter writer = new StreamWriter(file_path);
        //        log.Debug("File name: " + file_path);
        //        // Get all IDs
        //        List<IDs> ids = new List<IDs>(rd.getIDs());
        //        // Sort by scan number
        //        ids.Sort((IDs x, IDs y) => (x.getScanNum()).CompareTo(y.getScanNum()));

        //        // Write header
        //        String[] header = new String[] { "scan", "scan_t", "peptide_mass", "peptide_sequence", "parent_proteins",
        //            "peptide_evidence", "peptide_reference", "database_sequence_id", "xCorr", "deltaCN", "deltaCNStar",
        //            "spscore", "sprank", "evalue" };
        //        writer.Write(String.Join("\t", header));
        //        foreach (IDs id in ids)
        //        {
        //            writer.Write("\n" + outputIDToTSVFormat(id));
        //            writer.Flush();
        //        }
        //        writer.Flush();
        //        writer.Close();
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e.ToString());
        //        log.Error("Writing file unsuccessful!!!");
        //        Environment.Exit(0);
        //    }
        //    log.Debug("Writing file successful.");
        //}

        /*
         * Write the identification features used for training the logistic regression
         * classifier
         */
        //public static void writeIdentificationFeaturesFile(String file_path,
        //        List<IdentificationFeatures> positiveTrainingSet,
        //        List<IdentificationFeatures> negativeTrainingSet)
        //{
        //    log.Debug("Writing Identification Features to a file...");
        //    try
        //    {
        //        StreamWriter writer = new StreamWriter(file_path);
        //        log.Debug("File name: " + file_path);

        //        // Write header TODO remove
        //        String header = "label," + IdentificationFeatures.getHeader();
        //        writer.Write(header);

        //        // in the first column, 1 indicates positive training set
        //        foreach (IdentificationFeatures i in positiveTrainingSet)
        //        {
        //            writer.Write("\n" + "1," + i.WriteToFile());
        //            writer.Flush();
        //        }
        //        // in the first column, 0 indicates negative training set
        //        foreach (IdentificationFeatures i in negativeTrainingSet)
        //        {
        //            writer.Write("\n" + "0," + i.WriteToFile());
        //            writer.Flush();
        //        }
        //        writer.Flush();
        //        writer.Close();
        //    }
        //    catch (Exception e)
        //    {
        //        e.printStackTrace();
        //        log.Error("Writing file unsuccessful!!!");
        //        System.exit(0);
        //    }
        //    log.Debug("Writing file successful.");
        //}

        /*
         * Useful for outputting the IDs object in the correct order for
         * writeResultDatabaseToFile
         */
        private static String outputIDToTSVFormat(IDs id)
        {
            return(id.getScanNum() + "\t" + id.getScanTime() + "\t" + id.getPeptideMass() + "\t" + id.getPeptideSequence()
                   + "\t" + id.getParentProteinAccessions() + "\t" + id.getPepEvid() + "\t" + id.getPepRef() + "\t"
                   + id.getDBSeqID() + "\t" + id.getXCorr() + "\t" + id.getDeltaCN() + "\t" + id.getDeltaCNStar() + "\t"
                   + id.getSPScore() + "\t" + id.getSPRank() + "\t" + id.getEValue());
        }
        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();
        }