From f68dccd9031c84f73b9754c1fbced63bd8551f6f Mon Sep 17 00:00:00 2001 From: Derek Date: Tue, 13 Jul 2010 12:00:42 -0400 Subject: [PATCH] Purely cosmetic udpate. Cleaned up some commented blocks, added file header information (author, description, etc) --- BamIndex.cpp | 22 ++++++++++++---------- BamIndex.h | 12 ++++++++++++ bamtools_fasta.cpp | 34 +++++++++++++++++++++++++++++----- bamtools_fasta.h | 10 ++++++++++ bamtools_pileup.cpp | 13 +++++++++++++ bamtools_pileup.h | 13 +++++++++++++ 6 files changed, 89 insertions(+), 15 deletions(-) diff --git a/BamIndex.cpp b/BamIndex.cpp index 282326f..787995b 100644 --- a/BamIndex.cpp +++ b/BamIndex.cpp @@ -1,3 +1,15 @@ +// *************************************************************************** +// BamIndex.cpp (c) 2009 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 13 July 2010 (DB) +// --------------------------------------------------------------------------- +// Provides index functionality - both for the default (standardized) BAM +// index format (.bai) as well as a BamTools-specific (nonstandard) index +// format (.bti). +// *************************************************************************** + #include #include #include @@ -747,15 +759,6 @@ bool BamToolsIndex::Build(void) { // if block is full, get offset for next block, reset currentBlockCount if ( currentBlockCount == d->m_blockSize ) { -// cerr << "-------------------------------" << endl; -// cerr << "BlockCount = " << currentBlockCount << endl; -// cerr << endl; -// cerr << "Storing entry: " << endl; -// cerr << "\trefID : " << blockStartId << endl; -// cerr << "\tpos : " << blockStartPosition << endl; -// cerr << "\toffset : " << blockStartOffset << endl; -// - d->m_indexData.push_back( BamToolsIndexEntry(blockStartOffset, blockStartId, blockStartPosition) ); blockStartOffset = m_BGZF->Tell(); currentBlockCount = 0; @@ -796,7 +799,6 @@ bool BamToolsIndex::GetOffsets(const BamRegion& region, const bool isRightBoundS return false; // store offset & return success -/* cerr << "BTI::GetOffsets() : calculated offset = " << previousOffset << endl;*/ offsets.push_back(previousOffset); return true; } diff --git a/BamIndex.h b/BamIndex.h index 99dd095..aeecefb 100644 --- a/BamIndex.h +++ b/BamIndex.h @@ -1,3 +1,15 @@ +// *************************************************************************** +// BamIndex.h (c) 2009 Derek Barnett +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 13 July 2010 (DB) +// --------------------------------------------------------------------------- +// Provides index functionality - both for the default (standardized) BAM +// index format (.bai) as well as a BamTools-specific (nonstandard) index +// format (.bti). +// *************************************************************************** + #ifndef BAM_INDEX_H #define BAM_INDEX_H diff --git a/bamtools_fasta.cpp b/bamtools_fasta.cpp index 74cde03..7e94a52 100644 --- a/bamtools_fasta.cpp +++ b/bamtools_fasta.cpp @@ -1,3 +1,13 @@ +// *************************************************************************** +// bamtools_fasta.cpp (c) 2010 Derek Barnett, Erik Garrison +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 13 July 2010 +// --------------------------------------------------------------------------- +// Provides FASTA reading/indexing functionality. +// *************************************************************************** + #include #include #include @@ -157,12 +167,26 @@ bool Fasta::FastaPrivate::CreateIndex(const string& indexFilename) { string sequence = ""; while ( GetNextHeader(header) ) { + // --------------------------- // build index entry data FastaIndexData data; - GetNameFromHeader(header, data.Name); + + // store file offset of beginning of DNA sequence (after header) data.Offset = ftello(Stream); - GetNextSequence(sequence); + // parse header, store sequence name in data.Name + if ( !GetNameFromHeader(header, data.Name) ) { + cerr << "FASTA error : could not parse read name from FASTA header" << endl; + return false; + } + + // retrieve FASTA sequence + if ( !GetNextSequence(sequence) ) { + cerr << "FASTA error : could not read in next sequence from FASTA file" << endl; + return false; + } + + // store sequence length & line/byte lengths data.Length = sequence.length(); data.LineLength = lineLength; data.ByteLength = byteLength; @@ -305,7 +329,7 @@ bool Fasta::FastaPrivate::GetNameFromHeader(const string& header, string& name) } if ( start == stop ) { - cout << "FASTA error : could not parse read name from FASTA header." << endl; + cerr << "FASTA error : could not parse read name from FASTA header" << endl; return false; } @@ -582,7 +606,7 @@ Fasta::~Fasta(void) { d = 0; } -bool Fasta::Close(void) { +bool Fasta::Close(void) { return d->Close(); } @@ -600,4 +624,4 @@ bool Fasta::GetSequence(const int& refId, const int& start, const int& stop, str bool Fasta::Open(const string& filename, const string& indexFilename) { return d->Open(filename, indexFilename); -} \ No newline at end of file +} diff --git a/bamtools_fasta.h b/bamtools_fasta.h index 43c262b..f64a087 100644 --- a/bamtools_fasta.h +++ b/bamtools_fasta.h @@ -1,3 +1,13 @@ +// *************************************************************************** +// bamtools_fasta.h (c) 2010 Derek Barnett, Erik Garrison +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 13 July 2010 +// --------------------------------------------------------------------------- +// Provides FASTA reading/indexing functionality. +// *************************************************************************** + #ifndef BAMTOOLS_FASTA_H #define BAMTOOLS_FASTA_H diff --git a/bamtools_pileup.cpp b/bamtools_pileup.cpp index 5b84ead..1862289 100644 --- a/bamtools_pileup.cpp +++ b/bamtools_pileup.cpp @@ -1,3 +1,16 @@ +// *************************************************************************** +// bamtools_pileup.cpp (c) 2010 Derek Barnett, Erik Garrison +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 13 July 2010 +// --------------------------------------------------------------------------- +// Provides pileup conversion functionality. +// +// The 'assembly' aspect of pileup makes this more complicated than the +// simpler one-to-one conversion methods for other formats. +// *************************************************************************** + #include #include "BamMultiReader.h" #include "bamtools_pileup.h" diff --git a/bamtools_pileup.h b/bamtools_pileup.h index b28059c..3ffb030 100644 --- a/bamtools_pileup.h +++ b/bamtools_pileup.h @@ -1,3 +1,16 @@ +// *************************************************************************** +// bamtools_pileup.h (c) 2010 Derek Barnett, Erik Garrison +// Marth Lab, Department of Biology, Boston College +// All rights reserved. +// --------------------------------------------------------------------------- +// Last modified: 13 July 2010 +// --------------------------------------------------------------------------- +// Provides pileup conversion functionality. +// +// The 'assembly' aspect of pileup makes this more complicated than the +// simpler one-to-one conversion methods for other formats. +// *************************************************************************** + #ifndef BAMTOOLS_PILEUP_H #define BAMTOOLS_PILEUP_H -- 2.39.5