1 /****************************************************************\
2 *                                                                *
3 *  fasta2esd - generate an exonerate sequence database file      *
4 *                                                                *
5 *  Guy St.C. Slater..   mailto:guy@ebi.ac.uk                     *
6 *  Copyright (C) 2000-2009.  All Rights Reserved.                *
7 *                                                                *
8 *  This source code is distributed under the terms of the        *
9 *  GNU General Public License, version 3. See the file COPYING   *
10 *  or http://www.gnu.org/licenses/gpl.txt for details            *
11 *                                                                *
12 *  If you use this code, please keep this notice intact.         *
13 *                                                                *
14 \****************************************************************/
15 
16 #include "argument.h"
17 #include "dataset.h"
18 #include "alphabet.h"
19 #include "fastadb.h"
20 
Argument_main(Argument * arg)21 int Argument_main(Argument *arg){
22     register ArgumentSet *as
23            = ArgumentSet_create("Sequence Input Options");
24     GPtrArray *input_path_list;
25     gchar *output_path;
26     gboolean softmask_input;
27     Alphabet_Type alphabet_type;
28     register Dataset *dataset;
29     register FILE *fp;
30     ArgumentSet_add_option(as, 'f', "fasta", "path",
31         "Fasta format input sequences", NULL,
32         NULL, &input_path_list);
33     ArgumentSet_add_option(as, 'o', "output", "path",
34         "Output path for .esd file", NULL,
35         Argument_parse_string, &output_path);
36     ArgumentSet_add_option(as, '\0', "alphabet", NULL,
37         "Specify sequence alphabet type", "unknown",
38         Alphabet_Argument_parse_alphabet_type, &alphabet_type);
39     ArgumentSet_add_option(as, 's', "softmask", NULL,
40         "Treat input sequences as softmasked", "TRUE",
41         Argument_parse_boolean, &softmask_input);
42     Argument_absorb_ArgumentSet(arg, as);
43     Argument_process(arg, "fasta2esd",
44         "generate an exonerate sequence database file\n"
45         "Guy St.C. Slater. guy@ebi.ac.uk. 2006.\n", NULL);
46     /* Check output absent before creating dataset */
47     fp = fopen(output_path, "r");
48     if(fp)
49         g_error("Output file [%s] already exists", output_path);
50     /**/
51     g_message("Creating Dataset (alphabet:[%s] softmasked:[%s])",
52             Alphabet_Type_get_name(alphabet_type),
53             softmask_input?"yes":"no");
54     dataset = Dataset_create(input_path_list, alphabet_type, softmask_input);
55     g_message("Writing Dataset");
56     Dataset_write(dataset, output_path);
57     Dataset_destroy(dataset);
58     g_message("-- completed");
59     return 0;
60     }
61 
62