class Bio::Assembly::Contig

Attributes

consensus_seq[RW]
from[RW]
name[RW]
orientation[RW]
quality[RW]
reads[RW]
seq[RW]
to[RW]

Public Class Methods

new(str="") click to toggle source
# File lib/bio-assembly/contig.rb, line 10
def initialize(str="")
  @reads = Hash.new
  @seq = Bio::Sequence::NA.new(str)
  # counter for Reads
  @rds_parsed = 0
end

Public Instance Methods

add_read(read) click to toggle source
# File lib/bio-assembly/contig.rb, line 40
def add_read(read)
  # TODO do some checks for pos location
  @reads[read.name] = read
end
each_read() { |read| ... } click to toggle source
# File lib/bio-assembly/contig.rb, line 45
def each_read
  @reads.each_value { |read| yield read }
end
find_read_by_name(name) click to toggle source
# File lib/bio-assembly/contig.rb, line 17
def find_read_by_name(name)
  @reads[name]
end
find_reads_in_range(clear_range_from, clear_range_to) click to toggle source
# File lib/bio-assembly/contig.rb, line 21
def find_reads_in_range(clear_range_from, clear_range_to)
  reads_in_range = Array.new
  each_read do |read|
    
    # Read starts in region
    if read.from+read.clear_range_from > clear_range_from and read.from+read.clear_range_from < clear_range_to
       reads_in_range.push read
    # Read ends in region
    elsif read.to+read.clear_range_to < clear_range_to and read.to+read.clear_range_to > clear_range_from
       reads_in_range.push read
    # Read encompasses region
    elsif read.from+read.clear_range_from < clear_range_from and read.to+read.clear_range_to > clear_range_to
       reads_in_range.push read
    end
    
  end
  reads_in_range;
end
num_base_segments() click to toggle source
# File lib/bio-assembly/contig.rb, line 61
def num_base_segments
  num_base_sequences = 0
  each_read do |read|
    num_base_sequences += read.base_sequences.size unless read.base_sequences.nil?
  end
  num_base_sequences
end
num_bases() click to toggle source
# File lib/bio-assembly/contig.rb, line 53
def num_bases
  seq.length
end
num_reads() click to toggle source
# File lib/bio-assembly/contig.rb, line 49
def num_reads
  @reads.size
end
seq=(str) click to toggle source
# File lib/bio-assembly/contig.rb, line 57
def seq=(str)
  @seq = Bio::Sequence::NA.new(str)
end