]> git.donarmstrong.com Git - bamtools.git/blob - bamtools_sort.h
Reorganization of toolkit. Split subtools out to own headers. Added custom getopt...
[bamtools.git] / bamtools_sort.h
1 // ***************************************************************************
2 // bamtools_sortt.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 // Sorts an input BAM file (default by position) and stores in a new BAM file.
9 // ***************************************************************************
10
11 #ifndef BAMTOOLS_SORT_H
12 #define BAMTOOLS_SORT_H
13
14 #include <iostream>
15 #include <string>
16
17 #include "BamReader.h"
18 #include "bamtools_getopt.h"
19
20 namespace BamTools {
21
22 int BamSortHelp(void) { 
23     std::cerr << std::endl;
24     std::cerr << "usage:\tbamtools sort [--in BAM file] [--out sorted BAM file]" << std::endl;
25     std::cerr << "\t-i, --in\tInput BAM file to sort\t[default=stdin]" << std::endl;
26     std::cerr << "\t-o. --out\tDestination of sorted BAM file\t[default=stdout]" << std::endl;
27     std::cerr << std::endl;
28     return 0;
29 }
30
31 int RunBamSort(int argc, char* argv[]) {
32   
33     // else parse command line for args  
34     GetOpt options(argc, argv, 1);
35     
36     std::string inputFilename;
37     options.addOption('i', "in", &inputFilename);
38     
39     std::string outputFilename;
40     options.addOption('o', "out", &outputFilename);
41     
42     if ( !options.parse() ) return BamCoverageHelp();
43     if ( inputFilename.empty() )  { inputFilename  = "stdin"; }
44     if ( outputFilename.empty() ) { outputFilename = "stdout"; }
45     
46     // open our BAM reader
47 //     BamReader reader;
48 //     reader.Open(inputFilename);
49 //     
50 //     // retrieve header & reference dictionary info
51 //     std::string header = reader.GetHeaderText();
52 //     RefVector references = reader.GetReferenceData(); 
53 //     
54 //     BamWriter writer;
55 //     writer.Open(outputFilename, header, references);
56 //     
57     // sort BAM file
58     std::cerr << "Sorting " << inputFilename << std::endl;
59     std::cerr << "Saving sorted BAM in " << outputFilename << endl;
60     std::cerr << "FEATURE NOT YET IMPLEMENTED!" << std::endl;
61     
62     // clean & exit
63 //     reader.Close();
64 //     writer.Close();
65     return 0;
66 }
67
68 } // namespace BamTools
69
70 #endif // BAMTOOLS_SORT_H