class Bio::FastaNumericFormat

Treats a FASTA formatted numerical entry, such as:

>id and/or some comments                    <== comment line
24 15 23 29 20 13 20 21 21 23 22 25 13      <== numerical data
22 17 15 25 27 32 26 32 29 29 25

The precedent '>' can be omitted and the trailing '>' will be removed automatically.

Bio::FastaFormat.new

Stores the comment and the list of the numerical data.

Bio::FastaFormat#definition

The comment line of the FASTA formatted data.

Public Instance Methods

[](n) click to toggle source

Returns the n-th element. If out of range, returns nil.


Arguments:

  • (required) n: (Integer) position

Returns

(Integer or nil) the value

# File lib/bio/db/fasta/qual.rb, line 94
def [](n)
  data[n]
end
data() click to toggle source

Returns the list of the numerical data (typically the quality score of its corresponding sequence) as an Array.


Returns

(Array containing Integer) numbers

# File lib/bio/db/fasta/qual.rb, line 64
def data
  unless defined?(@list)
    @list = @data.strip.split(/\s+/).map {|x| x.to_i}
  end
  @list
end
each() { |x| ... } click to toggle source

Yields on each elements of the numerical data.


Yields

(Integer) a numerical data element

Returns

(undefined)

# File lib/bio/db/fasta/qual.rb, line 83
def each
  data.each do |x|
    yield x
  end
end
length() click to toggle source

Returns the number of elements in the numerical data, which will be the same of its corresponding sequence length.


Returns

(Integer) the number of elements

# File lib/bio/db/fasta/qual.rb, line 75
def length
  data.length
end
to_biosequence() click to toggle source

Returns the data as a Bio::Sequence object. In the returned sequence object, the length of the sequence is zero, and the numeric data is stored to the Bio::Sequence#quality_scores attirbute.

Because the meaning of the numeric data is unclear, Bio::Sequence#quality_score_type is not set by default.

Note: If you modify the returned Bio::Sequence object, the sequence or definition in this FastaNumericFormat object might also be changed (but not always be changed) because of efficiency.


Arguments:

Returns

(Bio::Sequence) sequence object

# File lib/bio/db/fasta/qual.rb, line 114
def to_biosequence
  s = Bio::Sequence.adapter(self,
                            Bio::Sequence::Adapter::FastaNumericFormat)
  s.seq = Bio::Sequence::Generic.new('')
  s
end
Also aliased as: to_seq
to_seq()
Alias for: to_biosequence