X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Ftoolkit%2Fbamtools_header.cpp;h=aad413f29df916ec0edade03eac4206770e0bac2;hb=8c80d760637f8df39262683cd2570f0589423d36;hp=180ef9e8f5f74cae23597eb46491f6dd73fe0248;hpb=577b6032aa3d85616047c8aba6061dd8dad20cfc;p=bamtools.git diff --git a/src/toolkit/bamtools_header.cpp b/src/toolkit/bamtools_header.cpp index 180ef9e..aad413f 100644 --- a/src/toolkit/bamtools_header.cpp +++ b/src/toolkit/bamtools_header.cpp @@ -3,21 +3,22 @@ // Marth Lab, Department of Biology, Boston College // All rights reserved. // --------------------------------------------------------------------------- -// Last modified: 1 June 2010 +// Last modified: 21 March 2011 // --------------------------------------------------------------------------- // Prints the SAM-style header from a single BAM file ( or merged header from // multiple BAM files) to stdout // *************************************************************************** +#include "bamtools_header.h" + +#include +#include +using namespace BamTools; + #include #include #include -#include "bamtools_header.h" -#include "bamtools_options.h" -#include "BamReader.h" -#include "BamMultiReader.h" using namespace std; -using namespace BamTools; // --------------------------------------------- // HeaderSettings implementation @@ -70,12 +71,17 @@ int HeaderTool::Run(int argc, char* argv[]) { if ( !m_settings->HasInputBamFilename ) m_settings->InputFiles.push_back(Options::StandardIn()); - // if able to open files, dump (merged) header contents to stdout + // attemp to open BAM files BamMultiReader reader; - if ( reader.Open(m_settings->InputFiles, false) ) - cout << reader.GetHeaderText() << endl; - + if ( !reader.Open(m_settings->InputFiles) ) { + cerr << "bamtools header ERROR: could not open BAM file(s) for reading... Aborting." << endl; + return 1; + } + + // dump (merged) header contents to stdout + cout << reader.GetHeaderText() << endl; + // clean up & exit reader.Close(); return 0; -} \ No newline at end of file +}