Skip to content

Commit

Permalink
integrate plink
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimens committed Jul 25, 2022
1 parent 033ba7f commit 98f6d8b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/PopGenCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ export bcf, vcf
include("io/Baypass.jl")
export baypass

include("io/Plink.jl")
export plink

include("io/ReadWrite.jl")
##
include("Datasets.jl")
Expand Down
2 changes: 1 addition & 1 deletion src/io/Plink.jl
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ plink(sharks, filename = "biallelic_sharks.ped")
```
"""
function plink(data::PopData; filename::String)
data.metadata.biallelic != true && throw(ArgumentError("To write to PLINK format, data must be biallelic.\nThis can be done with dropmultiallelic(::PopData)\n"))
data.metadata.biallelic != true && throw(ArgumentError("To write to PLINK format, data must be biallelic.\nThis can be done with dropmultiallelic())\n"))
basename = endswith(filename, r".bed|.ped") ? splitext(filename)[1] : filename
# the .fam file
tmp = data.metadata[:, r"population|name|sire|dam|sex|phenotype"]
Expand Down
10 changes: 8 additions & 2 deletions src/io/ReadWrite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ to Genepop format, call up the `?genepop` docstring.
| genepop | `.gen`, `.genepop` | ?genepop |
| delimited | `.csv`, `.txt`, `.tsv` | ?delimited |
| structure | `.str`, `.structure` | ?structure |
| plink | `.ped` | ?plink |
| baypass | `.baypass` | ?baypass |
### Example
```
Expand All @@ -80,8 +82,10 @@ function Base.write(data::PopData; filename::String, kwargs...)
structure(data, filename = filename; kwargs...)
elseif ext in ["csv", "txt", "tsv"]
delimited(data, filename = filename; kwargs...)
elseif ext == "baypass"
baypass(data, filename = filename)
else
@error "File type not recognized by filename extension. Please see the docstring"
throw(ArgumentError("File type not recognized by filename extension. Please see the docstring"))
end
end

Expand All @@ -93,7 +97,9 @@ function Base.write(data::PopData, filename::String, kwargs...)
structure(data, filename = filename; kwargs...)
elseif ext in ["csv", "txt", "tsv"]
delimited(data, filename = filename; kwargs...)
elseif ext == "baypass"
baypass(data, filename = filename)
else
@error "File type not recognized by filename extension. Please see the docstring"
throw(ArgumentError("File type not recognized by filename extension. Please see the docstring"))
end
end

2 comments on commit 98f6d8b

@pdimens
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@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 updated: JuliaRegistries/General/63875

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 v0.7.0 -m "<description of version>" 98f6d8b2c2f62d3dd62aca4f717f3f31fb7b8918
git push origin v0.7.0

Please sign in to comment.