Commit 045c51f7 authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 0.4.0

parent e821a2b6
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
language: python
sudo: true
python:
  - "3.6"
  - "3.5"
  - "2.7"
# command to install dependencies
virtualenv:
  system_site_packages: true
before_install:
  - sudo apt-get install python-numpy python-scipy
install:
  - pip install biopython
  - python setup.py build
  - sudo apt-get update
  - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
  - bash miniconda.sh -b -p $HOME/miniconda
  - export PATH="$HOME/miniconda/bin:$PATH"
  - hash -r
  - conda config --set always_yes yes --set changeps1 no
  - conda update -q conda
  # Useful for debugging any issues with conda
  - conda info -a

  - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy biopython nose
  - source activate test-environment
  - python setup.py install
# command to run tests
script:
  - bash .travis_test.sh
+7 −1
Original line number Diff line number Diff line
nosetests test/test_treetime.py
cd test
bash command_line_tests.sh
OUT=$?
if [ "$OUT" != 0 ]; then
	exit 1
fi
nosetests test_treetime.py
+13 −14
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@

TreeTime provides routines for ancestral sequence reconstruction and the inference of molecular-clock phylogenies, i.e., a tree where all branches are scaled such that the locations of terminal nodes correspond to their sampling times and internal nodes are placed at the most likely time of divergence.

TreeTime is implemented in Python 2.7 -- an experimental port to [Python 3 is available in a separate branch](https://github.com/neherlab/treetime/tree/py3).
TreeTime aims at striking a compromise between sophisticated probabilistic models of evolution and fast heuristics. It implements GTR models of ancestral inference and branch length optimization, but takes the tree topology as given.
To optimize the likelihood of time-scaled phylogenies, TreeTime uses an iterative approach that first infers ancestral sequences given the branch length of the tree, then optimizes the positions of unconstrained nodes on the time axis, and then repeats this cycle.
The only topology optimization are (optional) resolution of polytomies in a way that is most (approximately) consistent with the sampling time constraints on the tree.
@@ -34,22 +33,22 @@ The package is designed to be used as a stand-alone tool or as a library used in


### Installation and prerequisites
TreeTime is written in Python 2.7 and currently doesn't support Python 3.
* The package depends on several python libraries:
    - numpy, scipy: for all kind of mathematical operations as matrix operations, numerical integration, interpolation, minimization, etc.

    - BioPython: for parsing multiple sequence alignments and all phylogenetic functionality
TreeTime is compatible with Python 2.7 upwards and is tested on 2.7, 3.5, and 3.6.  It depends on several Python libraries:

    - matplotlib: optional dependency for plotting
  If you do not have these libraries, you can install them by typing in the terminal:
    ```bash
    $pip install numpy scipy biopython matplotlib
    ```
* numpy, scipy, pandas: for all kind of mathematical operations as matrix
  operations, numerical integration, interpolation, minimization, etc.

* To install the package, run `setup.py` script from the terminal:
    ```bash
    $python setup.py install
    ```
* BioPython: for parsing multiple sequence alignments and all phylogenetic
  functionality

* matplotlib: optional dependency for plotting

You may install TreeTime and its dependencies by running

    pip install .

within this repository.

You might need root privileges for system wide installation. Alternatively, you can simply use it TreeTime locally without installation. In this case, just download and unpack it, and then add the TreeTime folder to your $PYTHONPATH.

+5 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import numpy as np
from treetime import TreeAnc, GTR
from Bio import Phylo, AlignIO
from Bio import __version__ as bioversion
import sys

if __name__=="__main__":
    ###########################################################################
@@ -85,7 +86,8 @@ if __name__=="__main__":
    ###########################################################################
    ### ANCESTRAL RECONSTRUCTION
    ###########################################################################
    treeanc = TreeAnc(params.tree, aln=params.aln, gtr=gtr, verbose=4, fill_overhangs=not params.keep_overhangs)
    treeanc = TreeAnc(params.tree, aln=params.aln, gtr=gtr, verbose=4,
                      fill_overhangs=not params.keep_overhangs)
    treeanc.infer_ancestral_sequences('ml', infer_gtr=infer_gtr,
                                       marginal=params.marginal)

@@ -121,3 +123,5 @@ if __name__=="__main__":
    outtree_name = '.'.join(params.tree.split('/')[-1].split('.')[:-1])+'_mutation.nexus'
    Phylo.write(treeanc.tree, outtree_name, 'nexus')
    print("--- tree saved in nexus format as  \n\t %s\n"%outtree_name)

    sys.exit(0)
+8 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ import numpy as np
from treetime import TreeAnc, GTR
from Bio import Phylo, AlignIO
from Bio import __version__ as bioversion
import os,shutil
import os,shutil, sys

if __name__=="__main__":
    ###########################################################################
@@ -29,7 +29,6 @@ if __name__=="__main__":
        "Example: '--gtr K80 --gtr_params kappa=0.2 pis=0.25,0.25,0.25,0.25'. See the exact definitions of "
        " the parameters in the GTR creation methods in treetime/nuc_models.py. Only nucleotide models supported at present")

    parser.add_argument('--prot', default = False, action="store_true", help ="protein alignment")
    parser.add_argument('--zero_based', default = False, action='store_true', help='zero based SNP indexing')
    parser.add_argument('-n', default = 10, type=int, help='number of mutations/nodes that are printed to screen')
    parser.add_argument('--verbose', default = 1, type=int, help='verbosity of output 0-6')
@@ -39,6 +38,7 @@ if __name__=="__main__":
    ###########################################################################
    ### CHECK FOR TREE, build if not in place
    ###########################################################################

    if params.tree is None:
        from treetime.utils import tree_inference
        params.tree = os.path.basename(params.aln)+'.nwk'
@@ -47,6 +47,9 @@ if __name__=="__main__":
        tree_inference(params.aln, params.tree, tmp_dir = tmp_dir)
        if os.path.isdir(tmp_dir):
            shutil.rmtree(tmp_dir)
    elif not os.path.isfile(params.tree):
        print("Input tree file does not exist:", params.tree)
        exit(1)

    ###########################################################################
    ### GTR SET-UP
@@ -216,3 +219,6 @@ if __name__=="__main__":
        for name, val in mutation_by_strain_sorted[:params.n]:
            if len(val):
                print("\t%s\t%d"%(name, len(val)))


    sys.exit(0)
Loading