[med-svn] [Git][med-team/libmaus2][upstream] New upstream version 2.0.722+dfsg
Steffen Möller
gitlab at salsa.debian.org
Sat Jun 13 20:03:44 BST 2020
Steffen Möller pushed to branch upstream at Debian Med / libmaus2
Commits:
6344920a by Steffen Moeller at 2020-06-13T20:20:17+02:00
New upstream version 2.0.722+dfsg
- - - - -
8 changed files:
- ChangeLog
- configure.ac
- src/Makefile.am
- src/libmaus2/autoarray/AutoArray.hpp
- src/libmaus2/lcs/AlignmentTraceContainer.hpp
- src/libmaus2/lcs/NPLNoTrace.hpp
- src/libmaus2/util/ArgParser.hpp
- + src/libmaus2/util/SerialiseHelper.hpp
Changes:
=====================================
ChangeLog
=====================================
@@ -1,3 +1,23 @@
+libmaus2 (2.0.722-1) unstable; urgency=medium
+
+ * make size bumping more flexible in AutoArray
+ * avoid running asserts by checking parameters and throwing exception in NPLNoTrace
+
+ -- German Tischler-Höhle <germant at miltenyibiotec.de> Wed, 10 Jun 2020 14:59:41 +0200
+
+libmaus2 (2.0.721-1) unstable; urgency=medium
+
+ * add getMatchOffsets variants in AlignmentTraceContainer
+ * fix broken parsing of non value arguments in ArgParser
+
+ -- German Tischler-Höhle <germant at miltenyibiotec.de> Mon, 08 Jun 2020 17:08:42 +0200
+
+libmaus2 (2.0.720-1) unstable; urgency=medium
+
+ * add SerialiseHelper class
+
+ -- German Tischler-Höhle <germant at miltenyibiotec.de> Tue, 02 Jun 2020 17:13:24 +0200
+
libmaus2 (2.0.719-1) unstable; urgency=medium
* Make separator in VCFParser::getSampleValueVectorForKey a template argument
=====================================
configure.ac
=====================================
@@ -1,5 +1,5 @@
-AC_INIT(libmaus2,2.0.719,[germant at miltnyibiotec.de],[libmaus2],[https://github.com/gt1/libmaus2])
-LIBRARY_VERSION=2:719:0
+AC_INIT(libmaus2,2.0.722,[germant at miltnyibiotec.de],[libmaus2],[https://github.com/gt1/libmaus2])
+LIBRARY_VERSION=2:722:0
AC_MSG_NOTICE([Configuring for source in directory ${srcdir}])
AC_CANONICAL_SYSTEM
AC_CANONICAL_HOST
=====================================
src/Makefile.am
=====================================
@@ -1332,8 +1332,9 @@ libmaus2util_include_HEADERS=\
libmaus2/util/DirectoryStructure.hpp \
libmaus2/util/StreamGetObject.hpp \
libmaus2/util/StackTraceBufferContainer.hpp \
- libmaus2/util/StackLineTranslator.hpp
-
+ libmaus2/util/StackLineTranslator.hpp \
+ libmaus2/util/SerialiseHelper.hpp
+
libmaus2uint_includedir=$(includedir)/libmaus2/uint
libmaus2uint_include_HEADERS=\
libmaus2/uint/uint.hpp
=====================================
src/libmaus2/autoarray/AutoArray.hpp
=====================================
@@ -1783,31 +1783,42 @@ namespace libmaus2
return std::numeric_limits<uint64_t>::max();
}
- void bump()
+ static uint64_t getDefaultBumpC()
{
- uint64_t oldsize = size();
- uint64_t const one = 1;
- uint64_t newsize = std::max(oldsize<<1,one);
+ return 2;
+ }
+
+ static uint64_t getDefaultBumpD()
+ {
+ return 1;
+ }
+
+ void bump(uint64_t const c = getDefaultBumpC(), uint64_t const d = getDefaultBumpD())
+ {
+ uint64_t const oldsize = size();
+ uint64_t const one = 1;
+ uint64_t const nmult = (oldsize*c)/d;
+ uint64_t const newsize = std::max(nmult,oldsize+one);
resize(newsize);
}
- void ensureSize(uint64_t const s)
+ void ensureSize(uint64_t const s, uint64_t const c = getDefaultBumpC(), uint64_t const d = getDefaultBumpD())
{
while ( size() < s )
- bump();
+ bump(c,d);
}
- void push(uint64_t & o, N const & v)
+ void push(uint64_t & o, N const & v, uint64_t const c = getDefaultBumpC(), uint64_t const d = getDefaultBumpD())
{
- ensureSize(o+1);
+ ensureSize(o+1,c,d);
(*this)[o++] = v;
}
template<typename iterator>
- void push(uint64_t & o, iterator v, iterator ve)
+ void push(uint64_t & o, iterator v, iterator ve, uint64_t const c = getDefaultBumpC(), uint64_t const d = getDefaultBumpD())
{
uint64_t const n = ve-v;
- ensureSize(o+n);
+ ensureSize(o+n,c,d);
while ( v != ve )
(*this)[o++] = *(v++);
=====================================
src/libmaus2/lcs/AlignmentTraceContainer.hpp
=====================================
@@ -2576,6 +2576,38 @@ namespace libmaus2
}
}
+ static uint64_t getMatchOffsets(step_type const * ta, step_type const * te, libmaus2::autoarray::AutoArray < std::pair<uint64_t,uint64_t> > & R, uint64_t const off_a = 0, uint64_t const off_b = 0)
+ {
+ uint64_t o = 0;
+ uint64_t apos = off_a, bpos = off_b;
+
+ for ( step_type const * tc = ta; tc != te; ++tc )
+ {
+ switch ( *tc )
+ {
+ case STEP_MATCH:
+ R.push(o,std::pair<uint64_t,uint64_t>(apos,bpos));
+ apos += 1;
+ bpos += 1;
+ break;
+ case STEP_MISMATCH:
+ apos += 1;
+ bpos += 1;
+ break;
+ case STEP_INS:
+ bpos += 1;
+ break;
+ case STEP_DEL:
+ apos += 1;
+ break;
+ case STEP_RESET:
+ break;
+ }
+ }
+
+ return o;
+ }
+
static uint64_t getAOffsets(
step_type const * ta,
step_type const * te,
=====================================
src/libmaus2/lcs/NPLNoTrace.hpp
=====================================
@@ -96,6 +96,21 @@ namespace libmaus2
template<typename iter_a, typename iter_b>
ReturnValue np(iter_a const a, iter_a const ae, iter_b const b, iter_b const be, index_type const maxd = std::numeric_limits<index_type>::max())
{
+ if ( ae-a < 0 )
+ {
+ libmaus2::exception::LibMausException lme;
+ lme.getStream() << "[E] NPLNoTrace::np: ae-a = " << ae-a << std::endl;
+ lme.finish();
+ throw lme;
+ }
+ if ( be-b < 0 )
+ {
+ libmaus2::exception::LibMausException lme;
+ lme.getStream() << "[E] NPLNoTrace::np: be-b = " << be-b << std::endl;
+ lme.finish();
+ throw lme;
+ }
+
assert ( ae-a >= 0 );
assert ( be-b >= 0 );
=====================================
src/libmaus2/util/ArgParser.hpp
=====================================
@@ -214,6 +214,7 @@ namespace libmaus2
std::map<std::string, ArgumentDefinition const *> shortKeys;
std::map<std::string, ArgumentDefinition const *> longKeys;
+ // check whether argument names are unique
for ( uint64_t i = 0; i < Vformat.size(); ++i )
{
ArgumentDefinition const & D = Vformat.at(i);
@@ -252,6 +253,7 @@ namespace libmaus2
bool argvalue = false;
ArgumentDefinition const * D = nullptr;
+ // parse
for ( uint64_t i = 1; i < args.size(); ++i )
{
std::string arg = args.at(i);
@@ -272,8 +274,10 @@ namespace libmaus2
// if argument does not start with "--"
else if ( arg[1] != '-' )
{
+ // get argument key
argkey = arg.substr(1,1);
+ // search for key
std::map<std::string,ArgumentDefinition const *>::const_iterator it = shortKeys.find(argkey);
if ( it == shortKeys.end() )
@@ -284,16 +288,22 @@ namespace libmaus2
throw lme;
}
+ // get argument definition
D = it->second;
+ // use long name as key if any
if ( D->longName.size() )
argkey = D->longName;
+ // check if any value is given without a space between
if ( arg.size() > 2 )
{
+ // get value
std::string const argvalue = arg.substr(2);
+ // push it if argument requires value
if ( D->hasValue )
kvargs.insert(std::pair<std::string,std::string>(argkey,argvalue));
+ // otherwise throw error
else
{
libmaus2::exception::LibMausException lme;
@@ -302,8 +312,12 @@ namespace libmaus2
throw lme;
}
}
+ // if argument requires a value
else if ( D->hasValue )
argvalue = true;
+ // otherwise push kv element with empty value
+ else
+ kvargs.insert(std::pair<std::string,std::string>(argkey,std::string()));
}
else
{
@@ -345,6 +359,10 @@ namespace libmaus2
{
argvalue = true;
}
+ else
+ {
+ kvargs.insert(std::pair<std::string,std::string>(argkey,std::string()));
+ }
}
}
else
=====================================
src/libmaus2/util/SerialiseHelper.hpp
=====================================
@@ -0,0 +1,177 @@
+/*
+ libmaus2
+ Copyright (C) 2020 German Tischler-Höhle
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>..
+*/
+#if ! defined(LIBMAUS2_UTIL_SERIALISEHELPER_HPP)
+#define LIBMAUS2_UTIL_SERIALISEHELPER_HPP
+
+#include <libmaus2/exception/LibMausException.hpp>
+
+namespace libmaus2
+{
+ namespace util
+ {
+ struct SerialiseHelper
+ {
+ template<typename number_type>
+ static void writeNumber(std::ostream & out, number_type const v)
+ {
+ out.write(reinterpret_cast<char const *>(&v),sizeof(v));
+ if ( ! out )
+ {
+ libmaus2::exception::LibMausException lme;
+ lme.getStream() << "[E] SerialiseHelper::writeNumber: failed to write number" << std::endl;
+ lme.finish();
+ throw lme;
+ }
+ }
+
+ static void writeString(std::ostream & out, std::string const & s)
+ {
+ uint64_t const n = s.size();
+ writeNumber(out,n);
+ out.write(s.c_str(),n+1);
+ }
+
+ template<typename number_type>
+ static void readNumber(std::istream & in, number_type & v)
+ {
+ in.read(reinterpret_cast<char *>(&v),sizeof(v));
+ if ( ! in || in.gcount() != sizeof(v) )
+ {
+ libmaus2::exception::LibMausException lme;
+ lme.getStream() << "[E] SerialiseHelper::readNumber: failed to read number" << std::endl;
+ lme.finish();
+ throw lme;
+ }
+ }
+
+ static void readString(std::istream & in, std::string & s)
+ {
+ uint64_t n;
+ readNumber(in,n);
+ s.resize(n);
+ for ( uint64_t i = 0; i < n; ++i )
+ {
+ int c = in.get();
+ if ( in && c != std::istream::traits_type::eof() )
+ s[i] = c;
+ else
+ {
+ libmaus2::exception::LibMausException lme;
+ lme.getStream() << "[E] SerialiseHelper::readString: failed to read string" << std::endl;
+ lme.finish();
+ throw lme;
+ }
+ }
+
+ int c = in.get();
+ if ( ! in || c == std::istream::traits_type::eof() || c != 0 )
+ {
+ libmaus2::exception::LibMausException lme;
+ lme.getStream() << "[E] SerialiseHelper::readString: failed to read string" << std::endl;
+ lme.finish();
+ throw lme;
+ }
+ }
+
+ template<typename number_type>
+ static void getNumber(char const * & p, number_type & v)
+ {
+ v = *reinterpret_cast<number_type const *>(p);
+ p += sizeof(number_type);
+ }
+
+ template<typename number_type>
+ static number_type getNumber(char const * & p)
+ {
+ number_type v;
+ getNumber(p,v);
+ return v;
+ }
+
+ static void getStringPair(char const * & p, std::pair<char const *, char const *> & P)
+ {
+ uint64_t n;
+ getNumber(p,n);
+ P.first = p;
+ p += n;
+ P.second = p;
+ p += 1;
+ }
+
+ static std::pair<char const *, char const *> getStringPair(char const * & p)
+ {
+ std::pair<char const *, char const *> P;
+ getStringPair(p,P);
+ return P;
+ }
+
+ static std::string getString(char const * & p)
+ {
+ std::pair<char const *, char const *> P;
+ getStringPair(p,P);
+ return std::string(P.first,P.second);
+ }
+
+ static void test()
+ {
+ uint64_t n0 = 4;
+ std::string s = "hello world";
+ uint64_t n1 = 13;
+
+ std::ostringstream ostr;
+ writeNumber(ostr,n0);
+ writeString(ostr,s);
+ writeNumber(ostr,n1);
+ ostr.flush();
+
+ std::istringstream istr(ostr.str());
+
+ uint64_t in0, in1;
+ std::string ins;
+
+ readNumber(istr,in0);
+ readString(istr,ins);
+ readNumber(istr,in1);
+
+ if ( in0 != n0 || ins != s || in1 != n1 )
+ {
+ libmaus2::exception::LibMausException lme;
+ lme.getStream() << "[E] SerialiseHelper::test: failed" << std::endl;
+ lme.finish();
+ throw lme;
+ }
+
+ std::string const sdata = ostr.str();
+ char const * cdata = sdata.c_str();
+
+ uint64_t cn0 = getNumber<uint64_t>(cdata);
+ std::string cs = getString(cdata);
+ uint64_t cn1 = getNumber<uint64_t>(cdata);
+
+ if ( cn0 != n0 || cs != s || cn1 != n1 )
+ {
+ libmaus2::exception::LibMausException lme;
+ lme.getStream() << "[E] SerialiseHelper::test: failed" << std::endl;
+ lme.finish();
+ throw lme;
+ }
+ }
+ };
+ }
+}
+#endif
View it on GitLab: https://salsa.debian.org/med-team/libmaus2/-/commit/6344920a2195175b00e0f404a255c749e608930d
--
View it on GitLab: https://salsa.debian.org/med-team/libmaus2/-/commit/6344920a2195175b00e0f404a255c749e608930d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20200613/7667b57b/attachment-0001.html>
More information about the debian-med-commit
mailing list