Esempio n. 1
0
        private void WriteResultsToFile(DatabaseSequenceSpectrumMatch[] matches, string outputFilePath, FastaDatabase database)
        {
            using (var writer = new StreamWriter(outputFilePath))
            {
                writer.WriteLine("Scan\tPre\tSequence\tPost\tModifications\tComposition\tProteinName\tProteinDesc" +
                                 "\tProteinLength\tStart\tEnd\tCharge\tMostAbundantIsotopeMz\tMass\t#MatchedFragments\tProbability\tSpecEValue\tEValue");

                foreach (var scanNum in _ms2ScanNums)
                {
                    var match = matches[scanNum];
                    if (match == null)
                    {
                        continue;
                    }

                    var sequence           = match.Sequence;
                    var offset             = match.Offset;
                    var start              = database.GetOneBasedPositionInProtein(offset) + 1 + match.NumNTermCleavages;
                    var end                = start + sequence.Length - 1;
                    var proteinName        = database.GetProteinName(match.Offset);
                    var protLength         = database.GetProteinLength(proteinName);
                    var ion                = match.Ion;
                    var proteinDescription = database.GetProteinDescription(match.Offset);
                    var probability        = CompositeScorer.GetProbability(match.Score);

                    // Note for DblToString(value, 9, true), by having "9" and "true",
                    // values between 100 and 999 Da will have 7 digits after the decimal place, and
                    // values between 1000 and 9999 will have 6 digits after the decimal place
                    writer.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}\t{16}\t{17}",
                                     scanNum,
                                     match.Pre,                                                                                              // Pre
                                     sequence,                                                                                               // Sequence
                                     match.Post,                                                                                             // Post
                                     match.ModificationText,                                                                                 // Modifications
                                     ion.Composition,                                                                                        // Composition
                                     proteinName,                                                                                            // ProteinName
                                     proteinDescription,                                                                                     // ProteinDescription
                                     protLength,                                                                                             // ProteinLength
                                     start,                                                                                                  // Start position in protein
                                     end,                                                                                                    // End position in protein
                                     ion.Charge,                                                                                             // precursorCharge
                                     StringUtilities.DblToString(ion.GetMostAbundantIsotopeMz(), 9, true),                                   // MostAbundantIsotopeMz
                                     StringUtilities.DblToString(ion.Composition.Mass, 9, true),                                             // Mass
                                     match.NumMatchedFragments,                                                                              // (Number of matched fragments)
                                     StringUtilities.DblToString(probability, 4),                                                            // Probability
                                     StringUtilities.DblToString(ExcelMinValue(match.SpecEvalue), 6, true, 0.001),                           // EValue; will be displayed using scientific notation if the value is less than 0.001
                                     StringUtilities.DblToString(ExcelMinValue(match.SpecEvalue * database.GetNumEntries()), 6, true, 0.001) // SpecEValue; will be displayed using scientific notation if the value is less than 0.001
                                     );
                }
            }
        }