[med-svn] [Git][med-team/tantan][upstream] New upstream version 40
Sascha Steinbiss (@satta)
gitlab at salsa.debian.org
Mon Oct 24 21:44:27 BST 2022
Sascha Steinbiss pushed to branch upstream at Debian Med / tantan
Commits:
31713d06 by Sascha Steinbiss at 2022-10-24T22:30:21+02:00
New upstream version 40
- - - - -
6 changed files:
- README.rst
- src/Makefile
- src/mcf_util.cc
- src/mcf_util.hh
- + src/mcf_zstream.hh
- src/tantan_app.cc
Changes:
=====================================
README.rst
=====================================
@@ -26,14 +26,15 @@ set up your computer to find it automatically. Some possible ways:
* Copy ``tantan`` to a standard directory: ``sudo make install``
(using "sudo" to request administrator permissions).
-* Copy it to your personal bin directory: ``make install prefix=~``
+* Copy it to your personal bin directory: ``make install prefix=~`` or
+ ``make install prefix=~/.local``
* Adjust your `PATH variable`_.
You might need to log out and back in for your computer to recognize
the new program.
-**Alternative:** Install tantan from bioconda_.
+**Alternative:** Install tantan from bioconda_ or `Debian Med`_.
Normal usage
------------
@@ -219,3 +220,4 @@ sequences", MC Frith, Nucleic Acids Research 2011 39(4):e23.
.. _BED: https://genome.ucsc.edu/FAQ/FAQformat.html#format1
.. _PATH variable: https://en.wikipedia.org/wiki/PATH_(variable)
.. _bioconda: https://bioconda.github.io/
+.. _Debian Med: https://www.debian.org/devel/debian-med/
=====================================
src/Makefile
=====================================
@@ -4,13 +4,13 @@ all: ../bin/tantan
../bin/tantan: *.cc *.hh version.hh Makefile
mkdir -p ../bin
- $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ *.cc
+ $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ *.cc -lz
clean:
rm -f ../bin/tantan
VERSION1 = git describe --dirty
-VERSION2 = echo ' (HEAD -> main, tag: 39) ' | sed -e 's/.*tag: *//' -e 's/[,) ].*//'
+VERSION2 = echo ' (HEAD -> main, tag: 40) ' | sed -e 's/.*tag: *//' -e 's/[,) ].*//'
VERSION = \"`test -e ../.git && $(VERSION1) || $(VERSION2)`\"
=====================================
src/mcf_util.cc
=====================================
@@ -6,11 +6,11 @@
namespace mcf {
-std::istream &openIn(const std::string &fileName, std::ifstream &ifs) {
+std::istream &openIn(const std::string &fileName, izstream &z) {
if (fileName == "-") return std::cin;
- ifs.open(fileName.c_str());
- if (!ifs) throw std::runtime_error("can't open file: " + fileName);
- return ifs;
+ z.open(fileName.c_str());
+ if (!z) throw std::runtime_error("can't open file: " + fileName);
+ return z;
}
std::ostream &openOut(const std::string &fileName, std::ofstream &ofs) {
=====================================
src/mcf_util.hh
=====================================
@@ -3,6 +3,8 @@
#ifndef MCF_UTIL_HH
#define MCF_UTIL_HH
+#include "mcf_zstream.hh"
+
#include <cassert>
#include <fstream>
#include <sstream>
@@ -12,7 +14,7 @@
namespace mcf {
// open an input file, but if the name is "-", just return cin
-std::istream &openIn(const std::string &fileName, std::ifstream &ifs);
+std::istream &openIn(const std::string &fileName, izstream &z);
// open an output file, but if the name is "-", just return cout
std::ostream &openOut(const std::string &fileName, std::ofstream &ofs);
@@ -34,8 +36,8 @@ void unstringify(T& x, const std::string &s) {
template <typename T>
void unfilify(T& x, const std::string &fileName) {
- std::ifstream ifs;
- std::istream &input = openIn(fileName, ifs);
+ izstream z;
+ std::istream &input = openIn(fileName, z);
input >> x;
if (!input) throw std::runtime_error("can't read file: " + fileName);
// check for junk at end of file?
=====================================
src/mcf_zstream.hh
=====================================
@@ -0,0 +1,83 @@
+// Copyright 2017 Martin C. Frith
+
+// mcf::izstream is similar to std::ifstream. The difference is, if
+// you give it a gzip-compressed file, it will decompress what it
+// reads.
+
+#ifndef MCF_ZSTREAM_HH
+#define MCF_ZSTREAM_HH
+
+#include <zlib.h>
+
+#include <cstdio> // BUFSIZ
+#include <istream>
+#include <stdexcept>
+#include <streambuf>
+
+namespace mcf {
+
+class zbuf : public std::streambuf {
+public:
+ zbuf() : input(0) {}
+
+ ~zbuf() { close(); }
+
+ bool is_open() const { return input; }
+
+ zbuf *open(const char *fileName) {
+ if (is_open()) return 0;
+ input = gzopen(fileName, "rb");
+ if (!is_open()) return 0;
+ return this;
+ }
+
+ zbuf *close() {
+ if (!is_open()) return 0;
+ int e = gzclose(input);
+ input = 0;
+ return (e == Z_OK || e == Z_BUF_ERROR) ? this : 0;
+ }
+
+protected:
+ int underflow() {
+ if (gptr() == egptr()) {
+ int size = gzread(input, buffer, BUFSIZ);
+ if (size < 0) throw std::runtime_error("gzread error");
+ setg(buffer, buffer, buffer + size);
+ }
+ return (gptr() == egptr()) ?
+ traits_type::eof() : traits_type::to_int_type(*gptr());
+ }
+
+private:
+ gzFile input;
+ char buffer[BUFSIZ];
+};
+
+class izstream : public std::istream {
+public:
+ izstream() : std::istream(&buf) {}
+
+ izstream(const char *fileName) : std::istream(&buf) {
+ open(fileName);
+ }
+
+ bool is_open() const { return buf.is_open(); }
+
+ void open(const char *fileName) {
+ // do something special if fileName is "-"?
+ if (!buf.open(fileName)) setstate(failbit);
+ else clear();
+ }
+
+ void close() {
+ if (!buf.close()) setstate(failbit);
+ }
+
+private:
+ zbuf buf;
+};
+
+}
+
+#endif
=====================================
src/tantan_app.cc
=====================================
@@ -416,8 +416,8 @@ try {
processOneFile(std::cin, output);
for (int i = options.indexOfFirstNonOptionArgument; i < argc; ++i) {
- std::ifstream ifs;
- std::istream &input = openIn(argv[i], ifs);
+ izstream z;
+ std::istream &input = openIn(argv[i], z);
processOneFile(input, output);
}
View it on GitLab: https://salsa.debian.org/med-team/tantan/-/commit/31713d06e18217941826858c62aea558bdeed6ce
--
View it on GitLab: https://salsa.debian.org/med-team/tantan/-/commit/31713d06e18217941826858c62aea558bdeed6ce
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/20221024/b3ea2829/attachment-0001.htm>
More information about the debian-med-commit
mailing list