diff --git a/.appveyor.yml b/.appveyor.yml index 8056de2..12d034f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,6 +1,11 @@ environment: matrix: - - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe" + - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe" + - Julia_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" + +matrix: + allow_failures: + - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe" branches: only: diff --git a/.gitignore b/.gitignore index 5bdad97..00067bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .DS_Store docs/build/ docs/site/ + +BioFmtSpecimens diff --git a/.travis.yml b/.travis.yml index 6e4abe4..b7f4a34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,8 @@ os: - linux - osx julia: - - 0.6 + - 0.7 + - 1.0 - nightly matrix: allow_failures: @@ -11,6 +12,6 @@ matrix: notifications: email: false after_success: - - julia -e 'cd(Pkg.dir("BioCore")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())' - - julia -e 'cd(joinpath(Pkg.dir("BioCore"), "docs/src")); mkdir("assets"); cd("assets"); run(pipeline(`curl https://codeload.github.com/BioJulia/assets/tar.gz/master`, `tar -xz --strip=2 assets-master/doc_assets`))' - - julia -e 'cd(Pkg.dir("BioCore")); Pkg.add("Documenter"); include(joinpath("docs", "make.jl"))' + - julia -e 'using Pkg; Pkg.add("Documenter"); Pkg.add("Coverage")' + - julia -e 'using Coverage; import BioCore; cd(dirname(dirname(pathof(BioCore)))); Codecov.submit(process_folder())' + - julia -e 'import BioCore; cd(dirname(dirname(pathof(BioCore)))); include(joinpath("docs", "make.jl"))' diff --git a/CHANGELOG.md b/CHANGELOG.md index dd72b60..0d3bef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Basic project setup. [Unreleased]: https://github.com/BioJulia/BioCore.jl/compare/v2.0.0...HEAD -[1.4.0]: https://github.com/BioJulia/BioCore.jl/compare/v1.4.0...v2.0.0 +[2.0.0]: https://github.com/BioJulia/BioCore.jl/compare/v1.4.0...v2.0.0 [1.4.0]: https://github.com/BioJulia/BioCore.jl/compare/v1.2.1...v1.4.0 [1.3.0]: https://github.com/BioJulia/BioCore.jl/compare/v1.2.1...v1.3.0 [1.2.1]: https://github.com/BioJulia/BioCore.jl/compare/v1.2.0...v1.2.1 diff --git a/README.md b/README.md index c03f097..ab47b9d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # BioCore.jl -| **Release** | **Documentation** | **Maintainers** | -|:---------------------------------------------------------------:|:-------------------------------------------------------------------------------:|:-------------------------------------------:| -| [![](https://img.shields.io/github/release/BioJulia/BioCore.jl.svg)](https://github.com/BioJulia/BioCore.jl/releases/latest) [![](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/BioJulia/BioCore.jl/blob/master/LICENSE) | [![](https://img.shields.io/badge/docs-stable-blue.svg)](https://biojulia.github.io/BioCore.jl/stable) [![](https://img.shields.io/badge/docs-latest-blue.svg)](https://biojulia.github.io/BioCore.jl/latest) | ![](https://img.shields.io/badge/BioJulia%20Maintainer-Ward9250-orange.svg) | +[![](https://img.shields.io/github/release/BioJulia/BioCore.jl.svg?style=flat-square)](https://github.com/BioJulia/BioCore.jl/releases/latest) +[![](https://img.shields.io/badge/license-MIT-green.svg?style=flat-square)](https://github.com/BioJulia/BioCore.jl/blob/master/LICENSE) +[![](https://img.shields.io/badge/docs-stable-blue.svg?style=flat-square)](https://biojulia.github.io/BioCore.jl/stable) +[![](https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square)](https://biojulia.github.io/BioCore.jl/latest) +![](https://img.shields.io/badge/lifecycle-stable-green.svg?style=flat-square) +[![](https://img.shields.io/badge/discord-chat-blue.svg?style=flat-square&logo=discord&colorB=%237289DA)](https://discord.gg/z73YNFz) ## Description @@ -32,21 +35,59 @@ the master branch to try new features before release. ## Testing -BioCore.jl is tested against Julia `0.6` and current `0.7-dev` on Linux, OS X, and Windows. +BioCore.jl is tested against Julia `0.7` and `1.0.x` on Linux, OS X, and Windows. -| **PackageEvaluator** | **Latest Build Status** | -|:---------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------:| -| [![](https://pkg.julialang.org/badges/BioCore_0.6.svg)](https://pkg.julialang.org/detail/BioCore) [![](https://pkg.julialang.org/badges/BioCore_0.7.svg)](https://pkg.julialang.org/detail/BioCore) | [![](https://img.shields.io/travis/BioJulia/BioCore.jl/master.svg?label=Linux+/+macOS)](https://travis-ci.org/BioJulia/BioCore.jl) [![Build status](https://ci.appveyor.com/api/projects/status/xl19qeob3gsgm8j7?svg=true)](https://ci.appveyor.com/project/Ward9250/biocore-jl) [![](https://codecov.io/gh/BioJulia/BioCore.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/BioJulia/BioCore.jl) | +| **PackageEvaluator** | **Latest Build Status** | +|:--------------------:|:-----------------------:| +| [![](https://pkg.julialang.org/badges/BioCore_0.7.svg)](https://pkg.julialang.org/detail/BioCore) [![](https://pkg.julialang.org/badges/BioCore_1.0.svg)](https://pkg.julialang.org/detail/BioCore) | [![](https://img.shields.io/travis/BioJulia/BioCore.jl/master.svg?label=Linux+/+macOS)](https://travis-ci.org/BioJulia/BioCore.jl) [![Build status](https://ci.appveyor.com/api/projects/status/xl19qeob3gsgm8j7?svg=true)](https://ci.appveyor.com/project/Ward9250/biocore-jl) [![](https://codecov.io/gh/BioJulia/BioCore.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/BioJulia/BioCore.jl) | -## Contributing and Questions +## Contributing -We appreciate contributions from users including reporting bugs, fixing issues, -improving performance and adding new features. -Please go to the [contributing section of the documentation](biojulia.net/Contributing/latest) -for more information. +We appreciate contributions from users including reporting bugs, fixing +issues, improving performance and adding new features. + +Take a look at the [CONTRIBUTING](CONTRIBUTING.md) file provided with +every BioJulia package package for detailed contributor and maintainer +guidelines. + + +### Financial contributions + +We also welcome financial contributions in full transparency on our +[open collective](https://opencollective.com/biojulia). +Anyone can file an expense. If the expense makes sense for the development +of the community, it will be "merged" in the ledger of our open collective by +the core contributors and the person who filed the expense will be reimbursed. + + +## Backers & Sponsors + +Thank you to all our backers and sponsors! + +Love our work and community? [Become a backer](https://opencollective.com/biojulia#backer). + +[![backers](https://opencollective.com/biojulia/backers.svg?width=890)](https://opencollective.com/biojulia#backers) + +Does your company use BioJulia? Help keep BioJulia feature rich and healthy by +[sponsoring the project](https://opencollective.com/biojulia#sponsor) +Your logo will show up here with a link to your website. + +[![](https://opencollective.com/biojulia/sponsor/0/avatar.svg)](https://opencollective.com/biojulia/sponsor/0/website) +[![](https://opencollective.com/biojulia/sponsor/1/avatar.svg)](https://opencollective.com/biojulia/sponsor/1/website) +[![](https://opencollective.com/biojulia/sponsor/2/avatar.svg)](https://opencollective.com/biojulia/sponsor/2/website) +[![](https://opencollective.com/biojulia/sponsor/3/avatar.svg)](https://opencollective.com/biojulia/sponsor/3/website) +[![](https://opencollective.com/biojulia/sponsor/4/avatar.svg)](https://opencollective.com/biojulia/sponsor/4/website) +[![](https://opencollective.com/biojulia/sponsor/5/avatar.svg)](https://opencollective.com/biojulia/sponsor/5/website) +[![](https://opencollective.com/biojulia/sponsor/6/avatar.svg)](https://opencollective.com/biojulia/sponsor/6/website) +[![](https://opencollective.com/biojulia/sponsor/7/avatar.svg)](https://opencollective.com/biojulia/sponsor/7/website) +[![](https://opencollective.com/biojulia/sponsor/8/avatar.svg)](https://opencollective.com/biojulia/sponsor/8/website) +[![](https://opencollective.com/biojulia/sponsor/9/avatar.svg)](https://opencollective.com/biojulia/sponsor/9/website) + + +## Questions? + +If you have a question about contributing or using BioJulia software, come +on over and chat to us on [Discord](https://discord.gg/z73YNFz), or you can try the +[Bio category of the Julia discourse site](https://discourse.julialang.org/c/domain/bio). -If you have a question about -contributing or using this package, you are encouraged to use the -[Bio category of the Julia discourse -site](https://discourse.julialang.org/c/domain/bio). diff --git a/REQUIRE b/REQUIRE index 6bc6ffa..120f7b9 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,3 @@ -julia 0.6 -Compat 0.41.0 +julia 0.7 Automa -BufferedStreams 0.4.0 +BufferedStreams 1.0.0 diff --git a/docs/make.jl b/docs/make.jl index 1b7502d..6c69da5 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -12,7 +12,7 @@ makedocs( deploydocs( repo = "github.com/BioJulia/BioCore.jl.git", - julia = "0.6", + julia = "1.0", osname = "linux", target = "build", deps = nothing, diff --git a/docs/src/index.md b/docs/src/index.md deleted file mode 120000 index fe84005..0000000 --- a/docs/src/index.md +++ /dev/null @@ -1 +0,0 @@ -../../README.md \ No newline at end of file diff --git a/docs/src/index.md b/docs/src/index.md new file mode 100644 index 0000000..7a741f3 --- /dev/null +++ b/docs/src/index.md @@ -0,0 +1,93 @@ +# BioCore.jl + +[![](https://img.shields.io/github/release/BioJulia/BioCore.jl.svg?style=flat-square)](https://github.com/BioJulia/BioCore.jl/releases/latest) +[![](https://img.shields.io/badge/license-MIT-green.svg?style=flat-square)](https://github.com/BioJulia/BioCore.jl/blob/master/LICENSE) +[![](https://img.shields.io/badge/docs-stable-blue.svg?style=flat-square)](https://biojulia.github.io/BioCore.jl/stable) +[![](https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square)](https://biojulia.github.io/BioCore.jl/latest) +![](https://img.shields.io/badge/lifecycle-stable-green.svg?style=flat-square) +[![](https://img.shields.io/badge/discord-chat-blue.svg?style=flat-square&logo=discord&colorB=%237289DA)](https://discord.gg/z73YNFz) + + +## Description + +BioCore.jl provides core definitions that are common to all or many packages +in the BioJulia ecosystem. + +It also includes a definition of a common IO interface for IO of Bioinformatics +formats in BioJulia packages, and includes some helper functions for generating +file parsers from state machine automata with Automa.jl + + +## Installation + +BioCore is a dependency for other BioJulia packages, but you can install it +yourself with: + +```julia +using Pkg +add("BioCore") +#Pkg.add("BioCore") for julia prior to v0.7 +``` + +If you are interested in the cutting edge of the development, please check out +the master branch to try new features before release. + + +## Testing + +BioCore.jl is tested against Julia `0.7` and `1.0.x` on Linux, OS X, and Windows. + +| **PackageEvaluator** | **Latest Build Status** | +|:--------------------:|:-----------------------:| +| [![](https://pkg.julialang.org/badges/BioCore_0.7.svg)](https://pkg.julialang.org/detail/BioCore) [![](https://pkg.julialang.org/badges/BioCore_1.0.svg)](https://pkg.julialang.org/detail/BioCore) | [![](https://img.shields.io/travis/BioJulia/BioCore.jl/master.svg?label=Linux+/+macOS)](https://travis-ci.org/BioJulia/BioCore.jl) [![Build status](https://ci.appveyor.com/api/projects/status/xl19qeob3gsgm8j7?svg=true)](https://ci.appveyor.com/project/Ward9250/biocore-jl) [![](https://codecov.io/gh/BioJulia/BioCore.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/BioJulia/BioCore.jl) | + + +## Contributing + +We appreciate contributions from users including reporting bugs, fixing +issues, improving performance and adding new features. + +Take a look at the [CONTRIBUTING](https://github.com/BioJulia/BioCore.jl/blob/master/CONTRIBUTING.md) file provided with +every BioJulia package package for detailed contributor and maintainer +guidelines. + + +### Financial contributions + +We also welcome financial contributions in full transparency on our +[open collective](https://opencollective.com/biojulia). +Anyone can file an expense. If the expense makes sense for the development +of the community, it will be "merged" in the ledger of our open collective by +the core contributors and the person who filed the expense will be reimbursed. + + +## Backers & Sponsors + +Thank you to all our backers and sponsors! + +Love our work and community? [Become a backer](https://opencollective.com/biojulia#backer). + +[![backers](https://opencollective.com/biojulia/backers.svg?width=890)](https://opencollective.com/biojulia#backers) + +Does your company use BioJulia? Help keep BioJulia feature rich and healthy by +[sponsoring the project](https://opencollective.com/biojulia#sponsor) +Your logo will show up here with a link to your website. + +[![](https://opencollective.com/biojulia/sponsor/0/avatar.svg)](https://opencollective.com/biojulia/sponsor/0/website) +[![](https://opencollective.com/biojulia/sponsor/1/avatar.svg)](https://opencollective.com/biojulia/sponsor/1/website) +[![](https://opencollective.com/biojulia/sponsor/2/avatar.svg)](https://opencollective.com/biojulia/sponsor/2/website) +[![](https://opencollective.com/biojulia/sponsor/3/avatar.svg)](https://opencollective.com/biojulia/sponsor/3/website) +[![](https://opencollective.com/biojulia/sponsor/4/avatar.svg)](https://opencollective.com/biojulia/sponsor/4/website) +[![](https://opencollective.com/biojulia/sponsor/5/avatar.svg)](https://opencollective.com/biojulia/sponsor/5/website) +[![](https://opencollective.com/biojulia/sponsor/6/avatar.svg)](https://opencollective.com/biojulia/sponsor/6/website) +[![](https://opencollective.com/biojulia/sponsor/7/avatar.svg)](https://opencollective.com/biojulia/sponsor/7/website) +[![](https://opencollective.com/biojulia/sponsor/8/avatar.svg)](https://opencollective.com/biojulia/sponsor/8/website) +[![](https://opencollective.com/biojulia/sponsor/9/avatar.svg)](https://opencollective.com/biojulia/sponsor/9/website) + + +## Questions? + +If you have a question about contributing or using BioJulia software, come +on over and chat to us on [Discord](https://discord.gg/z73YNFz), or you can try the +[Bio category of the Julia discourse site](https://discourse.julialang.org/c/domain/bio). + diff --git a/src/BioCore.jl b/src/BioCore.jl index 5358960..cbf273d 100644 --- a/src/BioCore.jl +++ b/src/BioCore.jl @@ -6,8 +6,6 @@ # This file is a part of BioJulia. # License is MIT: https://github.com/BioJulia/BioCore.jl/blob/master/LICENSE.md -__precompile__() - module BioCore include("declare.jl") @@ -17,7 +15,6 @@ include("Mem.jl") include("Ragel.jl") include("ReaderHelper.jl") include("RecordHelper.jl") -include("StringFields.jl") include("Testing.jl") end # module BioCore diff --git a/src/IO.jl b/src/IO.jl index 98b70c6..7f6e644 100644 --- a/src/IO.jl +++ b/src/IO.jl @@ -52,7 +52,7 @@ See `subtypes(AbstractReader)` for all available data readers. """ abstract type AbstractReader <: AbstractFormattedIO end -Base.iteratorsize(::Type{T}) where T <: AbstractReader = Base.SizeUnknown() +Base.IteratorSize(::Type{T}) where T <: AbstractReader = Base.SizeUnknown() function Base.open(::Type{T}, filepath::AbstractString, args...; kwargs...) where T <: AbstractReader return T(open(filepath), args...; kwargs...) diff --git a/src/Mem.jl b/src/Mem.jl index 004a156..bd754a5 100644 --- a/src/Mem.jl +++ b/src/Mem.jl @@ -8,7 +8,7 @@ function copy(dst, src, n::Integer) end function copy(dst::Ptr, src::Ptr, n::Integer) - return ccall(:memcpy, Ptr{Void}, (Ptr{Void}, Ptr{Void}, Csize_t), dst, src, n) + return ccall(:memcpy, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), dst, src, n) end end diff --git a/src/Ragel.jl b/src/Ragel.jl index 59445aa..70eb3af 100644 --- a/src/Ragel.jl +++ b/src/Ragel.jl @@ -252,6 +252,15 @@ end # Iterator # -------- +function Base.iterate(reader::AbstractReader, nextone = eltype(reader)()) + if isnull(tryread!(reader, nextone)) + return nothing + else + return copy(get(nextone)), nextone + end +end + +#= function Base.start(reader::AbstractReader) T = eltype(reader) nextone = T() @@ -273,5 +282,6 @@ function Base.next(reader::AbstractReader, nextone) return ret, Nullable(item) end end +=# end # module Ragel diff --git a/src/RecordHelper.jl b/src/RecordHelper.jl index 8566f54..ed24fe2 100644 --- a/src/RecordHelper.jl +++ b/src/RecordHelper.jl @@ -8,8 +8,6 @@ module RecordHelper -using Compat: Cvoid - function compare_memory(p1::Ptr, p2::Ptr, len::Integer) return ccall(:memcmp, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), p1, p2, len) % Int end diff --git a/src/StringFields.jl b/src/StringFields.jl deleted file mode 100644 index f597842..0000000 --- a/src/StringFields.jl +++ /dev/null @@ -1,178 +0,0 @@ -# StringFields -# ============ -# -# UTF8-encoded mutable string type. -# -# This file is a part of BioJulia. -# License is MIT: https://github.com/BioJulia/BioCore.jl/blob/master/LICENSE.md - -module StringFields - -export StringField - -import BufferedStreams -using Compat: Cvoid - -""" -A simplistic mutable, utf8 encoded string. -""" -mutable struct StringField <: AbstractString - data::Vector{UInt8} - - # position of used data in `data` in bytes (not characters) - part::UnitRange{Int} -end - -function StringField() - return StringField(UInt8[], 1:0) -end - -function StringField(data::Vector{UInt8}) - return StringField(data, 1:length(data)) -end - -function StringField(data::SubString) - stringvec = Vector{UInt8}(data.string) - idx = 1+data.offset:data.offset+nextind(data, data.endof)-1 - return StringField(stringvec[idx], 1:endof(data)) -end - -function StringField(data::String) - return StringField(Vector{UInt8}(data), 1:endof(data)) -end - -# From base unicode/utf8.jl -function Base.endof(s::StringField) - d = s.data - i = s.part.stop - i == 0 && return i - while Base.is_valid_continuation(d[i]) - i -= 1 - end - @assert i >= s.part.start - return i - s.part.start + 1 -end - -# From base unicode/utf8.jl -function Base.isvalid(s::StringField, i::Integer) - return (1 <= i <= endof(s.data)) && - !Base.is_valid_continuation(s.data[s.part.start + i - 1]) -end - -# From base unicode/utf8.jl -function Base.next(s::StringField, i::Int) - d = s.data - b = d[s.part.start + i - 1] - if Base.is_valid_continuation(b) - throw(UnicodeError(Base.UTF_ERR_INVALID_INDEX, i, d[s.part.start + i - 1])) - end - - trailing = Base.utf8_trailing[b+1] - if length(s.part) < i + trailing - return '\ufffd', i+1 - end - c::UInt32 = 0 - for j = 1:trailing+1 - c <<= 6 - c += d[s.part.start + i - 1] - i += 1 - end - c -= Base.utf8_offset[trailing+1] - return Char(c), i -end - -function Base.copy!(field::StringField, data::Vector{UInt8}, - start::Integer, stop::Integer) - n = stop - start + 1 - if length(field.data) < n - resize!(field.data, n) - end - copy!(field.data, 1, data, start, n) - field.part = 1:n - return n -end - -function Base.copy!(to::StringField, from::StringField) - return copy!(to, from.data, from.part.start, from.part.stop) -end - -function Base.empty!(field::StringField) - field.part = 1:0 - return field -end - -function Base.isempty(field::StringField) - return field.part.start > field.part.stop -end - -function Base.convert(::Type{StringField}, str::String) - return StringField(copy(str.data), 1:length(str.data)) -end - -function Base.convert(::Type{StringField}, str::SubString) - return StringField(str) -end - -function Base.convert(::Type{String}, field::StringField) - return String(field.data[field.part]) -end - -function Base.convert(::Type{AbstractString}, field::StringField) - return convert(String, field) -end - -function Base.write(io::IO, field::StringField) - write(io, convert(String, field)) -end - -function Base.show(io::IO, field::StringField) - show(io, convert(String, field)) -end - -function Base.copy(field::StringField) - data = field.data[field.part] - return StringField(data, 1:length(data)) -end - -# From Base.hash over strings in hashing2.jl -function Base.hash(field::StringField, h::UInt64) - h += Base.memhash_seed - return ccall(Base.memhash, UInt, (Ptr{UInt8}, Csize_t, UInt32), - pointer(field.data, field.part.start), - length(field.part), h % UInt32) + h -end - -function Base.:(==)(a::StringField, b::StringField) - return length(a.part) == length(b.part) && cmp(a, b) == 0 -end - -function Base.:(==)(a::StringField, b::BufferedStreams.BufferedOutputStream) - if a === b - return true - elseif length(a) == length(b) - return ccall(:memcmp, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), - pointer(a.data, a.part.start), b.buffer, length(a.data)) == 0 - else - return false - end -end - -function Base.isless(a::StringField, b::StringField) - return cmp(a, b) < 0 -end - -function Base.cmp(a::StringField, b::StringField) - alen = length(a.part) - blen = length(b.part) - c = ccall(:memcmp, Cint, - (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), - pointer(a.data, a.part.start), - pointer(b.data, b.part.start), - min(alen, blen)) - if c == 0 - c = cmp(alen, blen) - end - return c -end - -end # module StringFields diff --git a/src/Testing.jl b/src/Testing.jl index 2367286..d7238ab 100644 --- a/src/Testing.jl +++ b/src/Testing.jl @@ -34,8 +34,7 @@ function get_bio_fmt_specimens(checkout = "master", auto_checkout = true, fresh end cd(FMT_SPECIMEN_PATH) do if auto_checkout - (so, si, pr) = readandwrite(`git describe --tags`) - checkout = readline(so) + checkout = open(readline, `git describe --tags`, "r+") end run(`git fetch origin`) run(`git checkout $(checkout)`)