X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Ftoolkit%2Fbamtools_index.cpp;h=6e5a86df6b65329e47283a754835d4de55544a30;hb=8c80d760637f8df39262683cd2570f0589423d36;hp=90339c4fe3b4de9ccb6f59a634f2c23831f426e2;hpb=577b6032aa3d85616047c8aba6061dd8dad20cfc;p=bamtools.git diff --git a/src/toolkit/bamtools_index.cpp b/src/toolkit/bamtools_index.cpp index 90339c4..6e5a86d 100644 --- a/src/toolkit/bamtools_index.cpp +++ b/src/toolkit/bamtools_index.cpp @@ -3,21 +3,21 @@ // Marth Lab, Department of Biology, Boston College // All rights reserved. // --------------------------------------------------------------------------- -// Last modified: 2 September 2010 +// Last modified: 21 March 2011 // --------------------------------------------------------------------------- -// Creates a BAM index (".bai") file for the provided BAM file. +// Creates a BAM index file. // *************************************************************************** -#include -#include - #include "bamtools_index.h" -#include "bamtools_options.h" -#include "BamReader.h" -using namespace std; +#include +#include using namespace BamTools; +#include +#include +using namespace std; + // --------------------------------------------- // IndexSettings implementation @@ -71,11 +71,15 @@ int IndexTool::Run(int argc, char* argv[]) { // open our BAM reader BamReader reader; - reader.Open(m_settings->InputBamFilename); + if ( !reader.Open(m_settings->InputBamFilename) ) { + cerr << "bamtools index ERROR: could not open BAM file: " << m_settings->InputBamFilename << endl; + return 1; + } // create index for BAM file - bool useDefaultIndex = !m_settings->IsUsingBamtoolsIndex; - reader.CreateIndex(useDefaultIndex); + const BamIndex::IndexType type = ( m_settings->IsUsingBamtoolsIndex ? BamIndex::BAMTOOLS + : BamIndex::STANDARD ); + reader.CreateIndex(type); // clean & exit reader.Close();