Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "popgen"
name = "varistat"
version = "0.1.0"
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion examples/from_tskit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::env;

use popgen::MultiSiteCounts;
use varistat::MultiSiteCounts;

fn process_ts(ts: &tskit::TreeSequence) {
let counts = MultiSiteCounts::try_from_tree_sequence(ts, None).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/from_vcf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use noodles::vcf;
use popgen::{adapter::vcf::record_to_genotypes_adapter, MultiSiteCounts};
use varistat::{adapter::vcf::record_to_genotypes_adapter, MultiSiteCounts};

static VCF_FILE: &str = r#"##fileformat=VCFv4.5
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
Expand Down
4 changes: 2 additions & 2 deletions src/adapter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(feature = "noodles")]
pub mod vcf {
use crate::{AlleleID, PopgenResult};
use crate::{AlleleID, VaristatResult};
use noodles::vcf::variant::record::samples::keys::key;
use noodles::vcf::variant::record::samples::series::Value;
use noodles::vcf::variant::record::samples::Sample;
Expand All @@ -13,7 +13,7 @@ pub mod vcf {
record: Record,
num_samples: usize,
ploidy: usize,
) -> PopgenResult<Vec<Option<AlleleID>>> {
) -> VaristatResult<Vec<Option<AlleleID>>> {
let mut genotypes = Vec::with_capacity(ploidy * num_samples);

for sample in record.samples().iter() {
Expand Down
4 changes: 2 additions & 2 deletions src/from_tree_sequence.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{MultiSiteCounts, PopgenResult};
use crate::{MultiSiteCounts, VaristatResult};

// NOTES:
// 1. tskit could use Add for all id types!
Expand Down Expand Up @@ -42,7 +42,7 @@ fn update_right(
pub fn try_from_tree_sequence(
ts: &tskit::TreeSequence,
_parameters: Option<FromTreeSequenceOptions>,
) -> PopgenResult<MultiSiteCounts> {
) -> VaristatResult<MultiSiteCounts> {
let mut counts = MultiSiteCounts::default();
let mut left = 0.0;
// NOTE: we need TreeSequence to be able to provide these
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub mod stats;
mod test;
pub(crate) mod util;

pub type PopgenResult<T> = Result<T, PopgenError>;
pub type VaristatResult<T> = Result<T, VaristatError>;

#[cfg(feature = "tskit")]
pub use tskit;
Expand All @@ -21,7 +21,7 @@ pub use from_tree_sequence::FromTreeSequenceOptions;

#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
pub enum PopgenError {
pub enum VaristatError {
#[cfg(feature = "noodles")]
#[error("couldn't handle VCF: {0}")]
NoodlesVCF(#[from] std::io::Error),
Expand Down Expand Up @@ -95,7 +95,7 @@ impl MultiSiteCounts {
pub fn try_from_tree_sequence(
ts: &tskit::TreeSequence,
options: Option<FromTreeSequenceOptions>,
) -> Result<Self, PopgenError> {
) -> Result<Self, VaristatError> {
from_tree_sequence::try_from_tree_sequence(ts, options)
}

Expand Down
4 changes: 2 additions & 2 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod tests {
#[cfg(feature = "noodles")]
mod vcf {
use crate::adapter::vcf::record_to_genotypes_adapter;
use crate::{AlleleID, MultiSiteCounts, PopgenResult};
use crate::{AlleleID, MultiSiteCounts, VaristatResult};
use noodles::vcf::header::record::value::map::{Contig, Format};
use noodles::vcf::header::record::value::Map;
use noodles::vcf::variant::io::Write;
Expand Down Expand Up @@ -168,7 +168,7 @@ mod tests {
.records()
.map(Result::unwrap)
.map(|rec| record_to_genotypes_adapter(&header, rec, num_samples, ploidy))
.collect::<PopgenResult<Vec<_>>>()
.collect::<VaristatResult<Vec<_>>>()
.unwrap();
let counts = MultiSiteCounts::from_tabular(all_alleles.iter().cloned());
(all_alleles, counts)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_try_from_tree_sequence.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// NOTE: these tests require compiling
// with the tskit feature

use popgen::tskit;
use popgen::tskit::prelude::StreamingIterator;
use varistat::tskit;
use varistat::tskit::prelude::StreamingIterator;

#[cfg(test)]
struct MutationData {
Expand Down Expand Up @@ -63,7 +63,7 @@ struct SiteCountContents {
}

#[cfg(test)]
fn validate_site_counts(counts: &popgen::iter::SiteCounts, expected: SiteCountContents) {
fn validate_site_counts(counts: &varistat::iter::SiteCounts, expected: SiteCountContents) {
let num_alleles = expected
.derived
.iter()
Expand Down Expand Up @@ -246,7 +246,7 @@ mod naive_details {
#[cfg(test)]
fn generate_expected_site_counts_naive(
ts: &tskit::TreeSequence,
options: Option<popgen::FromTreeSequenceOptions>,
options: Option<varistat::FromTreeSequenceOptions>,
) -> Vec<SiteCountContents> {
let mut expected = vec![];
// We have no code depending on options yet
Expand Down Expand Up @@ -645,9 +645,9 @@ where
#[cfg(test)]
fn generate_counts_and_validate(
ts: &tskit::TreeSequence,
options: Option<popgen::FromTreeSequenceOptions>,
options: Option<varistat::FromTreeSequenceOptions>,
) {
let counts = popgen::MultiSiteCounts::try_from_tree_sequence(ts, None).unwrap();
let counts = varistat::MultiSiteCounts::try_from_tree_sequence(ts, None).unwrap();
let expected = generate_expected_site_counts_naive(ts, options);
assert_eq!(counts.len(), expected.len());
for (obs, exp) in counts.iter().zip(expected.into_iter()) {
Expand Down
Loading