Skip to content

Commit

Permalink
Merge branch 'release/v2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
CiaranOMara committed May 23, 2019
2 parents 3b15a66 + 30c8050 commit 390742a
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 203 deletions.
100 changes: 0 additions & 100 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,6 @@ git-tree-sha1 = "039106453269e691fb54fb14e2b40f6c26091f62"
uuid = "0bcc2ff6-69eb-520d-bede-0374fc5bd2fd"
version = "1.1.0"

[[BinaryProvider]]
deps = ["Libdl", "Pkg", "SHA", "Test"]
git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.3"

[[CategoricalArrays]]
deps = ["Compat", "Future", "Missings", "Printf", "Reexport", "Requires"]
git-tree-sha1 = "94d16e77dfacc59f6d6c1361866906dbb65b6f6b"
uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597"
version = "0.5.2"

[[CodecZlib]]
deps = ["BinaryProvider", "Libdl", "Test", "TranscodingStreams"]
git-tree-sha1 = "e3df104c84dfc108f0ca203fd7f5bbdc98641ae9"
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
version = "0.5.1"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "49269e311ffe11ac5b334681d212329002a9832a"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "1.5.1"

[[DataFrames]]
deps = ["CategoricalArrays", "CodecZlib", "Compat", "DataStreams", "Dates", "InteractiveUtils", "IteratorInterfaceExtensions", "LinearAlgebra", "Missings", "Printf", "Random", "Reexport", "SortingAlgorithms", "Statistics", "StatsBase", "TableTraits", "Tables", "Test", "TranscodingStreams", "Unicode", "WeakRefStrings"]
git-tree-sha1 = "9cfed75401d25d281076eb5d82de148ac2933f9e"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "0.17.1"

[[DataStreams]]
deps = ["Dates", "Missings", "Test", "WeakRefStrings"]
git-tree-sha1 = "69c72a1beb4fc79490c361635664e13c8e4a9548"
uuid = "9a8bc11e-79be-5b39-94d7-1ccc349a1a85"
version = "0.4.1"

[[DataStructures]]
deps = ["InteractiveUtils", "OrderedCollections", "Random", "Serialization", "Test"]
git-tree-sha1 = "ca971f03e146cf144a9e2f2ce59674f5bf0e8038"
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
version = "0.15.0"

[[DataValues]]
deps = ["Dates", "InteractiveUtils", "LinearAlgebra", "Random", "Test"]
git-tree-sha1 = "05e4a87fe52a2af1b4a1ffd3ab2fc996c038b192"
Expand All @@ -61,10 +19,6 @@ version = "0.4.7"
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Expand All @@ -75,10 +29,6 @@ git-tree-sha1 = "c94b0787956629036fb2b20fccde9e52b89d079a"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.0.5"

[[Future]]
deps = ["Random"]
uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down Expand Up @@ -127,12 +77,6 @@ version = "0.4.0"
[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[OrderedCollections]]
deps = ["Random", "Serialization", "Test"]
git-tree-sha1 = "85619a3f3e17bb4761fe1b1fd47f0e979f964d5b"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.0.2"

[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand All @@ -149,12 +93,6 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[Reexport]]
deps = ["Pkg"]
git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0"
uuid = "189a3867-3050-52da-a836-e630ba90ab69"
version = "0.2.0"

[[Requires]]
deps = ["Test"]
git-tree-sha1 = "f6fbf4ba64d295e146e49e021207993b6b48c7d1"
Expand All @@ -167,33 +105,13 @@ uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[SortingAlgorithms]]
deps = ["DataStructures", "Random", "Test"]
git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd"
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
version = "0.3.1"

[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[StatsBase]]
deps = ["DataStructures", "DelimitedFiles", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "Test"]
git-tree-sha1 = "6479f15167b434c765d3508524264bfd63ded7c8"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
version = "0.28.0"

[[TableShowUtils]]
deps = ["DataValues", "Dates", "JSON", "Markdown", "Test"]
git-tree-sha1 = "14c54e1e96431fb87f0d2f5983f090f1b9d06457"
Expand All @@ -212,31 +130,13 @@ git-tree-sha1 = "55133a5476b61ec31060e555ffe12da27ac13682"
uuid = "382cd787-c1b6-5bf2-a167-d5b971a19bda"
version = "0.4.0"

[[Tables]]
deps = ["IteratorInterfaceExtensions", "LinearAlgebra", "Requires", "TableTraits", "Test"]
git-tree-sha1 = "5aa45584645393c1717e0cc1f0362c2ea81470a9"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "0.1.17"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[TranscodingStreams]]
deps = ["Pkg", "Random", "Test"]
git-tree-sha1 = "a34a2d588e2d2825602bf14a24216d5c8b0921ec"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.8.1"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[WeakRefStrings]]
deps = ["Missings", "Random", "Test"]
git-tree-sha1 = "cf70c71939e621a3fac4156a8bfb3c80d745794a"
uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5"
version = "0.5.7"
16 changes: 12 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
name = "BedgraphFiles"
uuid = "85eb9095-274b-55ce-be28-9e90f41ac741"
authors = ["Ciarán O'Mara <[email protected]>"]
version = "2.1.0"
version = "2.1.1"

[deps]
Bedgraph = "0bcc2ff6-69eb-520d-bede-0374fc5bd2fd"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataValues = "e7dc6d0d-1eca-5fa6-8ad6-5aecde8b7ea5"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
IterableTables = "1c8ee90f-4401-5389-894e-7a04a3dc0f4d"
IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
TableShowUtils = "5e66a065-1f0a-5976-b372-e0b8c017ca10"
TableTraits = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c"
TableTraitsUtils = "382cd787-c1b6-5bf2-a167-d5b971a19bda"

[compat]
julia = "0.7, ^1"
Bedgraph = "^1.1"
FileIO = "^1.0.1"
IteratorInterfaceExtensions = "^0.1.1, ^1"
IterableTables = ">=0.9.0"
TableShowUtils = "^0.2.0"
TableTraits = "^0.4, ^1"
TableTraitsUtils = "^0.3, ^0.4"

[extras]
Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1"

[targets]
test = ["Test", "Query"]
test = ["DataFrames", "Test", "Query"]
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![Build Status](https://travis-ci.org/CiaranOMara/BedgraphFiles.jl.svg?branch=master)](https://travis-ci.org/CiaranOMara/BedgraphFiles.jl)
[![Build status](https://ci.appveyor.com/api/projects/status/jny2ep4u3cmly8pj/branch/master?svg=true)](https://ci.appveyor.com/project/CiaranOMara/Bedgraphfiles-jl/branch/master)
[![BedgraphFiles](http://pkg.julialang.org/badges/BedgraphFiles_0.7.svg)](http://pkg.julialang.org/?pkg=BedgraphFiles)
[![codecov.io](http://codecov.io/github/CiaranOMara/BedgraphFiles.jl/coverage.svg?branch=master)](http://codecov.io/github/CiaranOMara/BedgraphFiles.jl?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/CiaranOMara/BedgraphFiles.jl/badge.svg?branch=master)](https://coveralls.io/github/CiaranOMara/BedgraphFiles.jl?branch=master)

Expand Down
9 changes: 0 additions & 9 deletions REQUIRE

This file was deleted.

38 changes: 14 additions & 24 deletions src/BedgraphFiles.jl
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
__precompile__()

module BedgraphFiles

using FileIO
using Requires

using Bedgraph
using DataFrames

using IteratorInterfaceExtensions, TableTraits, TableTraitsUtils
using TableShowUtils

import IterableTables


function __init__()
@require DataFrames="a93c6f00-e57d-5684-b7b6-d8193f3e46c0" include(joinpath(@__DIR__, "integrations","DataFrames.jl"))
end

const BedgraphFileFormat = File{format"bedGraph"}

struct BedgraphFile
filename::String
keywords
end

function Base.convert(::Type{Bedgraph.Record}, row::DataFrameRow) :: Bedgraph.Record
return Bedgraph.Record(row[1], row[2], row[3], row[4]) # Note: using index to allow flexible column names.
function Base.show(io::IO, source::BedgraphFile)
TableShowUtils.printtable(io, getiterator(source), "bedGraph file")
end

function Base.convert(::Type{Vector{Bedgraph.Record}}, df::DataFrame) :: Vector{Bedgraph.Record}

records = Vector{Bedgraph.Record}(undef, size(df)[1])

for (i, row) in enumerate(eachrow(df))
records[i] = convert(Bedgraph.Record, row)
function Base.read(file::BedgraphFile) :: Vector{Bedgraph.Record}
# Read file using Bedgraph package.
return open(file.filename, "r") do io
Bedgraph.readRecords(io)
end

return records
end

function Base.show(io::IO, source::BedgraphFile)
TableShowUtils.printtable(io, getiterator(source), "bedGraph file")
end

function load(f::BedgraphFileFormat; args...)
Expand All @@ -47,14 +45,6 @@ TableTraits.isiterabletable(x::BedgraphFile) = true
IteratorInterfaceExtensions.isiterable(x::Vector{Bedgraph.Record}) = true #Note: Vector{Bedgraph.Record} is iterable by default.
TableTraits.isiterabletable(x::Vector{Bedgraph.Record}) = true


function _loaddata(path) :: Vector{Bedgraph.Record}
# Read file using bedgraph package.
return open(path, "r") do io
Bedgraph.readRecords(io)
end
end

function IteratorInterfaceExtensions.getiterator(records::Vector{Bedgraph.Record})

columns = [
Expand All @@ -73,7 +63,7 @@ end

function IteratorInterfaceExtensions.getiterator(file::BedgraphFile)

records = _loaddata(file.filename)
records = read(file) #TODO: Generate iterator from first record?

it = getiterator(records)

Expand All @@ -97,7 +87,7 @@ end

function Vector{Bedgraph.Record}(file::B) :: Vector{Bedgraph.Record} where {B<:BedgraphFile}
@debug "Vector{Bedgraph.Record}(file::BedgraphFile)"
return _loaddata(file.filename)
return read(file)
end

function Vector{Bedgraph.Record}(x::T) :: Vector{Bedgraph.Record} where {T} #TODO: consider formalising Records function in bedgraph (e.g. Bedgraph.Records, Bedgraph.Bedgraph.Records) that returns Vector{Bedgraph.Record}.
Expand Down
16 changes: 16 additions & 0 deletions src/integrations/DataFrames.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@debug "BedgraphFiles loading DataFrames integration."

function Base.convert(::Type{Bedgraph.Record}, row::DataFrames.DataFrameRow) :: Bedgraph.Record
return Bedgraph.Record(row[1], row[2], row[3], row[4]) # Note: using index to allow flexible column names.
end

function Base.convert(::Type{Vector{Bedgraph.Record}}, df::DataFrames.DataFrame) :: Vector{Bedgraph.Record}

records = Vector{Bedgraph.Record}(undef, size(df)[1])

for (i, row) in enumerate(eachrow(df))
records[i] = convert(Bedgraph.Record, row)
end

return records
end
54 changes: 54 additions & 0 deletions test/integrations/test-DataFrames.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@testset "DataFrames" begin

using DataFrames


# DataFrame from Vector{Bedgraph.Record}.
df = DataFrame(Bag.records)

@test typeof(df) == DataFrame
@test size(df) == (9,4)

@test df[:chrom] == Bag.chroms
@test df[:first] == Bag.firsts
@test df[:last] == Bag.lasts
@test df[:value] == Bag.values

@test DataFrame(Bag.records) == Bag.records |> DataFrame


# DataFrame from bedGraph file.
df2 = DataFrame(load(Bag.file))

@test typeof(df2) == DataFrame
@test size(df2) == (9,4)

@test df2[:chrom] == Bag.chroms
@test df2[:first] == Bag.firsts
@test df2[:last] == Bag.lasts
@test df2[:value] == Bag.values

@test DataFrame(load(Bag.file)) == load(Bag.file) |> DataFrame


# DataFrame from headerless bedGraph file.
df3 = DataFrame(load(Bag.file_headerless))
@test typeof(df3) == DataFrame
@test size(df3) == (9,4)

@test df3[:chrom] == Bag.chroms
@test df3[:first] == Bag.firsts
@test df3[:last] == Bag.lasts
@test df3[:value] == Bag.values

@test DataFrame(load(Bag.file_headerless)) == load(Bag.file_headerless) |> DataFrame


# Save and load from DataFrame.
save(Bag.tmp_output_path, df)
@test df == load(Bag.tmp_output_path) |> DataFrame

df |> save(Bag.tmp_output_path)
@test df == load(Bag.tmp_output_path) |> DataFrame

end # test DataFrames
Loading

2 comments on commit 390742a

@CiaranOMara
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 register()

Release notes:

There are no new features in this release. This release contains some minor internal improvements as well as a much-appreciated Project.toml update from @davidanthoff.

@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/936

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 Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v2.1.1 -m "<description of version>" 390742a238ab18d172c599f47809441520135fc9
git push origin v2.1.1

Please sign in to comment.