1 // ***************************************************************************
2 // bamtools_dump.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 // Dumps alignment summaries out to stdout.
10 // ** This should probably go the way of the dodo soon? bamtools sam makes this
11 // obsolete and probably worthless.
13 // ***************************************************************************
15 #ifndef BAMTOOLS_DUMP_H
16 #define BAMTOOLS_DUMP_H
22 #include "BamMultiReader.h"
23 // #include "GetOpt.h"
24 #include "bamtools_getopt.h"
28 int BamDumpHelp(void) {
29 std::cerr << std::endl;
30 std::cerr << "usage:\tbamtools dump [BAM file1] [BAM file2] [BAM file3]..." << std::endl;
31 std::cerr << "\t[BAM file]\tInput file(s) to dump alignment summaries from [default=stdin]" << std::endl;
32 std::cerr << std::endl;
36 // Spit out basic BamAlignment data
37 void PrintAlignment(const BamTools::BamAlignment& alignment) {
38 std::cout << "---------------------------------" << std::endl;
39 std::cout << "Name: " << alignment.Name << std::endl;
40 std::cout << "Aligned to: " << alignment.RefID;
41 std::cout << ":" << alignment.Position << std::endl;
42 std::cout << std::endl;
45 int RunBamDump(int argc, char* argv[]) {
47 // else parse command line for args
48 GetOpt options(argc, argv, 1);
50 std::vector<std::string> inputFilenames;
51 options.addVariableLengthOption("in", &inputFilenames);
53 if ( !options.parse() ) return BamDumpHelp();
54 if ( inputFilenames.empty() ) { inputFilenames.push_back("stdin"); }
57 BamMultiReader reader;
58 reader.Open(inputFilenames, false);
60 // dump alignment summaries to stdout
61 BamAlignment bAlignment;
62 while (reader.GetNextAlignment(bAlignment)) {
63 PrintAlignment(bAlignment);
71 } // namespace BamTools
73 #endif // BAMTOOLS_DUMP_H