Class: BioInterchange::Genomics::RDFWriter

Inherits:
Writer
  • Object
show all
Defined in:
lib/biointerchange/genomics/gff3_rdf_ntriples.rb

Overview

Serializes GFF3, GVF and VCF models.

Inputs:

  • biointerchange.gff3

  • biointerchange.gvf

  • biointerchange.vcf

Outputs:

  • rdf.biointerchange.gfvo

Instance Method Summary collapse

Methods inherited from Writer

#add_prefix, #close, #create_triple, #set_base

Constructor Details

#initialize(ostream) ⇒ RDFWriter

Creates a new instance of a RDFWriter that will use the provided output stream to serialize RDF.

ostream

instance of an IO class or derivative that is used for RDF serialization



30
31
32
# File 'lib/biointerchange/genomics/gff3_rdf_ntriples.rb', line 30

def initialize(ostream)
  super(ostream)
end

Instance Method Details

#serialize(model, uri_prefix = nil) ⇒ Object

Serialize a model as RDF.

model

a generic representation of input data that is derived from BioInterchange::Genomics::GFF3FeatureSet

uri_prefix

optional URI prefix that replaces the default URI prefix for all set/feature/annotation URIs



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/biointerchange/genomics/gff3_rdf_ntriples.rb', line 38

def serialize(model, uri_prefix = nil)
  if model.instance_of?(BioInterchange::Genomics::GFF3FeatureSet) then
    @format = :gff3
  elsif model.instance_of?(BioInterchange::Genomics::GVFFeatureSet) then
    @format = :gvf
  elsif model.instance_of?(BioInterchange::Genomics::VCFFeatureSet) then
    @format = :vcf
  else
    raise BioInterchange::Exceptions::ImplementationWriterError, 'The provided model cannot be serialized. ' +
                         'This writer supports serialization for BioInterchange::Genomics::GFF3FeatureSet, ' +
                         'BioInterchange::Genomics::GVFFeatureSet and BioInterchange::Genomics::VCFFeatureSet.'
  end
  @base = BioInterchange::GFVO
  serialize_model(model, uri_prefix)
end