1
- #include " reconstructor .hpp"
1
+ #include " smoother .hpp"
2
2
3
3
using namespace std ;
4
4
@@ -80,7 +80,7 @@ void rebuild_bam_entry(bam1_t* alignment, char* seq, uint8_t* qual, vector<pair<
80
80
free (aux) ;
81
81
}
82
82
83
- void Reconstructor::reconstruct_read (bam1_t * alignment, char * read_seq, string chrom, int _i, int _j, int _k) {
83
+ void Smoother::smooth_read (bam1_t * alignment, char * read_seq, string chrom, int _i, int _j, int _k) {
84
84
auto cigar_offsets = decode_cigar (alignment) ;
85
85
int l = 0 ;
86
86
// try and filter unintenresting reads early on
@@ -213,11 +213,11 @@ void Reconstructor::reconstruct_read(bam1_t* alignment, char* read_seq, string c
213
213
ignored_reads[omp_get_thread_num () - 2 ].push_back (qname) ;
214
214
return ;
215
215
}
216
- reconstructed_reads [omp_get_thread_num () - 2 ].push_back (qname) ;
216
+ smoothed_reads [omp_get_thread_num () - 2 ].push_back (qname) ;
217
217
rebuild_bam_entry (alignment, new_seq, new_qual, new_cigar) ;
218
218
}
219
219
220
- void Reconstructor ::process_batch (vector<bam1_t *> bam_entries, int p, int i) {
220
+ void Smoother ::process_batch (vector<bam1_t *> bam_entries, int p, int i) {
221
221
bam1_t * alignment ;
222
222
for (int b = 0 ; b < bam_entries.size (); b++) {
223
223
alignment = bam_entries[b] ;
@@ -238,20 +238,20 @@ void Reconstructor::process_batch(vector<bam1_t*> bam_entries, int p, int i) {
238
238
if (chromosome_seqs.find (chrom) == chromosome_seqs.end ()) {
239
239
continue ;
240
240
}
241
- reconstruct_read (alignment, read_seqs[p][i][b], chrom, p, i, b) ;
241
+ smooth_read (alignment, read_seqs[p][i][b], chrom, p, i, b) ;
242
242
}
243
243
}
244
244
245
245
// BAM writing based on https://www.biostars.org/p/181580/
246
- void Reconstructor ::run () {
246
+ void Smoother ::run () {
247
247
config = Configuration::getInstance () ;
248
248
load_chromosomes (config->reference ) ;
249
249
// parse arguments
250
250
bam_file = hts_open (config->bam .c_str (), " r" ) ;
251
251
bam_index = sam_index_load (bam_file, config->bam .c_str ()) ;
252
252
bam_header = sam_hdr_read (bam_file) ; // read header
253
253
bgzf_mt (bam_file->fp .bgzf , 8 , 1 ) ;
254
- auto out_bam_path = config->workdir + (config->selective ? " /reconstructed .selective.bam" : " /reconstructed .bam" ) ;
254
+ auto out_bam_path = config->workdir + (config->selective ? " /smoothed .selective.bam" : " /smoothed .bam" ) ;
255
255
out_bam_file = hts_open (out_bam_path.c_str (), " wb" ) ;
256
256
bgzf_mt (out_bam_file->fp .bgzf , 8 , 1 ) ;
257
257
int r = sam_hdr_write (out_bam_file, bam_header) ;
@@ -292,7 +292,7 @@ void Reconstructor::run() {
292
292
load_batch_bam (config->threads , batch_size, 1 ) ;
293
293
int p = 1 ;
294
294
ignored_reads.resize (config->threads ) ;
295
- reconstructed_reads .resize (config->threads ) ;
295
+ smoothed_reads .resize (config->threads ) ;
296
296
time_t t ;
297
297
time (&t) ;
298
298
bool should_load = true ;
@@ -376,22 +376,22 @@ void Reconstructor::run() {
376
376
lprint ({" Done." });
377
377
sam_close (bam_file) ;
378
378
sam_close (out_bam_file) ;
379
- dump_reconstructed_read_ids () ;
379
+ dump_smoothed_read_ids () ;
380
380
lprint ({" Loaded" , to_string (reads_processed), " reads." });
381
381
lprint ({" Wrote" , to_string (reads_written), " reads." });
382
382
}
383
383
384
- void Reconstructor::dump_reconstructed_read_ids () {
385
- lprint ({" Dumping reconstructed read ids.." }) ;
386
- ofstream qname_file (config->workdir + " /reconstructed_reads .txt" ) ;
384
+ void Smoother::dump_smoothed_read_ids () {
385
+ lprint ({" Dumping smoothed read ids.." }) ;
386
+ ofstream qname_file (config->workdir + " /smoothed_reads .txt" ) ;
387
387
if (qname_file.is_open ()) {
388
388
for (int i = 0 ; i < config->threads ; i++) {
389
- for (const auto & qname: reconstructed_reads [i]) {
389
+ for (const auto & qname: smoothed_reads [i]) {
390
390
qname_file << qname << endl ;
391
391
}
392
392
}
393
393
} else {
394
- lprint ({" Error openning reconstructed_reads .txt." }, 2 ) ;
394
+ lprint ({" Error openning smoothed_reads .txt." }, 2 ) ;
395
395
}
396
396
qname_file.close () ;
397
397
ofstream ignore_file (config->workdir + " /ignored_reads.txt" ) ;
@@ -407,7 +407,7 @@ void Reconstructor::dump_reconstructed_read_ids() {
407
407
}
408
408
}
409
409
410
- bool Reconstructor ::load_batch_bam (int threads, int batch_size, int p) {
410
+ bool Smoother ::load_batch_bam (int threads, int batch_size, int p) {
411
411
int n = 0 ;
412
412
int i = 0 ;
413
413
int m = 0 ;
0 commit comments