@@ -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
@@ -1374,6 +1363,7 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
13741363 {
13751364 Log . Warn ( $ "Cannot find precursor scan for scan# { scanNumber } ") ;
13761365 _precursorTree [ - 2 ] = new PrecursorInfo ( 0 , msLevel , FindLastReaction ( scanEvent , msLevel ) , new PrecursorType [ 0 ] ) ;
1366+ ParseInput . NewWarn ( ) ;
13771367 }
13781368
13791369 try
@@ -1938,46 +1928,6 @@ private SpectrumType ConstructMSSpectrum(int scanNumber)
19381928
19391929 return spectrum ;
19401930 }
1941-
1942- private int FindLastReaction ( IScanEvent scanEvent , int msLevel )
1943- {
1944- int lastReactionIndex = msLevel - 2 ;
1945-
1946- //iteratively trying find the last available index for reaction
1947- while ( true )
1948- {
1949- try
1950- {
1951- scanEvent . GetReaction ( lastReactionIndex + 1 ) ;
1952- }
1953- catch ( ArgumentOutOfRangeException )
1954- {
1955- //stop trying
1956- break ;
1957- }
1958-
1959- lastReactionIndex ++ ;
1960- }
1961-
1962- //supplemental activation flag is on -> one of the levels (not necissirily the last one) used supplemental activation
1963- //check last two activations
1964- if ( scanEvent . SupplementalActivation == TriState . On )
1965- {
1966- var lastActivation = scanEvent . GetReaction ( lastReactionIndex ) . ActivationType ;
1967- var beforeLastActivation = scanEvent . GetReaction ( lastReactionIndex - 1 ) . ActivationType ;
1968-
1969- if ( ( beforeLastActivation == ActivationType . ElectronTransferDissociation || beforeLastActivation == ActivationType . ElectronCaptureDissociation ) &&
1970- ( lastActivation == ActivationType . CollisionInducedDissociation || lastActivation == ActivationType . HigherEnergyCollisionalDissociation ) )
1971- return lastReactionIndex - 1 ; //ETD or ECD followed by HCD or CID -> supplemental activation in the last level (move the last reaction one step back)
1972- else
1973- return lastReactionIndex ;
1974- }
1975- else //just use the last one
1976- {
1977- return lastReactionIndex ;
1978- }
1979- }
1980-
19811931 private SpectrumType ConstructPDASpectrum ( int scanNumber , int instrumentNumber )
19821932 {
19831933 // Get each scan from the RAW file
@@ -2558,29 +2508,6 @@ private PrecursorListType ConstructPrecursorList(int precursorScanNumber, IScanE
25582508
25592509 }
25602510
2561- private int GetParentFromScanString ( string scanString )
2562- {
2563- var parts = Regex . Split ( scanString , " " ) ;
2564-
2565- //find the position of the first (from the end) precursor with a different mass
2566- //to account for possible supplementary activations written in the filter
2567- var lastIonMass = parts . Last ( ) . Split ( '@' ) . First ( ) ;
2568- int last = parts . Length ;
2569- while ( last > 0 &&
2570- parts [ last - 1 ] . Split ( '@' ) . First ( ) == lastIonMass )
2571- {
2572- last -- ;
2573- }
2574-
2575- string parentFilter = String . Join ( " " , parts . Take ( last ) ) ;
2576- if ( _precursorScanNumbers . ContainsKey ( parentFilter ) )
2577- {
2578- return _precursorScanNumbers [ parentFilter ] ;
2579- }
2580-
2581- return - 2 ; //unsuccessful parsing
2582- }
2583-
25842511 /// <summary>
25852512 /// Populate the scan list element. Full version used for mass spectra,
25862513 /// having Scan Event, scan Filter etc
0 commit comments