diff -Nru python-cogent-2021.5.7a+dfsg/ChangeLog python-cogent-2021.10.12a1+dfsg/ChangeLog --- python-cogent-2021.5.7a+dfsg/ChangeLog 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/ChangeLog 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -Change log -========== - -The porting from PyCogent 1.9 to 3.0 has involved a massive number of changes! - -Please see the `wiki pages `_ for a summary of the API changes. - -But the best way to see them is all to use mercurial. \ No newline at end of file diff -Nru python-cogent-2021.5.7a+dfsg/changelog.md python-cogent-2021.10.12a1+dfsg/changelog.md --- python-cogent-2021.5.7a+dfsg/changelog.md 1970-01-01 00:00:00.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/changelog.md 2021-10-12 00:17:34.000000000 +0000 @@ -0,0 +1,59 @@ +# Since release 2021.5.7a1 + +## Contributors + +- GavinHuttley + +## DEV + +- added missing `dev` requires-extras to pyproject.toml for installing all packages required for development + +# Since release 2021.5.7a + +## Contributors + +- GavinHuttley +- jamesmartini +- KatherineCaley + +## API + +- ValueError if any tips missing in TreeNode.lowest_common_ancestor() +- added index_name argument to Table.to_categorical(), allows specifying the category column and getting the categorical table in one statement. + +## BUG + +- DataStore.write() requires identifiers end with indicated suffix +- cogent3.app.tree.quicktree() now works for 2 sequences +- Alignment.degap() now preserves sequence names +- cogent3.app.io.load_aligned() handles paml format +- fast_slow_dist results can now be saved by write_tabular, a DistanceMatrix.source attribute is created on-the-fly by the fast_slow_dist calculator, enabling it be written +- Alignment.variable_positions(), always report a position as variable if > 1 non-gap characters are present +- SequenceCollection.dotplot() method defaults handle single sequence +- app.evo.boostrap() can now be composed, + +## DEV + +- change to using flit for package management. This change requires you `python -m pip install flit`. If you clone this repository and want to do a developer install, you should first remove your existing one + + ````bash + $ python -m pip uninstall cogent3 + ```` + + then + + ```bash + $ flit install -s --python `which python` + ``` + +## DEP + +- removed WritableZippedDataStore, the zip archive format is inefficient for incremental inclusion of files. Use a tinydb instead. +- replaced interleave_len argument with wrap in sequence format writers +- removed Table.to_rich_html() method, use Table.to_html() instead + +## ENH + +- More robust alignment to reference algorithm. Builds a multiple sequence alignment from a series of pairwise alignments to a reference sequence. cogent3.app.align.align_to_ref() now retains gaps in the reference. This will be modestly slower than previously, but avoids losing information if the choice of reference sequence is a bad one. +- cogent3.app.composable.appify decorator class, simplifies converting a user defined function into a cogent3 composable app +- JSD calculation now uses more accurate math.fsum() \ No newline at end of file diff -Nru python-cogent-2021.5.7a+dfsg/debian/changelog python-cogent-2021.10.12a1+dfsg/debian/changelog --- python-cogent-2021.5.7a+dfsg/debian/changelog 2021-11-03 10:28:50.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/debian/changelog 2021-11-04 08:29:04.000000000 +0000 @@ -1,3 +1,10 @@ +python-cogent (2021.10.12a1+dfsg-1) unstable; urgency=medium + + * New upstream version + * Upstream switched to filt build system + + -- Andreas Tille Thu, 04 Nov 2021 09:29:04 +0100 + python-cogent (2021.5.7a+dfsg-3) unstable; urgency=medium [ Andreas Tille ] diff -Nru python-cogent-2021.5.7a+dfsg/debian/control python-cogent-2021.10.12a1+dfsg/debian/control --- python-cogent-2021.5.7a+dfsg/debian/control 2021-11-03 10:28:50.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/debian/control 2021-11-04 08:29:04.000000000 +0000 @@ -7,6 +7,7 @@ Priority: optional Build-Depends: debhelper-compat (= 13), dh-python, + flit, python3-all-dev, python3-matplotlib, python3-numba, @@ -15,7 +16,6 @@ python3-scitrack, python3-tqdm, python3-tinydb, - python3-setuptools, python3-sphinx, python3-numpydoc, python3-nbsphinx, diff -Nru python-cogent-2021.5.7a+dfsg/debian/patches/fix_interpreter.patch python-cogent-2021.10.12a1+dfsg/debian/patches/fix_interpreter.patch --- python-cogent-2021.5.7a+dfsg/debian/patches/fix_interpreter.patch 2021-11-03 10:28:50.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/debian/patches/fix_interpreter.patch 2021-11-04 08:29:04.000000000 +0000 @@ -3,14 +3,6 @@ Description: Fix broken interpreter lines Forwarded: not-needed ---- a/src/cogent3/phylo/maximum_likelihood.py -+++ b/src/cogent3/phylo/maximum_likelihood.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env python' -+#!/usr/bin/python3 - from math import exp - - from .least_squares import WLS --- a/src/cogent3/recalculation/__init__.py +++ b/src/cogent3/recalculation/__init__.py @@ -1,4 +1,4 @@ @@ -27,14 +19,6 @@ """Instances of these classes are assigned to different parameter/scopes by a parameter controller""" ---- a/src/cogent3/align/dp_calculation.py -+++ b/src/cogent3/align/dp_calculation.py -@@ -1,4 +1,4 @@ --#!/usr/bin/env/python -+#!/usr/bin/python3 - - import numpy - --- a/src/cogent3/data/molecular_weight.py +++ b/src/cogent3/data/molecular_weight.py @@ -1,4 +1,4 @@ diff -Nru python-cogent-2021.5.7a+dfsg/debian/patches/fix-setuptools-FTBFS.patch python-cogent-2021.10.12a1+dfsg/debian/patches/fix-setuptools-FTBFS.patch --- python-cogent-2021.5.7a+dfsg/debian/patches/fix-setuptools-FTBFS.patch 2021-11-03 10:28:50.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/debian/patches/fix-setuptools-FTBFS.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -Description: Do not put license name in a list, since this causes problems with new setuptools -Author: Nilesh Patra -Last-Update: 2021-11-03 -Forwarded: https://github.com/cogent3/cogent3/issues/979 - ---- a/setup.py -+++ b/setup.py -@@ -59,7 +59,7 @@ - long_description=long_description, - long_description_content_type="text/markdown", - platforms=["any"], -- license=["BSD"], -+ license="BSD", - keywords=[ - "biology", - "genomics", diff -Nru python-cogent-2021.5.7a+dfsg/debian/patches/py39_union_dict python-cogent-2021.10.12a1+dfsg/debian/patches/py39_union_dict --- python-cogent-2021.5.7a+dfsg/debian/patches/py39_union_dict 2021-11-03 10:28:50.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/debian/patches/py39_union_dict 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -From: Michael R. Crusoe -Subject: Add Python 3.9 compatibility -Forwarded: https://github.com/cogent3/cogent3/pull/850 ---- a/src/cogent3/util/union_dict.py -+++ b/src/cogent3/util/union_dict.py -@@ -4,7 +4,7 @@ - import sys - - from cogent3.util.misc import extend_docstring_from -- -+import sys - - __author__ = "Thomas La" - __copyright__ = "Copyright 2007-2021, The Cogent Project" -@@ -71,6 +71,14 @@ class UnionDict(dict): - self.union(other) - return self - -+ if sys.version_info[:2] == (3, 9): -+ def __ror__(self, other): -+ other.union(self) -+ return other -+ -+ def __ior__(self, other): -+ return self.__or__(other) -+ - def union(self, other): - """returns the union of self with other - diff -Nru python-cogent-2021.5.7a+dfsg/debian/patches/series python-cogent-2021.10.12a1+dfsg/debian/patches/series --- python-cogent-2021.5.7a+dfsg/debian/patches/series 2021-11-03 10:28:50.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/debian/patches/series 2021-11-04 08:29:04.000000000 +0000 @@ -1,4 +1,2 @@ sphinx.patch fix_interpreter.patch -py39_union_dict -fix-setuptools-FTBFS.patch diff -Nru python-cogent-2021.5.7a+dfsg/debian/patches/sphinx.patch python-cogent-2021.10.12a1+dfsg/debian/patches/sphinx.patch --- python-cogent-2021.5.7a+dfsg/debian/patches/sphinx.patch 2021-11-03 10:28:50.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/debian/patches/sphinx.patch 2021-11-04 08:29:04.000000000 +0000 @@ -39,13 +39,3 @@ - sphinx-gallery - sphinx_bootstrap_theme - ../ ---- a/setup.py -+++ b/setup.py -@@ -114,7 +114,6 @@ setup( - "pytest>=4.3.0", - "sphinx", - "sphinx-autobuild", -- "sphinxcontrib-bibtex", - "sphinx_panels", - "tox", - ], diff -Nru python-cogent-2021.5.7a+dfsg/debian/rules python-cogent-2021.10.12a1+dfsg/debian/rules --- python-cogent-2021.5.7a+dfsg/debian/rules 2021-11-03 10:28:50.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/debian/rules 2021-11-04 08:29:04.000000000 +0000 @@ -16,6 +16,8 @@ include /usr/share/dpkg/default.mk +export PYBUILD_SYSTEM=flit + %: dh $@ --with python3 --buildsystem=pybuild diff -Nru python-cogent-2021.5.7a+dfsg/doc/app/app-overview.rst python-cogent-2021.10.12a1+dfsg/doc/app/app-overview.rst --- python-cogent-2021.5.7a+dfsg/doc/app/app-overview.rst 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/doc/app/app-overview.rst 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ reader = io.load_aligned(format="fasta", moltype="dna") cpos3 = sample.take_codon_positions(3) - writer = io.write_seqs("path/to/write/thirdpos.zip", format="fasta") + writer = io.write_seqs("path/to/write/thirdpos", format="fasta") Using apps like functions ------------------------- @@ -28,7 +28,7 @@ just3rd = cpos3(data) m = writer(just3rd, identifier="3rdpos_data.fasta") -In the above, ``m`` is a ``DataStoreMember``. The result will be written into the zip archive specified in constructing the ``writer``. +In the above, ``m`` is a ``DataStoreMember``. The result will be written into the directory specified in constructing the ``writer``. Composing a multi-step process from several apps ------------------------------------------------ @@ -52,7 +52,6 @@ Here ``r`` is a list of all the ``DataStoreMember`` instances. - Other important features ------------------------ diff -Nru python-cogent-2021.5.7a+dfsg/doc/app/dstore.rst python-cogent-2021.10.12a1+dfsg/doc/app/dstore.rst --- python-cogent-2021.5.7a+dfsg/doc/app/dstore.rst 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/doc/app/dstore.rst 2021-10-12 00:17:34.000000000 +0000 @@ -71,6 +71,8 @@ The creation of a writeable data store is handled for you by the different writers we provide under ``cogent3.app.io``. +.. warning:: The ``WritableZippedDataStore`` is deprecated. + TinyDB data stores are special ------------------------------ diff -Nru python-cogent-2021.5.7a+dfsg/doc/app/user_function.rst python-cogent-2021.10.12a1+dfsg/doc/app/user_function.rst --- python-cogent-2021.5.7a+dfsg/doc/app/user_function.rst 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/doc/app/user_function.rst 2021-10-12 00:17:34.000000000 +0000 @@ -1,12 +1,12 @@ -Custom composable apps -====================== +Turn your functions into composable apps +======================================== -You can make a simple customised app using the ``user_function`` app. This is a wrapper class that takes a reference to your function and the input, output and data types. The resulting app can then become part of a composed function. +This is super easy -- just use the ``appify`` decorator! This generates a ``user_function`` wrapper class that takes a reference to your function and the input, output and data types. The resulting app can then become part of a composed function. -Defining a ``user_function`` requires you consider four things. +You need four things. ``func`` - A function you have written. This is required. + A function to decorate ... duh! ``input_types`` A type, or collection of type that your function can handle. This setting dictates what other apps have an output that is a compatable input for your function. @@ -20,42 +20,40 @@ A simple example ---------------- -We make a very simple function ``first4``, that returns the first 4 elements of an alignment. +Let's make an app that returns the elements of an alignment up to a specified index, with the index being a keyword argument. We now define a decorated function ``up_to()`` .. jupyter-execute:: - def first4(val): - return val[:4] + from cogent3.app.composable import ALIGNED_TYPE, appify -Now we define a ``user_function`` instance that takes and returns an ``ALIGNED_TYPE``. + @appify(ALIGNED_TYPE, ALIGNED_TYPE, data_types="Alignment") + def up_to(val, index=4): + return val[:index] + +Now we define a ``user_function`` instance that takes and ret +The ``repr()`` of your ``user_function`` instance indicates the wrapped function and the module it's in. .. jupyter-execute:: - from cogent3.app.composable import user_function, ALIGNED_TYPE + up_to - just4 = user_function( - first4, - input_types=ALIGNED_TYPE, - output_types=ALIGNED_TYPE, - data_types="Alignment", - ) - -The ``repr()`` of your ``user_function`` instance indicates the wrapped function and the module it's in. +We create an app instance for a specific value of ``index`` .. jupyter-execute:: - just4 + first4 = up_to(index=4) + first4 -You use it like all composable apps which we demonstrate using a small sample alignment. +You use ``first4()`` like all composable apps, e.g. .. jupyter-execute:: from cogent3 import make_aligned_seqs aln = make_aligned_seqs( - data=dict(a="GCAAGCGTTTAT", b="GCTTTTGTCAAT"), array_align=False + data=dict(a="GCAAGCGTTTAT", b="GCTTTTGTCAAT"), array_align=False, moltype="dna" ) - result = just4(aln) + result = first4(aln) result Renaming sequences @@ -68,46 +66,40 @@ .. jupyter-execute:: from cogent3.app.composable import ( - user_function, ALIGNED_TYPE, SEQUENCE_TYPE, SERIALISABLE_TYPE, + appify, ) - def renamer(aln): + @appify((ALIGNED_TYPE, SEQUENCE_TYPE), SERIALISABLE_TYPE) + def rename_seqs(aln): """upper case names""" return aln.rename_seqs(lambda x: x.upper()) - rename_seqs = user_function( - renamer, - input_types=(ALIGNED_TYPE, SEQUENCE_TYPE), - output_types=SERIALISABLE_TYPE, - data_types=("SequenceCollection", "Alignment", "ArrayAlignment"), - ) - result = rename_seqs(aln) - result.names + renamer = rename_seqs() + result = renamer(aln) + result -A user function for with a different output type ------------------------------------------------- +A user app with a different output type +--------------------------------------- In this example, we make an function that returns ``DistanceMatrix`` of an alignment. .. jupyter-execute:: from cogent3.app.composable import ( - user_function, ALIGNED_TYPE, PAIRWISE_DISTANCE_TYPE, + appify, ) - def _get_dist(aln): - return aln.distance_matrix(calc="hamming", show_progress=False) + @appify(ALIGNED_TYPE, PAIRWISE_DISTANCE_TYPE) + def get_dists(aln, calc="hamming"): + return aln.distance_matrix(calc=calc, show_progress=False) - get_dist = user_function( - _get_dist, - input_types=ALIGNED_TYPE, - output_types=PAIRWISE_DISTANCE_TYPE, - data_types=("Alignment", "ArrayAlignment"), - ) - result = get_dist(aln) - result \ No newline at end of file + percent_dist = get_dists(calc="percent") + result = percent_dist(aln) + result + +.. note:: We omitted the ``data_types`` argument just for demonstration purposes. diff -Nru python-cogent-2021.5.7a+dfsg/doc/conf.py python-cogent-2021.10.12a1+dfsg/doc/conf.py --- python-cogent-2021.5.7a+dfsg/doc/conf.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/doc/conf.py 2021-10-12 00:17:34.000000000 +0000 @@ -69,7 +69,7 @@ project = "cogent3" copyright = f"2020-{year}, cogent3 Team" -release = "2021.5.7a" +release = "2021.10.12a1" version = "" diff -Nru python-cogent-2021.5.7a+dfsg/doc/cookbook/loading_tabular.rst python-cogent-2021.10.12a1+dfsg/doc/cookbook/loading_tabular.rst --- python-cogent-2021.5.7a+dfsg/doc/cookbook/loading_tabular.rst 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/doc/cookbook/loading_tabular.rst 2021-10-12 00:17:34.000000000 +0000 @@ -191,7 +191,7 @@ table["NP_055852", "Region"] -.. note:: The ``index`` argument also applies when using ``make_table()``. +.. note:: The ``index_name`` argument also applies when using ``make_table()``. Create a table from a ``pandas.DataFrame`` ========================================== diff -Nru python-cogent-2021.5.7a+dfsg/doc/cookbook/tables.rst python-cogent-2021.10.12a1+dfsg/doc/cookbook/tables.rst --- python-cogent-2021.5.7a+dfsg/doc/cookbook/tables.rst 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/doc/cookbook/tables.rst 2021-10-12 00:17:34.000000000 +0000 @@ -352,7 +352,7 @@ Get a table of counts as a contingency table ============================================ -If our table consists of counts data, the ``Table`` can convert it into a ``CategoryCount`` instance that can be used for performing basic contingency table statistical tests, e.g. chisquare, G-test of independence, etc.. To do this, we must specify which column contains the row names using the ``index`` argument. +If our table consists of counts data, the ``Table`` can convert it into a ``CategoryCount`` instance that can be used for performing basic contingency table statistical tests, e.g. chisquare, G-test of independence, etc.. To do this, we must specify which column contains the row names using the ``index_name`` argument. .. jupyter-execute:: @@ -369,6 +369,13 @@ g_test = contingency.G_independence() g_test +Alternatively, you could also specify the ``index_name`` of the category column as + +.. jupyter-execute:: + + table = make_table(data={"Ts": [31, 58], "Tv": [36, 138], "": ["syn", "nsyn"]}) + contingency = table.to_categorical(["Ts", "Tv"], index_name="") + Appending tables ================ @@ -770,39 +777,7 @@ from cogent3 import load_table table = load_table("data/stats.tsv") - straight_html = table.to_rich_html(compact=True) - -We can provide customised formatting via a callback function. - -.. jupyter-execute:: - - def format_cell(value, row_num, col_num): - style = 'style="background: rgba(176, 245, 102, 0.25);"' if value else "" - return f"{value}" - - rich_html = table.to_rich_html(row_cell_func=format_cell, compact=False) - -Which produces the following... - -.. jupyter-execute:: - :hide-code: - - from IPython.core.display import HTML - HTML(rich_html) - -We could also use control html element format. - -.. jupyter-execute:: - - element_format = dict(thead=f'') - rich_html = table.to_rich_html(element_formatters=element_format) - -Which produces the following... - -.. jupyter-execute:: - :hide-code: - - HTML(rich_html) + straight_html = table.to_html() What formats can be written? ============================ diff -Nru python-cogent-2021.5.7a+dfsg/doc/doctest_rsts.py python-cogent-2021.10.12a1+dfsg/doc/doctest_rsts.py --- python-cogent-2021.5.7a+dfsg/doc/doctest_rsts.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/doc/doctest_rsts.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,6 +13,7 @@ from cogent3.util.misc import atomic_write + __author__ = "Gavin Huttley" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] diff -Nru python-cogent-2021.5.7a+dfsg/doc/examples/demo-mpi-parallel.py python-cogent-2021.10.12a1+dfsg/doc/examples/demo-mpi-parallel.py --- python-cogent-2021.5.7a+dfsg/doc/examples/demo-mpi-parallel.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/doc/examples/demo-mpi-parallel.py 2021-10-12 00:17:34.000000000 +0000 @@ -4,6 +4,7 @@ from cogent3.util import parallel + # the following environment variable is created by PBS on job execution PBS_NCPUS = os.environ.get("PBS_NCPUS", None) if PBS_NCPUS is None: diff -Nru python-cogent-2021.5.7a+dfsg/.github/workflows/testing_develop.yml python-cogent-2021.10.12a1+dfsg/.github/workflows/testing_develop.yml --- python-cogent-2021.5.7a+dfsg/.github/workflows/testing_develop.yml 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/.github/workflows/testing_develop.yml 2021-10-12 00:17:34.000000000 +0000 @@ -29,7 +29,8 @@ - name: "Installs for ${{ matrix.python-version }}" run: | python --version - python -m pip install --upgrade pip wheel setuptools + python -m pip install --upgrade pip wheel setuptools flit + python -m pip install --upgrade tox tox-gh-actions python -m pip install -r requirements.txt - name: "Run tox targets for ${{ matrix.python-version }}" diff -Nru python-cogent-2021.5.7a+dfsg/.hgignore python-cogent-2021.10.12a1+dfsg/.hgignore --- python-cogent-2021.5.7a+dfsg/.hgignore 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/.hgignore 2021-10-12 00:17:34.000000000 +0000 @@ -31,4 +31,5 @@ __pycache__ junit-*.xml doc/draw* -dist/* \ No newline at end of file +dist/* +working/* \ No newline at end of file diff -Nru python-cogent-2021.5.7a+dfsg/.hgtags python-cogent-2021.10.12a1+dfsg/.hgtags --- python-cogent-2021.5.7a+dfsg/.hgtags 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/.hgtags 2021-10-12 00:17:34.000000000 +0000 @@ -18,3 +18,5 @@ 743ea31a2fdef619b87165267e90a48523e8fceb 2020.12.14a 31dd23a514abd6fc973dfa575387c9cbad2bc27e 2020.12.21a b306abbf306afd5b63932244b816862210bdc371 2021.04.20a +9b3797a262b6c880803b32f7633ae3b9ff831f6c 2021.5.7a +a206748ce4632ae95320494f55612def65d2055c 2021.10.12a diff -Nru python-cogent-2021.5.7a+dfsg/LICENSE python-cogent-2021.10.12a1+dfsg/LICENSE --- python-cogent-2021.5.7a+dfsg/LICENSE 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/LICENSE 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,4 @@ -Copyright 2019-2020 Gavin Huttley +Copyright 2019-2021 Gavin Huttley Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -Nru python-cogent-2021.5.7a+dfsg/MANIFEST.in python-cogent-2021.10.12a1+dfsg/MANIFEST.in --- python-cogent-2021.5.7a+dfsg/MANIFEST.in 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/MANIFEST.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -include MANIFEST.in LICENSE -include requirements.txt -recursive-include src * diff -Nru python-cogent-2021.5.7a+dfsg/pyproject.toml python-cogent-2021.10.12a1+dfsg/pyproject.toml --- python-cogent-2021.5.7a+dfsg/pyproject.toml 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/pyproject.toml 2021-10-12 00:17:34.000000000 +0000 @@ -1,6 +1,111 @@ [build-system] -requires = ["setuptools", "wheel"] -build-backend = "setuptools.build_meta" +requires = ["flit_core >=2,<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.metadata] +module = "cogent3" +author = "Gavin Huttley" +author-email = "Gavin.Huttley@anu.edu.au" +home-page = "https://cogent3.org" +keywords = "biology, genomics, statistics, phylogeny, evolution, bioinformatics" +description-file = "README.md" +license = "BSD-3" +requires-python = ">=3.7" +requires = ["chardet", + "numpy", + "numba>0.48.0;python_version<'3.9'", + "numba>0.53; python_version>='3.9'", + "scitrack", + "tqdm", + "tinydb"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Topic :: Scientific/Engineering :: Bio-Informatics", + "Topic :: Software Development :: Libraries :: Python Modules", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + ] + +[tool.flit.metadata.urls] +Documentation = "https://www.cogent3.org/" +"Bug Tracker" = "https://github.com/cogent3/cogent3/issues" +"Source Code" = "https://github.com/cogent3/cogent3" +Changelog = "https://github.com/cogent3/cogent3/blob/develop/changelog.md" + +[tool.flit.sdist] +include = ["doc/", "requirements.txt", "src/*", "pyproject.toml"] +exclude = ["doc/*.html"] + +[tool.flit.metadata.requires-extra] +test = [ + "black", + "isort", + "pytest", + "pytest-cov", + "tox"] +doc = ["click", + "ipykernel", + "ipython", + "ipywidgets", + "jupyter-sphinx", + "jupyter_client", + "jupyterlab", + "jupytext", + "kaleido", + "matplotlib", + "nbconvert", + "nbconvert!=5.4", + "nbformat", + "nbsphinx", + "numpydoc", + "pillow", + "plotly", + "psutil", + "sphinx", + "sphinx-autobuild", + "sphinx-gallery==0.7", + "sphinx>=1.6", + "sphinx_bootstrap_theme", + "sphinx_panels", + "sphinxcontrib-bibtex<2.0.0"] +extra = ["pandas", "plotly", "psutil", "kaleido"] +dev = ["black", + "click", + "flit", + "ipykernel", + "ipython", + "ipywidgets", + "isort", + "jupyter-sphinx", + "jupyter_client", + "jupyterlab", + "jupytext", + "kaleido", + "matplotlib", + "nbconvert", + "nbconvert!=5.4", + "nbformat", + "nbsphinx", + "numpydoc", + "pandas", + "pillow", + "plotly", + "psutil", + "pytest", + "pytest-cov", + "sphinx", + "sphinx-autobuild", + "sphinx-gallery==0.7", + "sphinx>=1.6", + "sphinx_bootstrap_theme", + "sphinx_panels", + "sphinxcontrib-bibtex", + "sphinxcontrib-bibtex<2.0.0", + "tox"] [tool.pytest.ini_options] testpaths = [ @@ -9,7 +114,7 @@ [tool.black] line-length = 88 -target-version = ['py36', 'py37', 'py38'] +target-version = ['py37', 'py38', 'py39'] exclude = ''' /( \.eggs diff -Nru python-cogent-2021.5.7a+dfsg/README.md python-cogent-2021.10.12a1+dfsg/README.md --- python-cogent-2021.5.7a+dfsg/README.md 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/README.md 2021-10-12 00:17:34.000000000 +0000 @@ -2,7 +2,7 @@ [![codecov](https://codecov.io/gh/cogent3/cogent3/branch/master/graph/badge.svg)](https://codecov.io/gh/cogent3/cogent3) ![Using Black Formatting](https://img.shields.io/badge/code%20style-black-000000.svg) [![Python 3.7+](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/release/python-370/) - +[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/cogent3/cogent3.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/cogent3/cogent3/context:python) ## `cogent3` diff -Nru python-cogent-2021.5.7a+dfsg/requirements.txt python-cogent-2021.10.12a1+dfsg/requirements.txt --- python-cogent-2021.5.7a+dfsg/requirements.txt 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/requirements.txt 2021-10-12 00:17:34.000000000 +0000 @@ -1,5 +1,5 @@ chardet==4.0.0 -pillow==8.2.0 +pillow>=8.3.2 psutil==5.8.0 scipy==1.5.4; python_version < '3.7' scipy==1.6.1; python_version > '3.6' diff -Nru python-cogent-2021.5.7a+dfsg/setup.py python-cogent-2021.10.12a1+dfsg/setup.py --- python-cogent-2021.5.7a+dfsg/setup.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/setup.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -import pathlib -import sys - -from setuptools import find_packages, setup - - -__author__ = "Peter Maxwell" -__copyright__ = "Copyright 2007-2021, The Cogent Project" -__contributors__ = [ - "Peter Maxwell", - "Gavin Huttley", - "Matthew Wakefield", - "Greg Caporaso", - "Daniel McDonald", -] -__license__ = "BSD-3" -__version__ = "2021.5.7a" -__maintainer__ = "Gavin Huttley" -__email__ = "Gavin.Huttley@anu.edu.au" -__status__ = "Production" - -# Check Python version, no point installing if unsupported version inplace -min_version = (3, 7) -if sys.version_info < min_version: - py_version = ".".join(str(n) for n in sys.version_info) - msg = ( - f"Python-{'.'.join(map(str, min_version))} or greater is required, " - f"Python-{py_version} used." - ) - raise RuntimeError(msg) - - -# On windows with no commandline probably means we want to build an installer. -if sys.platform == "win32" and len(sys.argv) < 2: - sys.argv[1:] = ["bdist_wininst"] - - -short_description = "COmparative GENomics Toolkit 3" - -readme_path = pathlib.Path(__file__).parent / "README.md" - -long_description = readme_path.read_text() - -PACKAGE_DIR = "src" - -PROJECT_URLS = { - "Documentation": "https://www.cogent3.org/", - "Bug Tracker": "https://github.com/cogent3/cogent3/issues", - "Source Code": "https://github.com/cogent3/cogent3", -} - -setup( - name="cogent3", - version=__version__, - url="https://github.com/cogent3/cogent3", - author="Gavin Huttley", - author_email="gavin.huttley@anu.edu.au", - description=short_description, - long_description=long_description, - long_description_content_type="text/markdown", - platforms=["any"], - license=["BSD"], - keywords=[ - "biology", - "genomics", - "statistics", - "phylogeny", - "evolution", - "bioinformatics", - ], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: BSD License", - "Topic :: Scientific/Engineering :: Bio-Informatics", - "Topic :: Software Development :: Libraries :: Python Modules", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - ], - packages=find_packages(where="src"), - package_dir={"": PACKAGE_DIR}, - install_requires=[ - "chardet", - "numpy", - "numba>0.48.0;python_version<'3.9'", - "numba>0.53; python_version>='3.9'", - "scitrack", - "tqdm", - "tinydb", - ], - extras_require={ - "dev": [ - "black", - "click", - "ipykernel", - "ipywidgets", - "isort", - "jupyter-sphinx", - "jupyter_client", - "jupyterlab", - "jupytext", - "kaleido", - "nbconvert", - "nbformat", - "nbsphinx", - "numpydoc", - "pandas", - "plotly", - "psutil", - "pytest", - "pytest-cov", - "pytest>=4.3.0", - "sphinx", - "sphinx-autobuild", - "sphinxcontrib-bibtex", - "sphinx_panels", - "tox", - ], - "extra": ["pandas", "plotly", "psutil", "kaleido"], - }, - project_urls=PROJECT_URLS, -) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/align.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/align.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/align.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/align.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/compare_numba.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/compare_numba.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/compare_numba.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/compare_numba.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,27 +1,16 @@ -import numba import numpy as np -from numba import int64, njit -from numba.core.types import List -from numba.core.types.containers import Tuple - __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Stephen Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" -# @njit( -# List(dtype=Tuple(types=(int64, int64)))( -# numba.typeof(b"seq"), numba.typeof(b"seq"), int64, int64, int64, int64 -# ), -# cache=True, -# ) def segments_from_diagonal(seq1, seq2, window, threshold, min_gap_length, diagonal): assert window < 100 scores = np.zeros(window) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/dp_calculation.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/dp_calculation.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/dp_calculation.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/dp_calculation.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,7 +1,3 @@ -#!/usr/bin/env/python - -import numpy - from cogent3.align import indel_model, pairwise from cogent3.maths.markov import SiteClassTransitionMatrix from cogent3.recalculation.definition import ( @@ -9,7 +5,6 @@ CalculationDefn, NonParamDefn, PartitionDefn, - PositiveParamDefn, ProbabilityParamDefn, ) @@ -18,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttleuy" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/indel_model.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/indel_model.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/indel_model.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/indel_model.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/indel_positions.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/indel_positions.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/indel_positions.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/indel_positions.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,10 +1,8 @@ -#!/usr/bin/env python - __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" @@ -31,7 +29,7 @@ class POGBuilder(object): def __init__(self, children): self.children = children - self.remap = [{} for child in children] + self.remap = [{} for _ in children] self.started = [False, False] self.last = [None, None] self.result = [[]] diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Jeremy Widmann", "Gavin Huttley", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/pairwise_pogs_numba.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/pairwise_pogs_numba.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/pairwise_pogs_numba.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/pairwise_pogs_numba.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,7 +1,6 @@ -import numba import numpy as np -from numba import boolean, float64, int32, int64, njit, optional, types, uint8 +from numba import boolean, float64, int64, njit, optional, uint8 from numba.core.types.containers import Tuple @@ -9,7 +8,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Stephen Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -83,21 +82,16 @@ source_row_index_cache = np.zeros(256) N = max(T.shape[0], T.shape[1]) - row_count = plan.shape[0] dest_states = max(0, state_directions.shape[0]) - d4 = max(4, state_directions.shape[1]) row_count = x_index.shape[0] row_length = y_index.shape[0] - bin_count = match_scores.shape[0] max_x = match_scores.shape[1] max_y = match_scores.shape[2] - bin_count = max(xgap_scores.shape[0], bin_count) max_x = max(xgap_scores.shape[1], max_x) - bin_count = max(ygap_scores.shape[0], bin_count) max_y = max(ygap_scores.shape[1], max_y) for i in range(row_count): @@ -108,20 +102,10 @@ assert j_low >= 0 and j_high > j_low and j_high <= row_length - j_link_count = j_sources.shape[0] - row_length1 = row_length + 1 - row_length1 = max(row_length1, j_sources_offsets.shape[0]) - - i_link_count = i_sources.shape[0] - row_count1 = row_count + 1 - row_count1 = max(row_count1, i_sources_offsets.shape[0]) - - tmp_rows = mantissas.shape[0] row_length = max(mantissas.shape[1], row_length) N = max(mantissas.shape[2], N) if use_scaling: - tmp_rows = max(exponents.shape[0], tmp_rows) row_length = max(exponents.shape[1], row_length) N = max(exponents.shape[2], N) @@ -131,8 +115,6 @@ impossible = 0.0 if viterbi and track is not None and track_enc is not None: - row_count = max(track.shape[0], row_count) - row_length = max(track.shape[1], row_length) N = max(track.shape[2], N) (tcode_x, tcode_y, tcode_s) = track_enc else: diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/pairwise.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/pairwise.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/pairwise.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/pairwise.py 2021-10-12 00:17:34.000000000 +0000 @@ -32,7 +32,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" @@ -687,7 +687,7 @@ to_end = numpy.array([(len(T) - 1, 0, 0, 0)]) for (state, (i, j)) in cells: if i > last_i: - rr = pair.calc_rows( + _ = pair.calc_rows( last_i + 1, i + 1, 0, @@ -816,8 +816,6 @@ memory = problem_size * encoder.bytes / 10 ** 6 if dp_options.local: msg = "Local alignment" - elif cells is not None: - msg = "Posterior probs" elif ( self.pair.size[0] - 2 >= 3 and not backward diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/pairwise_seqs_numba.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/pairwise_seqs_numba.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/pairwise_seqs_numba.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/pairwise_seqs_numba.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Stephen Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -81,21 +81,16 @@ MIN_FLOAT_VALUE = 1.0 / SCALE_STEP N = max(T.shape[0], T.shape[1]) - row_count = plan.shape[0] dest_states = max(0, state_directions.shape[0]) - d4 = max(4, state_directions.shape[1]) row_count = x_index.shape[0] row_length = y_index.shape[0] - bin_count = match_scores.shape[0] max_x = match_scores.shape[1] max_y = match_scores.shape[2] - bin_count = max(xgap_scores.shape[0], bin_count) max_x = max(xgap_scores.shape[1], max_x) - bin_count = max(ygap_scores.shape[0], bin_count) max_y = max(ygap_scores.shape[1], max_y) for i in range(row_count): @@ -106,12 +101,10 @@ assert j_low >= 0 and j_high > j_low and j_high <= row_length - tmp_rows = mantissas.shape[0] row_length = max(mantissas.shape[1], row_length) N = max(mantissas.shape[2], N) if use_scaling: - tmp_rows = max(exponents.shape[0], tmp_rows) row_length = max(exponents.shape[1], row_length) N = max(exponents.shape[2], N) @@ -121,8 +114,6 @@ impossible = 0.0 if viterbi and track is not None and track_enc is not None: - row_count = max(track.shape[0], row_count) - row_length = max(track.shape[1], row_length) N = max(track.shape[2], N) (tcode_x, tcode_y, tcode_s) = track_enc else: diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/progressive.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/progressive.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/progressive.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/progressive.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,8 +1,4 @@ -#!/usr/bin/env python - - from cogent3 import make_tree -from cogent3.core.info import Info from cogent3.evolve.distance import EstimateDistances from cogent3.phylo import nj as NJ from cogent3.util import progress_display as UI @@ -12,7 +8,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/pycompare.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/pycompare.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/pycompare.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/pycompare.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/align/traceback.py python-cogent-2021.10.12a1+dfsg/src/cogent3/align/traceback.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/align/traceback.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/align/traceback.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Rob Knight", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/align.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/align.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/align.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/align.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,5 +1,7 @@ import warnings +from bisect import bisect_left + from cogent3 import make_tree from cogent3.align import ( global_pairwise, @@ -8,6 +10,8 @@ ) from cogent3.align.progressive import TreeAlign from cogent3.app import dist +from cogent3.core.alignment import Aligned, Alignment +from cogent3.core.location import gap_coords_to_map from cogent3.core.moltype import get_moltype from cogent3.evolve.models import get_model @@ -25,33 +29,312 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" -class _GapInRef: - """assumes first element of series is reference, returns True if that matches - gap_state""" - - def __init__(self, moltype, gap): - self.gap_state = moltype.alphabet.to_indices(gap)[0] - self.func = self._ref_gap if gap == "-" else self._array_ref_gap +class _GapOffset: + """computes sum of gap lengths preceding a position. Acts like a dict + for getting the offset for an integer key with the __getitem__ returning + the offset. + If your coordinate is an alignment position, set invert=True. + Examples + -------- + From sequence coordinate to an alignment coordinate + + >>> seq2aln = _GapOffset({1:3, 7:1}) + >>> seq_pos = 2 + >>> aln_pos = seq_pos + seq2aln[seq_pos] + >>> aln_pos + 5 + + From alignment coordinate to a sequence coordinate + + >>> aln2seq = _GapOffset({1:3, 7:1}, invert=True) + >>> seq_pos = aln_pos - aln2seq[seq_pos] + >>> seq_pos + 2 + """ - def _ref_gap(self, x): - return x[0] != self.gap_state + def __init__(self, gaps_lengths, invert=False): + """ + Parameters + ---------- + gaps_lengths : dict + {pos: length, ...} where pos is a gap insert position and length + how long the gap is. + invert : bool + if True, query keys are taken as being in alignment coordinates + """ + offset = 0 + min_val = None + result = {} + k = -1 + for k, l in sorted(gaps_lengths.items()): + if invert: + result[k + offset + l] = offset + l + result[k + offset] = offset + else: + result[k] = offset + + offset += l + if min_val is None: + min_val = k + + self._store = result + self.min_pos = min_val + self.max_pos = k + offset if invert else k + self.total = offset + self._ordered = None + self._invert = invert + + def __repr__(self): + return repr(self._store) + + def __str__(self): + return str(self._store) + + def __getitem__(self, k): + if not self._store: + return 0 + + if k in self._store: + return self._store[k] + + if k < self.min_pos: + return 0 + + if k > self.max_pos: + return self.total + + if self._ordered is None: + self._ordered = sorted(self._store) + + # k is definitely bounded by min and max positions here + i = bisect_left(self._ordered, k) + pos = self._ordered[i] + if self._invert: + pos = pos if pos in [k, 0] else self._ordered[i - 1] + return self._store[pos] + + +def _gap_union(seqs) -> dict: + """returns the union of all gaps in seqs""" + seq_name = None + all_gaps = {} + for seq in seqs: + if not isinstance(seq, Aligned): + raise TypeError(f"must be Aligned instances, not {type(seq)}") + if seq_name is None: + seq_name = seq.name + if seq.name != seq_name: + raise ValueError("all sequences must have the same name") + + gaps_lengths = dict(seq.map.get_gap_coordinates()) + all_gaps = _merged_gaps(all_gaps, gaps_lengths) + return all_gaps + + +def _gap_difference(seq_gaps: dict, union_gaps: dict) -> tuple: + """ + + Parameters + ---------- + seq_gaps + {gap pos: length, } of a sequence used to generate the gap union + union_gaps + {gap pos: maximum length, ...} derived from the same seq aligned + to different sequences + + Returns + ------- + gaps missing from seq_gaps, seq_gaps that overlap with union gaps + """ + missing = {} + overlapping = {} + for position, length in union_gaps.items(): + if position not in seq_gaps: + missing[position] = length + elif seq_gaps[position] != length: + overlapping[position] = length - seq_gaps[position] + return missing, overlapping + + +def _merged_gaps(a_gaps: dict, b_gaps: dict) -> dict: + """merges gaps that occupy same position + + Parameters + ---------- + a_gaps, b_gaps + [(gap position, length),...] + + Returns + ------- + Merged places as {gap position: length, ...} + + Notes + ----- + If a_gaps and b_gaps are from the same underlying sequence, set + function to 'max'. Use 'sum' when the gaps derive from different + sequences. + """ + + if not a_gaps: + return b_gaps + + if not b_gaps: + return a_gaps + + places = set(a_gaps) | set(b_gaps) + return { + place: max( + a_gaps.get(place, 0), + b_gaps.get(place, 0), + ) + for place in places + } - def _array_ref_gap(self, x): - return x.flatten()[0] != self.gap_state - def __call__(self, x): - return self.func(x) +def _subset_gaps_to_align_coords( + subset_gaps: dict, orig_gaps: dict, seq_2_aln: _GapOffset +) -> dict: + """compute alignment coords of subset gaps + + Parameters + ---------- + subset_gaps : dict + {position: length delta} lengths are the adjusted gap lengths + orig_gaps : dict + {position: orig length} the original gap lengths are from a pairwise + alignment + seq_2_aln : dict + {seq position: alignment position, ...} + + Returns + ------- + dict + {alignment position + orig length: length delta, ...} + + Notes + ----- + """ + result = {} + for p in subset_gaps: + offset = seq_2_aln[p] + result[offset + p + orig_gaps[p]] = subset_gaps[p] + + return result + + +def _combined_refseq_gaps(seq_gaps: dict, union_gaps: dict) -> dict: + # takes union gaps and refseq gaps, converts into diffs and + # subset diffs + seq2aln = _GapOffset(seq_gaps) + diff_gaps, subset_gaps = _gap_difference(seq_gaps, union_gaps) + align_coord_gaps = _subset_gaps_to_align_coords(subset_gaps, seq_gaps, seq2aln) + align_coord_gaps.update({p + seq2aln[p]: diff_gaps[p] for p in diff_gaps}) + return align_coord_gaps + + +def _gaps_for_injection(other_seq_gaps: dict, refseq_gaps: dict, seqlen: int) -> dict: + """projects refseq aligned gaps into otherseq + + Parameters + ---------- + other_seq_gaps : dict + {gap in other seq position: gap length} + refseq_gaps : dict + {gap as alignment position: gap length} + seqlen : int + length of sequence being injected into + + Returns + ------- + dict + {gap in other seq position: gap length} + """ + aln2seq = _GapOffset(other_seq_gaps, invert=True) + # to inject a gap means to convert it from alignment coordinates into + # sequence coordinates + # we probably need to include the refseq gap union because we need to + # establish whether a refseq gap overlaps with a gap in other seq + # and + all_gaps = {} + all_gaps.update(other_seq_gaps) + for gap_pos, gap_length in sorted(refseq_gaps.items()): + offset = aln2seq[gap_pos] + gap_pos -= offset + gap_pos = min(seqlen, gap_pos) + if gap_pos < 0: + raise ValueError( + f"computed gap_pos {gap_pos} < 0, correct reference sequence?" + ) + if gap_pos in all_gaps: + gap_length += all_gaps[gap_pos] + + all_gaps[gap_pos] = gap_length + + return all_gaps + + +def pairwise_to_multiple(pwise, ref_seq, moltype, info=None): + """ + turns pairwise alignments to a reference into a multiple alignment + + Parameters + ---------- + pwise + Series of pairwise alignments to ref_seq as + [(non-refseq name, aligned pair), ...] + ref_seq + The sequence common in all pairwise alignments + moltype + molecular type for the returned alignment + info + info object + + Returns + ------- + ArrayAlign + """ + if not hasattr(ref_seq, "name"): + raise TypeError(f"ref_seq must be a cogent3 sequence, not {type(ref_seq)}") + + refseqs = [s for _, aln in pwise for s in aln.seqs if s.name == ref_seq.name] + ref_gaps = _gap_union(refseqs) + + m = gap_coords_to_map(ref_gaps, len(ref_seq)) + aligned = [Aligned(m, ref_seq)] + for other_name, aln in pwise: + curr_ref = aln.named_seqs[ref_seq.name] + curr_ref_gaps = dict(curr_ref.map.get_gap_coordinates()) + other_seq = aln.named_seqs[other_name] + other_gaps = dict(other_seq.map.get_gap_coordinates()) + diff_gaps = _combined_refseq_gaps(curr_ref_gaps, ref_gaps) + inject = _gaps_for_injection(other_gaps, diff_gaps, len(other_seq.data)) + if inject: + m = gap_coords_to_map(inject, len(other_seq.data)) + other_seq = Aligned(m, other_seq.data) + + aligned.append(other_seq) + # default to ArrayAlign + return Alignment(aligned, moltype=moltype, info=info).to_type( + array_align=True, moltype=moltype + ) class align_to_ref(ComposableSeq): - """Aligns to a reference seq, no gaps in the reference. - Returns an Alignment object.""" + """Aligns sequences to a nominated reference in the unaligned collection. + This is much faster, and requires much less memory, than progressive_align + but the quality will likely be lower. Alignment quality will be strongly + affected by choice of reference. + + Returns + ------- + ArrayAlignment. + """ _input_types = SEQUENCE_TYPE _output_types = (ALIGNED_TYPE, SERIALISABLE_TYPE) @@ -122,27 +405,16 @@ seqs = seqs.to_moltype(self._moltype) ref_seq = seqs.get_seq(self._ref_name) - aligned = None kwargs = self._kwargs.copy() - no_ref_gap = None - - for i in range(seqs.num_seqs): - seq = seqs.seqs[i] + pwise = [] + for seq in seqs.seqs: if seq.name == self._ref_name: continue - result = global_pairwise(ref_seq, seq, **kwargs) - if no_ref_gap is None: - no_ref_gap = _GapInRef(result.moltype, seqs.moltype.gap) - - # as we're going to be using a pairwise distance that excludes gaps - # eliminating positions with deletions in the reference - result = result.filtered(no_ref_gap) - aligned = result if aligned is None else aligned.add_from_ref_aln(result) - - # default to ArrayAlign - new = aligned.to_type(array_align=True, moltype=self._moltype) - return new + aln = global_pairwise(ref_seq, seq, **kwargs).to_type(array_align=False) + pwise.append(((seq.name, aln))) + + return pairwise_to_multiple(pwise, ref_seq, self._moltype, info=seqs.info) class progressive_align(ComposableSeq): diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/composable.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/composable.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/composable.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/composable.py 2021-10-12 00:17:34.000000000 +0000 @@ -28,7 +28,6 @@ DataStoreMember, SingleReadDataStore, WritableDirectoryDataStore, - WritableZippedDataStore, ) @@ -36,7 +35,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -45,9 +44,7 @@ def _make_logfile_name(process): text = str(process) text = re.split(r"\s+\+\s+", text) - parts = [] - for part in text: - parts.append(part[: part.find("(")]) + parts = [part[: part.find("(")] for part in text] result = "-".join(parts) pid = os.getpid() result = f"{result}-pid{pid}.log" @@ -423,33 +420,34 @@ dstore = [dstore] dstore = [e for e in dstore if e] - if len(dstore) == 0: + if not dstore: raise ValueError("dstore is empty") start = time.time() loggable = hasattr(self, "data_store") - if not loggable: + if ( + not loggable + or type(logger) != scitrack.CachingLogger + and type(logger) != str + and logger != True + ): LOGGER = None elif type(logger) == scitrack.CachingLogger: LOGGER = logger elif type(logger) == str: LOGGER = scitrack.CachingLogger LOGGER.log_file_path = logger - elif logger == True: + else: log_file_path = pathlib.Path(_make_logfile_name(self)) src = pathlib.Path(self.data_store.source) log_file_path = src.parent / log_file_path LOGGER = scitrack.CachingLogger() LOGGER.log_file_path = str(log_file_path) - else: - LOGGER = None - if LOGGER: LOGGER.log_message(str(self), label="composable function") LOGGER.log_versions(["cogent3"]) results = [] - i = 0 - process = self.input if self.input else self + process = self.input or self if self.input: # As we will be explicitly calling the input object, we disconnect # the two-way interaction between input and self. This means self @@ -461,8 +459,10 @@ # with a tinydb dstore, this also excludes data that failed to complete todo = [m for m in dstore if not self.job_done(m)] - for result in ui.imap( - process, todo, parallel=parallel, par_kw=par_kw, mininterval=mininterval + for i, result in enumerate( + ui.imap( + process, todo, parallel=parallel, par_kw=par_kw, mininterval=mininterval + ) ): outcome = result if process is self else self(result) results.append(outcome) @@ -497,8 +497,6 @@ f"{outcome.origin} : {outcome.message}", label=outcome.type ) - i += 1 - finish = time.time() taken = finish - start if LOGGER: @@ -636,14 +634,7 @@ ), "invalid value for if_exists" self._if_exists = if_exists - if writer_class: - klass = writer_class - else: - klass = ( - WritableZippedDataStore - if data_path.endswith(".zip") - else WritableDirectoryDataStore - ) + klass = writer_class or WritableDirectoryDataStore self.data_store = klass( data_path, suffix=suffix, create=create, if_exists=if_exists ) @@ -703,14 +694,14 @@ If you create a function ``foo(arg1, arg2, kwarg1=False)``. You can turn this into a user function, e.g. - >>> ufunc = user_function(foo, in_types, out_types, arg2val, kwarg1=True) + >>> ufunc = user_function(foo, in_types, out_types, arg1val, kwarg1=True) Then - >>> ufunc(val) == foo(val, arg2val, kwarg1=True) + >>> ufunc(arg2val) == foo(arg1val, arg2val, kwarg1=True) """ super(user_function, self).__init__( - input_types=input_types, output_types=output_types + input_types=input_types, output_types=output_types, data_types=data_types ) self._user_func = func self._args = args @@ -747,3 +738,47 @@ def __repr__(self): return str(self) + + +class appify: + """function decorator for generating user apps. Simplifies creation of + user_function() instancese, e.g. + + >>> @appify(SEQUENCE_TYPE, SEQUENCE_TYPE, data_types="SequenceCollection") + ... def omit_seqs(seqs, quantile=None, gap_fraction=1, moltype="dna"): + ... return seqs.omit_bad_seqs(quantile=quantile, gap_fraction=gap_fraction, moltype="dna") + ... + + `omit_seqs()` is now an app factory, allowing creating variants of the app. + + >>> omit_bad = omit_seqs(quantile=0.95) + + omit_bad is now a composable user_function app. Calling with different + args/kwargs values returns a variant app, as per the behaviour of builtin + apps. + """ + + @extend_docstring_from(ComposableType.__init__) + def __init__(self, input_types, output_types, data_types=None) -> None: + self._it = input_types + self._ot = output_types + self._dt = data_types + self._func = None + + def __call__(self, func): + # executed on use as decorator + self._func = func + # makes the returned reference have the name, docs etc. + # of original function + self._make_app.__func__.__doc__ = f"appify: {func.__doc__}" + self._make_app.__func__.__repr__ = lambda x: repr(func) + self._make_app.__func__.__name__ = func.__name__ + self._make_app.__func__.__module__ = func.__module__ + + return self._make_app + + def _make_app(self, *args, **kwargs): + # construct the user_function app + return user_function( + self._func, self._it, self._ot, *args, data_types=self._dt, **kwargs + ) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/data_store.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/data_store.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/data_store.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/data_store.py 2021-10-12 00:17:34.000000000 +0000 @@ -36,7 +36,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -507,20 +507,29 @@ record = json.dumps(record) self.write(identifier, record) - def write(self, *args, **kwargs): + def write(self, identifier, data, *args, **kwargs): """ Parameters ---------- identifier : str - identifier that data wil be saved under + identifier that data will be saved under. Must have a suffix matching + self.suffix or ``.log``. data - data to be saved + data to be saved. If a tinydb, must be an object that can be + converted to json, or has a to_json() method. Otherwise, it must be a string. Returns ------- DataStoreMember instance """ - raise NotImplementedError + if not isinstance(data, str): + raise TypeError(f"data must be a string type, not {type(data)}") + + id_suffix = identifier.split(".")[-1] + if id_suffix not in (self.suffix, "log"): + raise ValueError( + f"identifier does not end with required suffix {self.suffix}" + ) def close(self): pass @@ -587,104 +596,20 @@ @extend_docstring_from(WritableDataStoreBase.write) def write(self, identifier, data): - relative_id = self.get_relative_identifier(identifier) - absolute_id = self.get_absolute_identifier(relative_id, from_relative=True) - - if self._md5: - self._checksums[absolute_id] = get_text_hexdigest(data) - - with atomic_write(str(absolute_id), in_zip=False) as out: - out.write(data) - - member = DataStoreMember(relative_id, self) - if relative_id not in self and relative_id.endswith(self.suffix): - self._members.append(member) - - return member - - -class WritableZippedDataStore(ReadOnlyZippedDataStore, WritableDataStoreBase): - def __init__( - self, - source, - suffix, - mode="a", - if_exists=RAISE, - create=False, - md5=True, - **kwargs, - ): - """ - Parameters - ---------- - source - path to directory / zip file - suffix - only members whose name matches the suffix are considered included - mode : str - file opening mode, defaults to append - if_exists : str - behaviour when the destination already exists. Valid constants are - defined in this file as OVERWRITE, SKIP, RAISE, IGNORE (they - correspond to lower case version of the same word) - create : bool - if True, the destination is created - md5 : bool - record md5 hexadecimal checksum of data when possible - """ - from cogent3.util.warning import discontinued - - discontinued( - "class", - self.__class__.__name__, - "2021.10.01", - reason="zips are not efficient for incremental inclusion of files, use a tinydb instead", - ) - - ReadOnlyZippedDataStore.__init__(self, source=source, suffix=suffix, md5=md5) - WritableDataStoreBase.__init__(self, if_exists=if_exists, create=create) - - d = locals() - self._persistent = {k: v for k, v in d.items() if k != "self"} - self.mode = "a" or mode - - def _has_other_suffixes(self, path, suffix): - allowed = {str(suffix), "log"} - for f in zipfile.ZipFile(path).namelist(): - if get_format_suffixes(str(f))[0] not in allowed: - return True - return False - - def _source_create_delete(self, if_exists, create): - if not is_master_process(): - return - exists = os.path.exists(self.source) - dirname = os.path.dirname(self.source) - if exists and if_exists == RAISE: - raise FileExistsError(f"'{self.source}' exists") - elif exists and if_exists == OVERWRITE: - if self._has_other_suffixes(self.source, self.suffix): - raise RuntimeError( - f"Unsafe to delete {self.source} as it contains ", - f"files other than .{self.suffix} or .log files." - " You will need to remove this directly yourself.", - ) - os.remove(self.source) - elif dirname and not os.path.exists(dirname) and not create: - raise FileExistsError(f"'{dirname}' does not exist") - - if create and dirname: - os.makedirs(dirname, exist_ok=True) + super().write(identifier, data) + id_suffix = identifier.split(".")[-1] + if id_suffix not in (self.suffix, "log"): + raise ValueError( + f"identifier does not end with required suffix {self.suffix}" + ) - @extend_docstring_from(WritableDataStoreBase.write) - def write(self, identifier, data): relative_id = self.get_relative_identifier(identifier) absolute_id = self.get_absolute_identifier(relative_id, from_relative=True) if self._md5: self._checksums[absolute_id] = get_text_hexdigest(data) - with atomic_write(str(relative_id), in_zip=self.source) as out: + with atomic_write(str(absolute_id), in_zip=False) as out: out.write(data) member = DataStoreMember(relative_id, self) @@ -1028,6 +953,15 @@ @extend_docstring_from(WritableDataStoreBase.write) def write(self, identifier, data): + # writing into a tinydb has its own logic for conversion to json + # so we don't validate data is a string for this case + super().write(identifier, "") + id_suffix = identifier.split(".")[-1] + if id_suffix not in (self.suffix, "log"): + raise ValueError( + f"identifier does not end with required suffix {self.suffix}" + ) + matches = self.filtered(identifier) if matches: return matches[0] diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/dist.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/dist.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/dist.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/dist.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,6 +11,7 @@ ALIGNED_TYPE, PAIRWISE_DISTANCE_TYPE, SERIALISABLE_TYPE, + TABULAR_TYPE, ComposableDistance, ) @@ -19,7 +20,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -33,7 +34,7 @@ """ _input_types = ALIGNED_TYPE - _output_types = (PAIRWISE_DISTANCE_TYPE, SERIALISABLE_TYPE) + _output_types = (PAIRWISE_DISTANCE_TYPE, TABULAR_TYPE, SERIALISABLE_TYPE) _data_types = ("ArrayAlignment", "Alignment") def __init__(self, distance=None, moltype=None, fast_calc=None, slow_calc=None): @@ -121,6 +122,7 @@ else: empty = {p: 0 for p in itertools.product(aln.names, aln.names)} dists = DistanceMatrix(empty) + dists.source = aln.info.source if self._sm: for a in dists.template.names[0]: for b in dists.template.names[1]: diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/evo.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/evo.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/evo.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/evo.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,8 +1,5 @@ -import os import warnings -from tqdm import tqdm - from cogent3 import load_tree, make_tree from cogent3.core.tree import TreeNode from cogent3.evolve.models import get_model @@ -34,7 +31,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -352,7 +349,7 @@ def test_hypothesis(self, aln): try: null = self.null(aln) - except ValueError as err: + except ValueError: msg = f"Hypothesis null had bounds error {aln.info.source}" return NotCompleted("ERROR", self, msg, source=aln) @@ -361,7 +358,7 @@ try: alts = [alt for alt in self._initialised_alt(null, aln)] - except ValueError as err: + except ValueError: msg = f"Hypothesis alt had bounds error {aln.info.source}" return NotCompleted("ERROR", self, msg, source=aln) @@ -389,7 +386,7 @@ class bootstrap(ComposableHypothesis): """Parametric bootstrap for a provided hypothesis. Returns a bootstrap_result.""" - _input_types = ALIGNED_TYPE + _input_types = (ALIGNED_TYPE, SERIALISABLE_TYPE) _output_types = (RESULT_TYPE, BOOTSTRAP_RESULT_TYPE, SERIALISABLE_TYPE) _data_types = ("ArrayAlignment", "Alignment") diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,14 +1,12 @@ import importlib import inspect -from warnings import filterwarnings - __author__ = "Gavin Huttley" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/io.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/io.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/io.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/io.py 2021-10-12 00:17:34.000000000 +0000 @@ -21,6 +21,7 @@ from .composable import ( ALIGNED_TYPE, IDENTIFIER_TYPE, + PAIRWISE_DISTANCE_TYPE, SEQUENCE_TYPE, SERIALISABLE_TYPE, TABULAR_RESULT_TYPE, @@ -31,6 +32,7 @@ ComposableTabular, NotCompleted, _checkpointable, + _get_source, ) from .data_store import ( IGNORE, @@ -51,7 +53,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -145,7 +147,7 @@ return seqs -class load_aligned(_seq_loader, ComposableAligned): +class load_aligned(ComposableAligned, _seq_loader): """Loads aligned sequences. Returns an Alignment object.""" klass = ArrayAlignment @@ -163,7 +165,7 @@ format : str sequence file format """ - super(ComposableAligned, self).__init__( + super(load_aligned, self).__init__( input_types=self._input_types, output_types=self._output_types, data_types=self._data_types, @@ -194,7 +196,7 @@ format : str sequence file format """ - super(ComposableSeq, self).__init__( + super(load_unaligned, self).__init__( input_types=self._input_types, output_types=self._output_types, data_types=self._data_types, @@ -238,7 +240,7 @@ strict all rows MUST have the same number of records """ - super(ComposableTabular, self).__init__( + super(load_tabular, self).__init__( input_types=self._input_types, output_types=self._output_types, data_types=self._data_types, @@ -306,7 +308,7 @@ try: header, data, title = self._parse(path) except Exception as err: - result = NotCompleted("ERROR", self, err.args[0], source=str(path)) + return NotCompleted("ERROR", self, err.args[0], source=str(path)) if self.as_type == "table": return Table(header=header, data=data, title=title) @@ -330,7 +332,7 @@ class write_tabular(_checkpointable, ComposableTabular): """writes tabular data""" - _input_types = (TABULAR_RESULT_TYPE, TABULAR_TYPE) + _input_types = (TABULAR_RESULT_TYPE, TABULAR_TYPE, PAIRWISE_DISTANCE_TYPE) _output_types = IDENTIFIER_TYPE _data_types = ("Table", "DictArray", "DistanceMatrix") @@ -579,6 +581,25 @@ self._load_checkpoint = self def write(self, data, identifier=None): + """ + + Parameters + ---------- + data + object that has a `to_json()` method, or can be json serialised + identifier : str + if not provided, taken from data.source or data.info.source + + Returns + ------- + identifier + """ + data_source = _get_source(data) + if (data_source and identifier is not None) and str(data_source) != str( + identifier + ): + raise ValueError(f"identifier {identifier} != data source {data_source}") + if identifier is None: identifier = self._make_output_identifier(data) # todo revisit this when we establish immutability behaviour of database diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/result.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/result.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/result.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/result.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -67,7 +67,8 @@ def __repr__(self): name = self.__class__.__name__ num = len(self) - types = [f"{repr(k)}: {self[k].__class__.__name__}" for k in self.keys()[:4]] + types = [f"{repr(k)}: {self[k].__class__.__name__}" for k in self] + types = types[:3] + ["..."] if num > 5 else types types = ", ".join(types) return f"{num}x {name}({types})" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/sample.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/sample.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/sample.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/sample.py 2021-10-12 00:17:34.000000000 +0000 @@ -22,7 +22,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -74,10 +74,25 @@ data series of alignment instances """ - names = self._name_callback(list(aln.names for aln in data)) + if len(data) == 0: + raise ValueError("no data") + + names = [] + for aln in data: + if not (isinstance(aln, ArrayAlignment) or isinstance(aln, Alignment)): + raise TypeError(f"{type(aln)} invalid for concat") + names.append(aln.names) + + names = self._name_callback(names) collated = defaultdict(list) + if self._moltype is None: + self._moltype = aln.moltype + for aln in data: - assert isinstance(aln, ArrayAlignment) or isinstance(aln, Alignment) + if self._moltype and aln.moltype != self._moltype: + # try converting + aln = aln.to_moltype(self.moltype) + if self._intersect: seqs = aln.take_seqs(names).to_dict() else: diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/translate.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/translate.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/translate.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/translate.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/app/tree.py python-cogent-2021.10.12a1+dfsg/src/cogent3/app/tree.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/app/tree.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/app/tree.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -147,18 +147,14 @@ size = dists.shape[0] dists = dists.drop_invalid() if self._drop_invalid else dists if dists is None or (dists.shape[0] != size and not self._drop_invalid): - msg = ( - f"some pairwise distances could not be computed with" - " {self._distance}, pick a different distance" - ) - raise ValueError(msg) + raise ValueError("invalid pairwise distances") # how many species do we have - species = dists.keys() - if len(species) == 2: - dist = list(dists.values())[0] / 2.0 - treestring = "(%s:%.4f,%s:%.4f)" % (species[0], dist, species[1], dist) - tree = make_tree(treestring=treestring, underscore_unmunge=True) + if size == 2: + dist = dists.array[0, 1] / 2.0 + newick = ",".join(f"{sp}:{dist:.4f}" for sp in dists.names) + newick = f"({newick})" + tree = make_tree(treestring=newick, underscore_unmunge=True) else: (result,) = gnj(dists.to_dict(), keep=1, show_progress=False) (score, tree) = result diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/cluster/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/cluster/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/cluster/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/cluster/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Catherine Lozuopone", "Rob Knight", "Peter Maxwell", "Justin Kuczynski"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Catherine Lozupone" __email__ = "lozupone@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/cluster/UPGMA.py python-cogent-2021.10.12a1+dfsg/src/cogent3/cluster/UPGMA.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/cluster/UPGMA.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/cluster/UPGMA.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ import numpy -from numpy import argmin, array, average, diag, ma, ravel, sum, take +from numpy import argmin, average, diag, ravel, take from cogent3.core.tree import PhyloNode from cogent3.util.dict_array import DictArray @@ -22,7 +22,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Catherine Lozuopone", "Rob Knight", "Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Catherine Lozupone" __email__ = "lozupone@colorado.edu" __status__ = "Production" @@ -150,7 +150,7 @@ if index1 == index2: matrix[diag([True] * len(matrix))] = large_number smallest_index = find_smallest_index(matrix) - row_order = condense_node_order(matrix, smallest_index, node_order) + _ = condense_node_order(matrix, smallest_index, node_order) matrix = condense_matrix(matrix, smallest_index, large_number) tree = node_order[smallest_index[0]] return tree diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/alignment.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/alignment.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/alignment.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/alignment.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Code for handling multiple sequence alignments. In particular: - SequenceCollection handles both aligned and unaligned sequences. @@ -92,7 +91,7 @@ "Jan Kosinski", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -211,7 +210,7 @@ def gap_run_ok(self, seq): """runs of gaps <= allowed_run""" - curr_run = max_run = 0 + curr_run = 0 is_gap = self.gap_chars.__contains__ result = True for i in seq: @@ -236,22 +235,6 @@ return ["%s_%s" % (base_name, i) for i in range(start_at, start_at + num_seqs)] -class SeqLabeler(object): - """Allows flexible seq labeling in to_fasta().""" - - def __init__(self, aln, label_f=assign_sequential_names, **kwargs): - """Initializes a new seq labeler.""" - self._aln = aln - self._label_f = label_f - self._map = { - orig: new for orig, new in zip(aln.names, label_f(len(aln.names, **kwargs))) - } - - def __call__(self, s): - """Returns seq name from seq id""" - return self._map[s.name] - - def coerce_to_string(s): """Converts an arbitrary sequence into a string.""" if isinstance(s, str): # if it's a string, OK as is @@ -674,10 +657,9 @@ # if we got names from the sequences, but otherwise assign the # names to successive sequences in order if (names is None) or (None in names): - per_seq_names = name_order = name_order + per_seq_names = name_order else: # got names from seqs, so assume name_order is in Names per_seq_names = names - name_order = name_order # check for duplicate names duplicates, fixed_names, fixed_seqs = self._strip_duplicates( @@ -905,13 +887,12 @@ # TODO handle case of not strict by building mask of degen positions # per seq if mask_degen and not hasattr(self.moltype, "alphabets"): - UserWarning( - "in get_identical_sets, strict has no effect as moltype " - "has no degenerate characters" + warnings.warn( + "in get_identical_sets, mask_degen has no effect as moltype " + f"{self.moltype.label!r} has no degenerate characters", + UserWarning, ) mask_degen = False - elif mask_degen: - degens = list(self.moltype.degenerates) + [self.moltype.gap] def reduced(seq, indices): s = "".join(seq[i] for i in range(len(seq)) if i not in indices) @@ -1102,7 +1083,7 @@ """ return alignment_to_fasta(self.to_dict()) - def to_nexus(self, seq_type, wrap=50, interleave_len=None): + def to_nexus(self, seq_type, wrap=50): """ Return alignment in NEXUS format and mapping to sequence ids @@ -1114,12 +1095,6 @@ Raises exception if invalid alignment """ - if interleave_len is not None: - cogent3.util.warning.deprecated( - "argument", "interleave_len", "wrap", "2021.6" - ) - wrap = interleave_len - return nexus_from_alignment(self, seq_type, wrap=wrap) @property @@ -1747,7 +1722,9 @@ from cogent3.draw.dotplot import Dotplot from cogent3.draw.drawable import AnnotatedDrawable - if name1 is None and name2 is None: + if len(self.names) == 1: + name1 = name2 = self.names[0] + elif name1 is None and name2 is None: name1, name2 = list(choice(self.names, size=2, replace=False)) elif not (name1 and name2): names = list(set(self.names + [None]) ^ set([name1, name2])) @@ -2803,7 +2780,6 @@ def to_html( self, name_order=None, - interleave_len=None, wrap=60, limit=None, ref_name="longest", @@ -2817,10 +2793,8 @@ ---------- name_order order of names for display. - interleave_len - will be replaced by wrap in version 2021.6 wrap - number of alignment columns per row, old name is interleave_len + number of alignment columns per row limit truncate alignment to this length ref_name @@ -2841,12 +2815,6 @@ >>> from IPython.core.display import HTML >>> HTML(aln.to_html()) """ - if interleave_len is not None: - cogent3.util.warning.deprecated( - "argument", "interleave_len", "wrap", "2021.6" - ) - wrap = interleave_len if wrap == 60 else wrap - css, styles = self.moltype.get_css_style( colors=colors, font_size=font_size, font_family=font_family ) @@ -2968,24 +2936,16 @@ ] return "\n".join(text) - def to_pretty(self, name_order=None, wrap=None, interleave_len=None): + def to_pretty(self, name_order=None, wrap=None): """returns a string representation of the alignment in pretty print format Parameters ---------- name_order order of names for display. - interleave_len - will be replaced by wrap in version 2021.6 wrap - maximum number of printed bases, old name is interleave_len + maximum number of printed bases """ - if interleave_len is not None: - cogent3.util.warning.deprecated( - "argument", "interleave_len", "wrap", "2021.6" - ) - wrap = interleave_len - names, output = self._get_raw_pretty(name_order=name_order) label_width = max(list(map(len, names))) name_template = "{:>%d}" % label_width @@ -3136,19 +3096,13 @@ column are ignored. """ - seqs = [str(self.named_seqs[n]) for n in self.names] - seq1 = seqs[0] - positions = list(zip(*seqs[1:])) + gaps = set(self.moltype.gaps) result = [] - for (position, (motif1, column)) in enumerate(zip(seq1, positions)): - for motif in column: - if motif != motif1: - if include_gap_motif: - result.append(position) - break - elif motif != "-" and motif1 != "-": - result.append(position) - break + for position, column in enumerate(self.iter_positions()): + column = set(column) + num_states = len(column) if include_gap_motif else len(column - gaps) + if num_states > 1: + result.append(position) return result @@ -3263,7 +3217,7 @@ else: subaln = self - for i in ui.series(range(bootstrap), count=bootstrap, noun="bootstrap"): + for _ in ui.series(range(bootstrap), count=bootstrap, noun="bootstrap"): b = subaln.sample(with_replacement=True) try: bdist = b.distance_matrix( @@ -3611,7 +3565,7 @@ WARNING: Data type of return array is not guaranteed -- check in caller! """ - result = array(list(map(alphabet.to_indices, data))) + result = array([alphabet.to_indices(v) for v in data], dtype=object).astype(int) names = [] for d in data: if hasattr(d, "name"): @@ -3907,8 +3861,6 @@ Should be able to handle joint alphabets, e.g. codons. """ result = [] - names = list(map(str, self.names)) - max_label_length = max(list(map(len, names))) + 1 seq2str = self.alphabet.from_indices for l, s in zip(self.names, self.array_seqs): result.append(">" + str(l) + "\n" + "".join(seq2str(s))) @@ -4283,12 +4235,12 @@ ---------- mask_degen if True, degenerate characters are ignored - """ if mask_degen and not hasattr(self.moltype, "alphabets"): - UserWarning( - "in get_identical_sets, strict has no effect as moltype " - "has no degenerate characters" + warnings.warn( + "in get_identical_sets, mask_degen has no effect as moltype " + f"{self.moltype.label!r} has no degenerate characters", + UserWarning, ) mask_degen = False @@ -4393,17 +4345,13 @@ # check if gap runs bad if ( b"\x01" * gap_run - in logical_and(seq_gaps, logical_not(template_gaps)) - .astype(uint8) - .tostring() + in logical_and(seq_gaps, logical_not(template_gaps)).astype(uint8).tobytes() ): return False # check if insertion runs bad elif ( b"\x01" * gap_run - in logical_and(template_gaps, logical_not(seq_gaps)) - .astype(uint8) - .tostring() + in logical_and(template_gaps, logical_not(seq_gaps)).astype(uint8).tobytes() ): return False return True @@ -4440,7 +4388,7 @@ aligned_seqs.append(s) else: aligned_seqs.append(self._seq_to_aligned(s, n)) - self.named_seqs = self.named_seqs = dict(list(zip(names, aligned_seqs))) + self.named_seqs = dict(list(zip(names, aligned_seqs))) self.seq_data = self._seqs = aligned_seqs def _coerce_seqs(self, seqs, is_array): diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/alphabet.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/alphabet.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/alphabet.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/alphabet.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ alphabet.py @@ -18,8 +17,6 @@ """ import json -import re -import string from itertools import product @@ -32,7 +29,6 @@ frombuffer, newaxis, ravel, - remainder, sum, take, transpose, @@ -42,7 +38,7 @@ zeros, ) -from cogent3.util.misc import bytes_to_string, get_object_provenance +from cogent3.util.misc import get_object_provenance Float = numpy.core.numerictypes.sctype2char(float) @@ -52,7 +48,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Rob Knight", "Andrew Butterfield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -182,7 +178,6 @@ accidentally use negative numbers as indices (this is very bad when doing indexed lookups). """ - data = data or [] self.moltype = moltype # check if motif lengths are homogeneous -- if so, set length @@ -620,7 +615,6 @@ Raises an AttributeError if MolType is not set. """ - result = "" return self.moltype.make_seq("".join(self[i] for i in data)) def get_matched_array(self, motifs, dtype=Float): diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/annotation.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/annotation.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/annotation.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/annotation.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -80,7 +80,6 @@ ) for base in containers: feature = feature.remapped_to(base, base.map) - index = map else: map = as_map(index, len(self)) return map @@ -290,8 +289,12 @@ return json.dumps(self.to_rich_dict()) +# https://pythonspeed.com/products/filmemoryprofiler/ + + class _Feature(_Annotatable, _Serialisable): qualifier_names = ["type", "name"] + __slots__ = ["parent", "map", "original", "_serialisable", "base", "base_map"] def __init__(self, parent, map, original=None, **kw): d = locals() diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/genetic_code.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/genetic_code.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/genetic_code.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/genetic_code.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Greg Caporaso", "Rob Knight", "Peter Maxwell", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Greg Caporaso" __email__ = "caporaso@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/info.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/info.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/info.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/info.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Prototype" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ "Greg Caporaso", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/location.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/location.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/location.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/location.py 2021-10-12 00:17:34.000000000 +0000 @@ -56,7 +56,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Peter Maxwell", "Matthew Wakefield", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Prototype" @@ -141,7 +141,7 @@ """Returns length of self.""" raise NotImplementedError - def __lt__(self): + def __lt__(self, other): """Compares indices of self with indices of other.""" raise NotImplementedError @@ -713,6 +713,18 @@ spans = [s.reversed_relative_to(self.parent_length) for s in self.spans] return Map(spans=spans, parent_length=self.parent_length) + def get_gap_coordinates(self): + """returns [(gap pos, gap length), ...]""" + gap_pos = [] + for i, span in enumerate(self.spans): + if not span.lost: + continue + + pos = self.spans[i - 1].end if i else 0 + gap_pos.append((pos, len(span))) + + return gap_pos + def gaps(self): """The gaps (lost spans) in this map""" locations = [] @@ -1046,3 +1058,38 @@ else: result.spans.append(Span(int(p))) return result + + +def gap_coords_to_map(gaps_lengths: dict, seq_length: int) -> Map: + """ + Parameters + ---------- + gaps_lengths + {gap insertion pos: gap length, ...} + seq_length : int + length of unaligned sequence + + Returns + ------- + Map + """ + + if not gaps_lengths: + return Map([(0, seq_length)], parent_length=seq_length) + + spans = [] + last = pos = 0 + for pos in sorted(gaps_lengths): + if pos > seq_length: + raise ValueError( + f"cannot have gap at position {pos} beyond seq_length= {seq_length}" + ) + + gap = LostSpan(length=gaps_lengths[pos]) + spans.extend([gap] if pos == 0 else [Span(last, pos), gap]) + last = pos + + if pos < seq_length: + spans.append(Span(last, seq_length)) + + return Map(spans=spans, parent_length=seq_length) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/moltype.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/moltype.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/moltype.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/moltype.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ moltype.py @@ -16,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Rob Knight", "Daniel McDonald"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -31,21 +30,6 @@ import numpy -from numpy import ( - arange, - array, - asarray, - newaxis, - ravel, - remainder, - take, - transpose, - uint8, - uint16, - uint32, - zeros, -) - from cogent3.core.alignment import ( Alignment, ArrayAlignment, @@ -132,9 +116,6 @@ IUPAC_DNA_complements = {"A": "T", "C": "G", "G": "C", "T": "A", "-": "-"} -IUPAC_DNA_complements = {"A": "T", "C": "G", "G": "C", "T": "A", "-": "-"} - - # note change in standard order from DNA IUPAC_RNA_chars = ["U", "C", "A", "G"] IUPAC_RNA_ambiguities = { @@ -490,12 +471,16 @@ degens = "".join(degens) else: constructor = Alphabet # assume multi-char - self.base = constructor(chars, moltype=moltype) - self.degen = constructor(chars + degens, moltype=moltype) - self.gapped = constructor(chars + gap, gap, moltype=moltype) - self.degen_gapped = constructor( - chars + gap + degens + missing, gap, moltype=moltype + + super(AlphabetGroup, self).__init__( + base=constructor(chars, moltype=moltype), + degen=constructor(chars + degens, moltype=moltype), + gapped=constructor(chars + gap, gap, moltype=moltype), + degen_gapped=constructor( + chars + gap + degens + missing, gap, moltype=moltype + ), ) + self._items = [self.base, self.degen, self.gapped, self.degen_gapped] self._set_relationships() # set complements if MolType was specified @@ -616,7 +601,7 @@ everything into the alphabet. Slated for deletion. preserve_existing_moltypes if True (default: False), does not - set the MolType of the things added in \*\*kwargs to self. + set the MolType of the things added in **kwargs to self. make_alphabet_group if True, makes an AlphabetGroup relating the various alphabets to one another. @@ -874,7 +859,6 @@ """ all = {} for i in self.alphabet: - curr = str(i) all[i] = i for key, val in list(self.degenerates.items()): all[key] = val diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/profile.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/profile.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/profile.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/profile.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -420,8 +420,7 @@ ylim=ylim, colours=colours, ) - xtick_vals = [j for j in range(0, segment.shape[0], 20)] - xtick_text = [f"{i + j}" for j in range(0, segment.shape[0], 20)] + sublogo.layout[f"x{axis}"].showticklabels = False sublogo.layout[f"x{axis}"].domain = [0, segment.shape[0] / wrap] diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/sequence.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/sequence.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/sequence.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/sequence.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Contains classes that represent biological sequence data. These provide generic biological sequence manipulation functions, plus functions that are critical for the EVOLVE calculations. @@ -12,7 +11,6 @@ creation. """ -import copy import json import re import warnings @@ -35,13 +33,11 @@ ) from numpy.random import permutation -import cogent3 - from cogent3.core.alphabet import AlphabetError from cogent3.core.genetic_code import get_code from cogent3.core.info import Info as InfoClass from cogent3.format.fasta import alignment_to_fasta -from cogent3.maths.stats.contingency import CategoryCounts, TestResult +from cogent3.maths.stats.contingency import CategoryCounts from cogent3.maths.stats.number import CategoryCounter from cogent3.parse import gff from cogent3.util.dict_array import DictArrayTemplate @@ -51,12 +47,7 @@ get_object_provenance, get_setting_from_environ, ) -from cogent3.util.transform import ( - KeepChars, - for_seq, - per_longest, - per_shortest, -) +from cogent3.util.transform import for_seq, per_shortest from .annotation import Map, _Annotatable @@ -71,7 +62,7 @@ "Daniel McDonald", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -342,7 +333,7 @@ def degap(self): """Deletes all gap characters from sequence.""" - return self.__class__(self.moltype.degap(self), info=self.info) + return self.__class__(self.moltype.degap(self), name=self.name, info=self.info) def gap_indices(self): """Returns list of indices of all gaps in the sequence, or [].""" @@ -641,7 +632,7 @@ last_nongap = i missing = self.moltype.missing if first_nongap is None: # sequence was all gaps - result = self.__class__([missing for i in len(self)], info=self.info) + result = self.__class__([missing for _ in len(self)], info=self.info) else: prefix = missing * first_nongap mid = str(self[first_nongap : last_nongap + 1]) @@ -672,17 +663,14 @@ colors=None, font_size=12, font_family="Lucida Console", - interleave_len=None, ): """returns html with embedded styles for sequence colouring Parameters ---------- - interleave_len - replaced by wrap in version 2021.6 wrap maximum number of printed bases, defaults to - alignment length, old name is interleave_len + alignment length limit truncate alignment to this length colors @@ -699,13 +687,6 @@ >>> from IPython.core.display import HTML >>> HTML(aln.to_html()) """ - if interleave_len is not None: - cogent3.util.warning.deprecated( - "argument", "interleave_len", "wrap", "2021.6" - ) - wrap = interleave_len if wrap == 60 else wrap - - # todo refactor interleave_len to be wrap css, styles = self.moltype.get_css_style( colors=colors, font_size=font_size, font_family=font_family ) @@ -1868,7 +1849,7 @@ """Returns new ArrayRnaSequence, converting T -> U""" if hasattr(data, "upper"): data = data.upper().replace("T", "U") - return super(ArrayNucleicAcidSequence, self).__init__(data, *args, **kwargs) + return super(ArrayRnaSequence, self).__init__(data, *args, **kwargs) class ArrayDnaSequence(ArrayNucleicAcidSequence): @@ -1879,7 +1860,7 @@ """Returns new ArrayRnaSequence, converting U -> T""" if hasattr(data, "upper"): data = data.upper().replace("U", "T") - return super(ArrayNucleicAcidSequence, self).__init__(data, *args, **kwargs) + return super(ArrayDnaSequence, self).__init__(data, *args, **kwargs) class ArrayCodonSequence(ArraySequence): diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/core/tree.py python-cogent-2021.10.12a1+dfsg/src/cogent3/core/tree.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/core/tree.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/core/tree.py 2021-10-12 00:17:34.000000000 +0000 @@ -59,7 +59,7 @@ "Justin Kuczynski", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -634,8 +634,9 @@ tipnames = set(tipnames) tips = [tip for tip in self.tips() if tip.name in tipnames] - if len(tips) == 0: - return None + if len(tips) != len(tipnames): + missing = tipnames - set(self.get_tip_names()) + raise ValueError(f"tipnames {missing} not present in self") # scrub tree if hasattr(self, "black"): @@ -1864,8 +1865,6 @@ to_process = [(self, 0.0)] tips_to_save = [] - curr_node, curr_dist = to_process[0] - seen = set([id(self)]) while to_process: curr_node, curr_dist = to_process.pop(0) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/data/energy_params.py python-cogent-2021.10.12a1+dfsg/src/cogent3/data/energy_params.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/data/energy_params.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/data/energy_params.py 2021-10-12 00:17:34.000000000 +0000 @@ -18,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Amanda Birmingham", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Amanda Birmingham" __email__ = "amanda.birmingham@thermofisher.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/data/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/data/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/data/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/data/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -6,7 +6,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Amanda Birmingham"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/data/molecular_weight.py python-cogent-2021.10.12a1+dfsg/src/cogent3/data/molecular_weight.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/data/molecular_weight.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/data/molecular_weight.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/draw/dendrogram.py python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/dendrogram.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/draw/dendrogram.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/dendrogram.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Rahul Ghangas"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" @@ -376,7 +376,7 @@ @property def x(self): if self._x is None: - y = self.y # triggers populating values + _ = self.y # triggers populating values return self._x @property diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/draw/dotplot.py python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/dotplot.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/draw/dotplot.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/dotplot.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Peter Maxwell", "Rahul Ghangas"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" @@ -84,7 +84,6 @@ acceptable_noise = min(len1, len2) / window threshold = suitable_threshold(window, acceptable_noise / universe) - key = (window, threshold, min_gap) fwd = dotplot( str(seq1), str(seq2), @@ -195,7 +194,6 @@ show_progress : bool displays progress bar """ - from cogent3.core.alignment import Aligned # we ensure sequences have gaps parsed and the calculate aspect ratio if hasattr(seq1, "moltype"): diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/draw/drawable.py python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/drawable.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/draw/drawable.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/drawable.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,14 +5,13 @@ from cogent3.util.misc import extend_docstring_from from cogent3.util.union_dict import UnionDict -from cogent3.util.warning import deprecated __author__ = "Rahul Ghangas and Gavin Huttley" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rahul Ghangas", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" @@ -174,7 +173,7 @@ else: try: self._traces = [UnionDict(trace) for trace in traces] - except ValueError as msg: + except ValueError: raise TypeError(f"expected a series of dicts, got {traces}") title = title if title is None else dict(text=title) self._default_layout = UnionDict( diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/draw/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/draw/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,5 +14,5 @@ "Sheng Han Moses Koh", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/draw/letter.py python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/letter.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/draw/letter.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/letter.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,11 +15,8 @@ SVG path formatting and then into an array format for inclusion here. """ -import os - import numpy -from cogent3.util.misc import extend_docstring_from from cogent3.util.union_dict import UnionDict @@ -27,7 +24,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Sheng Han Moses Koh", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/draw/logo.py python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/logo.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/draw/logo.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/draw/logo.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/best_likelihood.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/best_likelihood.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/best_likelihood.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/best_likelihood.py 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ __credits__ = ["Helen Lindsay", "Gavin Huttley", "Daniel McDonald"] cite = "Goldman, N. (1993). Statistical tests of models of DNA substitution. J Mol Evol, 36: 182-98" __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/bootstrap.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/bootstrap.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/bootstrap.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/bootstrap.py 2021-10-12 00:17:34.000000000 +0000 @@ -24,7 +24,6 @@ import random -from cogent3.util import parallel from cogent3.util import progress_display as UI @@ -38,7 +37,7 @@ "Peter Maxwell", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/coevolution.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/coevolution.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/coevolution.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/coevolution.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,7 +1,3 @@ -#!/usr/bin/env python -# Authors: Greg Caporaso (gregcaporaso@gmail.com), Brett Easton, Gavin Huttley -# coevolution.py - """ Description File created on 03 May 2007. @@ -47,44 +43,31 @@ """ -from optparse import make_option -from os.path import basename, exists, splitext +from os.path import basename from pickle import Pickler, Unpickler from random import shuffle -from sys import exit from numpy import ( - abs, array, e, - exp, float, - float64, greater_equal, isnan, less_equal, log, - mean, nan, nonzero, ones, - put, ravel, - reshape, - sqrt, - take, - transpose, - tril, zeros, ) from numpy.linalg import norm from cogent3 import PROTEIN, make_aligned_seqs -from cogent3.core.alignment import ArrayAlignment, seqs_from_fasta -from cogent3.core.alphabet import Alphabet, CharAlphabet +from cogent3.core.alignment import ArrayAlignment +from cogent3.core.alphabet import CharAlphabet from cogent3.core.moltype import IUPAC_gap, IUPAC_missing from cogent3.core.sequence import Sequence -from cogent3.core.tree import TreeError from cogent3.evolve.substitution_model import ( EmpiricalProteinMatrix, Parametric, @@ -92,15 +75,6 @@ from cogent3.maths.stats.distribution import binomial_exact from cogent3.maths.stats.number import CategoryCounter, CategoryFreqs from cogent3.maths.stats.special import ROUND_ERROR -from cogent3.parse.newick import TreeParseError -from cogent3.parse.record import FileFormatError, RecordError -from cogent3.util.recode_alignment import ( - alphabets, - recode_counts_and_freqs, - recode_dense_alignment, - recode_freq_vector, - square_matrix_to_dict, -) __author__ = "Greg Caporaso" @@ -113,7 +87,7 @@ "Rob Knight", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Greg Caporaso" __email__ = "gregcaporaso@gmail.com" __status__ = "Beta" @@ -226,7 +200,7 @@ for exclude in excludes: if exclude in states: try: - col = exclude_handler(col, excludes) + _ = exclude_handler(col, excludes) break except TypeError: return null_value @@ -641,7 +615,7 @@ # pos_freq as a float could be greater than scaled_aln_size. # In this case I cast it to an int. I don't like this alignment # scaling stuff though. - except ValueError as e: + except ValueError: results.append(binomial_exact(int(pos_freq), scaled_aln_size, natural_prob)) return array(results) @@ -787,8 +761,6 @@ sca_pair(aln,10,20,0.85) != \ sca_pair(aln.take_positions([10,20]),0,1,0.85) """ - num_positions = len(alignment) - num_seqs = alignment.num_seqs # Calculate frequency distributions natural_probs = probs_from_dict(background_freqs, alphabet) @@ -919,7 +891,6 @@ or a string. """ - num_seqs = alignment.num_seqs natural_probs = probs_from_dict(background_freqs, alphabet) aln_freqs = freqs_from_aln(alignment, alphabet, scaled_aln_size) aln_probs = get_positional_probabilities(aln_freqs, natural_probs, scaled_aln_size) @@ -1008,7 +979,6 @@ or a string. """ - num_seqs = alignment.num_seqs natural_probs = probs_from_dict(background_freqs, alphabet) aln_freqs = freqs_from_aln(alignment, alphabet, scaled_aln_size) aln_probs = get_positional_probabilities(aln_freqs, natural_probs, scaled_aln_size) @@ -1171,7 +1141,7 @@ for exclude in excludes: if exclude in states: try: - col = exclude_handler(col, excludes) + _ = exclude_handler(col, excludes) break except TypeError: return null_value @@ -1635,7 +1605,7 @@ result[merged_name] = Sequence( alignment1.get_gapped_seq(orig_name) ) + Sequence(alignment2.get_gapped_seq(aln2_name_map[merged_name])) - except KeyError as e: + except KeyError: raise KeyError( "A sequence identifier is in alignment2 " + "but not alignment1 -- did you filter out sequences identifiers" @@ -2056,9 +2026,9 @@ pass ignored = None if not ignored else list(set(ignored) & set(column_freqs.keys())) if ignored: - for e in ignored: + for e_ in ignored: try: - del column_freqs[e] + del column_freqs[e_] except KeyError: pass @@ -2517,7 +2487,7 @@ alignment_id = fields[0] alphabet_id = fields[1] method_id = fields[2] - extension = fields[3] + _ = fields[3] # extension except IndexError: raise ValueError( "output filepath not in parsable format: %s. See doc string for format definition." diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/discrete_markov.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/discrete_markov.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/discrete_markov.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/discrete_markov.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" @@ -54,7 +54,6 @@ PartitionDefn.check_value_is_valid(self, part, is_constant) def make_cells(self, input_soup=None, variable=None): - input_soup = input_soup or {} uniq_cells = [] all_cells = [] for (i, v) in enumerate(self.uniq): diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/distance.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/distance.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/distance.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/distance.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Peter Maxwell", "Matthew Wakefield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/fast_distance.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/fast_distance.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/fast_distance.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/fast_distance.py 2021-10-12 00:17:34.000000000 +0000 @@ -4,7 +4,7 @@ import numpy from numpy import array, diag, dot, eye, float64, int32, log, sqrt, zeros -from numpy.linalg import LinAlgError, det, inv, norm +from numpy.linalg import det, inv from cogent3 import DNA, RNA, get_moltype from cogent3.util.dict_array import DictArray @@ -18,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Yicheng Zhu", "Ben Kaehler"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" # pending addition of protein distance metrics diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -29,7 +29,7 @@ "Greg Caporaso", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/likelihood_calculation.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/likelihood_calculation.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/likelihood_calculation.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/likelihood_calculation.py 2021-10-12 00:17:34.000000000 +0000 @@ -20,7 +20,6 @@ NonParamDefn, ProbabilityParamDefn, SumDefn, - _FuncDefn, ) @@ -31,7 +30,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/likelihood_function.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/likelihood_function.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/likelihood_function.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/likelihood_function.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,5 +1,3 @@ -#!/usr/bin/env python - import json import random @@ -36,7 +34,7 @@ "Ananias Iliadis", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -538,16 +536,18 @@ def _for_display(self): """processes statistics tables for display""" - title = self.name if self.name else "Likelihood function statistics" + title = self.name or "Likelihood function statistics" result = [] result += self.get_statistics(with_motif_probs=True, with_titles=True) - for i, table in enumerate(result): + for i, table_ in enumerate(result): if ( - "motif" in table.title and table.shape[1] == 2 and table.shape[0] >= 60 + "motif" in table_.title + and table_.shape[1] == 2 + and table_.shape[0] >= 60 ): # just sort codon motif probs, then truncate - table = table.sorted(columns="motif") - table.set_repr_policy(head=5, tail=5, show_shape=False) - result[i] = table + table_ = table_.sorted(columns="motif") + table_.set_repr_policy(head=5, tail=5, show_shape=False) + result[i] = table_ return title, result def _repr_html_(self): @@ -560,10 +560,10 @@ nfp = "

number of free parameters = %d

" % self.get_num_free_params() title, results = self._for_display() - for i, table in enumerate(results): - table.title = table.title.capitalize() - table.set_repr_policy(show_shape=False) - results[i] = table._repr_html_() + for i, table_ in enumerate(results): + table_.title = table_.title.capitalize() + table_.set_repr_policy(show_shape=False) + results[i] = table_._repr_html_() results = ["

%s

" % title, lnL, nfp] + results return "\n".join(results) @@ -580,14 +580,10 @@ lnL = None nfp = "number of free parameters = %d" % self.get_num_free_params() - for table in results: - table.title = "" - - if lnL: - results = [title, lnL, nfp] + results - else: - results = [title, nfp] + results + for table_ in results: + table_.title = "" + results = [title, lnL, nfp] + results if lnL else [title, nfp] + results return "\n".join(map(str, results)) def get_annotated_tree(self, length_as=None): @@ -1077,7 +1073,7 @@ sequence_length = len(lht.index) except AttributeError: raise ValueError( - f"Must provide sequence_length since no alignment set on self" + "Must provide sequence_length since no alignment set on self" ) leaves = self.get_param_value("leaf_likelihoods", locus=locus) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/likelihood_tree_numba.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/likelihood_tree_numba.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/likelihood_tree_numba.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/likelihood_tree_numba.py 2021-10-12 00:17:34.000000000 +0000 @@ -7,7 +7,7 @@ __copyright__ = "Copyright 2007-2019, The Cogent Project" __credits__ = ["Peter Maxwell", "Rob Knight", "Gavin Huttley", "Stephen Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/likelihood_tree.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/likelihood_tree.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/likelihood_tree.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/likelihood_tree.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/models.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/models.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/models.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/models.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield", "Peter Maxwell", "Gavin Huttley", "James Kondilios"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" @@ -142,7 +142,7 @@ def K80(**kw): """Kimura 1980""" - required = dict(equal_motif_probs=True, optimise_motif_probs=False) + required = dict(name="K80", equal_motif_probs=True, optimise_motif_probs=False) kwargs = {} kwargs.update(kw) kwargs.update(required) @@ -151,7 +151,7 @@ def JC69(**kw): """Jukes and Cantor's 1969 model""" - required = dict(equal_motif_probs=True, optimise_motif_probs=False) + required = dict(name="JC69", equal_motif_probs=True, optimise_motif_probs=False) kwargs = {} kwargs.update(kw) kwargs.update(required) @@ -242,15 +242,23 @@ """Goldman and Yang 1994 codon substitution model. N Goldman and Z Yang, 1994, Mol Biol Evol, 11(5):725-36.""" - return Y98(**kw) + required = dict(name="GY94") + kwargs = {} + kwargs.update(kw) + kwargs.update(required) + return Y98(**kwargs) def Y98(**kw): """Yang's 1998 substitution model, a derivative of the GY94. Z Yang, 1998, Mol Biol Evol, 15(5):568-73""" + required = dict( - name="Y98", predicates=[_kappa, _omega], mprob_model="tuple", model_gaps=False + predicates=[_kappa, _omega], + mprob_model="tuple", + model_gaps=False, + name=kw.get("name", "Y98"), ) kwargs = dict(recode_gaps=True, motif_probs=None) kwargs.update(kw) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/motif_prob_model.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/motif_prob_model.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/motif_prob_model.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/motif_prob_model.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,15 +5,14 @@ import numpy from cogent3.evolve.likelihood_tree import make_likelihood_tree_leaf - -from . import substitution_calculation +from cogent3.recalculation.definition import CalcDefn, PartitionDefn __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -47,7 +46,7 @@ def make_motif_probs_defn(self): """Makes the first part of a parameter controller definition for this model, the calculation of motif probabilities""" - return substitution_calculation.PartitionDefn( + return PartitionDefn( name="mprobs", default=None, dimensions=("locus", "edge"), @@ -189,12 +188,10 @@ def make_motif_word_prob_defns(self): monomer_probs = self.make_motif_probs_defn() - word_probs = substitution_calculation.CalcDefn( - self.calc_word_probs, name="wprobs" - )(monomer_probs) - mprobs_matrix = substitution_calculation.CalcDefn( - self.calc_word_weight_matrix, name="mprobs_matrix" - )(monomer_probs) + word_probs = CalcDefn(self.calc_word_probs, name="wprobs")(monomer_probs) + mprobs_matrix = CalcDefn(self.calc_word_weight_matrix, name="mprobs_matrix")( + monomer_probs + ) return (monomer_probs, word_probs, mprobs_matrix) def adapt_motif_probs(self, motif_probs, auto=False): @@ -231,21 +228,15 @@ return result def calc_word_weight_matrix(self, monomer_probs): - positions = list(range(self.word_length)) monomer_probs = numpy.array(monomer_probs) # so [posn, motif] size = monomer_probs.shape[-1] # should be constant extended_indices = self.mutated_posn * size + self.mutant_motif - # print size, self.word_length - # for a in [extended_indices, self.mutated_posn, self.mutant_motif, - # monomer_probs]: - # print a.shape, a.max() - result = monomer_probs.take(extended_indices) * self.mask return result def make_motif_word_prob_defns(self): - monomer_probs = substitution_calculation.PartitionDefn( + monomer_probs = PartitionDefn( name="psmprobs", default=None, dimensions=("locus", "position", "edge"), @@ -254,15 +245,13 @@ monomer_probs3 = monomer_probs.across_dimension( "position", [str(i) for i in range(self.word_length)] ) - monomer_probs3 = substitution_calculation.CalcDefn( - lambda *x: numpy.array(x), name="mprobs" - )(*monomer_probs3) - word_probs = substitution_calculation.CalcDefn( - self.calc_word_probs, name="wprobs" - )(monomer_probs3) - mprobs_matrix = substitution_calculation.CalcDefn( - self.calc_word_weight_matrix, name="mprobs_matrix" - )(monomer_probs3) + monomer_probs3 = CalcDefn(lambda *x: numpy.array(x), name="mprobs")( + *monomer_probs3 + ) + word_probs = CalcDefn(self.calc_word_probs, name="wprobs")(monomer_probs3) + mprobs_matrix = CalcDefn(self.calc_word_weight_matrix, name="mprobs_matrix")( + monomer_probs3 + ) return (monomer_probs, word_probs, mprobs_matrix) def set_param_controller_motif_probs(self, pc, motif_probs, **kw): @@ -295,7 +284,7 @@ def make_motif_word_prob_defns(self): mprobs = self.make_motif_probs_defn() - mprobs_matrix = substitution_calculation.CalcDefn( - self.calc_word_weight_matrix, name="mprobs_matrix" - )(mprobs) + mprobs_matrix = CalcDefn(self.calc_word_weight_matrix, name="mprobs_matrix")( + mprobs + ) return (mprobs, mprobs, mprobs_matrix) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/ns_substitution_model.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/ns_substitution_model.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/ns_substitution_model.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/ns_substitution_model.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,9 +9,7 @@ from .substitution_model import ( Parametric, Stationary, - TimeReversibleNucleotide, _Codon, - _ContinuousSubstitutionModel, _SubstitutionModel, ) @@ -20,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __contributors__ = ["Gavin Huttley", "Peter Maxwell", "Ben Kaeheler", "Ananias Iliadis"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -62,7 +60,7 @@ y = alphabet[j] self.parameter_order.append("%s/%s" % (x, y)) self.param_pick[i, j] = len(self.parameter_order) - const_param = self.parameter_order.pop() + _ = self.parameter_order.pop() self.symmetric = False self.check_params_exist() diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/pairwise_distance_numba.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/pairwise_distance_numba.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/pairwise_distance_numba.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/pairwise_distance_numba.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2007-2019, The Cogent Project" __credits__ = ["Gavin Huttley", "Yicheng Zhu", "Ben Kaehler", "Stephen Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/parameter_controller.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/parameter_controller.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/parameter_controller.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/parameter_controller.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ This file defines a class for controlling the scope and heterogeneity of parameters involved in a maximum-likelihood based tree analysis. @@ -24,7 +23,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Andrew Butterfield", "Peter Maxwell", "Gavin Huttley", "Helen Lindsay"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.ed.au" __status__ = "Production" @@ -85,7 +84,7 @@ self.motifs = self._motifs = model.get_motifs() self._mprob_motifs = list(model.get_mprob_alphabet()) defn = self.make_likelihood_defn(**kw) - super(_LF, self).__init__(defn) + super(_LikelihoodParameterController, self).__init__(defn) self.set_default_param_rules() self.set_default_tree_parameter_rules() self.mprobs_from_alignment = motif_probs_from_align @@ -201,7 +200,7 @@ self.set_param_rule("expm", is_constant=True, value=expm) def make_calculator(self, **kw): - return super(_LF, self).make_calculator(**kw) + return super(_LikelihoodParameterController, self).make_calculator(**kw) def _process_scope_info( self, diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/predicate.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/predicate.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/predicate.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/predicate.py 2021-10-12 00:17:34.000000000 +0000 @@ -18,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/simulate.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/simulate.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/simulate.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/simulate.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/solved_models_numba.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/solved_models_numba.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/solved_models_numba.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/solved_models_numba.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2019, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Stephen Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/solved_models.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/solved_models.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/solved_models.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/solved_models.py 2021-10-12 00:17:34.000000000 +0000 @@ -20,7 +20,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" @@ -64,13 +64,13 @@ assert_allclose(P1, P2) -def _solved_nucleotide(name, predicates, rate_matrix_required=True, **kw): +def _solved_nucleotide(predicates, rate_matrix_required=True, **kw): if _solved_models is not None and not rate_matrix_required: klass = PredefinedNucleotide else: klass = TimeReversibleNucleotide kw["model_gaps"] = False - return klass(name=name, predicates=predicates, **kw) + return klass(predicates=predicates, **kw) kappa_y = MotifChange("T", "C").aliased("kappa_y") @@ -81,16 +81,21 @@ def TN93(**kw): """Tamura and Nei 1993 model""" kw["recode_gaps"] = True - return _solved_nucleotide("TN93", [kappa_y, kappa_r], **kw) + kw["name"] = "TN93" + return _solved_nucleotide([kappa_y, kappa_r], **kw) def HKY85(**kw): """Hasegawa, Kishino and Yano 1985 model""" kw["recode_gaps"] = True - return _solved_nucleotide("HKY85", [kappa], **kw) + # this function called by others, so we don't overwrite name if it exists + kw["name"] = kw.get("name", "HKY85") + return _solved_nucleotide([kappa], **kw) def F81(**kw): """Felsenstein's 1981 model""" kw["recode_gaps"] = True - return _solved_nucleotide("F81", [], **kw) + # this function called by others, so we don't overwrite name if it exists + kw["name"] = kw.get("name", "F81") + return _solved_nucleotide([], **kw) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/substitution_calculation.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/substitution_calculation.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/substitution_calculation.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/substitution_calculation.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,28 +1,17 @@ #!/usr/bin/env python import warnings -import numpy +from numpy.linalg import LinAlgError from cogent3.maths.matrix_exponentiation import ( CheckedExponentiator, FastExponentiator, - LinAlgError, PadeExponentiator, ) from cogent3.recalculation.definition import ( - CalcDefn, CalculationDefn, - CallDefn, - ConstDefn, - GammaDefn, - MonotonicDefn, - NonParamDefn, - PartitionDefn, PositiveParamDefn, - ProductDefn, RatioParamDefn, - SelectForDimension, - WeightedPartitionDefn, ) @@ -30,7 +19,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/substitution_model.py python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/substitution_model.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/evolve/substitution_model.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/evolve/substitution_model.py 2021-10-12 00:17:34.000000000 +0000 @@ -30,7 +30,6 @@ >>> parameter_controller = model.make_likelihood_function(tree) """ -import inspect import json import warnings @@ -42,28 +41,27 @@ from cogent3.core import moltype from cogent3.evolve import motif_prob_model, parameter_controller, predicate -from cogent3.evolve.discrete_markov import PsubMatrixDefn from cogent3.evolve.likelihood_tree import make_likelihood_tree_leaf from cogent3.evolve.substitution_calculation import ( AlignmentAdaptDefn, + ExpDefn, + LengthDefn, +) +from cogent3.evolve.substitution_calculation import ( + SubstitutionParameterDefn as ParamDefn, +) +from cogent3.recalculation.definition import ( CalcDefn, CallDefn, ConstDefn, - ExpDefn, GammaDefn, - LengthDefn, MonotonicDefn, NonParamDefn, PartitionDefn, ProductDefn, - RateDefn, SelectForDimension, + WeightedPartitionDefn, ) -from cogent3.evolve.substitution_calculation import ( - SubstitutionParameterDefn as ParamDefn, -) -from cogent3.evolve.substitution_calculation import WeightedPartitionDefn -from cogent3.maths.optimisers import ParameterOutOfBoundsError from cogent3.util.misc import extend_docstring_from, get_object_provenance @@ -79,7 +77,7 @@ "Von Bing Yap", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/alignment.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/alignment.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/alignment.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/alignment.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/bedgraph.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/bedgraph.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/bedgraph.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/bedgraph.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/clustal.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/clustal.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/clustal.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/clustal.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,13 +11,13 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jeremy Widmann"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Jeremy Widmann" __email__ = "jeremy.widmann@colorado.edu" __status__ = "Development" -def clustal_from_alignment(aln, interleave_len=None, wrap=None): +def clustal_from_alignment(aln, wrap=None): """ Parameters ---------- @@ -31,12 +31,6 @@ ------- Returns a string in Clustal format """ - if interleave_len is not None: - from cogent3.util.warning import deprecated - - deprecated("argument", "interleave_len", "wrap", "2021.6") - wrap = interleave_len if wrap == 60 else wrap - if not aln: return "" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/fasta.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/fasta.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/fasta.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/fasta.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jeremy Widmann", "Rob Knight", "Gavin Huttley", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Jeremy Widmann" __email__ = "jeremy.widmann@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/gde.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/gde.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/gde.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/gde.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jeremy Widmann", "Rob Knight", "Gavin Huttley", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Thomas La" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -29,7 +29,7 @@ "Marcin Cieslik", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/nexus.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/nexus.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/nexus.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/nexus.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,16 +1,14 @@ -#!/usr/bin/env python - __author__ = "Gavin Huttley" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" -def nexus_from_alignment(aln, seq_type, wrap=50, interleave_len=None): +def nexus_from_alignment(aln, seq_type, wrap=50): """returns a nexus formatted string Parameters @@ -19,14 +17,7 @@ dna, rna, or protein wrap the line width - interleave_len - will be replaced by wrap in version 2021.6 - """ - if interleave_len is not None: - cogent3.util.warning.deprecated("argument", "interleave_len", "wrap", "2021.6") - wrap = interleave_len if wrap == 50 else wrap - if aln.is_ragged(): raise ValueError( "Sequences in alignment are not all the same " diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/paml.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/paml.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/paml.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/paml.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jeremy Widmann", "Rob Knight", "Gavin Huttley", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Thomas La" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/phylip.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/phylip.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/phylip.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/phylip.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/table.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/table.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/table.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/table.py 2021-10-12 00:17:34.000000000 +0000 @@ -18,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Peter Maxwell", "Matthew Wakefield", "Jeremy Widmann"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -157,7 +157,6 @@ data += [thead] + row + [""] formatted_rows = [] - td = formatted("td", "") for ridx, row in enumerate(rows): new = [formatted("tr", "")] for cidx, cell in row_iterator(row): diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/format/util.py python-cogent-2021.10.12a1+dfsg/src/cogent3/format/util.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/format/util.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/format/util.py 2021-10-12 00:17:34.000000000 +0000 @@ -6,7 +6,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jeremy Widmann", "Rob Knight", "Gavin Huttley", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -44,6 +44,7 @@ from cogent3.util.misc import get_format_suffixes, open_ from cogent3.util.table import Table as _Table from cogent3.util.table import cast_str_to_array +from cogent3.util.warning import deprecated __author__ = "" @@ -71,13 +72,11 @@ "Daniel McDonald", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" -from cogent3.util.warning import deprecated, discontinued - if sys.version_info < (3, 6): PY_VERSION = ".".join([str(n) for n in sys.version_info]) @@ -368,7 +367,7 @@ """ if any(isinstance(a, str) for a in (header, data)): - raise TypeError(f"str type invalid, if its a path use load_table()") + raise TypeError("str type invalid, if it's a path use load_table()") if "index" in kwargs: deprecated("argument", "index", "index_name", "2021.11") diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/distance_transform.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/distance_transform.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/distance_transform.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/distance_transform.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ matrix based distance metrics, and related coordinate transforms functions to compute distance matrices row by row from abundance matrices, @@ -62,42 +61,19 @@ argsort, array, asarray, - geterr, isfinite, isnan, logical_and, - logical_not, - logical_or, - logical_xor, mean, min, multiply, nan_to_num, - nonzero, - ravel, - seterr, - shape, - sqrt, - square, - std, - sum, - take, - where, - zeros, ) +from numpy import ndim as rank +from numpy import ravel, seterr, shape, sqrt, square, sum, take, where, zeros from numpy.linalg import norm -try: - from numpy import ndim as rank -except ImportError: - from numpy import rank - -# any, all from numpy override built in any, all, preventing: -# ValueError: The truth value of an array with more than one element is -# ambiguous. Use a.any() or a.all() - - __author__ = "Justin Kuczynski" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = [ @@ -110,7 +86,7 @@ "Greg Caporaso", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Justin Kuczynski" __email__ = "justinak@gmail.com" __status__ = "Prototype" @@ -357,7 +333,6 @@ r1 = datamtx[i] for j in range(i): r2 = datamtx[j] - dist = 0.0 net = abs(r1 - r2) / (r1 + r2) num_nonzeros = 0 for k in range(r1.size): @@ -574,7 +549,6 @@ r1 = datamtx[i] for j in range(i): r2 = datamtx[j] - rowdiff = r2 - r1 dist = sum(abs(r1 - r2) / coldiffs) dists[i, j] = dists[j, i] = dist @@ -923,10 +897,7 @@ return zeros((0, 0), "d") rowmeans = mean(datamtx, axis=1) - rowstds = std(datamtx, axis=1) - dists = zeros((numrows, numrows), "d") - n = float(numrows) for i in range(numrows): r1 = datamtx[i, :] diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/geometry.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/geometry.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/geometry.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/geometry.py 2021-10-12 00:17:34.000000000 +0000 @@ -2,33 +2,25 @@ """Code for geometric operations, e.g. distances and center of mass.""" from numpy import ( - allclose, any, append, array, - c_, cos, delete, - dot, exp, - identity, insert, linalg, log, mean, min, - minimum, newaxis, nonzero, - ones, pi, sin, sqrt, sum, take, - vstack, ) -from numpy.linalg import norm __author__ = "Sandra Smit" @@ -42,7 +34,7 @@ "Helmut Simon", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Sandra Smit" __email__ = "sandra.smit@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -29,7 +29,7 @@ "Ben Kaehler", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/markov.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/markov.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/markov.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/markov.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/matrix_exponential_integration.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/matrix_exponential_integration.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/matrix_exponential_integration.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/matrix_exponential_integration.py 2021-10-12 00:17:34.000000000 +0000 @@ -19,7 +19,7 @@ __copyright__ = "Copyright 2007-2014, The Cogent Project" __credits__ = ["Ben Kaehler", "Von Bing Yap", "Gavin Huttley", "Ananias Iliadis"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Ben Kaehler" __email__ = "benjamin.kaehler@anu.edu.au" __status__ = "Production" @@ -48,7 +48,7 @@ exponentiator -- Exponentiator used in Van Loan method. Defaults to RobustEstimator. """ - self.Q = Q + super(VanLoanIntegratingExponentiator, self).__init__(Q) Qdim = len(Q) if R is None: self.R = identity(Qdim) @@ -76,7 +76,7 @@ """ Q -- a diagonisable matrix. """ - self.Q = Q + super(VonBingIntegratingExponentiator, self).__init__(Q) self.roots, self.evT = eig(Q) self.evI = inv(self.evT.T) # Remove following check if performance is a concern diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/matrix_exponentiation.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/matrix_exponentiation.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/matrix_exponentiation.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/matrix_exponentiation.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # 4 implementations of P = exp(Q*t) # APIs along the lines of: # exponentiator = WhateverExponenentiator(Q or Q derivative(s)) @@ -14,14 +13,14 @@ import numpy -from numpy.linalg import LinAlgError, eig, inv, solve +from numpy.linalg import eig, inv, solve __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Zongzhi Liu"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/matrix_logarithm.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/matrix_logarithm.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/matrix_logarithm.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/matrix_logarithm.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ from numpy import allclose, argmin, array, diag, dot, exp, eye from numpy import inner as innerproduct -from numpy import isclose, log, ones, pi, transpose, zeros +from numpy import isclose, log, ones, pi, zeros from numpy.linalg import eig as eigenvectors from numpy.linalg import inv as inverse from numpy.linalg import norm @@ -18,7 +18,7 @@ __copyright__ = "Copyright 2007-2014, The Cogent Project" __credits__ = ["Rob Knight", "Gavin Huttley", "Von Bing Yap", "Ben Kaehler"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/measure.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/measure.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/measure.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/measure.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,6 @@ -from numpy import array, diag, diagonal, dot, eye, log, sqrt +from math import fsum + +from numpy import array, diag, diagonal, dot, eye, isclose, log, sqrt from numpy.linalg import slogdet from numpy.testing import assert_allclose, assert_equal @@ -6,14 +8,12 @@ from cogent3.maths.util import safe_p_log_p, validate_freqs_array -from .util import safe_log - __author__ = "Gavin Huttley" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -115,9 +115,17 @@ except ValueError as err: raise AssertionError("freqs not valid") from err - H_mn = safe_p_log_p(freqs1 / 2 + freqs2 / 2).sum() - mn_H = sum([sum(i) for i in map(safe_p_log_p, [freqs1, freqs2])]) / 2 - return H_mn - mn_H + H_mn = fsum(safe_p_log_p(freqs1 / 2 + freqs2 / 2)) + mn_H = fsum([fsum(i) for i in map(safe_p_log_p, [freqs1, freqs2])]) / 2 + jsd_ = H_mn - mn_H + if jsd_ < 0 and isclose(jsd_, 0, atol=1e-10): + jsd_ = 0 + elif jsd_ < 0: + raise ArithmeticError( + f"{jsd_} is negative and below defined precision threshold" + ) + + return jsd_ @cogent3.util.misc.extend_docstring_from(jsd) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/optimisers.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/optimisers.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/optimisers.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/optimisers.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,6 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - """Local or Global-then-local optimisation with progress display """ @@ -21,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Andrew Butterfield", "Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -109,7 +106,7 @@ if not acceptable_inf(result): warnings.warn("Non-finite f %s from %s" % (result, x)) raise ParameterOutOfBoundsError - except (ArithmeticError, ParameterOutOfBoundsError) as detail: + except (ArithmeticError, ParameterOutOfBoundsError): result = out_of_bounds_value return result @@ -184,17 +181,7 @@ try: # Global optimisation if do_global: - if 0 and not do_local: - warnings.warn( - "local=False causes the post-global optimisation local " - '"polishing" optimisation to be skipped entirely, which seems ' - "pointless, so its meaning may change to a simple boolean " - "flag: local or global." - ) - # It also needlessly complicates this function. - gend = 1.0 - else: - gend = 0.9 + gend = 0.9 callback = unsteadyProgressIndicator(ui.display, "Global", 0.0, gend) gtol = [tolerance, global_tolerance][do_local] opt = GlobalOptimiser(filename=filename, interval=interval) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/period_numba.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/period_numba.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/period_numba.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/period_numba.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ __copyright__ = "Copyright 2007-2019, The Cogent Project" __credits__ = ["Julien Epps", "Hua Ying", "Gavin Huttley", "Stephen Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/period.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/period.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/period.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/period.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,9 +8,7 @@ multiply, pi, polyval, - power, sqrt, - sum, zeros, ) @@ -21,7 +19,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Julien Epps", "Hua Ying", "Gavin Huttley", "Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/scipy_optimisers.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/scipy_optimisers.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/scipy_optimisers.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/scipy_optimisers.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -69,7 +69,7 @@ if tolerance is None: tolerance = 1e-6 - fval_last = fval = numpy.inf + fval_last = numpy.inf if len(xopt) == 0: return function(xopt), xopt diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/scipy_optimize.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/scipy_optimize.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/scipy_optimize.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/scipy_optimize.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # We don't want to depend on the monolithic, fortranish, # Num-overlapping, mac-unfriendly SciPy. But this # module is too good to pass up. It has been lightly customised for @@ -23,14 +22,9 @@ import numpy -from numpy import absolute, asarray, atleast_1d, eye, isinf, sqrt, squeeze +from numpy import absolute, asarray, atleast_1d, eye, sqrt, squeeze -try: - import linesearch # from SciPy -except ImportError: - linesearch = None - # These have been copied from Numeric's MLab.py # I don't think they made the transition to scipy_core @@ -56,7 +50,7 @@ pymin = builtins.min pymax = builtins.max -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" _epsilon = sqrt(numpy.finfo(float).eps) @@ -154,8 +148,6 @@ tol2 = 2.0 * tol1 xmid = 0.5 * (a + b) if abs(x - xmid) < (tol2 - 0.5 * (b - a)): # check for convergence - xmin = x - fval = fx break infinities_present = [f for f in [fw, fv, fx] if numpy.isposinf(f)] if infinities_present or (abs(deltax) <= tol1): diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/simannealingoptimiser.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/simannealingoptimiser.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/simannealingoptimiser.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/simannealingoptimiser.py 2021-10-12 00:17:34.000000000 +0000 @@ -22,7 +22,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Andrew Butterfield", "Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/solve.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/solve.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/solve.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/solve.py 2021-10-12 00:17:34.000000000 +0000 @@ -4,7 +4,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/contingency.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/contingency.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/contingency.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/contingency.py 2021-10-12 00:17:34.000000000 +0000 @@ -2,17 +2,16 @@ from numpy.random import shuffle from numpy.testing import assert_allclose -from cogent3.format.table import formatted_cells, rich_html, simple_format from cogent3.maths.stats import chisqprob -from cogent3.maths.stats.test import G_fit, G_ind -from cogent3.util.dict_array import DictArray, DictArrayTemplate +from cogent3.maths.stats.test import G_fit +from cogent3.util.dict_array import DictArray __author__ = "Gavin Huttley" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/distribution.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/distribution.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/distribution.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/distribution.py 2021-10-12 00:17:34.000000000 +0000 @@ -33,7 +33,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Sandra Smit", "Gavin Huttley", "Daniel McDonald"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/information_criteria.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/information_criteria.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/information_criteria.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/information_criteria.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -29,7 +29,7 @@ "Micah Hamady", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/jackknife.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/jackknife.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/jackknife.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/jackknife.py 2021-10-12 00:17:34.000000000 +0000 @@ -7,13 +7,35 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Anuj Pahwa", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" def index_gen(length): + """returns a callable + + Parameters + ---------- + length : int + length of series of integers to generate + + Returns + ------- + callable + + Notes + ----- + When invoked with an int, returns all indices except that provided. + The result can be used with a numpy.take(data, indices). + + >>> gen_series = index_gen(4) + >>> gen_series(0) + [1, 2, 3] + >>> gen_series(1) + [0, 2, 3] + """ data = tuple(range(length)) def gen(i): diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/kendall.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/kendall.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/kendall.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/kendall.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Daniel McDonald"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -83,7 +83,6 @@ """ ranked = as_paired_ranks(x, y) n = len(ranked) - denom = n * (n - 1) / 2 con = 0 discor = 0 x_tied = 0 diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/ks.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/ks.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/ks.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/ks.py 2021-10-12 00:17:34.000000000 +0000 @@ -28,7 +28,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -74,7 +74,6 @@ m = 2 * k - 1 h = k - n * statistic H = ones(m ** 2, "d") - Q = zeros(m ** 2, "d") for i in range(m): for j in range(m): if i - j + 1 < 0: diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/number.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/number.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/number.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/number.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,5 +1,5 @@ from collections import Counter, defaultdict -from collections.abc import Mapping, MutableMapping +from collections.abc import MutableMapping import numpy @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -182,7 +182,7 @@ darr = DictArrayTemplate(*categories).wrap(numpy.zeros(shape, dtype=int)) for comb in product(*categories): indices = [[categories[i].index(c)] for i, c in enumerate(comb)] - darr.array[indices] = self[comb] + darr.array[tuple(indices)] = self[comb] return darr diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/period.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/period.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/period.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/period.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,4 @@ -from random import choice, random, shuffle +from random import choice import numpy @@ -17,7 +17,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Julien Epps", "Hua Ying", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/special.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/special.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/special.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/special.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Translations of functions from Release 2.3 of the Cephes Math Library, (c) Stephen L. Moshier 1984, 1995. """ @@ -10,7 +9,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Rob Knight", "Sandra Smit", "Daniel McDonald"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -458,18 +457,13 @@ def lgam(x): """Natural log of the gamma fuction: see Cephes docs for details""" - sgngam = 1 if x < -34: q = -x w = lgam(q) p = floor(q) if p == q: raise OverflowError("lgam returned infinity.") - i = p - if i & 1 == 0: - sgngam = -1 - else: - sgngam = 1 + z = q - p if z > 0.5: p += 1 @@ -479,6 +473,7 @@ raise OverflowError("lgam returned infinity.") z = LOGPI - log(z) - w return z + if x < 13: z = 1 p = 0 @@ -494,10 +489,7 @@ p += 1 u = x + p if z < 0: - sgngam = -1 z = -z - else: - sgngam = 1 if u == 2: return log(z) p -= 2 @@ -1121,11 +1113,11 @@ def incbi(aa, bb, yy0): """Incomplete beta inverse function. See Cephes for docs.""" # handle easy cases first - i = 0 if yy0 <= 0: return 0.0 elif yy0 >= 1.0: return 1.0 + # define inscrutable parameters x0 = 0.0 yl = 0.0 diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/test.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/test.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/stats/test.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/stats/test.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Provides standard statistical tests. Tests produce statistic and P-value. """ @@ -69,7 +68,7 @@ "Michael Dwan", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -604,7 +603,7 @@ AttributeError, TypeError, FloatingPointError, - ) as e: + ): # invalidate if the sample sizes are wrong, the values aren't numeric or # aren't present, etc. result = (None, None) @@ -1172,7 +1171,6 @@ Sx = npsum(x) Sy = npsum(y) Sxx = npsum(x * x) - Syy = npsum(y * y) Sxy = npsum(x * y) det = Sxx * N - Sx * Sx return (Sxy * N - Sy * Sx) / det, (Sxx * Sy - Sx * Sxy) / det @@ -1376,7 +1374,7 @@ """ try: return chi_high(-2 * npsum(list(map(log, probs))), 2 * len(probs)) - except OverflowError as e: + except OverflowError: return 0.0 @@ -1660,17 +1658,14 @@ combined.sort(order="stat") prev = None start = None - ties = False T = 0.0 for index in range(combined.shape[0]): value = combined["stat"][index] - sample = combined["sample"][index] if value == prev and start is None: start = index continue if value != prev and start is not None: - ties = True ave_rank = _average_rank(start, index) num_tied = index - start + 1 T += num_tied ** 3 - num_tied diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/maths/util.py python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/util.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/maths/util.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/maths/util.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,44 +1,8 @@ -#!/usr/bin/env python """Provides small utility functions for numpy arrays. """ -from operator import __getitem__ as getitem -from operator import mul - import numpy -from numpy import ( - arange, - argmin, - argsort, - array, - clip, - compress, - concatenate, - cumsum, - identity, - less, - log, - logical_not, - maximum, - min, - newaxis, - nonzero, - pi, - product, - put, - ravel, - repeat, - reshape, - searchsorted, - sort, - sqrt, - sum, - take, - trace, - where, - zeros, -) -from numpy.random import normal, randint +from numpy import array, clip, cumsum, searchsorted, sort, sum numerictypes = numpy.core.numerictypes.sctype2char @@ -50,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Sandra Smit", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/blast.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/blast.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/blast.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/blast.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,7 +1,5 @@ -#!/usr/bin/env python """Parsers for blast, psi-blast and blat. """ -from cogent3.parse.record import RecordError from cogent3.parse.record_finder import ( DelimitedRecordFinder, LabeledRecordFinder, @@ -13,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Micah Hamady", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Micah Hamady" __email__ = "hamady@colorado.edu" __status__ = "Prototype" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/blast_xml.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/blast_xml.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/blast_xml.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/blast_xml.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Parsers for XML output of blast, psi-blast and blat. """ @@ -7,16 +6,14 @@ __contributors__ = ["Micah Hamady"] __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Kristian Rother" __email__ = "krother@rubor.de" __status__ = "Prototype" import xml.dom.minidom -from operator import eq as _eq from operator import gt as _gt -from operator import le as _le from operator import lt as _lt from cogent3.parse.blast import MinimalBlastParser9, MinimalPsiBlastParser9 @@ -261,19 +258,14 @@ # code below copied from BlastResult, unchanged. mp = parser(data, True) - for props, rec_data in mp: - - iteration = 1 - if self.ITERATION in props: - iteration = int(props[self.ITERATION]) - + for _, rec_data in mp: hits = [] # check if found any hits if len(rec_data) > 1: for h in rec_data[1:]: hits.append(dict(list(zip(rec_data[0], h)))) else: - hits.append(dict(list(zip(rec_data[0], ["" for x in rec_data[0]])))) + hits.append(dict(list(zip(rec_data[0], ["" for _ in rec_data[0]])))) # get blast version of query id query_id = hits[0][self.QUERY_ID] diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/cigar.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/cigar.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/cigar.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/cigar.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Parsers for the cigar format Cigar stands for Compact Idiosyncratic gapped Alignment Report and defines the sequence @@ -19,14 +18,14 @@ import re from cogent3 import DNA, make_aligned_seqs -from cogent3.core.location import LostSpan, Map, Span, _LostSpan +from cogent3.core.location import LostSpan, Map, Span __author__ = "Hua Ying" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Hua Ying"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Hua Ying" __email__ = "hua.ying@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/cisbp.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/cisbp.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/cisbp.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/cisbp.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/clustal.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/clustal.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/clustal.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/clustal.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Sandra Smit", "Gavin Huttley", "Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/cogent3_json.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/cogent3_json.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/cogent3_json.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/cogent3_json.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Stephen Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/dialign.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/dialign.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/dialign.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/dialign.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/ebi.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/ebi.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/ebi.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/ebi.py 2021-10-12 00:17:34.000000000 +0000 @@ -3,7 +3,7 @@ """ import sys -from pprint import pformat, pprint +from pprint import pprint from cogent3.core.sequence import Sequence from cogent3.parse.record import FieldError, RecordError @@ -11,9 +11,8 @@ DelimitedRecordFinder, LabeledRecordFinder, TailedRecordFinder, - is_empty, ) -from cogent3.util.misc import NestedSplitter, curry, identity, list_flatten +from cogent3.util.misc import NestedSplitter, curry, list_flatten __author__ = "Zongzhi Liu and Sandra Smit" @@ -26,7 +25,7 @@ "Daniel McDonald", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Zongzhi Liu" __email__ = "zongzhi.liu@gmail.com" __status__ = "Development" @@ -254,7 +253,7 @@ try: dict(pairs) # catch error for any not splitted pair. - except ValueError as e: # dictionary update sequence element #1 has length 1; + except ValueError: # dictionary update sequence element #1 has length 1; if strict: raise ValueError("e\nFailed to get a dict from pairs: %s" % pairs) else: @@ -820,7 +819,7 @@ desc = description.rstrip(" )") try: mutation, comment = desc.split(mutation_comment_delimiter, 1) - except ValueError as e: # too many values to unpack + except ValueError: # too many values to unpack mutation, comment = desc, "" # split mutation into mut_from, mut_to @@ -828,7 +827,7 @@ mutation_delimiter = "->" try: mut_from, mut_to = list(map(strip, mutation.split(mutation_delimiter, 1))) - except ValueError as e: # too many values to unpack + except ValueError: # too many values to unpack mut_from, mut_to = mutation, "" # replace desc in fields with mut_from, mut_to and comment to get the @@ -1501,7 +1500,6 @@ "KW": kw_parser, "FT": ft_parser, "SQ": sq_parser, - "XX": None, "PR": pr_parser, "XX": None, "FH": None, @@ -1542,7 +1540,7 @@ sequence = seq_constructor(sequence) try: header = header_constructor(header_dict, strict=strict) - except (RecordError, FieldError, ValueError) as e: + except (RecordError, FieldError, ValueError): if strict: #!! just raise is better than raise RecordError raise # RecordError, str(e) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/fasta.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/fasta.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/fasta.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/fasta.py 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Development" @@ -154,7 +154,7 @@ try: name, info = info_maker(label) # will raise exception if bad yield name, seq_maker(seq, name=name, info=info) - except Exception as e: + except Exception: raise RecordError( "Sequence construction failed on record with label %s" % label ) @@ -163,7 +163,7 @@ try: name, info = info_maker(label) yield (name, seq_maker(seq, name=name, info=info)) - except Exception as e: + except Exception: continue diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/gbseq.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/gbseq.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/gbseq.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/gbseq.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield", "Peter Maxwell", "Gavin Huttley", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/gcg.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/gcg.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/gcg.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/gcg.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,10 +1,8 @@ -#!/usr/bin/env python - __author__ = "Matthew Wakefield" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield", "Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" @@ -14,11 +12,10 @@ def MsfParser(f): """Read sequences from a msf format file""" - alignmentdict = {} # parse optional header # parse optional text information # file header and sequence header are seperated by a line ending in '..' - line = f.readline().strip() + _ = f.readline() for line in f: line = line.strip() if line.endswith(".."): @@ -36,23 +33,23 @@ sequences = {} for line in f: line = line.strip().split() - if line and line[0] in sequences: - sequences[line[0]] += "".join(line[1:]) - elif line and line[0] in seqinfo: - sequences[line[0]] = "".join(line[1:]) + if line: + if line[0] in sequences: + sequences[line[0]] += "".join(line[1:]) + elif line[0] in seqinfo: + sequences[line[0]] = "".join(line[1:]) # consistency check if len(sequences) != len(seqinfo): warnings.warn( "Number of loaded seqs[%s] not same as " "expected[%s]." % (len(sequences), len(seqinfo)) ) - for name in sequences: - if len(sequences[name]) != seqinfo[name]: + for name, value_ in sequences.items(): + if len(value_) != seqinfo[name]: warnings.warn( "Length of loaded seqs [%s] is [%s] not " "[%s] as expected." % (name, len(sequences[name]), seqinfo[name]) ) # yield sequences - for name in sequences: - yield (name, sequences[name]) + yield from sequences.items() diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/genbank.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/genbank.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/genbank.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/genbank.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Peter Maxwell", "Matthew Wakefield", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/gff.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/gff.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/gff.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/gff.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ "Christopher Bradley", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/greengenes.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/greengenes.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/greengenes.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/greengenes.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Daniel McDonald"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Daniel McDonald" __email__ = "daniel.mcdonald@colorado.edu" __status__ = "Prototype" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -48,7 +48,7 @@ "Marcin Cieslik", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/jaspar.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/jaspar.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/jaspar.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/jaspar.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/locuslink.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/locuslink.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/locuslink.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/locuslink.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Parsers for the LL_tmpl file from LocusLink. Notes: @@ -56,7 +55,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Development" @@ -373,12 +372,3 @@ for record in LLFinder(lines): curr = LinesToLocusLink(record) yield curr - - -if __name__ == "__main__": - from sys import argv, stdout - - filename = argv[1] - count = 0 - for record in LocusLinkParser(open(filename)): - print(record) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/ncbi_taxonomy.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/ncbi_taxonomy.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/ncbi_taxonomy.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/ncbi_taxonomy.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jason Carnes", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Jason Carnes" __email__ = "jason.carnes@sbri.org" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/newick.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/newick.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/newick.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/newick.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Andrew Butterfield", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/nexus.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/nexus.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/nexus.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/nexus.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Catherine Lozuopone", "Rob Knight", "Micah Hamady", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Catherine Lozupone" __email__ = "lozupone@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/paml_matrix.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/paml_matrix.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/paml_matrix.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/paml_matrix.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,9 +1,5 @@ -#!/usr/bin/env python - import numpy -from cogent3.evolve import substitution_model - Float = numpy.core.numerictypes.sctype2char(float) @@ -12,7 +8,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/paml.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/paml.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/paml.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/paml.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,32 +1,43 @@ #!/usr/bin/env python +from io import TextIOWrapper + __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" -def PamlParser(f): - d = f.readline().split() - numseqs, seqlen = int(d[0]), int(d[1]) - for i in range(numseqs): - seqname = f.readline().strip() - if not seqname: - raise ValueError("Sequence name missing") - currseq = [] - length = 0 - while length < seqlen: - seq_line = f.readline() - if not seq_line: - raise ValueError( - 'Sequence "%s" is short: %s < %s' % (seqname, length, seqlen) - ) - seq_line = seq_line.strip() - length += len(seq_line) - currseq.append(seq_line) +def PamlParser(data): + if isinstance(data, TextIOWrapper): + data = data.read().splitlines() + num_seqs, seq_len = [int(v) for v in data[0].split()] + curr_seq = [] + curr_length = 0 + seqname = None + n = 0 + for line in data[1:]: + line = line.strip() + if not line: + continue + + if seqname is None: + seqname = line + continue + + curr_length += len(line) + curr_seq.append(line) + if curr_length == seq_len: + yield seqname, "".join(curr_seq) + + seqname = None + curr_seq = [] + curr_length = 0 + n += 1 - yield (seqname, "".join(currseq)) + if n != num_seqs: + raise ValueError(f"read {n} seqs, expected {num_seqs}") diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/phylip.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/phylip.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/phylip.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/phylip.py 2021-10-12 00:17:34.000000000 +0000 @@ -7,7 +7,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Micah Hamady", "Peter Maxwell", "Gavin Huttley", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Micah Hamady" __email__ = "hamady@colorado.edu" __status__ = "Prototype" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/psl.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/psl.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/psl.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/psl.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Peter Maxwell", "Gavin Huttley", "Anuj Pahwa"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/rdb.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/rdb.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/rdb.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/rdb.py 2021-10-12 00:17:34.000000000 +0000 @@ -6,7 +6,7 @@ from cogent3.core.alphabet import AlphabetError from cogent3.core.info import Info -from cogent3.core.sequence import RnaSequence, Sequence +from cogent3.core.sequence import RnaSequence from cogent3.parse.record import RecordError from cogent3.parse.record_finder import DelimitedRecordFinder @@ -15,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Sandra Smit", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Sandra Smit" __email__ = "sandra.smit@colorado.edu" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/record_finder.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/record_finder.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/record_finder.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/record_finder.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Provides some classes for treating files as sequences of records. Typically more useful as subclasses. Covers the three main types of records: @@ -13,14 +12,14 @@ DelimitedRecordFinder except that it accept a is_tail function instead of a str. Note that its default constuctor is rstrip instead of strip. """ -from cogent3.parse.record import FieldError, RecordError +from cogent3.parse.record import RecordError __author__ = "Rob Knight" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Gavin Huttley", "Zongzhi Liu"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/record.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/record.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/record.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/record.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/sequence.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/sequence.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/sequence.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/sequence.py 2021-10-12 00:17:34.000000000 +0000 @@ -30,7 +30,7 @@ "Rob Knight", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/table.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/table.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/table.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/table.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,10 +1,6 @@ -#!/usr/bin/env python - import csv import pathlib -from collections.abc import Callable - from cogent3.util.misc import open_ from cogent3.util.warning import deprecated @@ -15,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/tinyseq.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/tinyseq.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/tinyseq.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/tinyseq.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield", "Peter Maxwell", "Gavin Huttley", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/tree.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/tree.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/tree.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/tree.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Catherine Lozupone", "Daniel McDonald"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/tree_xml.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/tree_xml.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/tree_xml.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/tree_xml.py 2021-10-12 00:17:34.000000000 +0000 @@ -35,7 +35,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/parse/unigene.py python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/unigene.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/parse/unigene.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/parse/unigene.py 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/consensus.py python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/consensus.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/consensus.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/consensus.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield", "Peter Maxwell", "Gavin Huttley", "Ben Kaehler"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,8 +1,5 @@ -#!/usr/bin/env python - __all__ = [ "consensus", - "distance", "least_squares", "maximum_likelihood", "nj", @@ -14,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Peter Maxwell", "Matthew Wakefield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/least_squares.py python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/least_squares.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/least_squares.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/least_squares.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/maximum_likelihood.py python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/maximum_likelihood.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/maximum_likelihood.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/maximum_likelihood.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,8 +1,4 @@ -#!/usr/bin/env python' -from math import exp - from .least_squares import WLS -from .tree_collection import make_trees # only for back compat. from .tree_collection import LogLikelihoodScoredTreeCollection from .tree_space import TreeEvaluator, ancestry2tree @@ -11,7 +7,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/nj.py python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/nj.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/nj.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/nj.py 2021-10-12 00:17:34.000000000 +0000 @@ -24,7 +24,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/tree_collection.py python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/tree_collection.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/tree_collection.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/tree_collection.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Ben Kaehler"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/tree_space.py python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/tree_space.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/tree_space.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/tree_space.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/util.py python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/util.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/phylo/util.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/phylo/util.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "pm67nz@gmail.com" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/calculation.py python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/calculation.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/calculation.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/calculation.py 2021-10-12 00:17:34.000000000 +0000 @@ -2,7 +2,6 @@ import os import time -import warnings import numpy @@ -20,7 +19,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Daniel McDonald"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" @@ -213,8 +212,8 @@ other_cells.append(cell) self._cells = self.opt_pars + other_cells data_sets = [[0], [0, 1]][self.with_undo] - self.cell_values = [[None] * len(self._cells) for switch in data_sets] - self.arg_ranks = [[] for cell in self._cells] + self.cell_values = [[None] * len(self._cells) for _ in data_sets] + self.arg_ranks = [[] for _ in self._cells] for (i, cell) in enumerate(self._cells): cell.rank = i cell.consequences = {} @@ -236,7 +235,7 @@ cell.prime(self.cell_values) except KeyboardInterrupt: raise - except Exception as detail: + except Exception: print(("Failed initial calculation of %s" % cell.name)) raise else: @@ -531,9 +530,9 @@ elapsed[cell.rank] = t1 - t0 tds = [] - for ((name, cells), width) in self._cellsGroupedForDisplay: - text = "".join([" +"[cell.rank in elapsed] for cell in cells]) - elap = sum([elapsed.get(cell.rank, 0) for cell in cells]) + for ((_, cells), width) in self._cellsGroupedForDisplay: + text = "".join(" +"[cell.rank in elapsed] for cell in cells) + elap = sum(elapsed.get(cell.rank, 0) for cell in cells) if len(text) > width - 4: edge_width = min(len(text), (width - 4 - 3)) // 2 elipsis = [" ", "..."][not not text.strip()] diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/definition.py python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/definition.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/definition.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/definition.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """A recalculation engine, something like a spreadsheet. Goals: @@ -64,13 +63,11 @@ the one to be used next for recycling. """ -import warnings from collections import defaultdict import numpy -from cogent3.maths.stats.distribution import chdtri from cogent3.maths.util import proportions_to_ratios, ratios_to_proportions from cogent3.util.dict_array import DictArrayTemplate @@ -89,7 +86,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" @@ -192,11 +189,13 @@ """Uses a PartitionDefn (ie: N-1 optimiser parameters) to make an array of floats with weighted average of 1.0""" - def __init__(self, weights, name): + def __init__(self, weights, name=None): N = len(weights.bin_names) partition = PartitionDefn(size=N, name=name + "_partition") partition.user_param = False - CalculationDefn.__init__(self, weights, partition, name=name + "_distrib") + super(WeightedPartitionDefn, self).__init__( + weights, partition, name=name + "_distrib" + ) def calc(self, weights, values): scale = numpy.sum(weights * values) @@ -498,7 +497,6 @@ # This was originally put in its own function so as to provide a # closure containing the value of sum(value), which is no longer # required since it is now always 1.0. - N = len(value) assert abs(sum(value) - 1.0) < 0.00001 ratios = proportions_to_ratios(value) ratios = [LogOptPar(name + "_ratio", scope, (1e-6, r, 1e6)) for r in ratios] diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/scope.py python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/scope.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/scope.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/scope.py 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" @@ -452,7 +452,7 @@ class _NonLeafDefn(_Defn): def __init__(self, *args, **kw): - _Defn.__init__(self) + super(_NonLeafDefn, self).__init__() valid_dimensions = [] for arg in args: assert isinstance(arg, _Defn), type(arg) @@ -508,7 +508,7 @@ def __init__( self, name=None, extra_label=None, dimensions=None, independent_by_default=None ): - _Defn.__init__(self) + super(_LeafDefn, self).__init__() if dimensions is not None: assert type(dimensions) in [list, tuple], type(dimensions) self.valid_dimensions = tuple(dimensions) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/setting.py python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/setting.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/recalculation/setting.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/recalculation/setting.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/checkpointing.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/checkpointing.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/checkpointing.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/checkpointing.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/deserialise.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/deserialise.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/deserialise.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/deserialise.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,6 +1,5 @@ #!/usr/bin/env python import json -import os from importlib import import_module @@ -16,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -176,8 +175,7 @@ data["moltype"] = get_moltype(data.pop("moltype")) annotations = data.pop("annotations", None) make_seq = data["moltype"].make_seq - type_ = data.pop("type") - klass = _get_class(type_) + _ = data.pop("type") if "-" in data["seq"]: aligned = True diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/dict_array.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/dict_array.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/dict_array.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/dict_array.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Wrapper for numpy arrays so that they can be indexed by name >>> a = numpy.identity(3, int) @@ -34,7 +33,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Ben Kaehler"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" @@ -546,7 +545,7 @@ def row_sum(self): """returns DictArray summed across rows""" axis = 1 if len(self.shape) == 2 else 0 - result = self.array.sum(axis=1) + result = self.array.sum(axis=axis) template = DictArrayTemplate(self.template.names[0]) return template.wrap(result) diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/__init__.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/__init__.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -2,14 +2,15 @@ __all__ = [ "checkpointing", "deserialise", + "dict_array", "misc", - "modules", "parallel", + "progress_display", + "recode_alignment", "table", "transform", "union_dict", "warning", - "recode_alignment", ] __author__ = "" @@ -27,7 +28,7 @@ "Thomas La", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/misc.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/misc.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/misc.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/misc.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """Generally useful utility classes and methods. """ import os @@ -14,7 +13,7 @@ from os import path as os_path from os import remove from pathlib import Path -from random import choice, randint +from random import randint from tempfile import mkdtemp from warnings import warn from zipfile import ZipFile @@ -22,7 +21,7 @@ import numpy from chardet import detect -from numpy import array, ceil, finfo, float64, floor, log10, logical_not, sum +from numpy import array, finfo, float64 __author__ = "Rob Knight" @@ -38,7 +37,7 @@ "Marcin Cieslik", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -404,7 +403,7 @@ """return True if obj is iterable""" try: iter(obj) - except TypeError as e: + except TypeError: return False else: return True @@ -1158,7 +1157,6 @@ starts, ends, vals = list(zip(*spans_value)) indices_distinct_vals = get_run_start_indices(vals, digits=digits) data = [] - i = 0 for index, val in indices_distinct_vals: start = starts[index] end = ends[index] diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/parallel.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/parallel.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/parallel.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/parallel.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,17 +1,9 @@ -#!/usr/bin/env python - import concurrent.futures as concurrentfutures -import math import multiprocessing import os -import random import sys -import threading -import time import warnings -import numpy - from cogent3.util.misc import extend_docstring_from @@ -23,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Sheng Han Moses Koh", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/progress_display.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/progress_display.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/progress_display.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/progress_display.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Sheng Han Moses Koh"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/recode_alignment.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/recode_alignment.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/recode_alignment.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/recode_alignment.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,7 +1,3 @@ -#!/usr/bin/env python -# Author: Greg Caporaso (gregcaporaso@gmail.com) -# recode_alignment.py - """This file contains functions for recoding alignment objects with reduced-state alphabets, and also defines some reduced-state alphabets. @@ -38,12 +34,10 @@ """ -from optparse import OptionParser from numpy import array, take, zeros -from cogent3 import PROTEIN -from cogent3.core.alignment import Alignment, ArrayAlignment +from cogent3.core.alignment import ArrayAlignment from cogent3.evolve.models import DSO78_freqs, DSO78_matrix @@ -51,7 +45,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Greg Caporaso"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Greg Caporaso" __email__ = "gregcaporaso@gmail.com" __status__ = "Beta" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/table.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/table.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/table.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/table.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ A light-weight Table class for manipulating 2D data and representing it as text, or writing to file for import into other packages. @@ -45,7 +44,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Felix Schill", "Sheng Koh"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -1731,7 +1730,6 @@ formatted_table = bedgraph.bedgraph(self.sorted().array.tolist(), **kwargs) return formatted_table - missing_data = "0.0000" if format.lower() == "phylip" else self._missing_data if format.lower() in ("tsv", "csv"): sep = sep or {"tsv": "\t", "csv": ","}[format.lower()] format = "" @@ -1755,7 +1753,7 @@ return self.to_latex(concat_title_legend=concat_title_legend, **kwargs) if format == "html": - return self.to_rich_html(**kwargs) + return self.to_html(**kwargs) if format == "phylip": # need to eliminate row identifiers @@ -1812,90 +1810,6 @@ header, formatted_table, title=title, legend=legend, sep="\t" ) - def to_rich_html( - self, - row_cell_func=None, - header_cell_func=None, - element_formatters=None, - merge_identical=False, - compact=False, - ): # pragma: no cover - """returns just the table as html. - - Parameters - ---------- - row_cell_func - callback function that formats the row values. Must - take the row value and coordinates (row index, column index). - header_cell_func - callback function that formats the column headings - must take the header label value and coordinate - element_formatters - a dictionary of specific callback funcs for - formatting individual html table elements. - e.g. {'table': lambda x: ''} - merge_identical - cells within a row are merged to one span. - - """ - deprecated("method", "to_rich_html", "to_html", "2021.10") - - element_formatters = element_formatters or {} - formatted_table = self.array.tolist() - header, formatted_table = table_format.formatted_cells( - formatted_table, - self.header, - digits=self._digits, - column_templates=self._column_templates, - missing_data=self._missing_data, - ) - subtables = table_format.get_continuation_tables( - header, - formatted_table, - identifiers=self.index_name, - max_width=self._max_width, - ) - tables = [] - title = self.title if self.title else "" - if title: - title = escape(title) - legend = self.legend if self.legend else "" - if legend: - legend = escape(legend) - - for i, (h, t) in enumerate(subtables): - # but we strip the cell spacing - sh = [v.strip() for v in h] - t = [[c.strip() for c in r] for r in t] - - if title and i == 0: - st = element_formatters.get( - "caption", f'{title}' - ) - elif title: - st = element_formatters.get( - "caption", f'continuation' - ) - else: - st = None - - if legend and i == 0: - title = f"{st} {legend}" if st else legend - - caption = st if st else None - subtable = table_format.rich_html( - t, - row_cell_func=row_cell_func, - header=sh, - header_cell_func=header_cell_func, - element_formatters=element_formatters, - merge_identical=merge_identical, - compact=compact, - caption=caption, - ) - tables.append(subtable) - return "\n".join(tables) - def to_html(self, column_alignment=None): """construct html table @@ -1961,11 +1875,11 @@ for v in cols[c] ] - title = self.title if self.title else "" + title = self.title or "" if title and not table_format.is_html_markup(title): title = escape(title) - legend = self.legend if self.legend else "" + legend = self.legend or "" if legend and not table_format.is_html_markup(legend): legend = escape(legend) @@ -1985,7 +1899,7 @@ caption = str(HtmlElement(st, "caption", newline=True)) if st else "" rows = [] for i, row in enumerate(zip(*[cols[c] for c in header])): - txt = HtmlElement("".join([str(e) for e in row]), "tr") + txt = HtmlElement("".join(str(e) for e in row), "tr") rows.append(str(txt)) rows = str(HtmlElement("\n".join(rows), "tbody", newline=True)) @@ -1996,7 +1910,7 @@ for c in header ] - header = "".join([str(HtmlElement(c, "th")) for c in header]) + header = "".join(str(HtmlElement(c, "th")) for c in header) header = str( HtmlElement(header, "thead", css_classes=["head_cell"], newline=True) ) @@ -2117,7 +2031,7 @@ draw.layout |= default_layout return draw - def to_categorical(self, columns=None): + def to_categorical(self, columns=None, index_name=None): """construct object that can be used for statistical tests Parameters @@ -2140,8 +2054,9 @@ from cogent3.maths.stats.contingency import CategoryCounts from cogent3.util.dict_array import DictArrayTemplate + self.index_name = index_name if index_name is not None else self.index_name if self.index_name is None: - raise ValueError(f"requires index_name be set") + raise ValueError("requires index_name be set") columns = list(self.header) if columns is None else columns diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/transform.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/transform.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/transform.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/transform.py 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Sandra Smit", "Rob Knight", "Zongzhi Liu"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Sandra Smit" __email__ = "sandra.smit@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/union_dict.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/union_dict.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/union_dict.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/union_dict.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,16 +1,12 @@ -#!/usr/bin/env python """UnionDict extension of dict. """ -import sys - -from cogent3.util.misc import extend_docstring_from __author__ = "Thomas La" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -45,8 +41,9 @@ def __getattr__(self, item): if item in self: return self.get(item) + try: - result = super().__getattr__(item) + return super().__getattr__(item) except AttributeError: raise AttributeError(f"'{item}' not a key or attribute") diff -Nru python-cogent-2021.5.7a+dfsg/src/cogent3/util/warning.py python-cogent-2021.10.12a1+dfsg/src/cogent3/util/warning.py --- python-cogent-2021.5.7a+dfsg/src/cogent3/util/warning.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/src/cogent3/util/warning.py 2021-10-12 00:17:34.000000000 +0000 @@ -7,7 +7,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Jai Ram Rideout"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/benchmark_aligning.py python-cogent-2021.10.12a1+dfsg/tests/benchmark_aligning.py --- python-cogent-2021.5.7a+dfsg/tests/benchmark_aligning.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/benchmark_aligning.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Peter Maxwell" __email__ = "pm67nz@gmail.com" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/benchmark.py python-cogent-2021.10.12a1+dfsg/tests/benchmark.py --- python-cogent-2021.5.7a+dfsg/tests/benchmark.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/benchmark.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/__init__.py python-cogent-2021.10.12a1+dfsg/tests/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -21,7 +21,7 @@ "Edward Lang", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_align/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_align/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_align/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_align/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jeremy Widmann", "Peter Maxwell", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Jeremy Widmann" __email__ = "jeremy.widmann@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_align/test_align.py python-cogent-2021.10.12a1+dfsg/tests/test_align/test_align.py --- python-cogent-2021.5.7a+dfsg/tests/test_align/test_align.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_align/test_align.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_align.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_align.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_align.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_align.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,16 +1,33 @@ from unittest import TestCase, main -from cogent3 import DNA, get_moltype, make_tree, make_unaligned_seqs +from cogent3 import ( + DNA, + get_moltype, + make_aligned_seqs, + make_tree, + make_unaligned_seqs, +) from cogent3.align.align import make_generic_scoring_dict from cogent3.app import align as align_app +from cogent3.app.align import ( + _combined_refseq_gaps, + _gap_difference, + _gap_union, + _GapOffset, + _gaps_for_injection, + _merged_gaps, + pairwise_to_multiple, +) from cogent3.app.composable import NotCompleted +from cogent3.core.alignment import Aligned +from cogent3.core.location import gap_coords_to_map __author__ = "Gavin Huttley" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -48,9 +65,29 @@ ] +def make_pairwise(data, refseq_name, moltype="dna", array_align=False): + """returns series of refseq, [(n, pwise aln),..]. All alignments are to ref_seq""" + aln = make_aligned_seqs( + data, + array_align=array_align, + moltype=moltype, + ) + refseq = aln.get_seq(refseq_name) + pwise = [ + (n, aln.take_seqs([refseq_name, n]).omit_gap_pos()) + for n in aln.names + if n != refseq_name + ] + return refseq, pwise + + +def make_aligned(gaps_lengths, seq, name="seq1"): + seq = seq.moltype.make_seq(seq, name=name) + return Aligned(gap_coords_to_map(gaps_lengths, len(seq)), seq) + + class RefalignmentTests(TestCase): seqs = make_unaligned_seqs(_seqs, moltype=DNA) - treestring = "(Bandicoot:0.4,FlyingFox:0.05,(Rhesus:0.06," "Human:0.0):0.04);" def test_align_to_ref(self): """correctly aligns to a reference""" @@ -81,6 +118,210 @@ got = aligner(self.seqs) self.assertEqual(got.moltype.label, "dna") + def test_merged_gaps(self): + """correctly merges gaps""" + a = dict([(2, 3), (4, 9)]) + b = dict([(2, 6), (8, 5)]) + # omitting one just returns the other + self.assertIs(_merged_gaps(a, {}), a) + self.assertIs(_merged_gaps({}, b), b) + got = _merged_gaps(a, b) + self.assertEqual(got, [(2, 6), (4, 9), (8, 5)]) + + def test_aln_to_ref_known(self): + """correctly recapitulates known case""" + orig = make_aligned_seqs( + { + "Ref": "CAG---GAGAACAGAAACCCAT--TACTCACT", + "Qu1": "CAG---GAGAACAG---CCCGTGTTACTCACT", + "Qu2": "CAGCATGAGAACAGAAACCCGT--TA---ACT", + "Qu3": "CAGCATGAGAACAGAAACCCGT----CTCACT", + "Qu4": "CAGCATGAGAACAGAAACCCGTGTTACTCACT", + "Qu5": "CAG---GAGAACAG---CCCAT--TACTCACT", + "Qu6": "CAG---GA-AACAG---CCCAT--TACTCACT", + "Qu7": "CAG---GA--ACAGA--CCCGT--TA---ACT", + }, + moltype="dna", + ) + expect = orig.to_dict() + aligner = align_app.align_to_ref(ref_seq="Ref") + aln = aligner(orig.degap()) + self.assertEqual(aln.to_dict(), expect) + + def test_gap_union(self): + """correctly identifies the union of all gaps""" + # fails if not all sequences same + seq = DNA.make_seq("AACCCGTT") + all_gaps = dict([(0, 3), (2, 1), (5, 3), (6, 3)]) + final_seq = make_aligned(all_gaps, seq) + gap_sets = [ + dict([(5, 1), (6, 3)]), + dict([(2, 1), (5, 3)]), + dict([(2, 1), (5, 1), (6, 2)]), + dict([(0, 3)]), + ] + seqs = [make_aligned(gaps, seq) for gaps in gap_sets] + got = _gap_union(seqs) + self.assertEqual(got, dict(all_gaps)) + + # must all be Aligned instances + with self.assertRaises(TypeError): + _gap_union(seqs + ["GGGGGGGG"]) + + # must all have the same name + with self.assertRaises(ValueError): + _gap_union(seqs + [make_aligned({}, seq, name="blah")]) + + def test_gap_difference(self): + """correctly identifies the difference in gaps""" + seq = DNA.make_seq("AACCCGTT") + all_gaps = dict([(0, 3), (2, 1), (5, 3), (6, 3)]) + gap_sets = [ + dict([(5, 1), (6, 3)]), + dict([(2, 1), (5, 3)]), + dict([(2, 1), (5, 1), (6, 2)]), + dict([(0, 3)]), + ] + seqs = [make_aligned(gaps, seq) for gaps in gap_sets] + union = _gap_union(seqs) + expects = [ + [dict([(0, 3), (2, 1)]), dict([(5, 2)])], + [dict([(0, 3), (6, 3)]), {}], + [dict([(0, 3)]), dict([(5, 2), (6, 1)])], + [dict([(2, 1), (5, 3), (6, 3)]), {}], + ] + for seq, (plain, overlap) in zip(seqs, expects): + seq_gaps = dict(seq.map.get_gap_coordinates()) + got_plain, got_overlap = _gap_difference(seq_gaps, union) + self.assertEqual(got_plain, dict(plain)) + self.assertEqual(got_overlap, dict(overlap)) + + def test_merged_gaps(self): + """correctly handles gap values""" + a_gaps = {0: 2} + b_gaps = {2: 2} + self.assertEqual(_merged_gaps(a_gaps, {}), a_gaps) + self.assertEqual(_merged_gaps({}, b_gaps), b_gaps) + + def test_combined_refseq_gaps(self): + union = dict([(0, 3), (2, 1), (5, 3), (6, 3)]) + gap_sets = [ + [(5, 1), (6, 3)], + [(2, 1), (5, 3)], + [(2, 1), (5, 1), (6, 2)], + [(0, 3)], + ] + # for subset gaps, their alignment position is the + # offset + their position + their gap length + expects = [ + dict([(6, 2), (0, 3), (2, 1)]), + dict([(0, 3), (10, 3)]), + dict([(0, 3), (5 + 1 + 1, 2), (6 + 2 + 2, 1)]), + dict([(2 + 3, 1), (5 + 3, 3), (6 + 3, 3)]), + ] + for i, gap_set in enumerate(gap_sets): + got = _combined_refseq_gaps(dict(gap_set), union) + self.assertEqual(got, expects[i]) + + # if union gaps equals ref gaps + got = _combined_refseq_gaps({2: 2}, {2: 2}) + self.assertEqual(got, {}) + + def test_gaps_for_injection(self): + # for gaps before any otherseq gaps, alignment coord is otherseq coord + oseq_gaps = {2: 1, 6: 2} + rseq_gaps = {0: 3} + expect = {0: 3, 2: 1, 6: 2} + seqlen = 50 + got = _gaps_for_injection(oseq_gaps, rseq_gaps, seqlen) + self.assertEqual(got, expect) + # for gaps after otherseq gaps seq coord is align coord minus gap + # length totals + got = _gaps_for_injection(oseq_gaps, {4: 3}, seqlen) + expect = {2: 1, 3: 3, 6: 2} + self.assertEqual(got, expect) + got = _gaps_for_injection(oseq_gaps, {11: 3}, seqlen) + expect = {2: 1, 6: 2, 8: 3} + self.assertEqual(got, expect) + # gaps beyond sequence length added to end of sequence + got = _gaps_for_injection({2: 1, 6: 2}, {11: 3, 8: 3}, 7) + expect = {2: 1, 6: 2, 7: 6} + self.assertEqual(got, expect) + + def test_pairwise_to_multiple(self): + """the standalone function constructs a multiple alignment""" + expect = { + "Ref": "CAG---GAGAACAGAAACCCAT--TACTCACT", + "Qu1": "CAG---GAGAACAG---CCCGTGTTACTCACT", + "Qu2": "CAGCATGAGAACAGAAACCCGT--TA---ACT", + "Qu3": "CAGCATGAGAACAGAAACCCGT----CTCACT", + "Qu7": "CAG---GA--ACAGA--CCCGT--TA---ACT", + "Qu4": "CAGCATGAGAACAGAAACCCGTGTTACTCACT", + "Qu5": "CAG---GAGAACAG---CCCAT--TACTCACT", + "Qu6": "CAG---GA-AACAG---CCCAT--TACTCACT", + } + aln = make_aligned_seqs(expect, moltype="dna").omit_gap_pos() + expect = aln.to_dict() + for refseq_name in ["Qu3"]: + refseq, pwise = make_pairwise(expect, refseq_name) + got = pairwise_to_multiple(pwise, ref_seq=refseq, moltype=refseq.moltype) + self.assertEqual(len(got), len(aln)) + orig = dict(pwise) + _, pwise = make_pairwise(got.to_dict(), refseq_name) + got = dict(pwise) + # should be able to recover the original pairwise alignments + for key, value in got.items(): + self.assertEqual(value.to_dict(), orig[key].to_dict(), msg=refseq_name) + + with self.assertRaises(TypeError): + pairwise_to_multiple(pwise, "ACGG", DNA) + + def test_pairwise_to_multiple_2(self): + """correctly handle alignments with gaps beyond end of query""" + # cogent3.core.alignment.DataError: Not all sequences are the same length: + # max is 425, min is 419 + def make_pwise(data, ref_name): + result = [] + for n, seqs in data.items(): + result.append( + [n, make_aligned_seqs(data=seqs, moltype="dna", array_align=False)] + ) + ref_seq = result[0][1].get_seq(ref_name) + return result, ref_seq + + pwise = { + "Platypus": { + "Opossum": "-----------------GTGC------GAT-------------------------------CCAAAAACCTGTGTC--ACCGT--------GCC----CAGAGCCTCC----CTCAGGCCGCTCGGGGAG---TG-------GCCCCCCG--GC-GGAGGGCAGGGATGGGGAGT-AGGGGTGGCAGTC----GGAACTGGAAGAGCTT-TACAAACC---------GA--------------------GGCT-AGAGGGTC-TGCTTAC-------TTTTTACCTTGG------------GTTTG-CCAGGAGGTAG----------AGGATGA-----------------CTAC--ATCAAG----AGC------------TGGG-------------", + "Platypus": "CAGGATGACTACATCAAGAGCTGGGAAGATAACCAGCAAGGAGATGAAGCTCTGGACACTACCAAAGACCCCTGCCAGAACGTGAAGTGCAGCCGACACAAGGTCTGCATCGCTCAGGGCTACCAGAGAGCCATGTGTATCAGCCGCAAGAAGCTGGAGCACAGGATCAAGCAGCCAGCCCTGAAACTCCATGGAAACAGAGAGAGCTTCTGCAAGCCTTGTCACATGACCCAGCTGGCCTCTGTCTGCGGCTCGGACGGACACACTTACAGCTCCGTGTGCAAACTGGAGCAGCAGGCCTGTCTGACCAGCAAGCAGCTGACAGTCAAGTGTGAAGGCCAGTGCCCGTGCCCCACCGATCATGTTCCAGCCTCCACCGCTGATGGAAAACAAGAGACCT", + }, + "Wombat": { + "Opossum": "GTGCGATCCAAAAACCTGTGTCACCGTGCCCAGAGCCTCCCTCAGGCCGCTCGG-GGAGTGGCCCCCCGGCGGAGGGCAGGGATGGGGAGTAGGGGTGGCAGTCGGAACTGGAAGAGCTTTACAAACCGAGGCTAGAGGGTCTGCTTACTTTTTACCTTGG------GTTT--GC-CAGGA---GGT----AGAGGATGACTACATCAAGAGCTGGG---------------------------", + "Wombat": "--------CA----------TCACCGC-CCCTGCACC---------CGGCTCGGCGGAGGGGGATTCTAA-GGGGGTCAAGGATGGCGAG-ACCCCTGGCAATTTCA--TGGAGGA------CGAGCAATGGCT-----GTC-GTCCATCTCCCAGTATAGCGGCAAGATCAAGCACTGGAACCGCTTCCGAGACGATGACTACATCAAGAGCTGGGAGGACAGTCAGCAAGGAGATGAAGCGC", + }, + } + pwise, ref_seq = make_pwise(pwise, "Opossum") + aln = pairwise_to_multiple(pwise, ref_seq, ref_seq.moltype) + self.assertNotIsInstance(aln, NotCompleted) + + pwise = { + "Platypus": { + "Opossum": "-----------------GTGC------GAT-------------------------------CCAAAAACCTGTGTC", + "Platypus": "CAGGATGACTACATCAAGAGCTGGGAAGATAACCAGCAAGGAGATGAAGCTCTGGACACTACCAAAGACCCCTGCC", + }, + "Wombat": { + "Opossum": "GTGCGATCCAAAAACCTGTGTC", + "Wombat": "--------CA----------TC", + }, + } + pwise, ref_seq = make_pwise(pwise, "Opossum") + aln = pairwise_to_multiple(pwise, ref_seq, ref_seq.moltype) + self.assertNotIsInstance(aln, NotCompleted) + + +class ProgressiveAlignment(TestCase): + seqs = make_unaligned_seqs(_seqs, moltype=DNA) + treestring = "(Bandicoot:0.4,FlyingFox:0.05,(Rhesus:0.06," "Human:0.0):0.04);" + def test_progressive_align_protein_moltype(self): """tests guide_tree is None and moltype is protein""" from cogent3 import load_aligned_seqs @@ -204,5 +445,45 @@ self.assertEqual(len(aln), 14) +class GapOffsetTests(TestCase): + def test_empty(self): + """create an empty offset""" + goff = _GapOffset({}) + for i in range(4): + self.assertEqual(goff[i], 0) + + goff = _GapOffset({}, invert=True) + for i in range(4): + self.assertEqual(goff[i], 0) + + def test_repr_str(self): + """repr and str work""" + goff = _GapOffset({}, invert=True) + for func in (str, repr): + self.assertEqual(func(goff), "{}") + + def test_gap_offset(self): + goff = _GapOffset({1: 2, 3: 4}) + self.assertEqual(goff.min_pos, 1) + self.assertEqual(goff.max_pos, 3) + self.assertEqual(goff.total, 6) + self.assertEqual(goff[0], 0) + self.assertEqual(goff[1], 0) + self.assertEqual(goff[2], 2) + self.assertEqual(goff[3], 2) + self.assertEqual(goff[4], 6) + + def test_gap_offset_invert(self): + aln2seq = _GapOffset({2: 1, 5: 2, 7: 2}, invert=True) + self.assertEqual(aln2seq._store, {3: 1, 2: 0, 8: 3, 6: 1, 12: 5, 10: 3}) + self.assertEqual(aln2seq.max_pos, 12) + self.assertEqual(aln2seq.min_pos, 2) + self.assertEqual(aln2seq[11], 3) + seq2aln = _GapOffset({2: 1, 5: 2, 7: 2}) + for seq_pos in range(20): + aln_pos = seq_pos + seq2aln[seq_pos] + self.assertEqual(aln_pos - aln2seq[aln_pos], seq_pos) + + if __name__ == "__main__": main() diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_app_mpi.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_app_mpi.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_app_mpi.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_app_mpi.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,3 +1,5 @@ +from pathlib import Path +from tempfile import TemporaryDirectory from unittest import TestCase, main, skipUnless from cogent3.app import align as align_app @@ -10,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Sheng Han Moses Koh"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -24,27 +26,29 @@ """writing with overwrite in MPI should reset db""" dstore = io_app.get_data_store("data", suffix="fasta") members = dstore.filtered(callback=lambda x: "brca1.fasta" not in x.split("/")) - reader = io_app.load_unaligned() - aligner = align_app.align_to_ref() - writer = write_db("delme.tinydb", create=True, if_exists="overwrite") - process = reader + aligner + writer - - r = process.apply_to( - members, - logger=False, - show_progress=False, - parallel=True, - par_kw=dict(use_mpi=True), - ) - - expect = [str(m) for m in process.data_store] - process.data_store.close() - - # now get read only and check what's in there - result = io_app.get_data_store("delme.tinydb") - got = [str(m) for m in result] + with TemporaryDirectory(dir=".") as dirname: + path = Path(dirname) / "delme.tinydb" + reader = io_app.load_unaligned() + aligner = align_app.align_to_ref() + writer = write_db(path, create=True, if_exists="overwrite") + process = reader + aligner + writer + + r = process.apply_to( + members, + logger=False, + show_progress=False, + parallel=True, + par_kw=dict(use_mpi=True), + ) + + expect = [str(m) for m in process.data_store] + process.data_store.close() + + # now get read only and check what's in there + result = io_app.get_data_store(path) + got = [str(m) for m in result] - assert got == expect + assert got == expect if __name__ == "__main__": diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_composable.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_composable.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_composable.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_composable.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,6 +11,7 @@ SERIALISABLE_TYPE, ComposableSeq, NotCompleted, + appify, user_function, ) from cogent3.app.sample import min_length, omit_degenerates @@ -23,7 +24,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -368,6 +369,23 @@ self.assertEqual(got_1.to_dict(), {"a": "GCAA", "b": "GCTT"}) self.assertEqual(got_2, {("s1", "s2"): 2.0, ("s2", "s1"): 2.0}) + def test_appify(self): + """acts like a decorator should!""" + + @appify(SERIALISABLE_TYPE, SERIALISABLE_TYPE) + def slicer(val, index=2): + """my docstring""" + return val[:index] + + self.assertEqual(slicer.__doc__, "appify: my docstring") + self.assertEqual(slicer.__name__, "slicer") + app = slicer() + self.assertTrue(SERIALISABLE_TYPE in app._input_types) + self.assertTrue(SERIALISABLE_TYPE in app._output_types) + self.assertEqual(app(list(range(4))), [0, 1]) + app2 = slicer(index=3) + self.assertEqual(app2(list(range(4))), [0, 1, 2]) + def test_user_function_repr(self): u_function_1 = user_function(self.foo, "aligned", "aligned") u_function_2 = user_function(self.bar, "aligned", "pairwise_distances") diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_data_store.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_data_store.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_data_store.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_data_store.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,12 +1,14 @@ import json import os +import pathlib import shutil import sys -import zipfile +from pathlib import Path from tempfile import TemporaryDirectory from unittest import TestCase, main, skipIf +from cogent3 import load_aligned_seqs from cogent3.app.data_store import ( IGNORE, OVERWRITE, @@ -18,7 +20,6 @@ SingleReadDataStore, WritableDirectoryDataStore, WritableTinyDbDataStore, - WritableZippedDataStore, load_record_from_json, ) from cogent3.parse.fasta import MinimalFastaParser @@ -28,13 +29,13 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" -class DataStoreBaseTests: +class DataStoreBaseReadTests: basedir = "data" ReadClass = None WriteClass = None @@ -96,29 +97,6 @@ dstore = self.ReadClass(self.basedir, suffix=".fasta") self.assertEqual(len(dstore), len(dstore.members)) - def test_make_identifier(self): - """correctly construct an identifier for a new member""" - with TemporaryDirectory(dir=".") as dirname: - if dirname.startswith("." + os.sep): - dirname = dirname[2:] - - path = os.path.join(dirname, self.basedir) - base_path = path.replace(".zip", "") - dstore = self.WriteClass(path, suffix=".json", create=True) - name = "brca1.fasta" - got = dstore.make_absolute_identifier(name) - expect = os.path.join(base_path, name.replace("fasta", "json")) - self.assertEqual(got, expect) - - # now using a DataStoreMember - member = DataStoreMember( - os.path.join("blah" + os.sep + "blah", f"2-{name}"), None - ) - got = dstore.make_absolute_identifier(member) - expect = os.path.join(base_path, member.name.replace("fasta", "json")) - self.assertEqual(got, expect) - dstore.close() - def test_read(self): """correctly read content""" with open("data" + os.sep + "brca1.fasta") as infile: @@ -145,6 +123,42 @@ member = dstore.get_member(identifier) self.assertEqual(member.md5, md5) + def test_filter(self): + """filter method should return correctly matching members""" + dstore = self.ReadClass(self.basedir, suffix="*") + got = [m.name for m in dstore.filtered(callback=lambda x: "brca1" in str(x))] + self.assertTrue(len(set(got)), 2) + got = dstore.filtered(pattern="*brca1*") + expect = [ + path + for path in os.listdir(self.basedir.replace(".zip", "")) + if "brca1" in path + ] + self.assertEqual(len(got), len(expect)) + + def test_pickleable_roundtrip(self): + """pickling of data stores should be reversible""" + from pickle import dumps, loads + + dstore = self.ReadClass(self.basedir, suffix="*") + re_dstore = loads(dumps(dstore)) + got = re_dstore[0].read() + self.assertEqual(str(dstore), str(re_dstore)) + self.assertEqual(dstore[0].read(), re_dstore[0].read()) + + def test_pickleable_member_roundtrip(self): + """pickling of data store members should be reversible""" + from pickle import dumps, loads + + dstore = self.ReadClass(self.basedir, suffix="*") + re_member = loads(dumps(dstore[0])) + data = re_member.read() + self.assertTrue(len(data) > 0) + + +class DataStoreBaseWriteTests: + WriteClass = None + def test_write(self): """correctly write content""" with open("data" + os.sep + "brca1.fasta") as infile: @@ -159,6 +173,20 @@ self.assertEqual(got, expect) dstore.close() + def test_write_wout_suffix(self): + """appends suffix expected to records""" + with TemporaryDirectory(dir=".") as dirname: + dirname = Path(dirname) + path = dirname / f"{self.basedir}.tinydb" + dstore = self.WriteClass(path, suffix="fasta", create=True) + with self.assertRaises(ValueError): + dstore.write("1", str(dict(a=24, b="some text"))) + + dstore.write("1.fasta", str(dict(a=24, b="some text"))) + dstore.close() + dstore = self.ReadClass(path, suffix="fasta") + self.assertEqual(len(dstore), 1) + @skipIf(sys.platform.lower() != "darwin", "broken on linux") def test_md5_write(self): """tracks md5 sums of written data""" @@ -212,38 +240,6 @@ self.assertEqual(got_b, expect_b) dstore.close() - def test_filter(self): - """filter method should return correctly matching members""" - dstore = self.ReadClass(self.basedir, suffix="*") - got = [m.name for m in dstore.filtered(callback=lambda x: "brca1" in str(x))] - self.assertTrue(len(set(got)), 2) - got = dstore.filtered(pattern="*brca1*") - expect = [ - path - for path in os.listdir(self.basedir.replace(".zip", "")) - if "brca1" in path - ] - self.assertEqual(len(got), len(expect)) - - def test_pickleable_roundtrip(self): - """pickling of data stores should be reversible""" - from pickle import dumps, loads - - dstore = self.ReadClass(self.basedir, suffix="*") - re_dstore = loads(dumps(dstore)) - got = re_dstore[0].read() - self.assertEqual(str(dstore), str(re_dstore)) - self.assertEqual(dstore[0].read(), re_dstore[0].read()) - - def test_pickleable_member_roundtrip(self): - """pickling of data store members should be reversible""" - from pickle import dumps, loads - - dstore = self.ReadClass(self.basedir, suffix="*") - re_member = loads(dumps(dstore[0])) - data = re_member.read() - self.assertTrue(len(data) > 0) - def test_add_file(self): """correctly add an arbitrarily named file""" with open("data" + os.sep + "brca1.fasta") as infile: @@ -275,8 +271,33 @@ self.assertFalse(os.path.exists(log_path)) dstore.close() + def test_make_identifier(self): + """correctly construct an identifier for a new member""" + with TemporaryDirectory(dir=".") as dirname: + if dirname.startswith("." + os.sep): + dirname = dirname[2:] + + path = os.path.join(dirname, self.basedir) + base_path = path.replace(".zip", "") + dstore = self.WriteClass(path, suffix=".json", create=True) + name = "brca1.fasta" + got = dstore.make_absolute_identifier(name) + expect = os.path.join(base_path, name.replace("fasta", "json")) + self.assertEqual(got, expect) + + # now using a DataStoreMember + member = DataStoreMember( + os.path.join("blah" + os.sep + "blah", f"2-{name}"), None + ) + got = dstore.make_absolute_identifier(member) + expect = os.path.join(base_path, member.name.replace("fasta", "json")) + self.assertEqual(got, expect) + dstore.close() + -class DirectoryDataStoreTests(TestCase, DataStoreBaseTests): +class DirectoryDataStoreReadTests( + TestCase, DataStoreBaseReadTests, DataStoreBaseWriteTests +): basedir = "data" ReadClass = ReadOnlyDirectoryDataStore WriteClass = WritableDirectoryDataStore @@ -286,6 +307,26 @@ data = {m.name: m.read() for m in dstore} self.data = data + def test_identifier_write_str_data(self): + """data must be string type""" + data = load_aligned_seqs("data/brca1_5.paml") + with TemporaryDirectory(dir=".") as dirname: + path = pathlib.Path(dirname) / "delme" + dstore = self.WriteClass( + path, suffix=".fasta", if_exists=OVERWRITE, create=True + ) + # fails with not string + with self.assertRaises(TypeError): + dstore.write(data.info.source, data) + + # even bytes + with self.assertRaises(TypeError): + dstore.write(f"{data.info.source}-2.fasta", str(data).encode("utf-8")) + + # but works if data is str + dstore.write(f"{data.info.source}-1.fasta", str(data)) + dstore.close() + def test_write_class_source_create_delete(self): with TemporaryDirectory(dir=".") as dirname: # tests the case when the directory has the file with the same suffix to self.suffix @@ -343,7 +384,6 @@ def test_data_store_creation(self): """overwrite, raise, ignore conditions""" - from pathlib import Path def create_data_store(path): if path.exists(): @@ -401,8 +441,6 @@ def test_data_store_creation2(self): """handles create path argument""" - from pathlib import Path - with TemporaryDirectory(dir=".") as dirname: path = Path(dirname) / "subdir" # raises FileNotFoundError when create is False and full path does @@ -414,10 +452,9 @@ _ = self.WriteClass(path, suffix=".json", create=True) -class ZippedDataStoreTests(TestCase, DataStoreBaseTests): +class ZippedDataStoreReadTests(TestCase, DataStoreBaseReadTests): basedir = "data.zip" ReadClass = ReadOnlyZippedDataStore - WriteClass = WritableZippedDataStore def setUp(self): basedir = self.basedir.split(".")[0] @@ -428,10 +465,6 @@ def tearDown(self): os.remove(self.basedir) - def test_write_no_parent(self): - """zipped data store handles archive with no parent dir""" - self.WriteClass("delme.zip", create=True, suffix="fa") - def test_store_suffix(self): """data store adds file suffix if not provided""" source = self.basedir.split(".")[0] @@ -439,75 +472,6 @@ self.assertEqual(dstore.source, self.basedir) self.assertTrue(len(dstore) > 1) - def test_write_class_source_create_delete(self): - with TemporaryDirectory(dir=".") as dirname: - path = os.path.join(dirname, "delme_dir") - os.mkdir(path) - - # tests the case when the ZippedDataStore only contains files with the same suffix as self.suffix - test_case1_zip = "delme1.zip" - with zipfile.ZipFile(os.path.join(path, test_case1_zip), "w") as myzip: - test_path = os.path.join(path, "dummyPrefix_.json") - with open(test_path, "w"): - pass - myzip.write(test_path) - dstore = self.WriteClass( - os.path.join(path, test_case1_zip), - suffix=".json", - if_exists=OVERWRITE, - create=True, - ) - self.assertEqual(len(dstore), 0) - - # tests the case when the ZippedDataStore contains both files with the same suffix as self.suffix and log files - test_case2_zip = "delme2.zip" - with zipfile.ZipFile(os.path.join(path, test_case2_zip), "w") as myzip: - test_path = os.path.join(path, "dummyPrefix_.json") - with open(test_path, "w"): - pass - myzip.write(test_path) - test_path = os.path.join(path, "dummyPrefix_.log") - with open(test_path, "w"): - pass - myzip.write(test_path) - dstore = self.WriteClass( - os.path.join(path, test_case2_zip), - suffix=".json", - if_exists=OVERWRITE, - create=True, - ) - self.assertEqual(len(dstore), 0) - - # tests the case when the ZippedDataStore contains files with the different suffixes to self.suffix - test_case3_zip = "delme3.zip" - with zipfile.ZipFile(os.path.join(path, test_case3_zip), "w") as myzip: - test_path = os.path.join(path, "dummyPrefix_.dummySuffix") - with open(test_path, "w"): - pass - myzip.write(test_path) - with self.assertRaises(RuntimeError): - dstore = self.WriteClass( - os.path.join(path, test_case3_zip), - suffix=".json", - if_exists=OVERWRITE, - create=True, - ) - - # tests the case when the ZippedDataStore contains only log files - test_case4_zip = "delme4.zip" - with zipfile.ZipFile(os.path.join(path, test_case4_zip), "w") as myzip: - test_path = os.path.join(path, "dummyPrefix_.log") - with open(test_path, "w"): - pass - myzip.write(test_path) - dstore = self.WriteClass( - os.path.join(path, test_case4_zip), - suffix=".json", - if_exists=OVERWRITE, - create=True, - ) - self.assertEqual(len(dstore), 0) - class TinyDBDataStoreTests(TestCase): basedir = "data" @@ -725,7 +689,6 @@ def test_dblock(self): """locking/unlocking of db""" - from pathlib import Path from cogent3.app.data_store import _db_lockid @@ -760,7 +723,6 @@ def test_db_creation(self): """overwrite, raise, ignore conditions""" - from pathlib import Path def create_tinydb(path, create, locked=False): if path.exists(): @@ -815,7 +777,6 @@ def test_db_creation2(self): """handles create path argument""" - from pathlib import Path with TemporaryDirectory(dir=".") as dirname: dirname = Path(dirname) / "subdir" @@ -830,6 +791,21 @@ dstore = self.WriteClass(path, create=True) dstore.close() + def test_write_wout_suffix(self): + """appends suffix expected to records""" + with TemporaryDirectory(dir=".") as dirname: + dirname = Path(dirname) + path = dirname / f"{self.basedir}.tinydb" + dstore = self.WriteClass(path, create=True) + with self.assertRaises(ValueError): + dstore.write("1", dict(a=24, b="some text")) + + dstore.write("1.json", dict(a=24, b="some text")) + dstore.close() + dstore = self.ReadClass(path) + self.assertEqual(len(dstore), 1) + dstore.close() + class SingleReadStoreTests(TestCase): basedir = f"data{os.sep}brca1.fasta" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_dist.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_dist.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_dist.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_dist.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,5 +1,6 @@ import os +from tempfile import TemporaryDirectory from unittest import TestCase, main from numpy.testing import assert_allclose @@ -15,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Stephen Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -205,6 +206,27 @@ aligner = align.progressive_align(model="WG01", guide_tree=treestring) _ = aligner(self.seqs5) + def test_composes_with_write_tabular(self): + """correctly links to tabular""" + with TemporaryDirectory(dir=".") as dirname: + writer = io.write_tabular(dirname) + dist_calc = dist_app.fast_slow_dist(distance="hamming", moltype="protein") + _ = dist_calc + writer + + def test_functions_as_composable(self): + """works as a composable app""" + from pathlib import Path + + loader = io.load_aligned(moltype="dna", format="paml") + dist = dist_app.fast_slow_dist("hamming", moltype="dna") + with TemporaryDirectory(dir=".") as dirname: + dirname = Path(dirname) + writer = io.write_tabular(dirname) + proc = loader + dist + writer + _ = proc("data/brca1_5.250.paml") + output = dirname / "brca1_5.250.tsv" + self.assertTrue(output.exists()) + if __name__ == "__main__": main() diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_evo.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_evo.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_evo.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_evo.py 2021-10-12 00:17:34.000000000 +0000 @@ -1,4 +1,5 @@ from os.path import dirname, join +from tempfile import TemporaryDirectory from unittest import TestCase, main from unittest.mock import MagicMock @@ -6,6 +7,7 @@ from cogent3 import load_aligned_seqs, make_aligned_seqs, make_tree from cogent3.app import evo as evo_app +from cogent3.app import io from cogent3.app.composable import NotCompleted from cogent3.app.result import ( hypothesis_result, @@ -20,7 +22,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -800,6 +802,15 @@ result = strapper(aln) self.assertIsInstance(result, evo_app.bootstrap_result) + def test_bootstrap_composability(self): + """can be composed with load_db and write_db""" + m1 = evo_app.model("F81") + m2 = evo_app.model("HKY85") + hyp = evo_app.hypothesis(m1, m2) + with TemporaryDirectory(dir=".") as dirname: + path = join(dirname, "delme.tinydb") + _ = io.load_db() + evo_app.bootstrap(hyp, num_reps=2) + io.write_db(path) + if __name__ == "__main__": main() diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_init.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_init.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_init.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_init.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_io.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_io.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_io.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_io.py 2021-10-12 00:17:34.000000000 +0000 @@ -7,7 +7,6 @@ from os.path import join from tempfile import TemporaryDirectory from unittest import TestCase, main -from unittest.mock import patch import numpy @@ -17,25 +16,33 @@ from cogent3.app import align as align_app from cogent3.app import io as io_app from cogent3.app.composable import NotCompleted -from cogent3.app.data_store import WritableZippedDataStore from cogent3.app.io import write_db +from cogent3.app.result import generic_result from cogent3.core.alignment import ArrayAlignment, SequenceCollection from cogent3.core.profile import PSSM, MotifCountsArray, MotifFreqsArray from cogent3.evolve.fast_distance import DistanceMatrix from cogent3.maths.util import safe_log from cogent3.util.table import Table +from cogent3.util.union_dict import UnionDict __author__ = "Gavin Huttley" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" +def _get_generic_result(source): + """creates a generic result with a DNA moltype as the single value""" + gr = generic_result(source=source) + gr["dna"] = DNA + return gr + + class TestIo(TestCase): basedir = "data" @@ -114,6 +121,14 @@ for result in results: self.assertIsInstance(result, ArrayAlignment) + def test_load_aligned_paml(self): + """should handle paml too""" + paml_paths = io_app.get_data_store(self.basedir, suffix="paml") + loader = io_app.load_aligned(format="paml") + results = [loader(m) for m in paml_paths] + for result in results: + self.assertIsInstance(result, ArrayAlignment) + def test_load_aligned_from_zip(self): """correctly loads aligned seqs from a zip archive""" @@ -199,17 +214,16 @@ with TemporaryDirectory(dir=".") as dirname: outpath = join(dirname, "delme") writer = write_db(outpath, create=True, if_exists="ignore") - mock = patch("data.source", autospec=True) - mock.to_json = DNA.to_json - mock.source = join("blah", "delme.json") - got = writer(mock) + gr = _get_generic_result(join("blah", "delme.json")) + got = writer(gr) writer.data_store.db.close() dstore = io_app.get_data_store(f"{outpath}.tinydb", suffix="json") reader = io_app.load_db() got = reader(dstore[0]) dstore.close() - self.assertIsInstance(got, DNA.__class__) - self.assertEqual(got, DNA) + got.deserialised_values() + self.assertIsInstance(got["dna"], DNA.__class__) + self.assertEqual(got["dna"], DNA) def test_write_db_load_db2(self): """correctly write/load built-in python from tinydb""" @@ -225,6 +239,16 @@ dstore.close() self.assertEqual(got, data) + def test_write_db_invalid(self): + """value error if identifier does not match data.info.source""" + with TemporaryDirectory(dir=".") as dirname: + outpath = join(dirname, "delme") + writer = write_db(outpath, create=True, if_exists="ignore") + data = UnionDict(a=[1, 2], b="string", source="delme2.json") + got = writer(data, identifier=join("blah", "delme.json")) + self.assertTrue("ValueError" in got.message) + writer.data_store.db.close() + def test_load_db_failure_json_file(self): """informative load_db error message when given a json file path""" # todo this test has a trapped exception about being unable to delete @@ -232,10 +256,8 @@ with TemporaryDirectory(dir=".") as dirname: outpath = join(dirname, "delme") writer = write_db(outpath, create=True, if_exists="ignore") - mock = patch("data.source", autospec=True) - mock.to_json = DNA.to_json - mock.source = join("blah", "delme.json") - got = writer(mock) + gr = _get_generic_result(join("blah", "delme.json")) + got = writer(gr) writer.data_store.db.close() dstore = io_app.get_data_store(f"{outpath}.tinydb", suffix="json") reader = io_app.load_db() @@ -268,14 +290,6 @@ result = load_table(outpath) self.assertIsInstance(result, NotCompleted) - with TemporaryDirectory(dir=".") as dirname: - outpath = join(dirname, "delme.zip") - dstore = WritableZippedDataStore(outpath, suffix="tsv", create=True) - dstore.write("sample1.tsv", table.to_string("tsv")) - new = load_table(dstore[0]) - self.assertEqual(type(new[0, "B"]), type(table[0, "B"])) - self.assertEqual(type(new[0, "A"]), type(table[0, "A"])) - def test_write_tabular_motif_counts_array(self): """correctly writes tabular data for MotifCountsArray""" @@ -470,53 +484,19 @@ got.deserialised_values() self.assertEqual(got["dna"], DNA) - # now with a zipped archive - with TemporaryDirectory(dir=".") as dirname: - outdir = join(dirname, "delme.zip") - obj = generic_result(source=join("blah", "delme.json")) - obj["dna"] = DNA - writer = io_app.write_json(outdir, create=True) - identifier = writer(obj) - reader = io_app.load_json() - got = reader(writer.data_store[0]) - got.deserialised_values() - self.assertEqual(got["dna"], DNA) - expect = join(outdir.replace(".zip", ""), "delme.json") - if expect.startswith("." + os.sep): - expect = expect[2:] - self.assertEqual(identifier, expect) - def test_write_json_no_info(self): """correctly writes an object with out an info attribute from json""" # create a mock object that pretends like it's been derived from # something with TemporaryDirectory(dir=".") as dirname: outdir = join(dirname, "delme") - mock = patch("data.source", autospec=True) - mock.to_rich_dict = DNA.to_rich_dict - mock.source = join("blah", "delme.json") + gr = _get_generic_result(join("blah", "delme.json")) writer = io_app.write_json(outdir, create=True) - _ = writer(mock) + _ = writer(gr) reader = io_app.load_json() got = reader(writer.data_store[0]) - self.assertEqual(got, DNA) - - # now with a zipped archive - with TemporaryDirectory(dir=".") as dirname: - outdir = join(dirname, "delme.zip") - mock = patch("data.source", autospec=True) - mock.to_rich_dict = DNA.to_rich_dict - mock.source = join("blah", "delme.json") - writer = io_app.write_json(outdir, create=True) - identifier = writer(mock) - reader = io_app.load_json() - # checking loadable from a data store member too - got = reader(writer.data_store[0]) - self.assertEqual(got, DNA) - expect = join(outdir.replace(".zip", ""), "delme.json") - if expect.startswith("." + os.sep): - expect = expect[2:] - self.assertEqual(identifier, expect) + got.deserialised_values() + self.assertEqual(got["dna"], DNA) def test_restricted_usage_of_tinydb_suffix(self): """can only use tinydb in a load_db, write_db context""" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_result.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_result.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_result.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_result.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_sample.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_sample.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_sample.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_sample.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -415,6 +415,42 @@ }, ) + def test_concat_handles_moltype(self): + """coerces to type""" + alns = [ + make_aligned_seqs(data=d, moltype=DNA) + for d in [ + {"seq1": "AAA", "seq2": "AAA", "seq3": "AAA"}, + {"seq1": "TTT", "seq2": "TTT", "seq3": "TTT", "seq4": "TTT"}, + {"seq1": "CC", "seq2": "CC", "seq3": "CC"}, + ] + ] + ccat = sample.concat() + got = ccat(alns) + self.assertIsInstance(got.moltype, type(DNA)) + + def test_concat_validates_type(self): + """raises TypeError if not known alignment type""" + data = [ + {"seq1": "AAA", "seq2": "AAA", "seq3": "AAA"}, + make_aligned_seqs( + data={"seq1": "TTT", "seq2": "TTT", "seq3": "TTT", "seq4": "TTT"}, + moltype=DNA, + ), + ] + ccat = sample.concat() + # triggered by first record + with self.assertRaises(TypeError): + ccat(data) + + # triggered by second record + with self.assertRaises(TypeError): + ccat(data[::-1]) + + # triggered by no data + with self.assertRaises(ValueError): + ccat([]) + def test_trim_stop_codons(self): """trims stop codons using the specified genetic code""" trimmer = sample.trim_stop_codons() # defaults to standard code diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_translate.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_translate.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_translate.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_translate.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_app/test_tree.py python-cogent-2021.10.12a1+dfsg/tests/test_app/test_tree.py --- python-cogent-2021.5.7a+dfsg/tests/test_app/test_tree.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_app/test_tree.py 2021-10-12 00:17:34.000000000 +0000 @@ -23,7 +23,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -106,7 +106,6 @@ # tests when distances contain None data = dict( seq1="AGGGGGGGGGGCCCCCCCCCCCCCCCCCGGGGGGGGGGGGGGGCGGTTTTTTTTTTTTTTTTTT", - seq2="TAAAAAAAAAAGGGGGGGGGGGGGGGGGGTTTTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCC", ) aln2 = make_aligned_seqs(data=data, moltype=DNA) tree2 = proc(aln2) @@ -129,7 +128,7 @@ self.assertIsInstance(tree, PhyloNode) self.assertIsNotNone(tree.children) self.assertEqual( - set(tree.get_tip_names()), set.union(*(set(tup) for tup in data.keys())) + set(tree.get_tip_names()), set.union(*(set(tup) for tup in data)) ) data = { @@ -159,7 +158,7 @@ self.assertIsInstance(tree, PhyloNode) self.assertIsNotNone(tree.children) self.assertEqual( - set(tree.get_tip_names()), set.union(*(set(tup) for tup in data.keys())) + set(tree.get_tip_names()), set.union(*(set(tup) for tup in data)) ) data = { @@ -181,7 +180,7 @@ self.assertIsInstance(tree, PhyloNode) self.assertIsNotNone(tree.children) self.assertEqual( - set(tree.get_tip_names()), set.union(*(set(tup) for tup in data.keys())) + set(tree.get_tip_names()), set.union(*(set(tup) for tup in data)) ) data = { @@ -234,7 +233,14 @@ self.assertIsInstance(tree, PhyloNode) self.assertIsNotNone(tree.children) self.assertEqual( - set(tree.get_tip_names()), set.union(*(set(tup) for tup in data.keys())) + set(tree.get_tip_names()), set.union(*(set(tup) for tup in data)) + ) + + data = {"a": {"b": 0.1, "a": 0.0}, "b": {"a": 0.1, "b": 0.0}} + darr = DistanceMatrix(data) + tree = quick_tree.quick_tree(darr) + self.assertEqual( + set(tree.get_tip_names()), set.union(*(set(tup) for tup in data)) ) def test_uniformize_tree(self): diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_cluster/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_cluster/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_cluster/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_cluster/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Catherine Lozuopone", "Peter Maxwell", "Rob Knight", "Justin Kuczynski"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_cluster/test_UPGMA.py python-cogent-2021.10.12a1+dfsg/tests/test_cluster/test_UPGMA.py --- python-cogent-2021.5.7a+dfsg/tests/test_cluster/test_UPGMA.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_cluster/test_UPGMA.py 2021-10-12 00:17:34.000000000 +0000 @@ -27,7 +27,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_core/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -29,7 +29,7 @@ "Justin Kuczynski", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_alignment.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_alignment.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_alignment.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_alignment.py 2021-10-12 00:17:34.000000000 +0000 @@ -73,7 +73,7 @@ "Jan Kosinski", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -2115,16 +2115,6 @@ ] self.assertEqual(got, "\n".join(expect)) - def test_to_pretty_deprecation_warning(self): - """produce correct pretty print formatted text""" - seqs = {"seq1": "ACGAANGA", "seq2": "-CGAACGA", "seq3": "ATGAACGA"} - expect = ["seq1 ACGAANGA", "seq2 -....C..", "seq3 .T...C.."] - - aln = self.Class(data=seqs, moltype=DNA) - # should raise warning here - with self.assertWarns(DeprecationWarning): - aln.to_pretty(name_order=["seq1", "seq2", "seq3"], interleave_len=4) - def test_to_html(self): """produce correct html formatted text""" seqs = {"seq1": "ACG", "seq2": "-CT"} @@ -2169,21 +2159,16 @@ # order now changes self.assertTrue(got.find(ref_row) < got.find(other_row)) - def test_to_html_deprecation_warning(self): - """should raise warning using wrap and not interleave_len""" - seqs = {"seq1": "ACG", "seq2": "-CT"} - - aln = self.Class(data=seqs, moltype=DNA) - # specify interleave_len in 2 cases, wrap specified and not specified - # both should raise warnings - with self.assertWarns(DeprecationWarning): - aln.to_html(ref_name="seq2", interleave_len=40) - def test_variable_positions(self): """correctly identify variable positions""" - new_seqs = {"seq1": "ACGTACGT", "seq2": "ACCGACGT", "seq3": "ACGTACGT"} + new_seqs = {"A": "-CG-C", "B": "ACAA?", "C": "GCGAC"} + aln = self.Class(data=new_seqs, moltype=DNA) + self.assertEqual(aln.variable_positions(include_gap_motif=True), [0, 2, 3, 4]) + self.assertEqual(aln.variable_positions(include_gap_motif=False), [0, 2]) + new_seqs = {"A": "GCGAC", "B": "GCGAC", "C": "GCGAC"} aln = self.Class(data=new_seqs, moltype=DNA) - self.assertEqual(aln.variable_positions(), [2, 3]) + self.assertEqual(aln.variable_positions(include_gap_motif=True), []) + self.assertEqual(aln.variable_positions(include_gap_motif=False), []) def test_to_type(self): """correctly interconvert between alignment types""" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_alphabet.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_alphabet.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_alphabet.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_alphabet.py 2021-10-12 00:17:34.000000000 +0000 @@ -32,7 +32,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Rob Knight", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -221,7 +221,7 @@ """CharAlphabet init should make correct translation tables""" r = CharAlphabet("UCAG") i2c, c2i = r._indices_nums_to_chars, r._chars_to_indices - s = array([0, 0, 1, 0, 3, 2], "b").tostring() + s = array([0, 0, 1, 0, 3, 2], "b").tobytes() self.assertEqual(s.translate(i2c), b"UUCUGA") self.assertEqual("UUCUGA".translate(c2i), "\000\000\001\000\003\002") diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_annotation.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_annotation.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_annotation.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_annotation.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_core_standalone.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_core_standalone.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_core_standalone.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_core_standalone.py 2021-10-12 00:17:34.000000000 +0000 @@ -32,7 +32,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -215,11 +215,7 @@ aln = load_aligned_seqs(filename, **kw) if test_write: suffix, cmpr = get_format_suffixes(filename) - if not cmpr: - cmpr = "" - else: - cmpr = f".{cmpr}" - + cmpr = "" if not cmpr else f".{cmpr}" fn = tempfile.mktemp(suffix="." + suffix + cmpr) aln.write(filename=fn) os.remove(fn) @@ -380,9 +376,7 @@ alignment = make_aligned_seqs( data={"seq1": "ACGTACGT", "seq2": "ACGTACGT", "seq3": "ACGTACGT"} ) - result = [] - for bit in alignment.sliding_windows(5, 2): - result += [bit] + result = [bit for bit in alignment.sliding_windows(5, 2)] self.assertEqual( result[0].to_dict(), {"seq3": "ACGTA", "seq2": "ACGTA", "seq1": "ACGTA"} ) diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_features.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_features.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_features.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_features.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_genetic_code.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_genetic_code.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_genetic_code.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_genetic_code.py 2021-10-12 00:17:34.000000000 +0000 @@ -19,7 +19,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Greg Caporaso", "Rob Knight", "Peter Maxwell", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Greg Caporaso" __email__ = "caporaso@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_info.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_info.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_info.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_info.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_location.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_location.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_location.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_location.py 2021-10-12 00:17:34.000000000 +0000 @@ -4,14 +4,21 @@ """ from unittest import TestCase, main -from cogent3.core.location import Map, Range, RangeFromString, Span +from cogent3 import DNA +from cogent3.core.location import ( + Map, + Range, + RangeFromString, + Span, + gap_coords_to_map, +) __author__ = "Rob Knight" __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -528,6 +535,38 @@ coords = map.get_coordinates() self.assertEqual(coords, spans) + def test_get_gap_coords(self): + """returns gap start and lengths""" + m, seq = DNA.make_seq("-AC--GT-TTA--").parse_out_gaps() + got = m.get_gap_coordinates() + self.assertEqual(dict(got), {0: 1, 2: 2, 4: 1, 7: 2}) + + def test_gap_coords_to_map(self): + """construct a Map from coordinates of gap alone""" + m, seq = DNA.make_seq("-AC--GT-TTA--").parse_out_gaps() + gap_coords = {0: 1, 2: 2, 4: 1, 7: 2} + seqlen = 70 + got = gap_coords_to_map(gap_coords, seqlen) + self.assertEqual(len(got), seqlen + sum(gap_coords.values())) + + gap_coords = {5: 2, 17: 3, 10: 2} + seqlen = 20 + got = gap_coords_to_map(gap_coords, seqlen) + self.assertEqual(len(got), sum(gap_coords.values()) + seqlen) + + # roundtrip from Map.get_gap_coordinates() + self.assertEqual(dict(got.get_gap_coordinates()), gap_coords) + + # and no gaps + m, seq = DNA.make_seq("ACGTTTA").parse_out_gaps() + got = gap_coords_to_map({}, len(seq)) + self.assertEqual(len(got), len(m)) + self.assertEqual(got.get_coordinates(), m.get_coordinates()) + + # and gaps outside sequence + with self.assertRaises(ValueError): + got = gap_coords_to_map({20: 1}, len(seq)) + # run the following if invoked from command-line if __name__ == "__main__": diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_maps.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_maps.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_maps.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_maps.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Rob Knight", "Matthew Wakefield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_moltype.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_moltype.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_moltype.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_moltype.py 2021-10-12 00:17:34.000000000 +0000 @@ -34,7 +34,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Gavin Huttley", "Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_profile.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_profile.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_profile.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_profile.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Sandra Smit", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_seq_aln_integration.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_seq_aln_integration.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_seq_aln_integration.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_seq_aln_integration.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Sandra Smit", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Sandra Smit" __email__ = "sandra.smit@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_sequence.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_sequence.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_sequence.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_sequence.py 2021-10-12 00:17:34.000000000 +0000 @@ -43,7 +43,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Gavin Huttley", "Peter Maxwell", "Matthew Wakefield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" @@ -975,12 +975,6 @@ self.assertTrue(seq_row in got) - def test_to_html_deprecation_warning(self): - """produce correct html formatted text""" - seq = DnaSequence("ACGGTGGGGGGGGG") - with self.assertWarns(DeprecationWarning): - seq.to_html(interleave_len=50) - def test_repr_html(self): """correctly uses set_repr and the environment variable settings""" token = 'class="label"' @@ -1108,6 +1102,14 @@ sc = self.SequenceClass self.assertEqual(str(sc("TC").regap(sc("A---A-"))), "T---C-") + def test_degap_name(self): + """degap preserves name attribute""" + # todo this should work for any seq class, but is not + seq = DNA.make_seq("ACG---T", "blah") + got = seq.degap() + self.assertEqual(str(got), "ACGT") + self.assertEqual(got.name, "blah") + class SequenceIntegrationTests(TestCase): """Should be able to convert regular to model sequences, and back""" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_core/test_tree.py python-cogent-2021.10.12a1+dfsg/tests/test_core/test_tree.py --- python-cogent-2021.5.7a+dfsg/tests/test_core/test_tree.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_core/test_tree.py 2021-10-12 00:17:34.000000000 +0000 @@ -3,14 +3,13 @@ """ import json import os -import sys -import unittest from copy import copy, deepcopy from tempfile import TemporaryDirectory from unittest import TestCase, main -from numpy import arange, array +from numpy import array +from numpy.testing import assert_allclose, assert_equal from cogent3 import load_tree, make_tree from cogent3.core.tree import PhyloNode, TreeError, TreeNode @@ -34,13 +33,11 @@ "Jose Carlos Clemente Litran", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" -from numpy.testing import assert_allclose, assert_equal - base_path = os.path.dirname(os.path.dirname(__file__)) data_path = os.path.join(base_path, "data") @@ -1070,8 +1067,19 @@ self.assertEqual(obs_1, exp_1) self.assertEqual(obs_2, exp_2) + def test_lowest_common_ancestor_invalid_tips(self): + """fail if tips not present""" + t = DndParser("((a,(b,c)d)e,f,(g,h)i)j;") + # no tips present in tree should raise exception + with self.assertRaises(ValueError): + t.lowest_common_ancestor(["m", "n"]) + + # not all tips present in tree should raise exception + with self.assertRaises(ValueError): + t.lowest_common_ancestor(["a", "n"]) + def test_last_common_ancestor(self): - """TreeNode LastCommonAncestor should provide last common ancestor""" + """TreeNode last_common_ancestor should provide last common ancestor""" nodes, tree = self.TreeNode, self.TreeRoot a = nodes["a"] b = nodes["b"] @@ -1475,20 +1483,16 @@ def test_tip_to_tip_distances_endpoints(self): """Test getting specifc tip distances with tip_to_tip_distances""" - nodes = [ + exp_nodes = [ self.t.get_node_matching_name("H"), self.t.get_node_matching_name("G"), self.t.get_node_matching_name("M"), ] names = ["H", "G", "M"] - exp = (array([[0, 2.0, 6.7], [2.0, 0, 6.7], [6.7, 6.7, 0.0]]), nodes) - obs = self.t.tip_to_tip_distances(endpoints=names) - assert_equal(obs[0], exp[0]) - assert_equal(obs[1], exp[1]) - - obs = self.t.tip_to_tip_distances(endpoints=nodes) - assert_equal(obs[0], exp[0]) - assert_equal(obs[1], exp[1]) + exp_dists = array([[0, 2.0, 6.7], [2.0, 0, 6.7], [6.7, 6.7, 0.0]]) + got_dists, got_nodes = self.t.tip_to_tip_distances(endpoints=names) + assert_equal(got_dists, exp_dists) + self.assertEqual(got_nodes, exp_nodes) def test_prune(self): """prune should reconstruct correct topology and Lengths of tree.""" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_data/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_data/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_data/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_data/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_data/test_molecular_weight.py python-cogent-2021.10.12a1+dfsg/tests/test_data/test_molecular_weight.py --- python-cogent-2021.5.7a+dfsg/tests/test_data/test_molecular_weight.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_data/test_molecular_weight.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_draw/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_draw/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_draw/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_draw/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_draw/test_dendrogram.py python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_dendrogram.py --- python-cogent-2021.5.7a+dfsg/tests/test_draw/test_dendrogram.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_dendrogram.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Gavin Huttley", "Rahul Ghangas"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_draw/test_dotplot.py python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_dotplot.py --- python-cogent-2021.5.7a+dfsg/tests/test_draw/test_dotplot.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_dotplot.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" @@ -105,7 +105,7 @@ aln = ArrayAlignment( {"seq1": "ACGG", "seq2": "CGCA", "seq3": "CCG-"}, moltype="dna" ) - aln_plot = aln.dotplot("seq1", "seq2") + aln_plot = aln.dotplot("seq1") self.assertNotEqual(aln_plot._aligned_coords, None) def test_dotplot_seqcoll(self): @@ -118,6 +118,24 @@ self.assertEqual(len(dp.seq1), 4) self.assertEqual(len(dp.seq2), 3) + def test_dotplot_single(self): + """dotplot with single sequence should not fail""" + seqs = make_unaligned_seqs({"seq1": "ACGG"}, moltype="dna") + dp = seqs.dotplot() + self.assertEqual(dp.seq1, dp.seq2) + + def test_dotplot_missing(self): + """fail if a sequence name not present""" + seqs = make_unaligned_seqs( + {"seq1": "ACGG", "seq2": "CGCA", "seq3": "CCG-"}, moltype="dna" + ) + with self.assertRaises(ValueError): + _ = seqs.dotplot("seq1", "seq5") + with self.assertRaises(ValueError): + _ = seqs.dotplot("seq5", "seq1") + with self.assertRaises(ValueError): + _ = seqs.dotplot("seq5", "seq6") + def test_dotplot_title(self): """setting empty string title works""" seqs = make_unaligned_seqs( diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_draw/test_draw_integration.py python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_draw_integration.py --- python-cogent-2021.5.7a+dfsg/tests/test_draw/test_draw_integration.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_draw_integration.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_draw/test_logo.py python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_logo.py --- python-cogent-2021.5.7a+dfsg/tests/test_draw/test_logo.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_logo.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_draw/test_shapes.py python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_shapes.py --- python-cogent-2021.5.7a+dfsg/tests/test_draw/test_shapes.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_draw/test_shapes.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Gavin Huttley", "Rahul Ghangas"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Peter Maxwell", "Greg Caporaso"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_best_likelihood.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_best_likelihood.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_best_likelihood.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_best_likelihood.py 2021-10-12 00:17:34.000000000 +0000 @@ -20,7 +20,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Helen Lindsay"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Helen Lindsay" __email__ = "helen.lindsay@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_bootstrap.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_bootstrap.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_bootstrap.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_bootstrap.py 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ "Andrew Butterfield", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_coevolution.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_coevolution.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_coevolution.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_coevolution.py 2021-10-12 00:17:34.000000000 +0000 @@ -97,7 +97,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Greg Caporaso"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Greg Caporaso" __email__ = "gregcaporaso@gmail.com" __status__ = "Beta" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_distance.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_distance.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_distance.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_distance.py 2021-10-12 00:17:34.000000000 +0000 @@ -52,7 +52,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Yicheng Zhu", "Ben Kaehler"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_likelihood_function.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_likelihood_function.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_likelihood_function.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_likelihood_function.py 2021-10-12 00:17:34.000000000 +0000 @@ -62,7 +62,7 @@ "Ananias Iliadis", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_models.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_models.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_models.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_models.py 2021-10-12 00:17:34.000000000 +0000 @@ -24,7 +24,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -100,6 +100,15 @@ # unknown model raises exception _ = get_model("blah") + def test_model_names(self): + """name attribute matches model name""" + for model_name in models: + model = get_model(model_name) + self.assertTrue( + model.name.startswith(model_name), + msg=f"{model.name} does not start with {model_name}", + ) + def get_sample_model_types(mod_type=None): opts = dict( diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_motifchange.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_motifchange.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_motifchange.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_motifchange.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ "Brett Easton", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_newq.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_newq.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_newq.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_newq.py 2021-10-12 00:17:34.000000000 +0000 @@ -34,7 +34,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_ns_substitution_model.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_ns_substitution_model.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_ns_substitution_model.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_ns_substitution_model.py 2021-10-12 00:17:34.000000000 +0000 @@ -31,7 +31,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Ananias Iliadis"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_parameter_controller.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_parameter_controller.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_parameter_controller.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_parameter_controller.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Matthew Wakefield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_scale_rules.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_scale_rules.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_scale_rules.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_scale_rules.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_simulation.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_simulation.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_simulation.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_simulation.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_substitution_model.py python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_substitution_model.py --- python-cogent-2021.5.7a+dfsg/tests/test_evolve/test_substitution_model.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_evolve/test_substitution_model.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_format/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_format/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_format/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_format/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,7 +11,7 @@ "Jeremy Widmann", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_format/test_bedgraph.py python-cogent-2021.10.12a1+dfsg/tests/test_format/test_bedgraph.py --- python-cogent-2021.5.7a+dfsg/tests/test_format/test_bedgraph.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_format/test_bedgraph.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_format/test_clustal.py python-cogent-2021.10.12a1+dfsg/tests/test_format/test_clustal.py --- python-cogent-2021.5.7a+dfsg/tests/test_format/test_clustal.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_format/test_clustal.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jeremy Widmann"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Jeremy Widmann" __email__ = "jeremy.widmann@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_format/test_fasta.py python-cogent-2021.10.12a1+dfsg/tests/test_format/test_fasta.py --- python-cogent-2021.5.7a+dfsg/tests/test_format/test_fasta.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_format/test_fasta.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jeremy Widmann", "Gavin Huttley", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Jeremy Widmann" __email__ = "jeremy.widmann@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -20,7 +20,7 @@ "Antonio Gonzalez Pena", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_distance_transform.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_distance_transform.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_distance_transform.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_distance_transform.py 2021-10-12 00:17:34.000000000 +0000 @@ -47,7 +47,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __contributors__ = ["Justin Kuczynski", "Zongzhi Liu", "Greg Caporaso"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Justin Kuczynski" __email__ = "justinak@gmail.com" __status__ = "Prototype" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_geometry.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_geometry.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_geometry.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_geometry.py 2021-10-12 00:17:34.000000000 +0000 @@ -38,7 +38,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Sandra Smit", "Rob Knight", "Helmut Simon"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Sandra Smit" __email__ = "sandra.smit@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_matrix_exponential_integration.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_matrix_exponential_integration.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_matrix_exponential_integration.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_matrix_exponential_integration.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2014, The Cogent Project" __credits__ = ["Ben Kaehler", "Ananias Iliadis", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Ben Kaehler" __email__ = "benjamin.kaehler@anu.edu.au" __status__ = "Production" @@ -22,14 +22,8 @@ class TestIntegratingExponentiator(TestCase): - def test_van_loan_integrating_exponentiator(self): - """VanLoanIntegratingExponentiator should reproduce Felsenstein - analytic result, should throw if we pass it a defected matrix and ask - it to use CheckedExponentiator, will work with a defective matrix (that - we can integrate by hand) if we use the default RobustExponentiator, - and should work for different choices of R and exponentiatior.""" - # Result from Von Bing's R code - result = 0.7295333 + def setUp(self) -> None: + self.result = 0.7295333 q = array([[0.5, 0.2, 0.1, 0.2]] * 4) for i in range(4): q[i, i] = 0.0 @@ -38,16 +32,24 @@ i, ] ) - p0 = array([0.2, 0.3, 0.3, 0.2]) + self.q = q + self.p0 = array([0.2, 0.3, 0.3, 0.2]) - I = expm.VanLoanIntegratingExponentiator(q, -diag(q))(1.0) - assert_allclose(dot(p0, I), result) + def test_van_loan_integrating_exponentiator(self): + """VanLoanIntegratingExponentiator should reproduce Felsenstein + analytic result, should throw if we pass it a defected matrix and ask + it to use CheckedExponentiator, will work with a defective matrix (that + we can integrate by hand) if we use the default RobustExponentiator, + and should work for different choices of R and exponentiatior.""" + # Result from Von Bing's R code + I = expm.VanLoanIntegratingExponentiator(self.q, -diag(self.q))(1.0) + assert_allclose(dot(self.p0, I), self.result) self.assertRaises( ArithmeticError, expm.VanLoanIntegratingExponentiator, - q, - -diag(q), + self.q, + -diag(self.q), cmme.CheckedExponentiator, ) @@ -73,19 +75,8 @@ should match results obtained from VanLoanIntegratingExponentiator for a diagonisable matrix.""" # Result from Von Bing's R code. - result = 0.7295333 - q = array([[0.5, 0.2, 0.1, 0.2]] * 4) - for i in range(4): - q[i, i] = 0.0 - q[i, i] = -sum( - q[ - i, - ] - ) - p0 = array([0.2, 0.3, 0.3, 0.2]) - - I = expm.VonBingIntegratingExponentiator(q)(1.0) - assert_allclose(dot(dot(p0, I), -diag(q)), result) + I = expm.VonBingIntegratingExponentiator(self.q)(1.0) + assert_allclose(dot(dot(self.p0, I), -diag(self.q)), self.result) self.assertRaises( ArithmeticError, @@ -115,6 +106,16 @@ )(2.0), ) + def test_repr(self): + """repr() works for the integrating exponentiators""" + for klass in ( + expm.VanLoanIntegratingExponentiator, + expm.VonBingIntegratingExponentiator, + ): + i = klass(self.q) + g = repr(i) + self.assertIsInstance(g, str) + def test_calc_number_subs(self): """correctly compute ENS""" mprobs = diag([0.1, 0.2, 0.3, 0.4]) diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_matrix_logarithm.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_matrix_logarithm.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_matrix_logarithm.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_matrix_logarithm.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Gavin Huttley", "Ben Kaehler"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_measure.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_measure.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_measure.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_measure.py 2021-10-12 00:17:34.000000000 +0000 @@ -18,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Stephen Ka-Wah Ma"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" @@ -214,6 +214,30 @@ atol=self.atol, ) + assert_allclose( + jsd(case4[0], case4[0], validate=True), + 0.0, + err_msg="Testing case4 for jsd failed", + atol=self.atol, + ) + + def test_jsd_precision(self): + """handle case where the difference is incredibly small""" + pi_0 = [ + 0.4398948756903677, + 0.1623791467423164, + 0.31844113569205656, + 0.07928484187525932, + ] + pi_1 = [ + 0.43989487569036767, + 0.16237914674231643, + 0.3184411356920566, + 0.07928484187525933, + ] + result = jsd(pi_0, pi_1) + self.assertTrue(result >= 0) + def test_jsm(self): """evaluate jsm between identical, and non-identical distributions""" case1 = [ diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_optimisers.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_optimisers.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_optimisers.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_optimisers.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_period.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_period.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_period.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_period.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Julien Epps", "Hua Ying", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Catherine Lozupone", "Gavin Huttley", "Sandra Smit"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_contingency.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_contingency.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_contingency.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_contingency.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_distribution.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_distribution.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_distribution.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_distribution.py 2021-10-12 00:17:34.000000000 +0000 @@ -48,7 +48,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Rob Knight", "Sandra Smit"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_information_criteria.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_information_criteria.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_information_criteria.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_information_criteria.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_jackknife.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_jackknife.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_jackknife.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_jackknife.py 2021-10-12 00:17:34.000000000 +0000 @@ -9,7 +9,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Anuj Pahwa", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_ks.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_ks.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_ks.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_ks.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_number.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_number.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_number.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_number.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_period.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_period.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_period.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_period.py 2021-10-12 00:17:34.000000000 +0000 @@ -18,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Julien Epps", "Hua Ying", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_special.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_special.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_special.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_special.py 2021-10-12 00:17:34.000000000 +0000 @@ -26,7 +26,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Rob Knight", "Sandra Smit"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_test.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_test.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_stats/test_test.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_stats/test_test.py 2021-10-12 00:17:34.000000000 +0000 @@ -93,7 +93,7 @@ "Michael Dwan", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_maths/test_util.py python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_util.py --- python-cogent-2021.5.7a+dfsg/tests/test_maths/test_util.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_maths/test_util.py 2021-10-12 00:17:34.000000000 +0000 @@ -41,7 +41,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jeremy Widmann", "Rob Knight", "Sandra Smit"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -36,7 +36,7 @@ "Marcin Cieslik", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_blast.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_blast.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_blast.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_blast.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ __copyright__ = "Copyright 2007-2016, The Cogent Project" __credits__ = ["Micah Hamady", "Rob Knight"] __license__ = "GPL" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Micah Hamady" __email__ = "hamady@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_blast_xml.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_blast_xml.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_blast_xml.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_blast_xml.py 2021-10-12 00:17:34.000000000 +0000 @@ -8,7 +8,7 @@ __contributors__ = ["Micah Hamady"] __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Kristian Rother" __email__ = "krother@rubor.de" __status__ = "Prototype" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_cigar.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_cigar.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_cigar.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_cigar.py 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Hua Ying", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Hua Ying" __email__ = "hua.ying@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_clustal.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_clustal.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_clustal.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_clustal.py 2021-10-12 00:17:34.000000000 +0000 @@ -18,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Sandra Smit"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_dialign.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_dialign.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_dialign.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_dialign.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_ebi.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_ebi.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_ebi.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_ebi.py 2021-10-12 00:17:34.000000000 +0000 @@ -66,7 +66,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Zongzhi Liu", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Zongzhi Liu" __email__ = "zongzhi.liu@gmail.com" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_fasta.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_fasta.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_fasta.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_fasta.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_gbseq.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_gbseq.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_gbseq.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_gbseq.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_genbank.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_genbank.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_genbank.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_genbank.py 2021-10-12 00:17:34.000000000 +0000 @@ -26,7 +26,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_gff.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_gff.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_gff.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_gff.py 2021-10-12 00:17:34.000000000 +0000 @@ -14,7 +14,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_greengenes.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_greengenes.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_greengenes.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_greengenes.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,7 +15,7 @@ # remember to add yourself if you make changes __credits__ = ["Daniel McDonald"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Daniel McDonald" __email__ = "daniel.mcdonald@colorado.edu" __status__ = "Prototype" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_locuslink.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_locuslink.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_locuslink.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_locuslink.py 2021-10-12 00:17:34.000000000 +0000 @@ -30,7 +30,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_ncbi_taxonomy.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_ncbi_taxonomy.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_ncbi_taxonomy.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_ncbi_taxonomy.py 2021-10-12 00:17:34.000000000 +0000 @@ -20,7 +20,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Jason Carnes", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_nexus.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_nexus.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_nexus.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_nexus.py 2021-10-12 00:17:34.000000000 +0000 @@ -22,7 +22,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Catherine Lozupone", "Rob Knight", "Micah Hamady"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Catherine Lozupone" __email__ = "lozupone@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_pamlmatrix.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_pamlmatrix.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_pamlmatrix.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_pamlmatrix.py 2021-10-12 00:17:34.000000000 +0000 @@ -10,7 +10,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_phylip.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_phylip.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_phylip.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_phylip.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Micah Hamady", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Micah Hamady" __email__ = "hamady@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_psl.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_psl.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_psl.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_psl.py 2021-10-12 00:17:34.000000000 +0000 @@ -12,7 +12,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Peter Maxwell", "Gavin Huttley", "Anuj Pahwa"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Development" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_pwm_parsers.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_pwm_parsers.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_pwm_parsers.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_pwm_parsers.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,7 +11,7 @@ __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_rdb.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_rdb.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_rdb.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_rdb.py 2021-10-12 00:17:34.000000000 +0000 @@ -20,7 +20,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Sandra Smit", "Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Sandra Smit" __email__ = "sandra.smit@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_record_finder.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_record_finder.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_record_finder.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_record_finder.py 2021-10-12 00:17:34.000000000 +0000 @@ -17,7 +17,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Zongzhi Liu"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_record.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_record.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_record.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_record.py 2021-10-12 00:17:34.000000000 +0000 @@ -30,7 +30,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_tinyseq.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_tinyseq.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_tinyseq.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_tinyseq.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Matthew Wakefield"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Matthew Wakefield" __email__ = "wakefield@wehi.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_tree.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_tree.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_tree.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_tree.py 2021-10-12 00:17:34.000000000 +0000 @@ -19,7 +19,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Peter Maxwell", "Daniel McDonald"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_parse/test_unigene.py python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_unigene.py --- python-cogent-2021.5.7a+dfsg/tests/test_parse/test_unigene.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_parse/test_unigene.py 2021-10-12 00:17:34.000000000 +0000 @@ -18,7 +18,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_phylo.py python-cogent-2021.10.12a1+dfsg/tests/test_phylo.py --- python-cogent-2021.5.7a+dfsg/tests/test_phylo.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_phylo.py 2021-10-12 00:17:34.000000000 +0000 @@ -35,7 +35,7 @@ "Ben Kaehler", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_recalculation.py python-cogent-2021.10.12a1+dfsg/tests/test_recalculation.py --- python-cogent-2021.5.7a+dfsg/tests/test_recalculation.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_recalculation.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_util/__init__.py python-cogent-2021.10.12a1+dfsg/tests/test_util/__init__.py --- python-cogent-2021.5.7a+dfsg/tests/test_util/__init__.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_util/__init__.py 2021-10-12 00:17:34.000000000 +0000 @@ -20,7 +20,7 @@ "Greg Caporaso", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_util/test_deserialise.py python-cogent-2021.10.12a1+dfsg/tests/test_util/test_deserialise.py --- python-cogent-2021.5.7a+dfsg/tests/test_util/test_deserialise.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_util/test_deserialise.py 2021-10-12 00:17:34.000000000 +0000 @@ -28,7 +28,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_util/test_dictarray.py python-cogent-2021.10.12a1+dfsg/tests/test_util/test_dictarray.py --- python-cogent-2021.5.7a+dfsg/tests/test_util/test_dictarray.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_util/test_dictarray.py 2021-10-12 00:17:34.000000000 +0000 @@ -25,7 +25,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_util/test_misc.py python-cogent-2021.10.12a1+dfsg/tests/test_util/test_misc.py --- python-cogent-2021.5.7a+dfsg/tests/test_util/test_misc.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_util/test_misc.py 2021-10-12 00:17:34.000000000 +0000 @@ -69,7 +69,7 @@ "Daniel McDonald", ] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_util/test_parallel.py python-cogent-2021.10.12a1+dfsg/tests/test_util/test_parallel.py --- python-cogent-2021.5.7a+dfsg/tests/test_util/test_parallel.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_util/test_parallel.py 2021-10-12 00:17:34.000000000 +0000 @@ -13,7 +13,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Sheng Han Moses Koh"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "Gavin.Huttley@anu.edu.au" __status__ = "Alpha" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_util/test_recode_alignment.py python-cogent-2021.10.12a1+dfsg/tests/test_util/test_recode_alignment.py --- python-cogent-2021.5.7a+dfsg/tests/test_util/test_recode_alignment.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_util/test_recode_alignment.py 2021-10-12 00:17:34.000000000 +0000 @@ -19,7 +19,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Greg Caporaso"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Greg Caporaso" __email__ = "gregcaporaso@gmail.com" __status__ = "Beta" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_util/test_table.py python-cogent-2021.10.12a1+dfsg/tests/test_util/test_table.py --- python-cogent-2021.5.7a+dfsg/tests/test_util/test_table.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_util/test_table.py 2021-10-12 00:17:34.000000000 +0000 @@ -44,7 +44,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Thomas La", "Christopher Bradley"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" @@ -1927,10 +1927,10 @@ data = {"Ts": [31, 58], "Tv": [36, 138], "": ["syn", "nsyn"]} table = make_table(header=["", "Ts", "Tv"], data=data) with self.assertRaises(ValueError): + # did not set an index_name table.to_categorical(columns=["Ts", "Tv"]) - table.index_name = "" - got = table.to_categorical(columns=["Ts", "Tv"]) + got = table.to_categorical(columns=["Ts", "Tv"], index_name="") assert_equal(got.observed, table[:, 1:].array) got = table.to_categorical(["Ts"]) diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_util/test_transform.py python-cogent-2021.10.12a1+dfsg/tests/test_util/test_transform.py --- python-cogent-2021.5.7a+dfsg/tests/test_util/test_transform.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_util/test_transform.py 2021-10-12 00:17:34.000000000 +0000 @@ -16,7 +16,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Rob Knight", "Sandra Smit", "Zongzhi Liu"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Sandra Smit" __email__ = "sandra.smit@colorado.edu" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/test_util/test_union_dict.py python-cogent-2021.10.12a1+dfsg/tests/test_util/test_union_dict.py --- python-cogent-2021.5.7a+dfsg/tests/test_util/test_union_dict.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/test_util/test_union_dict.py 2021-10-12 00:17:34.000000000 +0000 @@ -11,7 +11,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Gavin Huttley", "Thomas La"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tests/timetrial.py python-cogent-2021.10.12a1+dfsg/tests/timetrial.py --- python-cogent-2021.5.7a+dfsg/tests/timetrial.py 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tests/timetrial.py 2021-10-12 00:17:34.000000000 +0000 @@ -15,7 +15,7 @@ __copyright__ = "Copyright 2007-2021, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Edward Lang"] __license__ = "BSD-3" -__version__ = "2021.5.7a" +__version__ = "2021.10.12a1" __maintainer__ = "Gavin Huttley" __email__ = "gavin.huttley@anu.edu.au" __status__ = "Production" diff -Nru python-cogent-2021.5.7a+dfsg/tox.ini python-cogent-2021.10.12a1+dfsg/tox.ini --- python-cogent-2021.5.7a+dfsg/tox.ini 2021-05-06 22:09:29.000000000 +0000 +++ python-cogent-2021.10.12a1+dfsg/tox.ini 2021-10-12 00:17:34.000000000 +0000 @@ -1,8 +1,10 @@ [tox] envlist = py37, py38, py39, py37mpi, py38mpi, py39mpi +isolated_build = True [testenv] passenv = * +changedir = tests deps = py{37,38}: numba>0.48.0 py39: numba>0.52 chardet @@ -17,39 +19,33 @@ py{37mpi,38mpi,39mpi}: mpi4py [testenv:py39] -changedir = tests basepython = python3.9 commands = pytest -x --junitxml=junit-{envname}.xml --cov-report xml --cov=cogent3 ./ --ignore=test_app_mpi.py [testenv:py38] -changedir = tests basepython = python3.8 commands = pytest -x --junitxml=junit-{envname}.xml --cov-report xml --cov=cogent3 ./ --ignore=test_app_mpi.py [testenv:py37] -changedir = tests basepython = python3.7 commands = pytest -x --junitxml=junit-{envname}.xml --cov-report xml --cov=cogent3 ./ --ignore=test_app_mpi.py [testenv:py37mpi] -changedir = tests basepython = python3.7 whitelist_externals = mpiexec commands = mpiexec -n 1 {envpython} -m mpi4py.futures -m pytest -x --junitxml=junit-{envname}.xml --cov-report xml --cov=cogent3 test_app/test_app_mpi.py [testenv:py38mpi] -changedir = tests basepython = python3.8 whitelist_externals = mpiexec commands = mpiexec -n 1 {envpython} -m mpi4py.futures -m pytest -x --junitxml=junit-{envname}.xml --cov-report xml --cov=cogent3 test_app/test_app_mpi.py [testenv:py39mpi] -changedir = tests basepython = python3.9 whitelist_externals = mpiexec commands =