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)



1157
1158
1159
# File 'lib/bio/db/gff.rb', line 1157

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.



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

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

Instance Method Details

#idObject

shortcut to the ID attribute



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

def id
  get_attribute('ID')
end

#id=(str) ⇒ Object

set ID attribute



1115
1116
1117
# File 'lib/bio/db/gff.rb', line 1115

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.



1163
1164
1165
# File 'lib/bio/db/gff.rb', line 1163

def parse(string)
  super
end

#to_sObject

Return the record as a GFF3 compatible string



1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
# File 'lib/bio/db/gff.rb', line 1168

def to_s
  cmnt = if defined?(@comment) and @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