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
-
chromatogram_type (String): This is extracted from the chromatogram file itself and will probably be either .scf or ABIF for
Scf
andAbif
files respectively. -
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 thetraces 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
Attributes
An array of ‘y’ positions (see description) for the ‘A’ trace from the chromatogram (Array
An array of ‘y’ positions (see description) for the ‘C’ trace from the chromatogram (Array
The mobility of the dye used when sequencing (String)
An array of ‘y’ positions (see description) for the ‘G’ trace from the chromatogram (Array
An array ‘x’ positions (see description) on the trace where the bases occur/have been called (Array)
An array of quality scores for each base in the sequence (Array)
The sequence contained within the chromatogram (String)
An array of ‘y’ positions (see description) for the ‘T’ trace from the chromatogram (Array
Public Class Methods
# File lib/bio/db/sanger_chromatogram/chromatogram.rb 73 def self.open(filename) 74 Bio::FlatFile.open(self, filename) 75 end
Public Instance Methods
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
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
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
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
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