Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMD/CMD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.7.82" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="mzLib" Version="1.0.553" />
<PackageReference Include="mzLib" Version="2.0.7" />
<PackageReference Include="NetSerializer" Version="4.1.2" />
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="SharpLearning.Common.Interfaces" Version="0.28.0" />
Expand Down
2 changes: 1 addition & 1 deletion GUI/GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="mzLib" Version="1.0.553" />
<PackageReference Include="mzLib" Version="2.0.7" />
<PackageReference Include="NetSerializer" Version="4.1.2" />
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="SharpLearning.Common.Interfaces" Version="0.28.0" />
Expand Down
6 changes: 6 additions & 0 deletions Test/SampleFiles/FraggerPsm_FragPipev21.1_psm.tsv
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 PeptideProphet 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
20100611_Velos1_TaGe_SA_Hela_1.00003.00003.2 D:\Projects\Chimeras\Mann_11cell_analysis\Hela\MsFragger\Hela_1_1\interact-20100611_Velos1_TaGe_SA_Hela_1.pep.xml KPVGAAK KAGGTKPK.KPVGAAK.KPKKAAGG K K 7 2 1.9398 669.4164 669.4123 335.7155 335.7135 669.4173 335.7159 -0.0049 0.01675 20.604 12.521 0.9176 2 1 130 136 0 0 TRUE sp|P16403|H12_HUMAN P16403 H12_HUMAN H1-2 Histone H1.2
20100611_Velos1_TaGe_SA_Hela_1.00004.00004.2 D:\Projects\Chimeras\Mann_11cell_analysis\Hela\MsFragger\Hela_1_1\interact-20100611_Velos1_TaGe_SA_Hela_1.pep.xml KPAAAAGAK KKTPKKAK.KPAAAAGAK.KAKSPKKA K K 9 2 2.9446 783.4582 783.4521 392.7364 392.7334 783.4603 392.7374 -0.0081 0.0001384 24.869 16.973 1 2 1 160 168 0 0 TRUE sp|P10412|H14_HUMAN P10412 H14_HUMAN H1-4 Histone H1.4
20100611_Velos1_TaGe_SA_Hela_1.00005.00005.2 D:\Projects\Chimeras\Mann_11cell_analysis\Hela\MsFragger\Hela_1_1\interact-20100611_Velos1_TaGe_SA_Hela_1.pep.xml LGHASDR AYGQAIAK.LGHASDR.IIAIDGDT K I 7 2 4.1263 754.3708 754.3652 378.1927 378.1899 754.3722 378.1934 -0.007 0.1565 14.722 10.374 0.7358 2 0 328 334 0 0 FALSE sp|P29401|TKT_HUMAN P29401 TKT_HUMAN TKT Transketolase tr|A0A0B4J1R6|A0A0B4J1R6_HUMAN
20100611_Velos1_TaGe_SA_Hela_1.00009.00009.2 D:\Projects\Chimeras\Mann_11cell_analysis\Hela\MsFragger\Hela_1_1\interact-20100611_Velos1_TaGe_SA_Hela_1.pep.xml KAAGGATPK VGAAKKPK.KAAGGATPK.KSAKKTPK K K 9 2 8.8589 799.4532 799.4476 400.7339 400.7311 799.4551 400.7348 -0.0075 0.003204 22.564 14.018 0.9705 2 1 140 148 0 0 TRUE sp|P16403|H12_HUMAN P16403 H12_HUMAN H1-2 Histone H1.2
20100611_Velos1_TaGe_SA_Hela_1.00018.00018.2 D:\Projects\Chimeras\Mann_11cell_analysis\Hela\MsFragger\Hela_1_1\interact-20100611_Velos1_TaGe_SA_Hela_1.pep.xml VVTHGGR GTAIKNGK.VVTHGGR.VIAVTAIR K V 7 2 19.114 724.3984 724.3949 363.2065 363.2047 724.398 363.2063 -0.0031 0.7595 11.978 0 0.8144 2 0 379 385 0 0 TRUE sp|P22102|PUR2_HUMAN P22102 PUR2_HUMAN GART Trifunctional purine biosynthetic protein adenosine-3
41 changes: 36 additions & 5 deletions Test/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ public void TestPercolatorReadPsmsGetsRTsFromFileHeader()
Assert.AreEqual(6, ids.Count);

//strings separated by commas should be taken literally as protein names
Assert.AreEqual(11,ids[0].ProteinGroups.Count);
List<string> expectedProteinNameStrings = new() { "sp|Q13885|TBB2A_HUMAN", "tr|M0R1I1|M0R1I1_HUMAN", "tr|Q5JP53|Q5JP53_HUMAN",
"tr|M0QZL7|M0QZL7_HUMAN", "sp|P04350|TBB4A_HUMAN", "sp|P07437|TBB5_HUMAN", "sp|Q9BVA1|TBB2B_HUMAN", "tr|M0R278|M0R278_HUMAN",
Assert.AreEqual(11, ids[0].ProteinGroups.Count);
List<string> expectedProteinNameStrings = new() { "sp|Q13885|TBB2A_HUMAN", "tr|M0R1I1|M0R1I1_HUMAN", "tr|Q5JP53|Q5JP53_HUMAN",
"tr|M0QZL7|M0QZL7_HUMAN", "sp|P04350|TBB4A_HUMAN", "sp|P07437|TBB5_HUMAN", "sp|Q9BVA1|TBB2B_HUMAN", "tr|M0R278|M0R278_HUMAN",
"tr|Q5ST81|Q5ST81_HUMAN", "sp|P68371|TBB4B_HUMAN", "tr|M0QY85|M0QY85_HUMAN" };
CollectionAssert.AreEquivalent(ids[0].ProteinGroups.Select(n=>n.ProteinGroupName).ToList(), expectedProteinNameStrings);
CollectionAssert.AreEquivalent(ids[0].ProteinGroups.Select(n => n.ProteinGroupName).ToList(), expectedProteinNameStrings);

List<double> actualRetentionTimes = ids.Select(t => Math.Round(t.Ms2RetentionTimeInMinutes, 2)).ToList();

Expand Down Expand Up @@ -456,7 +456,7 @@ public static void TestParallelProcessingMetaMorpheusOutputWithExtensions()
File.Delete(proteinsPath);
}

[Test]
[Test]
public static void TestParallelProcessingMetaMorpheusOutputWithExtensionsAndWindowsPath()
{
string search = "Parallel";
Expand Down Expand Up @@ -652,5 +652,36 @@ public static void TestSettingsPassing()
Assert.That(settingsValue, Is.EqualTo(engineValue));
}
}

[Test]
[TestCase(@"SampleFiles\FraggerPsm_FragPipev21.1_psm.tsv")]
public static void TestReadPsmsValidMsFraggerPsmFile(string path)
{
// Arrange
var filePath = Path.Combine(TestContext.CurrentContext.TestDirectory, path);
Assert.That(File.Exists(filePath));
// this is a local file path only used for testing, do not try to access
string mzmlPath = @"D:\Projects\Chimeras\Mann_11cell_analysis\Hela\MsFragger\Hela_1_1\20100611_Velos1_TaGe_SA_Hela_1.mzML";
SpectraFileInfo sfi = new SpectraFileInfo(mzmlPath, "A", 1, 1, 1);
PsmReader psmReader = new();

// Act
List<Identification> ids = psmReader.ReadPsms(filePath, false, new List<SpectraFileInfo> { sfi });

// Assert
Assert.IsNotEmpty(ids);
Assert.That(ids.Count, Is.GreaterThan(0));
}

[Test]
public static void TestReadPsmsThrowsException()
{
// Arrange
string invalidFilePath = "NonExistentFile.psmtsv";
PsmReader psmReader = new();

// Act & Assert
Assert.DoesNotThrow(() => psmReader.ReadPsms(invalidFilePath, false, new List<SpectraFileInfo>()));
}
}
}
10 changes: 9 additions & 1 deletion Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>
<None Remove="SampleFiles\FraggerPsm_FragPipev21.1_psm.tsv" />
</ItemGroup>
<ItemGroup>
<Content Include="SampleFiles\FraggerPsm_FragPipev21.1_psm.tsv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="mzLib" Version="1.0.553" />
<PackageReference Include="mzLib" Version="2.0.7" />
<PackageReference Include="NetSerializer" Version="4.1.2" />
<PackageReference Include="nunit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
Expand Down
36 changes: 36 additions & 0 deletions Util/PsmReader.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using FlashLFQ;
using MzLibUtil;
using Readers;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using ThermoFisher.CommonCore.Data.Business;
using UsefulProteomicsDatabases;

namespace Util
Expand Down Expand Up @@ -58,8 +61,41 @@ public PsmReader()
{ PsmFileType.PeptideShaker, new string[] { ", " } },
};

// TODO:
// try to cast filetype as IQuantifiableResultFile
// var readResult as IQuantifiableResultFile
// 1. use Parsefiletype extension to get supported filetype enum
// 2. get ResultFile by passing in filePath and enum
// try cast resultFile to IQuantResultFile
private static List<Identification> TryReadQuantifiableResultFile(string filepath, bool silent, List<SpectraFileInfo> rawfiles)
{
try
{
IQuantifiableResultFile quantifiable = FileReader.ReadQuantifiableResultFile(filepath);
List<Identification> identifications = quantifiable.MakeIdentifications(rawfiles);
if (!silent)
{
Console.WriteLine("Done reading PSMs; found " + identifications.Count);
}
return identifications;
}
catch (Exception e)
{
// not every file read in will be a QuantifiableResultFile, support for this is still in development
}
return null;
}


public List<Identification> ReadPsms(string filepath, bool silent, List<SpectraFileInfo> rawfiles, double qValueThreshold = 0.01, bool usePepQValue = false)
{
// check if file path can be read in using readers as QuantifiableResultFile
List<Identification> quantifiableIdentifications = TryReadQuantifiableResultFile(filepath, silent, rawfiles);
if (quantifiableIdentifications != null)
{
return quantifiableIdentifications;
}

if (_modSequenceToMonoMass == null)
{
_modSequenceToMonoMass = new Dictionary<string, double>();
Expand Down
2 changes: 1 addition & 1 deletion Util/Util.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.7.82" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="mzLib" Version="1.0.553" />
<PackageReference Include="mzLib" Version="2.0.7" />
<PackageReference Include="NetSerializer" Version="4.1.2" />
<PackageReference Include="Nett" Version="0.15.0" />
</ItemGroup>
Expand Down
Loading