Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
trishorts committed Nov 5, 2024
2 parents c9551e3 + e5cf73e commit e9d14c8
Show file tree
Hide file tree
Showing 165 changed files with 10,132 additions and 930 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: cd mzLib && dotnet restore
- name: Build
Expand All @@ -25,9 +25,9 @@ jobs:
- name: Build (TestFlashLFQ)
run: cd mzLib && dotnet build --no-restore ./TestFlashLFQ/TestFlashLFQ.csproj
- name: Add coverlet collector (Test)
run: cd mzLib && dotnet add Test/Test.csproj package coverlet.collector -v 6.0.0
run: cd mzLib && dotnet add Test/Test.csproj package coverlet.collector -v 6.0.2
- name: Add coverlet collector (TestFlashLFQ)
run: cd mzLib && dotnet add TestFlashLFQ/TestFlashLFQ.csproj package coverlet.collector -v 6.0.0
run: cd mzLib && dotnet add TestFlashLFQ/TestFlashLFQ.csproj package coverlet.collector -v 6.0.2
- name: Test
run: cd mzLib && dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" /p:CoverletOutputFormat=cobertura ./Test/Test.csproj
- name: TestFlashLFQ
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Set up NuGet
uses: nuget/setup-nuget@v1
with:
Expand Down
3 changes: 2 additions & 1 deletion mzLib/BayesianEstimation/BayesianEstimation.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Platforms>x64</Platforms>
</PropertyGroup>

Expand All @@ -11,6 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CsvHelper" Version="32.0.3" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
</ItemGroup>

Expand Down
4 changes: 3 additions & 1 deletion mzLib/Chemistry/ChemicalFormula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
using MzLibUtil;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;

namespace Chemistry
Expand Down Expand Up @@ -65,7 +67,7 @@ public ChemicalFormula(IHasChemicalFormula capFormula)
Elements = new Dictionary<Element, int>(capFormula.ThisChemicalFormula.Elements);
}

public ChemicalFormula ThisChemicalFormula => this;
[JsonIgnore] public ChemicalFormula ThisChemicalFormula => this;

/// <summary>
/// Gets the average mass of this chemical formula
Expand Down
6 changes: 5 additions & 1 deletion mzLib/Chemistry/Chemistry.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Platforms>x64</Platforms>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CsvHelper" Version="32.0.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\MzLibUtil\MzLibUtil.csproj" />
Expand Down
1 change: 1 addition & 0 deletions mzLib/Chemistry/ClassExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static double ToMass(this double massToChargeRatio, int charge)
return Math.Abs(charge) * massToChargeRatio - charge * Constants.ProtonMass;
}

public static double? RoundedDouble(this double myNumber, int places = 9) => RoundedDouble(myNumber as double?, places);
public static double? RoundedDouble(this double? myNumber, int places = 9)
{
if (myNumber != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MzLibUtil;
using NUnit.Framework;
using Assert = NUnit.Framework.Legacy.ClassicAssert;
using MassSpectrometry;
using System.Diagnostics.CodeAnalysis;
using Readers;
Expand Down
9 changes: 5 additions & 4 deletions mzLib/Development/Development.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Platforms>x64</Platforms>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="CsvHelper" Version="32.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
140 changes: 74 additions & 66 deletions mzLib/FlashLFQ/ChromatographicPeak.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,38 @@
using Chemistry;
using MathNet.Numerics.Statistics;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassExtensions = Chemistry.ClassExtensions;
using FlashLFQ.PEP;

namespace FlashLFQ
{
public class ChromatographicPeak
{
public double Intensity;
public double ApexRetentionTime => Apex?.IndexedPeak.RetentionTime ?? -1;
public readonly SpectraFileInfo SpectraFileInfo;
public List<IsotopicEnvelope> IsotopicEnvelopes;
public int ScanCount => IsotopicEnvelopes.Count;
public double SplitRT;
public readonly bool IsMbrPeak;
public double MbrScore;
public double PpmScore { get; set; }
public double IntensityScore { get; set; }
public double RtScore { get; set; }
public double ScanCountScore { get; set; }
public double IsotopicDistributionScore { get; set; }
/// <summary>
/// Stores the pearson correlation between the apex isotopic envelope and the theoretical isotopic distribution
/// </summary>
public double IsotopicPearsonCorrelation => Apex?.PearsonCorrelation ?? -1;
public double RtPredictionError { get; set; }
public List<int> ChargeList { get; set; }
internal double MbrQValue { get; set; }
public ChromatographicPeakData PepPeakData { get; set; }
public double? MbrPep { get; set; }

public ChromatographicPeak(Identification id, bool isMbrPeak, SpectraFileInfo fileInfo)
public ChromatographicPeak(Identification id, bool isMbrPeak, SpectraFileInfo fileInfo, bool randomRt = false)
{
SplitRT = 0;
NumChargeStatesObserved = 0;
Expand All @@ -27,6 +43,14 @@ public ChromatographicPeak(Identification id, bool isMbrPeak, SpectraFileInfo fi
IsotopicEnvelopes = new List<IsotopicEnvelope>();
IsMbrPeak = isMbrPeak;
SpectraFileInfo = fileInfo;
RandomRt = randomRt;
}

public bool Equals(ChromatographicPeak peak)
{
return SpectraFileInfo.Equals(peak.SpectraFileInfo)
&& Identifications.First().ModifiedSequence.Equals(peak.Identifications.First().ModifiedSequence)
&& ApexRetentionTime == peak.ApexRetentionTime;
}

public IsotopicEnvelope Apex { get; private set; }
Expand All @@ -36,70 +60,17 @@ public ChromatographicPeak(Identification id, bool isMbrPeak, SpectraFileInfo fi
public int NumIdentificationsByFullSeq { get; private set; }
public double MassError { get; private set; }
/// <summary>
/// Expected retention time for MBR acceptor peaks (mean)
/// Bool that describes whether the retention time of this peak was randomized
/// If true, implies that this peak is a decoy peak identified by the MBR algorithm
/// </summary>
public double? RtHypothesis { get; private set; }
/// <summary>
/// Std. Dev of retention time differences between MBR acceptor file and donor file, used if # calibration points < 6
/// </summary>
public double? RtStdDev { get; private set; }
/// <summary>
/// Interquartile range of retention time differences between MBR acceptor file and donor file, used if # calibration points >= 6
/// </summary>
public double? RtInterquartileRange { get; private set; }

public static string TabSeparatedHeader
{
get
{
var sb = new StringBuilder();
sb.Append("File Name" + "\t");
sb.Append("Base Sequence" + "\t");
sb.Append("Full Sequence" + "\t");
sb.Append("Protein Group" + "\t");
sb.Append("Peptide Monoisotopic Mass" + "\t");
sb.Append("MS2 Retention Time" + "\t");
sb.Append("Precursor Charge" + "\t");
sb.Append("Theoretical MZ" + "\t");
sb.Append("Peak intensity" + "\t");
sb.Append("Peak RT Start" + "\t");
sb.Append("Peak RT Apex" + "\t");
sb.Append("Peak RT End" + "\t");
sb.Append("Peak MZ" + "\t");
sb.Append("Peak Charge" + "\t");
sb.Append("Num Charge States Observed" + "\t");
sb.Append("Peak Detection Type" + "\t");
sb.Append("MBR Score" + "\t");
sb.Append("PSMs Mapped" + "\t");
sb.Append("Base Sequences Mapped" + "\t");
sb.Append("Full Sequences Mapped" + "\t");
sb.Append("Peak Split Valley RT" + "\t");
sb.Append("Peak Apex Mass Error (ppm)");
sb.Append("\tMBR Predicted RT");
//sb.Append("Timepoints");
return sb.ToString();
}
}

/// <summary>
/// Sets retention time information for a given peak. Used for MBR peaks
/// </summary>
/// <param name="rtHypothesis"> Expected retention time for peak, based on alignment between a donor and acceptor file </param>
/// <param name="rtStdDev"> Standard deviation in the retention time differences between aligned peaks </param>
/// <param name="rtInterquartileRange"> Interquartile range og the retention time differences between aligned peaks</param>
internal void SetRtWindow(double rtHypothesis, double? rtStdDev, double? rtInterquartileRange)
{
RtHypothesis = rtHypothesis;
RtStdDev = rtStdDev;
RtInterquartileRange = rtInterquartileRange;
}
public bool RandomRt { get; }
public bool DecoyPeptide => Identifications.First().IsDecoy;

public void CalculateIntensityForThisFeature(bool integrate)
{
if (IsotopicEnvelopes.Any())
{
double maxIntensity = IsotopicEnvelopes.Max(p => p.Intensity);
Apex = IsotopicEnvelopes.First(p => p.Intensity == maxIntensity);
Apex = IsotopicEnvelopes.MaxBy(p => p.Intensity);

if (integrate)
{
Expand Down Expand Up @@ -146,7 +117,7 @@ public void MergeFeatureWith(ChromatographicPeak otherFeature, bool integrate)
this.Identifications = this.Identifications
.Union(otherFeature.Identifications)
.Distinct()
.OrderBy(p => p.PosteriorErrorProbability).ToList();
.ToList();
ResolveIdentifications();
this.IsotopicEnvelopes.AddRange(otherFeature.IsotopicEnvelopes
.Where(p => !thisFeaturesPeaks.Contains(p.IndexedPeak)));
Expand All @@ -162,7 +133,40 @@ public void ResolveIdentifications()
this.NumIdentificationsByBaseSeq = Identifications.Select(v => v.BaseSequence).Distinct().Count();
this.NumIdentificationsByFullSeq = Identifications.Select(v => v.ModifiedSequence).Distinct().Count();
}

public static string TabSeparatedHeader
{
get
{
var sb = new StringBuilder();
sb.Append("File Name" + "\t");
sb.Append("Base Sequence" + "\t");
sb.Append("Full Sequence" + "\t");
sb.Append("Protein Group" + "\t");
sb.Append("Organism" + '\t');
sb.Append("Peptide Monoisotopic Mass" + "\t");
sb.Append("MS2 Retention Time" + "\t");
sb.Append("Precursor Charge" + "\t");
sb.Append("Theoretical MZ" + "\t");
sb.Append("Peak intensity" + "\t");
sb.Append("Peak RT Start" + "\t");
sb.Append("Peak RT Apex" + "\t");
sb.Append("Peak RT End" + "\t");
sb.Append("Peak MZ" + "\t");
sb.Append("Peak Charge" + "\t");
sb.Append("Num Charge States Observed" + "\t");
sb.Append("Peak Detection Type" + "\t");
sb.Append("PIP Q-Value" + "\t");
sb.Append("PIP PEP" + "\t");
sb.Append("PSMs Mapped" + "\t");
sb.Append("Base Sequences Mapped" + "\t");
sb.Append("Full Sequences Mapped" + "\t");
sb.Append("Peak Split Valley RT" + "\t");
sb.Append("Peak Apex Mass Error (ppm)" + "\t");
sb.Append("Decoy Peptide" + "\t");
sb.Append("Random RT");
return sb.ToString();
}
}
public override string ToString()
{
StringBuilder sb = new StringBuilder();
Expand Down Expand Up @@ -193,10 +197,12 @@ public override string ToString()
if (t.Any())
{
sb.Append(string.Join(";", t) + '\t');
sb.Append(string.Join(";", Identifications.SelectMany(id => id.ProteinGroups).Select(p => p.Organism).Distinct()) + '\t');
}
else
{
sb.Append("" + '\t');
sb.Append("" + '\t');
}

sb.Append("" + Identifications.First().MonoisotopicMass + '\t');
Expand Down Expand Up @@ -243,14 +249,16 @@ public override string ToString()
sb.Append("" + "MSMS" + "\t");
}

sb.Append("" + (IsMbrPeak ? MbrScore.ToString() : "") + "\t");
sb.Append("" + (IsMbrPeak ? MbrQValue.ToString() : "") + "\t");
sb.Append("" + (IsMbrPeak ? MbrPep.ToString() : "") + "\t");

sb.Append("" + Identifications.Count + "\t");
sb.Append("" + NumIdentificationsByBaseSeq + "\t");
sb.Append("" + NumIdentificationsByFullSeq + "\t");
sb.Append("" + SplitRT + "\t");
sb.Append("" + MassError);
sb.Append("\t" + (IsMbrPeak ? RtHypothesis.ToString() : ""));
sb.Append("\t" + DecoyPeptide);
sb.Append("\t" + RandomRt);

return sb.ToString();
}
Expand Down
7 changes: 5 additions & 2 deletions mzLib/FlashLFQ/FlashLFQ.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Platforms>x64</Platforms>
</PropertyGroup>

Expand All @@ -11,8 +11,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CsvHelper" Version="32.0.3" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="NetSerializer" Version="4.1.1" />
<PackageReference Include="Microsoft.ML" Version="3.0.1" />
<PackageReference Include="Microsoft.ML.FastTree" Version="3.0.1" />
<PackageReference Include="NetSerializer" Version="4.1.2" />
<PackageReference Include="SharpLearning.Optimization" Version="[0.28.0]" />
</ItemGroup>

Expand Down
Loading

0 comments on commit e9d14c8

Please sign in to comment.