Skip to content

Commit d9fd9a2

Browse files
committed
Remove references to reconstructor.
1 parent 0d5ea05 commit d9fd9a2

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

main.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "caller.hpp"
2424
#include "assembler.hpp"
25-
#include "reconstructor.hpp"
25+
#include "smoother.hpp"
2626

2727
#ifdef LOCAL_BUILD
2828
#include "finder.hpp"
@@ -68,7 +68,7 @@ void print_help() {
6868
cerr << "\tAssmble SFS into superstrings:" << endl ;
6969
cerr << "\t\tSVDSS assemble --workdir /path/to/.sfs/files --batches /number/of/SFS/batches" << endl ;
7070
cerr << "\tReconstruct sample:" << endl ;
71-
cerr << "\t\tSVDSS reconstruct --workdir /output/file/direcotry --bam /path/to/input/bam/file --reference /path/to/reference/genome/fasta" << endl ;
71+
cerr << "\t\tSVDSS smooth --workdir /output/file/direcotry --bam /path/to/input/bam/file --reference /path/to/reference/genome/fasta" << endl ;
7272
cerr << "\tCall SVs:" << endl ;
7373
cerr << "\t\tSVDSS call --workdir /path/to/assembled/.sfs/files --bam /path/to/input/bam/file --reference /path/to/reference/genome/fasta" << endl ;
7474
cerr << "\t\tOptional arguments: " << endl ;
@@ -102,9 +102,9 @@ int main(int argc, char** argv) {
102102
} else if (strcmp(argv[1], "assemble") == 0) {
103103
auto assembler = new Assembler() ;
104104
assembler->run() ;
105-
} else if (strcmp(argv[1], "reconstruct") == 0) {
106-
auto reconstructor = new Reconstructor() ;
107-
reconstructor->run() ;
105+
} else if (strcmp(argv[1], "smooth") == 0) {
106+
auto smoother = new Smoother() ;
107+
smoother->run() ;
108108
} else {
109109
print_help() ;
110110
}

ping_pong.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ bool PingPong::backward_search(rld_t *index, const uint8_t *P, int p2) {
5656
return sai.x[2] != 0 ;
5757
}
5858

59-
// This will be very fast for reconstructed reads
60-
// However non-reconstructed reads are going to produce loads of crappy SFS, unless we filter them
61-
void PingPong::ping_pong_search(rld_t *index, uint8_t* P, int l, std::vector<sfs_type_t>& solutions, bool isreconstructed, bam1_t* aln) {
59+
// This will be very fast for smoothed reads
60+
// However non-smoothed reads are going to produce loads of crappy SFS, unless we filter them
61+
void PingPong::ping_pong_search(rld_t *index, uint8_t* P, int l, std::vector<sfs_type_t>& solutions, bool is_smoothed, bam1_t* aln) {
6262
//cout << bam_get_qname(aln) << endl ;
6363
rldintv_t sai ;
6464
int begin = l - 1 ;
@@ -204,18 +204,18 @@ batch_type_t PingPong::process_batch(rld_t* index, int p, int i) {
204204
} else {
205205
for (int j = 0; j < read_seqs[p][i].size(); j++) {
206206
char *qname = bam_get_qname(bam_entries[p][i][j]) ;
207-
bool isreconstructed = reconstructed_reads.find(qname) != reconstructed_reads.end() ;
207+
bool is_smoothed = smoothed_reads.find(qname) != smoothed_reads.end() ;
208208
if (config->putative) {
209209
if (ignored_reads.find(qname) != ignored_reads.end()) {
210210
continue ;
211211
}
212-
// was not ignored, so either it's reconstructed or not:
213-
if (!isreconstructed) {
212+
// was not ignored, so either it's smoothed or not:
213+
if (!is_smoothed) {
214214
continue ;
215215
}
216216
}
217-
//cout << qname << " " << isreconstructed << endl ;
218-
ping_pong_search(index, read_seqs[p][i][j], read_seq_lengths[p][i][j], solutions[qname], isreconstructed, bam_entries[p][i][j]) ;
217+
//cout << qname << " " << is_smoothed << endl ;
218+
ping_pong_search(index, read_seqs[p][i][j], read_seq_lengths[p][i][j], solutions[qname], is_smoothed, bam_entries[p][i][j]) ;
219219
}
220220
}
221221
return solutions ;
@@ -280,7 +280,7 @@ int PingPong::search() {
280280
}
281281
if (config->putative) {
282282
lprint({"Putative SFS extraction enabled."}) ;
283-
load_reconstructed_read_ids() ;
283+
load_smoothed_read_ids() ;
284284
}
285285
// allocate all necessary stuff
286286
int p = 0 ;
@@ -412,8 +412,8 @@ int PingPong::search() {
412412
return u ;
413413
}
414414

415-
void PingPong::load_reconstructed_read_ids() {
416-
lprint({"Loading reconstructed read ids.."}) ;
415+
void PingPong::load_smoothed_read_ids() {
416+
lprint({"Loading smoothed read ids.."}) ;
417417
ifstream ignore_file(config->workdir + "/ignored_reads.txt") ;
418418
if (ignore_file.is_open()) {
419419
string read_name;
@@ -422,16 +422,16 @@ void PingPong::load_reconstructed_read_ids() {
422422
}
423423
ignore_file.close() ;
424424
}
425-
ifstream in_file(config->workdir + "/reconstructed_reads.txt") ;
425+
ifstream in_file(config->workdir + "/smoothed_reads.txt") ;
426426
if (in_file.is_open()) {
427427
string read_name;
428428
while (getline(in_file, read_name)) {
429-
reconstructed_reads[read_name] = true ;
429+
smoothed_reads[read_name] = true ;
430430
}
431431
in_file.close() ;
432432
}
433433
lprint({"Loaded", to_string(ignored_reads.size()), "ignored read ids."}) ;
434-
lprint({"Loaded", to_string(reconstructed_reads.size()), "reconstructed read ids."}) ;
434+
lprint({"Loaded", to_string(smoothed_reads.size()), "smoothed read ids."}) ;
435435
}
436436

437437
// ============================================================================= \\

ping_pong.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ class PingPong {
9393
samFile *bam_file ;
9494
bam_hdr_t *bam_header ;
9595

96-
unordered_map<string, bool> reconstructed_reads ;
96+
unordered_map<string, bool> smoothed_reads ;
9797
unordered_map<string, bool> ignored_reads ;
98-
void load_reconstructed_read_ids() ;
98+
void load_smoothed_read_ids() ;
9999

100100
std::vector<std::vector<std::vector<int>>> read_seq_lengths ;
101101
std::vector<std::vector<std::vector<int>>> read_seq_max_lengths ;
@@ -105,7 +105,7 @@ class PingPong {
105105
bool load_batch_bam(int threads, int batch_size, int p) ;
106106
bool load_batch_fastq(int threads, int batch_size, int p) ;
107107
batch_type_t process_batch(rld_t* index, int p, int i) ;
108-
void ping_pong_search(rld_t *index, uint8_t* seq, int l, std::vector<sfs_type_t>& solutions, bool isreconstructed, bam1_t*) ;
108+
void ping_pong_search(rld_t *index, uint8_t* seq, int l, std::vector<sfs_type_t>& solutions, bool is_smoothed, bam1_t*) ;
109109
void output_batch(int) ;
110110

111111
std::vector<std::vector<batch_type_t>> batches ;

reconstructor.cpp smoother.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "reconstructor.hpp"
1+
#include "smoother.hpp"
22

33
using namespace std ;
44

@@ -80,7 +80,7 @@ void rebuild_bam_entry(bam1_t* alignment, char* seq, uint8_t* qual, vector<pair<
8080
free(aux) ;
8181
}
8282

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) {
8484
auto cigar_offsets = decode_cigar(alignment) ;
8585
int l = 0 ;
8686
// try and filter unintenresting reads early on
@@ -213,11 +213,11 @@ void Reconstructor::reconstruct_read(bam1_t* alignment, char* read_seq, string c
213213
ignored_reads[omp_get_thread_num() - 2].push_back(qname) ;
214214
return ;
215215
}
216-
reconstructed_reads[omp_get_thread_num() - 2].push_back(qname) ;
216+
smoothed_reads[omp_get_thread_num() - 2].push_back(qname) ;
217217
rebuild_bam_entry(alignment, new_seq, new_qual, new_cigar) ;
218218
}
219219

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) {
221221
bam1_t* alignment ;
222222
for (int b = 0; b < bam_entries.size(); b++) {
223223
alignment = bam_entries[b] ;
@@ -238,20 +238,20 @@ void Reconstructor::process_batch(vector<bam1_t*> bam_entries, int p, int i) {
238238
if (chromosome_seqs.find(chrom) == chromosome_seqs.end()) {
239239
continue ;
240240
}
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) ;
242242
}
243243
}
244244

245245
// BAM writing based on https://www.biostars.org/p/181580/
246-
void Reconstructor::run() {
246+
void Smoother::run() {
247247
config = Configuration::getInstance() ;
248248
load_chromosomes(config->reference) ;
249249
// parse arguments
250250
bam_file = hts_open(config->bam.c_str(), "r") ;
251251
bam_index = sam_index_load(bam_file, config->bam.c_str()) ;
252252
bam_header = sam_hdr_read(bam_file) ; //read header
253253
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") ;
255255
out_bam_file = hts_open(out_bam_path.c_str(), "wb") ;
256256
bgzf_mt(out_bam_file->fp.bgzf, 8, 1) ;
257257
int r = sam_hdr_write(out_bam_file, bam_header) ;
@@ -292,7 +292,7 @@ void Reconstructor::run() {
292292
load_batch_bam(config->threads, batch_size, 1) ;
293293
int p = 1 ;
294294
ignored_reads.resize(config->threads) ;
295-
reconstructed_reads.resize(config->threads) ;
295+
smoothed_reads.resize(config->threads) ;
296296
time_t t ;
297297
time(&t) ;
298298
bool should_load = true ;
@@ -376,22 +376,22 @@ void Reconstructor::run() {
376376
lprint({"Done."});
377377
sam_close(bam_file) ;
378378
sam_close(out_bam_file) ;
379-
dump_reconstructed_read_ids() ;
379+
dump_smoothed_read_ids() ;
380380
lprint({"Loaded", to_string(reads_processed), "reads."});
381381
lprint({"Wrote", to_string(reads_written), "reads."});
382382
}
383383

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") ;
387387
if (qname_file.is_open()) {
388388
for (int i = 0; i < config->threads; i++) {
389-
for (const auto& qname: reconstructed_reads[i]) {
389+
for (const auto& qname: smoothed_reads[i]) {
390390
qname_file << qname << endl ;
391391
}
392392
}
393393
} else {
394-
lprint({"Error openning reconstructed_reads.txt."}, 2) ;
394+
lprint({"Error openning smoothed_reads.txt."}, 2) ;
395395
}
396396
qname_file.close() ;
397397
ofstream ignore_file(config->workdir + "/ignored_reads.txt") ;
@@ -407,7 +407,7 @@ void Reconstructor::dump_reconstructed_read_ids() {
407407
}
408408
}
409409

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) {
411411
int n = 0 ;
412412
int i = 0 ;
413413
int m = 0 ;

reconstructor.hpp smoother.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using namespace std ;
2727

2828
#define bam_set_seqi(s,i,b) ((s)[(i)>>1] = ((s)[(i)>>1] & (0xf0 >> ((~(i)&1)<<2))) | ((b)<<((~(i)&1)<<2)))
2929

30-
class Reconstructor {
30+
class Smoother {
3131

3232
public:
3333

@@ -38,7 +38,7 @@ class Reconstructor {
3838
// output BAM file
3939
samFile* out_bam_file ;
4040
// <time < batch < reads > > >
41-
std::vector<std::vector<std::string>> reconstructed_reads ;
41+
std::vector<std::vector<std::string>> smoothed_reads ;
4242
std::vector<std::vector<std::string>> ignored_reads ;
4343
std::vector<std::vector<std::vector<bam1_t*>>> bam_entries ;
4444

@@ -51,7 +51,7 @@ class Reconstructor {
5151
void run() ;
5252
bool load_batch_bam(int threads, int batch_size, int p) ;
5353
void process_batch(std::vector<bam1_t*> bam_entries, int , int) ;
54-
void reconstruct_read(bam1_t* alignment, char* read_seq, std::string chrom, int, int, int) ;
54+
void smooth_read(bam1_t* alignment, char* read_seq, std::string chrom, int, int, int) ;
5555

5656
Configuration* config ;
5757

@@ -64,7 +64,7 @@ class Reconstructor {
6464
int num_ignored_reads = 0 ;
6565
int reads_processed = 0 ;
6666

67-
void dump_reconstructed_read_ids() ;
67+
void dump_smoothed_read_ids() ;
6868
};
6969

7070
#endif

0 commit comments

Comments
 (0)