Module: RGFA::Headers

Included in:
RGFA
Defined in:
lib/rgfa/headers.rb

Overview

Methods for accessing the GFA header information.

The GFA header is accessed using RGFA#header, which returns a Line::Header object.

Multiple header lines defining the same tag

The specification does not explicitely forbid to have the same tag on different lines. To represent this case, a “field array” (RGFA::FieldArray) is used, which is an array of instances of a tag, from different lines of the header.

Examples:

Accessing the header information

rgfa.header.VN # => “1.0”
rgfa.header.co = “This the header comment”
rgfa.header.ni = 100
rgfa.header.field_to_s(:ni) # => “ni:i:100”

Header with tags repeated on different lines (see FieldArray)

rgfa.header.ni # => RGFA::FieldArray<[100,200] @datatype: :i>
rgfa.header.ni[0] # 100
rgfa.header.ni << 200 # “200” is also OK
rgfa.header.ni.map!{|i|i-10}
rgfa.header.ni = [100,200,300].to_rgfa_field_array

Adding instances of a tag (will go on different header lines)

rgfa.header.add(:xx, 100) # => 100 # single i tag, if .xx did not exist yet
rgfa.header.add(:xx, 100) # => RGFA::FieldArray<[100,100] @datatype: :i>
rgfa.header.add(:xx, 100) # => RGFA::FieldArray<[100,100,100] @datatype :i>

Instance Method Summary collapse

Instance Method Details

#delete_headersRGFA

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Remove all information from the header.

Returns:



60
61
62
63
# File 'lib/rgfa/headers.rb', line 60

def delete_headers
  init_headers
  return self
end

#headerRGFA::Line::Header

Returns an header line representing the entire header information; if multiple header line were present, and they contain the same tag, the tag value is represented by a FieldArray.

Returns:

  • (RGFA::Line::Header)

    an header line representing the entire header information; if multiple header line were present, and they contain the same tag, the tag value is represented by a FieldArray



39
40
41
# File 'lib/rgfa/headers.rb', line 39

def header
  @headers
end

#headersArray<RGFA::Line::Header>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

Read-only! The returned array containes copies of the original values, i.e.\ changes in the lines will not affect the RGFA object; to update the values in the RGFA use the #header method.

Header information in single-tag-lines.

Returns an array of RGFA::Line::Header objects, each containing a single field of the header.



53
54
55
# File 'lib/rgfa/headers.rb', line 53

def headers
  @headers.split
end