Skip to content

Commit

Permalink
Merge pull request ExpressionAnalysis#1 from wandai330/integer_overflow
Browse files Browse the repository at this point in the history
Fix int type overflow
  • Loading branch information
wandai330 authored Jun 16, 2017
2 parents e556e16 + 28e3c8f commit dac8de5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
8 changes: 6 additions & 2 deletions clipper/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CC=g++
PREFIX?=/usr
BINDIR?=$(PREFIX)/bin
CFLAGS?=-O3 -I.
CXXFLAGS=-std=c++0x $(CFLAGS)
# for debugging:
# CFLAGS?=-g -I.

Expand Down Expand Up @@ -70,7 +71,7 @@ $(PKG).${VER}-${REL}.tar.gz: $(PKG).tar.gz

sparsehash: sparsehash-2.0.3
cd sparsehash-2.0.3; ./configure; make
mkdir sparsehash
mkdir -p sparsehash
cp -r sparsehash-2.0.3/src/sparsehash/* sparsehash/

# why the libbam.a doesn't work? not sure... *.o works
Expand All @@ -94,8 +95,11 @@ else
$(CC) $(CFLAGS) fastq-lib.cpp tidx/tidx-lib.cpp -o $@ $< -lgsl -lgslcblas
endif

fastq-multx: fastq-multx.cpp fastq-lib.cpp sparsehash
$(CC) $(CXXFLAGS) fastq-multx.cpp fastq-lib.cpp -o $@

fastq-stats: fastq-stats.cpp fastq-lib.cpp gcModel.cpp sparsehash
$(CC) $(CFLAGS) fastq-lib.cpp gcModel.cpp -o $@ $<
$(CC) $(CXXFLAGS) fastq-lib.cpp gcModel.cpp -o $@ $<

bam-filter: bam-filter.cpp
$(CC) $(CFLAGS) fastq-lib.cpp -o $@ $< -lbamtools
Expand Down
10 changes: 5 additions & 5 deletions clipper/fastq-multx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ THE SOFTWARE.
See "void usage" below for usage.
*/

#include <cinttypes>
#include "fastq-lib.h"

#define MAX_BARCODE_NUM 6000
Expand All @@ -43,7 +43,7 @@ struct bc {
char *out[6]; // one output per input
FILE *fout[6];
bool gzout[6];
int cnt; // count found
uint64_t cnt; // count found
bool shifted; // count found in 1-shifted position
char * dual; // is this a dual-indexed barcode? if so, this points to the second index.
int dual_n; // length of dual
Expand Down Expand Up @@ -1072,17 +1072,17 @@ int main (int argc, char **argv) {

int j;
printf("Id\tCount\tFile(s)\n");
int tot=0;
uint64_t tot=0;
for (i=0;i<=bcnt;++i) {
printf("%s\t%d", bc[i].id.s, bc[i].cnt);
printf("%s\t%" PRIu64, bc[i].id.s, bc[i].cnt);
tot+=bc[i].cnt;
for (j=0;j<f_n;++j) {
if (bc[i].out[j])
printf("\t%s", bc[i].out[j]);
}
printf("\n");
}
printf("total\t%d\n", tot);
printf("total\t%" PRIu64 "\n", tot);

if (!io_ok)
return 3;
Expand Down
5 changes: 4 additions & 1 deletion clipper/fastq-stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const char * VERSION = "1.01 $Id$";

#include <ctype.h>
#include <stdio.h>
#include <cinttypes>

void usage( FILE * f ) {
fprintf( f,
Expand Down Expand Up @@ -153,7 +154,7 @@ int window = 2000000;
int cyclemax = 35;
int gcCyclemax = 100; // to compare with fastqc, seq is rounded to nearest 100 to reduce # of gc models; for < 200 length, this is teh same as max=100
float gcSum;
int gcTotal;
uint64_t gcTotal;

int show_max = 10;
bool debug = 0;
Expand Down Expand Up @@ -565,6 +566,8 @@ int main( int argc, char**argv ) {

if(gc) {
// put these where they belong
if (debug)
printf("gcTotal\t%" PRIu64 "\tgcSum\t%f\n\n", gcTotal, gcSum);
printf("pct-gc cycle-max\t%d\n", gcCyclemax);
printf("pct-gc mean\t%.2f\n", 100.0 * gcSum / gcTotal);
}
Expand Down

0 comments on commit dac8de5

Please sign in to comment.