Class: Bio::GFF::GFF3::SequenceRegion

Inherits:
Object
  • Object
show all
Includes:
Escape
Defined in:
lib/bio/db/gff.rb

Overview

Stores meta-data “##sequence-region seqid start end”.

Constant Summary

Constants included from Escape

Escape::UNSAFE, Escape::UNSAFE_ATTRIBUTE, Escape::UNSAFE_SEQID

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seqid, start, endpos) ⇒ SequenceRegion

creates a new SequenceRegion class



1033
1034
1035
1036
1037
# File 'lib/bio/db/gff.rb', line 1033

def initialize(seqid, start, endpos)
  @seqid = seqid
  @start = start ? start.to_i : nil
  @end = endpos ? endpos.to_i : nil
end

Instance Attribute Details

#endObject

end position



1053
1054
1055
# File 'lib/bio/db/gff.rb', line 1053

def end
  @end
end

#seqidObject

sequence ID



1047
1048
1049
# File 'lib/bio/db/gff.rb', line 1047

def seqid
  @seqid
end

#startObject

start position



1050
1051
1052
# File 'lib/bio/db/gff.rb', line 1050

def start
  @start
end

Class Method Details

.parse(str) ⇒ Object

parses given string and returns SequenceRegion class



1040
1041
1042
1043
1044
# File 'lib/bio/db/gff.rb', line 1040

def self.parse(str)
  dummy, seqid, start, endpos =
    str.chomp.split(/\s+/, 4).collect { |x| URI.unescape(x) }
  self.new(seqid, start, endpos)
end

Instance Method Details

#==(other) ⇒ Object

Returns true if self == other. Otherwise, returns false.



1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
# File 'lib/bio/db/gff.rb', line 1064

def ==(other)
  if other.class == self.class and
      other.seqid == self.seqid and
      other.start == self.start and
      other.end == self.end then
    true
  else
    false
  end
end

#to_sObject

string representation



1056
1057
1058
1059
1060
1061
# File 'lib/bio/db/gff.rb', line 1056

def to_s
  i = escape_seqid(column_to_s(@seqid))
  s = escape_seqid(column_to_s(@start))
  e = escape_seqid(column_to_s(@end))
  "##sequence-region #{i} #{s} #{e}\n"
end