module Bio::BioAlignment::Coerce

Public Class Methods

fetch_id(seq) click to toggle source

Make BioRuby's entry_id compatible with id

# File lib/bio-alignment/coerce.rb, line 5
def Coerce::fetch_id seq
  if seq.respond_to?(:id)
    seq.id
  elsif seq.respond_to?(:entry_id)
    seq.entry_id
  else
    "id?"
  end
end
fetch_seq(seq) click to toggle source

Coerce BioRuby's sequence objects to return the sequence itself

# File lib/bio-alignment/coerce.rb, line 16
def Coerce::fetch_seq seq
  if seq.respond_to?(:seq)
    seq.seq
  else
    seq
  end
end
fetch_seq_string(seq) click to toggle source

Coerce sequence objects into a string

# File lib/bio-alignment/coerce.rb, line 25
def Coerce::fetch_seq_string seq
  s = fetch_seq(seq)
  if s.respond_to?(:join)
    s.join
  else
    s.to_s
  end
end
to_elements(seq) click to toggle source

Coerce sequence objects into elements

# File lib/bio-alignment/coerce.rb, line 35
def Coerce::to_elements seq
  if seq.respond_to?(:to_elements)
    seq.to_elements
  else
    Elements.new(fetch_id(seq),fetch_seq(seq))
  end
end