@@ -640,6 +640,7 @@ private List<ChromatogramType> ConstructChromatograms(int firstScanNumber, int l
640640 {
641641 var chromatograms = new List < ChromatogramType > ( ) ;
642642
643+ //MS chromatograms
643644 // Define the settings for getting the Base Peak chromatogram
644645 var settings = new ChromatogramTraceSettings ( TraceType . BasePeak ) ;
645646
@@ -671,8 +672,8 @@ private List<ChromatogramType> ConstructChromatograms(int firstScanNumber, int l
671672 } ;
672673 chromatogram . cvParam [ 0 ] = new CVParamType
673674 {
674- accession = "MS:1000235 " ,
675- name = "total ion current chromatogram" ,
675+ accession = "MS:1000628 " ,
676+ name = "basepeak chromatogram" ,
676677 cvRef = "MS" ,
677678 value = ""
678679 } ;
@@ -791,8 +792,167 @@ private List<ChromatogramType> ConstructChromatograms(int firstScanNumber, int l
791792
792793 chromatograms . Add ( chromatogram ) ;
793794 }
795+
794796 }
795797
798+ //UV chromatograms
799+ if ( ParseInput . AllDetectors )
800+ {
801+ for ( int nrI = 0 ; nrI < _rawFile . GetInstrumentCountOfType ( Device . Pda ) ; nrI ++ )
802+ {
803+ _rawFile . SelectInstrument ( Device . Pda , nrI + 1 ) ;
804+
805+ var settingsPDA = new ChromatogramTraceSettings ( TraceType . TotalAbsorbance ) ;
806+
807+ var dataPDA = _rawFile . GetChromatogramData ( new IChromatogramSettings [ ] { settingsPDA } ,
808+ firstScanNumber , lastScanNumber ) ;
809+
810+ var tracePDA = ChromatogramSignal . FromChromatogramData ( dataPDA ) ;
811+
812+ for ( var i = 0 ; i < tracePDA . Length ; i ++ )
813+ {
814+ if ( tracePDA [ i ] . Length > 0 )
815+ {
816+ // Binary data array list
817+ var binaryData = new List < BinaryDataArrayType > ( ) ;
818+
819+ var chromatogram = new ChromatogramType
820+ {
821+ index = i . ToString ( ) ,
822+ id = String . Format ( "PDA_{0}_TotalAbsorbance_{1}" , nrI , i ) ,
823+ defaultArrayLength = 0 ,
824+ binaryDataArrayList = new BinaryDataArrayListType
825+ {
826+ count = "2" ,
827+ binaryDataArray = new BinaryDataArrayType [ 2 ]
828+ } ,
829+ cvParam = new CVParamType [ 1 ]
830+ } ;
831+ chromatogram . cvParam [ 0 ] = new CVParamType
832+ {
833+ accession = "MS:1000812" ,
834+ name = "absorption chromatogram" ,
835+ cvRef = "MS" ,
836+ value = ""
837+ } ;
838+
839+ // Chromatogram times
840+ if ( ! trace [ i ] . Times . IsNullOrEmpty ( ) )
841+ {
842+ // Set the chromatogram default array length
843+ chromatogram . defaultArrayLength = trace [ i ] . Times . Count ;
844+
845+ var timesBinaryData =
846+ new BinaryDataArrayType
847+ {
848+ binary = ParseInput . NoZlibCompression
849+ ? Get64BitArray ( trace [ i ] . Times )
850+ : GetZLib64BitArray ( trace [ i ] . Times )
851+ } ;
852+ timesBinaryData . encodedLength =
853+ ( 4 * Math . Ceiling ( ( double ) timesBinaryData
854+ . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
855+ var timesBinaryDataCvParams = new List < CVParamType >
856+ {
857+ new CVParamType
858+ {
859+ accession = "MS:1000595" ,
860+ name = "time array" ,
861+ cvRef = "MS" ,
862+ unitName = "minute" ,
863+ value = "" ,
864+ unitCvRef = "UO" ,
865+ unitAccession = "UO:0000031"
866+ } ,
867+ new CVParamType
868+ {
869+ accession = "MS:1000523" , name = "64-bit float" , cvRef = "MS" , value = ""
870+ }
871+ } ;
872+ if ( ! ParseInput . NoZlibCompression )
873+ {
874+ timesBinaryDataCvParams . Add (
875+ new CVParamType
876+ {
877+ accession = "MS:1000574" ,
878+ name = "zlib compression" ,
879+ cvRef = "MS" ,
880+ value = ""
881+ } ) ;
882+ }
883+
884+ timesBinaryData . cvParam = timesBinaryDataCvParams . ToArray ( ) ;
885+
886+ binaryData . Add ( timesBinaryData ) ;
887+ }
888+
889+ // Chromatogram intensities
890+ if ( ! trace [ i ] . Times . IsNullOrEmpty ( ) )
891+ {
892+ // Set the spectrum default array length if necessary
893+ if ( chromatogram . defaultArrayLength == 0 )
894+ {
895+ chromatogram . defaultArrayLength = trace [ i ] . Intensities . Count ;
896+ }
897+
898+ var intensitiesBinaryData =
899+ new BinaryDataArrayType
900+ {
901+ binary = ParseInput . NoZlibCompression
902+ ? Get64BitArray ( trace [ i ] . Intensities )
903+ : GetZLib64BitArray ( trace [ i ] . Intensities )
904+ } ;
905+ intensitiesBinaryData . encodedLength =
906+ ( 4 * Math . Ceiling ( ( double ) intensitiesBinaryData
907+ . binary . Length / 3 ) ) . ToString ( CultureInfo . InvariantCulture ) ;
908+ var intensitiesBinaryDataCvParams = new List < CVParamType >
909+ {
910+ new CVParamType
911+ {
912+ accession = "MS:1000515" ,
913+ name = "intensity array" ,
914+ cvRef = "MS" ,
915+ unitName = "absorbance unit" ,
916+ value = "" ,
917+ unitCvRef = "UO" ,
918+ unitAccession = "UO:0000269"
919+ } ,
920+ new CVParamType
921+ {
922+ accession = "MS:1000523" , name = "64-bit float" , cvRef = "MS" , value = ""
923+ }
924+ } ;
925+ if ( ! ParseInput . NoZlibCompression )
926+ {
927+ intensitiesBinaryDataCvParams . Add (
928+ new CVParamType
929+ {
930+ accession = "MS:1000574" ,
931+ name = "zlib compression" ,
932+ cvRef = "MS" ,
933+ value = ""
934+ } ) ;
935+ }
936+
937+ intensitiesBinaryData . cvParam = intensitiesBinaryDataCvParams . ToArray ( ) ;
938+
939+ binaryData . Add ( intensitiesBinaryData ) ;
940+ }
941+
942+ if ( ! binaryData . IsNullOrEmpty ( ) )
943+ {
944+ chromatogram . binaryDataArrayList = new BinaryDataArrayListType
945+ {
946+ count = binaryData . Count . ToString ( ) ,
947+ binaryDataArray = binaryData . ToArray ( )
948+ } ;
949+ }
950+
951+ chromatograms . Add ( chromatogram ) ;
952+ }
953+ }
954+ }
955+ }
796956 return chromatograms ;
797957 }
798958
0 commit comments