Class: Bio::SangerChromatogram
- Defined in:
- lib/bio/db/sanger_chromatogram/chromatogram.rb
Overview
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
-
chromatogram_type (String): This is extracted from the chromatogram file itself and will probably be either .scf or ABIF for Scf and Abif files respectively.
-
version (String): The version of the Scf or Abif file
-
sequence (String): the sequence contained within the chromatogram as a string.
-
qualities (Array): the quality scores of each base as an array of integers. These will probably be phred scores.
-
peak_indices (Array): if the sequence traces contained within the chromatogram are imagined
as being plotted on an x,y graph, the peak indices are the x positions of the peaks that
represent the nucleotides bases found in the sequence from the chromatogram. For example if
the peak_indices are [16,24,37,49 .…] and the sequence is AGGT.…, at position 16 the
traces in the chromatogram were base-called as an A, position 24 a G, position 37 a G, position 49 a T etc
-
atrace, ctrace, gtrace, ttrace (Array): If the sequence traces contained within the chromatogram are imagined as being plotted on an x,y graph, these attributes are arrays of y positions for each of the 4 nucleotide bases along the length of the x axis. If these were plotted joined by lines of different colours then the resulting graph should look like the original chromatogram file when viewed in a chromtogram viewer such as Chromas, 4Peaks or FinchTV.
-
dye_mobility (String): The mobility of the dye used when sequencing. This can influence the base calling
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
Instance Attribute Summary collapse
-
#atrace ⇒ Object
An array of ‘y’ positions (see description) for the ‘A’ trace from the chromatogram (Array.
-
#chromatogram_type ⇒ Object
The type of chromatogram file .scf for Scf files and ABIF doe Abif files.
-
#ctrace ⇒ Object
An array of ‘y’ positions (see description) for the ‘C’ trace from the chromatogram (Array.
-
#dye_mobility ⇒ Object
The mobility of the dye used when sequencing (String).
-
#gtrace ⇒ Object
An array of ‘y’ positions (see description) for the ‘G’ trace from the chromatogram (Array.
-
#peak_indices ⇒ Object
An array ‘x’ positions (see description) on the trace where the bases occur/have been called (Array).
-
#qualities ⇒ Object
An array of quality scores for each base in the sequence (Array).
-
#sequence ⇒ Object
The sequence contained within the chromatogram (String).
-
#ttrace ⇒ Object
An array of ‘y’ positions (see description) for the ‘T’ trace from the chromatogram (Array.
-
#version ⇒ Object
The Version of the Scf or Abif file (String).
Class Method Summary collapse
Instance Method Summary collapse
-
#complement ⇒ Object
Returns a new chromatogram object of the appropriate subclass (scf or abi) where the sequence, traces and qualities have all been revesed and complemented.
-
#complement! ⇒ Object
Reverses and complements the current chromatogram object including its sequence, traces and qualities.
-
#seq ⇒ Object
Returns a Bio::Sequence::NA object based on the sequence from the chromatogram.
-
#sequence_string ⇒ Object
Returns the sequence from the chromatogram as a string.
-
#to_biosequence ⇒ Object
(also: #to_seq)
Returns a Bio::Sequence object based on the sequence from the chromatogram.
Instance Attribute Details
#atrace ⇒ Object
An array of ‘y’ positions (see description) for the ‘A’ trace from the chromatogram (Array
64 65 66 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 64 def atrace @atrace end |
#chromatogram_type ⇒ Object
The type of chromatogram file .scf for Scf files and ABIF doe Abif files
54 55 56 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 54 def chromatogram_type @chromatogram_type end |
#ctrace ⇒ Object
An array of ‘y’ positions (see description) for the ‘C’ trace from the chromatogram (Array
66 67 68 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 66 def ctrace @ctrace end |
#dye_mobility ⇒ Object
The mobility of the dye used when sequencing (String)
72 73 74 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 72 def dye_mobility @dye_mobility end |
#gtrace ⇒ Object
An array of ‘y’ positions (see description) for the ‘G’ trace from the chromatogram (Array
68 69 70 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 68 def gtrace @gtrace end |
#peak_indices ⇒ Object
An array ‘x’ positions (see description) on the trace where the bases occur/have been called (Array)
62 63 64 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 62 def peak_indices @peak_indices end |
#qualities ⇒ Object
An array of quality scores for each base in the sequence (Array)
60 61 62 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 60 def qualities @qualities end |
#sequence ⇒ Object
The sequence contained within the chromatogram (String)
58 59 60 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 58 def sequence @sequence end |
#ttrace ⇒ Object
An array of ‘y’ positions (see description) for the ‘T’ trace from the chromatogram (Array
70 71 72 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 70 def ttrace @ttrace end |
#version ⇒ Object
The Version of the Scf or Abif file (String)
56 57 58 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 56 def version @version end |
Class Method Details
Instance Method Details
#complement ⇒ Object
Returns a new chromatogram object of the appropriate subclass (scf or abi) where the sequence, traces and qualities have all been revesed and complemented
127 128 129 130 131 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 127 def complement chromatogram = self.dup chromatogram.complement! return chromatogram end |
#complement! ⇒ Object
Reverses and complements the current chromatogram object including its sequence, traces and qualities
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 96 def complement! # reverse traces tmp_trace = @atrace @atrace = @ttrace.reverse @ttrace = tmp_trace.reverse tmp_trace = @ctrace @ctrace = @gtrace.reverse @gtrace = tmp_trace.reverse # reverse base qualities if !@aqual.nil? # if qualities exist tmp_qual = @aqual @aqual = @tqual.reverse @tqual = tmp_qual.reverse tmp_qual = @cqual @cqual = @gqual.reverse @gqual = tmp_qual.reverse end #reverse qualities @qualities = @qualities.reverse #reverse peak indices @peak_indices = @peak_indices.map{|index| @atrace.size - index} @peak_indices.reverse! # reverse sequence @sequence = @sequence.reverse.tr('atgcnrykmswbvdh','tacgnyrmkswvbhd') end |
#seq ⇒ Object
Returns a Bio::Sequence::NA object based on the sequence from the chromatogram
79 80 81 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 79 def seq Bio::Sequence::NA.new(@sequence) end |
#sequence_string ⇒ Object
Returns the sequence from the chromatogram as a string
90 91 92 |
# File 'lib/bio/db/sanger_chromatogram/chromatogram.rb', line 90 def sequence_string @sequence end |