Skip to content

Commit

Permalink
Deprecate buslje09 and BLMI using a filename and format
Browse files Browse the repository at this point in the history
  • Loading branch information
diegozea committed Jun 26, 2024
1 parent 51df92b commit 1bd9dac
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## MIToS.jl Release Notes

### Changes from v2.20.0 to v2.21.0

* *[Breaking change]* The `buslje09` and `BLMI` functions from the `Information` module does
not longer accept a filename and a file format as arguments. You should explicitly read
the MSA using the `read_file` function and then run the `buslje09` or `BLMI` functions
on the returned MSA object. As an example of migration, `buslje09("msa.sto", "Stockholm")`
should be replaced by `buslje09(read_file("msa.sto", Stockholm))`.

### Changes from v2.19.0 to v2.20.0

* *[Breaking change]* The PDB module has deprecated `residues` and `@residues` in favor of
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "MIToS"
uuid = "51bafb47-8a16-5ded-8b04-24ef4eede0b5"
version = "2.20.0"
version = "2.21.0"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
12 changes: 7 additions & 5 deletions src/Information/CorrectedMutualInformation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function _buslje09(aln, alphabet::A, clusters, lambda, apc) where A
end

"""
`buslje09` takes a MSA or a file and a `FileFormat` as first arguments. It calculates a Z score
and a corrected MI/MIp as described on **Busjle et. al. 2009**.
`buslje09` takes a MSA and calculates a Z score and a corrected MI/MIp as described
on **Busjle et. al. 2009**.
keyword argument, type, default value and descriptions:
Expand Down Expand Up @@ -68,6 +68,7 @@ function buslje09(aln::AbstractMatrix{Residue};
end

function buslje09(filename::String, format::Type{T}; kargs...) where T <: FileFormat
@warn "Using a file name and format with `buslje09` is deprecated. Use `read_file` to read an MSA object and call `buslje09` on it."
aln = read_file(filename, T, AnnotatedMultipleSequenceAlignment, generatemapping=true)
buslje09(aln; kargs...)
end
Expand All @@ -92,9 +93,9 @@ function _BLMI(aln, clusters, alpha, beta, apc, lambda::Float64=0.0)
end

"""
`BLMI` takes a MSA or a file and a `FileFormat` as first arguments. It calculates a Z score
(ZBLMI) and a corrected MI/MIp as described on **Busjle et. al. 2009** but using using
BLOSUM62 pseudo frequencies instead of a fixed pseudocount.
`BLMI` takes an MSA and calculates a Z score (ZBLMI) and a corrected MI/MIp as described
on **Busjle et. al. 2009** but using using BLOSUM62 pseudo frequencies instead of a
fixed pseudocount.
Keyword argument, type, default value and descriptions:
Expand Down Expand Up @@ -143,6 +144,7 @@ function BLMI(aln::AbstractMatrix{Residue};
end

function BLMI(filename::String, format::Type{T}; kargs...) where T <: FileFormat
@warn "Using a file name and format with `BLMI` is deprecated. Use `read_file` to read an MSA object and call `BLMI` on it."
aln = read_file(filename, T, AnnotatedMultipleSequenceAlignment, generatemapping=true)
BLMI(aln; kargs...)
end
31 changes: 19 additions & 12 deletions test/Information/CorrectedMutualInformation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,17 @@
@testset "Simple" begin
data = readdlm(joinpath(DATA,
"data_simple_soft_Busljeetal2009_measure_MI.txt"), comments=true)
results = buslje09(joinpath(DATA, "simple.fasta"), FASTA,
lambda=0.0, clustering=false, apc=false)
_msa = read_file(joinpath(DATA, "simple.fasta"), FASTA)
results = buslje09(_msa, lambda=0.0, clustering=false, apc=false)

@test isapprox(Float64(data[1, SCORE]), results[MIToS_SCORE][1,2], atol=1e-6)
@test isapprox(Float64(data[1, ZSCORE]), results[MIToS_ZSCORE][1,2], atol=2.)
end

@testset "Gaoetal2011" begin
data = readdlm(gao11_buslje09("MI"), comments=true)
results = buslje09(Gaoetal2011, FASTA, lambda=0.0, clustering=false, apc=false)
_msa = read_file(Gaoetal2011, FASTA)
results = buslje09(_msa, lambda=0.0, clustering=false, apc=false)

@test isapprox([ Float64(x) for x in data[:,SCORE] ],
matrix2list(results[MIToS_SCORE]), atol=1e-6)
Expand All @@ -252,15 +253,17 @@
# 1.38629 = 0.693147 + 0.693147
end

result_0_05 = buslje09(Gaoetal2011,FASTA,lambda=0.05,clustering=false,apc=false)
_msa = read_file(Gaoetal2011, FASTA)
result_0_05 = buslje09(_msa,lambda=0.05,clustering=false,apc=false)
@test isapprox(result_0_05[MIToS_SCORE][1,2], 0.33051006116310444, atol=1e-14)
end
end

@testset "MI + clustering" begin

data = readdlm(gao11_buslje09("MI_clustering"), comments=true)
results = buslje09(Gaoetal2011, FASTA, lambda=0.0, clustering=true, apc=false)
_msa = read_file(Gaoetal2011, FASTA)
results = buslje09(_msa, lambda=0.0, clustering=true, apc=false)

@test isapprox([ Float64(x) for x in data[:,SCORE] ],
matrix2list(results[MIToS_SCORE]), atol=1e-6)
Expand All @@ -271,7 +274,8 @@
@testset "MIp" begin

data = readdlm(gao11_buslje09("MI_APC"), comments=true)
results = buslje09(Gaoetal2011, FASTA, lambda=0.0, clustering=false, apc=true)
_msa = read_file(Gaoetal2011, FASTA)
results = buslje09(_msa, lambda=0.0, clustering=false, apc=true)

@test isapprox([ Float64(x) for x in data[:,SCORE] ],
matrix2list(results[MIToS_SCORE]), atol=1e-6)
Expand All @@ -284,7 +288,8 @@
@testset "MIp + clustering" begin

data = readdlm(gao11_buslje09("MI_APC_clustering"), comments=true)
results = buslje09(Gaoetal2011, FASTA, lambda=0.0, clustering=true, apc=true)
_msa = read_file(Gaoetal2011, FASTA)
results = buslje09(_msa, lambda=0.0, clustering=true, apc=true)

@test isapprox([ Float64(x) for x in data[:,SCORE] ],
matrix2list(results[MIToS_SCORE]), atol=1e-6)
Expand All @@ -298,8 +303,9 @@

@testset "Simple" begin
file = joinpath(DATA, "simple.fasta")
busl = buslje09(file, FASTA)
blmi = BLMI(file, FASTA)
msa = read_file(file, FASTA)
busl = buslje09(msa)
blmi = BLMI(msa)

@test PairwiseListMatrices.getlist(busl[1])
PairwiseListMatrices.getlist(blmi[1])
Expand All @@ -309,7 +315,7 @@

@testset "Gaoetal2011" begin
msa = read_file(Gaoetal2011, FASTA)
busl = buslje09(Gaoetal2011, FASTA, lambda=0.0, samples=0)
busl = buslje09(msa, lambda=0.0, samples=0)
blmi = BLMI(msa, lambda=0.0, beta=0.0, samples=5)
# BLMI should be equal to Buslje09 if beta is zero

Expand All @@ -320,8 +326,9 @@

@testset "Gaoetal2011, lambda 0.05" begin

busl = buslje09(Gaoetal2011, FASTA, lambda=0.5, samples=0)
blmi = BLMI(Gaoetal2011, FASTA, lambda=0.5, beta=0.0, samples=5)
msa = read_file(Gaoetal2011, FASTA)
busl = buslje09(msa, lambda=0.5, samples=0)
blmi = BLMI(msa, lambda=0.5, beta=0.0, samples=5)
# BLMI should be equal to Buslje09 if beta is zero

@test PairwiseListMatrices.getlist(busl[2])
Expand Down

2 comments on commit 1bd9dac

@diegozea
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/109817

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.21.0 -m "<description of version>" 1bd9dac0896f69bb4c5ca27d130ae5e95f97abb7
git push origin v2.21.0

Please sign in to comment.