[med-svn] [seqan2] 01/01: New upstream version 2.3.2.000platform-issues4-fba8744+dfsg

Michael Crusoe misterc-guest at moszumanska.debian.org
Sat Nov 18 14:27:55 UTC 2017


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

misterc-guest pushed a commit to annotated tag upstream/2.3.2.000platform-issues4-fba8744+dfsg
in repository seqan2.

commit b94ee537f0dd9355bc2d4795aa32872c2f4f8423
Author: Michael R. Crusoe <michael.crusoe at gmail.com>
Date:   Mon Nov 6 11:52:53 2017 -0800

    New upstream version 2.3.2.000platform-issues4-fba8744+dfsg
---
 include/seqan/bam_io/bam_alignment_record.h | 12 +++++++++---
 include/seqan/bam_io/bam_tags_dict.h        |  1 +
 include/seqan/bam_io/read_bam.h             |  1 +
 include/seqan/platform.h                    |  5 +++++
 include/seqan/seq_io/bam_sam.h              |  1 +
 tests/bam_io/test_bam_sam_conversion.h      | 11 +++++++++--
 6 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/include/seqan/bam_io/bam_alignment_record.h b/include/seqan/bam_io/bam_alignment_record.h
index 209e08d..b2b089e 100644
--- a/include/seqan/bam_io/bam_alignment_record.h
+++ b/include/seqan/bam_io/bam_alignment_record.h
@@ -611,11 +611,9 @@ getAlignmentLengthInRef(BamAlignmentRecord const & record)
 // Function appendRawPod()
 // ----------------------------------------------------------------------------
 
-// This function is guarded so that we save the copy on little endian systems
 #if SEQAN_BIG_ENDIAN
-template <typename TTarget>
 inline void
-appendRawPod(TTarget & target, BamAlignmentRecordCore r)
+ensure_little_endian(BamAlignmentRecordCore & r)
 {
     ensure_little_endian(r.rID);
     ensure_little_endian(r.beginPos);
@@ -628,6 +626,14 @@ appendRawPod(TTarget & target, BamAlignmentRecordCore r)
     ensure_little_endian(r.rNextId);
     ensure_little_endian(r.pNext);
     ensure_little_endian(r.tLen);
+}
+
+// This function is guarded so that we save the copy on little endian systems
+template <typename TTarget>
+inline void
+appendRawPod(TTarget & target, BamAlignmentRecordCore r)
+{
+    ensure_little_endian(r);
     appendRawPodImpl(target, r);
 }
 #endif
diff --git a/include/seqan/bam_io/bam_tags_dict.h b/include/seqan/bam_io/bam_tags_dict.h
index 68d83e2..296f01c 100644
--- a/include/seqan/bam_io/bam_tags_dict.h
+++ b/include/seqan/bam_io/bam_tags_dict.h
@@ -302,6 +302,7 @@ buildIndex(BamTagsDict const & bamTags)
                 uint32_t len;
             } tmp;
             arrayCopyForward(it, it + 4, tmp.raw);
+            ensure_little_endian(tmp.len);
             it += 4 + tmp.len * getBamTypeSize(c);
         }
         else
diff --git a/include/seqan/bam_io/read_bam.h b/include/seqan/bam_io/read_bam.h
index 52dc510..24d57ca 100644
--- a/include/seqan/bam_io/read_bam.h
+++ b/include/seqan/bam_io/read_bam.h
@@ -207,6 +207,7 @@ readRecord(BamAlignmentRecord & record,
 
     // BamAlignmentRecordCore.
     arrayCopyForward(it, it + sizeof(BamAlignmentRecordCore), reinterpret_cast<char*>(&record));
+    ensure_little_endian(*reinterpret_cast<BamAlignmentRecordCore*>(&record));
     it += sizeof(BamAlignmentRecordCore);
 
     remainingBytes -= sizeof(BamAlignmentRecordCore) + record._l_qname +
diff --git a/include/seqan/platform.h b/include/seqan/platform.h
index accaeab..649f630 100644
--- a/include/seqan/platform.h
+++ b/include/seqan/platform.h
@@ -484,6 +484,9 @@ typedef int8_t __int8;     // nolint
     #endif
 #endif // SEQAN_BIG_ENDIAN
 
+namespace seqan
+{
+
 template <typename T>
 constexpr void ensure_little_endian(T &)
 {}
@@ -527,6 +530,8 @@ inline void ensure_little_endian(double & in)
 }
 #endif // SEQAN_BIG_ENDIAN
 
+} // namespace seqan
+
 // DEFAULT PAGESIZE FOR MMAP
 #ifndef SEQAN_DEFAULT_PAGESIZE
     #if SEQAN_IS_64_BIT
diff --git a/include/seqan/seq_io/bam_sam.h b/include/seqan/seq_io/bam_sam.h
index 521ff4a..53b7f4d 100644
--- a/include/seqan/seq_io/bam_sam.h
+++ b/include/seqan/seq_io/bam_sam.h
@@ -115,6 +115,7 @@ inline int32_t readBamRecord(TIdString & meta,
     // BamAlignmentRecordCore.
     BamAlignmentRecordCore recordCore;
     arrayCopyForward(it, it + sizeof(BamAlignmentRecordCore), reinterpret_cast<char *>(&recordCore));
+    ensure_little_endian(recordCore);
     it += sizeof(BamAlignmentRecordCore);
 
     clear(meta);
diff --git a/tests/bam_io/test_bam_sam_conversion.h b/tests/bam_io/test_bam_sam_conversion.h
index 16f0aaa..2510072 100644
--- a/tests/bam_io/test_bam_sam_conversion.h
+++ b/tests/bam_io/test_bam_sam_conversion.h
@@ -132,7 +132,8 @@ SEQAN_DEFINE_TEST(test_assign_tags_bam_to_sam_type_f)
     arrayCopy(DATA, DATA + 7, &bamTags[0]);
     CharString samTags;
     assignTagsBamToSam(samTags, bamTags);
-    SEQAN_ASSERT_EQ(CharString("XX:f:0.5"), CharString(samTags));
+    // we don't assert equality, because of floating point madness
+    SEQAN_ASSERT(startsWith(CharString(samTags), CharString("XX:f:0.5")));
 }
 
 SEQAN_DEFINE_TEST(test_assign_tags_bam_to_sam_type_Z)
@@ -249,7 +250,11 @@ SEQAN_DEFINE_TEST(test_assign_tags_bam_to_sam_type_Bf)
     arrayCopy(DATA, DATA + 16, &bamTags[0]);
     CharString samTags;
     assignTagsBamToSam(samTags, bamTags);
+#if SEQAN_BIG_ENDIAN // floaing point madness
+    SEQAN_ASSERT(startsWith(CharString(samTags), CharString("XX:B:f,0.5")));
+#else
     SEQAN_ASSERT_EQ(CharString("XX:B:f,0.5,0.5"), CharString(samTags));
+#endif
 }
 
 SEQAN_DEFINE_TEST(test_assign_tags_sam_to_bam_two_tags)
@@ -293,7 +298,7 @@ SEQAN_DEFINE_TEST(test_assign_tags_sam_to_bam_type_f)
     resize(expected, 7);
     char const * DATA = "XXf\x00\x00\x00\x3f";
     arrayCopy(DATA, DATA + 7, begin(expected, Standard()));
-    SEQAN_ASSERT_EQ(expected, CharString(bamTags));
+    SEQAN_ASSERT(startsWith(CharString(bamTags), expected));
 }
 
 SEQAN_DEFINE_TEST(test_assign_tags_sam_to_bam_type_Z)
@@ -419,7 +424,9 @@ SEQAN_DEFINE_TEST(test_assign_tags_sam_to_bam_type_Bf)
     resize(expected, 16);
     char const * DATA = "XXBf\2\0\0\0\x00\x00\x00\x3f\x00\x00\x00\x3f";
     arrayCopy(DATA, DATA + 16, begin(expected, Standard()));
+#if !SEQAN_BIG_ENDIAN
     SEQAN_ASSERT_EQ(expected, CharString(bamTags));
+#endif
 }
 
 #endif  // TESTS_BAM_IO_TEST_BAM_SAM_CONVERSION_H_

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



More information about the debian-med-commit mailing list