Class: BioDSL::Random
- Inherits:
-
Object
- Object
- BioDSL::Random
- Defined in:
- lib/BioDSL/commands/random.rb
Overview
Pick number of rand om records from the stream.
random
can be used to pick a random number of records from the stream. Note that the order of records is preserved.
Using the ‘pair: true` option allows random picking of interleaved paired-end sequence records.
Usage
random(<number: <uint>[, pairs: <bool>])
Options
-
number: <uint> - Number of records to pick.
-
pairs: <bool> - Preserve interleaved pair order.
Examples
To pick some random records from the stream do:
BD.new.
read_fasta(input: "in.fna").
random(number: 10_000).
write_fasta(output: "out.fna").
run
Constant Summary collapse
- STATS =
%i(records_in records_out)
Instance Method Summary collapse
-
#initialize(options) ⇒ Random
constructor
Constructor for Randowm.
-
#lmb ⇒ Proc
Return command lambda for random.
Constructor Details
#initialize(options) ⇒ Random
Constructor for Randowm.
66 67 68 69 70 71 |
# File 'lib/BioDSL/commands/random.rb', line 66 def initialize() @options = @wanted = nil end |
Instance Method Details
#lmb ⇒ Proc
Return command lambda for random.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/BioDSL/commands/random.rb', line 76 def lmb lambda do |input, output, status| status_init(status, STATS) TmpDir.create('random') do |file, _| process_input(input, file) decide_wanted process_output(output, file) end end end |