44using System . IO ;
55using System . Linq ;
66using System . Reflection ;
7- using System . Web . WebSockets ;
87using log4net ;
98using Newtonsoft . Json ;
109using ThermoFisher . CommonCore . Data ;
@@ -122,16 +121,14 @@ public void WriteMetadata(IRawDataPlus rawFile, int firstScanNumber, int lastSca
122121 switch ( _parseInput . MetadataFormat )
123122 {
124123 case MetadataFormat . JSON :
125- _metadataFileName = _parseInput . MetadataOutputFile != null
126- ? _parseInput . MetadataOutputFile
127- : Path . Combine ( _parseInput . OutputDirectory , _parseInput . RawFileNameWithoutExtension ) +
124+ _metadataFileName = _parseInput . MetadataOutputFile ??
125+ Path . Combine ( _parseInput . OutputDirectory , _parseInput . RawFileNameWithoutExtension ) +
128126 "-metadata.json" ;
129127 WriteJsonMetada ( rawFile , firstScanNumber , lastScanNumber ) ;
130128 break ;
131129 case MetadataFormat . TXT :
132- _metadataFileName = _parseInput . MetadataOutputFile != null
133- ? _parseInput . MetadataOutputFile
134- : Path . Combine ( _parseInput . OutputDirectory , _parseInput . RawFileNameWithoutExtension ) +
130+ _metadataFileName = _parseInput . MetadataOutputFile ??
131+ Path . Combine ( _parseInput . OutputDirectory , _parseInput . RawFileNameWithoutExtension ) +
135132 "-metadata.txt" ;
136133 WriteTextMetadata ( rawFile , firstScanNumber , lastScanNumber ) ;
137134 break ;
@@ -176,43 +173,40 @@ private void WriteJsonMetada(IRawDataPlus rawFile, int firstScanNumber, int last
176173 metadata . addInstrumentProperty ( new CVTerm ( "AFR:0001259" , "AFO" , "firmware version" ,
177174 rawFile . GetInstrumentData ( ) . HardwareVersion ) ) ;
178175 }
179- }
180-
181176
182- // MS Data
183- foreach ( KeyValuePair < string , int > entry in msTypes )
184- {
185- if ( entry . Key . Equals ( MSOrderType . Ms . ToString ( ) ) )
186- metadata . addMSData ( new CVTerm ( "PRIDE:0000481" , "PRIDE" , "Number of MS1 spectra" ,
187- entry . Value . ToString ( ) ) ) ;
188- if ( entry . Key . Equals ( MSOrderType . Ms2 . ToString ( ) ) )
189- metadata . addMSData ( new CVTerm ( "PRIDE:0000482" , "PRIDE" , "Number of MS2 spectra" ,
190- entry . Value . ToString ( ) ) ) ;
191- if ( entry . Key . Equals ( MSOrderType . Ms3 . ToString ( ) ) )
192- metadata . addMSData ( new CVTerm ( "PRIDE:0000483" , "PRIDE" , "Number of MS3 spectra" ,
193- entry . Value . ToString ( ) ) ) ;
194- }
195-
196- metadata . addMSData ( new CVTerm ( "PRIDE:0000472" , "PRIDE" , "MS min charge" ,
197- minCharge . ToString ( CultureInfo . InvariantCulture ) ) ) ;
198- metadata . addMSData ( new CVTerm ( "PRIDE:0000473" , "PRIDE" , "MS max charge" ,
199- maxCharge . ToString ( CultureInfo . InvariantCulture ) ) ) ;
200-
201- metadata . addMSData ( new CVTerm ( "PRIDE:0000474" , "PRIDE" , "MS min RT" ,
202- minTime . ToString ( CultureInfo . InvariantCulture ) ) ) ;
203- metadata . addMSData ( new CVTerm ( "PRIDE:0000475" , "PRIDE" , "MS max RT" ,
204- maxTime . ToString ( CultureInfo . InvariantCulture ) ) ) ;
205-
206- metadata . addMSData ( new CVTerm ( "PRIDE:0000476" , "PRIDE" , "MS min MZ" ,
207- minMz . ToString ( CultureInfo . InvariantCulture ) ) ) ;
208- metadata . addMSData ( new CVTerm ( "PRIDE:0000477" , "PRIDE" , "MS max MZ" ,
209- maxMz . ToString ( CultureInfo . InvariantCulture ) ) ) ;
210-
211- // Scan Settings
212- // Get the start and end time from the RAW file
213-
214- if ( rawFile . SelectMsData ( ) )
215- {
177+
178+
179+ // MS Data
180+ foreach ( KeyValuePair < string , int > entry in msTypes )
181+ {
182+ if ( entry . Key . Equals ( MSOrderType . Ms . ToString ( ) ) )
183+ metadata . addMSData ( new CVTerm ( "PRIDE:0000481" , "PRIDE" , "Number of MS1 spectra" ,
184+ entry . Value . ToString ( ) ) ) ;
185+ if ( entry . Key . Equals ( MSOrderType . Ms2 . ToString ( ) ) )
186+ metadata . addMSData ( new CVTerm ( "PRIDE:0000482" , "PRIDE" , "Number of MS2 spectra" ,
187+ entry . Value . ToString ( ) ) ) ;
188+ if ( entry . Key . Equals ( MSOrderType . Ms3 . ToString ( ) ) )
189+ metadata . addMSData ( new CVTerm ( "PRIDE:0000483" , "PRIDE" , "Number of MS3 spectra" ,
190+ entry . Value . ToString ( ) ) ) ;
191+ }
192+
193+ metadata . addMSData ( new CVTerm ( "PRIDE:0000472" , "PRIDE" , "MS min charge" ,
194+ minCharge . ToString ( CultureInfo . InvariantCulture ) ) ) ;
195+ metadata . addMSData ( new CVTerm ( "PRIDE:0000473" , "PRIDE" , "MS max charge" ,
196+ maxCharge . ToString ( CultureInfo . InvariantCulture ) ) ) ;
197+
198+ metadata . addMSData ( new CVTerm ( "PRIDE:0000474" , "PRIDE" , "MS min RT" ,
199+ minTime . ToString ( CultureInfo . InvariantCulture ) ) ) ;
200+ metadata . addMSData ( new CVTerm ( "PRIDE:0000475" , "PRIDE" , "MS max RT" ,
201+ maxTime . ToString ( CultureInfo . InvariantCulture ) ) ) ;
202+
203+ metadata . addMSData ( new CVTerm ( "PRIDE:0000476" , "PRIDE" , "MS min MZ" ,
204+ minMz . ToString ( CultureInfo . InvariantCulture ) ) ) ;
205+ metadata . addMSData ( new CVTerm ( "PRIDE:0000477" , "PRIDE" , "MS max MZ" ,
206+ maxMz . ToString ( CultureInfo . InvariantCulture ) ) ) ;
207+
208+ // Scan Settings
209+ // Get the start and end time from the RAW file
216210 var runHeaderEx = rawFile . RunHeaderEx ;
217211 var startTime = runHeaderEx . StartTime ;
218212 var endTime = runHeaderEx . EndTime ;
@@ -373,21 +367,20 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
373367 {
374368 output . Add ( "Firmware version=" + rawFile . GetInstrumentData ( ) . HardwareVersion ) ;
375369 }
376- }
377-
378- // MS Data
379- output . Add ( "#MsData" ) ;
380- foreach ( KeyValuePair < string , int > entry in msTypes )
381- {
382- if ( entry . Key . Equals ( MSOrderType . Ms . ToString ( ) ) )
383- output . Add ( "Number of MS1 spectra=" + entry . Value ) ;
384- if ( entry . Key . Equals ( MSOrderType . Ms2 . ToString ( ) ) )
385- output . Add ( "Number of MS2 spectra=" + entry . Value ) ;
386- if ( entry . Key . Equals ( MSOrderType . Ms3 . ToString ( ) ) )
387- output . Add ( "Number of MS3 spectra=" + entry . Value ) ;
388- }
389370
390- output . AddRange ( new List < string >
371+ // MS Data
372+ output . Add ( "#MsData" ) ;
373+ foreach ( KeyValuePair < string , int > entry in msTypes )
374+ {
375+ if ( entry . Key . Equals ( MSOrderType . Ms . ToString ( ) ) )
376+ output . Add ( "Number of MS1 spectra=" + entry . Value ) ;
377+ if ( entry . Key . Equals ( MSOrderType . Ms2 . ToString ( ) ) )
378+ output . Add ( "Number of MS2 spectra=" + entry . Value ) ;
379+ if ( entry . Key . Equals ( MSOrderType . Ms3 . ToString ( ) ) )
380+ output . Add ( "Number of MS3 spectra=" + entry . Value ) ;
381+ }
382+
383+ output . AddRange ( new List < string >
391384 {
392385 $ "MS min charge={ minCharge . ToString ( CultureInfo . InvariantCulture ) } ",
393386 $ "MS max charge={ maxCharge . ToString ( CultureInfo . InvariantCulture ) } ",
@@ -396,11 +389,9 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
396389 $ "MS min MZ={ minMz . ToString ( CultureInfo . InvariantCulture ) } ",
397390 $ "MS max MZ={ maxMz . ToString ( CultureInfo . InvariantCulture ) } "
398391 }
399- ) ;
392+ ) ;
400393
401- // Scan Settings
402- if ( rawFile . SelectMsData ( ) )
403- {
394+ // Scan Settings
404395 // Get the start and end time from the RAW file
405396 var startTime = rawFile . RunHeaderEx . StartTime ;
406397 var endTime = rawFile . RunHeaderEx . EndTime ;
@@ -410,7 +401,7 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
410401 $ "Scan start time={ startTime . ToString ( CultureInfo . InvariantCulture ) } ",
411402 $ "Expected runtime={ rawFile . RunHeaderEx . ExpectedRunTime . ToString ( CultureInfo . InvariantCulture ) } ",
412403 $ "Mass resolution=[MS, MS:1000011, mass resolution, { rawFile . RunHeaderEx . MassResolution . ToString ( CultureInfo . InvariantCulture ) } ]",
413- "Units=" + rawFile . GetInstrumentData ( ) . Units ,
404+ $ "Units={ rawFile . GetInstrumentData ( ) . Units } " ,
414405 $ "Number of scans={ rawFile . RunHeaderEx . SpectraCount } ",
415406 $ "Scan range={ firstScanNumber } ;{ lastScanNumber } ",
416407 $ "Time range={ startTime . ToString ( CultureInfo . InvariantCulture ) } ;{ endTime . ToString ( CultureInfo . InvariantCulture ) } ",
@@ -419,6 +410,7 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
419410 }
420411 ) ;
421412 }
413+
422414 // Sample Data
423415 output . Add ( "#SampleData" ) ;
424416
0 commit comments