Class: Bio::Genscan::Report

Inherits:
Object show all
Defined in:
lib/bio/appl/genscan/report.rb

Overview

Bio::Genscan::Report - Class for Genscan report output.

Parser for the Genscan report output.

Defined Under Namespace

Classes: Exon, Gene

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ Report

Bio::Genscan::Report.new(str)

Parse a Genscan report output string.


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/bio/appl/genscan/report.rb', line 67

def initialize(report)
  @predictions = []
  @genscan_version = nil
  @date_run   = nil
  @time       = nil
  @query_name = nil
  @length     = nil
  @gccontent  = nil
  @isochore   = nil
  @matrix     = nil

  report.each_line("\n") do |line|
    case line
    when /^GENSCAN/
      parse_headline(line)
    when /^Sequence/
      parse_sequence(line)
    when /^Parameter/
      parse_parameter(line)
    when /^Predicted genes/
      break
    end
  end

  # rests
  i = report.index(/^Predicted gene/)
  j = report.index(/^Predicted peptide sequence/)

  # genes/exons
  genes_region = report[i...j]
  genes_region.each_line("\n") do |line|
    if /Init|Intr|Term|PlyA|Prom|Sngl/ =~ line
      gn, en = line.strip.split(" +")[0].split(/\./).map {|i| i.to_i }
      add_exon(gn, en, line)
    end
  end

  # sequences (peptide|CDS)
  sequence_region = report[j...report.size]
  sequence_region.gsub!(/^Predicted .+?:/, '')
  sequence_region.gsub!(/^\s*$/, '')
  sequence_region.split(Bio::FastaFormat::RS).each do |ff|
    add_seq(Bio::FastaFormat.new(ff))
  end
end

Instance Attribute Details

#date_runObject (readonly)

Returns


36
37
38
# File 'lib/bio/appl/genscan/report.rb', line 36

def date_run
  @date_run
end

#gccontentObject (readonly)

Returns C+G content of the query sequence.


50
51
52
# File 'lib/bio/appl/genscan/report.rb', line 50

def gccontent
  @gccontent
end

#genscan_versionObject (readonly)

Returns Genscan version.


33
34
35
# File 'lib/bio/appl/genscan/report.rb', line 33

def genscan_version
  @genscan_version
end

#isochoreObject (readonly)

Returns


53
54
55
# File 'lib/bio/appl/genscan/report.rb', line 53

def isochore
  @isochore
end

#lengthObject (readonly)

Returns Length of the query sequence.


47
48
49
# File 'lib/bio/appl/genscan/report.rb', line 47

def length
  @length
end

#matrixObject (readonly)

Returns


56
57
58
# File 'lib/bio/appl/genscan/report.rb', line 56

def matrix
  @matrix
end

#predictionsObject (readonly) Also known as: prediction, genes

Returns Array of Bio::Genscan::Report::Gene.


59
60
61
# File 'lib/bio/appl/genscan/report.rb', line 59

def predictions
  @predictions
end

#query_nameObject (readonly) Also known as: sequence_name, name

Returns Name of query sequence.


42
43
44
# File 'lib/bio/appl/genscan/report.rb', line 42

def query_name
  @query_name
end

#timeObject (readonly)

Returns


39
40
41
# File 'lib/bio/appl/genscan/report.rb', line 39

def time
  @time
end