Skip to content

Commit

Permalink
Test for append
Browse files Browse the repository at this point in the history
Mmap needs 8x skip. Mine was 23. I added another reserved byte,
which caused some test errors.
  • Loading branch information
xijiang committed Dec 6, 2022
1 parent 3456f98 commit 4e8df69
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GeneMatrix"
uuid = "b017c6bb-e7c7-4437-8ee6-a27b72ea26ab"
authors = ["Xijiang Yu <[email protected]> and contributors"]
version = "0.1.3"
version = "0.1.4"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ symmetric, then `mattp` is overruled as `S`.
The package also provides two other I/O functions to input and output
plink bed files.

*To be added*
- *To be added*

## Matrix construction

Expand All @@ -42,11 +42,13 @@ plink bed files.

## Pedigree

## Compat genotype storage
## Compact genotype storage and manipulation methods

## Todo

- [ ] `xyappend` functions
- [ ] `nrm`: numerical relationship matrix
- [ ] `nrminv`: the inverse of nrm
- [ ] `sortped`, recode pedigree to 1:nID.
- `nrm`: numerical relationship matrix
- `nrminv`: the inverse of nrm
- `sortped`, recode pedigree to 1:nID.
- `readmacs`, read simulation results from MaCS.
- `bed2int8`, convert bed file formats to Int8
- tests merging.
4 changes: 2 additions & 2 deletions src/append.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Append genotypes in `mat` to `file`.
"""
function xyappend(file::AbstractString, mat::Matrix; trans='N')
function xyappend(file::AbstractString, mat::AbstractMatrix; trans='N')
isfile(file) || error("File $file doesn't exist")
open(file, "r+") do io
mt, _, et, nrow, ncol = readhdr(io)
Expand All @@ -21,7 +21,7 @@ function xyappend(file::AbstractString, mat::Matrix; trans='N')
write(io, mat')
end

seek(io, 15)
seek(io, 16)
write(io, [ncol + ncl2])
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ function readxy(file)
mat = nothing # to return if success
open(file, "r") do io
mt, id, et, nrow, ncol = readhdr(io)
@info id
if et == Bool # eltype
mat = BitArray(undef, nrow, ncol)
read!(io, mat)
Expand Down Expand Up @@ -114,5 +113,6 @@ function writebed(bed, mat)
end
end

function bed2bytes(bed)
function bed2int8(bed)
end

28 changes: 14 additions & 14 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using GeneArrays
using GeneMatrix
using Test

@testset "I/O" begin
Expand All @@ -7,30 +7,30 @@ using Test

nrow, ncol = 200, 100
a = rand(nrow, ncol)
GeneArrays.writexy(file, a)
b = GeneArrays.readxy(file)
GeneMatrix.writexy(file, a)
b = GeneMatrix.readxy(file)
@test a == b

a = a'a
GeneArrays.writexy(file, a)
b = GeneArrays.readxy(file)
@test filesize(file) == ncol * (ncol + 1) * 4 + 23
GeneMatrix.writexy(file, a)
b = GeneMatrix.readxy(file)
@test filesize(file) == ncol * (ncol + 1) * 4 + 24
@test a == b

a = rand(nrow, 2ncol)
b = view(a, :, 1:ncol)
c = view(a, :, ncol+1:2ncol)
GeneArrays.writexy(file, b)
GeneArrays.xyappend(file, c)
d = GeneArrays.readxy(file)
GeneMatrix.writexy(file, b)
GeneMatrix.xyappend(file, c)
d = GeneMatrix.readxy(file)
@test a == d

GeneArrays.writexy(file, b)
GeneArrays.writexy(f2, c)
GeneArrays.xyappend(file, f2)
d = GeneArrays.readxy(file)
GeneMatrix.writexy(file, b)
GeneMatrix.writexy(f2, c)
GeneMatrix.xyappend(file, f2)
d = GeneMatrix.readxy(file)
@test a == d

rm(file)
rm(f2)
end

0 comments on commit 4e8df69

Please sign in to comment.