class Bio::FlatFile::Splitter::Default
Default
splitter. It sees following constants in the given class.
- DELIMITER
-
(String) delimiter indicates the end of a entry.
- FLATFILE_HEADER
-
(String) start of a entry, located on head of a line.
- DELIMITER_OVERRUN
-
(Integer) excess read size included in DELIMITER.
Attributes
(String) delimiter indicates the end of a entry.
(Integer) excess read data size included in delimiter.
(String) start of a entry, located on head of a line.
Public Class Methods
Source
# File lib/bio/io/flatfile/splitter.rb 129 def initialize(klass, bstream) 130 super(klass, bstream) 131 132 @delimiter = klass::DELIMITER rescue nil 133 @header = klass::FLATFILE_HEADER rescue nil 134 # for specific classes' benefit 135 unless header 136 if (defined?(Bio::GenBank) and klass == Bio::GenBank) or 137 (defined?(Bio::GenPept) and klass == Bio::GenPept) 138 @header = 'LOCUS ' 139 end 140 end 141 @delimiter_overrun = klass::DELIMITER_OVERRUN rescue nil 142 end
Creates a new splitter.
- klass
-
database class
- bstream
-
input stream. It must be a
BufferedInputStream
object.
Calls superclass method
Bio::FlatFile::Splitter::Template::new
Public Instance Methods
Source
# File lib/bio/io/flatfile/splitter.rb 181 def get_entry 182 p0 = stream_pos() 183 e = stream.gets(@delimiter) 184 if e and @delimiter_overrun then 185 if e[-@delimiter.size, @delimiter.size ] == @delimiter then 186 overrun = e[-@delimiter_overrun, @delimiter_overrun] 187 e[-@delimiter_overrun, @delimiter_overrun] = '' 188 stream.ungets(overrun) 189 end 190 end 191 p1 = stream_pos() 192 self.entry_start_pos = p0 193 self.entry = e 194 self.entry_ended_pos = p1 195 return entry 196 end
gets a entry
Source
# File lib/bio/io/flatfile/splitter.rb 159 def skip_leader 160 if @header then 161 data = String.new 162 while s = stream.gets(@header) 163 data << s 164 if data.split(/[\r\n]+/)[-1] == @header then 165 stream.ungets(@header) 166 return true 167 end 168 end 169 # @header was not found. For safety, 170 # pushes back data with removing white spaces in the head. 171 data.sub(/\A\s+/, '') 172 stream.ungets(data) 173 return nil 174 else 175 stream.skip_spaces 176 return nil 177 end 178 end
Skips leader of the entry.
If @header is not nil, it reads till the contents of @header comes at the head of a line. If correct FLATFILE_HEADER is found, returns true. Otherwise, returns nil.