# set BamTools version information
set (BamTools_VERSION_MAJOR 2)
set (BamTools_VERSION_MINOR 0)
-set (BamTools_VERSION_BUILD 2)
+set (BamTools_VERSION_BUILD 3)
# set our library and executable destination dirs
set (EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
# This could be handy for archiving the generated documentation or
# if some version control system is used.
-PROJECT_NUMBER = 2.0.2
+PROJECT_NUMBER = 2.0.3
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# create main BamTools API shared library
add_library( BamTools SHARED ${BamToolsAPISources} )
-set_target_properties( BamTools PROPERTIES SOVERSION "2.0.2" )
+set_target_properties( BamTools PROPERTIES SOVERSION "2.0.3" )
set_target_properties( BamTools PROPERTIES OUTPUT_NAME "bamtools" )
# create main BamTools API static library
// SamReadGroupDictionary.cpp (c) 2010 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 12 October 2011 (DB)
+// Last modified: 14 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides methods for operating on a collection of SamReadGroup entries.
// ***************************************************************************
Provides methods for operating on a collection of SamReadGroup entries.
*/
-/*! \typedef BamTools::SamReadGroupIterator
- \brief mutable iterator for SamReadGroupDictionary data
-
- \note This iterator, dereferenced, actually points to a
- std::pair<std::string, SamReadGroup>, NOT a "plain old" SamReadGroup.
- To retrieve the read group object:
-
- \code
- SamReadGroupIterator iter;
- SamReadGroup& rg = (*iter).second // OR iter->second;
- \endcode
-*/
-
-/*! \typedef BamTools::SamReadGroupConstIterator
- \brief const iterator for SamReadGroupDictionary data
-
- \note This iterator, dereferenced, actually points to a
- std::pair<std::string, SamReadGroup>, NOT a "plain old" SamReadGroup.
- To retrieve the read group object:
-
- \code
- SamReadGroupConstIterator iter;
- const SamReadGroup& sq = (*iter).second // OR iter->second;
- \endcode
-*/
-
/*! \fn SamReadGroupDictionary::SamReadGroupDictionary(void)
\brief constructor
*/
*/
SamReadGroupDictionary::SamReadGroupDictionary(const SamReadGroupDictionary& other)
: m_data(other.m_data)
+ , m_lookupData(other.m_lookupData)
{ }
/*! \fn SamReadGroupDictionary::~SamReadGroupDictionary(void)
\param[in] readGroup entry to be added
*/
void SamReadGroupDictionary::Add(const SamReadGroup& readGroup) {
- if ( IsEmpty() || !Contains(readGroup) )
- m_data[readGroup.ID] = readGroup;
+ if ( IsEmpty() || !Contains(readGroup) ) {
+ m_data.push_back(readGroup);
+ m_lookupData[readGroup.ID] = readGroup;
+ }
}
/*! \fn void SamReadGroupDictionary::Add(const std::string& readGroupId)
SamReadGroupConstIterator rgIter = readGroups.ConstBegin();
SamReadGroupConstIterator rgEnd = readGroups.ConstEnd();
for ( ; rgIter != rgEnd; ++rgIter )
- Add(rgIter->second);
+ Add(*rgIter);
}
/*! \fn void SamReadGroupDictionary::Add(const std::vector<SamReadGroup>& readGroups)
*/
void SamReadGroupDictionary::Clear(void) {
m_data.clear();
+ m_lookupData.clear();
}
/*! \fn SamReadGroupConstIterator SamReadGroupDictionary::ConstBegin(void) const
\return \c true if dictionary contains a read group with this ID
*/
bool SamReadGroupDictionary::Contains(const std::string& readGroupId) const {
- return ( m_data.find(readGroupId) != m_data.end() );
+ return ( m_lookupData.find(readGroupId) != m_lookupData.end() );
}
/*! \fn bool SamReadGroupDictionary::Contains(const SamReadGroup& readGroup) const
\sa Remove()
*/
void SamReadGroupDictionary::Remove(const std::string& readGroupId) {
- m_data.erase(readGroupId);
+
+ SamReadGroupIterator rgIter = Begin();
+ SamReadGroupIterator rgEnd = End();
+ for ( size_t i = 0 ; rgIter != rgEnd; ++rgIter, ++i ) {
+ SamReadGroup& rg = (*rgIter);
+ if( rg.ID == readGroupId ) {
+ m_data.erase( Begin() + i );
+ }
+ }
+
+ m_lookupData.erase(readGroupId);
}
/*! \fn void SamReadGroupDictionary::Remove(const std::vector<SamReadGroup>& readGroups)
\return a modifiable reference to the SamReadGroup associated with the ID
*/
SamReadGroup& SamReadGroupDictionary::operator[](const std::string& readGroupId) {
- if ( !Contains(readGroupId) )
- m_data[readGroupId] = SamReadGroup(readGroupId);
- return m_data[readGroupId];
+ if ( !Contains(readGroupId) ) {
+ SamReadGroup rg(readGroupId);
+ m_data.push_back(rg);
+ m_lookupData[readGroupId] = rg;
+ }
+ return m_lookupData[readGroupId];
}
// SamReadGroupDictionary.h (c) 2010 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 12 October 2011 (DB)
+// Last modified: 14 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides methods for operating on a collection of SamReadGroup entries.
// ***************************************************************************
namespace BamTools {
-typedef std::map<std::string, SamReadGroup> SamReadGroupContainer;
+typedef std::vector<SamReadGroup> SamReadGroupContainer;
typedef SamReadGroupContainer::iterator SamReadGroupIterator;
typedef SamReadGroupContainer::const_iterator SamReadGroupConstIterator;
// data members
private:
SamReadGroupContainer m_data;
+ std::map<std::string, SamReadGroup> m_lookupData;
};
} // namespace BamTools
// SamSequenceDictionary.cpp (c) 2010 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 12 October 2011 (DB)
+// Last modified: 14 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides methods for operating on a collection of SamSequence entries.
// *************************************************************************
Provides methods for operating on a collection of SamSequence entries.
*/
-/*! \typedef BamTools::SamSequenceIterator
- \brief mutable iterator for SamSequenceDictionary data
-
- \note This iterator, dereferenced, points to a std::pair<std::string, SamSequence>, NOT
- a "plain old" SamSequence. To retrieve the sequence:
-
- \code
- SamSequenceIterator iter;
- SamSequence& sq = (*iter).second // OR iter->second;
- \endcode
-*/
-
-/*! \typedef BamTools::SamSequenceConstIterator
- \brief const iterator for SamSequenceDictionary data
-
- \note This iterator, dereferenced, points to a std::pair<std::string, SamSequence>, NOT
- a "plain old" SamSequence. To retrieve the sequence:
-
- \code
- SamSequenceConstIterator iter;
- const SamSequence& sq = (*iter).second // OR iter->second;
- \endcode
-*/
-
/*! \fn SamSequenceDictionary::SamSequenceDictionary(void)
\brief constructor
*/
*/
SamSequenceDictionary::SamSequenceDictionary(const SamSequenceDictionary& other)
: m_data(other.m_data)
+ , m_lookupData(other.m_lookupData)
{ }
/*! \fn SamSequenceDictionary::~SamSequenceDictionary(void)
\param[in] sequence entry to be added
*/
void SamSequenceDictionary::Add(const SamSequence& sequence) {
- if ( IsEmpty() || !Contains(sequence) )
- m_data[sequence.Name] = sequence;
+ if ( IsEmpty() || !Contains(sequence) ) {
+ m_data.push_back(sequence);
+ m_lookupData[sequence.Name] = sequence;
+ }
}
/*! \fn void SamSequenceDictionary::Add(const std::string& name, const int& length)
SamSequenceConstIterator seqIter = sequences.ConstBegin();
SamSequenceConstIterator seqEnd = sequences.ConstEnd();
for ( ; seqIter != seqEnd; ++seqIter )
- Add(seqIter->second);
+ Add(*seqIter);
}
/*! \fn void SamSequenceDictionary::Add(const std::vector<SamSequence>& sequences)
*/
void SamSequenceDictionary::Clear(void) {
m_data.clear();
+ m_lookupData.clear();
}
/*! \fn SamSequenceConstIterator SamSequenceDictionary::ConstBegin(void) const
\return \c true if dictionary contains a sequence with this name
*/
bool SamSequenceDictionary::Contains(const std::string& sequenceName) const {
- return ( m_data.find(sequenceName) != m_data.end() );
+ return ( m_lookupData.find(sequenceName) != m_lookupData.end() );
}
/*! \fn bool SamSequenceDictionary::Contains(const SamSequence& sequence) const
\sa Remove()
*/
void SamSequenceDictionary::Remove(const std::string& sequenceName) {
- m_data.erase(sequenceName);
+
+ SamSequenceIterator seqIter = Begin();
+ SamSequenceIterator seqEnd = End();
+ for ( size_t i = 0 ; seqIter != seqEnd; ++seqIter, ++i ) {
+ SamSequence& seq = (*seqIter);
+ if( seq.Name == sequenceName ) {
+ m_data.erase( Begin() + i );
+ }
+ }
+
+ m_lookupData.erase(sequenceName);
}
/*! \fn void SamSequenceDictionary::Remove(const std::vector<SamSequence>& sequences)
\return a modifiable reference to the SamSequence associated with the name
*/
SamSequence& SamSequenceDictionary::operator[](const std::string& sequenceName) {
- if ( !Contains(sequenceName) )
- m_data[sequenceName] = SamSequence(sequenceName, 0);
- return m_data[sequenceName];
+ if ( !Contains(sequenceName) ) {
+ SamSequence seq(sequenceName, 0);
+ m_data.push_back(seq);
+ m_lookupData[sequenceName] = seq;
+ }
+ return m_lookupData[sequenceName];
}
// SamSequenceDictionary.h (c) 2010 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 12 October 2011
+// Last modified: 14 October 2011
// ---------------------------------------------------------------------------
// Provides methods for operating on a collection of SamSequence entries.
// ***************************************************************************
namespace BamTools {
-typedef std::map<std::string, SamSequence> SamSequenceContainer;
+typedef std::vector<SamSequence> SamSequenceContainer;
typedef SamSequenceContainer::iterator SamSequenceIterator;
typedef SamSequenceContainer::const_iterator SamSequenceConstIterator;
// data members
private:
SamSequenceContainer m_data;
+ std::map<std::string, SamSequence> m_lookupData;
};
} // namespace BamTools
// SamFormatPrinter.cpp (c) 2010 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 12 October 2011 (DB)
+// Last modified: 14 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides functionality for printing formatted SAM header to string
// ***************************************************************************
SamSequenceConstIterator seqIter = m_header.Sequences.ConstBegin();
SamSequenceConstIterator seqEnd = m_header.Sequences.ConstEnd();
for ( ; seqIter != seqEnd; ++seqIter ) {
- const SamSequence& seq = seqIter->second;
+ const SamSequence& seq = (*seqIter);
// @SQ SN:<Name> LN:<Length>
out << Constants::SAM_SQ_BEGIN_TOKEN
SamReadGroupConstIterator rgIter = m_header.ReadGroups.ConstBegin();
SamReadGroupConstIterator rgEnd = m_header.ReadGroups.ConstEnd();
for ( ; rgIter != rgEnd; ++rgIter ) {
- const SamReadGroup& rg = rgIter->second;
+ const SamReadGroup& rg = (*rgIter);
// @RG ID:<ID>
out << Constants::SAM_RG_BEGIN_TOKEN
// SamHeaderValidator.cpp (c) 2010 Derek Barnett
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 12 October 2011 (DB)
+// Last modified: 14 October 2011 (DB)
// ---------------------------------------------------------------------------
// Provides functionality for validating SamHeader data
// ***************************************************************************
SamSequenceConstIterator seqIter = sequences.ConstBegin();
SamSequenceConstIterator seqEnd = sequences.ConstEnd();
for ( ; seqIter != seqEnd; ++seqIter ) {
- const SamSequence& seq = seqIter->second;
+ const SamSequence& seq = (*seqIter);
isValid &= ValidateSequence(seq);
}
SamSequenceConstIterator seqIter = sequences.ConstBegin();
SamSequenceConstIterator seqEnd = sequences.ConstEnd();
for ( ; seqIter != seqEnd; ++seqIter ) {
- const SamSequence& seq = seqIter->second;
+ const SamSequence& seq = (*seqIter);
// lookup sequence name
const string& name = seq.Name;
SamReadGroupConstIterator rgIter = readGroups.ConstBegin();
SamReadGroupConstIterator rgEnd = readGroups.ConstEnd();
for ( ; rgIter != rgEnd; ++rgIter ) {
- const SamReadGroup& rg = rgIter->second;
+ const SamReadGroup& rg = (*rgIter);
isValid &= ValidateReadGroup(rg);
}
SamReadGroupConstIterator rgIter = readGroups.ConstBegin();
SamReadGroupConstIterator rgEnd = readGroups.ConstEnd();
for ( ; rgIter != rgEnd; ++rgIter ) {
- const SamReadGroup& rg = rgIter->second;
+ const SamReadGroup& rg = (*rgIter);
// --------------------------------
// check for unique ID
// bamtools_resolve.cpp (c) 2011
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
-// Last modified: 12 October 2011
+// Last modified: 14 October 2011
// ---------------------------------------------------------------------------
// Resolves paired-end reads (marking the IsProperPair flag as needed).
// ***************************************************************************
SamReadGroupConstIterator rgIter = header.ReadGroups.ConstBegin();
SamReadGroupConstIterator rgEnd = header.ReadGroups.ConstEnd();
for ( ; rgIter != rgEnd; ++rgIter ) {
- const SamReadGroup& rg = rgIter->second;
+ const SamReadGroup& rg = (*rgIter);
m_readGroups.insert( make_pair<string, ReadGroupResolver>(rg.ID, ReadGroupResolver()) );
}
}