git-svn-id: https://www.grenoble.prabi.fr/svn/LECASofts/ecoPCR/branches/refactoring@58 60f365c0-8329-0410-b2a4-ec073aeeaa1d
This commit is contained in:
@ -3,6 +3,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#define VERSION "0.1"
|
#define VERSION "0.1"
|
||||||
|
|
||||||
@ -23,7 +25,6 @@ int ispatternmatching(char **line, char **pattern, int32_t numpattern, int32_t e
|
|||||||
|
|
||||||
sscanf(line[4],"%d",&seq->taxid);
|
sscanf(line[4],"%d",&seq->taxid);
|
||||||
seq->AC = strdup(line[0]);
|
seq->AC = strdup(line[0]);
|
||||||
//seq->DE = strdup(line[]);
|
|
||||||
seq->SQ = strdup(line[18]);
|
seq->SQ = strdup(line[18]);
|
||||||
seq->SQ_length = strlen(line[18]);
|
seq->SQ_length = strlen(line[18]);
|
||||||
|
|
||||||
@ -66,9 +67,9 @@ static void PrintHelp()
|
|||||||
PP " -r : [R]estrict taxomic id\n\n");
|
PP " -r : [R]estrict taxomic id\n\n");
|
||||||
PP " -v : in[V]ert the sense of matching, to select non-matching lines.\n");
|
PP " -v : in[V]ert the sense of matching, to select non-matching lines.\n");
|
||||||
PP "------------------------------------------\n");
|
PP "------------------------------------------\n");
|
||||||
PP " Pattern : oligonucleotide pattern\n");;
|
PP " Pattern : oligonucleotide pattern\n");
|
||||||
PP "------------------------------------------\n\n");
|
PP "------------------------------------------\n\n");
|
||||||
PP " https://www.grenoble.prabi.fr/trac/ecoPCR/wiki");
|
PP " https://www.grenoble.prabi.fr/trac/ecoPCR/wiki\n");
|
||||||
PP "------------------------------------------\n\n");
|
PP "------------------------------------------\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,26 +110,31 @@ int main(int argc, char **argv){
|
|||||||
|
|
||||||
ecotaxonomy_t *taxonomy;
|
ecotaxonomy_t *taxonomy;
|
||||||
|
|
||||||
char *filename = NULL; // stores the datafile name
|
|
||||||
char *database = NULL; // stores the database path (for taxonomy)
|
char *database = NULL; // stores the database path (for taxonomy)
|
||||||
int32_t *restricted_taxid = NULL; // stores the restricted taxid
|
int32_t *restricted_taxid = NULL; // stores the restricted taxid
|
||||||
int32_t *ignored_taxid = NULL; // stores the ignored taxid
|
int32_t *ignored_taxid = NULL; // stores the ignored taxid
|
||||||
char **pattern = NULL; // stores the regex pattern
|
char **pattern = NULL; // stores the regex pattern
|
||||||
char *line[19] = {0}; // stores the line
|
char *line[19] = {0}; // stores the line
|
||||||
|
|
||||||
|
|
||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
char *stream = ECOMALLOC(sizeof(char *)*10000,"error stream buffer allocation");
|
char *stream = ECOMALLOC(sizeof(char *)*10000,"error stream buffer allocation");
|
||||||
int current_taxid;
|
int current_taxid;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
|
struct stat buf;
|
||||||
|
|
||||||
|
// check stdin
|
||||||
|
if (fstat(fileno(stdin),&buf) == 0)
|
||||||
|
if ( (buf.st_dev) == 0)
|
||||||
|
file = stdin;
|
||||||
|
|
||||||
|
|
||||||
while ((carg = getopt(argc, argv, "f:d:i:r:e:vh")) != -1) {
|
while ((carg = getopt(argc, argv, "f:d:i:r:e:vh")) != -1) {
|
||||||
|
|
||||||
switch (carg) {
|
switch (carg) {
|
||||||
case 'f':
|
case 'f':
|
||||||
filename = ECOMALLOC(strlen(optarg)+1,
|
if ( (file = fopen(optarg, "r")) == NULL)
|
||||||
"Error on filename allocation");
|
errflag++;
|
||||||
strcpy(filename,optarg);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
@ -201,22 +207,14 @@ int main(int argc, char **argv){
|
|||||||
/**
|
/**
|
||||||
* check everything required is provided
|
* check everything required is provided
|
||||||
*/
|
*/
|
||||||
if (!filename ||
|
if ( !file ||
|
||||||
!database ||
|
!database ||
|
||||||
(!p && restricted_taxid == NULL && ignored_taxid == NULL))
|
(!p && restricted_taxid == NULL && ignored_taxid == NULL)
|
||||||
|
)
|
||||||
errflag++;
|
errflag++;
|
||||||
|
|
||||||
if (errflag)
|
if (errflag)
|
||||||
ExitUsage(errflag);
|
ExitUsage(errflag);
|
||||||
|
|
||||||
/**
|
|
||||||
* Open the ecoPCR file
|
|
||||||
*/
|
|
||||||
if (filename)
|
|
||||||
{
|
|
||||||
if( (file = fopen(filename, "r")) == NULL)
|
|
||||||
ECOERROR(ECO_IO_ERROR,"Cannot open the file !");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the taxonomy back
|
* Get the taxonomy back
|
||||||
@ -282,6 +280,9 @@ int main(int argc, char **argv){
|
|||||||
|
|
||||||
printf("# %d matching result\n",matchingresult);
|
printf("# %d matching result\n",matchingresult);
|
||||||
|
|
||||||
|
if ( file != stdin )
|
||||||
|
fclose(file);
|
||||||
|
|
||||||
freememory(line,i);
|
freememory(line,i);
|
||||||
freememory(pattern,p);
|
freememory(pattern,p);
|
||||||
ECOFREE(pattern,"Error in free pattern");
|
ECOFREE(pattern,"Error in free pattern");
|
||||||
|
Reference in New Issue
Block a user