class Bio::FastQC::Converter

Public Class Methods

new(fastqc_object, id: nil, runid: nil) click to toggle source
# File lib/bio/fastqc/converter.rb, line 5
def initialize(fastqc_object, id: nil, runid: nil)
  @id = id
  @runid = runid
  @fastqc_object = fastqc_object
end

Public Instance Methods

convert_to(format) click to toggle source
# File lib/bio/fastqc/converter.rb, line 11
def convert_to(format)
  case format
  when "json"
    to_json
  when "json-ld", "jsonld"
    to_jsonld
  when "turtle", "ttl"
    to_turtle
  when "tsv"
    to_tsv
  end
end
to_json() click to toggle source
# File lib/bio/fastqc/converter.rb, line 24
def to_json
  json = if @id
           { @id => @fastqc_object }
         else
           @fastqc_object
         end
  JSON.dump(json)
end
to_jsonld() click to toggle source
# File lib/bio/fastqc/converter.rb, line 33
def to_jsonld
  json_ld_object = Semantics.new(@fastqc_object, id: @id, runid: @runid).json_ld_object
  JSON.dump(json_ld_object)
end
to_tsv() click to toggle source
# File lib/bio/fastqc/converter.rb, line 46
def to_tsv
  identifier = if @id
                 @id
               else
                 @fastqc_object[:filename].split(".").first
               end

  # return one-line tab separated value
  [
    identifier,
    @fastqc_object[:fastqc_version],
    @fastqc_object[:filename],
    @fastqc_object[:file_type],
    @fastqc_object[:encoding],
    @fastqc_object[:total_sequences],
    @fastqc_object[:filtered_sequences],
    @fastqc_object[:sequence_length],
    @fastqc_object[:min_length],
    @fastqc_object[:max_length],
    @fastqc_object[:mean_sequence_length],
    @fastqc_object[:median_sequence_length],
    @fastqc_object[:percent_gc],
    @fastqc_object[:total_duplicate_percentage],
    @fastqc_object[:overall_mean_quality_score],
    @fastqc_object[:overall_median_quality_score],
    @fastqc_object[:overall_n_content],
  ].join("\t")
end
to_ttl() click to toggle source
# File lib/bio/fastqc/converter.rb, line 42
def to_ttl
  to_turtle
end
to_turtle() click to toggle source
# File lib/bio/fastqc/converter.rb, line 38
def to_turtle
  Semantics.new(@fastqc_object, id: @id, runid: @runid).turtle
end