[med-svn] [seqan2] 01/01: New upstream version 2.3.2.000platform-issues3-1d438c8+dfsg
Michael Crusoe
misterc-guest at moszumanska.debian.org
Fri Nov 3 06:58:48 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-issues3-1d438c8+dfsg
in repository seqan2.
commit b32d493f1082525974615002f80fb398686130ff
Author: Michael R. Crusoe <michael.crusoe at gmail.com>
Date: Thu Nov 2 11:04:15 2017 -0700
New upstream version 2.3.2.000platform-issues3-1d438c8+dfsg
---
include/seqan/bam_io/bam_index_bai.h | 37 ++++++++++++++++++++++++++-----
include/seqan/bam_io/bam_sam_conversion.h | 11 +++++----
include/seqan/bam_io/bam_tags_dict.h | 2 ++
3 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/include/seqan/bam_io/bam_index_bai.h b/include/seqan/bam_io/bam_index_bai.h
index da7ea47..7aa7230 100644
--- a/include/seqan/bam_io/bam_index_bai.h
+++ b/include/seqan/bam_io/bam_index_bai.h
@@ -440,6 +440,7 @@ open(BamIndex<Bai> & index, char const * filename)
fin.read(reinterpret_cast<char *>(&nRef), 4);
if (!fin.good())
return false;
+ ensure_little_endian(nRef);
resize(index._linearIndices, nRef);
resize(index._binIndices, nRef);
@@ -451,6 +452,7 @@ open(BamIndex<Bai> & index, char const * filename)
fin.read(reinterpret_cast<char *>(&nBin), 4);
if (!fin.good())
return false;
+ ensure_little_endian(nBin);
index._binIndices[i].clear();
BaiBamIndexBinData_ data;
for (int j = 0; j < nBin; ++j) // For each bin.
@@ -461,11 +463,13 @@ open(BamIndex<Bai> & index, char const * filename)
fin.read(reinterpret_cast<char *>(&bin), 4);
if (!fin.good())
return false;
+ ensure_little_endian(bin);
int32_t nChunk = 0;
fin.read(reinterpret_cast<char *>(&nChunk), 4);
if (!fin.good())
return false;
+ ensure_little_endian(nChunk);
reserve(data.chunkBegEnds, nChunk);
for (int k = 0; k < nChunk; ++k) // For each chunk;
{
@@ -475,6 +479,8 @@ open(BamIndex<Bai> & index, char const * filename)
fin.read(reinterpret_cast<char *>(&chunkEnd), 8);
if (!fin.good())
return false;
+ ensure_little_endian(chunkBeg);
+ ensure_little_endian(chunkEnd);
appendValue(data.chunkBegEnds, Pair<uint64_t>(chunkBeg, chunkEnd));
}
@@ -487,6 +493,7 @@ open(BamIndex<Bai> & index, char const * filename)
fin.read(reinterpret_cast<char *>(&nIntv), 4);
if (!fin.good())
return false;
+ ensure_little_endian(nIntv);
clear(index._linearIndices[i]);
reserve(index._linearIndices[i], nIntv);
for (int j = 0; j < nIntv; ++j)
@@ -495,6 +502,7 @@ open(BamIndex<Bai> & index, char const * filename)
fin.read(reinterpret_cast<char *>(&ioffset), 8);
if (!fin.good())
return false;
+ ensure_little_endian(ioffset);
appendValue(index._linearIndices[i], ioffset);
}
}
@@ -510,6 +518,7 @@ open(BamIndex<Bai> & index, char const * filename)
fin.clear();
nNoCoord = 0;
}
+ ensure_little_endian(nNoCoord);
index._unalignedCount = nNoCoord;
return true;
@@ -549,6 +558,7 @@ inline bool save(BamIndex<Bai> const & index, char const * baiFilename)
// Write header.
out.write("BAI\1", 4);
int32_t numRefSeqs = length(index._binIndices);
+ ensure_little_endian(numRefSeqs);
out.write(reinterpret_cast<char *>(&numRefSeqs), 4);
// Write out indices.
@@ -563,35 +573,52 @@ inline bool save(BamIndex<Bai> const & index, char const * baiFilename)
// Write out binning index.
int32_t numBins = binIndex.size();
+ ensure_little_endian(numBins);
out.write(reinterpret_cast<char *>(&numBins), 4);
for (TBinIndexIter itB = binIndex.begin(), itBEnd = binIndex.end(); itB != itBEnd; ++itB)
{
// Write out bin id.
- out.write(reinterpret_cast<char const *>(&itB->first), 4);
+ uint32_t tmp = itB->first;
+ ensure_little_endian(tmp);
+ out.write(reinterpret_cast<char const *>(&tmp), 4);
// Write out number of chunks.
uint32_t numChunks = length(itB->second.chunkBegEnds);
+ ensure_little_endian(numChunks);
out.write(reinterpret_cast<char *>(&numChunks), 4);
// Write out all chunks.
typedef Iterator<String<Pair<uint64_t> > const, Rooted>::Type TChunkIter;
for (TChunkIter itC = begin(itB->second.chunkBegEnds); !atEnd(itC); goNext(itC))
{
- out.write(reinterpret_cast<char const *>(&itC->i1), 8);
- out.write(reinterpret_cast<char const *>(&itC->i2), 8);
+ uint64_t tmp1 = itC->i1;
+ ensure_little_endian(tmp1);
+ uint64_t tmp2 = itC->i2;
+ ensure_little_endian(tmp2);
+ out.write(reinterpret_cast<char const *>(&tmp1), 8);
+ out.write(reinterpret_cast<char const *>(&tmp2), 8);
}
}
// Write out linear index.
int32_t numIntervals = length(linearIndex);
+ ensure_little_endian(numIntervals);
out.write(reinterpret_cast<char *>(&numIntervals), 4);
typedef Iterator<String<uint64_t> const, Rooted>::Type TLinearIndexIter;
for (TLinearIndexIter it = begin(linearIndex, Rooted()); !atEnd(it); goNext(it))
- out.write(reinterpret_cast<char const *>(&*it), 8);
+ {
+ uint64_t tmp = *it;
+ ensure_little_endian(tmp);
+ out.write(reinterpret_cast<char const *>(&tmp), 8);
+ }
}
// Write the number of unaligned reads if set.
//std::cerr << "UNALIGNED\t" << index._unalignedCount << std::endl;
if (index._unalignedCount != maxValue<uint64_t>())
- out.write(reinterpret_cast<char const *>(&index._unalignedCount), 8);
+ {
+ uint64_t tmp = index._unalignedCount;
+ ensure_little_endian(tmp);
+ out.write(reinterpret_cast<char const *>(&tmp), 8);
+ }
return out.good(); // false on error, true on success.
}
diff --git a/include/seqan/bam_io/bam_sam_conversion.h b/include/seqan/bam_io/bam_sam_conversion.h
index f6e707b..66fafa9 100644
--- a/include/seqan/bam_io/bam_sam_conversion.h
+++ b/include/seqan/bam_io/bam_sam_conversion.h
@@ -233,7 +233,9 @@ struct AssignTagsBamToSamOneTagHelper_
if (BamTypeChar<Type>::VALUE != typeC)
return false;
- appendNumber(target, reinterpret_cast<Type const &>(*it));
+ Type tmp = *reinterpret_cast<Type const *>(&*it);
+ ensure_little_endian(tmp);
+ appendNumber(target, tmp);
it += sizeof(Type);
return true;
}
@@ -299,14 +301,15 @@ void _appendTagsBamToSamOneTag(TTarget & target, TSourceIter & it)
// Read array length.
union {
char raw[4];
- unsigned len;
+ uint32_t len;
} tmp;
- for (unsigned i = 0; i < 4; ++i)
+ for (uint32_t i = 0; i < 4; ++i)
{
SEQAN_ASSERT_NOT(atEnd(it));
tmp.raw[i] = *it++;
}
- for (unsigned i = 0; i < tmp.len; ++i)
+ ensure_little_endian(tmp.len);
+ for (uint32_t i = 0; i < tmp.len; ++i)
{
writeValue(target, ',');
if (!tagApply(func, BamTagTypes()))
diff --git a/include/seqan/bam_io/bam_tags_dict.h b/include/seqan/bam_io/bam_tags_dict.h
index 05ddae5..68d83e2 100644
--- a/include/seqan/bam_io/bam_tags_dict.h
+++ b/include/seqan/bam_io/bam_tags_dict.h
@@ -492,6 +492,7 @@ struct ExtractTagValueHelper_
} tmp;
arrayCopyForward(rawIter, rawIter + sizeof(Type), tmp.raw);
+ ensure_little_endian(tmp.i);
result = static_cast<TResultType>(tmp.i);
return true;
}
@@ -666,6 +667,7 @@ struct ToBamTagValueHelper_
} tmp;
tmp.i = static_cast<Type>(val);
+ ensure_little_endian(tmp.i);
append(result, toRange(&tmp.raw[0], &tmp.raw[sizeof(Type)]));
return true;
}
--
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