Method: Bio::FlatFile#initialize

Defined in:
lib/bio/io/flatfile.rb

#initialize(dbclass, stream) ⇒ FlatFile

Same as FlatFile.open, except that ‘stream’ should be a opened stream object (IO, File, …, who have the ‘gets’ method).

  • Example 1

    Bio::FlatFile.new(Bio::GenBank, ARGF)
    
  • Example 2

    Bio::FlatFile.new(Bio::GenBank, IO.popen("gzip -dc nc1101.flat.gz"))
    

Compatibility Note: Now, you cannot specify “:raw => true” or “:raw => false”. Below styles are DEPRECATED.

  • Example 3 (deprecated)

    # Bio::FlatFile.new(nil, $stdin, :raw=>true) # => ERROR
    # Please rewrite as below.
    ff = Bio::FlatFile.new(nil, $stdin)
    ff.raw = true
    
  • Example 3 in old style (deprecated)

    # Bio::FlatFile.new(nil, $stdin, true) # => ERROR
    # Please rewrite as below.
    ff = Bio::FlatFile.new(nil, $stdin)
    ff.raw = true
    


225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/bio/io/flatfile.rb', line 225

def initialize(dbclass, stream)
  # 2nd arg: IO object
  if stream.kind_of?(BufferedInputStream)
    @stream = stream
  else
    @stream = BufferedInputStream.for_io(stream)
  end
  # 1st arg: database class (or file format autodetection)
  if dbclass then
  self.dbclass = dbclass
  else
  autodetect
  end
  #
  @skip_leader_mode = :firsttime
  @firsttime_flag = true
  # default raw mode is false
  self.raw = false
end