Class: Bio::FastQC::Converter
- Inherits:
-
Object
- Object
- Bio::FastQC::Converter
- Defined in:
- lib/bio/fastqc/converter.rb
Instance Method Summary collapse
- #convert_to(format) ⇒ Object
-
#initialize(fastqc_object, id: nil, runid: nil) ⇒ Converter
constructor
A new instance of Converter.
- #to_json ⇒ Object
- #to_jsonld ⇒ Object
- #to_tsv ⇒ Object
- #to_ttl ⇒ Object
- #to_turtle ⇒ Object
Constructor Details
#initialize(fastqc_object, id: nil, runid: nil) ⇒ Converter
Returns a new instance of Converter.
6 7 8 9 10 |
# File 'lib/bio/fastqc/converter.rb', line 6 def initialize(fastqc_object, id: nil, runid: nil) @id = id @runid = runid @fastqc_object = fastqc_object end |
Instance Method Details
#convert_to(format) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bio/fastqc/converter.rb', line 12 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 ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/bio/fastqc/converter.rb', line 25 def to_json json = if @id { @id => @fastqc_object } else @fastqc_object end JSON.dump(json) end |
#to_jsonld ⇒ Object
34 35 36 37 |
# File 'lib/bio/fastqc/converter.rb', line 34 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 ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/bio/fastqc/converter.rb', line 47 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 ⇒ Object
43 44 45 |
# File 'lib/bio/fastqc/converter.rb', line 43 def to_ttl to_turtle end |