File: rabema.cpp

package info (click to toggle)
seqan2 2.4.0%2Bdfsg-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 224,180 kB
  • sloc: cpp: 256,886; ansic: 91,672; python: 8,330; sh: 995; xml: 570; makefile: 252; awk: 51; javascript: 21
file content (123 lines) | stat: -rw-r--r-- 4,279 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// ==========================================================================
//                      RABEMA Read Alignment Benchmark
// ==========================================================================
// Copyright (C) 2010-1012 Manuel Holtgrewe, FU Berlin
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along
// with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// ==========================================================================
// Author: Manuel Holtgrewe <manuel.holtgrewe@fu-berlin.de>
// ==========================================================================
// Read mapper benchmark tool.  This is the top level program that
// parses the command line parameters and then calls the main routine
// from the headers "build_gold_standard.h" and "evaluation.h".  These
// headers contain the code for building the gold standard and
// comparing the read mapper results against the gold standard.  They
// also contain the command line parsing code used here.
//
// Usage: rabema build_standard -o GOLD_STANDARD.gsi GENOME.fasta GOLD.sam
//        rabema compare GENOME.fasta GOLD_STANDARD.gsi READ_MAPPER_OUTPUT.sam
// ==========================================================================

#include "rabema.h"

#include <iostream>

#include "evaluation.h"
#include "build_gold_standard.h"

/* Print global help.  This function is called when the user specifies
   a wrong simulation command.
 */
void printHelpGlobal()
{
    std::cerr << "RABEMA - Read Alignment Benchmark" << std::endl
              << "(c) 2010 by Manuel Holtgrewe" << std::endl
              << std::endl
              << "Usage: rabema build_standard -o GOLD_STANDARD.gsi GENOME.fasta GOLD.sam" << std::endl
              << "       rabema compare GENOME.fasta GOLD_STANDARD.gsi READ_MAPPER_OUTPUT.sam" << std::endl
              << std::endl
              << "Call with 'rabema COMMAND --help' to get detailed help." << std::endl;
}

int parseOptions(Options<Global> & options, const int argc, const char * argv[])
{
    if (argc == 1 ||
        (argc >= 2 && CharString(argv[1]) == "--help") ||
        (argc >= 2 && CharString(argv[1]) == "-h"))
    {
        printHelpGlobal();
        return 0;
    }
    else if (argc >= 2 && CharString(argv[1]) != "build_standard" && CharString(argv[1]) != "compare")
    {
        printHelpGlobal();
        return 1;
    }

    if (CharString(argv[1]) == "build_standard")
    {
        options.selectedCommand = COMMAND_BUILD_STANDARD;
    }
    else if (CharString(argv[1]) == "compare")
    {
        options.selectedCommand = COMMAND_EVALUATE;
    }
    else
    {
        printHelpGlobal();
        return 1;
    }

    return 0;
}

int main(int argc, char const ** argv)
{
    Options<Global> globalOptions;
    int ret = parseOptions(globalOptions, argc, argv);
    if (ret)
        return ret;

    if (globalOptions.selectedCommand == COMMAND_BUILD_STANDARD)
    {
        CommandLineParser parser;
        setUpCommandLineParser(parser, BuildGoldStandard());
        Options<BuildGoldStandard> options;
        int ret = parseCommandLineAndCheck(options, parser, argc, argv);
        if (options.showHelp)
            return 0;

        if (ret != 0)
            return ret;

        return buildGoldStandard(options);
    }
    else if (globalOptions.selectedCommand == COMMAND_EVALUATE)
    {
        CommandLineParser parser;
        setUpCommandLineParser(parser, EvaluateResults());
        Options<EvaluateResults> options;
        int ret = parseCommandLineAndCheck(options, parser, argc, argv);
        if (options.showHelp)
            return 0;

        if (ret != 0)
            return ret;

        return evaluateReadMapperResult(options);
    }

    return 0;
}