Skip to content

Commit 9a49e0f

Browse files
committed
from cerr to cout
1 parent cf39753 commit 9a49e0f

File tree

8 files changed

+31
-40
lines changed

8 files changed

+31
-40
lines changed

src/commons/FileMerger.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,16 @@ size_t FileMerger::smallest(const uint64_t * lookingKmers,
309309
minTaxIdAtRank = INT_MAX;
310310
} else {
311311
// if (taxId2speciesId.find((int) lookingInfos[0]) == taxId2speciesId.end()) {
312-
// cerr << lookingKmers[0] << endl;
313-
// cerr << "TaxID not found 1: " << lookingInfos[0] << endl;
312+
// cout << lookingKmers[0] << endl;
313+
// cout << "TaxID not found 1: " << lookingInfos[0] << endl;
314314
// exit(1);
315315
// }
316316
minTaxIdAtRank = taxId2speciesId.at(lookingInfos[0]);
317317
}
318318
for(size_t i = 1; i < fileCnt; i++) {
319319
// if (taxId2speciesId.find((int) lookingInfos[i]) == taxId2speciesId.end()) {
320-
// cerr << lookingKmers[i] << endl;
321-
// cerr << "TaxID not found 2: " << lookingInfos[i] << endl;
320+
// cout << lookingKmers[i] << endl;
321+
// cout << "TaxID not found 2: " << lookingInfos[i] << endl;
322322
// exit(1);
323323
// }
324324
if(lookingKmers[i] < min ||

src/commons/IndexCreator.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,14 @@ void IndexCreator::getTaxonomyOfAccessions(vector<Accession> & observedAccession
287287
vector<pair<string, pair<TaxID, TaxID>>> acc2accId;
288288
int fd = open(acc2taxidFileName.c_str(), O_RDONLY);
289289
if (fd < 0) {
290-
cerr << "Cannot open file for mapping from accession to tax ID" << endl;
290+
cout << "Cannot open file for mapping from accession to tax ID" << endl;
291291
return;
292292
}
293293

294294
// Get the size of the file
295295
struct stat sb;
296296
if (fstat(fd, &sb) == -1) {
297-
cerr << "Cannot get the size of the file for mapping from accession to tax ID" << endl;
297+
cout << "Cannot get the size of the file for mapping from accession to tax ID" << endl;
298298
close(fd);
299299
return;
300300
}
@@ -304,7 +304,7 @@ void IndexCreator::getTaxonomyOfAccessions(vector<Accession> & observedAccession
304304
// Map the file to memory
305305
char* fileData = static_cast<char*>(mmap(nullptr, fileSize, PROT_READ, MAP_PRIVATE, fd, 0));
306306
if (fileData == MAP_FAILED) {
307-
cerr << "mmap failed" << endl;
307+
cout << "mmap failed" << endl;
308308
close(fd);
309309
return;
310310
}
@@ -353,7 +353,7 @@ void IndexCreator::getTaxonomyOfAccessions(vector<Accession> & observedAccession
353353
TaxID accTaxId = taxonomy->getSmallestUnusedExternalTaxID(usedExternalTaxIDs);
354354
acc2accId.emplace_back(accession, make_pair(taxID, accTaxId));
355355
if (accTaxId == 0) {
356-
cerr << "accTaxId is 0 for accession " << accession << " " << taxID << endl;
356+
cout << "accTaxId is 0 for accession " << accession << " " << taxID << endl;
357357
}
358358
observedAccessionsVec[it->second].taxID = accTaxId;
359359
newTaxons.emplace_back(accTaxId, taxID, "accession", accession);
@@ -366,7 +366,7 @@ void IndexCreator::getTaxonomyOfAccessions(vector<Accession> & observedAccession
366366
}
367367

368368
if (munmap(fileData, fileSize) == -1) {
369-
cerr << "munmap failed" << endl;
369+
cout << "munmap failed" << endl;
370370
}
371371

372372
if (par.accessionLevel == 1) {
@@ -379,7 +379,7 @@ void IndexCreator::getTaxonomyOfAccessions(vector<Accession> & observedAccession
379379
vector<std::string> unmappedAccessions;
380380
for (size_t i = 0; i < observedAccessionsVec.size(); ++i) {
381381
if (taxonomy->getInternalTaxID(observedAccessionsVec[i].taxID) == 0 || observedAccessionsVec[i].taxID == 0) {
382-
// cerr << "TaxID is 0 for accession " << observedAccessionsVec[i].accession << " " << observedAccessionsVec[i].taxID << endl;
382+
// cout << "TaxID is 0 for accession " << observedAccessionsVec[i].accession << " " << observedAccessionsVec[i].taxID << endl;
383383
unmappedAccessions.push_back(observedAccessionsVec[i].accession);
384384
continue;
385385
}
@@ -819,7 +819,7 @@ void IndexCreator::load_assacc2taxid(const string & mappingFile, unordered_map<s
819819
}
820820
}
821821
} else{
822-
cerr<<"Cannot open file for mappig from assemlby accession to tax ID"<<endl;
822+
cout<<"Cannot open file for mappig from assemlby accession to tax ID"<<endl;
823823
}
824824
map.close();
825825
}
@@ -1297,7 +1297,7 @@ void IndexCreator::loadCdsInfo(const string & cdsInfoFileList) {
12971297
void IndexCreator::loadMergedTaxIds(const std::string &mergedFile, unordered_map<TaxID, TaxID> & old2new) {
12981298
std::ifstream ss(mergedFile);
12991299
if (ss.fail()) {
1300-
cerr << "File " << mergedFile << " not found!\n";
1300+
cout << "File " << mergedFile << " not found!\n";
13011301
EXIT(EXIT_FAILURE);
13021302
}
13031303

src/commons/common.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,13 @@ int loadDbParameters(LocalParameters &par, const std::string & dbDir) {
8282
while (getline(dbParametersFile, eachLine)) {
8383
std::vector<std::string> tokens = Util::split(eachLine, "\t");
8484
if (tokens[0] == "Reduced_alphabet") {
85-
// if (stoi(tokens[1]) != par.reducedAA){
86-
// if (par.reducedAA == 0){ // DB with reduced AA
87-
// cerr << "Warning: Current DB is built with reduced 15 amino acid alphabets." << endl;
88-
// cerr << " --reduce-aa option will be ignored " << endl;
89-
// } else {
90-
// cerr << "Warning: Current DB is built with 20 amino acid alphabets." << endl;
91-
// cerr << " --reduce-aa option will be ignored " << endl;
92-
// }
93-
// }
9485
par.reducedAA = stoi(tokens[1]);
9586
} else if (tokens[0] == "Spaced_kmer_mask") {
9687
// par.spaceMask = tokens[1];
9788
} else if (tokens[0] == "Accession_level") {
9889
if (tokens[1] == "0" && par.accessionLevel == 1){
9990
par.accessionLevel = 0;
100-
cerr << "Warning: Current DB doesn't support accession-level classification." << endl;
91+
cout << "Warning: Current DB doesn't support accession-level classification." << endl;
10192
}
10293
if (tokens[1] == "1" && par.accessionLevel == 0){
10394
par.accessionLevel = 2;
@@ -232,19 +223,19 @@ void getObservedAccessionList(const string & fnaListFileName,
232223

233224
void fillAcc2TaxIdMap(unordered_map<string, TaxID> & acc2taxid,
234225
const string & acc2taxidFileName) {
235-
cerr << "Load mapping from accession ID to taxonomy ID ... " << flush;
226+
cout << "Load mapping from accession ID to taxonomy ID ... " << flush;
236227

237228
// Open the file
238229
int fd = open(acc2taxidFileName.c_str(), O_RDONLY);
239230
if (fd < 0) {
240-
cerr << "Cannot open file for mapping from accession to tax ID" << endl;
231+
cout << "Cannot open file for mapping from accession to tax ID" << endl;
241232
return;
242233
}
243234

244235
// Get the size of the file
245236
struct stat sb;
246237
if (fstat(fd, &sb) == -1) {
247-
cerr << "Cannot get the size of the file for mapping from accession to tax ID" << endl;
238+
cout << "Cannot get the size of the file for mapping from accession to tax ID" << endl;
248239
close(fd);
249240
return;
250241
}
@@ -254,7 +245,7 @@ void fillAcc2TaxIdMap(unordered_map<string, TaxID> & acc2taxid,
254245
// Map the file to memory
255246
char* fileData = static_cast<char*>(mmap(nullptr, fileSize, PROT_READ, MAP_PRIVATE, fd, 0));
256247
if (fileData == MAP_FAILED) {
257-
cerr << "mmap failed" << endl;
248+
cout << "mmap failed" << endl;
258249
close(fd);
259250
return;
260251
}
@@ -297,7 +288,7 @@ void fillAcc2TaxIdMap(unordered_map<string, TaxID> & acc2taxid,
297288

298289
// Unmap the file
299290
if (munmap(fileData, fileSize) == -1) {
300-
cerr << "munmap failed" << endl;
291+
cout << "munmap failed" << endl;
301292
}
302-
cerr << "Done" << endl;
293+
cout << "Done" << endl;
303294
}

src/util/apply-threshold.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int applyThreshold(int argc, const char **argv, const Command &command) {
8282
lineCnt++;
8383
}
8484
} else {
85-
cerr << "Cannot open file for old result" << endl;
85+
cout << "Cannot open file for old result" << endl;
8686
}
8787
old_result_file.close();
8888

@@ -96,7 +96,7 @@ int applyThreshold(int argc, const char **argv, const Command &command) {
9696
"\t" << ncbiTaxonomy.taxonNode(result.classification)->rankIdx << endl;
9797
}
9898
} else {
99-
cerr << "Cannot open file for new result" << endl;
99+
cout << "Cannot open file for new result" << endl;
100100
}
101101
new_result_file.close();
102102

@@ -106,7 +106,7 @@ int applyThreshold(int argc, const char **argv, const Command &command) {
106106
if (new_report_file.is_open()) {
107107
write_report_file(outDir + "/" + jobid + "_report.tsv", newResults.size(), taxonCounts, ncbiTaxonomy);
108108
} else {
109-
cerr << "Cannot open file for new report" << endl;
109+
cout << "Cannot open file for new report" << endl;
110110
}
111111
return 0;
112112
}

src/util/binning2report.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int binning2report(int argc, const char **argv, const Command &command){
5050
lineCnt++;
5151
}
5252
} else {
53-
cerr << "Cannot open the file of binning result" << endl;
53+
cout << "Cannot open the file of binning result" << endl;
5454
}
5555
binnings_file.close();
5656

@@ -60,7 +60,7 @@ int binning2report(int argc, const char **argv, const Command &command){
6060
if (new_report_file.is_open()) {
6161
write_report_file(outDir + "/" + jobid + "_report.tsv", binnings.size(), taxonCounts, ncbiTaxonomy);
6262
} else {
63-
cerr << "Cannot open file for new report" << endl;
63+
cout << "Cannot open file for new report" << endl;
6464
}
6565
return 0;
6666
}

src/workflow/build.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int build(int argc, const char **argv, const Command &command){
6464

6565
if(idxCre.getNumOfFlush() == 1) {
6666
delete taxonomy;
67-
cerr << "Index creation completed." << endl;
67+
cout << "Index creation completed." << endl;
6868
return 0;
6969
}
7070

@@ -79,6 +79,6 @@ int build(int argc, const char **argv, const Command &command){
7979
merger.setMergedFileNames(dbDir + "/diffIdx", dbDir + "/info", dbDir + "/split");
8080
merger.mergeTargetFiles();
8181
delete taxonomy;
82-
cerr << "Index creation completed." << endl;
82+
cout << "Index creation completed." << endl;
8383
return 0;
8484
}

src/workflow/classify.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ int classify(int argc, const char **argv, const Command& command)
3838
if (par.seqMode == 2) {
3939
// Check if the second argument is a directory
4040
if (FileUtil::directoryExists(par.filenames[1].c_str())) {
41-
cerr << "Error: " << par.filenames[1] << " is a directory. Please specify a query file name." << endl;
42-
cerr << " For '--seq-mode 2', please provide two query files." << endl;
41+
cout << "Error: " << par.filenames[1] << " is a directory. Please specify a query file name." << endl;
42+
cout << " For '--seq-mode 2', please provide two query files." << endl;
4343
exit(1);
4444
}
4545

@@ -50,8 +50,8 @@ int classify(int argc, const char **argv, const Command& command)
5050
// Check if the second argument is file
5151
if (FileUtil::fileExists(par.filenames[1].c_str())
5252
&& !FileUtil::directoryExists(par.filenames[1].c_str())) {
53-
cerr << "Error: " << par.filenames[1] << " is a file. Please specify a database directory." << endl;
54-
cerr << " For '--seq-mode 1' and '--seq-mode 3', please provide one query file." << endl;
53+
cout << "Error: " << par.filenames[1] << " is a file. Please specify a database directory." << endl;
54+
cout << " For '--seq-mode 1' and '--seq-mode 3', please provide one query file." << endl;
5555
exit(1);
5656
}
5757

src/workflow/updateDB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ int updateDB(int argc, const char **argv, const Command &command){
106106

107107
merger.mergeTargetFiles();
108108
delete taxonomy;
109-
cerr << "Index creation completed." << endl;
109+
cout << "Index creation completed." << endl;
110110
return 0;
111111
}

0 commit comments

Comments
 (0)