@@ -18,9 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
19
19
*/
20
20
21
- #include <stdio.h>
22
- #include <stdlib.h>
23
- #include <string.h>
24
21
#include "Globals.h"
25
22
#include "Utility.h"
26
23
#include "ErrorProcessing.h"
@@ -29,7 +26,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
29
26
#include "ErrorCorrection.h"
30
27
#include "Reads.h"
31
28
#include "Correction.h"
29
+
30
+ #include <stdio.h>
31
+ #include <stdlib.h>
32
+ #include <string.h>
32
33
#include <libgen.h>
34
+ #include <sys/types.h>
35
+ #include <sys/stat.h>
36
+ #include <unistd.h>
33
37
34
38
unsigned int KMER_SIZE = 31 ;
35
39
@@ -107,6 +111,19 @@ void hashReads(Correction* correction)
107
111
}
108
112
}
109
113
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
+
110
127
void executePairedCorrection (Correction * correction ,
111
128
FILE * leftCorrectedFile , FILE * rightCorrectedFile ,
112
129
FILE * leftGarbageFile , FILE * rightGarbageFile , FILE * extraFile )
@@ -402,14 +419,17 @@ Correction* preprocessing(int numInputFiles, char* inputFileNames, char* outputD
402
419
{
403
420
unsigned int LOW_COVERAGE_THRESHOLD_DEFAULT = 3 ;
404
421
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 ++ )
413
433
{
414
434
char * inputFileName = & (inputFileNames [i * 200 ]);
415
435
printf ("Reading file: %s\n" , inputFileName );
0 commit comments