Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max quant reader #2262

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
46bbdcc
Added PsmGenericReader
Alexander-Sol Jan 12, 2023
c1017f0
Merge branch 'master' into MaxQuantReader
Alexander-Sol Jan 12, 2023
cc11030
Fixed erros in PsmGenericReader
Alexander-Sol Jan 12, 2023
6e76407
Started MaxQuantModParsing
Alexander-Sol Jan 19, 2023
5592167
Almost finished on FullSeq Parsing
Alexander-Sol Jan 20, 2023
7d30666
commit before reworking modpositions
Alexander-Sol Jan 23, 2023
7b6feeb
Fixed bug in ParseMaxQuantMod
Alexander-Sol Jan 23, 2023
bf6437f
Merge branch 'master' into MaxQuantReader
Alexander-Sol Jan 25, 2023
53bb803
Added ReadMbrPeaks function
Alexander-Sol Jan 26, 2023
0501639
Deleted test coverage data
Alexander-Sol Jan 26, 2023
3090156
Wrote MsmsHeader class, reader refactoring
Alexander-Sol Jan 26, 2023
1cf21e2
working on msms.txt reader
Alexander-Sol Jan 27, 2023
bc20efb
Finished test for MaxQuantFragmentReader
Alexander-Sol Jan 30, 2023
9a4154a
MaxQuant reader is finished. Results can be written to a spectral lib…
Alexander-Sol Jan 30, 2023
b32af2f
Fixed issue in MiniClassicSearchEngine where theoretical fragments we…
Alexander-Sol Jan 31, 2023
0756a5b
Switched from addRange to replacing value
Alexander-Sol Jan 31, 2023
4bd9253
Merge branch 'MiniClassicSearchFix' into MaxQuantReader
Alexander-Sol Jan 31, 2023
3b226cd
Succesful MbrAnalysis with MaxQuant results
Alexander-Sol Feb 2, 2023
f08d048
idk
Alexander-Sol Feb 10, 2023
b97505d
Merge branch 'master' into MaxQuantReader
Alexander-Sol Feb 13, 2023
682a492
Added option to ignore artifact ions
Alexander-Sol Feb 13, 2023
2552b60
finished datasets
Alexander-Sol Feb 20, 2023
3390bf0
Added things related to retention time shift
Alexander-Sol Feb 24, 2023
e3c45b2
Broke some things
Alexander-Sol Feb 24, 2023
4902d46
idk
Alexander-Sol Feb 27, 2023
9e57f22
Final data generated
Alexander-Sol Mar 3, 2023
d5ddb73
Ignoring tests with local file references
Alexander-Sol Mar 10, 2023
0fd4289
Temp commit
Alexander-Sol Mar 10, 2023
c97739e
Fixed merge conflicts
Alexander-Sol Mar 10, 2023
e6f0ec5
Added additional features in MbrAnalysis PeakQuant
Alexander-Sol Mar 10, 2023
56118f9
Added additional PeakQuant features
Alexander-Sol Mar 10, 2023
d53279e
Commented out TIC stuff
Alexander-Sol Mar 10, 2023
a61f294
Created ExtendedWriter class and associated test
Alexander-Sol Mar 11, 2023
9cdea31
Started ExtendedPeakQuantResults in postsearchanalysistask
Alexander-Sol Mar 11, 2023
f6daa36
Finished apex envelope calculations
Alexander-Sol Mar 11, 2023
98fafd2
Finished first draft of WriteExtendedPeakQuant, need to write tests
Alexander-Sol Mar 11, 2023
fdc8f55
Succesfully calculating and writing additional info for QuantPeaks
Alexander-Sol Mar 13, 2023
de06415
Fixed conflicts
Alexander-Sol Mar 13, 2023
bdb0d50
Finished writer
Alexander-Sol Mar 14, 2023
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
24 changes: 24 additions & 0 deletions MetaMorpheus/Bootstrapper/Bootstrapper - Backup.wixproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="WixToolset.Sdk/4.0.0-rc.2">
<PropertyGroup>
<OutputName>MetaMorpheusInstaller</OutputName>
<OutputType>Bundle</OutputType>
<Platforms>x64;ARM64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WixToolset.Util.wixext" Version="4.0.0-rc.2" />
<PackageReference Include="WixToolset.Bal.wixext" Version="4.0.0-rc.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MetaMorpheusSetup\MetaMorpheusSetup.wixproj">
<Name>MetaMorpheusSetup</Name>
<Project>{be72541a-66a4-4958-9d19-56acc7d3876b}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="theme.xml" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion MetaMorpheus/CMD/CMD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="Microsoft.ML.CpuMath" Version="2.0.0" />
<PackageReference Include="Microsoft.ML.FastTree" Version="2.0.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
<PackageReference Include="mzLib" Version="1.0.537" />
<PackageReference Include="mzLib" Version="5.1.538" />
<PackageReference Include="Nett" Version="0.15.0" />
</ItemGroup>

Expand Down
26 changes: 15 additions & 11 deletions MetaMorpheus/EngineLayer/ClassicSearch/MiniClassicSearchEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Easy.Common.Extensions;
using ThermoFisher.CommonCore.Data;

namespace EngineLayer.ClassicSearch
{
Expand All @@ -19,20 +21,23 @@ public class MiniClassicSearchEngine
private readonly double[] ArrayOfRTs;
private CommonParameters myCommonParameters;
private CommonParameters FileSpecificParameters;
private bool _maxQuantAnalysis;

public MiniClassicSearchEngine(
Ms2ScanWithSpecificMass[] arrayOfRTSortedMS2Scans,
MassDiffAcceptor searchMode,
CommonParameters commonParameters,
SpectralLibrary spectralLibrary,
CommonParameters fileSpecificParameters)
CommonParameters fileSpecificParameters,
bool maxQuantAnalysis = false)
{
MS2ByRetentionTime = arrayOfRTSortedMS2Scans;
ArrayOfRTs = MS2ByRetentionTime.Select(p => p.RetentionTime).ToArray();
SearchMode = searchMode;
SpectralLibrary = spectralLibrary;
myCommonParameters = commonParameters;
FileSpecificParameters = fileSpecificParameters ?? commonParameters;
_maxQuantAnalysis = maxQuantAnalysis;
// Each instance of MCSE will be specific to one file.
}

Expand Down Expand Up @@ -72,7 +77,7 @@ public IEnumerable<PeptideSpectralMatch> SearchAroundPeak(PeptideWithSetModifica
foreach (ScanWithIndexAndNotchInfo scan in acceptableScans)
{
var dissociationType = FileSpecificParameters.DissociationType == DissociationType.Autodetect ?
scan.TheScan.TheScan.DissociationType.Value : FileSpecificParameters.DissociationType;
scan.TheScan.TheScan.DissociationType.Value : FileSpecificParameters.DissociationType;

if (!targetFragmentsForEachDissociationType.TryGetValue(dissociationType, out var peptideTheorProducts))
{
Expand All @@ -98,17 +103,14 @@ public IEnumerable<PeptideSpectralMatch> SearchAroundPeak(PeptideWithSetModifica
}

IEnumerable<PeptideSpectralMatch> matchedSpectra = acceptablePsms.Where(p => p != null);
foreach (PeptideSpectralMatch psm in matchedSpectra)
{
psm.ResolveAllAmbiguities();
}
if (!_maxQuantAnalysis) foreach (PeptideSpectralMatch psm in matchedSpectra) psm.ResolveAllAmbiguities();

CalculateSpectralAngles(SpectralLibrary, acceptablePsms.ToArray(), GetScansInWindow(peakApexRT), myCommonParameters, FileSpecificParameters);

return matchedSpectra;
}

public static void CalculateSpectralAngles(SpectralLibrary spectralLibrary, PeptideSpectralMatch[] psms,
public void CalculateSpectralAngles(SpectralLibrary spectralLibrary, PeptideSpectralMatch[] psms,
Ms2ScanWithSpecificMass[] arrayOfSortedMs2Scans, CommonParameters commonParameters, CommonParameters fileSpecificParameters)
{
if (spectralLibrary != null)
Expand All @@ -124,7 +126,6 @@ public static void CalculateSpectralAngles(SpectralLibrary spectralLibrary, Pept
int[] threads = Enumerable.Range(0, maxThreadsPerFile).ToArray();
for (int i = 0; i < psms.Length; i++)
{

lock (myLocks[i])
{
if (psms[i] != null)
Expand All @@ -134,11 +135,14 @@ public static void CalculateSpectralAngles(SpectralLibrary spectralLibrary, Pept
List<double> pwsmSpectralAngles = new();
foreach (var (Notch, Peptide) in psms[i].BestMatchingPeptides)
{
bool decoy = _maxQuantAnalysis ? false : Peptide.Protein.IsDecoy;
//if peptide is target, directly look for the target's spectrum in the spectral library
if (!Peptide.Protein.IsDecoy && spectralLibrary.TryGetSpectrum(Peptide.FullSequence, scan.PrecursorCharge, out var librarySpectrum))
if (!decoy && spectralLibrary.TryGetSpectrum(Peptide.FullSequence, scan.PrecursorCharge, out var librarySpectrum))
{
SpectralSimilarity s = new SpectralSimilarity(scan.TheScan.MassSpectrum, librarySpectrum.XArray, librarySpectrum.YArray,
SpectralSimilarity.SpectrumNormalizationScheme.squareRootSpectrumSum, fileSpecificParameters.ProductMassTolerance.Value, false);
SpectralSimilarity s = new SpectralSimilarity(scan.TheScan.MassSpectrum,
librarySpectrum.XArray, librarySpectrum.YArray,
SpectralSimilarity.SpectrumNormalizationScheme.squareRootSpectrumSum,
fileSpecificParameters.ProductMassTolerance.Value, false);
if (s.SpectralContrastAngle().HasValue)
{
pwsms.Add((Notch, Peptide));
Expand Down
2 changes: 1 addition & 1 deletion MetaMorpheus/EngineLayer/EngineLayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.ML.CpuMath" Version="2.0.0" />
<PackageReference Include="Microsoft.ML.FastTree" Version="2.0.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="2.2.8" />
<PackageReference Include="mzLib" Version="1.0.537" />
<PackageReference Include="mzLib" Version="5.1.538" />
<PackageReference Include="NETStandard.Library" Version="2.0.3" />
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
Expand Down
15 changes: 14 additions & 1 deletion MetaMorpheus/EngineLayer/PeptideSpectralMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ public PeptideSpectralMatch(PeptideWithSetModifications peptide, int notch, doub
{
get
{
return _BestMatchingPeptides.OrderBy(p => p.Pwsm.FullSequence)
var sequenceOrderedPeptides = _BestMatchingPeptides.OrderBy(p => p.Pwsm.FullSequence);
if (sequenceOrderedPeptides.Any(p => p.Pwsm.Protein == null)) return sequenceOrderedPeptides;
return sequenceOrderedPeptides
.ThenBy(p => p.Pwsm.Protein.Accession)
.ThenBy(p => p.Pwsm.OneBasedStartResidueInProtein);
}
Expand Down Expand Up @@ -194,6 +196,17 @@ public void SetFdrValues(double cumulativeTarget, double cumulativeDecoy, double
/// </summary>
public void ResolveAllAmbiguities()
{
// Ad-hoc error handling for MaxQuant PsmFromTsv
if (_BestMatchingPeptides.Any(p => p.Pwsm.Protein == null))
{
FullSequence = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.FullSequence)).ResolvedValue;
BaseSequence = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.BaseSequence)).ResolvedValue;
PeptideLength = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.Length)).ResolvedValue;
PeptideMonisotopicMass = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.MonoisotopicMass)).ResolvedValue;
ModsIdentified = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.AllModsOneIsNterminus)).ResolvedValue;
ModsChemicalFormula = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.AllModsOneIsNterminus.Select(c => (c.Value)))).ResolvedValue;
return;
}
IsDecoy = _BestMatchingPeptides.Any(p => p.Pwsm.Protein.IsDecoy);
IsContaminant = _BestMatchingPeptides.Any(p => p.Pwsm.Protein.IsContaminant);
FullSequence = PsmTsvWriter.Resolve(_BestMatchingPeptides.Select(b => b.Pwsm.FullSequence)).ResolvedValue;
Expand Down
76 changes: 76 additions & 0 deletions MetaMorpheus/EngineLayer/PsmTsv/MaxQuantMsmsHeader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EngineLayer
{
public class MaxQuantMsmsHeader
{
// File and scan information
public const string FileName = "Raw file";
public const string Ms2ScanNumber = "Scan number";
public const string Ms2ScanRetentionTime = "Retention time";
//public const string NumExperimentalPeaks = "Number of Matches";
//public const string TotalIonCurrent = "Total Ion Current";
public const string PrecursorScanNum = "Precursor full scan number";
public const string PrecursorCharge = "Charge";
public const string PrecursorMz = "m/z";
public const string PrecursorMass = "Mass";
public const string Score = "Score";
public const string DeltaScore = "Delta score";
//public const string Notch = "Notch";

// Sequence information
public const string BaseSequence = "Sequence";
public const string FullSequence = "Modified sequence";
//public const string EssentialSequence = "Essential Sequence";
//public const string AmbiguityLevel = "Ambiguity Level";
//public const string PsmCount = "PSM Count (unambiguous, <0.01 q-value)";
public const string Mods = "Modifications";
//public const string ModsChemicalFormulas = "Mods Chemical Formulas";
//public const string ModsCombinedChemicalFormula = "Mods Combined Chemical Formula";
//public const string NumVariableMods = "Num Variable Mods";
//public const string MissedCleavages = "Missed Cleavages";
//public const string PeptideMonoMass = "Peptide Monoisotopic Mass";
public const string MassDiffDa = "Mass error [Da]";
public const string MassDiffPpm = "Mass error [ppm]";
public const string ProteinAccession = "Proteins";
public const string ProteinName = "Protein Names";
public const string GeneName = "Gene Names";
//public const string OrganismName = "Organism Name";
//public const string IntersectingSequenceVariations = "Intersecting Sequence Variations";
//public const string IdentifiedSequenceVariations = "Identified Sequence Variations";
//public const string SpliceSites = "Splice Sites";
//public const string Contaminant = "Contaminant";
public const string Decoy = "Reverse";
//public const string PeptideDesicription = "Peptide Description";
//public const string StartAndEndResiduesInProtein = "Start and End Residues In Protein";
//public const string PreviousAminoAcid = "Previous Amino Acid";
//public const string NextAminoAcid = "Next Amino Acid";
//public const string TheoreticalsSearched = "Theoreticals Searched";
//public const string DecoyContaminantTarget = "Decoy/Contaminant/Target";
public const string MatchedIonSeries = "Matches";
public const string MatchedIonMzRatios = "Masses";
public const string MatchedIonMassDiffDa = "Mass deviations [Da]";
public const string MatchedIonMassDiffPpm = "Mass deviations [ppm]";
public const string MatchedIonIntensities = "Intensities";
public const string MatchedIonCounts = "Number of matches";

// Scoring
public const string PEP = "PEP";
//public const string LocalizedScores = "Localized Scores";
//public const string ImprovementPossible = "Improvement Possible";
//public const string CumulativeTarget = "Cumulative Target";
//public const string CumulativeDecoy = "Cumulative Decoy";
//public const string CumulativeTargetNotch = "Cumulative Target Notch";
//public const string CumulativeDecoyNotch = "Cumulative Decoy Notch";
//public const string QValue = "QValue";
//public const string QValueNotch = "QValue Notch";
//public const string PEP_QValue = "PEP_QValue";
//public const string SpectralAngle = "Normalized Spectral Angle";


}
}
Loading