]> git.donarmstrong.com Git - bamtools.git/blobdiff - src/toolkit/bamtools_header.cpp
Major update to BamTools version 1.0
[bamtools.git] / src / toolkit / bamtools_header.cpp
index b75f9a0e558b192cdac42350552881158efdc3c9..aad413f29df916ec0edade03eac4206770e0bac2 100644 (file)
@@ -3,23 +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 <api/BamMultiReader.h>
+#include <utils/bamtools_options.h>
+using namespace BamTools;
+
 #include <iostream>
 #include <string>
 #include <vector>
-
-#include "bamtools_header.h"
-#include "bamtools_options.h"
-#include "BamReader.h"
-#include "BamMultiReader.h"
-
 using namespace std;
-using namespace BamTools; 
   
 // ---------------------------------------------
 // HeaderSettings implementation
@@ -46,7 +45,7 @@ HeaderTool::HeaderTool(void)
     , m_settings(new HeaderSettings)
 {
     // set program details
-    Options::SetProgramInfo("bamtools header", "prints header from BAM file(s)", "-in <filename> [-in <filename> ... ] ");
+    Options::SetProgramInfo("bamtools header", "prints header from BAM file(s)", "[-in <filename> -in <filename> ...] ");
     
     // set up options 
     OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
@@ -72,14 +71,17 @@ int HeaderTool::Run(int argc, char* argv[]) {
     if ( !m_settings->HasInputBamFilename ) 
         m_settings->InputFiles.push_back(Options::StandardIn());
     
-    // open files
+    // attemp to open BAM files
     BamMultiReader reader;
-    if ( reader.Open(m_settings->InputFiles, false) ) {      
-        // dump header contents to stdout
-        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
+}