Skip to content

Commit 9fbcdd4

Browse files
committed
Rebuild for Julia 1.0, 1.1, and 1.2
get loglikelihood calculation running forgot to save on code re-locate causing function overwriting Manifest Sequence generation for a defined phylogenetic tree update manifest custom travis script Nice registry functionality limited to >v1.1.0 remove Manifest? remove Manifest? update .gitignore - Manifest removed for dependency version flexibility needed for Julia-1.0 support README update
1 parent 4da8ee1 commit 9fbcdd4

File tree

22 files changed

+199
-1352
lines changed

22 files changed

+199
-1352
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
*.jl.mem
44
.ipynb_checkpoints
55
testfile.jl
6+
.DS_Store
7+
Manifest.toml

.travis.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.5
7+
- 1.0
8+
- 1.1
9+
- 1.2
810
- nightly
911
notifications:
10-
email: false
12+
email: true
1113
matrix:
1214
allow_failures:
1315
- julia: nightly
1416
fast_finish: true
17+
script:
18+
- julia -e 'using Pkg;
19+
if VERSION >= v"1.1.0";
20+
Registry.add(Registry.RegistrySpec(url = "https://github.com/JuliaRegistries/General.git"));
21+
Registry.add(Registry.RegistrySpec(url = "https://github.com/BioJulia/BioJuliaRegistry.git"));
22+
Pkg.build(verbose = true);
23+
else;
24+
Pkg.build();
25+
end;
26+
Pkg.test(coverage=true)'

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Justin Angevaare
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

LICENSE.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

Project.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name = "PhyloModels"
2+
uuid = "6465ae08-de3a-5dbe-bda8-3920f6a01ab7"
3+
authors = ["Justin Angevaare <justinangevaare@gmail.com>"]
4+
version = "0.3.0"
5+
6+
[deps]
7+
GeneticBitArrays = "5d6f8c34-7f74-4dab-a49b-48b3414fbfce"
8+
PhyloTrees = "4c47b132-0681-5a5d-b498-3afcf53fd314"
9+
SubstitutionModels = "8365b1bb-bd83-58ee-a267-f2965fc81c73"
10+
11+
[compat]
12+
GeneticBitArrays = "≥ 0.2.1"
13+
julia = "≥ 1.0.0"
14+
15+
[extras]
16+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
17+
18+
[targets]
19+
test = ["Test"]

README.md

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,23 @@
11
# PhyloModels.jl
2-
2+
[![Latest Release](https://img.shields.io/github/release/jangevaare/PhyloModels.jl.svg)](https://github.com/jangevaare/PhyloModels.jl/releases/latest)
3+
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/jangevaare/PhyloModels.jl/blob/master/LICENSE)
34
[![Build Status](https://travis-ci.org/jangevaare/PhyloModels.jl.svg?branch=master)](https://travis-ci.org/jangevaare/PhyloModels.jl)
45

5-
PhyloModels.jl is a package for performing phylogenetic simulation and inference in Julia. This package is no longer being developed or maintained in favour of [BioJulia/SubstitutionModels.jl](https://github.com/BioJulia/SubstitutionModels.jl) and related bioinformatics packages in the [BioJulia](https://github.com/BioJulia) Ecosystem.
6-
7-
8-
### Simulation
9-
Genetic sequences can be simulated from phylogenetic trees by defining a root sequence, site rates, and a nucleotide substitution model. The following nucleotide substitution models are currently available: `JC69`, `K80`, `F81`, `F84`, `HKY85`, `TN93`, and `GTR`.
10-
11-
12-
### Inference
13-
The log likelihood of phylogenetic trees can be calculated when genetic sequences have been observed at all leaves, and a nucleotide substitution model has been specified by using the `loglikelihood` function. Below is an example from *Molecular Evolution: A Statistical Approach*
6+
PhyloModels.jl is a package for performing genetic sequence simulation from specified phylogenetic trees (using [PhyloTrees.jl](https://github.com/jangevaare/PhyloTrees.jl) for phylogenetic tree specification, and [SubstitutionModels.jl](https://github.com/BioJulia/SubstitutionModels.jl) for nucleic acid substitution model specification), and for loglikelihood calculation of phylogenetic trees using Felsenstein's tree pruning algorithm¹.
147

15-
> using PhyloTrees, PhyloModels
16-
>
17-
> # Build tree
18-
> tree = Tree()
19-
> addnodes!(tree, 9)
20-
> addbranch!(tree, 9, 6, 0.1)
21-
> addbranch!(tree, 9, 8, 0.1)
22-
> addbranch!(tree, 6, 7, 0.1)
23-
> addbranch!(tree, 6, 3, 0.2)
24-
> addbranch!(tree, 7, 1, 0.2)
25-
> addbranch!(tree, 7, 2, 0.2)
26-
> addbranch!(tree, 8, 4, 0.2)
27-
> addbranch!(tree, 8, 5, 0.2)
8+
¹ Felsenstein, J. (1981). Evolutionary trees from DNA sequences: a maximum likelihood approach. *Journal of molecular evolution, 17*(6), 368-376.
289

29-
Phylogenetic tree with 9 nodes and 8 branches
10+
## Installation
3011

31-
> # Set state of leaf nodes
32-
> node_data = Dict{Int64, Sequence}()
33-
> node_data[1] = Sequence("T")
34-
> node_data[2] = Sequence("C")
35-
> node_data[3] = Sequence("A")
36-
> node_data[4] = Sequence("C")
37-
> node_data[5] = Sequence("C")
38-
>
39-
> # Parametrize substitution model
40-
> model = K80([2.])
12+
Julia 1.0.x, 1.1.x, and 1.2.x are currently supported. The current release can be installed
13+
from the Julia REPL:
4114

42-
Kimura 1980 substitution model
15+
```julia
16+
pkg> add PhyloModels
17+
```
4318

44-
> # Calculate log likelihood
45-
> loglikelihood(tree, model, node_data)
19+
The development version (master branch) can be installed as:
4620

47-
-7.5814075725577
21+
```julia
22+
pkg> add PhyloModels#master
23+
```

REQUIRE

Lines changed: 0 additions & 3 deletions
This file was deleted.

appveyor.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/PhyloModels.jl

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,31 @@
1-
__precompile__()
2-
31
module PhyloModels
42

5-
# Dependencies
6-
using
7-
PhyloTrees,
8-
Distributions
3+
using PhyloTrees,
4+
SubstitutionModels,
5+
GeneticBitArrays
6+
7+
import SubstitutionModels.
8+
import Base.rand
99

10-
# Methods expanded
11-
import
12-
Base.show,
13-
Base.push!,
14-
Base.append!,
15-
Base.length,
16-
Base.getindex,
17-
Base.rand,
18-
Base.copy,
19-
Base.deleteat!,
20-
StatsBase.loglikelihood
10+
# Re-export all of PhyloTrees, SubstitutionModels, and GeneticBitArrays
11+
for name in names(PhyloTrees)
12+
@eval export $(name)
13+
end
2114

22-
export
23-
# Sequences
24-
Sequence,
15+
for name in names(SubstitutionModels)
16+
@eval export $(name)
17+
end
2518

26-
# Substitution Models
27-
SubstitutionModel,
28-
SubstitutionModelPrior,
29-
JC69,
30-
K80,
31-
F81,
32-
F84,
33-
HKY85,
34-
TN93,
35-
GTR,
36-
JC69Prior,
37-
K80Prior,
38-
F81Prior,
39-
F84Prior,
40-
HKY85Prior,
41-
TN93Prior,
42-
GTRPrior,
43-
Q,
44-
P,
45-
logprior,
19+
for name in names(GeneticBitArrays)
20+
@eval export $(name)
21+
end
4622

47-
# Simulation
48-
simulate,
49-
simulate!,
23+
const NodeDNA = Dict{Int64, DNASeq}
24+
const NodeRNA = Dict{Int64, RNASeq}
5025

51-
# Loglikelihoods
52-
loglikelihood
26+
include("loglikelihood.jl")
27+
include("simulate.jl")
5328

54-
# Package files
55-
include("sequences.jl")
56-
include("substitution_models/abstract.jl")
57-
include("substitution_models/jc69.jl")
58-
include("substitution_models/k80.jl")
59-
include("substitution_models/f81.jl")
60-
include("substitution_models/f84.jl")
61-
include("substitution_models/hky85.jl")
62-
include("substitution_models/tn93.jl")
63-
include("substitution_models/gtr.jl")
64-
include("simulation.jl")
65-
include("loglikelihoods.jl")
29+
export NodeDNA, NodeRNA, siimulate!, simulate, rand, loglikelihood
6630

6731
end # module
Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
"""
2-
loglikelihood(tree::Tree,
3-
mod::SubstitutionModel,
4-
node_data::Dict{Int64, Sequence},
5-
output_calculations::Bool=false)
6-
7-
Calculates the log likelihood of a tree with sequences observed at all leaves
8-
"""
91
function loglikelihood(tree::Tree,
10-
mod::SubstitutionModel,
11-
node_data::Dict{Int64, Sequence},
12-
output_calculations::Bool=false)
2+
mod::T,
3+
node_data::N;
4+
output_calculations::Bool=false) where {T <: NASM, N <: Union{NodeDNA, NodeRNA}}
135
# Error checking
146
if !all(map(x -> x in keys(node_data), findleaves(tree)))
157
error("Some leaves are missing sequence data")
@@ -19,11 +11,12 @@ function loglikelihood(tree::Tree,
1911

2012
# Create a Dict to store likelihood calculations
2113
calculations = Dict{Int64, Array{Float64, 2}}()
14+
2215
# Find node visit order for postorder traversal
2316
visit_order = postorder(tree)
2417
for i in visit_order
2518
if isleaf(tree, i)
26-
calculations[i] = node_data[i].nucleotides
19+
calculations[i] = node_data[i].data
2720
else
2821
branches = tree.nodes[i].out
2922
for j in branches
@@ -39,8 +32,8 @@ function loglikelihood(tree::Tree,
3932
end
4033
end
4134
if output_calculations
42-
return sum(log.(mod.π' * calculations[visit_order[end]])), calculations, visit_order
35+
return sum(log.((mod)' * calculations[visit_order[end]])), calculations, visit_order
4336
else
44-
return sum(log.(mod.π' * calculations[visit_order[end]]))
37+
return sum(log.((mod)' * calculations[visit_order[end]]))
4538
end
4639
end

0 commit comments

Comments
 (0)