2
2
3
3
void Caller::run () {
4
4
config = Configuration::getInstance ();
5
-
6
- load_chromosomes (config->reference );
7
- cout << " Loaded all chromosomes" << endl ;
5
+ lprint ({" PingPong SV Caller running on" , to_string (config->threads ), " threads.." }) ;
6
+ // load reference genome and SFS
7
+ load_chromosomes (config->reference ) ;
8
+ lprint ({" Loaded all chromosomes." }) ;
8
9
load_input_sfs () ;
9
-
10
- ovcf.open (config->workdir + " /svs_poa.vcf" );
10
+ // call SVs from extended SFS
11
+ vector<SV> svs ;
12
+ Extender extender = Extender (&SFSs) ;
13
+ extender.run (config->threads ) ;
14
+ svs.insert (svs.begin (), extender.svs .begin (), extender.svs .end ()) ;
15
+ lprint ({" Predicted" , to_string (svs.size ()), " SVs from extended SFS." }) ;
16
+ interval_tree_t <int > vartree ;
17
+ for (const auto & sv: svs) {
18
+ vartree.insert ({sv.s - 1000 , sv.e + 1000 }) ;
19
+ }
20
+ // call SVS from clipped SFS
21
+ Clipper clipper (extender.clips );
22
+ clipper.call (config->threads , vartree) ;
23
+ int s = 0 ;
24
+ for (int i = 0 ; i < config->threads ; i++) {
25
+ s += clipper._p_svs [i].size () ;
26
+ svs.insert (svs.begin (), clipper._p_svs [i].begin (), clipper._p_svs [i].end ()) ;
27
+ }
28
+ lprint ({" Predicted" , to_string (s), " SVs from extended SFS." }) ;
29
+ std::sort (svs.begin (), svs.end ()) ;
30
+ // output POA alignments SAM
11
31
osam.open (config->workdir + " /poa.sam" );
12
- // --- SAM header
13
32
osam << " @HD\t VN:1.4" << endl;
14
33
for (int i = 0 ; i < chromosomes.size (); ++i) {
15
34
osam << " @SQ\t SN:" << chromosomes[i] << " \t " << " LN:" << strlen (chromosome_seqs[chromosomes[i]]) << endl ;
16
35
}
17
- // --- VCF header
18
- print_vcf_header () ;
19
-
20
- // vector<vector<Consensus>> alignments(config->threads) ; // produce a SAM file of consensus alignments
21
- // vector<vector<SV>> svs(config->threads) ; // produce a SAM file of consensus alignments
22
- // #pragma omp parallel for num_threads(config->threads) schedule(static,1)
23
- // for(int i = 0; i < chromosomes.size(); i++) {
24
- // string chrom = chromosomes[i] ;
25
- // int t = i % config->threads ;
26
- // cout << "Processing chromosome " << chrom << ".. " << endl ;
27
-
28
- // Extender extender = Extender(chrom, &SFSs) ;
29
- // extender.run(4) ;
30
- // alignments[t].insert(alignments[t].begin(), extender.alignments.begin(), extender.alignments.end()) ;
31
- // svs[t].insert(svs[t].begin(), extender.svs.begin(), extender.svs.end()) ;
32
-
33
- // cout << svs[t].size() << " SVs." << endl ;
34
-
35
- // //Clipper clipper(chrom, extender.clips);
36
- // //clipper.call(reference[chrom], sv_tree);
37
- // //svs[omp_get_thread_num()].insert(svs[omp_get_thread_num()].begin(), clipper.svs.begin(), clipper.svs.end()) ;
38
- // }
39
- // for (int i = 0; i < config->threads; i++) {
40
- // for (int j = 0; j < alignments[i].size(); j++) {
41
- // const auto& c = alignments[i][j] ;
42
- // osam << c.chrom << ":" << c.s + 1 << "-" << c.e + 1 << "\t"
43
- // << "0"
44
- // << "\t" << c.chrom << "\t" << c.s + 1 << "\t"
45
- // << "60"
46
- // << "\t" << c.cigar << "\t"
47
- // << "*"
48
- // << "\t"
49
- // << "0"
50
- // << "\t"
51
- // << "0"
52
- // << "\t" << c.seq << "\t"
53
- // << "*" << endl ;
54
- // }
55
- // for (const SV& sv: svs[i]) {
56
- // ovcf << sv << endl ;
57
- // }
58
- // }
59
-
60
-
61
- Extender extender = Extender (&SFSs) ;
62
- extender.run (config->threads ) ;
63
- // Clipper clipper(chrom, extender.clips);
64
- // clipper.call(reference[chrom], sv_tree);
65
- // svs[omp_get_thread_num()].insert(svs[omp_get_thread_num()].begin(), clipper.svs.begin(), clipper.svs.end()) ;
66
-
67
36
for (int j = 0 ; j < extender.alignments .size (); j++) {
68
37
const auto & c = extender.alignments [j] ;
69
38
osam << c.chrom << " :" << c.s + 1 << " -" << c.e + 1 << " \t "
@@ -79,13 +48,13 @@ void Caller::run() {
79
48
<< " \t " << c.seq << " \t "
80
49
<< " *" << endl ;
81
50
}
82
-
83
- std::sort (extender.svs .begin (), extender.svs .end ()) ;
51
+ osam.close () ;
52
+ // output SV calls
53
+ ovcf.open (config->workdir + " /svs_poa.vcf" );
54
+ print_vcf_header () ;
84
55
for (const SV& sv: extender.svs ) {
85
56
ovcf << sv << endl ;
86
57
}
87
-
88
- osam.close () ;
89
58
ovcf.close () ;
90
59
}
91
60
@@ -94,12 +63,12 @@ void Caller::load_input_sfs() {
94
63
int num_batches = config->aggregate_batches ;
95
64
int num_threads = num_batches < threads ? num_batches : threads ;
96
65
vector<unordered_map<string, vector<SFS>>> _SFSs (num_batches) ;
97
- cout << " Loading assmbled SFS.." << endl ;
66
+ lprint ({ " Loading assmbled SFS.." }) ;
98
67
#pragma omp parallel for num_threads(num_threads)
99
68
for (int j = 0 ; j < num_batches; j++) {
100
69
string s_j = std::to_string (j) ;
101
70
string inpath = config->workdir + " /solution_batch_" + s_j + " .assembled.sfs" ;
102
- cout << " [I] Loading SFS from " << inpath << endl ;
71
+ // cout << "[I] Loading SFS from " << inpath << endl ;
103
72
ifstream inf (inpath) ;
104
73
string line ;
105
74
if (inf.is_open ()) {
@@ -122,7 +91,7 @@ void Caller::load_input_sfs() {
122
91
int r = 0 ;
123
92
int c = 0 ;
124
93
for (int j = 0 ; j < num_batches; j++) {
125
- lprint ({" Batch" , to_string (j), " with" , to_string (_SFSs[j].size ()), " strings." });
94
+ // lprint({"Batch", to_string(j), "with", to_string(_SFSs[j].size()), "strings."});
126
95
r += _SFSs[j].size () ;
127
96
SFSs.insert (_SFSs[j].begin (), _SFSs[j].end ()) ;
128
97
for (auto & read : _SFSs[j]) {
0 commit comments