Skip to content

Commit baa1b6a

Browse files
mainclass refactoring
json validation addition ongoing
1 parent 94f1945 commit baa1b6a

45 files changed

Lines changed: 17038 additions & 302 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

MainClass.cs

Lines changed: 83 additions & 81 deletions
Large diffs are not rendered by default.

ParseInput.cs

Lines changed: 22 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ParseInput
1414
/// <summary>
1515
/// The RAW folder path.
1616
/// </summary>
17-
public string RawDirectoryPath { get; }
17+
public string RawDirectoryPath { get; set; }
1818

1919
public string RawFilePath
2020
{
@@ -34,50 +34,50 @@ public string RawFilePath
3434
/// <summary>
3535
/// The output directory.
3636
/// </summary>
37-
public string OutputDirectory { get; }
37+
public string OutputDirectory { get; set; }
3838

3939
/// <summary>
4040
/// The output file.
4141
/// </summary>>
42-
public string OutputFile { get; }
42+
public string OutputFile { get; set; }
4343

4444
/// <summary>
4545
/// The output format.
4646
/// </summary>
47-
public OutputFormat OutputFormat { get; }
47+
public OutputFormat OutputFormat { get; set; }
4848

4949
/// <summary>
50-
/// Output the metadata.
50+
/// The metadata output format.
5151
/// </summary>
52-
public MetadataFormat OutputMetadata { get; }
52+
public MetadataFormat MetadataFormat { get; set; }
5353

5454
/// <summary>
5555
/// The metadata output file.
5656
/// </summary>>
57-
public string MetadataOutputFile { get; }
57+
public string MetadataOutputFile { get; set; }
5858

5959
/// <summary>
6060
/// Gzip the output file.
6161
/// </summary>
62-
public bool Gzip { get; }
62+
public bool Gzip { get; set; }
6363

64-
public bool NoPeakPicking { get; }
64+
public bool NoPeakPicking { get; set; }
6565

66-
public bool NoZlibCompression { get; }
66+
public bool NoZlibCompression { get; set; }
6767

68-
public LogFormat LogFormat { get; }
68+
public LogFormat LogFormat { get; set; }
6969

70-
public bool IgnoreInstrumentErrors { get; }
70+
public bool IgnoreInstrumentErrors { get; set; }
7171

7272
private S3Loader S3Loader { get; set; }
7373

74-
private string S3AccessKeyId { get; }
74+
public string S3AccessKeyId { get; set; }
7575

76-
private string S3SecretAccessKey { get; }
76+
public string S3SecretAccessKey { get; set; }
7777

78-
private string S3url { get; }
78+
public string S3Url { get; set; }
7979

80-
private readonly string bucketName;
80+
public string BucketName { get; set; }
8181

8282
/// <summary>
8383
/// The raw file name.
@@ -89,76 +89,28 @@ public string RawFilePath
8989
/// </summary>
9090
public string RawFileNameWithoutExtension { get; private set; }
9191

92-
public ParseInput(string rawFilePath, string rawDirectoryPath, string outputDirectory, string outputFile,
93-
OutputFormat outputFormat
94-
)
92+
public ParseInput()
9593
{
96-
RawFilePath = rawFilePath;
97-
RawDirectoryPath = rawDirectoryPath;
98-
OutputDirectory = outputDirectory;
99-
OutputFile = outputFile;
100-
OutputFormat = outputFormat;
101-
OutputMetadata = MetadataFormat.NONE;
94+
MetadataFormat = MetadataFormat.NONE;
10295
Gzip = false;
10396
NoPeakPicking = false;
10497
NoZlibCompression = false;
10598
LogFormat = LogFormat.DEFAULT;
10699
IgnoreInstrumentErrors = false;
107-
108-
if (S3url != null && S3AccessKeyId != null && S3SecretAccessKey != null && bucketName != null)
109-
if (Uri.IsWellFormedUriString(S3url, UriKind.Absolute))
110-
{
111-
InitializeS3Bucket();
112-
}
113-
else
114-
{
115-
throw new RawFileParserException("Invalid S3 url: " + S3url);
116-
}
117-
118-
if (OutputDirectory == null && OutputFile != null)
119-
OutputDirectory = Path.GetDirectoryName(OutputFile);
120100
}
121101

122-
public ParseInput(string rawFilePath, string rawDirectoryPath, string outputDirectory, string outputFile,
123-
OutputFormat outputFormat, MetadataFormat outputMetadata, string metadataOutputFile, bool gzip,
124-
bool noPeakPicking, bool noZlibCompression, LogFormat logFormat, bool ignoreInstrumentErrors, string s3url,
125-
string s3AccessKeyId, string s3SecretAccessKey, string bucketName
126-
)
102+
public ParseInput(string rawFilePath, string rawDirectoryPath, string outputDirectory, OutputFormat outputFormat
103+
) : this()
127104
{
128105
RawFilePath = rawFilePath;
129106
RawDirectoryPath = rawDirectoryPath;
130107
OutputDirectory = outputDirectory;
131-
OutputFile = outputFile;
132108
OutputFormat = outputFormat;
133-
OutputMetadata = outputMetadata;
134-
MetadataOutputFile = metadataOutputFile;
135-
Gzip = gzip;
136-
NoPeakPicking = noPeakPicking;
137-
NoZlibCompression = noZlibCompression;
138-
LogFormat = logFormat;
139-
IgnoreInstrumentErrors = ignoreInstrumentErrors;
140-
S3url = s3url;
141-
S3AccessKeyId = s3AccessKeyId;
142-
S3SecretAccessKey = s3SecretAccessKey;
143-
this.bucketName = bucketName;
144-
145-
if (S3url != null && S3AccessKeyId != null && S3SecretAccessKey != null && bucketName != null)
146-
if (Uri.IsWellFormedUriString(S3url, UriKind.Absolute))
147-
{
148-
InitializeS3Bucket();
149-
}
150-
else
151-
{
152-
throw new RawFileParserException("Invalid S3 url: " + S3url);
153-
}
154-
155-
if (OutputDirectory == null && OutputFile != null)
156-
OutputDirectory = Path.GetDirectoryName(OutputFile);
157109
}
158110

159-
private void InitializeS3Bucket()
111+
public void InitializeS3Bucket()
160112
{
161-
S3Loader = new S3Loader(S3url, S3AccessKeyId, S3SecretAccessKey, bucketName);
113+
S3Loader = new S3Loader(S3Url, S3AccessKeyId, S3SecretAccessKey, BucketName);
162114
}
163115
}
164116
}

RawFileParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private static void ProcessFile(ParseInput parseInput)
103103
var firstScanNumber = rawFile.RunHeaderEx.FirstSpectrum;
104104
var lastScanNumber = rawFile.RunHeaderEx.LastSpectrum;
105105

106-
if (parseInput.OutputMetadata != MetadataFormat.NONE)
106+
if (parseInput.MetadataFormat != MetadataFormat.NONE)
107107
{
108108
MetadataWriter metadataWriter;
109109
if (parseInput.MetadataOutputFile != null)
@@ -116,7 +116,7 @@ private static void ProcessFile(ParseInput parseInput)
116116
parseInput.RawFileNameWithoutExtension);
117117
}
118118

119-
switch (parseInput.OutputMetadata)
119+
switch (parseInput.MetadataFormat)
120120
{
121121
case MetadataFormat.JSON:
122122
metadataWriter.WriteJsonMetada(rawFile, firstScanNumber, lastScanNumber);

ThermoRawFileParser.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
<HintPath>packages\Parquet.Net.2.0.0\lib\net451\Parquet.dll</HintPath>
9797
</Reference>
9898
<Reference Include="System" />
99+
<Reference Include="System.ComponentModel.DataAnnotations" />
99100
<Reference Include="System.Core" />
100101
<Reference Include="System.Numerics" />
101102
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

ThermoRawFileParserTest/ThermoRawFileParserTest.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
<HintPath>..\packages\mzLib.1.0.450\lib\net471\Chemistry.dll</HintPath>
5656
<Private>True</Private>
5757
</Reference>
58+
<Reference Include="DotLiquid, Version=2.0.314.0, Culture=neutral, PublicKeyToken=82e46016ecf9f07c">
59+
<HintPath>..\packages\DotLiquid.2.0.314\lib\net45\DotLiquid.dll</HintPath>
60+
<Private>True</Private>
61+
</Reference>
5862
<Reference Include="DotNetZip, Version=1.13.3.0, Culture=neutral, PublicKeyToken=6583c7c814667745">
5963
<HintPath>..\packages\DotNetZip.1.13.3\lib\net40\DotNetZip.dll</HintPath>
6064
<Private>True</Private>
@@ -79,6 +83,7 @@
7983
<HintPath>..\packages\mzLib.1.0.450\lib\net471\Mgf.dll</HintPath>
8084
<Private>True</Private>
8185
</Reference>
86+
<Reference Include="Microsoft.CSharp" />
8287
<Reference Include="MzIdentML, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
8388
<HintPath>..\packages\mzLib.1.0.450\lib\net471\MzIdentML.dll</HintPath>
8489
<Private>True</Private>
@@ -91,10 +96,18 @@
9196
<HintPath>..\packages\mzLib.1.0.450\lib\net471\MzML.dll</HintPath>
9297
<Private>True</Private>
9398
</Reference>
99+
<Reference Include="Namotion.Reflection, Version=1.0.8.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102">
100+
<HintPath>..\packages\Namotion.Reflection.1.0.8\lib\net45\Namotion.Reflection.dll</HintPath>
101+
<Private>True</Private>
102+
</Reference>
94103
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed">
95104
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
96105
<Private>True</Private>
97106
</Reference>
107+
<Reference Include="NJsonSchema, Version=10.1.4.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102">
108+
<HintPath>..\packages\NJsonSchema.10.1.4\lib\net45\NJsonSchema.dll</HintPath>
109+
<Private>True</Private>
110+
</Reference>
98111
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb">
99112
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
100113
<Private>True</Private>
@@ -114,9 +127,11 @@
114127
<Reference Include="System" />
115128
<Reference Include="System.Core" />
116129
<Reference Include="System.Data" />
130+
<Reference Include="System.Net" />
117131
<Reference Include="System.Numerics" />
118132
<Reference Include="System.Runtime.Serialization" />
119133
<Reference Include="System.Xml" />
134+
<Reference Include="System.Xml.Linq" />
120135
<Reference Include="ThermoFisher.CommonCore.BackgroundSubtraction, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1aef06afb5abd953">
121136
<HintPath>..\packages\mzLib.1.0.450\lib\net471\ThermoFisher.CommonCore.BackgroundSubtraction.dll</HintPath>
122137
<Private>True</Private>

ThermoRawFileParserTest/WriterTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void TestMgf()
1919
var tempFilePath = Path.GetTempPath();
2020

2121
var testRawFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"small.RAW");
22-
var parseInput = new ParseInput(testRawFile, null, tempFilePath, null, OutputFormat.MGF);
22+
var parseInput = new ParseInput(testRawFile, null, tempFilePath, OutputFormat.MGF);
2323

2424
RawFileParser.Parse(parseInput);
2525

@@ -34,7 +34,7 @@ public void TestFolderMgfs()
3434
var tempFilePath = Path.GetTempPath();
3535

3636
var testRawFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"TestFolderMgfs");
37-
var parseInput = new ParseInput(null, testRawFolder, tempFilePath, null, OutputFormat.MGF);
37+
var parseInput = new ParseInput(null, testRawFolder, tempFilePath, OutputFormat.MGF);
3838

3939
RawFileParser.Parse(parseInput);
4040

@@ -52,7 +52,7 @@ public void TestMzml()
5252
var tempFilePath = Path.GetTempPath();
5353

5454
var testRawFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"small.RAW");
55-
var parseInput = new ParseInput(testRawFile, null, tempFilePath, null, OutputFormat.MzML);
55+
var parseInput = new ParseInput(testRawFile, null, tempFilePath, OutputFormat.MzML);
5656

5757
RawFileParser.Parse(parseInput);
5858

@@ -77,7 +77,7 @@ public void TestIndexedMzML()
7777
Console.WriteLine(tempFilePath);
7878

7979
var testRawFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"small.RAW");
80-
var parseInput = new ParseInput(testRawFile, null, tempFilePath, null, OutputFormat.IndexMzML);
80+
var parseInput = new ParseInput(testRawFile, null, tempFilePath, OutputFormat.IndexMzML);
8181

8282
RawFileParser.Parse(parseInput);
8383

0 commit comments

Comments
 (0)