class Bio::SangerChromatogram

Description

This is the Superclass for the Abif and Scf classes that allow importing of the common scf and abi sequence chromatogram formats The following attributes are Common to both the Abif and Scf subclasses

Usage

filename = "path/to/sequence_chromatogram_file"

for Abif files

chromatogram_ff = Bio::Abif.open(filename)

for Scf files

chromatogram_ff = Bio::Scf.open(filename)

chromatogram = chromatogram_ff.next_entry
chromatogram.to_seq # => returns a Bio::Sequence object
chromatogram.sequence # => returns the sequence contained within the chromatogram as a string
chromatogram.qualities # => returns an array of quality values for each base
chromatogram.atrace # => returns an array of the a trace y positions

Attributes

atrace[RW]

An array of ‘y’ positions (see description) for the ‘A’ trace from the chromatogram (Array

chromatogram_type[RW]

The type of chromatogram file .scf for Scf files and ABIF doe Abif files

ctrace[RW]

An array of ‘y’ positions (see description) for the ‘C’ trace from the chromatogram (Array

dye_mobility[RW]

The mobility of the dye used when sequencing (String)

gtrace[RW]

An array of ‘y’ positions (see description) for the ‘G’ trace from the chromatogram (Array

peak_indices[RW]

An array ‘x’ positions (see description) on the trace where the bases occur/have been called (Array)

qualities[RW]

An array of quality scores for each base in the sequence (Array)

sequence[RW]

The sequence contained within the chromatogram (String)

ttrace[RW]

An array of ‘y’ positions (see description) for the ‘T’ trace from the chromatogram (Array

version[RW]

The Version of the Scf or Abif file (String)

Public Class Methods

open(filename) click to toggle source
   # File lib/bio/db/sanger_chromatogram/chromatogram.rb
73 def self.open(filename)
74   Bio::FlatFile.open(self, filename)
75 end

Public Instance Methods

complement() click to toggle source

Returns a new chromatogram object of the appropriate subclass (scf or abi) where the sequence, traces and qualities have all been revesed and complemented

    # File lib/bio/db/sanger_chromatogram/chromatogram.rb
126 def complement
127   chromatogram = self.dup
128   chromatogram.complement!
129   return chromatogram
130 end
complement!() click to toggle source

Reverses and complements the current chromatogram object including its sequence, traces and qualities

    # File lib/bio/db/sanger_chromatogram/chromatogram.rb
 95 def complement!
 96   # reverse traces
 97   tmp_trace = @atrace
 98   @atrace = @ttrace.reverse
 99   @ttrace = tmp_trace.reverse
100   tmp_trace = @ctrace
101   @ctrace = @gtrace.reverse
102   @gtrace = tmp_trace.reverse
103 
104   # reverse base qualities
105   if (defined? @aqual) && @aqual # if qualities exist
106     tmp_qual = @aqual
107     @aqual = @tqual.reverse
108     @tqual = tmp_qual.reverse
109     tmp_qual = @cqual
110     @cqual = @gqual.reverse
111     @gqual = tmp_qual.reverse
112   end
113 
114   #reverse qualities
115   @qualities = @qualities.reverse
116 
117   #reverse peak indices
118   @peak_indices = @peak_indices.map{|index| @atrace.size - index}
119   @peak_indices.reverse!
120 
121   # reverse sequence
122   @sequence = @sequence.reverse.tr('atgcnrykmswbvdh','tacgnyrmkswvbhd')
123 end
seq() click to toggle source

Returns a Bio::Sequence::NA object based on the sequence from the chromatogram

   # File lib/bio/db/sanger_chromatogram/chromatogram.rb
78 def seq
79   Bio::Sequence::NA.new(@sequence)
80 end
sequence_string() click to toggle source

Returns the sequence from the chromatogram as a string

   # File lib/bio/db/sanger_chromatogram/chromatogram.rb
89 def sequence_string
90   @sequence
91 end
to_biosequence() click to toggle source

Returns a Bio::Sequence object based on the sequence from the chromatogram

   # File lib/bio/db/sanger_chromatogram/chromatogram.rb
83 def to_biosequence
84   Bio::Sequence.adapter(self, Bio::Sequence::Adapter::SangerChromatogram)
85 end
Also aliased as: to_seq
to_seq()
Alias for: to_biosequence