Class: BioDSL::WriteFasta
- Inherits:
-
Object
- Object
- BioDSL::WriteFasta
- Defined in:
- lib/BioDSL/commands/write_fasta.rb
Overview
Write sequences from stream in FASTA format.
Description
write_fasta
writes sequence from the data stream in FASTA format. However, a FASTA entry will only be written if a SEQ key and a SEQ_NAME key is present. An example FASTA entry:
>test1
TATGACGCGCATCGACAGCAGCACGAGCATGCATCGACTG
TGCACTGACTACGAGCATCACTATATCATCATCATAATCT
TACGACATCTAGGGACTAC
For more about the FASTA format:
en.wikipedia.org/wiki/FASTA_format
Usage
write_fasta([wrap: <uin>[, output: <file>[, force: <bool>
[, gzip: <bool> | bzip2: <bool>]]]])
Options
-
output <file> - Output file.
-
force <bool> - Force overwrite existing output file.
-
wrap <uint> - Wrap sequence into lines of wrap length.
-
gzip <bool> - Write gzipped output file.
-
bzip2 <bool> - Write bzipped output file.
Examples
To write FASTA entries to STDOUT.
write_fasta
To write FASTA entries wrapped in lines of length of 80 to STDOUT.
write_fasta(wrap: 80)
To write FASTA entries to a file ‘test.fna’.
write_fasta(output: "test.fna")
To overwrite output file if this exists use the force option:
write_fasta(output: "test.fna", force: true)
To write gzipped FASTA entries to file ‘test.fna.gz’.
write_fasta(output: "test.fna.gz", gzip: true)
To write bzipped FASTA entries to file ‘test.fna.bz2’.
write_fasta(output: "test.fna.bz2", bzip2: true)
Constant Summary collapse
- STATS =
%i(records_in records_out sequences_in sequences_out residues_in residues_out)
Instance Method Summary collapse
-
#initialize(options) ⇒ WriteFasta
constructor
Constructor for the WriteFasta class.
-
#lmb ⇒ Proc
Return a lambda for the write_fasta command.
Constructor Details
#initialize(options) ⇒ WriteFasta
Constructor for the WriteFasta class.
97 98 99 100 101 |
# File 'lib/BioDSL/commands/write_fasta.rb', line 97 def initialize() @options = @options[:output] ||= $stdout end |
Instance Method Details
#lmb ⇒ Proc
Return a lambda for the write_fasta command.
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/BioDSL/commands/write_fasta.rb', line 106 def lmb lambda do |input, output, status| status_init(status, STATS) if @options[:output] == $stdout write_stdout(input, output) else write_file(input, output) end end end |