diff --git a/mzLib/FlashLFQ/Peptide.cs b/mzLib/FlashLFQ/Peptide.cs index a52824f9a..39088d35a 100644 --- a/mzLib/FlashLFQ/Peptide.cs +++ b/mzLib/FlashLFQ/Peptide.cs @@ -40,7 +40,7 @@ public static string TabSeparatedHeader(List rawFiles) { sb.Append("Detection Type_" + rawfile.FilenameWithoutExtension + "\t"); } - return sb.ToString(); + return sb.ToString().TrimEnd('\t'); } public double GetIntensity(SpectraFileInfo fileInfo) diff --git a/mzLib/FlashLFQ/ProteinGroup.cs b/mzLib/FlashLFQ/ProteinGroup.cs index c9cea2c7c..de87c4539 100644 --- a/mzLib/FlashLFQ/ProteinGroup.cs +++ b/mzLib/FlashLFQ/ProteinGroup.cs @@ -70,7 +70,7 @@ public static string TabSeparatedHeader(List spectraFiles) } } - return sb.ToString(); + return sb.ToString().TrimEnd('\t'); } public string ToString(List spectraFiles) diff --git a/mzLib/TestFlashLFQ/TestFlashLFQ.cs b/mzLib/TestFlashLFQ/TestFlashLFQ.cs index 9d9f28498..787b2800b 100644 --- a/mzLib/TestFlashLFQ/TestFlashLFQ.cs +++ b/mzLib/TestFlashLFQ/TestFlashLFQ.cs @@ -1180,6 +1180,8 @@ public static void TestFlashLfqQoutputRealData() var engine = new FlashLfqEngine(ids, matchBetweenRuns: true, requireMsmsIdInCondition: false, useSharedPeptidesForProteinQuant: true, maxThreads: -1); var results = engine.Run(); + results.WriteResults(Path.Combine(outputDirectory,"peaks.tsv"), Path.Combine(outputDirectory, "peptides.tsv"), Path.Combine(outputDirectory, "proteins.tsv"), Path.Combine(outputDirectory, "bayesian.tsv"),true); + var peaks = results.Peaks.Values.ToList(); var peptides = results.PeptideModifiedSequences.Values.ToList(); var proteins = results.ProteinGroups.Values.ToList(); @@ -1194,6 +1196,16 @@ public static void TestFlashLfqQoutputRealData() CollectionAssert.AreEquivalent(new string[] { "Q7KZF4", "P52298", "Q15149", "Q15149", "Q7KZF4", "P52298" }, peptides.Select(g => g.ProteinGroups.First()).Select(m => m.ProteinGroupName).ToArray()); Assert.AreEqual(3, proteins.Count); + + List peaksList = File.ReadAllLines(Path.Combine(outputDirectory, "peaks.tsv")).ToList(); + List peptidesList = File.ReadAllLines(Path.Combine(outputDirectory, "peptides.tsv")).ToList(); + List proteinsList = File.ReadAllLines(Path.Combine(outputDirectory, "proteins.tsv")).ToList(); + + //check that all rows including header have the same number of elements + Assert.AreEqual(1, peaksList.Select(l => l.Split('\t').Length).Distinct().ToList().Count); + Assert.AreEqual(1, peptidesList.Select(l => l.Split('\t').Length).Distinct().ToList().Count); + Assert.AreEqual(1, proteinsList.Select(l => l.Split('\t').Length).Distinct().ToList().Count); + CollectionAssert.AreEquivalent(new string[] { "P52298", "Q15149", "Q7KZF4" }, proteins.Select(p => p.ProteinGroupName.ToArray())); Directory.Delete(outputDirectory, true);