Skip to content
This repository has been archived by the owner on Apr 27, 2018. It is now read-only.

Commit

Permalink
Make DEBUG build work on Linux, clean up Linux type warnings on printfs
Browse files Browse the repository at this point in the history
  • Loading branch information
bolosky committed Apr 30, 2015
1 parent 52d4556 commit 1d97a36
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 64 deletions.
16 changes: 9 additions & 7 deletions SNAPLib/AlignerContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,18 @@ AlignerContext::printStats()
);

if (NULL != perfFile) {
fprintf(perfFile, "%d\t%d\t%0.2f%%\t%0.2f%%\t%0.2f%%\t%0.2f%%\t%0.2f%%\t%lld\t%lld\tt%.0f\n",
_int64 reads = max(stats->totalReads, (_int64) 1);
double time = (double)(max(alignTime, (_int64) 1));
fprintf(perfFile, "%d\t%d\t%0.2f%%\t%0.2f%%\t%0.2f%%\t%0.2f%%\t%ld\t%.02f%%\t%ld\tt%.0f\n",
maxHits_, maxDist_,
100.0 * usefulReads / max(stats->totalReads, (_int64) 1),
100.0 * stats->singleHits / stats->totalReads,
100.0 * stats->multiHits / stats->totalReads,
100.0 * stats->notFound / stats->totalReads,
100.0 * usefulReads / reads,
100.0 * stats->singleHits / stats->totalReads,
100.0 * stats->multiHits / stats->totalReads,
100.0 * stats->notFound / stats->totalReads,
stats->lvCalls,
100.0 * stats->alignedAsPairs / stats->totalReads,
100.0 * stats->alignedAsPairs / stats->totalReads,
stats->totalReads,
(1000.0 * usefulReads) / max(alignTime, (_int64) 1));
(1000.0 * usefulReads) / time);

fprintf(perfFile,"\n");
}
Expand Down
2 changes: 1 addition & 1 deletion SNAPLib/Bam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ class BAMDupMarkFilter : public BAMFilter
if (mates.size() > 0) {
WriteErrorMessage("duplicate matching ended with %d unmatched reads:\n", mates.size());
for (MateMap::iterator i = mates.begin(); i != mates.end(); i = mates.next(i)) {
WriteErrorMessage("%u%s/%u%s\n", i->key.locations[0], i->key.isRC[0] ? "rc" : "", i->key.locations[1], i->key.isRC[1] ? "rc" : "");
WriteErrorMessage("%u%s/%u%s\n", GenomeLocationAsInt64(i->key.locations[0]), i->key.isRC[0] ? "rc" : "", GenomeLocationAsInt64(i->key.locations[1]), i->key.isRC[1] ? "rc" : "");
}
}
#endif
Expand Down
17 changes: 9 additions & 8 deletions SNAPLib/BaseAligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Routine Description:


#ifdef _DEBUG
bool _DumpAlignments = false;
bool _DumpAlignments = true;
#endif // _DEBUG

void
Expand Down Expand Up @@ -422,8 +422,8 @@ Return Value:
secondaryResults);

#ifdef _DEBUG
if (_DumpAlignments) printf("\tFinal result score %d MAPQ %d (%e probability of best candidate, %e probability of all candidates) at %u\n",
primaryResult->score, primaryResult->mapq, probabilityOfBestCandidate, probabilityOfAllCandidates, primaryResult->location);
if (_DumpAlignments) printf("\tFinal result score %d MAPQ %d (%e probability of best candidate, %e probability of all candidates) at %lu\n",
primaryResult->score, primaryResult->mapq, probabilityOfBestCandidate, probabilityOfAllCandidates, GenomeLocationAsInt64(primaryResult->location));
#endif // _DEBUG
finalizeSecondaryResults(*primaryResult, nSecondaryResults, secondaryResults, maxSecondaryResults, maxEditDistanceForSecondaryResults, bestScore);
return;
Expand Down Expand Up @@ -475,10 +475,10 @@ Return Value:

#ifdef _DEBUG
if (_DumpAlignments) {
printf("\tSeed offset %2d, %4d hits, %4d rcHits.", nextSeedToTest, nHits[0], nHits[1]);
printf("\tSeed offset %2d, %4ld hits, %4ld rcHits.", nextSeedToTest, nHits[0], nHits[1]);
for (int rc = 0; rc < 2; rc++) {
for (unsigned i = 0; i < __min(nHits[rc], 5); i++) {
printf(" %sHit at %9llu.", rc == 1 ? "RC " : "", doesGenomeIndexHave64BitLocations ? hits[rc][i] : (_int64)hits32[rc][i]);
printf(" %sHit at %9lu.", rc == 1 ? "RC " : "", doesGenomeIndexHave64BitLocations ? GenomeLocationAsInt64(hits[rc][i]) : (_int64)hits32[rc][i]);
}
}
printf("\n");
Expand Down Expand Up @@ -620,7 +620,7 @@ Return Value:
secondaryResults)) {

#ifdef _DEBUG
if (_DumpAlignments) printf("\tFinal result score %d MAPQ %d at %u\n", primaryResult->score, primaryResult->mapq, primaryResult->location);
if (_DumpAlignments) printf("\tFinal result score %d MAPQ %d at %lu\n", primaryResult->score, primaryResult->mapq, GenomeLocationAsInt64(primaryResult->location));
#endif // _DEBUG

finalizeSecondaryResults(*primaryResult, nSecondaryResults, secondaryResults, maxSecondaryResults, maxEditDistanceForSecondaryResults, bestScore);
Expand All @@ -645,7 +645,8 @@ Return Value:
secondaryResults);

#ifdef _DEBUG
if (_DumpAlignments) printf("\tFinal result score %d MAPQ %d (%e probability of best candidate, %e probability of all candidates) at %u\n", primaryResult->score, primaryResult->mapq, probabilityOfBestCandidate, probabilityOfAllCandidates, primaryResult->location);
if (_DumpAlignments) printf("\tFinal result score %d MAPQ %d (%e probability of best candidate, %e probability of all candidates) at %lu\n",
primaryResult->score, primaryResult->mapq, probabilityOfBestCandidate, probabilityOfAllCandidates, GenomeLocationAsInt64(primaryResult->location));
#endif // _DEBUG

finalizeSecondaryResults(*primaryResult, nSecondaryResults, secondaryResults, maxSecondaryResults, maxEditDistanceForSecondaryResults, bestScore);
Expand Down Expand Up @@ -925,7 +926,7 @@ Return Value:


#ifdef _DEBUG
if (_DumpAlignments) printf("Scored %9u weight %2d limit %d, result %2d %s\n", genomeLocation, elementToScore->weight, scoreLimit, score, elementToScore->direction ? "RC" : "");
if (_DumpAlignments) printf("Scored %9lu weight %2d limit %d, result %2d %s\n", GenomeLocationAsInt64(genomeLocation), elementToScore->weight, scoreLimit, score, elementToScore->direction ? "RC" : "");
#endif // _DEBUG

candidateToScore->score = score;
Expand Down
2 changes: 1 addition & 1 deletion SNAPLib/ChimericPairedEndAligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void ChimericPairedEndAligner::align(

#ifdef _DEBUG
if (_DumpAlignments) {
printf("ChimericPairedEndAligner: (%u, %u) score (%d, %d), MAPQ (%d, %d)\n\n\n",result->location[0], result->location[1],
printf("ChimericPairedEndAligner: (%lu, %lu) score (%d, %d), MAPQ (%d, %d)\n\n\n", GenomeLocationAsInt64(result->location[0]), GenomeLocationAsInt64(result->location[1]),
result->score[0], result->score[1], result->mapq[0], result->mapq[1]);
}
#endif // _DEBUG
Expand Down
8 changes: 7 additions & 1 deletion SNAPLib/Compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,13 @@ class ExclusiveLock {
#endif // _MSC_VER


ExclusiveLock() : initialized(false), holderThreadId(0), wholeProgramScope(false) {}
ExclusiveLock() : initialized(false), wholeProgramScope(false)
#ifdef _MSC_VER
, holderThreadId(0)
#endif // _MSC_VER

{}

~ExclusiveLock() {_ASSERT(!initialized || wholeProgramScope);} // Must DestroyExclusiveLock first
};

Expand Down
8 changes: 4 additions & 4 deletions SNAPLib/DataReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,15 +1677,15 @@ DecompressDataReader::findPointer(
for (int i = 0; i < count; i++) {
Entry* e = &entries[i];
if (e->compressed <= p && p < e->compressed + e->compressedValid) {
sprintf(result, "compressed #%d @ %lld", i, (char*)p - e->compressed);
sprintf(result, "compressed #%d @ %ld", i, (char*)p - e->compressed);
break;
}
if (e->decompressed <= p && p < e->decompressed + extraBytes) {
sprintf(result, "decompressed #%d %lld", i, (char*) p - e->decompressed);
sprintf(result, "decompressed #%d %ld", i, (char*) p - e->decompressed);
break;
}
if (e->decompressed + extraBytes <= p && p < e->decompressed + totalExtra) {
sprintf(result, "extra #%d %lld", i, (char*) p - e->decompressed - extraBytes);
sprintf(result, "extra #%d %ld", i, (char*) p - e->decompressed - extraBytes);
break;
}
}
Expand Down Expand Up @@ -1805,7 +1805,7 @@ DecompressDataReader::decompressThread(
soft_exit(1);
}
if (input > entry->compressedValid || zip->BSIZE() >= BAM_BLOCK || zip->ISIZE() > BAM_BLOCK) {
fprintf(stderr, "error reading BAM file at offset %lld\n", reader->getFileOffset());
fprintf(stderr, "error reading BAM file at offset %ld\n", reader->getFileOffset());
soft_exit(1);
}
} while (input < entry->compressedStart);
Expand Down
4 changes: 2 additions & 2 deletions SNAPLib/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ WriteProgressCounter(const char *counterName, _int64 increment)
return;
}

fprintf(stderr,"reporter:counter:SNAP,%s,%lld\n", counterName, increment);
fflush(stderr);
fprintf(stderr,"reporter:counter:SNAP,%s,%ld\n", counterName, increment);
fflush(stderr);
}
10 changes: 5 additions & 5 deletions SNAPLib/Genome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ Genome::saveToFile(const char *fileName) const
return false;
}

fprintf(saveFile,"%lld %d\n",nBases, nContigs);
fprintf(saveFile,"%ld %d\n",nBases, nContigs);
char *curChar = NULL;

for (int i = 0; i < nContigs; i++) {
for (int n = 0; n < strlen(contigs[i].name); n++){
curChar = contigs[i].name + n;
if (*curChar == ' '){ *curChar = '_'; }
}
fprintf(saveFile,"%lld %s\n",contigs[i].beginningLocation, contigs[i].name);
fprintf(saveFile,"%ld %s\n", GenomeLocationAsInt64(contigs[i].beginningLocation), contigs[i].name);
}

//
Expand Down Expand Up @@ -236,7 +236,7 @@ Genome::loadFromFile(const char *fileName, unsigned chromosomePadding, GenomeLoc
}

_int64 contigStart;
if (1 != sscanf(contigNameBuffer, "%lld", &contigStart)) {
if (1 != sscanf(contigNameBuffer, "%ld", &contigStart)) {
WriteErrorMessage("Unable to parse contig start in genome file '%s', '%s%'\n", fileName, contigNameBuffer);
soft_exit(1);
}
Expand Down Expand Up @@ -320,7 +320,7 @@ Genome::openFileAndGetSizes(const char *filename, GenericFile **file, GenomeDist
char linebuf[2000];
char *retval = (*file)->gets(linebuf, sizeof(linebuf));

if (NULL == retval || 2 != sscanf(linebuf,"%lld %d\n", nBases, nContigs)) {
if (NULL == retval || 2 != sscanf(linebuf,"%ld %d\n", nBases, nContigs)) {
(*file)->close();
delete *file;
*file = NULL;
Expand Down Expand Up @@ -489,4 +489,4 @@ const Genome::Contig *Genome::getContigForRead(GenomeLocation location, unsigned
return contig;
}

GenomeLocation InvalidGenomeLocation; // Gets set on genome build/load
GenomeLocation InvalidGenomeLocation; // Gets set on genome build/load
8 changes: 4 additions & 4 deletions SNAPLib/GenomeIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ GenomeIndex::BuildIndexToDirectory(const Genome *genome, int seedLen, double sla
WriteErrorMessage("GenomeIndex::saveToDirectory: Failed to save the genome itself\n");
return false;
}
fprintf(stderr,"%llds\n", (timeInMillis() + 500 - start) / 1000);
fprintf(stderr,"%lds\n", (timeInMillis() + 500 - start) / 1000);

GenomeIndex *index = new GenomeIndex();
index->genome = NULL; // We always delete the index when we're done, but we delete the genome first to save space during the overflow table build.
Expand Down Expand Up @@ -676,7 +676,7 @@ GenomeIndex::BuildIndexToDirectory(const Genome *genome, int seedLen, double sla
fprintf(histogramFile,"%d\t%d\n", i, histogram[i]);
}
}
fprintf(histogramFile, "%d larger than %d with %d total genome locations, largest seed %d\n", countOfTooBigForHistogram, maxHistogramEntry, sumOfTooBigForHistogram, largestSeed);
fprintf(histogramFile, "%ld larger than %u with %ld total genome locations, largest seed %ld\n", countOfTooBigForHistogram, maxHistogramEntry, sumOfTooBigForHistogram, largestSeed);
fclose(histogramFile);
delete [] histogram;
}
Expand Down Expand Up @@ -728,7 +728,7 @@ GenomeIndex::BuildIndexToDirectory(const Genome *genome, int seedLen, double sla
return false;
}

fprintf(indexFile,"%d %d %d %lld %d %d %d %lld %d %d", GenomeIndexFormatMajorVersion, GenomeIndexFormatMinorVersion, index->nHashTables,
fprintf(indexFile,"%d %d %d %lu %d %d %d %lu %d %d", GenomeIndexFormatMajorVersion, GenomeIndexFormatMinorVersion, index->nHashTables,
index->overflowTableSize, seedLen, chromosomePaddingSize, hashTableKeySize, totalBytesWritten, large ? 0 : 1, locationSize);

fclose(indexFile);
Expand Down Expand Up @@ -1622,7 +1622,7 @@ GenomeIndex::loadFromDirectory(char *directoryName, bool map, bool prefetch)
unsigned hashTableKeySize;
unsigned smallHashTable;
unsigned locationSize;
if (10 != (nRead = sscanf(indexFileBuf,"%d %d %d %lld %d %d %d %lld %d %d", &majorVersion, &minorVersion, &nHashTables, &overflowTableSize, &seedLen, &chromosomePadding,
if (10 != (nRead = sscanf(indexFileBuf,"%d %d %d %lu %d %d %d %lu %d %d", &majorVersion, &minorVersion, &nHashTables, &overflowTableSize, &seedLen, &chromosomePadding,
&hashTableKeySize, &hashTablesFileSize, &smallHashTable, &locationSize))) {
if (3 == nRead || 6 == nRead || 7 == nRead || 9 == nRead) {
WriteErrorMessage("Indices built by versions before 1.0dev.21 are no longer supported. Please rebuild your index.\n");
Expand Down
Loading

0 comments on commit 1d97a36

Please sign in to comment.