Skip to content

Commit 099a11c

Browse files
committed
Advanced MSLevel filter
1 parent 42131e5 commit 099a11c

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

MainClass.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ private static void RegularParametersParsing(string[] args)
766766
if (parseInput.OutputFormat == OutputFormat.IndexMzML) parseInput.OutputFormat = OutputFormat.MzML;
767767
}
768768

769+
parseInput.MaxLevel = parseInput.MsLevel.Max();
770+
769771
if (parseInput.S3Url != null && parseInput.S3AccessKeyId != null &&
770772
parseInput.S3SecretAccessKey != null && parseInput.BucketName != null)
771773
if (Uri.IsWellFormedUriString(parseInput.S3Url, UriKind.Absolute))

ParseInput.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public int Warnings
9696

9797
public HashSet<int> MsLevel { get; set; }
9898

99+
public int MaxLevel { get; set; }
100+
99101
public bool MgfPrecursor { get; set; }
100102

101103
public bool NoiseData { get; set; }
@@ -136,6 +138,7 @@ public ParseInput()
136138
Vigilant = false;
137139
_errors = 0;
138140
_warnings = 0;
141+
MaxLevel = 10;
139142
}
140143

141144
public ParseInput(string rawFilePath, string rawDirectoryPath, string outputDirectory, OutputFormat outputFormat

Writer/MzMlSpectrumWriter.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,20 +401,23 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
401401

402402

403403
SpectrumType spectrum = null;
404+
int level;
404405

405406
try
406407
{
407-
spectrum = ConstructMSSpectrum(scanNumber);
408+
level = (int) _rawFile.GetScanEventForScanNumber(scanNumber).MSOrder; //applying MS level pre filter
409+
if (level <= ParseInput.MaxLevel)
410+
spectrum = ConstructMSSpectrum(scanNumber);
408411
}
409412
catch (Exception ex)
410413
{
411414
Log.Error($"Scan #{scanNumber} cannot be processed because of the following exception: {ex.Message}\n{ex.StackTrace}");
412415
ParseInput.NewError();
413416
}
414417

415-
var level = spectrum != null ? int.Parse(spectrum.cvParam.Where(p => p.accession == "MS:1000511").First().value) : 0;
418+
level = spectrum != null ? int.Parse(spectrum.cvParam.Where(p => p.accession == "MS:1000511").First().value) : 0;
416419

417-
if (spectrum != null && ParseInput.MsLevel.Contains(level)) //applying MS level filter
420+
if (spectrum != null && ParseInput.MsLevel.Contains(level)) //applying final MS filter
418421
{
419422
spectrum.index = index.ToString();
420423
if (_doIndexing)

0 commit comments

Comments
 (0)