Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
- use factory classes exclusively in bamcollate2
Browse files Browse the repository at this point in the history
- add setup for irods stream handlers in bamtofastq and bamcollate2
  • Loading branch information
German Tischler committed Jan 21, 2015
1 parent 8d4fac4 commit 2fd027d
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 115 deletions.
54 changes: 53 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ if test "${have_libmaus}" = "no" ; then
fi

AC_LANG_PUSH([C++])
AC_MSG_CHECKING([whether we libmaus has support for io_lib])
AC_MSG_CHECKING([whether libmaus has support for io_lib])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <libmaus/LibMausConfig.hpp>
Expand All @@ -208,6 +208,57 @@ if test "${have_libmaus_iolib}" = "yes" ; then
LIBMAUSIOLIBDEFINE="#define BIOBAMBAM_LIBMAUS_HAVE_IO_LIB"
fi

## zzzz

AC_LANG_PUSH([C++])
AC_MSG_CHECKING([whether libmaus has support for iRODS])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <libmaus/LibMausConfig.hpp>
int main(int argc, char * argv[[]]) {
#if ! defined(LIBMAUS_HAVE_IRODS)
#error "installed libmaus does not support iRODS"
#endif
return 0;
}])],
have_libmaus_irods=yes,
have_libmaus_irods=no
)
AC_LANG_POP
AC_MSG_RESULT($have_libmaus_irods)

LIBMAUSIRODSDEFINE=
LIBMAUSIRODSCPPFLAGS=
LIBMAUSIRODSLIBS=
if test "${have_libmaus_irods}" = "yes" ; then
if test ! -z "${with_libmaus}" ; then
PKGCONFIGPATHSAVE="${PKG_CONFIG_PATH}"
if test -z "${PKG_CONFIG_PATH}" ; then
export PKG_CONFIG_PATH="${with_libmaus}/lib/pkgconfig"
else
export PKG_CONFIG_PATH="${with_libmaus}/lib/pkgconfig:${PKG_CONFIG_PATH}"
fi
fi

PKG_CHECK_MODULES([libmausirods],[libmausirods >= 0.0.187])

LIBMAUSIRODSCPPFLAGS="${libmausirods_CFLAGS}"
LIBMAUSIRODSLIBS="${libmausirods_LIBS}"

LIBMAUSCPPFLAGS="${LIBMAUSCPPFLAGS} ${LIBMAUSIRODSCPPFLAGS}"
LIBMAUSLIBS="${LIBMAUSLIBS} ${LIBMAUSIRODSLIBS}"
CPPFLAGS="${CPPFLAGS} ${LIBMAUSIRODSCPPFLAGS}"
LIBS="${LIBS} ${LIBMAUSIRODSLIBS}"

if test ! -z "${with_libmaus}" ; then
if test ! -z "${PKGCONFIGPATHSAVE}" ; then
export PKG_CONFIG_PATH="${PKGCONFIGPATHSAVE}"
fi
fi

LIBMAUSIRODSDEFINE="#define BIOBAMBAM_LIBMAUS_HAVE_IRODS"
fi

CPPFLAGS="${CPPFLAGS_SAVE}"
LDFLAGS="${LDFLAGS_SAVE}"
LIBS="${LIBS_SAVE}"
Expand Down Expand Up @@ -357,6 +408,7 @@ AC_SUBST([LIBMAUSCPPFLAGS])
AC_SUBST([LIBMAUSLIBS])
#
AC_SUBST([LIBMAUSIOLIBDEFINE])
AC_SUBST([LIBMAUSIRODSDEFINE])
#
AC_SUBST([LIFTINGWAVELETTRANSFORMDEFINE])
AC_SUBST([BAMREFDEPTHPEAKS])
Expand Down
1 change: 1 addition & 0 deletions src/biobambam/BamBamConfig.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
@LIBMAUSIOLIBDEFINE@
@BIOBAMBAM_HAVE_XERCES_C@
@BIOBAMBAM_HAVE_GMP@
@LIBMAUSIRODSDEFINE@

#endif
140 changes: 26 additions & 114 deletions src/programs/bamcollate2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,67 +1008,19 @@ void bamcollate2CollatingRanking(libmaus::util::ArgInfo const & arginfo)
libmaus::util::TempFileRemovalContainer::addTempFile(tmpfilename);
std::string const inputformat = arginfo.getValue<std::string>("inputformat",getDefaultInputFormat());
std::string const inputfilename = arginfo.getValue<std::string>("filename","-");
uint64_t const numthreads = arginfo.getValue<uint64_t>("threads",0);

unsigned int const hlog = arginfo.getValue<unsigned int>("colhlog",18);
uint64_t const sbs = arginfo.getValueUnsignedNumeric<uint64_t>("colsbs",128ull*1024ull*1024ull);

if ( inputformat == "bam" )
{
BamToFastQInputFileStream bamin(inputfilename);

if ( numthreads > 0 )
{
libmaus::bambam::BamParallelCircularHashCollatingBamDecoder CHCBD(
bamin.in,
numthreads,
tmpfilename,excludeflags,
true, /* put rank */
hlog,
sbs
);
bamcollate2CollatingRanking(arginfo,CHCBD);
}
else
{
libmaus::bambam::BamCircularHashCollatingBamDecoder CHCBD(
bamin.in,
tmpfilename,excludeflags,
true, /* put rank */
hlog,
sbs
);
bamcollate2CollatingRanking(arginfo,CHCBD);
}
}
#if defined(BIOBAMBAM_LIBMAUS_HAVE_IO_LIB)
else if ( inputformat == "sam" )
{
libmaus::bambam::ScramCircularHashCollatingBamDecoder CHCBD(inputfilename,"r","",
tmpfilename,excludeflags,
true, /* put rank */
hlog,sbs
);
bamcollate2CollatingRanking(arginfo,CHCBD);
}
else if ( inputformat == "cram" )
{
std::string const reference = arginfo.getValue<std::string>("reference","");
libmaus::bambam::ScramCircularHashCollatingBamDecoder CHCBD(inputfilename,"rc",reference,
tmpfilename,excludeflags,
true, /* put rank */
hlog,sbs
);
bamcollate2CollatingRanking(arginfo,CHCBD);
}
#endif
else
{
libmaus::exception::LibMausException se;
se.getStream() << "unknown input format " << inputformat << std::endl;
se.finish();
throw se;
}
uint64_t const inputbuffersize = arginfo.getValueUnsignedNumeric<uint64_t>("inputbuffersize",getDefaultInputBufferSize());
libmaus::aio::PosixFdInputStream PFIS(STDIN_FILENO,inputbuffersize);
libmaus::bambam::BamAlignmentDecoderWrapper::unique_ptr_type decwrapper(
libmaus::bambam::BamMultiAlignmentDecoderFactory::construct(
arginfo,true /* put rank */, 0 /* copy stream */, PFIS
)
);
libmaus::bambam::CircularHashCollatingBamDecoder CHCBD(decwrapper->getDecoder(),tmpfilename,excludeflags,hlog,sbs);
bamcollate2CollatingRanking(arginfo,CHCBD);

std::cout.flush();
}
Expand Down Expand Up @@ -1383,67 +1335,19 @@ void bamcollate2CollatingPostRanking(libmaus::util::ArgInfo const & arginfo)
libmaus::util::TempFileRemovalContainer::addTempFile(tmpfilename);
std::string const inputformat = arginfo.getValue<std::string>("inputformat",getDefaultInputFormat());
std::string const inputfilename = arginfo.getValue<std::string>("filename","-");
uint64_t const numthreads = arginfo.getValue<uint64_t>("threads",0);

unsigned int const hlog = arginfo.getValue<unsigned int>("colhlog",18);
uint64_t const sbs = arginfo.getValueUnsignedNumeric<uint64_t>("colsbs",128ull*1024ull*1024ull);

if ( inputformat == "bam" )
{
BamToFastQInputFileStream bamin(inputfilename);

if ( numthreads > 0 )
{
libmaus::bambam::BamParallelCircularHashCollatingBamDecoder CHCBD(
bamin.in,
numthreads,
tmpfilename,excludeflags,
true, /* put rank */
hlog,
sbs
);
bamcollate2CollatingPostRanking(arginfo,CHCBD);
}
else
{
libmaus::bambam::BamCircularHashCollatingBamDecoder CHCBD(
bamin.in,
tmpfilename,excludeflags,
true, /* put rank */
hlog,
sbs
);
bamcollate2CollatingPostRanking(arginfo,CHCBD);
}
}
#if defined(BIOBAMBAM_LIBMAUS_HAVE_IO_LIB)
else if ( inputformat == "sam" )
{
libmaus::bambam::ScramCircularHashCollatingBamDecoder CHCBD(inputfilename,"r","",
tmpfilename,excludeflags,
true, /* put rank */
hlog,sbs
);
bamcollate2CollatingPostRanking(arginfo,CHCBD);
}
else if ( inputformat == "cram" )
{
std::string const reference = arginfo.getValue<std::string>("reference","");
libmaus::bambam::ScramCircularHashCollatingBamDecoder CHCBD(inputfilename,"rc",reference,
tmpfilename,excludeflags,
true, /* put rank */
hlog,sbs
);
bamcollate2CollatingPostRanking(arginfo,CHCBD);
}
#endif
else
{
libmaus::exception::LibMausException se;
se.getStream() << "unknown input format " << inputformat << std::endl;
se.finish();
throw se;
}
uint64_t const inputbuffersize = arginfo.getValueUnsignedNumeric<uint64_t>("inputbuffersize",getDefaultInputBufferSize());
libmaus::aio::PosixFdInputStream PFIS(STDIN_FILENO,inputbuffersize);
libmaus::bambam::BamAlignmentDecoderWrapper::unique_ptr_type decwrapper(
libmaus::bambam::BamMultiAlignmentDecoderFactory::construct(
arginfo,true /* put rank */, 0 /* copy stream */, PFIS
)
);
libmaus::bambam::CircularHashCollatingBamDecoder CHCBD(decwrapper->getDecoder(),tmpfilename,excludeflags,hlog,sbs);
bamcollate2CollatingPostRanking(arginfo,CHCBD);

std::cout.flush();
}
Expand Down Expand Up @@ -1502,10 +1406,18 @@ void bamcollate2(libmaus::util::ArgInfo const & arginfo)
}
}

#if defined(LIBMAUS_HAVE_IRODS)
#include <libmaus/irods/IRodsInputStreamFactory.hpp>
#endif

int main(int argc, char * argv[])
{
try
{
#if defined(LIBMAUS_HAVE_IRODS)
libmaus::irods::IRodsInputStreamFactory::registerHandler();
#endif

libmaus::timing::RealTimeClock rtc; rtc.start();

::libmaus::util::ArgInfo arginfo(argc,argv);
Expand Down
8 changes: 8 additions & 0 deletions src/programs/bamtofastq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,10 +1041,18 @@ void bamtofastq(libmaus::util::ArgInfo const & arginfo)
}
}

#if defined(LIBMAUS_HAVE_IRODS)
#include <libmaus/irods/IRodsInputStreamFactory.hpp>
#endif

int main(int argc, char * argv[])
{
try
{
#if defined(LIBMAUS_HAVE_IRODS)
libmaus::irods::IRodsInputStreamFactory::registerHandler();
#endif

libmaus::timing::RealTimeClock rtc; rtc.start();

::libmaus::util::ArgInfo arginfo(argc,argv);
Expand Down

0 comments on commit 2fd027d

Please sign in to comment.