Skip to content

Commit

Permalink
edited FileNameToFilePath method in MSFraggerPsm to account for MSFra…
Browse files Browse the repository at this point in the history
…gger file name additions and wrote tests
  • Loading branch information
mzhastings committed Aug 20, 2024
1 parent 611a608 commit 9806eb0
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 6 deletions.
1 change: 1 addition & 0 deletions mzLib/FlashLFQ/ResultsReading/IdentificationAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static List<Identification> MakeIdentifications(IQuantifiableResultFile q
SpectraFileInfo file = null;
if (allFiles.TryGetValue(record.FileName, out var fileInfo))
{
// placeholder values for SpectraFileInfo that will be edited later
file = new SpectraFileInfo(record.FileName, "", 1, 1, 1);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,17 @@ public class MsFraggerPsm : IQuantifiableRecord
public double NextScore { get; set; }

[Name("PeptideProphet Probability")]
public double PeptideProphetProbability { get; set; }
[CsvHelper.Configuration.Attributes.Optional]
private double? _peptideProphetProbability;

/// <summary>
/// New MsFragger output renames the header "PeptideProphet Probability" as just "Probability".
/// Headers are mutually exclusive, will not both occur in the same file.
/// As such, both instances need to be accounted for seperately as optional fields.
/// </summary>
[Name("Probability")]
[CsvHelper.Configuration.Attributes.Optional]
private double? _probability;

[Name("Number of Enzymatic Termini")]
public int NumberOfEnzymaticTermini { get; set; }
Expand Down Expand Up @@ -158,6 +168,11 @@ public class MsFraggerPsm : IQuantifiableRecord
[Ignore]
public int OneBasedScanNumber => _oneBasedScanNumber ??= int.Parse(Spectrum.Split('.')[1]);

/// <summary>
/// Ensures Probabilty is asscociated either the Probability or PeptideProphet Probability header or 0
/// </summary>
[Ignore] public double PeptideProphetProbability => _probability ?? _peptideProphetProbability ?? 0;

#endregion

#region IQuantifiableRecord Implementation
Expand Down
9 changes: 4 additions & 5 deletions mzLib/Readers/ExternalResults/ResultFiles/MsFraggerPsmFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ public Dictionary<string, string> FileNametoFilePath (List<string> fullFilePath)

foreach(var fileName in rawFileNames)
{
string shortFileName = Path.GetFileNameWithoutExtension(fileName);
if (shortFileName.Contains("."))
{
shortFileName = Path.GetFileNameWithoutExtension(shortFileName);
}
string shortFileName = Path.GetFileName(fileName);
// MSFragger results append the raw file with "interact-" and replace .raw with .pep.xml
// In order to correctly match the file names, these changes must be removed
shortFileName = shortFileName.Replace("interact-", "").Replace(".pep.xml", "");

foreach(var file in fullFilePath)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Spectrum Spectrum File Peptide Modified Peptide Extended Peptide Prev AA Next AA Peptide Length Charge Retention Observed Mass Calibrated Observed Mass Observed M/Z Calibrated Observed M/Z Calculated Peptide Mass Calculated M/Z Delta Mass Expectation Hyperscore Nextscore Probability Number of Enzymatic Termini Number of Missed Cleavages Protein Start Protein End Intensity Assigned Modifications Observed Modifications Purity Is Unique Protein Protein ID Entry Name Gene Protein Description Mapped Genes Mapped Proteins
SmallCalibratibleYeast.00002.00002.2 E:\MadeleineH\YeastProteomeMSFragger\1\interact-SmallCalibratibleYeast.pep.xml RGNVCGDAK RGNVCGDAK NVSVKEIR.RGNVCGDAK.NDPPKGCA R N 9 2 1443.6643 975.4455 975.4455 488.7300 488.7300 975.4556 488.7351 -0.0101 0.00047835460000 25.7810 11.6900 0.9997 2 1 320 328 1.81151584E8 5C(57.0215) 0.00 true sp|P02994|EF1A_YEAST P02994 EF1A_YEAST TEF1 Elongation factor 1-alpha
SmallCalibratibleYeast.00004.00004.2 E:\MadeleineH\YeastProteomeMSFragger\1\interact-SmallCalibratibleYeast.pep.xml EKAEAEAEK GIREKRAR.EKAEAEAEK.KK R K 9 2 1444.1241 1003.4855 1003.4855 502.7500 502.7500 1003.4821 502.7483 0.0033 0.02974116000000 18.6380 12.6310 0.9269 2 1 189 197 3.6544424E7 0.00 false sp|P40212|RL13B_YEAST P40212 RL13B_YEAST RPL13B Large ribosomal subunit protein eL13B RPL13A sp|Q12690|RL13A_YEAST
SmallCalibratibleYeast.00008.00008.2 E:\MadeleineH\YeastProteomeMSFragger\1\interact-SmallCalibratibleYeast.pep.xml KITSNQR FNVPIDGK.KITSNQR.IVAAIPTI K I 7 2 1446.0237 845.4655 845.4655 423.7400 423.7400 845.4719 423.7432 -0.0064 0.13056640000000 17.5940 12.5170 0.9646 2 1 33 39 2.5555878E7 0.00 true sp|P00560|PGK_YEAST P00560 PGK_YEAST PGK1 Phosphoglycerate kinase
SmallCalibratibleYeast.00009.00009.2 E:\MadeleineH\YeastProteomeMSFragger\1\interact-SmallCalibratibleYeast.pep.xml GIDHTSK .GIDHTSK.QHKRSGHR M Q 7 2 1446.2545 756.3855 756.3855 379.2000 379.2000 756.3766 379.1956 0.0089 0.01669167000000 17.6100 9.8270 0.9965 2 0 2 8 6.739196E7 0.00 false sp|P0CX49|RL18A_YEAST P0CX49 RL18A_YEAST RPL18A Large ribosomal subunit protein eL18A RPL18B sp|P0CX50|RL18B_YEAST
SmallCalibratibleYeast.00010.00010.2 E:\MadeleineH\YeastProteomeMSFragger\1\interact-SmallCalibratibleYeast.pep.xml EKAEAEAEK GIREKRAR.EKAEAEAEK.KK R K 9 2 1446.4789 1003.4855 1003.4855 502.7500 502.7500 1003.4821 502.7483 0.0033 0.02315876000000 18.5780 12.4510 0.9875 2 1 189 197 3.6544424E7 0.00 false sp|P40212|RL13B_YEAST P40212 RL13B_YEAST RPL13B Large ribosomal subunit protein eL13B RPL13A sp|Q12690|RL13A_YEAST
6 changes: 6 additions & 0 deletions mzLib/Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@
<None Update="FileReadingTests\ExternalFileTypes\MsPathFinderT_TargetResults_IcTarget.tsv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FileReadingTests\ExternalFileTypes\psm.tsv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FileReadingTests\ExternalFileTypes\SmallCalibratibleYeastFragger_psm.tsv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="FileReadingTests\ExternalFileTypes\ToppicProteoformSingle_TopPICv1.5.3_proteoform_single.tsv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
18 changes: 18 additions & 0 deletions mzLib/TestFlashLFQ/TestIdentificationAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,23 @@ public void TestFileNametoFilePath(string path)
Assert.AreEqual(output, fullFilePath1);
Assert.That(!allFiles.ContainsValue(fullFilePath2));
}

[Test]
[TestCase(@"FileReadingTests\ExternalFileTypes\SmallCalibratibleYeastFragger_psm.tsv")]
public void TestFileNametoFilePathLocalPath(string path)
{
string filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, path);
MsFraggerPsmFile file = new MsFraggerPsmFile(filePath);
string fileName = file.First().FileName;

List<string> fullFilePath = new List<string>();
string rawFilePath = @"DataFiles\SmallCalibratibleYeast.mzml";
fullFilePath.Add(rawFilePath);

Dictionary<string, string> allFiles = file.FileNametoFilePath(fullFilePath);

Assert.That(allFiles.TryGetValue(fileName, out var output));
Assert.AreEqual(output, rawFilePath);
}
}
}

0 comments on commit 9806eb0

Please sign in to comment.