Code Monkey home page Code Monkey logo

forrustts's Introduction

Forward simulation with tree sequence recording in rust

This package is currently "experimental"!

forrustts (pronounced "forests") is a port of many ideas from the fwdpp library from C++ to rust.

It is licensed under the MIT license.

Packaging

Getting started

cargo build
cargo test --workspace

Development information

CI

CI testing is done using GitHub actions for both Linux and macOS. These actions include using clippy, which is a very strict code linter. The actions also check code format using rustfmt.

Code coverage

Use tarpaulin. The documentation for that crate is excellent. The short version is:

cargo tarpaulin -o html

This command will run the tests and generate a nice html report.

Change log

See here.

forrustts's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar molpopgen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

forrustts's Issues

Replace GSL with rand.

The GSL is over kill for this crate. We can switch to the lighter rand family of crates.

Replace drain with truncate

Several places where we drain a slice should instead be calls to truncate, as we don't need the drained items.

Need "table sorting" flags.

Need a bitflags type to affect the behavior of the table sorting function. Right now, we need a "skip edge table" flag.

Tskit output

This should be a cargo option. Given how tskit metadata works, the implementation should be either a set of functions or a class that consumes a table collection.

Provenance, too, should be an option.

This may be what pushes a redesign of the code layout into a cargo workspace.

Nested list access performance

All of the current data access functions are range checked, yet we generate the final return value with [], which is also range checked. The second accesses should use get_unchecked.

Documentation issues

Some things still refer to tskit_rust instead of tskit or just plain don't link to a function.

need a SamplesInfo type

We may want info beyond just "is a sample or not", so let's move the sample's vector into a struct.

Rename NULL_ID

The typography is inconsistent. This should be NullId.

Iterator for nested forward list.

It would be preferable to have a means of iterating a list via Iterator rather than the current callback method (which we should deprecate).

Examples vs integration tests

Currently, examples/forward_simluation.rs serves as both. That should change, and just be an example of the most efficient means of tree seq recording.

The "integration" test stuff should be move internally to test-only modules.

The down side is some code duplication, but we can make the internal simulator much simpler.

Tables mod should be pub.

For cases where tables are worked on via dumped vectors, several currently private functions become useful.

Thus, the mod should be pub, and we only import a few key types into the module root/prelude.

Add description of edge buffering

Should add this to the docs. Sadly, rustdoc doesn't allow standalone markdown (yet) in stable, so let's do it in the EdgeBuffer type.

But, do it after #53, as we'll move one of the bits of data there.

TableCollection interface should be a trait?

We'd like to support 32 and 64 tables "out of the box". A big first step is to get the API written down as a trait. Here's a mock-up for future me.

// Table row
pub struct E<T> {
    left: i64,
    right: i64,
    parent: T,
    child: T,
}

// table collection
pub struct TC<T> {
    pub edges: Vec<E<T>>,
}

impl<T> TC<T> {
    pub fn new() -> Self {
        TC::<T> { edges: vec![] }
    }
}

// Interface
trait TCT<T> {
    fn add_edge(&mut self, left: i64, right: i64, parent: T, child: T) -> T;
}

// macros for the details
macro_rules! add_edge {
    ($itype: ty) => {
        fn add_edge(&mut self, left: i64, right: i64, parent: $itype, child: $itype) -> $itype {
            self.edges.push(E::<$itype> {
                left,
                right,
                parent,
                child,
            });
            self.edges.len() as $itype
        }
    };
}

// Concrete definitions
impl TCT<i32> for TC<i32> {
    add_edge!(i32);
}

impl TCT<i64> for TC<i64> {
    add_edge!(i64);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn it_works() {
        let mut t = TC::<i32>::new();
        let x = t.add_edge(0, 1, 2, 3);
        assert_eq!(x, 1);
        assert_eq!(t.edges[0].left, 0);
        assert_eq!(t.edges[0].right, 1);
        assert_eq!(t.edges[0].parent, 2);
        assert_eq!(t.edges[0].child, 3);
    }
}

Example program behavior

The forward simulation example has the following incorrect behavior:

Simulating with a buffer and not simplifying returns an empty edge table.

Decide on license

The latest release was changes to the MIT license, which we did because we removed using the GSL for random numbers. However, a GPL license is more in the spirit of what we intend here. This is academic research software, and requiring modifications to be open is more in line with my views on open access.

Pin tskit version.

The current scheme uses default pinning, but we should use "=x.y.x" while that dependency is unstable.

Add getter functions from tables.

The current .edge(...), etc., panic! if indexes are out of range. We need to add analogs to Vec's get and get_unchecked functions. The latter will be unsafe.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.