Class: BioDSL::Usearch::IO
Overview
Class for Usearch IO.
Instance Attribute Summary
Attributes inherited from Filesys
Instance Method Summary collapse
-
#each(format = :uc) ⇒ Object
Parse a given type of Uclust format and yield the result.
-
#each_uc {|Hash| ... } ⇒ Object
Parse each UC type record and yield the result.
Methods inherited from Filesys
#close, #eof?, #gets, #initialize, open, #puts, #read, tmpfile, which, #write
Constructor Details
This class inherits a constructor from BioDSL::Filesys
Instance Method Details
#each(format = :uc) ⇒ Object
Parse a given type of Uclust format and yield the result.
266 267 268 269 270 271 272 |
# File 'lib/BioDSL/usearch.rb', line 266 def each(format = :uc) case format when :uc then each_uc { |e| yield e } else fail UsearchError, "Unknown iterator format: #{format}" end end |
#each_uc {|Hash| ... } ⇒ Object
Parse each UC type record and yield the result.
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/BioDSL/usearch.rb', line 279 def each_uc @io.each do |line| fields = line.chomp.split("\t") record = {TYPE: fields[0], CLUSTER: fields[1].to_i} case fields[0] when 'C' then record[:CLUSTER_SIZE] = fields[2].to_i else record[:SEQ_LEN] = fields[2].to_i end record[:IDENT] = fields[3].to_f if fields[0] == 'H' record[:STRAND] = fields[4] record[:CIGAR] = fields[7] record[:Q_ID] = fields[8] record[:S_ID] = fields[9] if fields[0] == 'H' yield record end end |