[med-svn] [Git][med-team/biobambam2][master] 8 commits: Revert extra examples package. I was somehow misleaded when checking the size...

Andreas Tille gitlab at salsa.debian.org
Thu May 28 09:06:31 BST 2020



Andreas Tille pushed to branch master at Debian Med / biobambam2


Commits:
d5c96003 by Andreas Tille at 2020-05-28T08:14:41+02:00
Revert extra examples package.  I was somehow misleaded when checking the size of the examples.  They are not that big compared to the size of the package

- - - - -
8408476a by Andreas Tille at 2020-05-28T08:15:02+02:00
New upstream version 2.0.164+ds
- - - - -
60d1f557 by Andreas Tille at 2020-05-28T08:15:02+02:00
routine-update: New upstream version

- - - - -
2de3bb50 by Andreas Tille at 2020-05-28T08:15:03+02:00
Update upstream source from tag 'upstream/2.0.164+ds'

Update to upstream version '2.0.164+ds'
with Debian dir 8cf762923f714848d1aae2289e0286d6c8c4e2c7
- - - - -
d006490d by Andreas Tille at 2020-05-28T08:15:03+02:00
routine-update: debhelper-compat 13

- - - - -
1368b28f by Andreas Tille at 2020-05-28T09:09:32+02:00
Bump versioned Build-Depends: libmaus2-dev (>= 2.0.719)

- - - - -
8db1f5f4 by Andreas Tille at 2020-05-28T09:10:42+02:00
Team upload to unstable

- - - - -
04058123 by Andreas Tille at 2020-05-28T09:31:31+02:00
Avoid typos

- - - - -


13 changed files:

- .gitignore
- ChangeLog
- configure.ac
- − debian/biobambam2-examples.install
- debian/changelog
- debian/control
- debian/docs
- debian/examples
- src/Makefile.am
- src/programs/bamauxmerge2.cpp
- + src/programs/bamcountflags.cpp
- src/programs/bamfilterk.cpp
- + src/programs/vcffilterfilterflags.cpp


Changes:

=====================================
.gitignore
=====================================
@@ -68,3 +68,4 @@ src/filtergtf
 src/vcfreplacecontigs
 src/vcffiltersamples
 src/vcfdiff
+src/vcffilterfilterflags


=====================================
ChangeLog
=====================================
@@ -1,3 +1,27 @@
+biobambam2 (2.0.164-1) unstable; urgency=medium
+
+  * Add vcffilterfilterflags
+
+ -- German Tischler-Höhle <germant at miltenyibiotec.de>  Thu, 07 May 2020 13:45:25 +0200
+
+biobambam2 (2.0.163-1) unstable; urgency=medium
+
+  * do not use assert in parallel loop of bamfilterk
+
+ -- German Tischler-Höhle <germant at miltenyibiotec.de>  Wed, 22 Apr 2020 09:13:28 +0200
+
+biobambam2 (2.0.162-1) unstable; urgency=medium
+
+  * Add mapped/unmapped in bamcountflags
+
+ -- German Tischler-Höhle <germant at miltenyibiotec.de>  Mon, 30 Mar 2020 15:11:34 +0200
+
+biobambam2 (2.0.161-1) unstable; urgency=medium
+
+  * Add bamcountflags
+
+ -- German Tischler-Höhle <germant at miltenyibiotec.de>  Mon, 30 Mar 2020 14:31:52 +0200
+
 biobambam2 (2.0.160-1) unstable; urgency=medium
 
   * Add bamdepthmerge for merging several depth tracks into a single table


=====================================
configure.ac
=====================================
@@ -1,4 +1,4 @@
-AC_INIT(biobambam2,2.0.160,[germant at miltenyibiotec.de],[biobambam2],[https://gitlab.com/german.tischler/biobambam2])
+AC_INIT(biobambam2,2.0.164,[germant at miltenyibiotec.de],[biobambam2],[https://gitlab.com/german.tischler/biobambam2])
 AC_CANONICAL_SYSTEM
 AC_PROG_LIBTOOL
 
@@ -463,7 +463,7 @@ AC_ARG_ENABLE(install_uncommon,
         AS_HELP_STRING([--enable-install-uncommon],[enable installation of some uncommon programs (default no)]),
         [install_uncommon=${enableval}],[install_uncommon=no])
 
-UNCOMMON="bamfilter bamfilterbyname bamfixmatecoordinates bamfixmatecoordinatesnamesorted bamtoname bamdisthist fastabgzfextract bamheap bamfrontback bamrandomtag bamheap2 bamheap3 bamtagconversion fastqtobampar bambisect vcffilterinfo vcfpatchcontigprepend vcfconcat vcfsort filtergtf bamconsensus vcfreplacecontigs vcffiltersamples bamexploderg bamexondepth bamheadercat bammarkduplicatesoptdist vcfdiff bamsimpledepth bamdepthmerge"
+UNCOMMON="bamfilter bamfilterbyname bamfixmatecoordinates bamfixmatecoordinatesnamesorted bamtoname bamdisthist fastabgzfextract bamheap bamfrontback bamrandomtag bamheap2 bamheap3 bamtagconversion fastqtobampar bambisect vcffilterinfo vcfpatchcontigprepend vcfconcat vcfsort filtergtf bamconsensus vcfreplacecontigs vcffiltersamples bamexploderg bamexondepth bamheadercat bammarkduplicatesoptdist vcfdiff bamsimpledepth bamdepthmerge bamcountflags vcffilterfilterflags"
 UNCOMMONINSTALLED=
 UNCOMMONUNINSTALLED=
 if test "${install_uncommon}" = "yes" ; then


=====================================
debian/biobambam2-examples.install deleted
=====================================
@@ -1,3 +0,0 @@
-debian/tests/data/*                 usr/share/doc/biobambam2/examples/
-debian/tests/data/README.test_data	usr/share/doc/biobambam2/
-debian/tests/run-unit-test		    usr/share/doc/biobambam2/


=====================================
debian/changelog
=====================================
@@ -1,11 +1,18 @@
-biobambam2 (2.0.160+ds-2) UNRELEASED; urgency=medium
+biobambam2 (2.0.164+ds-1) unstable; urgency=medium
 
+  * Team upload.
+
+  [ Pranav Ballaney ]
   * Add autopkgtest data
   * Add autopkgtests
   * Install manpages and docs
-  TODO: Move examples to separate binary package
 
- -- Pranav Ballaney <ballaneypranav at gmail.com>  Wed, 27 May 2020 13:57:01 +0200
+  [ Andreas Tille ]
+  * New upstream version
+  * debhelper-compat 13 (routine-update)
+  * Bump versioned Build-Depends: libmaus2-dev (>= 2.0.719)
+
+ -- Pranav Ballaney <ballaneypranav at gmail.com>  Thu, 28 May 2020 08:15:02 +0200
 
 biobambam2 (2.0.160+ds-1) unstable; urgency=medium
 


=====================================
debian/control
=====================================
@@ -3,9 +3,9 @@ Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.
 Uploaders: Andreas Tille <tille at debian.org>
 Section: science
 Priority: optional
-Build-Depends: debhelper-compat (= 12),
+Build-Depends: debhelper-compat (= 13),
                pkg-config,
-               libmaus2-dev (>= 2.0.713)
+               libmaus2-dev (>= 2.0.719)
 Standards-Version: 4.5.0
 Vcs-Browser: https://salsa.debian.org/med-team/biobambam2
 Vcs-Git: https://salsa.debian.org/med-team/biobambam2.git
@@ -16,7 +16,6 @@ Package: biobambam2
 Architecture: any
 Depends: ${shlibs:Depends},
          ${misc:Depends}
-Suggests: biobambam2-examples
 Description: tools for early stage alignment file processing
  This package contains some tools for processing BAM files, including
  .
@@ -33,25 +32,3 @@ Description: tools for early stage alignment file processing
                   query name
    bamtofastq:    reads BAM and writes FastQ; output can be collated
                   or uncollated by query name
-
-Package: biobambam2-examples
-Architecture: any
-Depends: ${misc:Depends}
-Enhances: biobambam2
-Description: tools for early stage alignment file processing
- The biobambam2 package contains some tools for processing BAM files, including
- .
-   bamsormadup:  parallel sorting and duplicate marking
-   bamcollate2:  reads BAM and writes BAM reordered such that alignment
-                 or collated by query name
-   bammarkduplicates: reads BAM and writes BAM with duplicate alignments
-                 marked using the BAM flags field
-   bammaskflags: reads BAM and writes BAM while masking (removing) bits
-                 from the flags column
-   bamrecompress: reads BAM and writes BAM with a defined compression
-                  setting. This tool is capable of multi-threading.
-   bamsort:       reads BAM and writes BAM resorted by coordinates or
-                  query name
-   bamtofastq:    reads BAM and writes FastQ; output can be collated
-                  or uncollated by query name
-   This package contains some examples that can be used for testing biobambam2.
\ No newline at end of file


=====================================
debian/docs
=====================================
@@ -1,3 +1,5 @@
 README
 README.md
 debian/README.test
+debian/tests/run-unit-test
+debian/tests/data/README*


=====================================
debian/examples
=====================================
@@ -1 +1 @@
-debian/tests/data/*
\ No newline at end of file
+debian/tests/data/*


=====================================
src/Makefile.am
=====================================
@@ -137,6 +137,7 @@ EXTRA_PROGRAMS = blastnxmltobam \
 	bambisect \
 	bamconsensus \
 	vcffilterinfo \
+	vcffilterfilterflags \
 	vcffiltersamples \
 	vcfpatchcontigprepend \
 	vcfconcat \
@@ -149,7 +150,8 @@ EXTRA_PROGRAMS = blastnxmltobam \
 	bammarkduplicatesoptdist \
 	vcfdiff \
 	bamsimpledepth \
-	bamdepthmerge
+	bamdepthmerge \
+	bamcountflags
 
 populaterefcache_SOURCES = programs/populaterefcache.cpp biobambam2/Licensing.cpp
 populaterefcache_LDADD = ${LIBMAUS2LIBS}
@@ -171,6 +173,11 @@ vcffilterinfo_LDADD = ${LIBMAUS2LIBS}
 vcffilterinfo_LDFLAGS = ${AM_CPPFLAGS} ${LIBMAUS2CPPFLAGS} ${LIBMAUS2LDFLAGS} ${AM_LDFLAGS}
 vcffilterinfo_CPPFLAGS = ${AM_CPPFLAGS} ${LIBMAUS2CPPFLAGS}
 
+vcffilterfilterflags_SOURCES = programs/vcffilterfilterflags.cpp biobambam2/Licensing.cpp
+vcffilterfilterflags_LDADD = ${LIBMAUS2LIBS}
+vcffilterfilterflags_LDFLAGS = ${AM_CPPFLAGS} ${LIBMAUS2CPPFLAGS} ${LIBMAUS2LDFLAGS} ${AM_LDFLAGS}
+vcffilterfilterflags_CPPFLAGS = ${AM_CPPFLAGS} ${LIBMAUS2CPPFLAGS}
+
 vcffiltersamples_SOURCES = programs/vcffiltersamples.cpp biobambam2/Licensing.cpp
 vcffiltersamples_LDADD = ${LIBMAUS2LIBS}
 vcffiltersamples_LDFLAGS = ${AM_CPPFLAGS} ${LIBMAUS2CPPFLAGS} ${LIBMAUS2LDFLAGS} ${AM_LDFLAGS}
@@ -685,3 +692,8 @@ bamdepthmerge_SOURCES = programs/bamdepthmerge.cpp biobambam2/Licensing.cpp
 bamdepthmerge_LDADD = ${LIBMAUS2LIBS}
 bamdepthmerge_LDFLAGS = ${AM_CPPFLAGS} ${LIBMAUS2CPPFLAGS} ${LIBMAUS2LDFLAGS} ${AM_LDFLAGS}
 bamdepthmerge_CPPFLAGS = ${AM_CPPFLAGS} ${LIBMAUS2CPPFLAGS}
+
+bamcountflags_SOURCES = programs/bamcountflags.cpp biobambam2/Licensing.cpp
+bamcountflags_LDADD = ${LIBMAUS2LIBS}
+bamcountflags_LDFLAGS = ${AM_CPPFLAGS} ${LIBMAUS2CPPFLAGS} ${LIBMAUS2LDFLAGS} ${AM_LDFLAGS}
+bamcountflags_CPPFLAGS = ${AM_CPPFLAGS} ${LIBMAUS2CPPFLAGS}


=====================================
src/programs/bamauxmerge2.cpp
=====================================
@@ -240,12 +240,18 @@ struct DataBlock
 	typedef libmaus2::util::unique_ptr<this_type>::type unique_ptr_type;
 	typedef libmaus2::util::shared_ptr<this_type>::type shared_ptr_type;
 
+	// stream identifier
 	uint64_t streamid;
+	// buffer
 	libmaus2::autoarray::AutoArray<char> A;
+	// current pointer
 	char * c;
+	// number of bytes in buffer
 	uint64_t n;
+	// true if end of file has been reached
 	bool eof;
 	uint64_t seqid;
+	// space reserved for putback
 	uint64_t putbackspace;
 
 	libmaus2::bambam::parallel::FragmentAlignmentBuffer::shared_ptr_type fragmentBuffer;
@@ -292,8 +298,10 @@ struct DataBlock
 
 		if ( m > putbackspace )
 		{
+			// allocate new buffer
 			libmaus2::autoarray::AutoArray<char> B(n+m,false);
 
+			// copy old buffer
 			std::copy(c,c+n,B.begin()+m);
 
 			A = B;


=====================================
src/programs/bamcountflags.cpp
=====================================
@@ -0,0 +1,376 @@
+/**
+    biobambam
+    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/>..
+**/
+
+#include <biobambam2/BamBamConfig.hpp>
+#include <biobambam2/Licensing.hpp>
+#include <biobambam2/DepthInterval.hpp>
+
+#include <iomanip>
+
+#include <config.h>
+
+#include <libmaus2/util/TempFileRemovalContainer.hpp>
+#include <libmaus2/bambam/BamMultiAlignmentDecoderFactory.hpp>
+#include <libmaus2/util/ArgParser.hpp>
+#include <libmaus2/util/ArgInfo.hpp>
+#include <libmaus2/bambam/CircularHashCollatingBamDecoder.hpp>
+
+struct Callback : public libmaus2::bambam::CollatingBamDecoderAlignmentInputCallback
+{
+	uint64_t sec;
+	uint64_t sup;
+
+	Callback() : sec(0), sup(0)
+	{
+	}
+
+	virtual void operator()(::libmaus2::bambam::BamAlignment const & A)
+	{
+		if ( A.isSecondary() )
+		{
+			sec++;
+		}
+		if ( A.isSupplementary() )
+		{
+			sup++;
+		}
+	}
+};
+
+struct Counter
+{
+	uint64_t pairs;
+	uint64_t pairs_both;
+	uint64_t pairs_none;
+	uint64_t pairs_1;
+	uint64_t pairs_2;
+	uint64_t pairs_proper;
+
+	uint64_t o1;
+	uint64_t o1_mapped;
+	uint64_t o1_unmapped;
+
+	uint64_t o2;
+	uint64_t o2_mapped;
+	uint64_t o2_unmapped;
+
+	Counter()
+	: pairs(0), pairs_both(0), pairs_none(0), pairs_1(0), pairs_2(0), pairs_proper(0),
+	  o1(0), o1_mapped(0), o1_unmapped(0), o2(0), o2_mapped(0), o2_unmapped(0)
+	{
+
+	}
+
+	void update(std::pair <libmaus2::bambam::BamAlignment const *, libmaus2::bambam::BamAlignment const *> const & P)
+	{
+		if ( P.first && P.second )
+		{
+			pairs += 1;
+
+			if ( P.first->isMapped() && P.second->isMapped() )
+			{
+				pairs_both += 1;
+
+				if ( P.first->isProper() && P.second->isProper() )
+				{
+					pairs_proper += 1;
+				}
+			}
+			else if ( P.first->isMapped() )
+			{
+				pairs_1 += 1;
+			}
+			else if ( P.second->isMapped() )
+			{
+				pairs_2 += 1;
+			}
+			else
+			{
+				pairs_none += 1;
+			}
+		}
+		else if ( P.first )
+		{
+			o1 += 1;
+
+			if ( P.first->isMapped() )
+				o1_mapped++;
+			else
+				o1_unmapped++;
+		}
+		else if ( P.second )
+		{
+			o2 += 1;
+
+			if ( P.second->isMapped() )
+				o2_mapped++;
+			else
+				o2_unmapped++;
+		}
+	}
+};
+
+std::ostream & operator<<(std::ostream & out, Counter const & C)
+{
+	out << C.pairs << "/" << C.o1 << "/" << C.o2 << "\t"
+		<< C.pairs_both << "/" << C.pairs_proper << "/" << C.pairs_1 << "/" << C.pairs_2 << "/" << C.pairs_none << "\t"
+		<< C.o1_mapped << "/" << C.o1_unmapped << "\t"
+		<< C.o2_mapped << "/" << C.o2_unmapped
+		;
+	return out;
+}
+
+struct CounterContainer
+{
+	Counter global;
+	Counter split;
+	std::map<uint64_t,Counter> M;
+
+	void update(std::pair <libmaus2::bambam::BamAlignment const *, libmaus2::bambam::BamAlignment const *> const & P)
+	{
+		global.update(P);
+
+		if ( P.first && P.second )
+		{
+			if ( P.first->isMapped() && P.second->isMapped() )
+			{
+				if ( P.first->getRefID() == P.second->getRefID() )
+					M[P.first->getRefID()].update(P);
+				else
+					split.update(P);
+			}
+			else if ( P.first->isMapped() )
+				M[P.first->getRefID()].update(P);
+			else if ( P.second->isMapped() )
+				M[P.second->getRefID()].update(P);
+		}
+		else if ( P.first )
+		{
+			if ( P.first->isMapped() )
+				M[P.first->getRefID()].update(P);
+		}
+		else if ( P.second )
+		{
+			if ( P.second->isMapped() )
+				M[P.second->getRefID()].update(P);
+		}
+	}
+};
+
+void bamcountflags(libmaus2::util::ArgParser const & arg)
+{
+	libmaus2::bambam::BamAlignmentDecoderWrapper::unique_ptr_type decwrapper(
+		libmaus2::bambam::BamMultiAlignmentDecoderFactory::construct(arg,true /* put rank */));
+	::libmaus2::bambam::BamAlignmentDecoder * ppdec = &(decwrapper->getDecoder());
+	::libmaus2::bambam::BamAlignmentDecoder & dec = *ppdec;
+	::libmaus2::bambam::BamHeader const & header = dec.getHeader();
+	std::string const tmpfilebase = arg.uniqueArgPresent("T") ? arg["T"] : libmaus2::util::ArgInfo::getDefaultTmpFileName(arg.progname);
+
+	libmaus2::bambam::CircularHashCollatingBamDecoder CHC(
+		dec,tmpfilebase+".coltmp",
+		libmaus2::bambam::BamFlagBase::LIBMAUS2_BAMBAM_FSECONDARY|libmaus2::bambam::BamFlagBase::LIBMAUS2_BAMBAM_FSUPPLEMENTARY);
+
+	Callback CB;
+
+	CHC.addInputCallback(&CB);
+
+	std::pair <libmaus2::bambam::BamAlignment const *, libmaus2::bambam::BamAlignment const *> P;
+
+	uint64_t c = 0;
+	uint64_t p = 0;
+	uint64_t const mod = 1024*1024;
+
+	CounterContainer C;
+
+	uint64_t mapped = 0;
+	uint64_t unmapped = 0;
+
+	while ( CHC.tryPair(P) )
+	{
+		C.update(P);
+
+		if ( P.first )
+		{
+			if ( P.first->isMapped() )
+				mapped += 1;
+			else
+				unmapped += 1;
+
+			++c;
+		}
+		if ( P.second )
+		{
+			if ( P.second->isMapped() )
+				mapped += 1;
+			else
+				unmapped += 1;
+
+			++c;
+		}
+
+		if ( c / mod != p / mod )
+		{
+			std::cerr << "[V]\t" << ((c/mod)*mod) << "\t" << C.global << "\t" << mapped << "/" << unmapped << std::endl;
+			p = c;
+		}
+	}
+
+	std::cout << "global\t" << C.global << "\t" << mapped << "/" << unmapped << std::endl;
+	for ( std::map<uint64_t,Counter>::const_iterator it = C.M.begin(); it != C.M.end(); ++it )
+	{
+		std::cout << header.getRefIDName(it->first) << "\t" << it->second << std::endl;
+	}
+
+	#if 0
+	libmaus2::bambam::BamAlignment const & algn = dec.getAlignment();
+	uint64_t const mindepth = arg.getParsedArgOrDefault<uint64_t>("mindepth",0);
+	uint64_t const maxdepth = arg.getParsedArgOrDefault<uint64_t>("maxdepth",std::numeric_limits<int64_t>::max());
+	bool const binary = arg.getParsedArgOrDefault<int>("binary",0);
+	int const verbose = arg.getParsedArgOrDefault<int>("verbose",1);
+
+	libmaus2::util::FiniteSizeHeap<uint64_t> FSH(0);
+
+	uint64_t prevstart = 0;
+	uint64_t depth = 0;
+	int64_t prevrefid = -1;
+
+	IntervalHandler IH(mindepth,maxdepth,binary,header);
+
+	while ( dec.readAlignment() )
+	{
+		if ( algn.isMapped() )
+		{
+			if ( verbose && (algn.getRefID() != prevrefid) )
+				std::cerr << "[V] " << dec.getHeader().getRefIDName(algn.getRefID()) << std::endl;
+
+			libmaus2::math::IntegerInterval<int64_t> const I = algn.getReferenceInterval();
+
+			int64_t const i_from = I.from;
+			int64_t const i_to = i_from + I.diameter();
+
+			// std::cerr << "[" << i_from << "," << i_to << ")" << std::endl;
+
+			// stack is not empty and top element is finished
+			while (
+				(!FSH.empty())
+				&&
+				(
+					algn.getRefID() != prevrefid
+					||
+					static_cast<int64_t>(FSH.top()) <= i_from
+				)
+			)
+			{
+				uint64_t const end = FSH.pop();
+
+				if ( end > prevstart )
+				{
+					biobambam2::DepthInterval const D(prevrefid,prevstart,end,depth);
+					IH.handle(D);
+				}
+
+				depth -= 1;
+				prevstart = end;
+			}
+
+			// we have reached the end of a refid
+			if ( algn.getRefID() != prevrefid && prevrefid >= 0 )
+			{
+				assert ( depth == 0 );
+
+				// length of ref id
+				int64_t const len = dec.getHeader().getRefIDLength(prevrefid);
+
+				// if there is a depth 0 stretch in the end
+				if ( len > static_cast<int64_t>(prevstart) )
+				{
+					biobambam2::DepthInterval const D(prevrefid,prevstart,len,depth);
+					IH.handle(D);
+				}
+
+				prevstart = 0;
+			}
+
+			if ( i_from > static_cast<int64_t>(prevstart) )
+			{
+				biobambam2::DepthInterval const D(algn.getRefID(),prevstart,i_from,depth);
+				IH.handle(D);
+			}
+
+			depth += 1;
+			prevstart = i_from;
+
+			FSH.pushBump(i_to);
+
+			prevrefid = algn.getRefID();
+		}
+	}
+
+	while (
+		(!FSH.empty())
+	)
+	{
+		uint64_t const end = FSH.pop();
+
+		if ( end > prevstart )
+		{
+			biobambam2::DepthInterval const D(prevrefid,prevstart,end,depth);
+			IH.handle(D);
+		}
+
+		depth -= 1;
+		prevstart = end;
+	}
+
+	if ( prevrefid >= 0 )
+	{
+		assert ( depth == 0 );
+
+		int64_t const len = dec.getHeader().getRefIDLength(prevrefid);
+
+		if ( len > static_cast<int64_t>(prevstart) )
+		{
+			biobambam2::DepthInterval const D(prevrefid,prevstart,len,depth);
+			IH.handle(D);
+		}
+
+		prevstart = 0;
+	}
+
+	IH.finish();
+	#endif
+}
+
+int main(int argc, char * argv[])
+{
+	try
+	{
+		std::vector<libmaus2::util::ArgParser::ArgumentDefinition> Vformat = libmaus2::bambam::BamAlignmentDecoderInfo::getArgumentDefinitions();
+		Vformat.push_back(libmaus2::util::ArgParser::ArgumentDefinition("v","verbose",true));
+		Vformat.push_back(libmaus2::util::ArgParser::ArgumentDefinition("T","",true));
+
+		::libmaus2::util::ArgParser arg(argc,argv,Vformat);
+
+		bamcountflags(arg);
+	}
+	catch(std::exception const & ex)
+	{
+		std::cerr << ex.what() << std::endl;
+		return EXIT_FAILURE;
+	}
+}


=====================================
src/programs/bamfilterk.cpp
=====================================
@@ -528,88 +528,118 @@ int bamfilterk(libmaus2::util::ArgInfo const & arginfo)
 
 	Filter const filter(KH,AKB,AK,KB,k,thresval);
 
+	std::atomic<uint64_t> parfailed(0);
+
 	#if defined(_OPENMP)
 	#pragma omp parallel for num_threads(numthreads) schedule(dynamic,1)
 	#endif
 	for ( uint64_t i = 0; i < numpacks; ++i )
 	{
-		std::string const & tmpfn = Vtmp[i];
-		uint64_t const low = i * packsize;
-		uint64_t const high = std::min(low+packsize,n);
-		assert ( high > low );
+		try
+		{
+			std::string const & tmpfn = Vtmp[i];
+			uint64_t const low = i * packsize;
+			uint64_t const high = std::min(low+packsize,n);
+			assert ( high > low );
 
-		assert ( low % 2 == 0 );
-		assert ( high % 2 == 0 );
+			assert ( low % 2 == 0 );
+			assert ( high % 2 == 0 );
 
-		uint64_t const nump = (high-low)/2;
+			uint64_t const nump = (high-low)/2;
 
-		// uint64_t const size = high-low;
+			// uint64_t const size = high-low;
 
-		libmaus2::aio::OutputStreamInstance::unique_ptr_type pOS(new libmaus2::aio::OutputStreamInstance(tmpfn));
-		libmaus2::lz::BgzfDeflate<std::ostream>::unique_ptr_type pBOS(new libmaus2::lz::BgzfDeflate<std::ostream>(*pOS,level));
+			libmaus2::aio::OutputStreamInstance::unique_ptr_type pOS(new libmaus2::aio::OutputStreamInstance(tmpfn));
+			libmaus2::lz::BgzfDeflate<std::ostream>::unique_ptr_type pBOS(new libmaus2::lz::BgzfDeflate<std::ostream>(*pOS,level));
 
-		std::pair<
-			std::pair<uint8_t const *,uint64_t>,
-			libmaus2::bambam::BamRawDecoderBase::RawInterval
-			> P[2];
+			std::pair<
+				std::pair<uint8_t const *,uint64_t>,
+				libmaus2::bambam::BamRawDecoderBase::RawInterval
+				> P[2];
 
-		libmaus2::bambam::BamRawDecoder::unique_ptr_type pdec(indexdec.getRawDecoderAt(bamfn,low));
+			libmaus2::bambam::BamRawDecoder::unique_ptr_type pdec(indexdec.getRawDecoderAt(bamfn,low));
 
-		libmaus2::autoarray::AutoArray<uint8_t> U0;
-		libmaus2::autoarray::AutoArray<uint8_t> U1;
+			libmaus2::autoarray::AutoArray<uint8_t> U0;
+			libmaus2::autoarray::AutoArray<uint8_t> U1;
 
-		libmaus2::autoarray::AutoArray<char> A;
-		libmaus2::fastx::SingleWordDNABitBuffer forw(k);
-		libmaus2::autoarray::AutoArray<Match> AM;
+			libmaus2::autoarray::AutoArray<char> A;
+			libmaus2::fastx::SingleWordDNABitBuffer forw(k);
+			libmaus2::autoarray::AutoArray<Match> AM;
 
-		for ( uint64_t pindex = 0; pindex < nump; ++pindex )
-		{
-			P[0] = pdec->getPos();
-			assert ( P[0].first.first );
-			U0.ensureSize(P[0].first.second);
-			std::copy(P[0].first.first,P[0].first.first + P[0].first.second,U0.begin());
-			P[0].first.first = U0.begin();
+			for ( uint64_t pindex = 0; pindex < nump; ++pindex )
+			{
+				P[0] = pdec->getPos();
+				assert ( P[0].first.first );
+				U0.ensureSize(P[0].first.second);
+				std::copy(P[0].first.first,P[0].first.first + P[0].first.second,U0.begin());
+				P[0].first.first = U0.begin();
 
-			P[1] = pdec->getPos();
-			assert ( P[1].first.first );
+				P[1] = pdec->getPos();
+				assert ( P[1].first.first );
 
-			#if 0
-			U1.ensureSize(P[1].first.second);
-			std::copy(P[1].first.first,P[1].first.first + P[1].first.second,U1.begin());
-			P[1].first.first = U1.begin();
-			#endif
+				#if 0
+				U1.ensureSize(P[1].first.second);
+				std::copy(P[1].first.first,P[1].first.first + P[1].first.second,U1.begin());
+				P[1].first.first = U1.begin();
+				#endif
 
-			char const * c0 = libmaus2::bambam::BamAlignmentDecoderBase::getReadName(P[0].first.first);
-			char const * c1 = libmaus2::bambam::BamAlignmentDecoderBase::getReadName(P[1].first.first);
+				char const * c0 = libmaus2::bambam::BamAlignmentDecoderBase::getReadName(P[0].first.first);
+				char const * c1 = libmaus2::bambam::BamAlignmentDecoderBase::getReadName(P[1].first.first);
 
-			bool const samename = (strcmp(c0,c1) == 0);
+				bool const samename = (strcmp(c0,c1) == 0);
 
-			assert ( samename );
+				if ( ! samename )
+				{
+					libmaus2::exception::LibMausException lme;
+					lme.getStream() << "[E] samename check failed, mismatching are" << std::endl;
+					lme.getStream() << "[E] " << c0 << std::endl;
+					lme.getStream() << "[E] " << c1 << std::endl;
+					lme.finish();
+					throw lme;
+				}
+				assert ( samename );
 
-			bool const thres0 = filter.checkFilter(P[0],A,forw,AM);
-			bool const thres1 = filter.checkFilter(P[1],A,forw,AM);
+				bool const thres0 = filter.checkFilter(P[0],A,forw,AM);
+				bool const thres1 = filter.checkFilter(P[1],A,forw,AM);
 
-			if ( thres0 || thres1 )
-			{
-				putAlignment(P[0],*pBOS);
-				putAlignment(P[1],*pBOS);
-				written += 1;
+				if ( thres0 || thres1 )
+				{
+					putAlignment(P[0],*pBOS);
+					putAlignment(P[1],*pBOS);
+					written += 1;
+				}
 			}
-		}
 
-		pBOS->flush();
-		pBOS.reset();
-		pOS->flush();
-		pOS.reset();
+			pBOS->flush();
+			pBOS.reset();
+			pOS->flush();
+			pOS.reset();
 
-		uint64_t const lpackfinished = ++packfinished;
+			uint64_t const lpackfinished = ++packfinished;
 
+			{
+				libmaus2::parallel::ScopeStdSpinLock slock(libmaus2::aio::StreamLock::cerrlock);
+				std::cerr << lpackfinished << "/" << numpacks << "\t" << written << std::endl;
+			}
+		}
+		catch(std::exception const & ex)
 		{
-			libmaus2::parallel::ScopeStdSpinLock slock(libmaus2::aio::StreamLock::cerrlock);
-			std::cerr << lpackfinished << "/" << numpacks << "\t" << written << std::endl;
+			parfailed++;
+			{
+				libmaus2::parallel::ScopeStdSpinLock slock(libmaus2::aio::StreamLock::cerrlock);
+				std::cerr << ex.what() << std::endl;
+			}
 		}
 	}
 
+	if ( parfailed )
+	{
+		libmaus2::exception::LibMausException lme;
+		lme.getStream() << "[E] parallel loop failed" << std::endl;
+		lme.finish();
+		throw lme;
+	}
+
 	std::cerr << "[V] wrote " << written << " pairs" << std::endl;
 
 	std::cout.write(bgzfhead.c_str(),bgzfhead.size());


=====================================
src/programs/vcffilterfilterflags.cpp
=====================================
@@ -0,0 +1,93 @@
+/**
+    bambam
+    Copyright (C) 2019 German Tischler
+
+    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/>..
+**/
+#include <config.h>
+
+#include <libmaus2/vcf/VCFParser.hpp>
+#include <libmaus2/util/ArgInfo.hpp>
+#include <libmaus2/lz/BgzfDeflate.hpp>
+
+#include <biobambam2/Licensing.hpp>
+
+bool getDefaultVerbose() { return true; }
+
+int vcffilterinfox(libmaus2::util::ArgInfo const & arginfo, std::istream & in, std::ostream & out)
+{
+	//unsigned int const verbose = arginfo.getValue<unsigned int>("verbose",getDefaultVerbose());
+	std::string const filter = arginfo.getUnparsedValue("filter",std::string());
+	bool const gz = arginfo.getValue<int>("gz",0);
+
+	if ( gz )
+	{
+		libmaus2::lz::BgzfOutputStream BOS(out);
+		libmaus2::vcf::VCFParser::runFilterFilterFlags(in,BOS,filter);
+		BOS.flush();
+		BOS.addEOFBlock();
+	}
+	else
+	{
+		libmaus2::vcf::VCFParser::runFilterFilterFlags(in,out,filter);
+	}
+
+	return EXIT_SUCCESS;
+}
+
+int main(int argc, char * argv[])
+{
+	try
+	{
+		::libmaus2::util::ArgInfo const arginfo(argc,argv);
+
+		for ( uint64_t i = 0; i < arginfo.restargs.size(); ++i )
+			if (
+				arginfo.restargs[i] == "-v"
+				||
+				arginfo.restargs[i] == "--version"
+			)
+			{
+				std::cerr << ::biobambam2::Licensing::license();
+				return EXIT_SUCCESS;
+			}
+			else if (
+				arginfo.restargs[i] == "-h"
+				||
+				arginfo.restargs[i] == "--help"
+			)
+			{
+				std::cerr << ::biobambam2::Licensing::license();
+				std::cerr << std::endl;
+				std::cerr << "Key=Value pairs:" << std::endl;
+				std::cerr << std::endl;
+
+				std::vector< std::pair<std::string,std::string> > V;
+
+				V.push_back ( std::pair<std::string,std::string> ( "verbose=<["+::biobambam2::Licensing::formatNumber(getDefaultVerbose())+"]>", "print progress report (default: 1)" ) );
+
+				::biobambam2::Licensing::printMap(std::cerr,V);
+
+				std::cerr << std::endl;
+				return EXIT_SUCCESS;
+			}
+
+		return vcffilterinfox(arginfo,std::cin,std::cout);
+	}
+	catch(std::exception const & ex)
+	{
+		std::cerr << ex.what() << std::endl;
+		return EXIT_FAILURE;
+	}
+}



View it on GitLab: https://salsa.debian.org/med-team/biobambam2/-/compare/8f789457d4b490ef2ec7174ccfbcaa8545413557...040581234af0a46b91d9cd5525c7ed9ad4903fac

-- 
View it on GitLab: https://salsa.debian.org/med-team/biobambam2/-/compare/8f789457d4b490ef2ec7174ccfbcaa8545413557...040581234af0a46b91d9cd5525c7ed9ad4903fac
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/20200528/7eb11355/attachment-0001.html>


More information about the debian-med-commit mailing list