Class: FastaWriter
- Inherits:
-
Object
- Object
- FastaWriter
- Defined in:
- lib/bigbio/db/fasta/fastawriter.rb
Overview
Fasta writer
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(fn) ⇒ FastaWriter
constructor
Open a FASTA stream for writing.
-
#write(item) ⇒ Object
write a FASTA item.
Constructor Details
#initialize(fn) ⇒ FastaWriter
Open a FASTA stream for writing
6 7 8 |
# File 'lib/bigbio/db/fasta/fastawriter.rb', line 6 def initialize fn @f = File.open(fn,"w") end |
Instance Method Details
#close ⇒ Object
21 22 23 |
# File 'lib/bigbio/db/fasta/fastawriter.rb', line 21 def close @f.close end |
#write(item) ⇒ Object
write a FASTA item. An itex should respond to descr and seq, or id and seq
12 13 14 15 16 17 18 19 |
# File 'lib/bigbio/db/fasta/fastawriter.rb', line 12 def write item if item.respond_to?(:descr) @f.write ">"+item.descr+"\n" else @f.write ">"+item.id+"\n" end @f.write item.seq.to_s.strip+"\n" end |