Class: BioInterchange::Phylogenetics::NewickReader

Inherits:
Reader
  • Object
show all
Defined in:
lib/biointerchange/phylogenetics/newick_reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(date = nil, batch_size = nil) ⇒ NewickReader

Creates a new instance of a Newick file format reader.

The reader supports batch processing.

date

Optional date of when the Newick file was produced, annotated, etc.

batch_size

Optional integer that determines that number of features that

should be processed in one go.



27
28
29
30
# File 'lib/biointerchange/phylogenetics/newick_reader.rb', line 27

def initialize(date = nil, batch_size = nil)
  @date = date
  @batch_size = batch_size
end

Instance Method Details

#deserialize(inputstream) ⇒ Object

Reads a Newick file from the input stream and returns an associated model.

If this method is called when postponed? returns true, then the reading will continue from where it has been interrupted beforehand.

inputstream

an instance of class IO or String that holds the contents of a Newick file



38
39
40
41
42
43
44
45
46
# File 'lib/biointerchange/phylogenetics/newick_reader.rb', line 38

def deserialize(inputstream)
  if inputstream.kind_of?(IO)
    create_model(inputstream)
  elsif inputstream.kind_of?(String) then
    create_model(StringIO.new(inputstream))
  else
    raise BioInterchange::Exceptions::ImplementationReaderError, 'The provided input stream needs to be either of type IO or String.'
  end
end

#postponed?Boolean

Returns true if the reading of the input was postponed due to a full batch.

Returns:

  • (Boolean)


49
50
51
# File 'lib/biointerchange/phylogenetics/newick_reader.rb', line 49

def postponed?
  @postponed
end