@@ -27,8 +27,6 @@ public class MzMlSpectrumWriter : SpectrumWriter
2727 private static readonly ILog Log =
2828 LogManager . GetLogger ( MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
2929
30- private readonly Regex _filterStringIsolationMzPattern = new Regex ( @"ms\d+ (.+?) \[" ) ;
31-
3230 // Tune version < 3 produces multiple trailer entry like "SPS Mass [number]"
3331 private readonly Regex _spSentry = new Regex ( @"SPS Mass\s+\d+:" ) ;
3432
@@ -45,12 +43,6 @@ public class MzMlSpectrumWriter : SpectrumWriter
4543 private readonly Dictionary < IonizationModeType , CVParamType > _ionizationTypes =
4644 new Dictionary < IonizationModeType , CVParamType > ( ) ;
4745
48- // Precursor scan number (value) and isolation m/z (key) for reference in the precursor element of an MSn spectrum
49- private readonly Dictionary < string , int > _precursorScanNumbers = new Dictionary < string , int > ( ) ;
50-
51- //Precursor information for scans
52- private Dictionary < int , PrecursorInfo > _precursorTree = new Dictionary < int , PrecursorInfo > ( ) ;
53-
5446 private const string SourceFileId = "RAW1" ;
5547 private readonly XmlSerializerFactory _factory = new XmlSerializerFactory ( ) ;
5648 private const string Ns = "http://psi.hupo.org/ms/mzml" ;
@@ -68,8 +60,6 @@ public MzMlSpectrumWriter(ParseInput parseInput) : base(parseInput)
6860 _mzMlNamespace . Add ( string . Empty , "http://psi.hupo.org/ms/mzml" ) ;
6961 _doIndexing = ParseInput . OutputFormat == OutputFormat . IndexMzML ;
7062 _osOffset = Environment . NewLine == "\n " ? 0 : 1 ;
71- _precursorScanNumbers [ "" ] = - 1 ;
72- _precursorTree [ - 1 ] = new PrecursorInfo ( ) ;
7363 }
7464
7565 /// <inheritdoc />
@@ -639,7 +629,6 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
639629
640630 _writer . WriteValue ( BitConverter . ToString ( hash ) . Replace ( "-" , "" ) . ToLowerInvariant ( ) ) ;
641631 _writer . WriteEndElement ( ) ; // fileChecksum
642-
643632 _writer . WriteEndElement ( ) ; // indexedmzML
644633 }
645634
@@ -652,21 +641,6 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
652641
653642 Writer . Flush ( ) ;
654643 Writer . Close ( ) ;
655-
656- //This section is not necessary?
657- /*if (_doIndexing)
658- {
659- try
660- {
661- cryptoStream.Flush();
662- cryptoStream.Close();
663- }
664- catch (System.ObjectDisposedException e)
665- {
666- // Cannot access a closed file. CryptoStream was already closed when closing _writer
667- Log.Warn($"Warning: {e.Message}");
668- }
669- }*/
670644 }
671645
672646 // In case of indexed mzML, change the extension from xml to mzML and check for the gzip option
@@ -1286,7 +1260,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
12861260 int ? charge = trailerData . AsPositiveInt ( "Charge State:" ) ;
12871261 double ? monoisotopicMz = trailerData . AsDouble ( "Monoisotopic M/Z:" ) ;
12881262 double ? ionInjectionTime = trailerData . AsDouble ( "Ion Injection Time (ms):" ) ;
1289- double ? isolationWidth = trailerData . AsDouble ( "MS" + ( int ) scanFilter . MSOrder + " Isolation Width:" ) ;
1263+ double ? isolationWidth = trailerData . AsDouble ( "MS" + msLevel + " Isolation Width:" ) ;
12901264 double ? FAIMSCV = null ;
12911265 if ( trailerData . AsBool ( "FAIMS Voltage On:" ) . GetValueOrDefault ( false ) )
12921266 FAIMSCV = trailerData . AsDouble ( "FAIMS CV:" ) ;
@@ -1374,6 +1348,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
13741348 {
13751349 Log . Warn ( $ "Cannot find precursor scan for scan# { scanNumber } ") ;
13761350 _precursorTree [ - 2 ] = new PrecursorInfo ( 0 , msLevel , FindLastReaction ( scanEvent , msLevel ) , new PrecursorType [ 0 ] ) ;
1351+ ParseInput . NewWarn ( ) ;
13771352 }
13781353
13791354 try
@@ -2011,46 +1986,6 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
20111986
20121987 return spectrum ;
20131988 }
2014-
2015- private int FindLastReaction ( IScanEvent scanEvent , int msLevel )
2016- {
2017- int lastReactionIndex = msLevel - 2 ;
2018-
2019- //iteratively trying find the last available index for reaction
2020- while ( true )
2021- {
2022- try
2023- {
2024- scanEvent . GetReaction ( lastReactionIndex + 1 ) ;
2025- }
2026- catch ( ArgumentOutOfRangeException )
2027- {
2028- //stop trying
2029- break ;
2030- }
2031-
2032- lastReactionIndex ++ ;
2033- }
2034-
2035- //supplemental activation flag is on -> one of the levels (not necissirily the last one) used supplemental activation
2036- //check last two activations
2037- if ( scanEvent . SupplementalActivation == TriState . On )
2038- {
2039- var lastActivation = scanEvent . GetReaction ( lastReactionIndex ) . ActivationType ;
2040- var beforeLastActivation = scanEvent . GetReaction ( lastReactionIndex - 1 ) . ActivationType ;
2041-
2042- if ( ( beforeLastActivation == ActivationType . ElectronTransferDissociation || beforeLastActivation == ActivationType . ElectronCaptureDissociation ) &&
2043- ( lastActivation == ActivationType . CollisionInducedDissociation || lastActivation == ActivationType . HigherEnergyCollisionalDissociation ) )
2044- return lastReactionIndex - 1 ; //ETD or ECD followed by HCD or CID -> supplemental activation in the last level (move the last reaction one step back)
2045- else
2046- return lastReactionIndex ;
2047- }
2048- else //just use the last one
2049- {
2050- return lastReactionIndex ;
2051- }
2052- }
2053-
20541989 private SpectrumType ConstructPDASpectrum ( int scanNumber , int instrumentNumber )
20551990 {
20561991 // Get each scan from the RAW file
@@ -2631,29 +2566,6 @@ private PrecursorListType ConstructPrecursorList(int precursorScanNumber, IScanE
26312566
26322567 }
26332568
2634- private int GetParentFromScanString ( string scanString )
2635- {
2636- var parts = Regex . Split ( scanString , " " ) ;
2637-
2638- //find the position of the first (from the end) precursor with a different mass
2639- //to account for possible supplementary activations written in the filter
2640- var lastIonMass = parts . Last ( ) . Split ( '@' ) . First ( ) ;
2641- int last = parts . Length ;
2642- while ( last > 0 &&
2643- parts [ last - 1 ] . Split ( '@' ) . First ( ) == lastIonMass )
2644- {
2645- last -- ;
2646- }
2647-
2648- string parentFilter = String . Join ( " " , parts . Take ( last ) ) ;
2649- if ( _precursorScanNumbers . ContainsKey ( parentFilter ) )
2650- {
2651- return _precursorScanNumbers [ parentFilter ] ;
2652- }
2653-
2654- return - 2 ; //unsuccessful parsing
2655- }
2656-
26572569 /// <summary>
26582570 /// Populate the scan list element. Full version used for mass spectra,
26592571 /// having Scan Event, scan Filter etc
0 commit comments