-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadsimulator.cpp
26 lines (22 loc) · 1.13 KB
/
readsimulator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "readsimulator.h"
#include "fastq.h"
#include "stringutils.h"
void ReadSimulator::SimulatePairEnd( std::ofstream& out1, std::ofstream& out2,
const size_t insertSize, const size_t readLength) {
this->qualityString = std::string(readLength, 'I') ;
for(int i = 0 ; i < _reference.GetSequence().size() - readLength - insertSize ; ++i)
{
std::string firstReadID = "r" + std::to_string(i) + "/1";
std::string secondReadID = "r" + std::to_string(i) + "/2";
FASTQRead read1 = GenerateRead(i, readLength, firstReadID);
FASTQRead read2 = GenerateReverseRead(i + insertSize - readLength, readLength, secondReadID);
read1.Write(out1);
read2.Write(out2);
}
}
FASTQRead ReadSimulator::GenerateRead(size_t position, size_t length, std::string readName) {
return FASTQRead(readName, _reference.GetSequence().substr(position, length), qualityString);
}
FASTQRead ReadSimulator::GenerateReverseRead(size_t position, size_t length, std::string readName) {
return FASTQRead(readName, stringutil::reverse_complement(_reference.GetSequence().substr(position, length)), qualityString);
}