@@ -214,70 +214,70 @@ private void Parse()
214214
215215 while ( ( line = fileReader . ReadLine ( ) ) != null )
216216 {
217- lineCounter ++ ;
217+ if ( ++ lineCounter > MaxLinesToRead ) break ;
218+
218219 lineSize += fileReader . CurrentEncoding . GetByteCount ( line ) ;
219220 Status = ( Math . Round ( ( lineSize * 100.0 ) / fileSize , 0 ) ) . ToString ( ) ;
220221
221- if ( line . Trim ( ) . Length > 0 && lineCounter <= MaxLinesToRead )
222+ if ( line . Trim ( ) . Length <= 0 ) continue ;
223+
224+ DropReadingPeak = false ;
225+ string [ ] splittedLine = line . Split ( Delimiter ) ;
226+
227+ if ( ! ( _leftColumn < splittedLine . Length && int . TryParse ( splittedLine [ _leftColumn ] , out left ) ) )
228+ {
229+ DropLine ( "\t Line " + lineCounter . ToString ( ) + "\t :\t Invalid start/position column number" ) ;
230+ continue ;
231+ }
232+
233+ if ( _rightColumn >= 0 && ! ( _rightColumn < splittedLine . Length && int . TryParse ( splittedLine [ _rightColumn ] , out right ) ) )
234+ {
235+ DropLine ( "\t Line " + lineCounter . ToString ( ) + "\t :\t Invalid stop column number" ) ;
236+ continue ;
237+ }
238+
239+ I readingInterval = BuildInterval ( left , right , splittedLine , lineCounter ) ;
240+ if ( DropReadingPeak )
241+ continue ;
242+
243+ chrName = null ;
244+ if ( _chrColumn < splittedLine . Length )
222245 {
223- DropReadingPeak = false ;
224- string [ ] splittedLine = line . Split ( Delimiter ) ;
225-
226- if ( ! ( _leftColumn < splittedLine . Length && int . TryParse ( splittedLine [ _leftColumn ] , out left ) ) )
227- {
228- DropLine ( "\t Line " + lineCounter . ToString ( ) + "\t :\t Invalid start/position column number" ) ;
229- continue ;
230- }
231-
232- if ( _rightColumn >= 0 && ! ( _rightColumn < splittedLine . Length && int . TryParse ( splittedLine [ _rightColumn ] , out right ) ) )
233- {
234- DropLine ( "\t Line " + lineCounter . ToString ( ) + "\t :\t Invalid stop column number" ) ;
235- continue ;
236- }
237-
238- I readingInterval = BuildInterval ( left , right , splittedLine , lineCounter ) ;
239- if ( DropReadingPeak )
240- continue ;
241-
242- chrName = null ;
243- if ( _chrColumn < splittedLine . Length )
244- {
245- if ( Regex . IsMatch ( splittedLine [ _chrColumn ] . ToLower ( ) , "chr" ) )
246- chrName = splittedLine [ _chrColumn ] ;
247- else if ( int . TryParse ( splittedLine [ _chrColumn ] , out int chrNumber ) )
248- chrName = "chr" + chrNumber ;
249- else if ( _assemblyData . ContainsKey ( "chr" + splittedLine [ _chrColumn ] ) )
250- chrName = "chr" + splittedLine [ _chrColumn ] ;
251- else
252- chrName = splittedLine [ _chrColumn ] ;
253- if ( ReadOnlyAssemblyChrs && ! _assemblyData . ContainsKey ( chrName ) )
254- chrName = null ;
255- }
256- if ( chrName == null )
257- {
258- DropLine ( "\t Line " + lineCounter . ToString ( ) + "\t :\t Invalid chromosome number ( " + splittedLine [ _chrColumn ] . ToString ( ) + " )" ) ;
259- continue ;
260- }
246+ if ( Regex . IsMatch ( splittedLine [ _chrColumn ] . ToLower ( ) , "chr" ) )
247+ chrName = splittedLine [ _chrColumn ] ;
248+ else if ( int . TryParse ( splittedLine [ _chrColumn ] , out int chrNumber ) )
249+ chrName = "chr" + chrNumber ;
250+ else if ( _assemblyData . ContainsKey ( "chr" + splittedLine [ _chrColumn ] ) )
251+ chrName = "chr" + splittedLine [ _chrColumn ] ;
252+ else
253+ chrName = splittedLine [ _chrColumn ] ;
254+ if ( ReadOnlyAssemblyChrs && ! _assemblyData . ContainsKey ( chrName ) )
255+ chrName = null ;
256+ }
257+ if ( chrName == null )
258+ {
259+ DropLine ( "\t Line " + lineCounter . ToString ( ) + "\t :\t Invalid chromosome number ( " + splittedLine [ _chrColumn ] . ToString ( ) + " )" ) ;
260+ continue ;
261+ }
261262
263+ strand = '*' ;
264+ if ( _strandColumn != - 1 && _strandColumn < line . Length &&
265+ ( char . TryParse ( splittedLine [ _strandColumn ] , out strand ) && strand != '+' && strand != '-' && strand != '*' ) )
262266 strand = '*' ;
263- if ( _strandColumn != - 1 && _strandColumn < line . Length &&
264- ( char . TryParse ( splittedLine [ _strandColumn ] , out strand ) && strand != '+' && strand != '-' && strand != '*' ) )
265- strand = '*' ;
266-
267- switch ( HashFunction )
268- {
269- case HashFunctions . FNV :
270- readingInterval . HashKey = FNVHashFunction ( readingInterval , lineCounter ) ;
271- break ;
272-
273- default :
274- readingInterval . HashKey = OneAtATimeHashFunction ( readingInterval , lineCounter ) ;
275- break ;
276- }
277-
278- _data . Add ( readingInterval , chrName , strand ) ;
279- _data . IntervalsCount ++ ;
267+
268+ switch ( HashFunction )
269+ {
270+ case HashFunctions . FNV :
271+ readingInterval . HashKey = FNVHashFunction ( readingInterval , lineCounter ) ;
272+ break ;
273+
274+ default :
275+ readingInterval . HashKey = OneAtATimeHashFunction ( readingInterval , lineCounter ) ;
276+ break ;
280277 }
278+
279+ _data . Add ( readingInterval , chrName , strand ) ;
280+ _data . IntervalsCount ++ ;
281281 }
282282 }
283283 }
0 commit comments