class Bio::Abif

Description

This class inherits from the SangerChromatogram superclass. It captures the information contained within an ABIF format chromatogram file generated by DNA sequencing. See the SangerChromatogram class for usage.

Constants

DATA_TYPES
PACK_TYPES

Attributes

chemistry[RW]

The chemistry used when sequencing e.g Dye terminators => 'term.' (String)

sample_title[RW]

The sample title as entered when sequencing the sample (String)

Public Class Methods

new(string) click to toggle source

see SangerChromatogram class for how to create an Abif object and its usage

# File lib/bio/db/sanger_chromatogram/abif.rb, line 37
def initialize(string)
  header = string.slice(0,128)
  # read in header info
  @chromatogram_type, @version, @directory_tag_name, @directory_tag_number, @directory_element_type, @directory_element_size, @directory_number_of_elements, @directory_data_size, @directory_data_offset, @directory_data_handle= header.unpack("a4 n a4 N n n N N N N")
  @version = @version/100.to_f
  get_directory_entries(string)
  # get sequence
  @sequence = @directory_entries["PBAS"][1].data.map{|char| char.chr.downcase}.join("")
  #get peak indices
  @peak_indices = @directory_entries["PLOC"][1].data
  #get qualities
  @qualities = @directory_entries["PCON"][1].data
  # get sample title
  @sample_title = @directory_entries["SMPL"][1].data
  @directory_entries["PDMF"].size > 2 ? @dye_mobility = @directory_entries["PDMF"][2].data : @dye_mobility = @directory_entries["PDMF"][1].data
  #get trace data
  @chemistry = @directory_entries["phCH"][1].data
  base_order = @directory_entries["FWO_"][1].data.map{|char| char.chr.downcase}
  (9..12).each do |data_index|
    self.instance_variable_set("@#{base_order[data_index-9]}trace", @directory_entries["DATA"][data_index].data)
  end

end

Public Instance Methods

data(name, tag_number = 1) click to toggle source

Returns the data for the name. If not found, returns nil.


Arguments:

  • (required) name: (String) name of the data

  • (required) tag_number: (Integer) tag number (default 1)

Returns

any data type or nil

# File lib/bio/db/sanger_chromatogram/abif.rb, line 68
def data(name, tag_number = 1)
  d = @directory_entries[name]
  d ? d[tag_number].data : nil
end