11using System ;
22using System . Collections . Generic ;
33using System . IO ;
4+ using System . Reflection ;
5+ using log4net ;
6+ using NUnit . Framework . Internal ;
47using ThermoFisher . CommonCore . Data ;
58using ThermoFisher . CommonCore . Data . Business ;
69using ThermoFisher . CommonCore . Data . Interfaces ;
@@ -9,6 +12,9 @@ namespace ThermoRawFileParser.XIC
912{
1013 public class XicReader
1114 {
15+ private static readonly ILog Log =
16+ LogManager . GetLogger ( MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
17+
1218 private const string MsFilter = "ms" ;
1319
1420 public static void ReadXic ( string rawFilePath , bool base64 , XicData xicData )
@@ -104,36 +110,52 @@ public static void ReadXic(string rawFilePath, bool base64, XicData xicData)
104110 xicUnit . Meta . RtEnd = endTime ;
105111 }
106112
113+ IChromatogramData data = null ;
107114 if ( rtFilteredScans == null )
108115 {
109116 rtFilteredScans = rawFile . GetFilteredScansListByTimeRange ( MsFilter ,
110117 xicUnit . Meta . RtStart . Value , xicUnit . Meta . RtEnd . Value ) ;
111- }
112118
113- IChromatogramData data ;
114- if ( ! rtFilteredScans . IsNullOrEmpty ( ) )
115- {
116- data = rawFile . GetChromatogramData ( new IChromatogramSettings [ ] { settings } , rtFilteredScans [ 0 ] ,
117- rtFilteredScans [ rtFilteredScans . Count - 1 ] ) ;
119+ if ( rtFilteredScans . Count != 0 )
120+ {
121+ data = rawFile . GetChromatogramData ( new IChromatogramSettings [ ] { settings } ,
122+ rtFilteredScans [ 0 ] ,
123+ rtFilteredScans [ rtFilteredScans . Count - 1 ] ) ;
124+ if ( data . PositionsArray . Length == 1 && data . PositionsArray [ 0 ] . Length == 1 &&
125+ ( Math . Abs ( data . PositionsArray [ 0 ] [ 0 ] - startTime ) < 0.001 ||
126+ Math . Abs ( data . PositionsArray [ 0 ] [ 0 ] - endTime ) < 0.001 ) )
127+ {
128+ Log . Warn (
129+ $ "Only the minimum or maximum retention time was returned. This is an indication that the provided retention time range [{ xicUnit . Meta . RtStart } -{ xicUnit . Meta . RtEnd } ] lies outside the max. window [{ startTime } -{ endTime } ]") ;
130+ }
131+ }
132+ else
133+ {
134+ Log . Warn (
135+ $ "No scans found in retention time range [{ xicUnit . Meta . RtStart } -{ xicUnit . Meta . RtEnd } ]. This is an indication that the provided retention time window lies outside the max. window [{ startTime } -{ endTime } ]") ;
136+ }
118137 }
119138 else
120139 {
121140 data = rawFile . GetChromatogramData ( new IChromatogramSettings [ ] { settings } , firstScanNumber ,
122141 lastScanNumber ) ;
123142 }
124143
125- var chromatogramTrace = ChromatogramSignal . FromChromatogramData ( data ) ;
126- if ( chromatogramTrace [ 0 ] . Scans . Count != 0 )
144+ if ( data != null )
127145 {
128- if ( ! base64 )
129- {
130- xicUnit . RetentionTimes = chromatogramTrace [ 0 ] . Times ;
131- xicUnit . Intensities = chromatogramTrace [ 0 ] . Intensities ;
132- }
133- else
146+ var chromatogramTrace = ChromatogramSignal . FromChromatogramData ( data ) ;
147+ if ( chromatogramTrace [ 0 ] . Scans . Count != 0 )
134148 {
135- xicUnit . RetentionTimes = GetBase64String ( chromatogramTrace [ 0 ] . Times ) ;
136- xicUnit . Intensities = GetBase64String ( chromatogramTrace [ 0 ] . Intensities ) ;
149+ if ( ! base64 )
150+ {
151+ xicUnit . RetentionTimes = chromatogramTrace [ 0 ] . Times ;
152+ xicUnit . Intensities = chromatogramTrace [ 0 ] . Intensities ;
153+ }
154+ else
155+ {
156+ xicUnit . RetentionTimes = GetBase64String ( chromatogramTrace [ 0 ] . Times ) ;
157+ xicUnit . Intensities = GetBase64String ( chromatogramTrace [ 0 ] . Intensities ) ;
158+ }
137159 }
138160 }
139161 }
0 commit comments