2
* @file shuffle_reads.cpp
3
* @brief Shuffle a set of reads.
4
* @author Yu Peng (ypeng@cs.hku.hk)
17
#include "misc/options_description.h"
18
#include "misc/utils.h"
19
#include "sequence/sequence.h"
20
#include "sequence/sequence_io.h"
24
int main(int argc, char *argv[])
26
OptionsDescription desc;
30
desc.Parse(argc, argv);
33
throw logic_error("not enough parameters");
38
cerr << e.what() << endl;
39
cerr << "shuffle_reads - shuffle reads." << endl;
40
cerr << "Usage: shuffle_reads reads.fq shuffle_reads.fa [...] " << endl;
41
cerr << "Allowed Options: " << endl;
46
deque<Sequence> reads;
48
ReadSequence(argv[1], reads, names);
50
int n = reads.size()/2;
52
for (int i = 0; i < n; ++i)
55
for (int i = 0; i < n; ++i)
56
swap(aux[i], aux[rand()%(n-i) + i]);
58
FastaWriter writer(argv[2]);
59
for (int i = 0; i < n; ++i)
61
writer.Write(reads[aux[i]*2], names[aux[i]*2]);
62
writer.Write(reads[aux[i]*2+1], names[aux[i]*2+1]);