Example #1
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());
        }