]> git.donarmstrong.com Git - bamtools.git/blob - bamtools_index.h
Reorganization of toolkit. Split subtools out to own headers. Added custom getopt...
[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] <BAM file>" << std::endl;
26     std::cerr << "\t--nclist\tUse NCList indexing scheme (faster?)\t[default=off] ** JUST HERE AS POSSIBLE SWITCH EXAMPLE FOR NOW **" << std::endl;
27     std::cerr << "\t<BAM file>\tInput BAM file to generate index from\t[req'd]" << std::endl;
28     std::cerr << std::endl;
29     return 0;
30 }
31
32 int RunBamIndex(int argc, char* argv[]) {
33   
34     // else parse command line for args  
35     GetOpt options(argc, argv, 1);
36     
37     std::string inputFilename;
38     options.addRequiredArgument("input", &inputFilename);
39     
40     bool useNCList;
41     options.addSwitch("nclist", &useNCList);
42     
43     if ( !options.parse() ) return BamIndexHelp();
44     
45     // open our BAM reader
46     BamReader reader;
47     reader.Open(inputFilename);
48     
49     // create index for BAM file
50     reader.CreateIndex();
51     
52     // clean & exit
53     reader.Close();
54     return 0;
55 }
56
57 } // namespace BamTools
58
59 #endif // BAMTOOLS_INDEX_H