Class | Bio::SangerChromatogram |
In: |
lib/bio/db/sanger_chromatogram/chromatogram.rb
|
Parent: | Object |
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
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
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) |
# File lib/bio/db/sanger_chromatogram/chromatogram.rb, line 74 74: def self.open(filename) 75: Bio::FlatFile.open(self, filename) 76: end
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, line 127 127: def complement 128: chromatogram = self.dup 129: chromatogram.complement! 130: return chromatogram 131: end
Reverses and complements the current chromatogram object including its sequence, traces and qualities
# File lib/bio/db/sanger_chromatogram/chromatogram.rb, line 96 96: def complement! 97: # reverse traces 98: tmp_trace = @atrace 99: @atrace = @ttrace.reverse 100: @ttrace = tmp_trace.reverse 101: tmp_trace = @ctrace 102: @ctrace = @gtrace.reverse 103: @gtrace = tmp_trace.reverse 104: 105: # reverse base qualities 106: if !@aqual.nil? # if qualities exist 107: tmp_qual = @aqual 108: @aqual = @tqual.reverse 109: @tqual = tmp_qual.reverse 110: tmp_qual = @cqual 111: @cqual = @gqual.reverse 112: @gqual = tmp_qual.reverse 113: end 114: 115: #reverse qualities 116: @qualities = @qualities.reverse 117: 118: #reverse peak indices 119: @peak_indices = @peak_indices.map{|index| @atrace.size - index} 120: @peak_indices.reverse! 121: 122: # reverse sequence 123: @sequence = @sequence.reverse.tr('atgcnrykmswbvdh','tacgnyrmkswvbhd') 124: end
Returns a Bio::Sequence::NA object based on the sequence from the chromatogram
# File lib/bio/db/sanger_chromatogram/chromatogram.rb, line 79 79: def seq 80: Bio::Sequence::NA.new(@sequence) 81: end
Returns the sequence from the chromatogram as a string
# File lib/bio/db/sanger_chromatogram/chromatogram.rb, line 90 90: def sequence_string 91: @sequence 92: end
Returns a Bio::Sequence object based on the sequence from the chromatogram
# File lib/bio/db/sanger_chromatogram/chromatogram.rb, line 84 84: def to_biosequence 85: Bio::Sequence.adapter(self, Bio::Sequence::Adapter::SangerChromatogram) 86: end