py3seq

Python class providing an interface to the 3seq recombination detection program.


Keywords
Python, 3seq, recombination, detection
License
MIT
Install
pip install py3seq==1.1.4

Documentation

py3seq - a Python wrapper for 3seq recombination detection

Runs under Python 2.7, 3.5, 3.6, and 3.7. Change log Build Status

Here's a Python class that can be used to call the 3seq recombination detection algorithm described in An exact nonparametric method for inferring mosaic structure in sequence triplets by Maciej F. Boni, David Posada, and Marcus W. Feldman in Genetics. 2007 Jun; 176(2): 1035–1047. doi: 10.1534/genetics.106.068874.

An improvement to the algorithm was described in Improved Algorithmic Complexity for the 3SEQ Recombination Detection Algorithm by Ha Minh Lam, Oliver Ratmann, and Maciej F. Boni in Molecular Biology and Evolution, Volume 35, Issue 1, 1 January 2018, Pages 247–251, doi 10.1093/molbev/msx263.

3seq pre-requisite

py3seq relies on you first installing the 3seq program (whose output py3seq reads).

The source code for 3seq can be obtained from http://mol.ax/software/3seq. The manual is here.

You will need to compile the software and then move the resulting 3seq exectuable into a directory that's in your shell's PATH variable.

Note that although the py3seq code uses the MIT license, because you will need to run 3seq to produce input for py3seq, you are still bound by the license on the underlying 3seq C++ code. The 3seq source code has the following notice near the top of source/AppInfo.cpp: "Licensed for non-commercial use only".

p-value lookup table

You will also need a p-value lookup table for 3seq to use. You can either generate one yourself (see steps 3a, 3b, and 4 in the manual). Or else download and uncompress PVT.3SEQ.2017.700 from http://mol.ax/3seq.

Installing py3seq

$ pip install py3seq

Using py3seq

from __future__ import print_function

from py3seq import RecombinationAnalysis, readRecombinants

# The p-value lookup table file PVT.3SEQ.2017.700 is available as described above.
analysis = RecombinationAnalysis('PVT.3SEQ.2017.700')

# Run the recombination on a FASTA file (Phylip is also supported, or you
# can pass a Reads instance from the dark-matter package).
analysis.run('filename.fasta')

# The 3seq output files can now be accessed in analysis.tmpDir in case you
# need them. See section 8 of the 3seq manual for their names.

# Process all predicted recombinants.
for recombinant in readRecombinants(analysis.recombinantFile()):
    print('%s is predicted to be a recombinant of %s and %s' %
          (recombinant.recombinantId, recombinant.pId, recombinant.qId))
    # See py3seq for all attributes of the Recombinant class.

# Remove 3seq output files.
analysis.removeOutput()

# See what shell commands were run in performing the analysis and how long they
# took, etc.
print('\n'.join(analysis.executor.log))

Development

$ git clone https://github/acorg/py3seq
$ cd py3seq
$ pip install -e '.[dev]'   # To install development dependencies.
$ make check