Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-11-12 Can Alkan <calkan@gmail.com>
* Default output file is now (seqFile1)-output.sam(.gz) & default nohit file is (seqFile1)-output.nohit.fastq(.gz)
* No-hit FASTQ output is new also compressed when --outcomp parameter is used.
* mrsFAST now accepts -t as a short form for --threads.

2014-03-31 Faraz Hach <fhach@sfu.ca>
* Added with-sse4 option to Makefile
* Bug reported by viktor in dc mode is fixed.
Expand Down
307 changes: 288 additions & 19 deletions CommandLineParser.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CommandLineParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@

int parseCommandLine (int argc, char *argv[]);
void finalizeCommandParser();

void printHelp(void);
#endif
8 changes: 4 additions & 4 deletions Common.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ FILE *fileOpen(char *fileName, char *mode)
fp = fopen (fileName, mode);
if (fp == NULL)
{
fprintf(stdout, "Error: Cannot Open the file %s\n", fileName);
fflush(stdout);
fprintf(stderr, "Error: Cannot Open the file %s\n", fileName);
fflush(stderr);
exit(EXIT_FAILURE);
}
return fp;
Expand All @@ -74,8 +74,8 @@ gzFile fileOpenGZ(char *fileName, char *mode)
gzfp = gzopen (fileName, mode);
if (gzfp == Z_NULL)
{
fprintf(stdout, "Error: Cannot Open the file %s\n", fileName);
fflush(stdout);
fprintf(stderr, "Error: Cannot Open the file %s\n", fileName);
fflush(stderr);
exit(EXIT_FAILURE);
}
return gzfp;
Expand Down
1 change: 1 addition & 0 deletions Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ extern int bestMappingMode;
extern int SNPMode;
extern int seqCompressed;
extern int outCompressed;
extern int isCloud;
extern int cropSize;
extern int tailCropSize;
extern int progressRep;
Expand Down
18 changes: 9 additions & 9 deletions HashTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ int generateHashTable(char *fileName, char *indexName)
if (!initLoadingRefGenome(fileName, genomeMetaInfo, &genomeMetaInfoLength))
return 0;
initSavingIHashTable(indexName, genomeMetaInfo, genomeMetaInfoLength);
fprintf(stdout, "Generating Index from %s", fileName);
fflush(stdout);
fprintf(stderr, "Generating Index from %s", fileName);
fflush(stderr);

do
{
Expand All @@ -244,14 +244,14 @@ int generateHashTable(char *fileName, char *indexName)

if ( strcmp(prev, refGenName) != 0)
{
fprintf(stdout, "\n - %s ", refGenName);
fflush(stdout);
fprintf(stderr, "\n - %s ", refGenName);
fflush(stderr);
sprintf(prev, "%s", refGenName);
}
else
{
fprintf(stdout, ".");
fflush(stdout);
fprintf(stderr, ".");
fflush(stderr);
}

c = refGen;
Expand Down Expand Up @@ -296,7 +296,7 @@ int generateHashTable(char *fileName, char *indexName)
finalizeLoadingRefGenome();
finalizeSavingIHashTable();

fprintf(stdout, "\nDONE in %0.2fs!\n", (getTime()-startTime));
fprintf(stderr, "\nDONE in %0.2fs!\n", (getTime()-startTime));
return 1;
}
/**********************************************/
Expand All @@ -315,12 +315,12 @@ int checkHashTable(char *fileName)
tmp = fread(&magicNumber, sizeof(magicNumber), 1, _ih_fp);
if (magicNumber == 1)
{
fprintf(stdout, "Error: Please use version 1.2.6.4 in bisulfite mode.\n");
fprintf(stderr, "Error: Please use version 1.2.6.4 in bisulfite mode.\n");
return 0;
}
else if (magicNumber == 0)
{
fprintf(stdout, "Error: Please use version 2.x.x.x or upgrade your index.\n");
fprintf(stderr, "Error: Please use version 2.x.x.x or upgrade your index.\n");
return 0;
}

Expand Down
39 changes: 5 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
MRSFAST_VERSION := "3.4.0"
MRSFAST_VERSION := "3.4.8"
BUILD_DATE := "$(shell date)"

all: OPTIMIZE_FLAGS build
debug: DEBUG_FLAGS build
profile: PROFILE_FLAGS build
build: clean_executables SSE_FLAGS mrsfast snp_indexer clean_objects
build: clean_executables mrsfast snp_indexer clean_objects

LDFLAGS=#-static
LIBS=-lz -lm -pthread -lpthread
CFLAGS=-fno-pic -DMRSFAST_VERSION=\"$(MRSFAST_VERSION)\" -DBUILD_DATE=\"$(BUILD_DATE)\"
LIBS=-lz -lm -pthread -lpthread -DSSE4=1 -msse4.2
CFLAGS=-DMRSFAST_VERSION=\"$(MRSFAST_VERSION)\" -DBUILD_DATE=\"$(BUILD_DATE)\" -DSSE4=1 -msse4.2

objects=baseFAST.o Sort.o MrsFAST.o Common.o CommandLineParser.o RefGenome.o HashTable.o Reads.o Output.o SNPReader.o HELP.o
objects=baseFAST.o Sort.o MrsFAST.o Common.o CommandLineParser.o RefGenome.o HashTable.o Reads.o Output.o SNPReader.o

mrsfast: clean_executables $(objects)
ifeq ($(shell uname -s),Linux)
Expand Down Expand Up @@ -38,15 +38,6 @@ clean_executables:
@rm -f mrsfast
@rm -f snp_indexer

HELP.o:
@groff -Tascii -man ./HELP.man > HELP
ifeq ($(shell uname -s),Linux)
@ld -r -b binary -o HELP.o HELP
else
@touch HELPstub.c
gcc -o HELPstub.o -c HELPstub.c
ld -r -o HELP.o -sectcreate binary HELP HELP HELPstub.o
endif

DEBUG_FLAGS:
$(eval CFLAGS = $(CFLAGS) -ggdb)
Expand All @@ -59,23 +50,3 @@ PROFILE_FLAGS:
$(eval CFLAGS = $(CFLAGS) -pg -g)
$(eval LIBS = $(LIBS) -pg -g)

SSE_FLAGS:
ifeq ($(shell uname -s),Linux)
ifeq ($(with-sse4),no)
$(shell echo "-DSSE4=0")
else
$(eval CFLAGS = $(CFLAGS) \
$(shell gv=`gcc -dumpversion`; \
sc=`grep -c "sse4" /proc/cpuinfo`; \
echo $$sc.$$gv | awk -F. '{if($$1>0 && $$2>=4 && $$3>=4) print "-DSSE4=1 -msse4.2"; else print "-DSSE4=0"}'))
endif
else
ifeq ($(with-sse4),no)
$(shell echo "-DSSE4=0")
else
$(eval CFLAGS = $(CFLAGS) \
$(shell gv=`gcc -dumpversion`; \
sc=`sysctl -n machdep.cpu.features | grep -c "SSE4"` ;\
echo $$sc.$$gv | awk -F. '{if($$1>0 && $$2>=4 && $$3>=4) print "-DSSE4=1 -msse4.2"; else print "-DSSE4=0"}'))
endif
endif
36 changes: 18 additions & 18 deletions MrsFAST.c
Original file line number Diff line number Diff line change
Expand Up @@ -2692,34 +2692,34 @@ void outputBestPairedEnd()
f1 = 1 + 4 + 8 + 64;
f2 = 1 + 4 + 8 + 128;
optSize1 = optSize2 = 0;
//fprintf(stdout, "unset\n");
//fprintf(stderr, "unset\n");
break;
case first_mate:
f1 = 1 + 8 + 64 + ((_msf_bestMappingPE[i].dir1 == -1) ?16 :0);
f2 = 1 + 4 + 128 + ((_msf_bestMappingPE[i].dir1 == -1) ?32 :0);
optSize2 = 0;
//fprintf(stdout, "1stmate\n");
//fprintf(stderr, "1stmate\n");
break;
case second_mate:
f1 = 1 + 4 + 64 + ((_msf_bestMappingPE[i].dir2 == -1) ?32 :0);
f2 = 1 + 8 + 128 + ((_msf_bestMappingPE[i].dir2 == -1) ?16 :0);
//fprintf(stdout, "2ndmate\n");
//fprintf(stderr, "2ndmate\n");
optSize1 = 0;
break;
case trans_loc:
f1 = 1 + 64 + ((_msf_bestMappingPE[i].dir1 == -1) ?16 :0) + ((_msf_bestMappingPE[i].dir2 == -1) ?32 :0);
f2 = 1 + 128 + ((_msf_bestMappingPE[i].dir2 == -1) ?16 :0) + ((_msf_bestMappingPE[i].dir1 == -1) ?32 :0);
//fprintf(stdout, "transLoc %d %d\n", f1, f2);
//fprintf(stderr, "transLoc %d %d\n", f1, f2);
break;
case improper:
f1 = 1 + 64 + ((_msf_bestMappingPE[i].dir1 == -1) ?16 :0) + ((_msf_bestMappingPE[i].dir2 == -1) ?32 :0);
f2 = 1 + 128 + ((_msf_bestMappingPE[i].dir2 == -1) ?16 :0) + ((_msf_bestMappingPE[i].dir1 == -1) ?32 :0);
//fprintf(stdout, "improper\n");
//fprintf(stderr, "improper\n");
break;
case proper:
f1 = 1 + 2 + 64 + ((_msf_bestMappingPE[i].dir1 == -1) ?16 :0) + ((_msf_bestMappingPE[i].dir2 == -1) ?32 :0);
f2 = 1 + 2 + 128 + ((_msf_bestMappingPE[i].dir2 == -1) ?16 :0) + ((_msf_bestMappingPE[i].dir1 == -1) ?32 :0);
//fprintf(stdout, "proper\n");
//fprintf(stderr, "proper\n");
break;
}
//output best
Expand Down Expand Up @@ -3415,7 +3415,7 @@ void updateBestPairedEnd()
}


//fprintf(stdout, "HERE?\n");
//fprintf(stderr, "HERE?\n");
/* pos = 0;

for (j=0; j<size1; j++)
Expand Down Expand Up @@ -3622,7 +3622,7 @@ void outputPairedEndDiscPP()
int dist = 0;
char event;

//fprintf(stdout, "%c %c ", dir1, dir2);
//fprintf(stderr, "%c %c ", dir1, dir2);

if (loc1 == loc2)
{
Expand All @@ -3633,49 +3633,49 @@ void outputPairedEndDiscPP()
if ( dir1 == dir2 )
{
event = 'V';
//fprintf(stdout, "Inverstion \n");
//fprintf(stderr, "Inverstion \n");
}
else
{
if (loc1 < loc2)
{

//fprintf(stdout, "< %d ", loc2-loc1-SEQ_LENGTH);
//fprintf(stderr, "< %d ", loc2-loc1-SEQ_LENGTH);

if (dir1 == 'R' && dir2 == 'F')
{
event = 'E';

//fprintf(stdout, "Everted \n");
//fprintf(stderr, "Everted \n");
}
else if ( loc2 - loc1 >= maxPairEndedDiscordantDistance )
{
event = 'D';
//fprintf(stdout, "Deletion \n");
//fprintf(stderr, "Deletion \n");
}
else
{
event = 'I';
//fprintf(stdout, "Insertion \n");
//fprintf(stderr, "Insertion \n");
}
}
else if (loc2 < loc1)
{
//fprintf(stdout, "> %d ", loc1-loc2-SEQ_LENGTH);
//fprintf(stderr, "> %d ", loc1-loc2-SEQ_LENGTH);
if (dir2 == 'R' && dir1 == 'F')
{
event = 'E';
//fprintf(stdout, "Everted \n");
//fprintf(stderr, "Everted \n");
}
else if ( loc1 - loc2 >= maxPairEndedDiscordantDistance )
{
event = 'D';
//fprintf(stdout, "Deletion \n");
//fprintf(stderr, "Deletion \n");
}
else
{
event = 'I';
//fprintf(stdout, "Insertion \n");
//fprintf(stderr, "Insertion \n");
}
}
}
Expand Down Expand Up @@ -4080,7 +4080,7 @@ void calculateConcordantDistances()

minPairEndedDistance = (int)(mu - 3*sigma);
maxPairEndedDistance = (int)(mu + 3*sigma);
//fprintf(stdout, "cnt %d mu %lf sig %lf min %d max %d\n", cnt, mu, sigma, minPairEndedDistance, maxPairEndedDistance);
//fprintf(stderr, "cnt %d mu %lf sig %lf min %d max %d\n", cnt, mu, sigma, minPairEndedDistance, maxPairEndedDistance);

FILE *out = fileOpen(concordantStatOutput, "w");
fprintf(out, "TotalNumbReads: 2*%d\n", (_msf_seqListSize / 2));
Expand Down
29 changes: 25 additions & 4 deletions Output.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ int initOutput ( char *fileName, int compressed)
if (compressed)
{
char newFileName[strlen(mappingOutputPath)+strlen(fileName)+4];
sprintf(newFileName, "%s%s.sam.gz", mappingOutputPath, fileName);
if (!isCloud)
sprintf(newFileName, "%s%s.sam.gz", mappingOutputPath, fileName);
else
sprintf(newFileName, "%s.sam.gz", fileName);
fprintf(stderr, "mappingOutputPath: %s\nfileName: %s\nnewFileName: %s\n", mappingOutputPath, fileName, newFileName);
_out_gzfp = fileOpenGZ(newFileName, "w1f");
if (_out_gzfp == Z_NULL)
{
Expand All @@ -187,11 +191,28 @@ int initOutput ( char *fileName, int compressed)
}
else
{
//sprintf(newFileName, "%s%s.sam", mappingOutputPath, fileName);
sprintf(newFileName, "%s%s", mappingOutputPath, fileName);
if (!isCloud){
int fnlen = strlen(fileName);
if ( ! (fileName[fnlen-1]=='m' && fileName[fnlen-2]=='a' && fileName[fnlen-3]=='s' ) )
sprintf(newFileName, "%s%s.sam", mappingOutputPath, fileName);
else
sprintf(newFileName, "%s%s", mappingOutputPath, fileName);
}
else{
int fnlen = strlen(fileName);
if ( ! (fileName[fnlen-1]=='m' && fileName[fnlen-2]=='a' && fileName[fnlen-3]=='s' ) )
sprintf(newFileName, "%s.sam", fileName);
else
sprintf(newFileName, "%s", fileName);
//sprintf(newFileName, "%s%s", mappingOutputPath, fileName);
}
}

_out_fp = fileOpen(newFileName, "w");
if (!strstr(newFileName, "/dev/stdout"))
_out_fp = fileOpen(newFileName, "w");
else
_out_fp = stdout;

if (_out_fp == NULL)
{
return 0;
Expand Down
Loading