Skip to content

Commit

Permalink
Eliminate extra tab from chromatographic peak (#749)
Browse files Browse the repository at this point in the history
* correct Within calculation

* update unit tests

* this is the spot

* add space

* remove tab

* remove extra tab from peptides and proteins output of flashlfq

---------

Co-authored-by: MICHAEL SHORTREED <[email protected]>
  • Loading branch information
trishorts and MICHAEL SHORTREED authored Dec 12, 2023
1 parent 167fa9b commit 79207f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mzLib/FlashLFQ/Peptide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static string TabSeparatedHeader(List<SpectraFileInfo> rawFiles)
{
sb.Append("Detection Type_" + rawfile.FilenameWithoutExtension + "\t");
}
return sb.ToString();
return sb.ToString().TrimEnd('\t');
}

public double GetIntensity(SpectraFileInfo fileInfo)
Expand Down
2 changes: 1 addition & 1 deletion mzLib/FlashLFQ/ProteinGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static string TabSeparatedHeader(List<SpectraFileInfo> spectraFiles)
}
}

return sb.ToString();
return sb.ToString().TrimEnd('\t');
}

public string ToString(List<SpectraFileInfo> spectraFiles)
Expand Down
12 changes: 12 additions & 0 deletions mzLib/TestFlashLFQ/TestFlashLFQ.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<string> peaksList = File.ReadAllLines(Path.Combine(outputDirectory, "peaks.tsv")).ToList();
List<string> peptidesList = File.ReadAllLines(Path.Combine(outputDirectory, "peptides.tsv")).ToList();
List<string> 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);
Expand Down

0 comments on commit 79207f3

Please sign in to comment.