Open bernt-matthias opened 4 months ago
I will add a minimal working example.
small.raw
and small.data
are the same binary file, however, the latter cannot be opened by RawFileReaderFactory
using System.Security.Cryptography;
using ThermoFisher.CommonCore.Data;
using ThermoFisher.CommonCore.Data.Business;
namespace TestApp
{
class TestApp
{
static void Main()
{
TryOpen("small.raw");
TryOpen("small.data");
}
static void TryOpen(string path)
{
Console.WriteLine($"Working on {path}");
using (var md5 = MD5.Create())
{
using var stream = File.OpenRead(path);
var hash = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "");
Console.WriteLine($"MD5: {hash}");
}
using var rawFile = RawFileReaderFactory.ReadFile(path);
if (rawFile.IsOpen)
{
rawFile.SelectMsData();
Console.WriteLine($"Opened, {rawFile.RunHeaderEx.SpectraCount} spectra in the file");
}
else
{
Console.WriteLine("Cannot be openned");
}
}
}
}
Output:
Working on small.raw
MD5: 1B12C93735A9EAECD072031B2184D2ED
Opened, 48 spectra in the file
Working on small.data
MD5: 1B12C93735A9EAECD072031B2184D2ED
Cannot be openned
It seems that raw files can not be processed if they have a different file extension, e.g. https://github.com/compomics/ThermoRawFileParser/issues/180.
Since there are use cases that could benefit from this we are wondering if it is possible to read raw files even if they have a different extension.