From: derek Date: Mon, 13 Dec 2010 20:53:12 +0000 (-0500) Subject: Minor formatting cleanup X-Git-Url: https://git.donarmstrong.com/?p=bamtools.git;a=commitdiff_plain;h=81ffcac10d28190c191243226e3841d13746f89e Minor formatting cleanup --- diff --git a/src/api/BamIndex.cpp b/src/api/BamIndex.cpp index d0230b7..dbfe1c9 100644 --- a/src/api/BamIndex.cpp +++ b/src/api/BamIndex.cpp @@ -44,12 +44,12 @@ BamIndex* BamIndex::FromBamFilename(const std::string& bamFilename, const std::string bamtoolsIndexFilename = bamFilename + ".bti"; const bool bamtoolsIndexExists = BamTools::FileExists(bamtoolsIndexFilename); if ( (type == BamIndex::BAMTOOLS) && bamtoolsIndexExists ) - return new BamToolsIndex(bgzf, reader); + return new BamToolsIndex(bgzf, reader); const std::string standardIndexFilename = bamFilename + ".bai"; const bool standardIndexExists = BamTools::FileExists(standardIndexFilename); if ( (type == BamIndex::STANDARD) && standardIndexExists ) - return new BamStandardIndex(bgzf, reader); + return new BamStandardIndex(bgzf, reader); // ---------------------------------------------------- // preferred type could not be found, try other (non-preferred) types @@ -57,7 +57,7 @@ BamIndex* BamIndex::FromBamFilename(const std::string& bamFilename, if ( bamtoolsIndexExists ) return new BamToolsIndex(bgzf, reader); if ( standardIndexExists ) return new BamStandardIndex(bgzf, reader); - return 0; + return 0; } // returns index based on explicitly named index file (or 0 if not found) @@ -74,11 +74,11 @@ BamIndex* BamIndex::FromIndexFilename(const std::string& indexFilename, // if has bamtoolsIndexExtension if ( indexFilename.find(bamtoolsIndexExtension) == (indexFilename.length() - bamtoolsIndexExtension.length()) ) - return new BamToolsIndex(bgzf, reader); + return new BamToolsIndex(bgzf, reader); // if has standardIndexExtension if ( indexFilename.find(standardIndexExtension) == (indexFilename.length() - standardIndexExtension.length()) ) - return new BamStandardIndex(bgzf, reader); + return new BamStandardIndex(bgzf, reader); // otherwise, unsupported file type return 0; diff --git a/src/api/BamIndex.h b/src/api/BamIndex.h index b54aace..d09106a 100644 --- a/src/api/BamIndex.h +++ b/src/api/BamIndex.h @@ -63,7 +63,7 @@ class API_EXPORT BamIndex { virtual bool Jump(const BamTools::BamRegion& region, bool* hasAlignmentsInRegion) =0; // loads existing data from file into memory virtual bool Load(const std::string& filename); - // change the index caching behavior + // change the index caching behavior virtual void SetCacheMode(const BamIndexCacheMode mode); // writes in-memory index data out to file // N.B. - (this is the original BAM filename, method will modify it to use applicable extension) @@ -135,6 +135,7 @@ class API_EXPORT BamIndex { FILE* m_indexStream; + // friends friend class Internal::BamStandardIndex; friend class Internal::BamToolsIndex; }; diff --git a/src/api/BamReader.cpp b/src/api/BamReader.cpp index bd4bff9..c357b9d 100644 --- a/src/api/BamReader.cpp +++ b/src/api/BamReader.cpp @@ -38,9 +38,9 @@ bool BamReader::IsIndexLoaded(void) const { return HasIndex(); } bool BamReader::IsOpen(void) const { return d->mBGZF.IsOpen; } bool BamReader::Jump(int refID, int position) { return d->SetRegion( BamRegion(refID, position) ); } bool BamReader::Open(const std::string& filename, - const std::string& indexFilename, - const bool lookForIndex, - const bool preferStandardIndex) + const std::string& indexFilename, + const bool lookForIndex, + const bool preferStandardIndex) { return d->Open(filename, indexFilename, lookForIndex, preferStandardIndex); } diff --git a/src/api/BamReader.h b/src/api/BamReader.h index 7bdcbe7..c3452f6 100644 --- a/src/api/BamReader.h +++ b/src/api/BamReader.h @@ -44,9 +44,9 @@ class API_EXPORT BamReader { bool Jump(int refID, int position = 0); // opens BAM file (and optional BAM index file, if provided) // @lookForIndex - if no indexFilename provided, look in BAM file's directory for an existing index file - // default behavior is to skip index file search if no index filename given + // default behavior is to skip index file search if no index filename given // @preferStandardIndex - if true, give priority in index file searching to standard BAM index (*.bai) - // default behavior is to prefer the BamToolsIndex (*.bti) if both are available + // default behavior is to prefer the BamToolsIndex (*.bti) if both are available bool Open(const std::string& filename, const std::string& indexFilename = "", const bool lookForIndex = false, @@ -67,7 +67,7 @@ class API_EXPORT BamReader { // retrieves next available alignment core data (returns success/fail) // ** DOES NOT parse any character data (read name, bases, qualities, tag data) ** // useful for operations requiring ONLY aligner-related information - // (refId/position, alignment flags, CIGAR, mapQuality, etc) + // (refId/position, alignment flags, CIGAR, mapQuality, etc) bool GetNextAlignmentCore(BamAlignment& bAlignment); // ---------------------- @@ -93,36 +93,36 @@ class API_EXPORT BamReader { // default behavior is to create the BAM standard index (".bai") // set flag to false to create the BamTools-specific index (".bti") bool CreateIndex(bool useStandardIndex = true); - // returns whether index data is available for reading - // (e.g. if true, BamReader should be able to seek to a region) - bool HasIndex(void) const; - // change the index caching behavior - // default BamReader/Index mode is LimitedIndexCaching - // @mode - can be either FullIndexCaching, LimitedIndexCaching, - // or NoIndexCaching. See BamIndex.h for more details + // returns whether index data is available for reading + // (e.g. if true, BamReader should be able to seek to a region) + bool HasIndex(void) const; + // change the index caching behavior + // default BamReader/Index mode is LimitedIndexCaching + // @mode - can be either FullIndexCaching, LimitedIndexCaching, + // or NoIndexCaching. See BamIndex.h for more details void SetIndexCacheMode(const BamIndex::BamIndexCacheMode mode); // deprecated methods public: - // deprecated (but still available): prefer HasIndex() instead - // - // Deprecated purely for API semantic clarity - HasIndex() should be clearer - // than IsIndexLoaded() in light of the new caching modes that may clear the - // index data from memory, but leave the index file open for later random access - // seeks. - // - // For example, what would (IsIndexLoaded() == true) mean when cacheMode has been - // explicitly set to NoIndexCaching? This is confusing at best, misleading about - // current memory behavior at worst. - // - // returns whether index data is available - // (e.g. if true, BamReader should be able to seek to a region) + // deprecated (but still available): prefer HasIndex() instead + // + // Deprecated purely for API semantic clarity - HasIndex() should be clearer + // than IsIndexLoaded() in light of the new caching modes that may clear the + // index data from memory, but leave the index file open for later random access + // seeks. + // + // For example, what would (IsIndexLoaded() == true) mean when cacheMode has been + // explicitly set to NoIndexCaching? This is confusing at best, misleading about + // current memory behavior at worst. + // + // returns whether index data is available + // (e.g. if true, BamReader should be able to seek to a region) bool IsIndexLoaded(void) const; // private implementation private: - Internal::BamReaderPrivate* d; + Internal::BamReaderPrivate* d; }; } // namespace BamTools diff --git a/src/api/BamWriter.cpp b/src/api/BamWriter.cpp index 08ec3fe..e92d071 100644 --- a/src/api/BamWriter.cpp +++ b/src/api/BamWriter.cpp @@ -29,14 +29,14 @@ BamWriter::~BamWriter(void) { // closes the alignment archive void BamWriter::Close(void) { - d->Close(); + d->Close(); } // opens the alignment archive bool BamWriter::Open(const string& filename, - const string& samHeader, - const RefVector& referenceSequences, - bool isWriteUncompressed) + const string& samHeader, + const RefVector& referenceSequences, + bool isWriteUncompressed) { return d->Open(filename, samHeader, referenceSequences, isWriteUncompressed); } diff --git a/src/api/BamWriter.h b/src/api/BamWriter.h index 518c350..55f86f4 100644 --- a/src/api/BamWriter.h +++ b/src/api/BamWriter.h @@ -42,7 +42,7 @@ class API_EXPORT BamWriter { // private implementation private: - Internal::BamWriterPrivate* d; + Internal::BamWriterPrivate* d; }; } // namespace BamTools diff --git a/src/api/internal/BamReader_p.cpp b/src/api/internal/BamReader_p.cpp index b63a8e6..b5b1148 100644 --- a/src/api/internal/BamReader_p.cpp +++ b/src/api/internal/BamReader_p.cpp @@ -179,36 +179,36 @@ bool BamReaderPrivate::BuildCharData(BamAlignment& bAlignment) { switch (type) { - case('A') : - case('C') : - ++i; - break; - - case('S') : - SwapEndian_16p(&tagData[i]); - i += sizeof(uint16_t); - break; - - case('F') : - case('I') : - SwapEndian_32p(&tagData[i]); - i += sizeof(uint32_t); - break; - - case('D') : - SwapEndian_64p(&tagData[i]); - i += sizeof(uint64_t); - break; - - case('H') : - case('Z') : - while (tagData[i]) { ++i; } - ++i; // increment one more for null terminator - break; - - default : - fprintf(stderr, "ERROR: Invalid tag value type\n"); // shouldn't get here - exit(1); + case('A') : + case('C') : + ++i; + break; + + case('S') : + SwapEndian_16p(&tagData[i]); + i += sizeof(uint16_t); + break; + + case('F') : + case('I') : + SwapEndian_32p(&tagData[i]); + i += sizeof(uint32_t); + break; + + case('D') : + SwapEndian_64p(&tagData[i]); + i += sizeof(uint64_t); + break; + + case('H') : + case('Z') : + while (tagData[i]) { ++i; } + ++i; // increment one more for null terminator + break; + + default : + fprintf(stderr, "ERROR: Invalid tag value type\n"); // shouldn't get here + exit(1); } } } diff --git a/src/toolkit/bamtools.cpp b/src/toolkit/bamtools.cpp index c7491d7..2f91e2d 100644 --- a/src/toolkit/bamtools.cpp +++ b/src/toolkit/bamtools.cpp @@ -3,21 +3,12 @@ // Marth Lab, Department of Biology, Boston College // All rights reserved. // --------------------------------------------------------------------------- -// Last modified: 5 December 2010 +// Last modified: 13 December 2010 // --------------------------------------------------------------------------- // 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 #include "bamtools_convert.h" #include "bamtools_count.h" #include "bamtools_coverage.h" @@ -31,8 +22,14 @@ #include "bamtools_split.h" #include "bamtools_stats.h" #include "bamtools_version.h" -using namespace std; + +#include +#include +#include +#include + using namespace BamTools; +using namespace std; // bamtools subtool names static const string CONVERT = "convert"; @@ -117,6 +114,7 @@ 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; @@ -131,8 +129,8 @@ int Version(void) { stringstream versionStream(""); versionStream << BAMTOOLS_VERSION_MAJOR << "." - << BAMTOOLS_VERSION_MINOR << "." - << BAMTOOLS_VERSION_BUILD; + << BAMTOOLS_VERSION_MINOR << "." + << BAMTOOLS_VERSION_BUILD; cout << endl; cout << "bamtools " << versionStream.str() << endl; diff --git a/src/toolkit/bamtools_convert.cpp b/src/toolkit/bamtools_convert.cpp index 6e37e8f..5bd957b 100644 --- a/src/toolkit/bamtools_convert.cpp +++ b/src/toolkit/bamtools_convert.cpp @@ -132,7 +132,7 @@ struct ConvertTool::ConvertToolPrivate { void PrintJson(const BamAlignment& a); void PrintSam(const BamAlignment& a); void PrintWiggle(const BamAlignment& a); - void PrintYaml(const BamAlignment& a); + void PrintYaml(const BamAlignment& a); // special case - uses the PileupEngine bool RunPileupConversion(BamMultiReader* reader); @@ -249,7 +249,7 @@ bool ConvertTool::ConvertToolPrivate::Run(void) { // iterate through file, doing conversion BamAlignment a; - while ( reader.GetNextAlignment(a) ) + while ( reader.GetNextAlignment(a) ) (this->*pFunction)(a); // set flag for successful conversion @@ -657,15 +657,15 @@ void ConvertTool::ConvertToolPrivate::PrintYaml(const BamAlignment& a) { // write Cigar data const vector& cigarData = a.CigarData; if ( !cigarData.empty() ) { - m_out << " " << "Cigar: "; - vector::const_iterator cigarBegin = cigarData.begin(); - vector::const_iterator cigarIter = cigarBegin; - vector::const_iterator cigarEnd = cigarData.end(); - for ( ; cigarIter != cigarEnd; ++cigarIter ) { - const CigarOp& op = (*cigarIter); - m_out << op.Length << op.Type; - } - m_out << endl; + m_out << " " << "Cigar: "; + vector::const_iterator cigarBegin = cigarData.begin(); + vector::const_iterator cigarIter = cigarBegin; + vector::const_iterator cigarEnd = cigarData.end(); + for ( ; cigarIter != cigarEnd; ++cigarIter ) { + const CigarOp& op = (*cigarIter); + m_out << op.Length << op.Type; + } + m_out << endl; } } diff --git a/src/toolkit/bamtools_count.cpp b/src/toolkit/bamtools_count.cpp index b6184db..0a0620a 100644 --- a/src/toolkit/bamtools_count.cpp +++ b/src/toolkit/bamtools_count.cpp @@ -89,7 +89,7 @@ int CountTool::Run(int argc, char* argv[]) { // if no region specified, count entire file if ( !m_settings->HasRegion ) { - while ( reader.GetNextAlignmentCore(al) ) + while ( reader.GetNextAlignmentCore(al) ) ++alignmentCount; } diff --git a/src/toolkit/bamtools_filter.cpp b/src/toolkit/bamtools_filter.cpp index 2b8b45e..8a816c3 100644 --- a/src/toolkit/bamtools_filter.cpp +++ b/src/toolkit/bamtools_filter.cpp @@ -74,7 +74,7 @@ struct BamAlignmentChecker { const PropertyFilterValue& valueFilter = (*propertyIter).second; if ( propertyName == ALIGNMENTFLAG_PROPERTY ) keepAlignment &= valueFilter.check(al.AlignmentFlag); - else if ( propertyName == CIGAR_PROPERTY ) { + else if ( propertyName == CIGAR_PROPERTY ) { stringstream cigarSs; const vector& cigarData = al.CigarData; if ( !cigarData.empty() ) { @@ -129,93 +129,93 @@ struct BamAlignmentChecker { bool checkAlignmentTag(const PropertyFilterValue& valueFilter, const BamAlignment& al) { - // ensure filter contains string data - Variant entireTagFilter = valueFilter.Value; - if ( !entireTagFilter.is_type() ) return false; - - // localize string from variant - const string& entireTagFilterString = entireTagFilter.get(); - - // ensure we have at least "XX:x" - if ( entireTagFilterString.length() < 4 ) return false; - - // get tagName & lookup in alignment - // if found, set tagType to tag type character - // if not found, return false - const string& tagName = entireTagFilterString.substr(0,2); - char tagType = '\0'; - if ( !al.GetTagType(tagName, tagType) ) return false; - - // remove tagName & ":" from beginning tagFilter - string tagFilterString = entireTagFilterString.substr(3); - - // switch on tag type to set tag query value & parse filter token - int32_t intFilterValue, intQueryValue; - uint32_t uintFilterValue, uintQueryValue; - float realFilterValue, realQueryValue; - string stringFilterValue, stringQueryValue; - - PropertyFilterValue tagFilter; - PropertyFilterValue::ValueCompareType compareType; - bool keepAlignment = false; - switch (tagType) { - - // signed int tag type - case 'c' : - case 's' : + // ensure filter contains string data + Variant entireTagFilter = valueFilter.Value; + if ( !entireTagFilter.is_type() ) return false; + + // localize string from variant + const string& entireTagFilterString = entireTagFilter.get(); + + // ensure we have at least "XX:x" + if ( entireTagFilterString.length() < 4 ) return false; + + // get tagName & lookup in alignment + // if found, set tagType to tag type character + // if not found, return false + const string& tagName = entireTagFilterString.substr(0,2); + char tagType = '\0'; + if ( !al.GetTagType(tagName, tagType) ) return false; + + // remove tagName & ":" from beginning tagFilter + string tagFilterString = entireTagFilterString.substr(3); + + // switch on tag type to set tag query value & parse filter token + int32_t intFilterValue, intQueryValue; + uint32_t uintFilterValue, uintQueryValue; + float realFilterValue, realQueryValue; + string stringFilterValue, stringQueryValue; + + PropertyFilterValue tagFilter; + PropertyFilterValue::ValueCompareType compareType; + bool keepAlignment = false; + switch (tagType) { + + // signed int tag type + case 'c' : + case 's' : case 'i' : - if ( al.GetTag(tagName, intQueryValue) ) { - if ( FilterEngine::parseToken(tagFilterString, intFilterValue, compareType) ) { - tagFilter.Value = intFilterValue; - tagFilter.Type = compareType; - keepAlignment = tagFilter.check(intQueryValue); - } - } - break; - - // unsigned int tag type + if ( al.GetTag(tagName, intQueryValue) ) { + if ( FilterEngine::parseToken(tagFilterString, intFilterValue, compareType) ) { + tagFilter.Value = intFilterValue; + tagFilter.Type = compareType; + keepAlignment = tagFilter.check(intQueryValue); + } + } + break; + + // unsigned int tag type case 'C' : case 'S' : - case 'I' : - if ( al.GetTag(tagName, uintQueryValue) ) { - if ( FilterEngine::parseToken(tagFilterString, uintFilterValue, compareType) ) { - tagFilter.Value = uintFilterValue; - tagFilter.Type = compareType; - keepAlignment = tagFilter.check(uintQueryValue); - } - } - break; - - // 'real' tag type + case 'I' : + if ( al.GetTag(tagName, uintQueryValue) ) { + if ( FilterEngine::parseToken(tagFilterString, uintFilterValue, compareType) ) { + tagFilter.Value = uintFilterValue; + tagFilter.Type = compareType; + keepAlignment = tagFilter.check(uintQueryValue); + } + } + break; + + // 'real' tag type case 'f' : - if ( al.GetTag(tagName, realQueryValue) ) { - if ( FilterEngine::parseToken(tagFilterString, realFilterValue, compareType) ) { - tagFilter.Value = realFilterValue; - tagFilter.Type = compareType; - keepAlignment = tagFilter.check(realQueryValue); - } - } + if ( al.GetTag(tagName, realQueryValue) ) { + if ( FilterEngine::parseToken(tagFilterString, realFilterValue, compareType) ) { + tagFilter.Value = realFilterValue; + tagFilter.Type = compareType; + keepAlignment = tagFilter.check(realQueryValue); + } + } break; - - // string tag type + + // string tag type case 'A': case 'Z': - case 'H': + case 'H': if ( al.GetTag(tagName, stringQueryValue) ) { - if ( FilterEngine::parseToken(tagFilterString, stringFilterValue, compareType) ) { - tagFilter.Value = stringFilterValue; - tagFilter.Type = compareType; - keepAlignment = tagFilter.check(stringQueryValue); - } - } - break; - - // unknown tag type - default : - keepAlignment = false; - } - - return keepAlignment; + if ( FilterEngine::parseToken(tagFilterString, stringFilterValue, compareType) ) { + tagFilter.Value = stringFilterValue; + tagFilter.Type = compareType; + keepAlignment = tagFilter.check(stringQueryValue); + } + } + break; + + // unknown tag type + default : + keepAlignment = false; + } + + return keepAlignment; } }; @@ -774,12 +774,12 @@ bool FilterTool::FilterToolPrivate::Run(void) { // attempt to re-open reader with index files reader.Close(); - bool openedOK = reader.Open(m_settings->InputFiles, true, false ); + bool openedOK = reader.Open(m_settings->InputFiles, true, false ); // if error if ( !openedOK ) { cerr << "ERROR: Could not open input BAM file(s)... Aborting." << endl; - return false; + return false; } // if index data available, we can use SetRegion @@ -789,19 +789,19 @@ bool FilterTool::FilterToolPrivate::Run(void) { if ( !reader.SetRegion(region.LeftRefID, region.LeftPosition, region.RightRefID, region.RightPosition) ) { cerr << "ERROR: Region requested, but could not set BamReader region to REGION: " << m_settings->Region << " Aborting." << endl; reader.Close(); - return false; + return false; } // everything checks out, just iterate through specified region, filtering alignments - while ( reader.GetNextAlignment(al) ) + while ( reader.GetNextAlignment(al) ) if ( CheckAlignment(al) ) writer.SaveAlignment(al); - } + } // no index data available, we have to iterate through until we // find overlapping alignments else { - while ( reader.GetNextAlignment(al) ) { + while ( reader.GetNextAlignment(al) ) { if ( (al.RefID >= region.LeftRefID) && ((al.Position + al.Length) >= region.LeftPosition) && (al.RefID <= region.RightRefID) && ( al.Position <= region.RightPosition) ) { @@ -817,7 +817,7 @@ bool FilterTool::FilterToolPrivate::Run(void) { cerr << "ERROR: Could not parse REGION - " << m_settings->Region << endl; cerr << "Be sure REGION is in valid format (see README) and that coordinates are valid for selected references" << endl; reader.Close(); - return false; + return false; } } diff --git a/src/toolkit/bamtools_revert.cpp b/src/toolkit/bamtools_revert.cpp index 0a6c08a..2c1ae96 100644 --- a/src/toolkit/bamtools_revert.cpp +++ b/src/toolkit/bamtools_revert.cpp @@ -3,7 +3,7 @@ // Marth Lab, Department of Biology, Boston College // All rights reserved. // --------------------------------------------------------------------------- -// Last modified: 5 December 2010 +// Last modified: 13 December 2010 // --------------------------------------------------------------------------- // Prints general alignment statistics for BAM file(s). // *************************************************************************** @@ -37,12 +37,12 @@ struct RevertTool::RevertSettings { // constructor RevertSettings(void) : HasInput(false) - , HasOutput(false) - , IsForceCompression(false) - , IsKeepDuplicateFlag(false) - , IsKeepQualities(false) - , InputFilename(Options::StandardIn()) - , OutputFilename(Options::StandardOut()) + , HasOutput(false) + , IsForceCompression(false) + , IsKeepDuplicateFlag(false) + , IsKeepQualities(false) + , InputFilename(Options::StandardIn()) + , OutputFilename(Options::StandardOut()) { } }; @@ -62,12 +62,12 @@ struct RevertTool::RevertToolPrivate { // internal methods private: - void RevertAlignment(BamAlignment& al); + void RevertAlignment(BamAlignment& al); // data members private: RevertTool::RevertSettings* m_settings; - string m_OQ; + string m_OQ; }; RevertTool::RevertToolPrivate::RevertToolPrivate(RevertTool::RevertSettings* settings) @@ -84,16 +84,16 @@ void RevertTool::RevertToolPrivate::RevertAlignment(BamAlignment& al) { // replace Qualities with OQ, if requested if ( !m_settings->IsKeepQualities ) { - string originalQualities; - if ( al.GetTag(m_OQ, originalQualities) ) { - al.Qualities = originalQualities; - al.RemoveTag(m_OQ); - } + string originalQualities; + if ( al.GetTag(m_OQ, originalQualities) ) { + al.Qualities = originalQualities; + al.RemoveTag(m_OQ); + } } // clear duplicate flag, if requested if ( !m_settings->IsKeepDuplicateFlag ) - al.SetIsDuplicate(false); + al.SetIsDuplicate(false); } bool RevertTool::RevertToolPrivate::Run(void) { @@ -101,7 +101,7 @@ bool RevertTool::RevertToolPrivate::Run(void) { // opens the BAM file without checking for indexes BamReader reader; if ( !reader.Open(m_settings->InputFilename) ) { - cerr << "Could not open input BAM file... quitting." << endl; + cerr << "Could not open input BAM file... quitting." << endl; return false; } @@ -120,7 +120,7 @@ bool RevertTool::RevertToolPrivate::Run(void) { // plow through file, reverting alignments BamAlignment al; while ( reader.GetNextAlignment(al) ) { - RevertAlignment(al); + RevertAlignment(al); writer.SaveAlignment(al); } diff --git a/src/toolkit/bamtools_sort.cpp b/src/toolkit/bamtools_sort.cpp index 2f463ba..e518db3 100644 --- a/src/toolkit/bamtools_sort.cpp +++ b/src/toolkit/bamtools_sort.cpp @@ -266,9 +266,8 @@ bool SortTool::SortToolPrivate::MergeSortedRuns(void) { // while data available in temp files BamAlignment al; - while ( multiReader.GetNextAlignmentCore(al) ) { + while ( multiReader.GetNextAlignmentCore(al) ) mergedWriter.SaveAlignment(al); - } // close readers multiReader.Close(); diff --git a/src/toolkit/bamtools_split.cpp b/src/toolkit/bamtools_split.cpp index 62dc104..748127f 100644 --- a/src/toolkit/bamtools_split.cpp +++ b/src/toolkit/bamtools_split.cpp @@ -24,37 +24,37 @@ using namespace BamTools; namespace BamTools { - // string constants - static const string SPLIT_MAPPED_TOKEN = ".MAPPED"; - static const string SPLIT_UNMAPPED_TOKEN = ".UNMAPPED"; - static const string SPLIT_PAIRED_TOKEN = ".PAIRED_END"; - static const string SPLIT_SINGLE_TOKEN = ".SINGLE_END"; - static const string SPLIT_REFERENCE_TOKEN = ".REF_"; +// string constants +static const string SPLIT_MAPPED_TOKEN = ".MAPPED"; +static const string SPLIT_UNMAPPED_TOKEN = ".UNMAPPED"; +static const string SPLIT_PAIRED_TOKEN = ".PAIRED_END"; +static const string SPLIT_SINGLE_TOKEN = ".SINGLE_END"; +static const string SPLIT_REFERENCE_TOKEN = ".REF_"; - string GetTimestampString(void) { - - // get human readable timestamp - time_t currentTime; - time(¤tTime); - stringstream timeStream(""); - timeStream << ctime(¤tTime); - - // convert whitespace to '_' - string timeString = timeStream.str(); - size_t found = timeString.find(" "); - while (found != string::npos) { - timeString.replace(found, 1, "_"); - found = timeString.find(" ", found+1); - } - return timeString; - } - - // remove copy of filename without extension - // (so /path/to/file.txt becomes /path/to/file ) - string RemoveFilenameExtension(const string& filename) { - size_t found = filename.rfind("."); - return filename.substr(0, found); +string GetTimestampString(void) { + + // get human readable timestamp + time_t currentTime; + time(¤tTime); + stringstream timeStream(""); + timeStream << ctime(¤tTime); + + // convert whitespace to '_' + string timeString = timeStream.str(); + size_t found = timeString.find(" "); + while (found != string::npos) { + timeString.replace(found, 1, "_"); + found = timeString.find(" ", found+1); } + return timeString; +} + +// remove copy of filename without extension +// (so /path/to/file.txt becomes /path/to/file ) +string RemoveFilenameExtension(const string& filename) { + size_t found = filename.rfind("."); + return filename.substr(0, found); +} } // namespace BamTools