Class: Bio::GFF::GFF3::Record

Inherits:
Bio::GFF::GFF2::Record show all
Includes:
Escape
Defined in:
lib/bio/db/gff.rb

Overview

Represents a single line of a GFF3-formatted file. See Bio::GFF::GFF3 for more information.

Direct Known Subclasses

RecordBoundary

Defined Under Namespace

Classes: Gap, Target

Constant Summary

Constants included from Escape

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

Constants included from Bio::GFF::GFF2::Escape

Bio::GFF::GFF2::Escape::BACKSLASH, Bio::GFF::GFF2::Escape::CHAR2BACKSLASH, Bio::GFF::GFF2::Escape::CHAR2BACKSLASH_EXTENDED, Bio::GFF::GFF2::Escape::IDENTIFIER_GFF2, Bio::GFF::GFF2::Escape::NUMERIC_GFF2, Bio::GFF::GFF2::Escape::PROHIBITED_GFF2_COLUMNS, Bio::GFF::GFF2::Escape::PROHIBITED_GFF2_TAGS, Bio::GFF::GFF2::Escape::UNSAFE_GFF2

Instance Attribute Summary

Attributes inherited from Bio::GFF::GFF2::Record

#comment

Attributes inherited from Record

#attributes, #comment, #end, #feature, #frame, #score, #seqname, #source, #start, #strand

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bio::GFF::GFF2::Record

#==, #add_attribute, #attributes_to_hash, #comment_only?, #comments, #comments=, #delete_attribute, #delete_attributes, #get_attribute, #get_attributes, #replace_attributes, #set_attribute, #sort_attributes_by_tag!

Methods inherited from Record

#comments, #comments=

Constructor Details

#initialize(*arg) ⇒ Record

Creates a Bio::GFF::GFF3::Record object. Is typically not called directly, but is called automatically when creating a Bio::GFF::GFF3 object.


Arguments:

  • str: a tab-delimited line in GFF3 format

Arguments:

  • seqid: sequence ID (String or nil)

  • source: source (String or nil)

  • feature_type: type of feature (String)

  • start_position: start (Integer)

  • end_position: end (Integer)

  • score: score (Float or nil)

  • strand: strand (String or nil)

  • phase: phase (Integer or nil)

  • attributes: attributes (Array or nil)



1130
1131
1132
# File 'lib/bio/db/gff.rb', line 1130

def initialize(*arg)
  super(*arg)
end

Class Method Details

.parse(str) ⇒ Object

Parses a GFF3-formatted line and returns a new Bio::GFF::GFF3::Record object.



1109
1110
1111
# File 'lib/bio/db/gff.rb', line 1109

def self.parse(str)
  self.new.parse(str)
end

Instance Method Details

#idObject

shortcut to the ID attribute



1083
1084
1085
# File 'lib/bio/db/gff.rb', line 1083

def id
  get_attribute('ID')
end

#id=(str) ⇒ Object

set ID attribute



1088
1089
1090
# File 'lib/bio/db/gff.rb', line 1088

def id=(str)
  set_attribute('ID', str)
end

#parse(string) ⇒ Object

Parses a GFF3-formatted line and stores data from the string. Note that all existing data is wiped out.



1136
1137
1138
# File 'lib/bio/db/gff.rb', line 1136

def parse(string)
  super
end

#to_sObject

Return the record as a GFF3 compatible string



1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
# File 'lib/bio/db/gff.rb', line 1141

def to_s
  cmnt = if @comment and !@comment.to_s.strip.empty? then
           @comment.gsub(/[\r\n]+/, ' ')
         else
           false
         end
  return "\##{cmnt}\n" if self.comment_only? and cmnt
  [
   escape_seqid(column_to_s(@seqname)),
   escape(column_to_s(@source)),
   escape(column_to_s(@feature)),
   escape(column_to_s(@start)),
   escape(column_to_s(@end)),
   escape(column_to_s(@score)),
   escape(column_to_s(@strand)),
   escape(column_to_s(@frame)),
   attributes_to_s(@attributes)
  ].join("\t") + 
    (cmnt ? "\t\##{cmnt}\n" : "\n")
end