Skip to content

Commit c5fa3cc

Browse files
committed
Fixed a crash when the output directory was missing.
1 parent 8284e58 commit c5fa3cc

File tree

4 files changed

+48
-18
lines changed

4 files changed

+48
-18
lines changed

README

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
======================================================================
22
Pollux
3-
Copyright (C) 2014 Eric Marinier
3+
Copyright (C) 2014-2015 Eric Marinier
44

55
This program is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -24,10 +24,10 @@ produced by second-generation sequencing technologies.
2424

2525
-- Release --
2626

27-
Pollux 1.01
28-
11 February 2015
27+
Pollux 1.0.2
28+
6 June 2015
2929

30-
Added compability with older versions of the GCC compiler.
30+
Fixed a crash when the output directory was missing.
3131

3232
-- Requirements --
3333

@@ -45,6 +45,9 @@ Pollux's command line arguments can be found by running:
4545
Simple correction:
4646
./pollux -i <fastq_reads>
4747

48+
Paired correction:
49+
./pollux -p -i <fastq_reads_1> <fastq_reads_2> -o ouput
50+
4851
-- Contact --
4952

5053
Brendan McConkey: [email protected]

ReleaseNotes

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
======================================================================
22

3-
Pollux 1.01
3+
Pollux 1.0.2
4+
6 June 2015
5+
6+
Fixed a crash when the output directory was missing.
7+
8+
======================================================================
9+
10+
Pollux 1.0.1
411
11 February 2015
512

613
Added compability with older versions of the GCC compiler.
714

815
======================================================================
916

10-
Pollux 1.00
17+
Pollux 1.0.0
1118
4 November 2014
1219

1320
This is the initial release of Pollux.

source/ErrorProcessing.c

+31-11
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
1919
*/
2020

21-
#include <stdio.h>
22-
#include <stdlib.h>
23-
#include <string.h>
2421
#include "Globals.h"
2522
#include "Utility.h"
2623
#include "ErrorProcessing.h"
@@ -29,7 +26,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2926
#include "ErrorCorrection.h"
3027
#include "Reads.h"
3128
#include "Correction.h"
29+
30+
#include <stdio.h>
31+
#include <stdlib.h>
32+
#include <string.h>
3233
#include <libgen.h>
34+
#include <sys/types.h>
35+
#include <sys/stat.h>
36+
#include <unistd.h>
3337

3438
unsigned int KMER_SIZE = 31;
3539

@@ -107,6 +111,19 @@ void hashReads(Correction* correction)
107111
}
108112
}
109113

114+
void checkDirectoryExistsAndCreate(char* directory)
115+
{
116+
const int MISSING = -1;
117+
118+
struct stat st = {0};
119+
120+
if (stat(directory, &st) == MISSING)
121+
{
122+
printf("Creating directory: %s\n", directory);
123+
mkdir(directory, 0700);
124+
}
125+
}
126+
110127
void executePairedCorrection(Correction* correction,
111128
FILE* leftCorrectedFile, FILE* rightCorrectedFile,
112129
FILE* leftGarbageFile, FILE* rightGarbageFile, FILE* extraFile)
@@ -402,14 +419,17 @@ Correction* preprocessing(int numInputFiles, char* inputFileNames, char* outputD
402419
{
403420
unsigned int LOW_COVERAGE_THRESHOLD_DEFAULT = 3;
404421

405-
// Data Structures:
406-
KMerHashTable* kmers = newKMerHashTable();
407-
Reads** reads = (Reads**)malloc(sizeof(Reads*) * numInputFiles);
408-
Correction* correction = (Correction*)malloc(sizeof(Correction));
409-
410-
// CREATE READS:
411-
printf("Creating read objects...\n");
412-
for(int i = 0; i < numInputFiles; i++)
422+
// DATA STRUCTURES:
423+
KMerHashTable* kmers = newKMerHashTable();
424+
Reads** reads = (Reads**)malloc(sizeof(Reads*) * numInputFiles);
425+
Correction* correction = (Correction*)malloc(sizeof(Correction));
426+
427+
// OUTPUT DIRECTORY:
428+
checkDirectoryExistsAndCreate(outputDirectory);
429+
430+
// CREATE READS:
431+
printf("Creating read objects...\n");
432+
for(int i = 0; i < numInputFiles; i++)
413433
{
414434
char* inputFileName = &(inputFileNames[i * 200]);
415435
printf("Reading file: %s\n", inputFileName);

source/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ int main(int argc, char**argv)
128128
bool filtering = true;
129129

130130
printf("\n");
131-
printf("Pollux 1.00\n");
131+
printf("Pollux 1.0.2\n");
132132
printf("Source compiled on %s at %s.\n", __DATE__, __TIME__);
133133
printf("\n");
134134

0 commit comments

Comments
 (0)