]> git.donarmstrong.com Git - bamtools.git/blob - bamtools_index.h
Mostly cleaned up help & usage messages. Added MIT license.
[bamtools.git] / bamtools_index.h
1 // ***************************************************************************
2 // bamtools_index.h (c) 2010 Derek Barnett, Erik Garrison
3 // Marth Lab, Department of Biology, Boston College
4 // All rights reserved.
5 // ---------------------------------------------------------------------------
6 // Last modified: 26 May 2010
7 // ---------------------------------------------------------------------------
8 // Creates a BAM index (".bai") file for the provided BAM file.
9 // ***************************************************************************
10
11 #ifndef BAMTOOLS_INDEX_H
12 #define BAMTOOLS_INDEX_H
13
14 #include <iostream>
15 #include <string>
16
17 #include "BamReader.h"
18 // #include "GetOpt.h"
19 #include "bamtools_getopt.h"
20
21 namespace BamTools {
22
23 int BamIndexHelp(void) { 
24     std::cerr << std::endl;
25     std::cerr << "usage:\tbamtools index [--nclist] FILE" << std::endl;
26     std::cerr << std::endl;
27     std::cerr << "\t--nclist  Use NCList indexing scheme (faster?)   [off] ** JUST HERE AS POSSIBLE SWITCH EXAMPLE FOR NOW **" << std::endl;
28     std::cerr << "\tFILE      Input BAM file to generate index from  [REQUIRED]" << std::endl;
29     std::cerr << std::endl;
30     return 0;
31 }
32
33 int RunBamIndex(int argc, char* argv[]) {
34   
35     // else parse command line for args  
36     GetOpt options(argc, argv, 1);
37     
38     std::string inputFilename;
39     options.addRequiredArgument("input", &inputFilename);
40     
41     bool useNCList;
42     options.addSwitch("nclist", &useNCList);
43     
44     if ( !options.parse() ) return BamIndexHelp();
45     
46     // open our BAM reader
47     BamReader reader;
48     reader.Open(inputFilename);
49     
50     // create index for BAM file
51     reader.CreateIndex();
52     
53     // clean & exit
54     reader.Close();
55     return 0;
56 }
57
58 } // namespace BamTools
59
60 #endif // BAMTOOLS_INDEX_H