@@ -227,20 +227,20 @@ private void WriteJsonMetada(IRawDataPlus rawFile, int firstScanNumber, int last
227227 // Sample Data
228228 if ( ! rawFile . SampleInformation . SampleName . IsNullOrEmpty ( ) )
229229 {
230- metadata . addSampleProperty ( new CVTerm ( "MS:1000002" , "MS" , "Sample Name " ,
230+ metadata . addSampleProperty ( new CVTerm ( "MS:1000002" , "MS" , "sample name " ,
231231 rawFile . SampleInformation . SampleName ) ) ;
232232 }
233233
234234 if ( ! rawFile . SampleInformation . SampleId . IsNullOrEmpty ( ) )
235235 {
236- metadata . addSampleProperty ( new CVTerm ( "MS:1000001" , "MS" , "Sample Number " ,
236+ metadata . addSampleProperty ( new CVTerm ( "MS:1000001" , "MS" , "sample number " ,
237237 rawFile . SampleInformation . SampleId ) ) ;
238238 }
239239
240240 if ( ! rawFile . SampleInformation . SampleType . ToString ( ) . IsNullOrEmpty ( ) &&
241241 ! rawFile . SampleInformation . SampleType . ToString ( ) . Equals ( "Unknown" ) )
242242 {
243- metadata . addSampleProperty ( new CVTerm ( "NCIT:C25284" , "NCIT" , "Sample Type" ,
243+ metadata . addSampleProperty ( new CVTerm ( "NCIT:C25284" , "NCIT" , "Type" ,
244244 rawFile . SampleInformation . SampleType . ToString ( ) ) ) ;
245245 }
246246
@@ -258,13 +258,13 @@ private void WriteJsonMetada(IRawDataPlus rawFile, int firstScanNumber, int last
258258
259259 if ( rawFile . SampleInformation . SampleVolume != 0 )
260260 {
261- metadata . addSampleProperty ( new CVTerm ( "MS:1000005" , "MS" , "Sample Volume " ,
261+ metadata . addSampleProperty ( new CVTerm ( "MS:1000005" , "MS" , "sample volume " ,
262262 rawFile . SampleInformation . SampleVolume . ToString ( CultureInfo . InvariantCulture ) ) ) ;
263263 }
264264
265265 if ( rawFile . SampleInformation . InjectionVolume != 0 )
266266 {
267- metadata . addSampleProperty ( new CVTerm ( "AFR:0001577" , "AFO" , "Injection Volume " ,
267+ metadata . addSampleProperty ( new CVTerm ( "AFR:0001577" , "AFO" , "injection volume setting " ,
268268 rawFile . SampleInformation . InjectionVolume . ToString ( CultureInfo . InvariantCulture ) ) ) ;
269269 }
270270
@@ -276,53 +276,48 @@ private void WriteJsonMetada(IRawDataPlus rawFile, int firstScanNumber, int last
276276
277277 if ( rawFile . SampleInformation . DilutionFactor != 0 )
278278 {
279- metadata . addSampleProperty ( new CVTerm ( "AFQ:0000178" , "AFO" , "Dilution Factor " ,
279+ metadata . addSampleProperty ( new CVTerm ( "AFQ:0000178" , "AFO" , "dilution factor " ,
280280 rawFile . SampleInformation . DilutionFactor . ToString ( CultureInfo . InvariantCulture ) ) ) ;
281281 }
282282
283283 if ( ! rawFile . SampleInformation . InstrumentMethodFile . IsNullOrEmpty ( ) )
284284 {
285- metadata . addSampleProperty ( new CVTerm ( "AFR:0002045" , "AFO" , "Device Acquisition Method " , rawFile . SampleInformation . InstrumentMethodFile ) ) ;
285+ metadata . addSampleProperty ( new CVTerm ( "AFR:0002045" , "AFO" , "device acquisition method " , rawFile . SampleInformation . InstrumentMethodFile ) ) ;
286286 }
287287
288288 if ( rawFile . SampleInformation . IstdAmount != 0 )
289289 {
290- metadata . addSampleProperty ( new CVTerm ( "" , "" , "Internal Standard Amount " , rawFile . SampleInformation . IstdAmount . ToString ( ) ) ) ;
290+ metadata . addSampleProperty ( new CVTerm ( "" , "" , "internal standard amount " , rawFile . SampleInformation . IstdAmount . ToString ( ) ) ) ;
291291 }
292292
293293 if ( ! rawFile . SampleInformation . CalibrationLevel . IsNullOrEmpty ( ) )
294294 {
295- metadata . addSampleProperty ( new CVTerm ( "AFR:0001849" , "AFO" , "Calibration Level " , rawFile . SampleInformation . CalibrationLevel ) ) ;
295+ metadata . addSampleProperty ( new CVTerm ( "AFR:0001849" , "AFO" , "calibration level " , rawFile . SampleInformation . CalibrationLevel ) ) ;
296296 }
297297
298298 if ( ! rawFile . SampleInformation . ProcessingMethodFile . IsNullOrEmpty ( ) )
299299 {
300- metadata . addSampleProperty ( new CVTerm ( "AFR:0002175" , "AFO" , "Data Processing Method " , rawFile . SampleInformation . ProcessingMethodFile ) ) ;
300+ metadata . addSampleProperty ( new CVTerm ( "AFR:0002175" , "AFO" , "data processing method " , rawFile . SampleInformation . ProcessingMethodFile ) ) ;
301301 }
302302
303303 if ( rawFile . SampleInformation . SampleWeight != 0 )
304304 {
305- metadata . addSampleProperty ( new CVTerm ( "" , "" , "Sample Weight " , rawFile . SampleInformation . SampleWeight . ToString ( ) ) ) ;
305+ metadata . addSampleProperty ( new CVTerm ( "AFR:0001982 " , "AFO " , "sample weight " , rawFile . SampleInformation . SampleWeight . ToString ( ) ) ) ;
306306 }
307307
308308 string [ ] userLabels = rawFile . UserLabel ;
309309 string [ ] userTexts = rawFile . SampleInformation . UserText ;
310310 if ( ! userLabels . IsNullOrEmpty ( ) && ! userTexts . IsNullOrEmpty ( ) )
311311 {
312- if ( userLabels . Length > userTexts . Length )
313- {
314- throw new RawFileParserException ( ) ;
315- }
316312 for ( int i = 0 ; i < userLabels . Length ; i ++ )
317313 {
318- if ( ! userTexts [ i ] . IsNullOrEmpty ( ) )
314+ if ( i < userTexts . Length && ! userTexts [ i ] . IsNullOrEmpty ( ) )
319315 {
320316 metadata . addSampleProperty ( new CVTerm ( "" , "" , userLabels [ i ] , userTexts [ i ] ) ) ;
321317 }
322318 }
323319 }
324320
325-
326321 // Write the meta data to file
327322 var json = JsonConvert . SerializeObject ( metadata ) ;
328323 json . Replace ( "\r \n " , "\n " ) ;
@@ -346,7 +341,7 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
346341 var output = new List < string >
347342 {
348343 "#FileProperties" ,
349- "RAW File Path =" + rawFile . FileName ,
344+ "RAW file path =" + rawFile . FileName ,
350345 "RAW file version=" + rawFile . FileHeader . Revision ,
351346 "Creation date=" + rawFile . FileHeader . CreationDate
352347 } ;
@@ -413,86 +408,82 @@ private void WriteTextMetadata(IRawDataPlus rawFile, int firstScanNumber, int la
413408
414409 if ( ! rawFile . SampleInformation . SampleName . IsNullOrEmpty ( ) )
415410 {
416- output . Add ( "Sample Name =" + rawFile . SampleInformation . SampleName ) ;
411+ output . Add ( "Sample name =" + rawFile . SampleInformation . SampleName ) ;
417412 }
418413
419414 if ( ! rawFile . SampleInformation . SampleId . IsNullOrEmpty ( ) )
420415 {
421- output . Add ( "Sample Number =" + rawFile . SampleInformation . SampleId ) ;
416+ output . Add ( "Sample id =" + rawFile . SampleInformation . SampleId ) ;
422417 }
423418
424419 if ( ! rawFile . SampleInformation . SampleType . ToString ( ) . IsNullOrEmpty ( ) &&
425420 ! rawFile . SampleInformation . SampleType . ToString ( ) . Equals ( "Unknown" ) )
426421 {
427- output . Add ( "Sample Type =" + rawFile . SampleInformation . SampleType ) ;
422+ output . Add ( "Sample type =" + rawFile . SampleInformation . SampleType ) ;
428423 }
429424
430425 if ( ! rawFile . SampleInformation . Comment . IsNullOrEmpty ( ) )
431426 {
432- output . Add ( "Comment =" + rawFile . SampleInformation . Comment ) ;
427+ output . Add ( "Sample comment =" + rawFile . SampleInformation . Comment ) ;
433428 }
434429
435430 if ( ! rawFile . SampleInformation . Vial . IsNullOrEmpty ( ) )
436431 {
437- output . Add ( "Vial =" + rawFile . SampleInformation . Vial ) ;
432+ output . Add ( "Sample vial =" + rawFile . SampleInformation . Vial ) ;
438433 }
439434
440435 if ( rawFile . SampleInformation . SampleVolume != 0 )
441436 {
442- output . Add ( "Sample Volume =" + rawFile . SampleInformation . SampleVolume ) ;
437+ output . Add ( "Sample volume =" + rawFile . SampleInformation . SampleVolume ) ;
443438 }
444439
445440 if ( rawFile . SampleInformation . InjectionVolume != 0 )
446441 {
447- output . Add ( "Injection Volume =" + rawFile . SampleInformation . InjectionVolume ) ;
442+ output . Add ( "Sample injection volume =" + rawFile . SampleInformation . InjectionVolume ) ;
448443 }
449444
450445 if ( rawFile . SampleInformation . RowNumber != 0 )
451446 {
452- output . Add ( "Sample Row Number =" + rawFile . SampleInformation . RowNumber ) ;
447+ output . Add ( "Sample row number =" + rawFile . SampleInformation . RowNumber ) ;
453448 }
454449
455450 if ( rawFile . SampleInformation . DilutionFactor != 0 )
456451 {
457- output . Add ( "Dilution Factor =" + rawFile . SampleInformation . DilutionFactor ) ;
452+ output . Add ( "Sample dilution factor =" + rawFile . SampleInformation . DilutionFactor ) ;
458453 }
459454
460455 if ( rawFile . SampleInformation . IstdAmount != 0 )
461456 {
462- output . Add ( "Internal Standard Amount =" + rawFile . SampleInformation . IstdAmount ) ;
457+ output . Add ( "Internal standard amount =" + rawFile . SampleInformation . IstdAmount ) ;
463458 }
464459
465460 if ( ! rawFile . SampleInformation . CalibrationLevel . IsNullOrEmpty ( ) )
466461 {
467- output . Add ( "Calibration Level =" + rawFile . SampleInformation . CalibrationLevel ) ;
462+ output . Add ( "Calibration level =" + rawFile . SampleInformation . CalibrationLevel ) ;
468463 }
469464
470465 if ( ! rawFile . SampleInformation . InstrumentMethodFile . IsNullOrEmpty ( ) )
471466 {
472- output . Add ( "Device Acquisition Method =" + rawFile . SampleInformation . InstrumentMethodFile ) ;
467+ output . Add ( "Device acquisition method =" + rawFile . SampleInformation . InstrumentMethodFile ) ;
473468 }
474469
475470 if ( rawFile . SampleInformation . SampleWeight != 0 )
476471 {
477- output . Add ( "Sample Weight =" + rawFile . SampleInformation . SampleWeight ) ;
472+ output . Add ( "Sample weight =" + rawFile . SampleInformation . SampleWeight ) ;
478473 }
479474
480475 if ( ! rawFile . SampleInformation . ProcessingMethodFile . IsNullOrEmpty ( ) )
481476 {
482- output . Add ( "Data Processing Method =" + rawFile . SampleInformation . ProcessingMethodFile ) ;
477+ output . Add ( "Data processing method =" + rawFile . SampleInformation . ProcessingMethodFile ) ;
483478 }
484479
485480 string [ ] userLabels = rawFile . UserLabel ;
486481 string [ ] userTexts = rawFile . SampleInformation . UserText ;
487482 if ( ! userLabels . IsNullOrEmpty ( ) && ! userTexts . IsNullOrEmpty ( ) )
488483 {
489- if ( userLabels . Length > userTexts . Length )
490- {
491- throw new RawFileParserException ( ) ;
492- }
493484 for ( int i = 0 ; i < userLabels . Length ; i ++ )
494485 {
495- if ( ! userTexts [ i ] . IsNullOrEmpty ( ) )
486+ if ( i < userTexts . Length && ! userTexts [ i ] . IsNullOrEmpty ( ) )
496487 {
497488 output . Add ( userLabels [ i ] + "=" + userTexts [ i ] ) ;
498489 }
0 commit comments