class Bio::Meme::Mast::Report

Description

A class to parse the output from Mast

WARNING: Currently support is only for -hit_list (machine readable) format

HTML (default) output is not supported

Examples

Attributes

motifs[R]

Public Class Methods

new(mast_hitlist) click to toggle source
# File lib/bio/appl/meme/mast/report.rb, line 40
def initialize(mast_hitlist)
  @motifs = parse_hit_list(mast_hitlist)
end

Public Instance Methods

each() { |motif| ... } click to toggle source

Iterates each motif (Bio::Meme::Motif)

# File lib/bio/appl/meme/mast/report.rb, line 45
def each
  @motifs.each do |motif|
    yield motif
  end
end
Also aliased as: each_motif
each_motif()
Alias for: each

Private Instance Methods

parse_hit_list(data) click to toggle source

Each line corresponds to one motif occurrence in one sequence.

The format of the hit lines is
       [<sequence_name> <strand><motif> <start> <end> <p-value>]+
where 
        <sequence_name> is the name of the sequence containing the hit
        <strand>        is the strand (+ or - for DNA, blank for protein),
        <motif>         is the motif number,
        <start>         is the starting position of the hit,
        <end>           is the ending position of the hit, and
        <p-value>       is the position p-value of the hit.
# File lib/bio/appl/meme/mast/report.rb, line 65
def parse_hit_list(data)
  motifs = []
  data.each_line do |line|
    
    line.chomp!
    
    # skip comments
    next if line =~ /^#/
    
    fields = line.split(/\s/)
    
    if fields.size == 5
      motifs << Motif.new(fields[0], strand = nil, fields[1], fields[2], fields[3], fields[4])
    elsif fields.size == 6
      motifs << Motif.new(fields[0], fields[1], fields[2], fields[3], fields[4], fields[5])
    else
      raise RuntimeError.new("Could not parse mast output")
    end
    
  end
  motifs
end