Skip to content

Commit

Permalink
.NET 6.0 (smith-chem-wisc#615)
Browse files Browse the repository at this point in the history
* net6.0

* merge upstream and update workflows

* use nuget pack not dotnet pack

* name

* setup nuget separately

* change release name back

* readme

* image before releases

* replace webclient with httpclient

* use multiline

* use line concatenation for a couple places

* no slash

* use &&

* break up steps more

* fix xml writer errors and such

* more fixes

* fix httpclient

* code cleanup

* add back comments

Co-authored-by: MICHAEL SHORTREED <[email protected]>
  • Loading branch information
acesnik and MICHAEL SHORTREED authored Apr 21, 2022
1 parent 3d0a4e4 commit b68aa96
Show file tree
Hide file tree
Showing 28 changed files with 135 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .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: 5.0.x
dotnet-version: 6.0.x
- name: Restore dependencies
run: cd mzLib && dotnet restore
- name: Build
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: 5.0.x
dotnet-version: 6.0.x
- name: Set up NuGet
uses: nuget/setup-nuget@v1
with:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

A library for mass spectrometry projects.


[![GitHub Action Builds](https://github.com/smith-chem-wisc/mzLib/actions/workflows/dotnet.yml/badge.svg)](https://github.com/smith-chem-wisc/mzLib/actions/workflows/dotnet.yml)
[![codecov](https://codecov.io/gh/smith-chem-wisc/mzLib/branch/master/graph/badge.svg)](https://codecov.io/gh/smith-chem-wisc/mzLib)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/10000/badge.svg)](https://scan.coverity.com/projects/mzlib)
Expand Down
2 changes: 1 addition & 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>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Platforms>x64</Platforms>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion mzLib/Chemistry/Chemistry.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
2 changes: 1 addition & 1 deletion 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>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Platforms>x64</Platforms>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion mzLib/MassSpectrometry/MassSpectrometry.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
2 changes: 1 addition & 1 deletion mzLib/Mgf/Mgf.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
2 changes: 1 addition & 1 deletion mzLib/MzIdentML/MzIdentML.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
2 changes: 1 addition & 1 deletion mzLib/MzLibUtil/MzLibUtil.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
17 changes: 7 additions & 10 deletions mzLib/MzLibUtil/TextFileReading.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.Reflection;
using System.Text;

namespace MzLibUtil
{
public static class TextFileReading
{
readonly static FieldInfo charPosField = typeof(StreamReader).GetField("_charPos", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
readonly static FieldInfo charLenField = typeof(StreamReader).GetField("_charLen", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
readonly static FieldInfo charBufferField = typeof(StreamReader).GetField("_charBuffer", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
private static readonly FieldInfo charPosField = typeof(StreamReader).GetField("_charPos", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
private static readonly FieldInfo charLenField = typeof(StreamReader).GetField("_charLen", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
private static readonly FieldInfo charBufferField = typeof(StreamReader).GetField("_charBuffer", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);

/// <summary>
/// The StreamReader object does not have a reliable method to get a byte position in
/// a file. This method calculates it.
///
///
/// Code from: https://stackoverflow.com/questions/10189270/tracking-the-position-of-the-line-of-a-streamreader/34744440
///
///
/// See also alternative method:
/// Code from: https://stackoverflow.com/questions/5404267/streamreader-and-seeking
/// </summary>
Expand All @@ -35,4 +32,4 @@ public static long GetByteOffsetAtCurrentPosition(StreamReader reader)
return reader.BaseStream.Position - reader.CurrentEncoding.GetByteCount(charBuffer, charPos, charLen - charPos);
}
}
}
}
2 changes: 1 addition & 1 deletion mzLib/MzML/MzML.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
10 changes: 4 additions & 6 deletions mzLib/MzML/Mzml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,10 @@ public static Mzml LoadAllStaticData(string filePath, FilteringParams filterPara
string sendCheckSum;
using (FileStream stream = File.OpenRead(filePath))
{
using (SHA1Managed sha = new SHA1Managed())
{
byte[] checksum = sha.ComputeHash(stream);
sendCheckSum = BitConverter.ToString(checksum)
.Replace("-", string.Empty);
}
SHA1 sha = SHA1.Create();
byte[] checksum = sha.ComputeHash(stream);
sendCheckSum = BitConverter.ToString(checksum)
.Replace("-", string.Empty);
}
sourceFile = new SourceFile(
@"no nativeID format",
Expand Down
15 changes: 6 additions & 9 deletions mzLib/MzML/MzmlMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Serialization;

namespace IO.MzML
Expand Down Expand Up @@ -974,12 +974,12 @@ public static void CreateAndWriteMyMzmlWithCalibratedSpectra(MsDataFile myMsData

if (!writeIndexed)
{
using (TextWriter writer = new StreamWriter(outputFile))
using (XmlWriter writer = XmlWriter.Create(outputFile, new() { NewLineChars = "\n", Indent = true }))
{
mzmlSerializer.Serialize(writer, mzML);
}
}
else if (writeIndexed)
else
{
Generated.indexedmzML indexedMzml = new Generated.indexedmzML();
indexedMzml.mzML = mzML;
Expand All @@ -992,9 +992,8 @@ public static void CreateAndWriteMyMzmlWithCalibratedSpectra(MsDataFile myMsData
};

// write the initial file to disk (just the mzML data in an indexedmzML wrapper, without the completed index)
using (TextWriter writer = new StreamWriter(outputFile))
using (XmlWriter writer = XmlWriter.Create(outputFile, new() { NewLineChars = "\n", Indent = true }))
{
writer.NewLine = NewLine;
indexedSerializer.Serialize(writer, indexedMzml);
}

Expand Down Expand Up @@ -1095,9 +1094,8 @@ public static void CreateAndWriteMyMzmlWithCalibratedSpectra(MsDataFile myMsData

// write file w/ correct index and temporary checksum
indexedMzml.fileChecksum = "0";
using (TextWriter writer = new StreamWriter(outputFile))
using (XmlWriter writer = XmlWriter.Create(outputFile, new() { NewLineChars = "\n", Indent = true }))
{
writer.NewLine = NewLine;
indexedSerializer.Serialize(writer, indexedMzml);
}

Expand All @@ -1106,9 +1104,8 @@ public static void CreateAndWriteMyMzmlWithCalibratedSpectra(MsDataFile myMsData
indexedMzml.fileChecksum = BitConverter.ToString(hash.Hash).Replace("-", string.Empty).ToLowerInvariant();

// write the final file w/ correct index and correct checksum
using (TextWriter writer = new StreamWriter(outputFile))
using (XmlWriter writer = XmlWriter.Create(outputFile, new() { NewLineChars = "\n", Indent = true }))
{
writer.NewLine = NewLine;
indexedSerializer.Serialize(writer, indexedMzml);
}
}
Expand Down
2 changes: 1 addition & 1 deletion mzLib/Proteomics/Proteomics.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
2 changes: 1 addition & 1 deletion mzLib/Test/DatabaseTests/TestDatabaseLoaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ public static void TestDownloadAvailableUniProtProteomes()
{
string filepath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"DatabaseTests");
string downloadedFilePath = ProteinDbRetriever.DownloadAvailableUniProtProteomes(filepath);
Assert.AreEqual(filepath + "\\availableUniProtProteomes.txt.gz", downloadedFilePath);
Assert.AreEqual(Path.Combine(filepath, "availableUniProtProteomes.txt.gz"), downloadedFilePath);

Dictionary<string, string> uniprotProteoms = ProteinDbRetriever.UniprotProteomesList(downloadedFilePath);

Expand Down
8 changes: 4 additions & 4 deletions mzLib/Test/Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>x64</Platforms>
</PropertyGroup>
Expand All @@ -13,9 +13,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions mzLib/Test/TestMsDataFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ public void TestAMoreRealFile()

var precursorScan = myMsDataFile.GetOneBasedScan(theScan.OneBasedPrecursorScanNumber.Value);
theScan.RefineSelectedMzAndIntensity(precursorScan.MassSpectrum);
Assert.AreEqual(.32872, theScan.SelectedIonIntensity, 0.01);
Assert.AreEqual(693.9892, theScan.SelectedIonMZ, 0.01);
Assert.AreEqual(693.655, theScan.SelectedIonMonoisotopicGuessMz, 0.001);
Assert.AreEqual(.32872, (double)theScan.SelectedIonIntensity, 0.01);
Assert.AreEqual(693.9892, (double)theScan.SelectedIonMZ, 0.01);
Assert.AreEqual(693.655, (double)theScan.SelectedIonMonoisotopicGuessMz, 0.001);

Assert.AreNotEqual(0, myMsDataFile.GetOneBasedScan(2).MassSpectrum.FirstX);

Expand Down
7 changes: 6 additions & 1 deletion mzLib/Test/TestRawFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static void TestLoadAllStaticDataRawFileReader(string infile, string outf
Mzml.LoadAllStaticData(outfile2);
Console.WriteLine($"Analysis time for TestLoadAllStaticDataRawFileReader({infile}): {stopwatch.Elapsed.Hours}h {stopwatch.Elapsed.Minutes}m {stopwatch.Elapsed.Seconds}s");
}

/// <summary>
/// Tests the dynamic connection for thermorawfilereader
/// </summary>
Expand Down Expand Up @@ -72,8 +73,9 @@ public static void TestDynamicConnectionRawFileReader()

Console.WriteLine($"Analysis time for TestDynamicConnectionRawFileReader: {stopwatch.Elapsed.Hours}h {stopwatch.Elapsed.Minutes}m {stopwatch.Elapsed.Seconds}s");
}

/// <summary>
/// Test Peak Filtering for ThermoRawFileReader
/// Tests peak filtering for ThermoRawFileReader
/// </summary>
/// <param name="infile"></param>
[Test]
Expand Down Expand Up @@ -122,6 +124,7 @@ public static void TestPeakFilteringRawFileReader(string infile)
Console.WriteLine($"Analysis time for TestPeakFilteringRawFileReader: {stopwatch.Elapsed.Hours}h " +
$"{stopwatch.Elapsed.Minutes}m {stopwatch.Elapsed.Seconds}s");
}

/// <summary>
/// Test Thermo License for ThermoRawFileReader
/// </summary>
Expand All @@ -136,6 +139,7 @@ public static void TestThermoLicence()

Console.WriteLine($"Analysis time for TestThermoLicence: {stopwatch.Elapsed.Hours}h {stopwatch.Elapsed.Minutes}m {stopwatch.Elapsed.Seconds}s");
}

/// <summary>
/// Test that raw files can be opened dynamically in ThermoRawFileReader
/// </summary>
Expand Down Expand Up @@ -202,6 +206,7 @@ public static void TestDynamicRaw(string fileName)
}
}
}

/// <summary>
/// Tests that you can read EtHCD files in ThermoRawFileReader
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions mzLib/TestFlashLFQ/TestFlashLFQ.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<IsPackable>false</IsPackable>
<Platforms>x64</Platforms>
</PropertyGroup>
Expand All @@ -13,9 +13,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 4 additions & 6 deletions mzLib/ThermoRawFileReader/ThermoRawFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ public static ThermoRawFileReader LoadAllStaticData(string filePath, IFilteringP
string sendCheckSum;
using (FileStream stream = File.OpenRead(filePath))
{
using (SHA1Managed sha = new SHA1Managed())
{
byte[] checksum = sha.ComputeHash(stream);
sendCheckSum = BitConverter.ToString(checksum)
.Replace("-", string.Empty);
}
SHA1 sha = SHA1.Create();
byte[] checksum = sha.ComputeHash(stream);
sendCheckSum = BitConverter.ToString(checksum)
.Replace("-", string.Empty);
}

SourceFile sourceFile = new SourceFile(
Expand Down
2 changes: 1 addition & 1 deletion mzLib/ThermoRawFileReader/ThermoRawFileReader.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

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

Expand Down
Loading

0 comments on commit b68aa96

Please sign in to comment.