]> git.donarmstrong.com Git - bamtools.git/blob - bamtools_sort.cpp
further cleanup of duplicate @RG tag warning reporting
[bamtools.git] / bamtools_sort.cpp
1 // ***************************************************************************
2 // bamtools_sort.cpp (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 #include <iostream>
12 #include <string>
13
14 #include "bamtools_sort.h"
15 #include "bamtools_options.h"
16 #include "BamReader.h"
17
18 using namespace std;
19 using namespace BamTools;
20
21 // ---------------------------------------------
22 // SortSettings implementation
23
24 struct SortTool::SortSettings {
25
26     // flags
27     bool HasInputBamFilename;
28     bool HasOutputBamFilename;
29
30     // filenames
31     string InputBamFilename;
32     string OutputBamFilename;
33     
34     // constructor
35     SortSettings(void)
36         : HasInputBamFilename(false)
37         , HasOutputBamFilename(false)
38         , InputBamFilename(Options::StandardIn())
39         , OutputBamFilename(Options::StandardOut())
40     { }
41 };  
42
43 // ---------------------------------------------
44 // SortTool implementation
45
46 SortTool::SortTool(void)
47     : AbstractTool()
48     , m_settings(new SortSettings)
49 {
50     // set program details
51     Options::SetProgramInfo("bamtools sort", "sorts a BAM file", "[-in <filename>] [-out <filename>]");
52     
53     // set up options 
54     OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
55     Options::AddValueOption("-in",  "BAM filename", "the input BAM file",  "", m_settings->HasInputBamFilename,  m_settings->InputBamFilename,  IO_Opts, Options::StandardIn());
56     Options::AddValueOption("-out", "BAM filename", "the output BAM file", "", m_settings->HasOutputBamFilename, m_settings->OutputBamFilename, IO_Opts, Options::StandardOut());
57 }
58
59 SortTool::~SortTool(void) {
60     delete m_settings;
61     m_settings = 0;
62 }
63
64 int SortTool::Help(void) {
65     Options::DisplayHelp();
66     return 0;
67 }
68
69 int SortTool::Run(int argc, char* argv[]) {
70   
71     // parse command line arguments
72     Options::Parse(argc, argv, 1);
73     
74     // do sorting
75     
76     return 0;
77 }