@@ -196,7 +196,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
196196 value = ""
197197 } ) ;
198198 }
199- //TODO FID chromatogram as ion current
199+ //TODO non-standard chromatograms pressure, flow, FID, etc
200200 }
201201
202202 _writer . WriteEndElement ( ) ; // fileContent
@@ -283,7 +283,7 @@ public override void Write(IRawDataPlus rawFile, int firstScanNumber, int lastSc
283283 {
284284 PopulateInstrumentConfigurationList ( firstScanNumber , lastScanNumber , instrumentModel ) ;
285285 }
286- else //TODO Fake instrument configuration
286+ else
287287 {
288288 _writer . WriteStartElement ( "instrumentConfigurationList" ) ;
289289 _writer . WriteAttributeString ( "count" , "1" ) ;
@@ -952,24 +952,9 @@ private List<ChromatogramType> ConstructChromatograms(int firstScanNumber, int l
952952 for ( var i = 0 ; i < trace . Length ; i ++ )
953953 {
954954 // CV Data for Total Absorbance Chromatogram
955- var chroType = new CVParamType
956- {
957- accession = "MS:1000812" ,
958- name = "absorption chromatogram" ,
959- cvRef = "MS" ,
960- value = ""
961- } ;
962-
963- var intensType = new CVParamType
964- {
965- accession = "MS:1000515" ,
966- name = "intensity array" ,
967- cvRef = "MS" ,
968- unitName = "absorbance unit" ,
969- value = instData . Units . ToString ( ) ,
970- unitCvRef = "UO" ,
971- unitAccession = "UO:0000269"
972- } ;
955+ var chroType = OntologyMapping . chromatogramTypes [ "absoption" ] ;
956+ var intensType = OntologyMapping . dataArrayTypes [ "absoption" ] ;
957+ intensType . value = instData . Units . ToString ( ) ;
973958
974959 var chromatogram = TraceToChromatogram ( trace [ i ] ,
975960 String . Format ( "PDA#{0}_TotalAbsorbance_{1}" , nrI , i ) ,
@@ -998,25 +983,10 @@ private List<ChromatogramType> ConstructChromatograms(int firstScanNumber, int l
998983 for ( var i = 0 ; i < trace . Length ; i ++ )
999984 {
1000985 // CV Data for Absorbance Chromatogram
1001- var chroType = new CVParamType
1002- {
1003- accession = "MS:1000812" ,
1004- name = "absorption chromatogram" ,
1005- cvRef = "MS" ,
1006- value = ""
1007- } ;
1008-
1009- var intensType = new CVParamType
1010- {
1011- accession = "MS:1000515" ,
1012- name = "intensity array" ,
1013- cvRef = "MS" ,
1014- unitName = "absorbance unit" ,
1015- value = instData . Units . ToString ( ) ,
1016- unitCvRef = "UO" ,
1017- unitAccession = "UO:0000269"
1018- } ;
1019-
986+ var chroType = OntologyMapping . chromatogramTypes [ "absorbtion" ] ;
987+ var intensType = OntologyMapping . dataArrayTypes [ "absoption" ] ;
988+ intensType . value = instData . Units . ToString ( ) ;
989+
1020990 var chromatogram = TraceToChromatogram ( trace [ i ] ,
1021991 String . Format ( "UV#{0}_{1}_{2}" , nrI , channelName , i ) ,
1022992 chroType , intensType ) ;
@@ -1026,129 +996,61 @@ private List<ChromatogramType> ConstructChromatograms(int firstScanNumber, int l
1026996 }
1027997 }
1028998
1029- for ( int nrI = 1 ; nrI < _rawFile . GetInstrumentCountOfType ( Device . Analog ) + 1 ; nrI ++ )
999+ //Chromatograms from (MS)Analog devices: Pressure, FID, etc
1000+ foreach ( var deviceType in new Device [ 2 ] { Device . Analog , Device . MSAnalog } )
10301001 {
1031- _rawFile . SelectInstrument ( Device . Analog , nrI ) ;
1032-
1033- var instData = _rawFile . GetInstrumentData ( ) ;
1034-
1035- for ( int channel = 0 ; channel < instData . ChannelLabels . Length ; channel ++ )
1002+ var channelNameIndex = 0 ;
1003+ for ( int nrI = 1 ; nrI < _rawFile . GetInstrumentCountOfType ( deviceType ) + 1 ; nrI ++ )
10361004 {
1037- var channelName = instData . ChannelLabels [ channel ] ;
1005+ _rawFile . SelectInstrument ( deviceType , nrI ) ;
10381006
1039- if ( channelName . ToLower ( ) . Contains ( "pressure" ) )
1040- {
1041- settings = new ChromatogramTraceSettings ( TraceType . StartAnalogChromatogramTraces + channel + 1 ) ;
1007+ var instData = _rawFile . GetInstrumentData ( ) ;
10421008
1043- data = _rawFile . GetChromatogramData ( new IChromatogramSettings [ ] { settings } , - 1 , - 1 ) ;
1009+ for ( int channel = 0 ; channel < instData . ChannelLabels . Length ; channel ++ )
1010+ {
1011+ var channelName = instData . ChannelLabels [ channel ] ;
1012+ if ( channelName . IsNullOrEmpty ( ) )
1013+ {
1014+ channelName = $ "Channel{ channelNameIndex ++ } ";
1015+ }
10441016
1017+ settings = new ChromatogramTraceSettings ( TraceType . StartAnalogChromatogramTraces + channel + 1 ) ;
1018+ data = _rawFile . GetChromatogramData ( new IChromatogramSettings [ ] { settings } , - 1 , - 1 ) ;
10451019 trace = ChromatogramSignal . FromChromatogramData ( data ) ;
10461020
10471021 for ( var i = 0 ; i < trace . Length ; i ++ )
10481022 {
1049- // CV Data for Absorbance Chromatogram
1050- var chroType = new CVParamType
1023+ //Default data type
1024+ var chroType = OntologyMapping . chromatogramTypes [ "unknown" ] ;
1025+ var intensType = OntologyMapping . dataArrayTypes [ "unknown" ] ;
1026+
1027+ if ( channelName . ToLower ( ) . Contains ( "pressure" ) )
10511028 {
1052- accession = "MS:1003019" ,
1053- name = "pressure chromatogram" ,
1054- cvRef = "MS" ,
1055- value = ""
1056- } ;
1057-
1058- var intensType = new CVParamType
1029+ chroType = OntologyMapping . chromatogramTypes [ "pressure" ] ;
1030+ intensType = OntologyMapping . dataArrayTypes [ "pressure" ] ;
1031+ }
1032+ else if ( channelName . ToLower ( ) . Contains ( "flow" ) )
10591033 {
1060- accession = "MS:1000821" ,
1061- name = "pressure array" ,
1062- cvRef = "MS" ,
1063- unitName = "pressure unit" ,
1064- value = "" ,
1065- unitCvRef = "UO" ,
1066- unitAccession = "UO:0000109"
1067- } ;
1034+ chroType = OntologyMapping . chromatogramTypes [ "flow" ] ;
1035+ intensType = OntologyMapping . dataArrayTypes [ "flow" ] ;
1036+ }
1037+ else if ( channelName . ToLower ( ) . Contains ( "fid" ) )
1038+ {
1039+ //FID is ion current type
1040+ chroType = OntologyMapping . chromatogramTypes [ "current" ] ;
1041+ intensType = OntologyMapping . dataArrayTypes [ "intensity" ] ;
1042+ }
10681043
10691044 var chromatogram = TraceToChromatogram ( trace [ i ] ,
1070- String . Format ( "AD# {0}_ {1}_{2}" , nrI , channelName , i ) ,
1045+ String . Format ( "{0}# {1}_{2}_{3} " , deviceType . ToString ( ) , nrI , channelName . Replace ( " " , "_" ) , i ) ,
10711046 chroType , intensType ) ;
10721047
10731048 chromatograms . Add ( chromatogram ) ;
10741049 }
10751050 }
10761051 }
10771052 }
1078-
1079- var channelNameIndex = 0 ;
1080-
1081- for ( int nrI = 1 ; nrI < _rawFile . GetInstrumentCountOfType ( Device . MSAnalog ) + 1 ; nrI ++ )
1082- {
1083- _rawFile . SelectInstrument ( Device . MSAnalog , nrI ) ;
1084-
1085- var instData = _rawFile . GetInstrumentData ( ) ;
1086-
1087- for ( int channel = 0 ; channel < instData . ChannelLabels . Length ; channel ++ )
1088- {
1089- var channelName = instData . ChannelLabels [ channel ] ;
1090-
1091- if ( channelName . IsNullOrEmpty ( ) )
1092- {
1093- channelName = $ "Channel{ channelNameIndex ++ } ";
1094- }
1095-
1096- settings = new ChromatogramTraceSettings ( TraceType . StartAnalogChromatogramTraces + channel + 1 ) ;
1097- data = _rawFile . GetChromatogramData ( new IChromatogramSettings [ ] { settings } , - 1 , - 1 ) ;
1098- trace = ChromatogramSignal . FromChromatogramData ( data ) ;
1099-
1100- for ( var i = 0 ; i < trace . Length ; i ++ )
1101- {
1102- // CV Data for Chromatogram
1103- var chroType = new CVParamType
1104- {
1105- accession = "MS:1000626" ,
1106- name = "chromatogram type" ,
1107- cvRef = "MS" ,
1108- value = $ "{ channelName } chromatogram"
1109- } ;
1110-
1111- var intensType = new CVParamType
1112- {
1113- accession = "MS:1000786" ,
1114- name = "non-standard data array" ,
1115- cvRef = "MS" ,
1116- unitName = "unit" ,
1117- value = instData . Units . ToString ( ) ,
1118- unitCvRef = "UO" ,
1119- unitAccession = "UO:0000000"
1120- } ;
1121-
1122- if ( instData . Units . ToString ( ) . ToLower ( ) . Contains ( "absorbance" ) )
1123- {
1124- chroType = new CVParamType
1125- {
1126- accession = "MS:1000812" ,
1127- name = "absorption chromatogram" ,
1128- cvRef = "MS" ,
1129- value = $ "{ channelName } chromatogram"
1130- } ;
1131-
1132- intensType = new CVParamType
1133- {
1134- accession = "MS:1000515" ,
1135- name = "intensity array" ,
1136- cvRef = "MS" ,
1137- unitName = "absorbance unit" ,
1138- value = instData . Units . ToString ( ) ,
1139- unitCvRef = "UO" ,
1140- unitAccession = "UO:0000269"
1141- } ;
1142- }
1143-
1144- var chromatogram = TraceToChromatogram ( trace [ i ] ,
1145- String . Format ( "MSAD#{0}_{1}_{2}" , nrI , channelName . Replace ( " " , "_" ) , i ) ,
1146- chroType , intensType ) ;
1147-
1148- chromatograms . Add ( chromatogram ) ;
1149- }
1150- }
1151- }
1053+
11521054 }
11531055
11541056 return chromatograms ;
@@ -1192,16 +1094,7 @@ private ChromatogramType TraceToChromatogram(ChromatogramSignal trace, string ch
11921094 . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
11931095 var timesBinaryDataCvParams = new List < CVParamType >
11941096 {
1195- new CVParamType
1196- {
1197- accession = "MS:1000595" ,
1198- name = "time array" ,
1199- cvRef = "MS" ,
1200- unitName = "minute" ,
1201- value = "" ,
1202- unitCvRef = "UO" ,
1203- unitAccession = "UO:0000031"
1204- } ,
1097+ OntologyMapping . dataArrayTypes [ "time" ] ,
12051098 new CVParamType
12061099 {
12071100 accession = "MS:1000523" , name = "64-bit float" , cvRef = "MS" , value = ""
0 commit comments