Skip to content

Commit

Permalink
Merge 3899ef7 into db62811
Browse files Browse the repository at this point in the history
  • Loading branch information
alanderos91 committed Jan 20, 2019
2 parents db62811 + 3899ef7 commit 38c7791
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 173 deletions.
26 changes: 17 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@ matrix:
notifications:
email: false

script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd())'
- julia -e 'Pkg.test("BioSimulator", coverage=true)'
#script: # the default script is equivalent to the following
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.clone(pwd()); Pkg.build("Example"); Pkg.test("Example"; coverage=true)';

after_success:
- julia -e 'cd(Pkg.dir("BioSimulator")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
- julia -e 'cd(Pkg.dir("BioSimulator")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia -e 'Pkg.add("Plots"); Pkg.add("GR")'
- julia -e 'Pkg.add("Documenter"); Pkg.add("JSON")'
- julia -e 'cd(Pkg.dir("BioSimulator")); include(joinpath("docs", "make.jl"))'
- julia -e 'if VERSION >= v"0.7.0-" using Pkg end; cd(Pkg.dir("BioSimulator")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())';
- julia -e 'if VERSION >= v"0.7.0-" using Pkg end; cd(Pkg.dir("BioSimulator")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())';

jobs:
include:
- stage: "Documentation"
julia: 1.0
os: linux
script:
- julia -e 'using Pkg; Pkg.add("Documenter"); Pkg.add("TikzPictures"); Pkg.add("Plots")'
- julia --project=docs/ -e 'using Pkg; Pkg.instantiate();
Pkg.develop(PackageSpec(path=pwd()))'
- julia --project=docs/ docs/make.jl
after_success: skip
49 changes: 25 additions & 24 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-1.0-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-1.0-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
- julia_version: 0.7
- julia_version: 1
- julia_version: nightly

platform:
- x86 # 32-bit
- x64 # 64-bit

# Uncomment the following lines to allow failures on nightly julia
# (tests will run but not make your overall status red)
matrix:
allow_failures:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-1.0-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-1.0-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
allow_failures:
- julia_version: 1
- julia_version: nightly

branches:
only:
- master
Expand All @@ -24,20 +27,18 @@ notifications:
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
- set PATH=C:\Miniconda3;C:\Miniconda3\Scripts;%PATH%
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"BioSimulator\"); Pkg.build(\"BioSimulator\")"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"BioSimulator\")"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
3 changes: 1 addition & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV["PLOTS_TEST"] = "true"

makedocs(
doctest = false,
format = :html,
format = Documenter.HTML(),
modules = [BioSimulator],
clean = true,
sitename = "BioSimulator.jl",
Expand All @@ -22,7 +22,6 @@ makedocs(
deploydocs(
repo = "github.com/alanderos91/BioSimulator.jl.git",
target = "build",
julia = "0.6",
deps = nothing,
make = nothing
)
12 changes: 6 additions & 6 deletions docs/src/man/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ The following examples illustrate BioSimulator.jl's interface and features.
Each code block assumes BioSimulator.jl and Plots.jl are loaded; that is, `using BioSimulator, Plots`.

```@setup kendall
using BioSimulator, Plots
using BioSimulator, Plots, TikzPictures
gr(fmt = :png, dpi = 300)
```
```@setup mmek
using BioSimulator, Plots
using BioSimulator, Plots, TikzPictures
gr(fmt = :png, dpi = 300)
```
```@setup gene
using BioSimulator, Plots
using BioSimulator, Plots, TikzPictures
gr(fmt = :png, dpi = 300)
```
```@setup brusselator_cascade
Expand Down Expand Up @@ -41,7 +41,7 @@ model <= Reaction("immigration", 0.5, "0 --> X")
# Petri net; the "scale = 2" argument is optional and can be omitted
# it is used to pass additional options for the underlying Tikz document
fig = visualize(model, "scale = 2")
nothing #hide
TikzPictures.save(SVG("kendall_petri.svg"), fig) # hide
```
![](kendall_petri.svg)

Expand Down Expand Up @@ -88,7 +88,7 @@ model <= Reaction("Conversion", 0.1, "SE --> P + E")
# Petri net
fig = visualize(model)
nothing #hide
TikzPictures.save(SVG("mmek_petri.svg"), fig) # hide
```
![](mmek_petri.svg)

Expand Down Expand Up @@ -175,7 +175,7 @@ model = autoreg()
# Petri net
fig = visualize(model)
nothing # hide
TikzPictures.save(SVG("gene_petri.svg"), fig) # hide
```
![](gene_petri.svg)

Expand Down
7 changes: 4 additions & 3 deletions src/BioSimulator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ __precompile__()

using DataStructures
using RecipesBase

import TikzGraphs
using SparseArrays
using LightGraphs: DiGraph, add_edge!
using Random

import TikzGraphs
import StatsFuns.RFunctions: poisrand

import DataFrames: DataFrame
import Statistics: mean, std

import Base: (<=),
(>=),
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/odm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ end
r.scaled_rates[i] = k[i]
r.dependencies[i] = g[i]
for j in eachindex(g[i])
r.dependencies[i][j] = findfirst(ix, g[i][j])
r.dependencies[i][j] = something(findfirst(isequal(g[i][j]), ix), 0)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/otl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mutable struct OTL <: TauLeapMethod
# end
function OTL(end_time, ϵ, δ, β, stats_tracked)
new(end_time, ϵ, δ, β,
0.0, Matrix{Float64}(0,0), Int[],
0.0, Matrix{Float64}(undef,0,0), Int[],
stats_tracked,
Dict{Symbol,Int}(
:negative_excursions => 0,
Expand Down
6 changes: 3 additions & 3 deletions src/backend/pvec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Base.eltype(x::PVec{T}) where T = T

##### PVec interface #####
intensity(x::PVec) = x.intensity
isstable{T}(x::PVec{T}) = (x.error_bound <= eps(T) * x.intensity)
isstable(x::PVec{T}) where T = (x.error_bound <= eps(T) * x.intensity)

@fastmath function update_errorbound!{T}(x::PVec{T}, xi::T, i::Integer)
@fastmath function update_errorbound!(x::PVec{T}, xi::T, i::Integer) where T
x.error_bound = x.error_bound + eps(T) * (x.intensity + x[i] + xi)
end

@fastmath function update_intensity!{T}(x::PVec{T}, xi::T, i::Integer)
@fastmath function update_intensity!(x::PVec{T}, xi::T, i::Integer) where T
# if x.intensity - x[i] + xi < 0
# error("""
# Intensity update failed!
Expand Down
8 changes: 4 additions & 4 deletions src/backend/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ function make_dependency_graph!(dg, reactions_dict)
return dg
end

function make_species_vector(dict::Associative{Symbol,Species})
X0 = Array{Int}(length(dict))
id = Array{Symbol}(length(dict))
function make_species_vector(dict::AbstractDict{Symbol,Species})
X0 = zeros(Int, length(dict))
id = Array{Symbol}(undef, length(dict))
id2ind = Dict{Symbol,Int}()

i = 1
for (key, s) in dict
X0[i] = s.population
id[i] = s.id
id[i] = Symbol(s.id)
id2ind[key] = i
i = i + 1
end
Expand Down
2 changes: 1 addition & 1 deletion src/interface/reaction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function print_participants(io, participants)
end
end

parse_reaction(formula::String) = parse_reaction(parse(formula))
parse_reaction(formula::String) = parse_reaction(Meta.parse(formula))

function parse_reaction(ex::Expr)
reactants = OrderedDict{Symbol,Int}()
Expand Down
6 changes: 3 additions & 3 deletions src/interface/simulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ end

function build_output(::Val{:fixed}, nspecies, epochs, ntrials, tfinal)
n = epochs + 1
tdata = collect(linspace(0.0, tfinal, n))
tdata = collect(range(0.0, stop = tfinal, length = n))
output = RegularEnsemble(ntrials, nspecies, epochs)
for i in eachindex(output)
@inbounds copy!(output[i].tdata, tdata)
@inbounds copyto!(output[i].tdata, tdata)
end
return output
end
Expand Down Expand Up @@ -100,7 +100,7 @@ end
function simulate_chunk!(output, Xt, X0, algorithm, reactions, trial_set)
a = propensities(reactions)
for trial in trial_set
copy!(Xt, X0)
copyto!(Xt, X0)
reset!(algorithm, Xt, reactions)

xw = output[trial]
Expand Down
2 changes: 1 addition & 1 deletion src/output/average_path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function AveragePath(xw :: RegularEnsemble{T1,T2}) where {T1,T2}
trials = length(xw)

xmean = mean(xw[k].xdata for k in 1:trials)
temp = std([xw[k].xdata[i, j] for i in 1:d, j in 1:n, k in 1:trials], 3)
temp = std([xw[k].xdata[i, j] for i in 1:d, j in 1:n, k in 1:trials], dims=3)
xstd = reshape(temp, n, d)

return AveragePath{T1}(tdata, xmean, xstd)
Expand Down
6 changes: 3 additions & 3 deletions src/output/petrinet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ function petri_net(model :: Network)
end

species_nodes = collect(1:s)
species_labels = map(string, keys(species))
species_labels = [string(v) for v in keys(species)]
species_styles = Dict( i => "draw, rounded corners, fill=blue!10, font=\\large" for i in species_nodes )

reaction_nodes = collect(s+1:s+r)
reaction_labels = map(string, keys(reactions))
reaction_labels = [string(v) for v in keys(reactions)]
reaction_styles = Dict( i => "draw, rounded corners, thick, fill=red!10, font=\\large" for i in reaction_nodes)

node_labels = [ species_labels; reaction_labels ]
Expand All @@ -85,7 +85,7 @@ function draw(x :: PetriNet, options)
edge_labels = x.edge_labels
edge_styles = x.edge_styles

labels = map(x -> replace(x, "_", "\$\\cdot\$"), labels)
labels = map(x -> replace(x, "_" => "\$\\cdot\$"), labels)

TikzGraphs.plot(graph, TikzGraphs.Layouts.Layered(),
labels,
Expand Down
6 changes: 3 additions & 3 deletions src/output/summary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function get_regular_path(xw::SamplePath{T1,T2}, tfinal, epochs) where {T1,T2}

x0 = xw.xdata[1]

tdata = collect(linspace(0.0, tfinal, max_epoch))
tdata = collect(range(0.0, stop = tfinal, length = max_epoch))
xdata = zeros(T2, length(xw.xdata[1]), max_epoch)
epoch = 1

Expand Down Expand Up @@ -103,9 +103,9 @@ end

if species == nothing
species = collect(keys(result.id2index))
labels = map(String, keys(result.id2index))
labels = [string(s) for s in keys(result.id2index)]
else
labels = map(s -> String(s), species)
labels = [string(s) for s in species]
end

label --> reshape(labels, 1, length(labels))
Expand Down
34 changes: 19 additions & 15 deletions test/independent.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
x0 = 1_000
model_size = [10, 100, 500]

t = 10.0
n = 1
u = 5357
m = 1

algorithms = [
function test_independent()
x0 = 1_000
model_size = [10, 100, 500]

t = 10.0
n = 1
u = 5357
m = 1

algorithms = [
Direct(),
FirstReaction(),
NextReaction(),
OptimizedDirect(),
TauLeaping(),
StepAnticipation()
]

for algorithm in algorithms
@printf "%+6s\n" algorithm
for M in model_size
]
for algorithm in algorithms
@printf "%+6s\n" algorithm
for M in model_size
model = independent(M, x0)
srand(u)
seed!(u)
@printf "%+6s: %3d" "M" M
@time run_test(model, algorithm, t, n, m)
end
end
end

test_independent()

0 comments on commit 38c7791

Please sign in to comment.