X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Ftoolkit%2Fbamtools.cpp;h=4875a9a10bdb3ba1dbfdc9ac50d1f5ccfc0ebe07;hb=8c80d760637f8df39262683cd2570f0589423d36;hp=6c5c1f60337848a3929daba0d4c1d61258dda218;hpb=abb3c1abf0301481545a24445ad2bd4263fceb2b;p=bamtools.git diff --git a/src/toolkit/bamtools.cpp b/src/toolkit/bamtools.cpp index 6c5c1f6..4875a9a 100644 --- a/src/toolkit/bamtools.cpp +++ b/src/toolkit/bamtools.cpp @@ -3,20 +3,11 @@ // Marth Lab, Department of Biology, Boston College // All rights reserved. // --------------------------------------------------------------------------- -// Last modified: 25 October 2010 +// Last modified: 21 March 2011 (DB) // --------------------------------------------------------------------------- // Integrates a number of BamTools functionalities into a single executable. // *************************************************************************** -// stringify version information -#define BAMTOOLS_VER1_(x) #x -#define BAMTOOLS_VER_(x) BAMTOOLS_VER1_(x) -#define BAMTOOLS_VERSION BAMTOOLS_VER_(BT_VERSION) - -// includes -#include -#include -#include #include "bamtools_convert.h" #include "bamtools_count.h" #include "bamtools_coverage.h" @@ -25,11 +16,18 @@ #include "bamtools_index.h" #include "bamtools_merge.h" #include "bamtools_random.h" +#include "bamtools_revert.h" #include "bamtools_sort.h" #include "bamtools_split.h" #include "bamtools_stats.h" -using namespace std; +#include "bamtools_version.h" +#include +#include +#include +#include +#include using namespace BamTools; +using namespace std; // bamtools subtool names static const string CONVERT = "convert"; @@ -40,6 +38,7 @@ static const string HEADER = "header"; static const string INDEX = "index"; static const string MERGE = "merge"; static const string RANDOM = "random"; +static const string REVERT = "revert"; static const string SORT = "sort"; static const string SPLIT = "split"; static const string STATS = "stats"; @@ -78,6 +77,7 @@ AbstractTool* CreateTool(const string& arg) { if ( arg == INDEX ) return new IndexTool; if ( arg == MERGE ) return new MergeTool; if ( arg == RANDOM ) return new RandomTool; + if ( arg == REVERT ) return new RevertTool; if ( arg == SORT ) return new SortTool; if ( arg == SPLIT ) return new SplitTool; if ( arg == STATS ) return new StatsTool; @@ -112,24 +112,31 @@ int Help(int argc, char* argv[]) { cerr << "\tindex Generates index for BAM file" << endl; cerr << "\tmerge Merge multiple BAM files into single file" << endl; cerr << "\trandom Select random alignments from existing BAM file(s)" << endl; + cerr << "\trevert Removes duplicate marks and restores original base qualities" << endl; cerr << "\tsort Sorts the BAM file according to some criteria" << endl; cerr << "\tsplit Splits a BAM file on user-specified property, creating a new BAM output file for each value found" << endl; cerr << "\tstats Prints some basic statistics from input BAM file(s)" << endl; cerr << endl; cerr << "See 'bamtools help COMMAND' for more information on a specific command." << endl; cerr << endl; - return 0; + return EXIT_SUCCESS; } // print version info int Version(void) { + + stringstream versionStream(""); + versionStream << BAMTOOLS_VERSION_MAJOR << "." + << BAMTOOLS_VERSION_MINOR << "." + << BAMTOOLS_VERSION_BUILD; + cout << endl; - cout << "bamtools " << BAMTOOLS_VERSION << endl; + cout << "bamtools " << versionStream.str() << endl; cout << "Part of BamTools API and toolkit" << endl; cout << "Primary authors: Derek Barnett, Erik Garrison, Michael Stromberg" << endl; - cout << "(c) 2009-2010 Marth Lab, Biology Dept., Boston College" << endl; + cout << "(c) 2009-2011 Marth Lab, Biology Dept., Boston College" << endl; cout << endl; - return 0; + return EXIT_SUCCESS; } // toolkit entry point @@ -144,10 +151,10 @@ int main(int argc, char* argv[]) { // 'bamtools version', 'bamtools --version', or 'bamtools -v' if ( IsVersion(argv[1]) ) return Version(); - // determine desired sub-tool + // determine desired sub-tool, run if found AbstractTool* tool = CreateTool( argv[1] ); - - // if found, run tool... otherwise show help if ( tool ) return tool->Run(argc, argv); - else return Help(argc, argv); + + // no tool matched, show help + return Help(argc, argv); }