forked from BioinformaticsArchive/blasr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SplitContigs.cpp
47 lines (42 loc) · 1.04 KB
/
SplitContigs.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "../common/FASTAReader.h"
#include "../common/FASTASequence.h"
#include "../common/utils.h"
#include <string>
#include <stdlib.h>
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char* argv[]) {
if (argc < 4) {
cout << "usage: splitContigs in.fa contiglength out" << endl;
exit(1);
}
string inFileName, outFileName;
inFileName = argv[1];
int contigLength = atoi(argv[2]);
outFileName = argv[3];
ofstream seqOut;
CrucialOpen(outFileName, seqOut, std::ios::out);
FASTAReader reader;
reader.Init(inFileName);
FASTASequence seq;
DNALength curOffset;
while(reader.GetNext(seq)) {
FASTASequence subseq;
int i;
curOffset = 0;
for (i =0 ; i < seq.length / contigLength + 1; i++ ) {
subseq.seq = &seq.seq[curOffset];
subseq.title = seq.title;
if (curOffset + contigLength > seq.length) {
subseq.length = seq.length - curOffset;
}
else {
subseq.length = contigLength;
}
subseq.PrintSeq(seqOut);
curOffset += contigLength;
}
}
return 0;
}