Skip to content

Commit d68b4c7

Browse files
committed
Ignore not-Raw-files during folder processing
1 parent b7cc800 commit d68b4c7

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

RawFileParser.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Linq;
34
using ThermoFisher.CommonCore.Data;
45
using ThermoFisher.CommonCore.Data.Business;
56
using ThermoFisher.CommonCore.Data.Interfaces;
@@ -23,9 +24,10 @@ public static void Parse(ParseInput parseInput)
2324
{
2425
Log.Info("Started analyzing folder " + parseInput.RawDirectoryPath);
2526

26-
var rawFilesPath =
27-
Directory.EnumerateFiles(parseInput.RawDirectoryPath);
28-
if (Directory.GetFiles(parseInput.RawDirectoryPath, "*", SearchOption.TopDirectoryOnly).Length == 0)
27+
var rawFilesPath = Directory.EnumerateFiles(parseInput.RawDirectoryPath, "*", SearchOption.TopDirectoryOnly).Where(s => s.ToLower().EndsWith("raw")).ToArray();
28+
Log.Info(String.Format("The folder contains {0} RAW files", rawFilesPath.Length));
29+
30+
if (rawFilesPath.Length == 0)
2931
{
3032
Log.Debug("No raw files found in folder");
3133
throw new RawFileParserException("No raw files found in folder!");

ThermoRawFileParser.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
5757
<Prefer32Bit>false</Prefer32Bit>
5858
</PropertyGroup>
59+
<PropertyGroup>
60+
<StartupObject>ThermoRawFileParser.MainClass</StartupObject>
61+
</PropertyGroup>
5962
<ItemGroup>
6063
<Reference Include="AWS.Logger.Core, Version=1.4.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604">
6164
<HintPath>packages\AWS.Logger.Core.1.4.0\lib\net45\AWS.Logger.Core.dll</HintPath>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NOTRAWFILE

ThermoRawFileParserTest/WriterTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,25 @@ public void TestMgf()
3535
public void TestFolderMgfs()
3636
{
3737
// Get temp path for writing the test MGF
38-
var tempFilePath = Path.GetTempPath();
38+
var tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
39+
40+
Directory.CreateDirectory(tempFilePath);
3941

4042
var testRawFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data/TestFolderMgfs");
4143
var parseInput = new ParseInput(null, testRawFolder, tempFilePath, OutputFormat.MGF);
4244

4345
RawFileParser.Parse(parseInput);
4446

47+
var numfiles = Directory.GetFiles(tempFilePath, "*.mgf");
48+
Assert.AreEqual(numfiles.Length, 2);
49+
4550
var mgfData = Mgf.LoadAllStaticData(Path.Combine(tempFilePath, "small1.mgf"));
4651
Assert.AreEqual(34, mgfData.NumSpectra);
4752

4853
var mgfData2 = Mgf.LoadAllStaticData(Path.Combine(tempFilePath, "small2.mgf"));
4954
Assert.AreEqual(34, mgfData2.NumSpectra);
55+
56+
Directory.Delete(tempFilePath, true);
5057
}
5158

5259
[Test]

0 commit comments

Comments
 (0)