diff -Nru gfapy-1.2.2+dfsg/CHANGES.txt gfapy-1.2.3+dfsg/CHANGES.txt --- gfapy-1.2.2+dfsg/CHANGES.txt 2022-01-13 10:36:06.000000000 +0000 +++ gfapy-1.2.3+dfsg/CHANGES.txt 2022-02-03 15:47:16.000000000 +0000 @@ -1,3 +1,7 @@ +== 1.2.3 == + +- make it possible to count input header lines correctly + == 1.2.2 == - remove to/from aliases for GFA1 containment/link fields diff -Nru gfapy-1.2.2+dfsg/debian/changelog gfapy-1.2.3+dfsg/debian/changelog --- gfapy-1.2.2+dfsg/debian/changelog 2022-01-21 10:24:22.000000000 +0000 +++ gfapy-1.2.3+dfsg/debian/changelog 2022-02-07 14:34:57.000000000 +0000 @@ -1,3 +1,9 @@ +gfapy (1.2.3+dfsg-1) unstable; urgency=medium + + * New upstream release. + + -- Sascha Steinbiss Mon, 07 Feb 2022 15:34:57 +0100 + gfapy (1.2.2+dfsg-1) unstable; urgency=medium * New upstream release. diff -Nru gfapy-1.2.2+dfsg/doc/conf.py gfapy-1.2.3+dfsg/doc/conf.py --- gfapy-1.2.2+dfsg/doc/conf.py 2022-01-13 10:36:06.000000000 +0000 +++ gfapy-1.2.3+dfsg/doc/conf.py 2022-02-03 15:47:16.000000000 +0000 @@ -76,7 +76,7 @@ # The short X.Y version. version = '1.2' # The full version, including alpha/beta/rc tags. -release = '1.2.2' +release = '1.2.3' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff -Nru gfapy-1.2.2+dfsg/doc/tutorial/header.rst gfapy-1.2.3+dfsg/doc/tutorial/header.rst --- gfapy-1.2.2+dfsg/doc/tutorial/header.rst 2022-01-13 10:36:06.000000000 +0000 +++ gfapy-1.2.3+dfsg/doc/tutorial/header.rst 2022-02-03 15:47:16.000000000 +0000 @@ -167,3 +167,23 @@ >>> str(gfa) 'H\tVN:Z:1.0\nH\txx:i:1\nH\txx:i:2' +Count the input header lines +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Due to the different way header lines are stored, the number of header elements +is not equal to the number of header lines in the input. This is annoying if an +application wants to count the number of input lines in a file. In order to make +that possible, the number of input header lines are counted and can be +retrieved using the :attr:`~gfapy.lines.headers.Headers.n_input_header_lines` +property of the Gfa instance. + +.. doctest:: + + >>> gfa = gfapy.Gfa() + >>> gfa.add_line("H\txx:i:1\tyy:Z:ABC") #doctest: +ELLIPSIS + >>> gfa.add_line("H\txy:i:2") #doctest: +ELLIPSIS + >>> gfa.add_line("H\tyz:i:3\tab:A:A") #doctest: +ELLIPSIS + >>> len(gfa.headers) + 5 + >>> gfa.n_input_header_lines + 3 diff -Nru gfapy-1.2.2+dfsg/gfapy/gfa.py gfapy-1.2.3+dfsg/gfapy/gfa.py --- gfapy-1.2.2+dfsg/gfapy/gfa.py 2022-01-13 10:36:06.000000000 +0000 +++ gfapy-1.2.3+dfsg/gfapy/gfa.py 2022-02-03 15:47:16.000000000 +0000 @@ -41,6 +41,7 @@ self._records = defaultdict(dict) self._records["H"] = gfapy.line.Header(["H"], vlevel = vlevel) self._records["H"].connect(self) + self._n_input_header_lines = 0 self._records["S"] = {} self._records["P"] = {} self._records["F"] = {} diff -Nru gfapy-1.2.2+dfsg/gfapy/lines/creators.py gfapy-1.2.3+dfsg/gfapy/lines/creators.py --- gfapy-1.2.2+dfsg/gfapy/lines/creators.py 2022-01-13 10:36:06.000000000 +0000 +++ gfapy-1.2.3+dfsg/gfapy/lines/creators.py 2022-02-03 15:47:16.000000000 +0000 @@ -87,6 +87,7 @@ gfa_line = gfapy.Line(gfa_line, dialect=self._dialect) gfa_line.connect(self) elif rt == "H": + self._n_input_header_lines += 1 if isinstance(gfa_line, str): gfa_line = gfapy.Line(gfa_line, vlevel=self._vlevel, dialect=self._dialect) @@ -139,6 +140,7 @@ "Cannot add instance of incompatible line type "+ str(type(gfa_line))) if gfa_line.record_type == "H": + self._n_input_header_lines += 1 if self._vlevel > 0 and gfa_line.VN and gfa_line.VN != "1.0": raise gfapy.VersionError( "Header line specified wrong version ({})\n".format(gfa_line.VN)+ @@ -172,6 +174,7 @@ "Cannot add instance of incompatible line type "+ str(type(gfa_line))) if gfa_line.record_type == "H": + self._n_input_header_lines += 1 if self._vlevel > 0 and gfa_line.VN and gfa_line.VN != "2.0": raise gfapy.VersionError( "Header line specified wrong version ({})\n".format(gfa_line.VN)+ diff -Nru gfapy-1.2.2+dfsg/gfapy/lines/headers.py gfapy-1.2.3+dfsg/gfapy/lines/headers.py --- gfapy-1.2.2+dfsg/gfapy/lines/headers.py 2022-01-13 10:36:06.000000000 +0000 +++ gfapy-1.2.3+dfsg/gfapy/lines/headers.py 2022-02-03 15:47:16.000000000 +0000 @@ -10,6 +10,10 @@ return self._records["H"] @property + def n_input_header_lines(self): + return self._n_input_header_lines + + @property def headers(self): """The splitted header of the Gfa instance. diff -Nru gfapy-1.2.2+dfsg/setup.py gfapy-1.2.3+dfsg/setup.py --- gfapy-1.2.2+dfsg/setup.py 2022-01-13 10:36:06.000000000 +0000 +++ gfapy-1.2.3+dfsg/setup.py 2022-02-03 15:47:16.000000000 +0000 @@ -9,7 +9,7 @@ sys.exit("Sorry, only Python 3 is supported") setup(name='gfapy', - version='1.2.2', + version='1.2.3', description='Library for handling data in the GFA1 and GFA2 formats', long_description=readme(), url='https://github.com/ggonnella/gfapy',