This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository bamtools.

commit 1e568fc9f22d07199522ee7a16b33646ea7fd567
Author: Andreas Tille <ti...@debian.org>
Date:   Fri Jan 13 10:08:37 2017 +0100

    New upstream version 2.4.1+dfsg
---
 CMakeLists.txt                       |   3 +-
 docs/Doxyfile                        |   8 +-
 src/api/BamAux.h                     |   7 ++
 src/api/BamMultiReader.cpp           |   4 +-
 src/api/CMakeLists.txt               |   2 +-
 src/api/internal/io/HttpHeader_p.cpp |   2 +-
 src/api/internal/io/NetUnix_p.h      |   4 +
 src/toolkit/CMakeLists.txt           |   2 +-
 src/toolkit/bamtools_split.cpp       | 139 ++++++++++++++++++++++++++++++-----
 9 files changed, 141 insertions(+), 30 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dade1e3..e1f2aa7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,7 +32,7 @@ ensure_out_of_source_build( "
 # set BamTools version information
 set( BamTools_VERSION_MAJOR 2 )
 set( BamTools_VERSION_MINOR 4 )
-set( BamTools_VERSION_BUILD 0 )
+set( BamTools_VERSION_BUILD 1 )
 
 # set our library and executable destination dirs
 set( EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin" )
@@ -40,6 +40,7 @@ set( LIBRARY_OUTPUT_PATH    "${CMAKE_SOURCE_DIR}/lib" )
 
 # define compiler flags for all code
 set( CMAKE_BUILD_TYPE Release )
+set( CMAKE_CXX_FLAGS_RELEASE "-std=c++98 ${CMAKE_CXX_FLAGS_RELEASE}" )
 add_definitions( -Wall -D_FILE_OFFSET_BITS=64 )
 
 # -----------------------------------------------
diff --git a/docs/Doxyfile b/docs/Doxyfile
index 7c21624..6c8f51b 100644
--- a/docs/Doxyfile
+++ b/docs/Doxyfile
@@ -31,7 +31,7 @@ PROJECT_NAME           = BamTools
 # This could be handy for archiving the generated documentation or 
 # if some version control system is used.
 
-PROJECT_NUMBER         = 2.4.0
+PROJECT_NUMBER         = 2.4.1
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
 # base path where the generated documentation will be put. 
@@ -590,7 +590,7 @@ WARN_LOGFILE           =
 # directories like "/usr/src/myproject". Separate the files or directories 
 # with spaces.
 
-INPUT                  = /home/derek/development/bamtools/src/api
+INPUT                  = src/api
 
 # This tag can be used to specify the character encoding of the source files 
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
@@ -649,7 +649,7 @@ RECURSIVE              = YES
 # excluded from the INPUT source files. This way you can easily exclude a 
 # subdirectory from a directory tree whose root is specified with the INPUT 
tag.
 
-EXCLUDE                = /home/derek/development/bamtools/src/api/internal
+EXCLUDE                = src/api/internal
 
 # The EXCLUDE_SYMLINKS tag can be used select whether or not files or 
 # directories that are symbolic links (a Unix filesystem feature) are excluded 
@@ -1454,7 +1454,7 @@ HAVE_DOT               = NO
 # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory 
 # containing the font.
 
-DOT_FONTNAME           = FreeSans
+# DOT_FONTNAME           = FreeSans
 
 # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. 
 # The default size is 10pt.
diff --git a/src/api/BamAux.h b/src/api/BamAux.h
index b448b76..9c50bf6 100644
--- a/src/api/BamAux.h
+++ b/src/api/BamAux.h
@@ -424,8 +424,15 @@ API_EXPORT inline unsigned int UnpackUnsignedInt(char* 
buffer) {
 API_EXPORT inline unsigned short UnpackUnsignedShort(const char* buffer) {
     union { unsigned short value; unsigned char valueBuffer[sizeof(unsigned 
short)]; } un;
     un.value = 0;
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
     un.valueBuffer[0] = buffer[0];
     un.valueBuffer[1] = buffer[1];
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+    un.valueBuffer[0] = buffer[1];
+    un.valueBuffer[1] = buffer[0];
+#else
+    #error "Unsupported hardware"
+#endif
     return un.value;
 }
 
diff --git a/src/api/BamMultiReader.cpp b/src/api/BamMultiReader.cpp
index 5c2a065..bf205ba 100644
--- a/src/api/BamMultiReader.cpp
+++ b/src/api/BamMultiReader.cpp
@@ -361,10 +361,10 @@ bool BamMultiReader::Rewind(void) {
     method can be useful when you know, for example, that your BAM files are 
sorted
     by coordinate but upstream processes did not set the header tag properly.
 
-    \note This method should \bold not be called while reading alignments via
+    \note This method should \b not be called while reading alignments via
     GetNextAlignment() or GetNextAlignmentCore(). For proper results, you 
should
     call this method before (or immediately after) opening files, rewinding,
-    jumping, etc. but \bold not once alignment fetching has started. There is
+    jumping, etc. but \b not once alignment fetching has started. There is
     nothing in the API to prevent you from doing so, but the results may be
     unexpected.
 
diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt
index 32edcff..4d5838b 100644
--- a/src/api/CMakeLists.txt
+++ b/src/api/CMakeLists.txt
@@ -34,7 +34,7 @@ set( BamToolsAPISources
 # create main BamTools API shared library
 add_library( BamTools SHARED ${BamToolsAPISources} )
 set_target_properties( BamTools PROPERTIES
-                       SOVERSION "2.4.0"
+                       SOVERSION "2.4.1"
                        OUTPUT_NAME "bamtools" )
 
 # create main BamTools API static library
diff --git a/src/api/internal/io/HttpHeader_p.cpp 
b/src/api/internal/io/HttpHeader_p.cpp
index fa71886..2a36666 100644
--- a/src/api/internal/io/HttpHeader_p.cpp
+++ b/src/api/internal/io/HttpHeader_p.cpp
@@ -1,4 +1,4 @@
-// ***************************************************************************
+// ***************************************************************************
 // HttpHeader_p.cpp (c) 2011 Derek Barnett
 // Marth Lab, Department of Biology, Boston College
 // ---------------------------------------------------------------------------
diff --git a/src/api/internal/io/NetUnix_p.h b/src/api/internal/io/NetUnix_p.h
index 8cf75f8..fb589d2 100644
--- a/src/api/internal/io/NetUnix_p.h
+++ b/src/api/internal/io/NetUnix_p.h
@@ -31,6 +31,10 @@
 #include <netdb.h>
 #include <unistd.h>
 
+#ifdef __FreeBSD__
+#  include <netinet/in.h>
+#endif
+
 #ifndef   BT_SOCKLEN_T
 #  define BT_SOCKLEN_T socklen_t
 #endif
diff --git a/src/toolkit/CMakeLists.txt b/src/toolkit/CMakeLists.txt
index c781148..cc76b35 100644
--- a/src/toolkit/CMakeLists.txt
+++ b/src/toolkit/CMakeLists.txt
@@ -31,7 +31,7 @@ add_executable( bamtools_cmd
 
 # set BamTools application properties
 set_target_properties( bamtools_cmd PROPERTIES
-                       VERSION  2.4.0
+                       VERSION  2.4.1
                        OUTPUT_NAME "bamtools"
                      )
 # make version info available in application
diff --git a/src/toolkit/bamtools_split.cpp b/src/toolkit/bamtools_split.cpp
index 6425e95..ebccd6b 100644
--- a/src/toolkit/bamtools_split.cpp
+++ b/src/toolkit/bamtools_split.cpp
@@ -72,6 +72,7 @@ struct SplitTool::SplitSettings {
     bool HasCustomOutputStub;
     bool HasCustomRefPrefix;
     bool HasCustomTagPrefix;
+    bool HasListTagDelimiter;
     bool IsSplittingMapped;
     bool IsSplittingPaired;
     bool IsSplittingReference;
@@ -83,6 +84,7 @@ struct SplitTool::SplitSettings {
     string CustomTagPrefix;
     string InputFilename;
     string TagToSplit;
+    string ListTagDelimiter;
     
     // constructor
     SplitSettings(void)
@@ -90,6 +92,7 @@ struct SplitTool::SplitSettings {
         , HasCustomOutputStub(false)
         , HasCustomRefPrefix(false)
         , HasCustomTagPrefix(false)
+        , HasListTagDelimiter(false)
         , IsSplittingMapped(false)
         , IsSplittingPaired(false)
         , IsSplittingReference(false)
@@ -99,6 +102,7 @@ struct SplitTool::SplitSettings {
         , CustomTagPrefix("")
         , InputFilename(Options::StandardIn())
         , TagToSplit("")
+        , ListTagDelimiter("--")
     { } 
 };  
 
@@ -139,8 +143,14 @@ class SplitTool::SplitToolPrivate {
         // finds first alignment and calls corresponding SplitTagImpl<> 
         // depending on tag type
         bool SplitTag(void);
-        // templated split tag implementation 
-        // handle the various types that are possible for tags
+
+    public:
+
+        // handles list-type tags
+        template<typename T>
+        bool SplitListTagImpl(BamAlignment& al);
+
+        // handles single-value tags
         template<typename T>
         bool SplitTagImpl(BamAlignment& al);    
         
@@ -199,7 +209,7 @@ bool SplitTool::SplitToolPrivate::Run(void) {
 
     // if we get here, no property was specified 
     cerr << "bamtools split ERROR: no property given to split on... " << endl
-         << "Please use -mapped, -paired, -reference, or -tag TAG to specifiy 
desired split behavior." << endl;
+         << "Please use -mapped, -paired, -reference, or -tag TAG to specify 
desired split behavior." << endl;
     return false;
 }    
 
@@ -383,27 +393,37 @@ bool SplitTool::SplitToolPrivate::SplitTag(void) {
         // pass it the current alignment found
         switch ( tagType ) {
           
-            case (Constants::BAM_TAG_TYPE_INT8)  :
-            case (Constants::BAM_TAG_TYPE_INT16) :
-            case (Constants::BAM_TAG_TYPE_INT32) :
-                return SplitTagImpl<int32_t>(al);
-                
-            case (Constants::BAM_TAG_TYPE_UINT8)  :
-            case (Constants::BAM_TAG_TYPE_UINT16) :
-            case (Constants::BAM_TAG_TYPE_UINT32) :
-                return SplitTagImpl<uint32_t>(al);
-              
-            case (Constants::BAM_TAG_TYPE_FLOAT)  :
-                return SplitTagImpl<float>(al);
+            case (Constants::BAM_TAG_TYPE_INT8)   : return 
SplitTagImpl<int8_t>(al);
+            case (Constants::BAM_TAG_TYPE_INT16)  : return 
SplitTagImpl<int16_t>(al);
+            case (Constants::BAM_TAG_TYPE_INT32)  : return 
SplitTagImpl<int32_t>(al);
+            case (Constants::BAM_TAG_TYPE_UINT8)  : return 
SplitTagImpl<uint8_t>(al);
+            case (Constants::BAM_TAG_TYPE_UINT16) : return 
SplitTagImpl<uint16_t>(al);
+            case (Constants::BAM_TAG_TYPE_UINT32) : return 
SplitTagImpl<uint32_t>(al);
+            case (Constants::BAM_TAG_TYPE_FLOAT)  : return 
SplitTagImpl<float>(al);
             
             case (Constants::BAM_TAG_TYPE_ASCII)  :
             case (Constants::BAM_TAG_TYPE_STRING) :
             case (Constants::BAM_TAG_TYPE_HEX)    :
                 return SplitTagImpl<string>(al);
 
-            case (Constants::BAM_TAG_TYPE_ARRAY) :
-                cerr << "bamtools split ERROR: array tag types are not 
supported" << endl;
-                return false;
+            case (Constants::BAM_TAG_TYPE_ARRAY) : {
+
+                char arrayTagType(0);
+                if (!al.GetArrayTagType(m_settings->TagToSplit, arrayTagType))
+                    continue;
+                switch(arrayTagType) {
+                    case (Constants::BAM_TAG_TYPE_INT8)   : return 
SplitListTagImpl<int8_t>(al);
+                    case (Constants::BAM_TAG_TYPE_INT16)  : return 
SplitListTagImpl<int16_t>(al);
+                    case (Constants::BAM_TAG_TYPE_INT32)  : return 
SplitListTagImpl<int32_t>(al);
+                    case (Constants::BAM_TAG_TYPE_UINT8)  : return 
SplitListTagImpl<uint8_t>(al);
+                    case (Constants::BAM_TAG_TYPE_UINT16) : return 
SplitListTagImpl<uint16_t>(al);
+                    case (Constants::BAM_TAG_TYPE_UINT32) : return 
SplitListTagImpl<uint32_t>(al);
+                    case (Constants::BAM_TAG_TYPE_FLOAT)  : return 
SplitListTagImpl<float>(al);
+                    default:
+                        cerr << "bamtools split ERROR: array tag has 
unsupported element type: " << arrayTagType << endl;
+                        return false;
+                }
+            }
           
             default:
                 cerr << "bamtools split ERROR: unknown tag type encountered: " 
<< tagType << endl;
@@ -447,7 +467,83 @@ void SplitTool::SplitToolPrivate::CloseWriters(map<T, 
BamWriter*>& writers) {
     writers.clear();
 }
 
-// handle the various types that are possible for tags
+// handle list-type tags
+template<typename T>
+bool SplitTool::SplitToolPrivate::SplitListTagImpl(BamAlignment& al) {
+
+    typedef T         TagElementType;
+    typedef vector<T> TagValueType;
+    typedef map<string, BamWriter*> WriterMap;
+    typedef typename WriterMap::iterator WriterMapIterator;
+
+    // set up splitting data structure
+    WriterMap outputFiles;
+    WriterMapIterator writerIter;
+
+    // determine tag prefix
+    string tagPrefix = SPLIT_TAG_TOKEN;
+    if ( m_settings->HasCustomTagPrefix )
+        tagPrefix = m_settings->CustomTagPrefix;
+
+    // make sure prefix starts with '.'
+    const size_t dotFound = tagPrefix.find('.');
+    if ( dotFound != 0 )
+        tagPrefix = string(".") + tagPrefix;
+
+    const string tag = m_settings->TagToSplit;
+    BamWriter* writer;
+    TagValueType currentValue;
+    while (m_reader.GetNextAlignment(al)) {
+
+        string listTagLabel;
+        if (!al.GetTag(tag, currentValue))
+            listTagLabel = "none";
+        else {
+            // make list label from tag data
+            stringstream listTagLabelStream;
+            typename TagValueType::const_iterator tagValueIter = 
currentValue.begin();
+            typename TagValueType::const_iterator tagValueEnd  = 
currentValue.end();
+            for (; tagValueIter != tagValueEnd; ++tagValueIter)
+                listTagLabelStream << (*tagValueIter) << 
m_settings->ListTagDelimiter;
+            listTagLabel = listTagLabelStream.str();
+            if (!listTagLabel.empty())
+                listTagLabel = listTagLabel.substr(0, listTagLabel.size() - 
m_settings->ListTagDelimiter.size()); // pop last delimiter
+        }
+
+        // lookup writer for label
+        writerIter = outputFiles.find(listTagLabel);
+
+        // if not found, create one
+        if (writerIter == outputFiles.end()) {
+
+            // open new BamWriter, save first alignment
+            stringstream outputFilenameStream;
+            outputFilenameStream << m_outputFilenameStub << tagPrefix << tag 
<< "_" << listTagLabel << ".bam";
+            writer = new BamWriter;
+            if ( !writer->Open(outputFilenameStream.str(), m_header, 
m_references) ) {
+                cerr << "bamtools split ERROR: could not open " << 
outputFilenameStream.str()
+                     << " for writing." << endl;
+                return false;
+            }
+
+            // store in map
+            outputFiles.insert( make_pair(listTagLabel, writer) );
+        }
+
+        // else grab existing writer
+        else writer = (*writerIter).second;
+
+        // store alignment in proper BAM output file
+        if ( writer )
+            writer->SaveAlignment(al);
+    }
+
+    // clean up & return success
+    CloseWriters(outputFiles);
+    return true;
+}
+
+// handle the single-value tags
 template<typename T>
 bool SplitTool::SplitToolPrivate::SplitTagImpl(BamAlignment& al) {
   
@@ -554,13 +650,16 @@ SplitTool::SplitTool(void)
     
     // set up options 
     OptionGroup* IO_Opts = Options::CreateOptionGroup("Input & Output");
-    Options::AddValueOption("-in",   "BAM filename",  "the input BAM file",  
"", m_settings->HasInputFilename,  m_settings->InputFilename,  IO_Opts, 
Options::StandardIn());
+    Options::AddValueOption("-in",   "BAM filename",  "the input BAM file",  
"",
+                            m_settings->HasInputFilename,  
m_settings->InputFilename,  IO_Opts, Options::StandardIn());
     Options::AddValueOption("-refPrefix", "string", "custom prefix for 
splitting by references. Currently files end with REF_<refName>.bam. This 
option allows you to replace \"REF_\" with a prefix of your choosing.", "",
                             m_settings->HasCustomRefPrefix, 
m_settings->CustomRefPrefix, IO_Opts);
     Options::AddValueOption("-tagPrefix", "string", "custom prefix for 
splitting by tags. Current files end with TAG_<tagname>_<tagvalue>.bam. This 
option allows you to replace \"TAG_\" with a prefix of your choosing.", "",
                             m_settings->HasCustomTagPrefix, 
m_settings->CustomTagPrefix, IO_Opts);
     Options::AddValueOption("-stub", "filename stub", "prefix stub for output 
BAM files (default behavior is to use input filename, without .bam extension, 
as stub). If input is stdin and no stub provided, a timestamp is generated as 
the stub.", "",
                             m_settings->HasCustomOutputStub, 
m_settings->CustomOutputStub, IO_Opts);
+    Options::AddValueOption("-tagListDelim", "string", "delimiter used to 
separate values in the filenames generated from splitting on list-type tags 
[--]", "",
+                            m_settings->HasListTagDelimiter, 
m_settings->ListTagDelimiter, IO_Opts);
     
     OptionGroup* SplitOpts = Options::CreateOptionGroup("Split Options");
     Options::AddOption("-mapped",    "split mapped/unmapped alignments",       
m_settings->IsSplittingMapped,    SplitOpts);

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/debian-med/bamtools.git

_______________________________________________
debian-med-commit mailing list
debian-med-commit@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to