File: build_index.cpp

package info (click to toggle)
hilive 2.0a-5
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 956 kB
  • sloc: cpp: 4,723; python: 241; xml: 188; sh: 35; makefile: 14
file content (60 lines) | stat: -rw-r--r-- 2,411 bytes parent folder | download | duplicates (2)
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
#include <boost/program_options.hpp>

#include "../lib/headers.h"
#include "../lib/definitions.h"
#include "../lib/kindex.h"
#include "../lib/argument_parser.h"

AlignmentSettings globalAlignmentSettings;
mutex_map<std::string> fileLocks;


/**
 * Main function that organizes the overall structure of the program.
 * @param argc Number of arguments
 * @param argv Argument array
 * @return 0 on success, other numbers on error
 */
int main(int argc, const char* argv[]) {

	// Program start output.
	std::cout << std::endl << "________________________________________________________________________________" << std::endl << std::endl << "HiLive Index Builder v" << HiLive_VERSION_MAJOR << "." << HiLive_VERSION_MINOR <<
			" - Build Index for Realtime Alignment of Illumina Reads" << std::endl << "________________________________________________________________________________" << std::endl << std::endl;

	// Init argument parser
	BuildIndexArgumentParser argumentParser(argc, argv);

	// Parse command line arguments
	int parser_returnStatus = argumentParser.parseCommandLineArguments();

	// Successful execution of "help" or "license"
	if ( parser_returnStatus == 1 ) {
		exit(EXIT_SUCCESS);
	}

	// Parsing error
	else if ( parser_returnStatus == -1 ) {
		std::cout << "Parsing of command line options failed. For help, type 'hilive-build --help'." << std::endl;
		exit(EXIT_FAILURE);
	}

	// Build index
	std::cout << "Create FM-index from file " << argumentParser.fasta_name << " ..." << std::endl;

	  KixBuild* index = new KixBuild();

	// create and save the index
	  switch( index->create_index(argumentParser.fasta_name, argumentParser.index_name, !argumentParser.do_not_convert_spaces, argumentParser.trim_ids) ) {
	  case 0: std::cerr << "Index was successfully built to file(s) " << argumentParser.index_name << std::endl; break;
	  case 1: std::cerr << "Reading input file failed (no sequences found)." << std::endl; break;
	  case 2: std::cerr << "Reading input file failed." << std::endl; break;
	  case 3: std::cerr << "Writing metadata to file(s) failed." << std::endl; break;
	  case 4: std::cerr << "Index building failed." << std::endl; break;
	  case 5: std::cerr << "Writing index to file " << argumentParser.index_name << " failed." << std::endl; break;
	  default: std::cerr << "Failed due to an unknown error." << std::endl; break;
	  }

	delete index;

	return EXIT_SUCCESS;
}