+// ***************************************************************************
+// 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 <cstdio>
#include <cstdlib>
#include <algorithm>
// 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;
return false;
// store offset & return success
-/* cerr << "BTI::GetOffsets() : calculated offset = " << previousOffset << endl;*/
offsets.push_back(previousOffset);
return true;
}
+// ***************************************************************************
+// 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
+// ***************************************************************************
+// 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 <cstdio>
#include <cstdlib>
#include <cstring>
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;
}
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;
}
d = 0;
}
-bool Fasta::Close(void) {
+bool Fasta::Close(void) {
return d->Close();
}
bool Fasta::Open(const string& filename, const string& indexFilename) {
return d->Open(filename, indexFilename);
-}
\ No newline at end of file
+}
+// ***************************************************************************
+// 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
+// ***************************************************************************
+// 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 <vector>
#include "BamMultiReader.h"
#include "bamtools_pileup.h"
+// ***************************************************************************
+// 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