Giter Site home page Giter Site logo

widdowquinn / pyani Goto Github PK

View Code? Open in Web Editor NEW
181.0 11.0 54.0 189.51 MB

Application and Python module for average nucleotide identity analyses of microbes.

Home Page: http://widdowquinn.github.io/pyani/

License: MIT License

Python 99.55% Makefile 0.45%
bioinformatics average-nucleotide-identity taxonomy taxonomy-assignment classification ani

pyani's Introduction

pyani

Application and Python module for whole-genome classification of microbes using Average Nucleotide Identity.


Contributing

If you would like to contribute code to the pyani project (e.g. a bug fix or new feature), please refer to the CONTRIBUTING.md guide for more details.

pyani is maintained by:

and we are grateful to all who have contributed to this software:

Contributors ✨ (emoji key):

Leighton Pritchard
Leighton Pritchard

πŸ“– πŸ’» 🎨 πŸ’΅ πŸ€” πŸš‡ πŸ“† πŸ”§ ⚠️ βœ…
Bailey Harrington
Bailey Harrington

πŸ’» πŸ“– 🎨 πŸ€” πŸš‡ πŸ”§
Peter Cock
Peter Cock

πŸ’» πŸ€”
Robert Davey
Robert Davey

πŸ’» πŸ€”
Nick Waters
Nick Waters

πŸ“–
YT
YT

πŸ’» πŸ€”
Γ–zcan Esen
Γ–zcan Esen

πŸ’» πŸ›
BalΓ‘zs Brankovics
BalΓ‘zs Brankovics

πŸ’» πŸ›
sammywinchester19
sammywinchester19

πŸ›
Ram Krishna Shrestha
Ram Krishna Shrestha

⚠️ πŸ’» πŸ€” πŸ›
Donovan Parks
Donovan Parks

πŸ›
Zaki Saati SantamarΓ­a
Zaki Saati SantamarΓ­a

πŸ›
neelam19051
neelam19051

πŸ›
jthomp28
jthomp28

πŸ›
louellette
louellette

πŸ€”
Seb.
Seb.

πŸ€”
ninjatacoshell
ninjatacoshell

πŸ€”
Patricia H. Brito
Patricia H. Brito

πŸ€”
Zilia Y. MuΓ±oz Ramirez
Zilia Y. MuΓ±oz Ramirez

πŸ›
nclaesnacw
nclaesnacw

πŸ€”
Eric Deveaud
Eric Deveaud

πŸ›
Angelika Kiepas
Angelika Kiepas

πŸ’» 🎨 ⚠️

(This project follows the all-contributors specification. Contributions of any kind welcome!)


Citing pyani

A complete guide to citing pyani is included in the file CITATIONS. Please cite the following manuscript in your work, if you have found pyani useful:

Pritchard et al. (2016) "Genomics and taxonomy in diagnostics for food security: soft-rotting enterobacterial plant pathogens" Anal. Methods 8, 12-24 DOI: 10.1039/C5AY02550H


macOS Python 3.11 build Linux Python 3.11 build codecov.io coverage Codacy Badge CodeFactor documentation pyani sourcerank

All Contributors

pyani PyPi version pyani licence pyani PyPi version pyani PyPi version pyani PyPi version

GitHub Issues GitHub Stars Code Style: black

Anaconda-Server Badge Anaconda-Server Badge

Anaconda-Server Badge Anaconda-Server Badge Anaconda-Server Badge


Table of Contents


Overview

pyani is a software package and Python3 module that calculates average nucleotide identity (ANI) and related measures for whole genome comparisons, and renders relevant graphical summary output.

Where available, pyani can take advantage of multicore systems, and integrates with SGE/OGE-type job schedulers for the sequence comparisons.

pyani installs the program pyani, which enables command-line based analysis of genomes.


Installation

IMPORTANT NOTICE

THIS REPOSITORY DEFAULT BRANCH CONTAINS A DEVELOPMENT VERSION OF PYANI (v0.3+). IT HAS A DIFFERENT COMMAND-LINE INTERFACE THAN THE STABLE PYANI VERSION (v0.2.x).

Documentation for stable version pyani v0.2.x

IF YOU WISH TO INSTALL THE STABLE VERSION OF PYANI, PLEASE FOLLOW THESE INSTRUCTIONS FOR INSTALLING v0.2.x

The easiest way to install pyani v0.2 is to use conda or pip. conda is recommended for the simplest installation of third-party tool dependencies (mummer and BLAST/BLAST+).

conda

You will need to install the bioconda channel, following instructions at https://bioconda.github.io/user/install.html. Then, to create a new environment for pyani and install the program, issue the following command:

conda create --name pyani_env python=3.8 -y
conda activate pyani_env
conda install pyani

pip

pip will install pyani and its Python dependencies, but not the third-party tools.

pip3 install pyani

Third-party tools

Four alignment packages are required, to use all of pyani's methods: mummer, BLAST+, legacy BLAST, and fastANI. (Note that it is not necessary to install all four tools to use pyani. You need only install the tools that are required for the method you wish to use.)

The simplest route to obtaining these tools is to use conda/bioconda:

conda install mummer blast legacy-blast fastani -y

But they can also be installed by following instructions from the tools' own websites.

  • BLAST+ (for anib) ftp://ftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST/
  • legacy BLAST (for aniblastall) ftp://ftp.ncbi.nlm.nih.gov/blast/executables/release/LATEST/
  • MUMmer (for anim) http://mummer.sourceforge.net/
  • fastANI (for fastani) https://github.com/ParBLiSS/FastANI

NOTE: Installing legacy BLAST

The legacy BLAST executable available from NCBI will not run on macOS Big Sur.

If you wish to use pyani blastall or the ANIblastall method with the legacy pyani interface, you will require a locally-installed copy of this package. This is one of the packages linked in the requirements-thirdparty.txt file.

Note: Installing fastANI

fastANI installation (via conda) will fail for Python 3.9 on macOS.

If you are using Python β‰₯3.9 to run pyani on macOS, fastANI will fail to install due to errors in the conda recipe (for build h0a26cfa_0). Using an earlier version of Python may be the simplest solution. However, you can also install fastANI yourselfβ€”via condaβ€”using a slightly altered version of the command produced from the conda recipe, as shown below.

N.B. We have placed the fastANI requirement in its own requirements-fastani.txt file so that this will not also cause other installations to fail.

Bypassing conda
c++ -O3 -DNDEBUG -std=c++11 -Isrc \
-I ${ENV_DIR}/lib/include -mmacosx-version-min=10.7 \
-stdlib=libc++ -Xpreprocessor -fopenmp -lomp \
-DUSE_BOOST src/cgi/core_genome_identity.cpp -o fastANI \
${ENV_DIR}/lib/lib/libboost_math_c99.a \
-lstdc++ -lz -lm

Two alterations need to be made to the file name specified in the fifth line here:

  1. One of the /libs should be removed.
  2. The file extension should be changed from .a, to .dylib.

The resultant command ought to look something like this (with ${ENV_DIR} being wherever you're installing fastANI):

c++ -O3 -DNDEBUG -std=c++11 -Isrc \
-I ${ENV_DIR}/lib/include -mmacosx-version-min=10.7 \
-stdlib=libc++ -Xpreprocessor -fopenmp -lomp \
-DUSE_BOOST src/cgi/core_genome_identity.cpp -o fastANI \
${ENV_DIR}/lib/libboost_math_c99.dylib \
-lstdc++ -lz -lm

For a more technical overview of the issue, and other solutions that may be shared there, please see #377.

Troubleshooting

This solution is how one of our developers managed to solve the problem. We hope it works for you, but can not guarantee this. Unfortunately, if this does not work for you, we will also not be able to troubleshoot the issue. In this instance, please file an issue at https://github.com/bioconda/bioconda-recipes.


Documentation (v0.3)

This README.md file provides a quick overview and walkthrough for THE DEVELOPMENT VERSION (v0.3+) OF pyani, and full documentation can be found at the link below:

THIS README AND THE DOCUMENTATION AT READTHEDOCS REFERS TO A DEVELOPMENT VERSION OF PYANI (v0.3+). IT HAS A DIFFERENT COMMAND-LINE INTERFACE THAN THE STABLE PYANI VERSION (v0.2.x).

THE STABLE VERSION OF PYANI (v0.2) DOES NOT HAVE THE pyani COMMAND

Older documentation (v0.2)

If you are using pyani v0.2.x, then please note that the command-line API has changed, and documentation for this version can be found at the following page:

Bugs, issues, problems and questions

If you would like to report a bug or problem with pyani, or ask a question of the developer(s), please raise an issue at the link below:


Walkthrough: A First Analysis

The command-line interface to pyani uses subcommands. These separate individual steps of an analysis into separate actions.

  1. Download genomes
  2. Create a database to hold genome data and analysis results
  3. Perform ANI analysis
  4. Report and visualise analysis results
  5. Generate species hypotheses (classify genomes) using the analysis results

The steps are described in detail with examples, below.

1. Download genome data

The first step is to obtain genome data for analysis. pyani expects to find each individual genome in its own FASTA file (that file can contain multiple sequences - chromosomes and plasmids; sequenced scaffolds, etc). All the FASTA files for an analysis are expected to be located in a single subdirectory (with optional labels and classes files). You can arrange your data manually, but pyani provides a subcommand that downloads all genomes in a taxon subtree from NCBI, and organises them ready for use with pyani.

We'll use the pyani download subcommand to download all available genomes for Candidatus Blochmannia from NCBI. The taxon ID for this grouping is 203804.

pyani download -o C_blochmannia --email [email protected] -t 203804 -v -l C_blochmannia_dl.log

The first argument is the output directory into which the downloaded genomes will be written (-o C_blochmannia). To download anything from NCBI we must provide an email address (--email [email protected]), and to specify which taxon subtree we want to download we provide the taxon ID (-t 203804).

Here we also request verbose output (-v), and write a log file for reproducible research/diagnosing bugs and errors (-l C_blochmannia_dl.log).

This produces a new subdirectory (C_blochmannia) with the following contents:

$ tree C_blochmannia
C_blochmannia
β”œβ”€β”€ GCF_000011745.1_ASM1174v1_genomic.fna
β”œβ”€β”€ GCF_000011745.1_ASM1174v1_genomic.fna.gz
β”œβ”€β”€ GCF_000011745.1_ASM1174v1_genomic.fna.md5
β”œβ”€β”€ GCF_000011745.1_ASM1174v1_hashes.txt
β”œβ”€β”€ GCF_000043285.1_ASM4328v1_genomic.fna
β”œβ”€β”€ GCF_000043285.1_ASM4328v1_genomic.fna.gz
β”œβ”€β”€ GCF_000043285.1_ASM4328v1_genomic.fna.md5
β”œβ”€β”€ GCF_000043285.1_ASM4328v1_hashes.txt
β”œβ”€β”€ GCF_000185985.2_ASM18598v2_genomic.fna
β”œβ”€β”€ GCF_000185985.2_ASM18598v2_genomic.fna.gz
β”œβ”€β”€ GCF_000185985.2_ASM18598v2_genomic.fna.md5
β”œβ”€β”€ GCF_000185985.2_ASM18598v2_hashes.txt
β”œβ”€β”€ GCF_000331065.1_ASM33106v1_genomic.fna
β”œβ”€β”€ GCF_000331065.1_ASM33106v1_genomic.fna.gz
β”œβ”€β”€ GCF_000331065.1_ASM33106v1_genomic.fna.md5
β”œβ”€β”€ GCF_000331065.1_ASM33106v1_hashes.txt
β”œβ”€β”€ GCF_000973505.1_ASM97350v1_genomic.fna
β”œβ”€β”€ GCF_000973505.1_ASM97350v1_genomic.fna.gz
β”œβ”€β”€ GCF_000973505.1_ASM97350v1_genomic.fna.md5
β”œβ”€β”€ GCF_000973505.1_ASM97350v1_hashes.txt
β”œβ”€β”€ GCF_000973545.1_ASM97354v1_genomic.fna
β”œβ”€β”€ GCF_000973545.1_ASM97354v1_genomic.fna.gz
β”œβ”€β”€ GCF_000973545.1_ASM97354v1_genomic.fna.md5
β”œβ”€β”€ GCF_000973545.1_ASM97354v1_hashes.txt
β”œβ”€β”€ classes.txt
└── labels.txt

Seven genomes have been downloaded, and each is represented by four files:

  • _genomic.fna.gz: the compressed genome sequence
  • _genomic.fna: the uncompressed genome sequence
  • _genomic.fna.md5: an MD5 hash/checksum of the (uncompressed) genome sequence; this was generated during the download
  • _hashes.txt: a list of MD5 hashes; this is provided by NCBI and is a reference to be sure that the download did not corrupt the genome sequence

There are two additional plain text files: classes.txt and labels.txt, which provide alternative labels for use in the analysis. These files are generated during the download.

2. Create an analysis database

pyani uses a database to store genome data and analysis results. This is convenient for data sharing and developing custom analyses, but also makes it easier to extend an existing ANI analysis with new genomes, without having to repeat calculations that were already performed.

To create a new, clean, database in the default location (.pyani/pyanidb) issue the command:

pyani createdb -v -l C_blochmannia_createdb.log

As above, the verbose (-v) and log file (-l C_blochmannia_createdb.log) options allow for reproducible work. The default database location is in the hidden directory (.pyani):

$ tree .pyani
.pyani
└── pyanidb

Subsequent pyani commands will assume this location for the database, but you can specify the location when creating a database, or using an existing database.

3. Conduct ANI analysis

pyani provides four subcommands to run ANI analyses:

  • anim: ANIm
  • anib: ANIb, using BLAST+
  • aniblastall: ANIb, using legacy BLAST
  • tetra: TETRA

In this walkthrough, we'll run ANIm on the downloaded genomes, using the command:

pyani anim -i C_blochmannia -o C_blochmannia_ANIm -v -l C_blochmannia_ANIm.log \
    --name "C. blochmannia run 1" \
    --labels C_blochmannia/labels.txt --classes C_blochmannia/classes.txt

All four analysis commands operate in a similar way. The first two arguments are paths to directories: the first path is to a directory containing input genomes, and the second is the path to an output directory for storing intermediate results. The -v and -l arguments work as above, specifying verbose output and logging output to a file.

You will probably notice that the verbose output is very verbose, to enable informative identification of any problems. In particular, the verbose output (which is also written to the log file) writes out the command-lines used for the pairwise comparisons so, if something goes wrong, you can test whether a specific comparison can be run at the command-line at all, to aid diagnosis of any problems.

Rerunning the same analysis

One reason for using a database backend for analysis results is so that, for very large analyses, we do not ever need to recalculate a pairwise genome comparison. All the analysis subcommands check whether input genomes have been used before (using the unique MD5 hash for each genome to identify whether it's been used previously), and whether the comparison of two genomes has been run, with the particular analysis settings that were used. If either genome was not seen before, or if the analysis settings are different, the comparison is performed.

You can test this for yourself by running the analysis command again, as below. You will see a number of messages indicating that genomes have been seen before, and that analyses performed before were skipped:

$ pyani anim -i C_blochmannia -o C_blochmannia_ANIm -v -l C_blochmannia_ANIm.log \
    --name "C. blochmannia run 2" \
    --labels C_blochmannia/labels.txt --classes C_blochmannia/classes.txt
INFO: command-line: pyani anim -i C_blochmannia -o C_blochmannia_ANIm -v -l C_blochmannia_ANIm.log
INFO: Running ANIm analysis
INFO: Adding analysis information to database .pyani/pyanidb
INFO: Current analysis has ID 2 in this database
INFO: Identifying input genome/hash files:
[…]
INFO: Adding genome data to database...
WARNING: Genome already in database with this hash and path!
WARNING: Using existing genome from database, row 1
[…]
INFO: Complete pairwise comparison list:
    [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 3), (2, 4), (2, 5), (2, 6), (3, 4), (3, 5), (3, 6), (4, 5), (4, 6), (5, 6)]
INFO: Excluding pre-calculated comparisons
INFO: Comparisons still to be performed:
    []
INFO: All comparison results already present in database (skipping comparisons)
INFO: Completed. Time taken: 0.211

4. Reporting Analyses and Analysis Results

Once an analysis is run, the results are placed in a local SQLite database, which can be queried for information about the analyses that have been run. You can request information about:

  • --runs: show all analysis runs with results stored in the database
  • --runs_genomes: show all the analysis runs with results in the database, and all the genomes analysed in each run
  • --genomes: show all the genomes used for any analysis in the database
  • --genomes_runs: for each genome in the database, also list the analysis results it participates in
  • --run_results: show all the pairwise comparison results for a named run (run IDs can be obtained with the --runs argument

The report tables are written to a named directory (compulsory argument), and are written by default to a .tab plain-text format, but HTML and Excel format can also be requested with the --formats argument:

$ pyani report -v --runs -o C_blochmannia_ANIm/ --formats html,excel,stdout
INFO: Processed arguments: Namespace(cmdline='./pyani report -v --runs -o C_blochmannia_ANIm/ --formats html,excel', dbpath='.pyani/pyanidb', formats='html,excel', func=<function subcmd_report at 0x10c674a60>, logfile=None, outdir='C_blochmannia_ANIm/', run_results=False, show_genomes=False, show_genomes_runs=False, show_runs=True, show_runs_genomes=False, verbose=True)
INFO: command-line: ./pyani report -v --runs -o C_blochmannia_ANIm/ --formats html,excel
INFO: Creating output in formats: ['excel', 'tab', 'html']
INFO: Using database: .pyani/pyanidb
INFO: Writing table of pyani runs from the database to C_blochmannia_ANIm/runs.*
INFO: Completed. Time taken: 0.937
$ tree -L 1 C_blochmannia_ANIm/
C_blochmannia_ANIm/
β”œβ”€β”€ nucmer_output
β”œβ”€β”€ runs.html
β”œβ”€β”€ runs.tab
└── runs.xlsx

To see all of the pairwise results for an individual run, the run ID must be provided. It is possible to get results for more than one run ID by providing a comma-separated list of run IDs (though each run's results will be provided in a separate file):

$ pyani report -v --runs -o C_blochmannia_ANIm/ --formats html,excel --run_results 1,2,3,4
INFO: Processed arguments: Namespace(cmdline='./pyani report -v --runs -o C_blochmannia_ANIm/ --formats html,excel --run_results 1,2,3,4', dbpath='.pyani/pyanidb', formats='html,excel', func=<function subcmd_report at 0x108616a60>, logfile=None, outdir='C_blochmannia_ANIm/', run_results='1,2,3,4', show_genomes=False, show_genomes_runs=False, show_runs=True, show_runs_genomes=False, verbose=True)
INFO: command-line: ./pyani report -v --runs -o C_blochmannia_ANIm/ --formats html,excel --run_results 1,2,3,4
INFO: Creating output in formats: ['tab', 'excel', 'html']
INFO: Using database: .pyani/pyanidb
INFO: Writing table of pyani runs from the database to C_blochmannia_ANIm/runs.*
INFO: Attempting to write results tables for runs: ['1', '2', '3', '4']
INFO: Collecting data for run with ID: 1
INFO: Collecting data for run with ID: 2
INFO: Collecting data for run with ID: 3
INFO: Collecting data for run with ID: 4
INFO: Completed. Time taken: 1.285

You can see a run's results in the terminal by specifying the stdout format. For example, to see the identity, coverage, and other output matrices, you would specify --run_matrices <RUN> and --formats=stdout as below:

$ pyani report -o C_blochmannia_ANIm --formats=stdout --run_matrices 1
TABLE: C_blochmannia_ANIm/matrix_identity_1
                                                    C. Blochmannia pennsylvanicus BPEN  C. Blochmannia floridanus  C. Blochmannia vafer BVAF  C. Blochmannia chromaiodes 640  B. endosymbiont of Polyrhachis (Hedomyrma) turneri 675  B. endosymbiont of Camponotus (Colobopsis) obliquus 757
C. Blochmannia pennsylvanicus BPEN                                            1.000000                   0.834866                   0.836903                        0.980244                                           0.843700                                                0.829509
C. Blochmannia floridanus                                                     0.834866                   1.000000                   0.828733                        0.834916                                           0.847060                                                0.857859
C. Blochmannia vafer BVAF                                                     0.836903                   0.828733                   1.000000                        0.837811                                           0.866015                                                0.844438
C. Blochmannia chromaiodes 640                                                0.980244                   0.834916                   0.837811                        1.000000                                           0.849834                                                0.834769
B. endosymbiont of Polyrhachis (Hedomyrma) turn...                            0.843700                   0.847060                   0.866015                        0.849834                                           1.000000                                                0.844228
B. endosymbiont of Camponotus (Colobopsis) obli...                            0.829509                   0.857859                   0.844438                        0.834769                                           0.844228                                                1.000000

TABLE: C_blochmannia_ANIm/matrix_coverage_1
                                                    C. Blochmannia pennsylvanicus BPEN  C. Blochmannia floridanus  C. Blochmannia vafer BVAF  C. Blochmannia chromaiodes 640  B. endosymbiont of Polyrhachis (Hedomyrma) turneri 675  B. endosymbiont of Camponotus (Colobopsis) obliquus 757
C. Blochmannia pennsylvanicus BPEN                                            1.000000                   0.045736                   0.041404                        1.000306                                           0.017263                                                0.021027
C. Blochmannia floridanus                                                     0.051317                   1.000000                   0.152609                        0.054930                                           0.016366                                                0.010749
C. Blochmannia vafer BVAF                                                     0.045362                   0.149012                   1.000000                        0.046520                                           0.008356                                                0.014706
C. Blochmannia chromaiodes 640                                                1.000856                   0.048983                   0.042485                        1.000000                                           0.014056                                                0.016140
B. endosymbiont of Polyrhachis (Hedomyrma) turn...                            0.018238                   0.015410                   0.008058                        0.014841                                           1.000000                                                0.020416
B. endosymbiont of Camponotus (Colobopsis) obli...                            0.021508                   0.009799                   0.013730                        0.016500                                           0.019766                                                1.000000

TABLE: C_blochmannia_ANIm/matrix_aln_lengths_1
                                                    C. Blochmannia pennsylvanicus BPEN  C. Blochmannia floridanus  C. Blochmannia vafer BVAF  C. Blochmannia chromaiodes 640  B. endosymbiont of Polyrhachis (Hedomyrma) turneri 675  B. endosymbiont of Camponotus (Colobopsis) obliquus 757
C. Blochmannia pennsylvanicus BPEN                                            791654.0                    36207.0                    32778.0                        791896.0                                            13666.0                                                 16646.0
C. Blochmannia floridanus                                                      36207.0                   705557.0                   107674.0                         38756.0                                            11547.0                                                  7584.0
C. Blochmannia vafer BVAF                                                      32778.0                   107674.0                   722585.0                         33615.0                                             6038.0                                                 10626.0
C. Blochmannia chromaiodes 640                                                791896.0                    38756.0                    33615.0                        791219.0                                            11121.0                                                 12770.0
B. endosymbiont of Polyrhachis (Hedomyrma) turn...                             13666.0                    11547.0                     6038.0                         11121.0                                           749321.0                                                 15298.0
B. endosymbiont of Camponotus (Colobopsis) obli...                             16646.0                     7584.0                    10626.0                         12770.0                                            15298.0                                                     NaN

TABLE: C_blochmannia_ANIm/matrix_sim_errors_1
                                                    C. Blochmannia pennsylvanicus BPEN  C. Blochmannia floridanus  C. Blochmannia vafer BVAF  C. Blochmannia chromaiodes 640  B. endosymbiont of Polyrhachis (Hedomyrma) turneri 675  B. endosymbiont of Camponotus (Colobopsis) obliquus 757
C. Blochmannia pennsylvanicus BPEN                                                 0.0                     5979.0                     5346.0                         15645.0                                             2136.0                                                  2838.0
C. Blochmannia floridanus                                                       5979.0                        0.0                    18441.0                          6398.0                                             1766.0                                                  1078.0
C. Blochmannia vafer BVAF                                                       5346.0                    18441.0                        0.0                          5452.0                                              809.0                                                  1653.0
C. Blochmannia chromaiodes 640                                                 15645.0                     6398.0                     5452.0                             0.0                                             1670.0                                                  2110.0
B. endosymbiont of Polyrhachis (Hedomyrma) turn...                              2136.0                     1766.0                      809.0                          1670.0                                                0.0                                                  2383.0
B. endosymbiont of Camponotus (Colobopsis) obli...                              2838.0                     1078.0                     1653.0                          2110.0                                             2383.0                                                     0.0

TABLE: C_blochmannia_ANIm/matrix_hadamard_1
                                                    C. Blochmannia pennsylvanicus BPEN  C. Blochmannia floridanus  C. Blochmannia vafer BVAF  C. Blochmannia chromaiodes 640  B. endosymbiont of Polyrhachis (Hedomyrma) turneri 675  B. endosymbiont of Camponotus (Colobopsis) obliquus 757
C. Blochmannia pennsylvanicus BPEN                                            1.000000                   0.038183                   0.034652                        0.980543                                           0.014564                                                0.017442
C. Blochmannia floridanus                                                     0.042843                   1.000000                   0.126472                        0.045862                                           0.013863                                                0.009221
C. Blochmannia vafer BVAF                                                     0.037964                   0.123491                   1.000000                        0.038975                                           0.007237                                                0.012418
C. Blochmannia chromaiodes 640                                                0.981082                   0.040896                   0.035594                        1.000000                                           0.011945                                                0.013473
B. endosymbiont of Polyrhachis (Hedomyrma) turn...                            0.015387                   0.013053                   0.006978                        0.012613                                           1.000000                                                0.017236
B. endosymbiont of Camponotus (Colobopsis) obli...                            0.017841                   0.008406                   0.011594                        0.013774                                           0.016687                                                1.000000

5. Generating graphical output for ANI

The output of a pyani run can also be represented graphically, using the plot subcommand. For example, the command:

pyani plot -o C_blochmannia_ANIm --run_id 1 -v --formats png,pdf

will place .pdf and .png format output in the C_blochmannia_ANIm output directory for the run with ID 1, generated above. Five heatmaps are generated:

  • percentage identity
  • percentage coverage (for both query and subject)
  • alignment length (total aligned length)
  • similarity errors (total number of mismatches, not including indels)
  • hadamard matrix (dot product of identity and coverage matrices)

The heatmaps also include dendrograms, clustering the rows and columns by overall similarity.

NOTE: Running pyani plot with a large number of genomes (~500) and the default figure output (--method seaborn) may reduce output figure quality:

  • labels in .png files may be difficult to read
  • .pdf files may render very slowly due to the large number of numerical values in heatmap cells.

With large datasets, --method mpl (matplotlib) is recommended.

Please be aware that the matrix orientation differs for these two options; so, with seaborn (the default, --method seaborn), the orientation of self-comparisons is top left to bottom right (\), while with matplotlib (--method mpl) the orientation is bottom left to top right (/).

6. Classifying Genomes from Analysis Results


Using a scheduler

SGE/OGE

The --scheduler SGE argument allows one to use pyani with an an SGE-type scheduler.

In order for this work, one must be able to submit jobs using the qsub command. By default, this will batch the pairwise comparisons in array jobs of 10,000, in order to avoid clogging the scheduler queue. Each comparison will be run as a single-core task in an array job.

Arguments assigned by Pyani

The following arguments will be automatically set:

-N job_name  # this is the value passed to `--name`
-cwd
-o ./stdout  # cwd/ + "stdout"
-e ./stderr  # cwd/ + "stderr"

Modifiable arguments

The number of pairwise comparisons submitted per chunk can be modified using:

--SGEgroupsize *number*

The job prefix to use can be modified using:

--jobprefix *prefix*

Specifying additional arguments

Additional SGE arguments may be specified with:

--SGEargs "<your arguments here>"

Running pyani version 0.2.x

Script: average_nucleotide_identity.py

The average_nucleotide_identity.py script - installed as part of this package - enables straightforward ANI analysis at the command-line, and uses the pyani module behind the scenes.

You can get a summary of available command-line options with average_nucleotide_identity.py -h

$ ./average_nucleotide_identity.py -h
usage: average_nucleotide_identity.py [-h] [-o OUTDIRNAME] [-i INDIRNAME] [-v]
                                      [-f] [-s FRAGSIZE] [-l LOGFILE]
                                      [--skip_nucmer] [--skip_blastn]
                                      [--noclobber] [--nocompress] [-g]
                                      [--gformat GFORMAT] [--gmethod GMETHOD]
                                      [--labels LABELS] [--classes CLASSES]
                                      [-m METHOD] [--scheduler SCHEDULER]
                                      [--workers WORKERS]
                                      [--SGEgroupsize SGEGROUPSIZE]
                                      [--maxmatch] [--nucmer_exe NUCMER_EXE]
                                      [--blastn_exe BLASTN_EXE]
                                      [--makeblastdb_exe MAKEBLASTDB_EXE]
                                      [--blastall_exe BLASTALL_EXE]
                                      [--formatdb_exe FORMATDB_EXE]
                                      [--write_excel] [--subsample SUBSAMPLE]
                                      [--seed SEED] [--jobprefix JOBPREFIX]


[…]

Example data and output can be found in the directory test_ani_data. The data are chromosomes of four isolates of Caulobacter. Basic analyses can be performed with the command lines:

./average_nucleotide_identity.py -i tests/test_ani_data/ -o tests/test_ANIm_output -m ANIm -g
./average_nucleotide_identity.py -i tests/test_ani_data/ -o tests/test_ANIb_output -m ANIb -g
./average_nucleotide_identity.py -i tests/test_ani_data/ -o tests/test_ANIblastall_output -m ANIblastall -g
./average_nucleotide_identity.py -i tests/test_ani_data/ -o tests/test_TETRA_output -m TETRA -g

The graphical output below, supporting assignment of NC_002696 and NC_011916 to the same species (C.crescentus), and the other two isolates to distinct species (NC_014100:C.segnis; NC_010338:C. sp K31), was generated with the command-line:

./average_nucleotide_identity.py -v -i tests/test_ani_data/ \
    -o tests/test_ANIm_output/ -g --gformat png,pdf,eps \
    --classes tests/test_ani_data/classes.tab \
    --labels tests/test_ani_data/labels.tab

ANIm percentage identity for Caulobacter test data ANIm alignment coverage for Caulobacter test data ANIm alignment length for Caulobacter test data ANIm alignment similarity errors for Caulobacter test data

Script: genbank_get_genomes_by_taxon.py

The script genbank_get_genomes_by_taxon.py, installed by this package, enables download of genomes from NCBI, specified by taxon ID. The script will download all available assemblies for taxa at or below the specified node in the NCBI taxonomy tree.

Command-line options can be viewed using:

$ genbank_get_genomes_by_taxon.py -h
usage: genbacnk_get_genomes_by_taxon.py [-h] [-o OUTDIRNAME] [-t TAXON] [-v]
                                        [-f] [--noclobber] [-l LOGFILE]
                                        [--format FORMAT] [--email EMAIL]
                                        [--retries RETRIES]
                                        [--batchsize BATCHSIZE]
[…]

For example, the NCBI taxonomy ID for Caulobacter is 75, so all publicly-available Caulobacter sequences can be obtained using the command-line:

$ genbank_get_genomes_by_taxon.py -o Caulobacter_downloads -v -t 75 -l Caulobacter_downloads.log --email [email protected]
INFO: genbank_get_genomes_by_taxon.py: Mon Apr 18 17:22:54 2016
INFO: command-line: /Users/lpritc/Virtualenvs/pyani3/bin/genbank_get_genomes_by_taxon.py -o Caulobacter_downloads -v -t 75 -l Caulobacter_downloads.log --email [email protected]
INFO: Namespace(batchsize=10000, email='[email protected]', force=False, format='gbk,fasta', logfile='Caulobacter_downloads.log', noclobber=False, outdirname='Caulobacter_downloads', retries=20, taxon='75', verbose=True)
INFO: Set NCBI contact email to [email protected]
INFO: Creating directory Caulobacter_downloads
INFO: Output directory: Caulobacter_downloads
INFO: Passed taxon IDs: 75
INFO: Entrez ESearch with query: txid75[Organism:exp]
INFO: Entrez ESearch returns 29 assembly IDs
INFO: Identified 29 unique assemblies
INFO: Taxon 75: 29 assemblies
[…]
INFO: Assembly 639581: 271 contigs
INFO: Assembly 233261: 17 contigs
INFO: Assembly 575291: 48 contigs
INFO: Mon Apr 18 17:25:46 2016
INFO: Done.

NOTE: You must provide a valid email to identify yourself to NCBI for troubleshooting.

The number of attempted retries for each download, and the size of a batch download can be modified. By default, the script will attempt 20 download retries, and obtain sequences in batches of 10,000.


Method and Output Description

Average Nucleotide Identity (ANI)

This module calculates Average Nucleotide Identity (ANI) according to one of a number of alternative methods described in, e.g.

  • Richter M, Rossello-Mora R (2009) Shifting the genomic gold standard for the prokaryotic species definition. Proc Natl Acad Sci USA 106: 19126-19131. doi:10.1073/pnas.0906412106. (ANI1020, ANIm, ANIb)
  • Goris J, Konstantinidis KT, Klappenbach JA, Coenye T, Vandamme P, et al. (2007) DNA-DNA hybridization values and their relationship to whole-genome sequence similarities. Int J Syst Evol Micr 57: 81-91. doi:10.1099/ijs.0.64483-0.

ANI is proposed to be the appropriate in silico substitute for DNA-DNA hybridisation (DDH), and so useful for delineating species boundaries. A typical percentage threshold for species boundary in the literature is 95% ANI (e.g. Richter et al. 2009).

All ANI methods follow the basic algorithm:

  • Align the genome of organism 1 against that of organism 2, and identify the matching regions.
  • Calculate the percentage nucleotide identity of the matching regions, as an average for all matching regions.

Methods differ on: (1) what alignment algorithm is used, and the choice of parameters (this affects the aligned region boundaries); (2) what the input is for alignment (typically either fragments of fixed size, or the most complete assembly available).

  • ANIm: uses MUMmer (NUCmer) to align the input sequences
  • ANIb: uses BLASTN+ to align 1020nt fragments of the input sequences
  • ANIblastall: uses legacy BLASTN to align 10al20nt fragments of the input sequences
  • TETRA: calculates tetranucleotide frequencies of each input sequence

The algorithms take as input correctly-formatted FASTA multiple sequence files. All sequences for a single organism should be contained in only one sequence file. Although it is possible to provide new labels for each input genome for rendering graphical output, the names of these files are used for identification so it is best to name them sensibly.

Output is written to a named directory. The output files differ depending on the chosen ANI method.

  • ANIm: MUMmer/NUCmer .delta files, describing each pairwise sequence alignment. Output as tab-separated plain text format tables describing: alignment coverage; total alignment lengths; similarity errors; and percentage identity (ANIm).
  • ANIb and ANIblastall: FASTA sequences describing 1020nt fragments of each input sequence; BLAST nucleotide databases - one for each set of fragments; and BLASTN output files (tab-separated tabular format plain text) - one for each pairwise comparison of input sequences. Output as tab-separated plain text tables describing: alignment coverage; total alignment lengths; similarity errors; and percentage identity (ANIb or ANIblastall).
  • TETRA: Tab-separated plain text files describing the Pearson correlations between Z-score distributions for each tetranucleotide in each input sequence (TETRA).

If graphical output is chosen, the output directory will also contain PDF, PNG and EPS files representing the various output measures as a heatmap with row and column dendrograms. Other output formats (e.g. SVG) can be specified with the --gformat argument.


Licensing

Unless otherwise indicated, all code is subject to the following agreement:

    (c) The James Hutton Institute 2014-2019
    (c) The University of Strathclyde 2019-present
    Author: Leighton Pritchard

    Contact: [email protected]

    Address:
    Leighton Pritchard,
    Strathclyde Institute of Pharmacy and Biomedical Sciences
    161 Cathedral Street
    Glasgow
    G4 0RE,
    Scotland,
    UK

The MIT License

Copyright (c) 2014-2019 The James Hutton Institute
Copyright (c) 2014-present The James Hutton Institute

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

pyani's People

Contributors

allcontributors[bot] avatar b-brankovics avatar baileythegreen avatar froggleston avatar kiepczi avatar nickp60 avatar ozcan avatar peterjc avatar rknx avatar widdowquinn avatar ytanizaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyani's Issues

shebang of average_nucleotide_identity.py seems to be subjective

Just a minor issue: I just installed the current version of pyani via pip. This version includes this shebang, which seems to point to a developers subjective python location:
#!/Users/lpritc/Development/GitHub/pyani/venv-pyani/bin/python

Maybe this should be changed to the more generally applicable #!/usr/bin/env python or simply left out completely?

pyani Version: pyani-0.2.2

Python Version: 3.5.2

Operating System: Red Hat Linux

Document version of Python required

It wasn't clear from the README which versions of Python are supported (probably just Python 2.7 right now, see also #12 for Python 3 support).

Note following the dependency chain from requirements.txt, recent versions of rpy2 and pandas do not support Python 2.6 any more.

Error installing pyani

Hello, guys.
I installed python Version 3.5.2 to set up pyani.
But after performing with pip3 install pyani command, I have an error in the command python setup.py .
How can I solve this problem??

Tests fail with MatPlotLib 2.0

Summary:

nosetests fail with the new matplotlib

Description:

Running nosetests fails with

======================================================================
ERROR: Write .png graphics with mpl
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/lpritc/Documents/Development/pyani/tests/test_graphics.py", line 60, in test_png_mpl
    draw_format_method("png", "mpl")
  File "/Users/lpritc/Documents/Development/pyani/tests/test_graphics.py", line 55, in draw_format_method
    params=method_params)
  File "/Users/lpritc/Documents/Development/pyani/pyani/pyani_graphics.py", line 322, in heatmap_mpl
    orientation='row')
  File "/Users/lpritc/Documents/Development/pyani/pyani/pyani_graphics.py", line 196, in add_mpl_dendrogram
    height_ratios=[1, 0.15])
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/matplotlib/gridspec.py", line 345, in __init__
    height_ratios=height_ratios)
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/matplotlib/gridspec.py", line 47, in __init__
    self.set_height_ratios(height_ratios)
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/matplotlib/gridspec.py", line 76, in set_height_ratios
    raise ValueError('Expected the given number of height ratios to '
ValueError: Expected the given number of height ratios to match the number of rows of the grid

======================================================================
ERROR: Write .svg graphics with mpl
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/lpritc/Documents/Development/pyani/tests/test_graphics.py", line 65, in test_svg_mpl
    draw_format_method("svg", "mpl")
  File "/Users/lpritc/Documents/Development/pyani/tests/test_graphics.py", line 55, in draw_format_method
    params=method_params)
  File "/Users/lpritc/Documents/Development/pyani/pyani/pyani_graphics.py", line 322, in heatmap_mpl
    orientation='row')
  File "/Users/lpritc/Documents/Development/pyani/pyani/pyani_graphics.py", line 196, in add_mpl_dendrogram
    height_ratios=[1, 0.15])
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/matplotlib/gridspec.py", line 345, in __init__
    height_ratios=height_ratios)
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/matplotlib/gridspec.py", line 47, in __init__
    self.set_height_ratios(height_ratios)
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/matplotlib/gridspec.py", line 76, in set_height_ratios
    raise ValueError('Expected the given number of height ratios to '
ValueError: Expected the given number of height ratios to match the number of rows of the grid

======================================================================
ERROR: Write .pdf graphics with mpl
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Users/lpritc/Documents/Development/pyani/tests/test_graphics.py", line 70, in test_pdf_mpl
    draw_format_method("pdf", "mpl")
  File "/Users/lpritc/Documents/Development/pyani/tests/test_graphics.py", line 55, in draw_format_method
    params=method_params)
  File "/Users/lpritc/Documents/Development/pyani/pyani/pyani_graphics.py", line 322, in heatmap_mpl
    orientation='row')
  File "/Users/lpritc/Documents/Development/pyani/pyani/pyani_graphics.py", line 196, in add_mpl_dendrogram
    height_ratios=[1, 0.15])
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/matplotlib/gridspec.py", line 345, in __init__
    height_ratios=height_ratios)
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/matplotlib/gridspec.py", line 47, in __init__
    self.set_height_ratios(height_ratios)
  File "/Users/lpritc/Documents/Development/pyani/venv-pyani-devel/lib/python3.6/site-packages/matplotlib/gridspec.py", line 76, in set_height_ratios
    raise ValueError('Expected the given number of height ratios to '
ValueError: Expected the given number of height ratios to match the number of rows of the grid

Reproducible Steps:

  • clone pyani
  • create virtualenv and install requirements
  • run nosetests

pyani Version:

0.2.1

Python Version:

3.6

Operating System:

OSX

error in running average_nucleotide_identity

Hi

I tried running pyani on the test dataset but ran into this error:

average_nucleotide_identity.py -i tests/test_ani_data/ -o tests/test_ANIm_output -m ANIm -g
WARNING: At least one NUCmer comparison failed. ANIm may fail.
/home/dnanexus/py350/lib/python3.5/site-packages/scipy/cluster/hierarchy.py:667: RuntimeWarning: invalid value encountered in greater_equal
if np.all(y >= 0) and np.allclose(y, y.T):
Traceback (most recent call last):
File "/home/dnanexus/py350/bin/average_nucleotide_identity.py", line 791, in
draw(methods[args.method][1], gfmt, args.rerender)
File "/home/dnanexus/py350/bin/average_nucleotide_identity.py", line 627, in draw
params=params)
File "/home/dnanexus/py350/lib/python3.5/site-packages/pyani/pyani_graphics.py", line 322, in heatmap_mpl
orientation='col')
File "/home/dnanexus/py350/lib/python3.5/site-packages/pyani/pyani_graphics.py", line 200, in add_mpl_dendrogram
dend = sch.dendrogram(sch.linkage(dists, method='complete'),
File "/home/dnanexus/py350/lib/python3.5/site-packages/scipy/cluster/hierarchy.py", line 676, in linkage
raise ValueError("The condensed distance matrix must contain only finite values.")
ValueError: The condensed distance matrix must contain only finite values.

Pls advise.

Thank you.

matplotlib collections.py FutureWarning

$ ./average_nucleotide_identity.py -i tests/test_ani_data/  -o tests/test_ANIm_output/ -g --gformat png \
    --classes tests/test_ani_data/classes.tab     --labels tests/test_ani_data/labels.tab --force
/Users/lpritc/Virtualenvs/pyani/lib/python2.7/site-packages/matplotlib/collections.py:590:
FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform
 elementwise comparison
  if self._edgecolors == str('face'):

Palette of colors

It's me, again! This time not for a real issue but for a cosmetic detail ;)

What's the best way to change the palette of colors?

Collating results is slow for large datasets (>1500 genomes)

Currently, the code writes out all results individually and leaves processing output for calculation of ANI etc. until the end. This leaves an uninformative, and long, lag time before the results are presented to the user.

It may be possible to collate/summarise intermediate results in file, as we go. The total analysis time will be no shorter, but it might avoid that 'dead time' after the alignments are done.

Repeated ERROR: One or more NUCmer output files has a problem.

Summary:

I would expect to see this error message block only once:

ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.

Description:

Describe the issue as clearly as possible.

Reproducible Steps:

Using taxon 613 download with the fetch script.

Current Output:

The current output. Knowing what is the current behavior is useful.

$ average_nucleotide_identity.py -i pyani_fetch_txid613 -o pyani_calc_txid613_all -l pyani_calc_txid613.log -g --labels pyani_fetch_txid613/labels.txt --classes pyani_fetch_txid613/classes.txt --scheduler SGE --jobprefix "pyani613_all" --noclobber  --force
WARNING: NOCLOBBER: not actually deleting directory
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_000176835.2_ASM17683v2_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_900016775.1_STsPazieg1.0_genomic_vs_GCF_000783975.1_ASM78397v1_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_900016775.1_STsPazieg1.0_genomic_vs_GCF_000261045.2_ASM26104v2_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_900016775.1_STsPazieg1.0_genomic_vs_GCF_000513215.1_DB11_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_001606165.1_ASM160616v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_900016775.1_STsPazieg1.0_genomic_vs_GCA_000392415.2_Cofactor_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_001294565.1_ASM129456v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_001590765.1_ASM159076v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_001914155.1_ASM191415v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_001663115.1_ASM166311v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
...

Expected Output:

Describe what you expect the output to be. Knowing the correct behavior is also very useful.

$ average_nucleotide_identity.py -i pyani_fetch_txid613 -o pyani_calc_txid613_all -l pyani_calc_txid613.log -g --labels pyani_fetch_txid613/labels.txt --classes pyani_fetch_txid613/classes.txt --scheduler SGE --jobprefix "pyani613_all" --noclobber  --force
WARNING: NOCLOBBER: not actually deleting directory
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_000176835.2_ASM17683v2_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_900016775.1_STsPazieg1.0_genomic_vs_GCF_000783975.1_ASM78397v1_genomic.delta is zero!
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_900016775.1_STsPazieg1.0_genomic_vs_GCF_000261045.2_ASM26104v2_genomic.delta is zero!
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_900016775.1_STsPazieg1.0_genomic_vs_GCF_000513215.1_DB11_genomic.delta is zero!
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_001606165.1_ASM160616v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_900016775.1_STsPazieg1.0_genomic_vs_GCA_000392415.2_Cofactor_genomic.delta is zero!
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_001294565.1_ASM129456v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_001590765.1_ASM159076v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCA_001914155.1_ASM191415v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
WARNING: Total alignment length reported in pyani_calc_txid613_all/nucmer_output/GCF_001663115.1_ASM166311v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
...
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
...

pyani Version:

0.2.3.dev

Python Version:

3.5

Operating System:

Linux

local variable 'filestem' referenced before assignment in all methods except TETRA

Thank you for this script. I keep running into this issue when running ANIm or ANIb. It does not seem to be present when using TETRA

Summary:

Please provide a short summary (a couple of sentences).

Using the command: average_nucleotide_identity.py -v -i tests/reference/ -o tests/output/ -m ANIm -g --gformat pdf --labels tests/labels -l log_test -f

Description:

Describe the issue as clearly as possible.

It generates the NUCmer command-lines, then produces the following:

INFO: Command pool done.
INFO: Cumulative return value: 0
INFO: All multiprocessing jobs complete.
INFO: Processing NUCmer .delta files.
INFO: Compressing/deleting tests/output/nucmer_output
INFO: Compressing output from tests/output/nucmer_output to tests/output/nucmer_output.tar.gz
INFO: Removing output directory tests/output/nucmer_output
INFO: Writing ANIm results to tests/output/
Traceback (most recent call last):
File "/bin/average_nucleotide_identity.py", line 4, in
import('pkg_resources').run_script('pyani==0.2.1.dev0', 'average_nucleotide_identity.py')
File "/lib/python3.6/site-packages/pkg_resources/init.py", line 743, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/lib/python3.6/site-packages/pkg_resources/init.py", line 1505, in run_script
exec(script_code, namespace, namespace)
File "/lib/python3.6/site-packages/pyani-0.2.1.dev0-py3.6.egg/EGG-INFO/scripts/average_nucleotide_identity.py", line 781, in
File "/lib/python3.6/site-packages/pyani-0.2.1.dev0-py3.6.egg/EGG-INFO/scripts/average_nucleotide_identity.py", line 596, in write
UnboundLocalError: local variable 'filestem' referenced before assignment

pyani Version:

0.2.1.dev

Python Version:

3.6.0

Operating System:

CentOS 6.8

ValueError: The condensed distance matrix must contain only finite values.

Summary:

Dendrogram step failed with an exception, perhaps due to an infinity from a divide by zero?

Description:

Stack trace below.

Reproducible Steps:

I'm not yet sure if this is reproducible, recently I have been re-running average_nucleotide_identity.py on the same input folder (after first unzipping the nucmer tar-ball), while tweaking the input to add a species of interest.

Current Output:

The current output. Knowing what is the current behavior is useful.

$ average_nucleotide_identity.py -i interesting_serratia -o interesting_serratia_cmp -l interesting_serratia_cmp.log -g --labels interesting_serratia/labels.txt --classes interesting_serratia/classes.txt --scheduler SGE --jobprefix "Serratia" --noclobber --force --skip_nucmer
WARNING: NOCLOBBER: not actually deleting directory
WARNING: Skipping NUCmer run (as instructed)!
WARNING: Total alignment length reported in interesting_serratia_cmp/nucmer_output/GCF_000988045.1_GFC_24_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!
...
WARNING: Total alignment length reported in interesting_serratia_cmp/nucmer_output/GCF_001514455.1_ASM151445v1_genomic_vs_GCA_900016775.1_STsPazieg1.0_genomic.delta is zero!/mnt/shared/users/pc40583/lib/python3.5/site-packages/scipy/cluster/hierarchy.py:667: RuntimeWarning: invalid value encountered in greater_equal
  if np.all(y >= 0) and np.allclose(y, y.T):
Traceback (most recent call last):
  File "/home/pc40583/bin/average_nucleotide_identity.py", line 4, in <module>
    __import__('pkg_resources').run_script('pyani==0.2.3.dev0', 'average_nucleotide_identity.py')
  File "/home/pc40583/lib/python3.5/site-packages/pkg_resources/__init__.py", line 738, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/home/pc40583/lib/python3.5/site-packages/pkg_resources/__init__.py", line 1506, in run_script
    exec(script_code, namespace, namespace)
  File "/mnt/shared/users/pc40583/lib/python3.5/site-packages/pyani-0.2.3.dev0-py3.5.egg/EGG-INFO/scripts/average_nucleotide_identity.py", line 811, in <module>
  File "/mnt/shared/users/pc40583/lib/python3.5/site-packages/pyani-0.2.3.dev0-py3.5.egg/EGG-INFO/scripts/average_nucleotide_identity.py", line 640, in draw
  File "/mnt/shared/users/pc40583/lib/python3.5/site-packages/pyani-0.2.3.dev0-py3.5.egg/pyani/pyani_graphics.py", line 322, in heatmap_mpl
  File "/mnt/shared/users/pc40583/lib/python3.5/site-packages/pyani-0.2.3.dev0-py3.5.egg/pyani/pyani_graphics.py", line 200, in add_mpl_dendrogram
  File "/mnt/shared/users/pc40583/lib/python3.5/site-packages/scipy/cluster/hierarchy.py", line 676, in linkage
    raise ValueError("The condensed distance matrix must contain only finite values.")
ValueError: The condensed distance matrix must contain only finite values.

Expected Output:

I would expect the failure to be caught and a nicer error message to be shown.

Once we understand where the non-finite value comes from, perhaps NaN might work instead...

pyani Version:

$ python3 -c "import pyani; print(pyani.__version__)"
0.2.3.dev

Specifically running from my recently rebased resume branch, see #76

Also relevant,

$ python3 -c "import scipy; print(scipy.__version__)"
0.19.0

Python Version:

$ python3 --version
Python 3.6.0

Operating System:

Linux, 64-bit.

ValueError: math domain error

Finally I'm back with my issue which wasn't really solved. It appears that it depends of my input dataset. Have you an idea of the cause of the error?

average_nucleotide_identity.py -i /home/mgonnet/Data_GB_try/ -o /home/mgonnet/Data_GB_try/ANI/ -m ANIm -g --gformat png
/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py:2791: UserWarning: Attempting to set identical bottom==top results
in singular transformations; automatically expanding.
bottom=0, top=0.0
  'bottom=%s, top=%s') % (bottom, top))
/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py:2544: UserWarning: Attempting to set identical left==right results
in singular transformations; automatically expanding.
left=0.0, right=0
  'left=%s, right=%s') % (left, right))
Traceback (most recent call last):
  File "/usr/local/bin/average_nucleotide_identity.py", line 4, in <module>
    __import__('pkg_resources').run_script('pyani==0.1.2-', 'average_nucleotide_identity.py')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 534, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1445, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/pyani-0.1.2_-py2.7.egg/EGG-INFO/scripts/average_nucleotide_identity.py", line 666, in <module>

  File "/usr/local/lib/python2.7/dist-packages/pyani-0.1.2_-py2.7.egg/EGG-INFO/scripts/average_nucleotide_identity.py", line 561, in draw

  File "build/bdist.linux-x86_64/egg/pyani/pyani_graphics.py", line 209, in heatmap_mpl
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1500, in colorbar
    cb = cbar.colorbar_factory(cax, mappable, **kw)
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 1316, in colorbar_factory
    cb = Colorbar(cax, mappable, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 892, in __init__
    ColorbarBase.__init__(self, ax, **kw)
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 321, in __init__
    self.draw_all()
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 346, in draw_all
    self._config_axes(X, Y)
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 440, in _config_axes
    self.update_ticks()
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 371, in update_ticks
    ticks, ticklabels, offset_string = self._ticker()
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 591, in _ticker
    formatter.set_locs(b)
  File "/usr/lib/python2.7/dist-packages/matplotlib/ticker.py", line 523, in set_locs
    self._set_format(vmin, vmax)
  File "/usr/lib/python2.7/dist-packages/matplotlib/ticker.py", line 584, in _set_format
    loc_range_oom = int(math.floor(math.log10(loc_range)))
ValueError: math domain error

Check assembly_status.txt for failed downloads?

Summary:

Sometimes FTP downloads attempted by genbank_get_genomes_by_taxon.py fail for a reason, e.g.

ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/336/365/GCF_000336365.1_ASM33636v1/GCF_000336365.1_ASM33636v1_genomic.fna.gz

ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/186/485/GCA_000186485.1_ASM18648v1/GCA_000186485.1_ASM18648v1_genomic.fna.gz

Here there are assembly_status.txt files on the FTP site which explain why, both contain one line of plain text:

status=replaced

ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/176/835/GCA_000176835.1_ASM17683v1/assembly_status.txt

ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/000/186/485/GCA_000186485.1_ASM18648v1/assembly_status.txt

Expected Output:

When an FTP download fails, it is worth examining the assembly_status.txt file automatically?

pyani Version:

0.2.3.dev

Python Version:

3.5

Operating System:

Linux

Downloading md5checksums.txt from NCBI FTP site?

Summary:

The NCBI FTP site the genbank_get_genomes_by_taxon.py script downloads sequences from (in FASTA or GenBank format) provides MD5 checksums, which we could fetch, record, and verify.

(This may also be useful with long terms goals on the roadmap https://github.com/widdowquinn/pyani/wiki/roadmap for pyani, although the NCBI gives hashes of the gzipped files which may not be as helpful)

Description:

e.g. ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/001/564/475/GCA_001564475.1_12082_3_81/ provides multiple files including the FASTA genome, ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/001/564/475/GCA_001564475.1_12082_3_81/GCA_001564475.1_12082_3_81_genomic.fna.gz

In particular it offers ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/001/564/475/GCA_001564475.1_12082_3_81/md5checksums.txt which contains:

2a2c33ee1ce27114e28ae1d34f07e1ab  ./GCA_001564475.1_12082_3_81_assembly_report.txt
154272f854dece3959b9321a21ec107b  ./GCA_001564475.1_12082_3_81_assembly_stats.txt
6fe8468575a1884c63565a96128fd7d6  ./GCA_001564475.1_12082_3_81_assembly_structure/Primary_Assembly/component_localID2acc
20e600cc92c0ff47a7ef3babd5b337c3  ./GCA_001564475.1_12082_3_81_assembly_structure/Primary_Assembly/scaffold_localID2acc
f1796bfc28ace76fa5ee3acc22a7d082  ./GCA_001564475.1_12082_3_81_assembly_structure/Primary_Assembly/unplaced_scaffolds/AGP/unplaced.scaf.agp.gz
69768f693e3faeff9d1db36be46bf04e  ./GCA_001564475.1_12082_3_81_assembly_structure/Primary_Assembly/unplaced_scaffolds/FASTA/unplaced.scaf.fna.gz
76a9e6c5153d64fb1240a878d0324c6f  ./GCA_001564475.1_12082_3_81_cds_from_genomic.fna.gz
cd7202a6459f3786fb391a7346d002d7  ./GCA_001564475.1_12082_3_81_feature_table.txt.gz
69768f693e3faeff9d1db36be46bf04e  ./GCA_001564475.1_12082_3_81_genomic.fna.gz
1a9d9720c54cf391cabc9b7690d60be2  ./GCA_001564475.1_12082_3_81_genomic.gbff.gz
22390a0d63a06f516bbf813b78a61dab  ./GCA_001564475.1_12082_3_81_genomic.gff.gz
303e1e045d97b149f569859f04375f7d  ./GCA_001564475.1_12082_3_81_protein.faa.gz
c1961cb0f31a03efc369bb46486cfe2f  ./GCA_001564475.1_12082_3_81_protein.gpff.gz
da00d9bcfd6fe6fdcb419727695eee65  ./GCA_001564475.1_12082_3_81_rna_from_genomic.fna.gz
95b8e7e2668bcee46919eb43127e996e  ./GCA_001564475.1_12082_3_81_wgsmaster.gbff.gz
900e1650239d0b71b2c671c98518907f  ./annotation_hashes.txt

Sadly the static filename md5checksums.txt would clash, so it would have to be renamed, perhaps to GCA_001564475.1_12082_3_81.mf5 - or we could extract the checksums for the files of interest (those the script downloads) and create for example GCA_001564475.1_12082_3_81_genomic.fna.gz.md5 containing:

69768f693e3faeff9d1db36be46bf04e  ./GCA_001564475.1_12082_3_81_genomic.fna.gz

or:

69768f693e3faeff9d1db36be46bf04e  GCA_001564475.1_12082_3_81_genomic.fna.gz

This would match the naming convention used elsewhere on the NCBI FTP site and more widely of filename.ext.md5 containing the checksum for filename.ext, using the md5sum command line tool's format.

The download script could then verify the download file has the expected checksum:

$ md5sum -c GCA_001564475.1_12082_3_81_genomic.fna.gz.md5 
GCA_001564475.1_12082_3_81_genomic.fna.gz: OK

ClusterWarning ... looks suspiciously like an uncondensed distance matrix

Summary:

Sometimes I see this warning from SciPy:

ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix

I am using:

$ python3 -c "import scipy; print(scipy.__version__)"
0.19.0

This warning was added to SciPy in this commit: scipy/scipy@24f27b6

Reproducible Steps:

$ git clone [email protected]:widdowquinn/pyani.git
$ cd pyani
$ python3 setup.py install
$ bin/average_nucleotide_identity.py -i tests/test_failing_data/ -o ./test_out -m ANIm -g --gformat png

Current Output:

$ bin/average_nucleotide_identity.py -i tests/test_failing_data/ -o ./test_out -m ANIm -g --gformat png
WARNING: Total alignment length reported in ./test_out/nucmer_output/NC_010473_vs_NC_015216.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in ./test_out/nucmer_output/NC_013353_vs_NC_023044.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in ./test_out/nucmer_output/NC_010473_vs_NC_023044.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in ./test_out/nucmer_output/NC_000918_vs_NC_023044.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in ./test_out/nucmer_output/NC_013353_vs_NC_000918.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in ./test_out/nucmer_output/NC_015216_vs_NC_000918.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in ./test_out/nucmer_output/NC_010473_vs_NC_000918.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
WARNING: Total alignment length reported in ./test_out/nucmer_output/NC_013353_vs_NC_015216.delta is zero!
ERROR: One or more NUCmer output files has a problem.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. If so, please consider using the --maxmatch option.
ERROR: Alternatively, this may be due to NUCmer run failure: analysis may continue, but please investigate.
ERROR: This is possibly due to a NUCmer comparison being too distant for use. Please consider using the --maxmatch option.
ERROR: This is alternatively due to NUCmer run failure, analysis will continue, but please investigate.
/home/pc40583/lib/python3.5/site-packages/pyani/pyani_graphics.py:200: ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix
  dend = sch.dendrogram(sch.linkage(dists, method='complete'),
/home/pc40583/lib/python3.5/site-packages/pyani/pyani_graphics.py:200: ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix
  dend = sch.dendrogram(sch.linkage(dists, method='complete'),
/home/pc40583/lib/python3.5/site-packages/pyani/pyani_graphics.py:200: ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix
  dend = sch.dendrogram(sch.linkage(dists, method='complete'),
/home/pc40583/lib/python3.5/site-packages/pyani/pyani_graphics.py:200: ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix
  dend = sch.dendrogram(sch.linkage(dists, method='complete'),
/home/pc40583/lib/python3.5/site-packages/pyani/pyani_graphics.py:200: ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix
  dend = sch.dendrogram(sch.linkage(dists, method='complete'),
/home/pc40583/lib/python3.5/site-packages/pyani/pyani_graphics.py:200: ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix
  dend = sch.dendrogram(sch.linkage(dists, method='complete'),

Expected Output:

Silence the scipy warning?

pyani Version:

0.2.3.dev

Python Version:

3.5

Operating System:

Linux

math domain error

I manage to perform previous analysis with your amazing script. unfortunatly I've a problem with a new attempt

python average_nucleotide_identity.py -i /home/mgonnet/Documents/84_3/ -o /home/mgonnet/Documents/84_3/out/ -m ANIm -g --gformat pdf -v

raising a ValueError: math domain error when trying to call matplotlib/ticker.py

INFO: Writing heatmap to /home/mgonnet/Documents/84_3/out/ANIm_similarity_errors.pdf
Traceback (most recent call last):
  File "average_nucleotide_identity.py", line 666, in <module>
    draw(results, methods[args.method][1])
  File "average_nucleotide_identity.py", line 561, in draw
    classes=get_labels(args.classes))
  File "/home/mgonnet/Soft/pyani/pyani/pyani_graphics.py", line 209, in heatmap_mpl
    cb = fig.colorbar(ax_map, scale_ax, ticks=cbticks)
  File "/usr/lib/python2.7/dist-packages/matplotlib/figure.py", line 1500, in colorbar
    cb = cbar.colorbar_factory(cax, mappable, **kw)
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 1316, in colorbar_factory
    cb = Colorbar(cax, mappable, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 892, in __init__
    ColorbarBase.__init__(self, ax, **kw)
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 321, in __init__
    self.draw_all()
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 346, in draw_all
    self._config_axes(X, Y)
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 440, in _config_axes
    self.update_ticks()
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 371, in update_ticks
    ticks, ticklabels, offset_string = self._ticker()
  File "/usr/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 591, in _ticker
    formatter.set_locs(b)
  File "/usr/lib/python2.7/dist-packages/matplotlib/ticker.py", line 523, in set_locs
    self._set_format(vmin, vmax)
  File "/usr/lib/python2.7/dist-packages/matplotlib/ticker.py", line 584, in _set_format
    loc_range_oom = int(math.floor(math.log10(loc_range)))
ValueError: math domain error

Any idea?

Maxmatch flag not being applied when using ANIm

Summary:

Please provide a short summary (a couple of sentences).
When using the --maxmatch flag with ANIm, the nucmer commands use -mum instead of -maxmatch. This results in some incorrect results, such as two organisms in different genuses returning .95+ ANI based on the alignment of a single, short fragment.

Description:

Describe the issue as clearly as possible.
The maxmatch flag seems to always be defaulted to False even if specified for use.

Reproducible Steps:

Please report steps to reproduce the issue. If it's not possible to reproduce, please include a description of how you discovered the issue.

Noticed several results that did not make sense, as mentioned above.

Expected Output:

Describe what you expect the output to be. Knowing the correct behavior is also very useful.
I manually ran nucmer with maxmatch and received a result of ~.81, which makes more sense. I also ran nucmer without maxmatch and received the .95 result based on the single short fragment alignment that corresponded to the result from pyani.

pyani Version:

0.2.1

Python Version:

3.6

Operating System:

CentOS 6.8

Multiple array jobs submitted to SGE out of order

I presume each array job is limited to 10000 child-jobs due to an SGE limitation, and therefore when there are more pairwise comparisons pyani creates multiple array jobs, here seven:

Using v0.2, e.g.

$ ~/repositories/pyani/average_nucleotide_identity.py -i fetch_taxa/ -o big_test --scheduler SGE
Your job-array 13782.1-10000:1 ("ANI_5") has been submitted
Your job-array 13783.1-10000:1 ("ANI_1") has been submitted
Your job-array 13784.1-10000:1 ("ANI_6") has been submitted
Your job-array 13785.1-10000:1 ("ANI_2") has been submitted
Your job-array 13786.1-2481:1 ("ANI_7") has been submitted
Your job-array 13787.1-10000:1 ("ANI_3") has been submitted
Your job-array 13788.1-10000:1 ("ANI_4") has been submitted
...

Expected output would be to submit the jobs in order,

$ ~/repositories/pyani/average_nucleotide_identity.py -i fetch_taxa/ -o big_test --scheduler SGE
Your job-array 13782.1-10000:1 ("ANI_1") has been submitted
Your job-array 13783.1-10000:1 ("ANI_2") has been submitted
Your job-array 13784.1-10000:1 ("ANI_3") has been submitted
Your job-array 13785.1-10000:1 ("ANI_4") has been submitted
Your job-array 13786.1-10000:1 ("ANI_5") has been submitted
Your job-array 13787.1-10000:1 ("ANI_6") has been submitted
Your job-array 13788.1-2481:1 ("ANI_7") has been submitted
...

Empty BLAST output results in error message

I have a couple of hundred genomes I would like to calculate the ANI for using blastn.
Some pairs of genomes do not produce any alignments and therefore empty BLAST files.
This results in an error message during the parsing step and the pipeline just breaks.

Could you check for this case and fill the table with reasonable values (mainly zeros) so that
the tables and graphics still get generated?

Thanks,
Alex

Providing short description for the plots

Hello!

I was wondering if you can provide some short description for each graph output.
Like:

  • What the plot is showing
  • How the values are computed
  • How can we read the plot

Because, for some of them (e.g. Hadamard, similarity error, ..) I can't explain what's on the plot.
Thanks

Hello,

Summary:

Please provide a short summary (a couple of sentences).

Description:

Describe the issue as clearly as possible.

Reproducible Steps:

Please report steps to reproduce the issue. If it's not possible to reproduce, please include a description of how you discovered the issue.

If you have a reproducible example, please include it.

Current Output:

The current output. Knowing what is the current behavior is useful.

Expected Output:

Describe what you expect the output to be. Knowing the correct behavior is also very useful.

pyani Version:

Python Version:

Operating System:

Which arguments is expected by --maxmatch?

Summary:

I want to use --maxmtach option for ANIm

Description:

I tried
--maxmtach TRUE
--maxmtach True
--maxmtach 1
--maxmtach 500
--maxmtach 0

(/home/sebastien/anaconda3/bin/average_nucleotide_identity.py -i ALL_ruben/ -o ALL_ruben_ANI_anim -g --gmethod seaborn --gformat pdf,png -v -l ALL_ruben_anim_log -m ANIm --maxmatch True)

Current Output:

average_nucleotide_identity.py: error: unrecognized arguments: True

Labels and Class flags

Hello,

I had a question on the maps generated from pyani. Is it possible to specify user-defined labes? If it is, what format would be required in order to do so?

-Ksoca

pyani Version: pyani-0.2.1
Python Version: 3.5.0b4
Operating System: Centos 6 Linux

module object has no attribute run

Hi there,

I've recently installed pyani and tried to run it using 8 cores with the following command:

average_nucleotide_identity.py -i $pin -o $pout -m ANIb --workers 8

This leads to the following error output:

Traceback (most recent call last): File "/usr/local/bin/average_nucleotide_identity.py", line 806, in <module> results = methods[args.method][0](infiles, org_lengths) File "/usr/local/bin/average_nucleotide_identity.py", line 532, in unified_anib logger=logger) File "/usr/local/lib/python3.4/dist-packages/pyani/run_multiprocessing.py", line 45, in run_dependency_graph cumretval += multiprocessing_run(cmdset, workers, verbose) File "/usr/local/lib/python3.4/dist-packages/pyani/run_multiprocessing.py", line 86, in multiprocessing_run for cline in cmdlines] File "/usr/local/lib/python3.4/dist-packages/pyani/run_multiprocessing.py", line 86, in <listcomp> for cline in cmdlines] AttributeError: 'module' object has no attribute 'run'

I've checked and module seems to be installed correctly in my ptyhon3.4. Am I doing something wrong, or do you have any advice to overcome this?

Thanks in advance,
Sander

Set number of threads

First off, the pyani package looks great. I was wondering if it was possible to limit the number of threads used in the multiprocessing mode to a set number? I'm trying to run the script on a non-SGE server and I'm concerned that the script as is, will try and use all available threads on the node... which is not so good.

Thanks!

Request adding --version switch to the command line tools

Summary:

It does not seem to be possible to determine the version of the pyani command line scripts from running the scripts themselves.

Description:

The convention --version is not supported (-v is taken for verbose mode), and the help text does include the version either.

Reproducible Steps:

$ average_nucleotide_identity.py --version
usage: average_nucleotide_identity.py [-h] [-o OUTDIRNAME] [-i INDIRNAME] [-v]
                                      [-f] [-s FRAGSIZE] [-l LOGFILE]
                                      [--skip_nucmer] [--skip_blastn]
                                      [--noclobber] [--nocompress] [-g]
                                      [--gformat GFORMAT] [--gmethod GMETHOD]
                                      [--labels LABELS] [--classes CLASSES]
                                      [-m METHOD] [--scheduler SCHEDULER]
                                      [--workers WORKERS]
                                      [--SGEgroupsize SGEGROUPSIZE]
                                      [--maxmatch] [--nucmer_exe NUCMER_EXE]
                                      [--blastn_exe BLASTN_EXE]
                                      [--makeblastdb_exe MAKEBLASTDB_EXE]
                                      [--blastall_exe BLASTALL_EXE]
                                      [--formatdb_exe FORMATDB_EXE]
                                      [--write_excel] [--rerender]
                                      [--subsample SUBSAMPLE] [--seed SEED]
                                      [--jobprefix JOBPREFIX]
average_nucleotide_identity.py: error: unrecognized arguments: --version

Current Output:

See above.

Expected Output:

I propose something like this, and would be willing to implement it:

$ average_nucleotide_identity.py --version
pyani 0.2.3

Or if you prefer, a longer string giving the script version number as well as the pyani version number?

pyani Version:

$ python3 -c "import pyani; print(pyani.__version__)"
0.2.3

Python Version:

Should not be relevant, but:

$ python3 --version
Python 3.5.0

Operating System:

Should not be relevant, but 64-bit Linux CentOS.

Order of genomes

Summary:

Please provide a short summary (a couple of sentences).

Description:

Describe the issue as clearly as possible.

Reproducible Steps:

Please report steps to reproduce the issue. If it's not possible to reproduce, please include a description of how you discovered the issue.

If you have a reproducible example, please include it.

Current Output:

The current output. Knowing what is the current behavior is useful.

Expected Output:

Describe what you expect the output to be. Knowing the correct behavior is also very useful.

pyani Version:

Python Version:

Operating System:

Rerunning analyses

I used pyani to compare 23 genomes that are all around 5 Mb in size. Running on two of my laptop's processors, pyani took ~6 minutes to run the tetra analysis, ~1 hour to run the ANIg, and ~4 hours each to run the ANIb and ANIblastall analyses. Not long after that another genome became available. I was hoping that I could use pyani to compare the 24th genome to the other 23 without having to rerun all the previous comparisons. It looks to me like that's what the -f and --noclobber arguments are supposed to accomplish. But when I ran

./average_nucleotide_identity.py -i tests/my_genomes/ -o tests/my_genomes_ANIm_output -m ANIm -g -v -f --noclobber

pyani still re-calculated every possible pairwise ANI (which took a little over an hour).

It would be a real time-saver (especially for larger data sets) if pyani can check whether any pairwise comparisons have already been done and then skip them.

ANI always 1.0

Hello,

I've been trying to run ANI on divergent sequences and the result alway give 1.0 identity for all pair of genomes...
These are simulated sequences but clearly giving the alignment here it sounds that something is going wrong.

The only warning I'm getting is :
WARNING: At least one NUCmer comparison failed. ANIm may fail.
However I don't know how to troubleshoot this.

Thanks for helping me.

zz

Hi! If input fasta files more than 6, then an error.

average_nucleotide_identity.py -i ANI -o ANI_OUT -m ANIblastall -g

Traceback (most recent call last):
File "/usr/local/bin/average_nucleotide_identity.py", line 772, in
results = methods[args.method][0](infiles, org_lengths)
File "/usr/local/bin/average_nucleotide_identity.py", line 550, in unified_anib
fraglengths=fraglengths, mode=args.method)
File "/usr/local/lib/python3.4/dist-packages/pyani/anib.py", line 372, in process_blast
mode)
File "/usr/local/lib/python3.4/dist-packages/pyani/anib.py", line 417, in parse_blast_tab
data = pd.DataFrame.from_csv(filename, header=None, sep='\t')
File "/usr/local/lib/python3.4/dist-packages/pandas/core/frame.py", line 1189, in from_csv
infer_datetime_format=infer_datetime_format)
File "/usr/local/lib/python3.4/dist-packages/pandas/io/parsers.py", line 562, in parser_f
return _read(filepath_or_buffer, kwds)
File "/usr/local/lib/python3.4/dist-packages/pandas/io/parsers.py", line 315, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/usr/local/lib/python3.4/dist-packages/pandas/io/parsers.py", line 645, in init
self._make_engine(self.engine)
File "/usr/local/lib/python3.4/dist-packages/pandas/io/parsers.py", line 799, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "/usr/local/lib/python3.4/dist-packages/pandas/io/parsers.py", line 1213, in init
self._reader = _parser.TextReader(src, **kwds)
File "pandas/parser.pyx", line 523, in pandas.parser.TextReader.cinit (pandas/parser.c:5214)
pandas.io.common.EmptyDataError: No columns to parse from file

ANIb with custom fragment size

I really like using your script for ANI calculations, however whenever I try to set the fragment size for ANIb with the '-s' option the script fails to run.

joseph@JADESKTOP:~/comparative_genomics/NDB3Y10/ANI_analysis$ average_nucleotide_identity.py -i ../all_genomes/ -o ANIb_100 -s 100 -m ANIb
usage: average_nucleotide_identity.py [-h] [-o OUTDIRNAME] [-i INDIRNAME] [-v]
                                      [-f] [-s] [-l LOGFILE] [--skip_nucmer]
                                      [--skip_blastn] [--noclobber] [-g]
                                      [--gformat GFORMAT] [--gmethod GMETHOD]
                                      [--labels LABELS] [--classes CLASSES]
                                      [-m METHOD] [--scheduler SCHEDULER]
                                      [--maxmatch] [--nucmer_exe NUCMER_EXE]
                                      [--blastn_exe BLASTN_EXE]
                                      [--makeblastdb_exe MAKEBLASTDB_EXE]
                                      [--blastall_exe BLASTALL_EXE]
                                      [--formatdb_exe FORMATDB_EXE]
                                      [--write_excel]
average_nucleotide_identity.py: error: unrecognized arguments: 100

I've had a similar result with your 'calculate_ani.py' script. Am I doing something wrong?

I'm using Python 2.7.6

Minimum version of pandas required?

I am exploring automating the pyani tests with TravisCI.

Ideally I would run this within their Python VM, but currently I am trying the TravisCI R support on the assumption this is the easiest way to get R and thus rpy2 installed. This https://travis-ci.org/peterjc/pyani/builds/82568268 build was using the system python, and:

$ sudo apt-get install python-pandas

This installed pandas 0.7.0 which turns out to be too old:

$ make test
./average_nucleotide_identity.py -i tests/test_ani_data -o tests/test_ANIm_output \
      -m ANIm --classes tests/test_ani_data/classes.tab --labels tests/test_ani_data/labels.tab -g -v
INFO: Namespace(blastall_exe='blastall', blastn_exe='blastn', classes='tests/test_ani_data/classes.tab', force=False, formatdb_exe='formatdb', fragsize=1020, gformat='pdf', gmethod='mpl', graphics=True, indirname='tests/test_ani_data', labels='tests/test_ani_data/labels.tab', logfile=None, makeblastdb_exe='makeblastdb', maxmatch=False, method='ANIm', noclobber=False, nucmer_exe='nucmer', outdirname='tests/test_ANIm_output', scheduler='multiprocessing', skip_blastn=False, skip_nucmer=False, verbose=True, write_excel=False)
INFO: Input directory: tests/test_ani_data
INFO: Creating directory tests/test_ANIm_output
INFO: Output directory: tests/test_ANIm_output
INFO: Using ANI method: ANIm
INFO: Using scheduler method: multiprocessing
INFO: Identifying FASTA files in tests/test_ani_data
INFO: Input files:
    tests/test_ani_data/NC_011916.fna
    tests/test_ani_data/NC_010338.fna
    tests/test_ani_data/NC_014100.fna
    tests/test_ani_data/NC_002696.fna
INFO: Processing input sequence lengths
INFO: Sequence lengths:
    NC_002696: 4016947
    NC_014100: 4655622
    NC_010338: 5477872
    NC_011916: 4042929
INFO: Carrying out ANIm analysis
INFO: Running ANIm
INFO: Generating NUCmer command-lines
INFO: Running jobs with multiprocessing
INFO: Command pool now running:
INFO: nucmer -mum -p tests/test_ANIm_output/NC_010338_vs_NC_002696 tests/test_ani_data/NC_010338.fna tests/test_ani_data/NC_002696.fna
INFO: nucmer -mum -p tests/test_ANIm_output/NC_011916_vs_NC_010338 tests/test_ani_data/NC_011916.fna tests/test_ani_data/NC_010338.fna
INFO: nucmer -mum -p tests/test_ANIm_output/NC_011916_vs_NC_014100 tests/test_ani_data/NC_011916.fna tests/test_ani_data/NC_014100.fna
INFO: nucmer -mum -p tests/test_ANIm_output/NC_010338_vs_NC_014100 tests/test_ani_data/NC_010338.fna tests/test_ani_data/NC_014100.fna
INFO: nucmer -mum -p tests/test_ANIm_output/NC_014100_vs_NC_002696 tests/test_ani_data/NC_014100.fna tests/test_ani_data/NC_002696.fna
INFO: nucmer -mum -p tests/test_ANIm_output/NC_011916_vs_NC_002696 tests/test_ani_data/NC_011916.fna tests/test_ani_data/NC_002696.fna
INFO: Command pool done.
INFO: Cumulative return value: 0
INFO: All multiprocessing jobs complete.
INFO: Processing NUCmer .delta files.
Traceback (most recent call last):
  File "./average_nucleotide_identity.py", line 658, in <module>
    results = methods[args.method][0](infiles, org_lengths)
  File "./average_nucleotide_identity.py", line 349, in calculate_anim
    data = anim.process_deltadir(args.outdirname, org_lengths, logger=logger)
  File "/home/travis/build/peterjc/pyani/pyani/anim.py", line 185, in process_deltadir
    alignment_lengths.loc[qname, sname] = tot_length
  File "/usr/lib/pymodules/python2.7/pandas/core/frame.py", line 1437, in __getattr__
    (type(self).__name__, name))
AttributeError: 'DataFrame' object has no attribute 'loc'
make: *** [ANIm] Error 1

The .loc attribute was added in pandas 0.11 http://pandas.pydata.org/pandas-docs/stable/whatsnew.html

Should the main README.md say it requires at least pandas 0.11?

ImportError: No module named 'openpyxl'

Summary:

Attempted to run the test data with the command:
average_nucleotide_identity.py -i test_ani_data/ -o my_test_ANIb -g --gformat png -m ANIb -l ANIb_log --write_excel

Currently running python 3.5.0b4 (installed with pyenv) on Fedora 23

Description:

$ average_nucleotide_identity.py -i test_ani_data/ -o my_test_ANIb -g --gformat png -m ANIb -l ANIb_log --write_excel
Traceback (most recent call last):
  File "/home/jearl/.pyenv/versions/3.5.0b4/bin/average_nucleotide_identity.py", line 807, in <module>
    write(results, methods[args.method][1])
  File "/home/jearl/.pyenv/versions/3.5.0b4/bin/average_nucleotide_identity.py", line 617, in write
    index=True)
  File "/home/jearl/.pyenv/versions/3.5.0b4/lib/python3.5/site-packages/pandas/core/frame.py", line 1453, in to_excel
    excel_writer = ExcelWriter(excel_writer, engine=engine)
  File "/home/jearl/.pyenv/versions/3.5.0b4/lib/python3.5/site-packages/pandas/io/excel.py", line 771, in __init__
    if not openpyxl_compat.is_compat(major_ver=self.openpyxl_majorver):
  File "/home/jearl/.pyenv/versions/3.5.0b4/lib/python3.5/site-packages/pandas/compat/openpyxl_compat.py", line 27, in is_compat
    import openpyxl
ImportError: No module named 'openpyxl'

Reproducible Steps:

only seems to happen if I use the '--write_excel' option, otherwise program seems to run fine on the test data

pyani Version: pyani-0.2.1-py3

Python Version: 3.5.0b4

Operating System: Fedora 23

Error in TETRA calculation

Thank you for a wonderful tool. I've used your scripts in some of my recent works.
I got An error while conducting the TETRA calculation as below.

Reproducible Steps and Current Output:

$ python average_nucleotide_identity.py -m TETRA -i INPUTDIR -o OUTPUTDIR
Traceback (most recent call last):
  File "average_nucleotide_identity.py", line 770, in <module>
    write(results)
  File "average_nucleotide_identity.py", line 586, in write
    for dfr, filestem in results.data:
AttributeError: 'tuple' object has no attribute 'data'

(It works if I use the "-m ANIb" option.)

Proposal for amendment:

To avoid the error, I changed line 460 in the "calculate_tetra" method.

    return (tetra_correlations, )

to

    return tetra_correlations  # returns Pandas DataFrame object, not tuple

Also I needed to change the "write" method as following.
This was because other methods (ANIb or ANIm) return the results in ANIResults objects, while TETRA method does not.

def write(results):

    if args.method == "TETRA":
        if args.write_excel:
            results.to_excel(os.path.join(args.outdirname, "tetra_result") + '.xlsx', index=True)
        results.to_csv(os.path.join(args.outdirname, "tetra_result") + '.tab',
                   index=True, sep="\t")
    else:

        logger.info("Writing %s results to %s", args.method, args.outdirname)
        for dfr, filestem in results.data:
            logger.info("\t%s", filestem)
            if args.write_excel:
                dfr.to_excel(os.path.join(args.outdirname, filestem) + '.xlsx',
                             index=True)
            dfr.to_csv(os.path.join(args.outdirname, filestem) + '.tab',
                       index=True, sep="\t")

I am not sure if this is the best way.
Please let me know if you have any other good ideas.

Pandas warnings: SettingWithCopyWarning and FutureWarning

Running locally with Python 2.7.10 and dependencies including pandas 0.16.2 installed under $HOME, the tests appear to work but adjustments, but I see this kind of warning from the tests (also ANIblastall tests etc):

$ make test
...
INFO: Processing pairwise ANIb BLAST output.
/mnt/shared/users/xxx/repositories/pyani/pyani/anib.py:413: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  filtered['index'] = filtered.index
/home/xxx/lib/python2.7/site-packages/pandas/util/decorators.py:81: FutureWarning: the 'cols' keyword is deprecated, use 'subset' instead
  warnings.warn(msg, FutureWarning)
/home/xxx/lib/python2.7/site-packages/pandas/util/decorators.py:88: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  return func(*args, **kwargs)
INFO: Writing ANIb results to tests/test_ANIb_output
...
NFO: Writing heatmap to tests/test_TETRA_output/TETRA_correlations.pdf
INFO: Done.

Defaults for labels and classes matching fetch script output

Summary:

The genbank_get_genomes_by_taxon.py script puts labels.txt and classes.txt in the output folder with the FASTA files.

If the --labels and --classes arguments to average_nucleotide_identity.py are not given they could default to these filesnames in the --indir folder.

Issues when trying to use pyani

Summary:

I'm trying to fetch some data from NCBI but it didn't work. Then, i try to use the example which is in the README. I got the same error.

Description:

I think it's a problem from alternative assemblies

Reproducible Steps:

As i say, i just run the following command from readme file:

genbank_get_genomes_by_taxon.py -o Caulobacter_downloads -v -t 75 -l Caulobacter_downloads.log --email [email protected]

(I used my own email obviously)

Current Output:

See file error.log.txt

Expected Output:

INFO: command-line: /Users/lpritc/Virtualenvs/pyani3/bin/genbank_get_genomes_by_taxon.py -o Caulobacter_downloads -v -t 75 -l Caulobacter_downloads.log --email [email protected]
INFO: Namespace(batchsize=10000, email='[email protected]', force=False, format='gbk,fasta', logfile='Caulobacter_downloads.log', noclobber=False, outdirname='Caulobacter_downloads', retries=20, taxon='75', verbose=True)
INFO: Set NCBI contact email to [email protected]
INFO: Creating directory Caulobacter_downloads
INFO: Output directory: Caulobacter_downloads
INFO: Passed taxon IDs: 75
INFO: Entrez ESearch with query: txid75[Organism:exp]
INFO: Entrez ESearch returns 29 assembly IDs
INFO: Identified 29 unique assemblies
INFO: Taxon 75: 29 assemblies
[…]
INFO: Assembly 639581: 271 contigs
INFO: Assembly 233261: 17 contigs
INFO: Assembly 575291: 48 contigs
INFO: Mon Apr 18 17:25:46 2016
INFO: Done.

pyani Version:

The last one

Python Version:

When i enter python3 in terminal, it's python3.6 (Should i specify python 3.4 in pyani script?)
error.log.txt

Operating System:

Ubuntu 14.04 LTS

"Segmentation fault: 11" when generating a graphic

Hi,
Thanks for creating pyani. When trying to generate graphics of any sort, I get a "Segmentation fault: 11" error. I am using the Continuum Anaconda distribution of python2.7, and I have all of the dependencies installed. The error occurred with your test files, as well as with my own fasta files. The graphic format type did not matter.

$ ./average_nucleotide_identity.py -i tests/test_ani_data/ -o tests/test_ANIm_output -m ANIm -g
Segmentation fault: 11

If you need more system details, let me know. I am new to posting issues.
Best,
-Nicholas

Description of Heatmap Outputs

Summary:

I'm familiar with ANI (and there is a very good description of it in the README), so the *_percentage_identity, *_alignment_length, and *_alignment_coverage make sense to me.

I'm not so sure about the *_hadamard or *_similarity_errors graphs. Is there a good resource to find out more as to how to interpret these? Or the algorithms used to generate them?

pyani Version: pyani-0.2.1

Python Version: 3.5.0b4

Operating System: Fedora 23

Add average amino acid identity (AAI)

An alternative to ANI for more distantly related genomes is average amino acid identity (AAI; see Konstantinidis and Tiedje 2005 and Rodrigues and Konstantinidis 2014). Instead of DNA FASTA files the user would need to supply protein FASTA files.

This web tool only lets you calculate AAI for two genomes at a time.

This web tool lets you calculate AAI for multiple genomes, but only the ones that are stored in its database (i.e. no user-generated genomes). And the database doesn't appear to have been updated since around 2012.

This web tool lets you calculate AAI for up to 10 genomes at a time, but you have to run them through RAST, first, which is inconvenient.

So being able to run AAI on your own machine, like pyani already does for ANI and tetranucleotide regression, would be very useful.

Anaconda Python3.5 requires 'rpy2' v.2.8.0 for pyani to function

It seems that pyani requires a rpy2 version of 2.8.0 (and not 2.7.0) if one is using the Anaconda Python distribution (at least for Mac OS X 'El Capitan', python 3.5), otherwise you get this error:
File "~/anaconda/lib/python3.5/site-packages/rpy2/robjects/vectors.py", line 336, in <module> class StrVector(Vector, StrSexpVector): TypeError: type 'rpy2.rinterface.StrSexpVector' is not an acceptable base type

See here for more information on the bug in rpy2 2.7.0.

Scary message "Following jobs do not exist"

Using v0.2, e.g.

$ ~/repositories/pyani/average_nucleotide_identity.py -i fetch_taxa/ -o big_test --scheduler SGE
Your job-array 13782.1-10000:1 ("ANI_5") has been submitted
Your job-array 13783.1-10000:1 ("ANI_1") has been submitted
Your job-array 13784.1-10000:1 ("ANI_6") has been submitted
Your job-array 13785.1-10000:1 ("ANI_2") has been submitted
Your job-array 13786.1-2481:1 ("ANI_7") has been submitted
Your job-array 13787.1-10000:1 ("ANI_3") has been submitted
Your job-array 13788.1-10000:1 ("ANI_4") has been submitted
Following jobs do not exist: 
ANI_1
Following jobs do not exist: 
ANI_2
Following jobs do not exist: 
ANI_3
Following jobs do not exist: 
ANI_4
Following jobs do not exist: 
ANI_5
Following jobs do not exist: 
ANI_6
Following jobs do not exist: 
ANI_7

The message is triggered during polling the SGE server and an array of jobs has finished - in this case successfully. Rewording to "Following jobs have finished:" might be better?

TravisCI integration

It would be great to have pyani automatically tested via TravisCI. However, the dependencies are a bit of a pain.

First effort: https://github.com/peterjc/pyani/tree/travis

Today's efforts: https://github.com/peterjc/pyani/tree/travis2

Installing numpy and scipy etc is fairly quick if you can use pre-compiled wheels (coming to PyPI soon).

The current version of rpy2 available on PyPI is rpy2 v2.7.8 https://pypi.python.org/pypi/rpy2/2.7.8 and this no longer supports Python 2.6, or R v2.x. Furthermore, the current white-listed r-base r-base-dev apt-get packages from Ubuntu Precise give R 2.14.1 which is too old for the latest rpy. So we can't easily test the R based graphics...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.