{"id":28292381,"url":"https://github.com/cidm-ph/distmat","last_synced_at":"2025-09-03T18:47:05.392Z","repository":{"id":62445062,"uuid":"542871725","full_name":"cidm-ph/distmat","owner":"cidm-ph","description":"Distance matrix data types and file formats for Rust","archived":false,"fork":false,"pushed_at":"2024-11-11T09:46:29.000Z","size":121,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-30T08:53:14.146Z","etag":null,"topics":["bioinformatics","data-structures","distance-matrix"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cidm-ph.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-29T01:55:27.000Z","updated_at":"2022-12-08T05:40:18.000Z","dependencies_parsed_at":"2023-02-09T01:45:18.773Z","dependency_job_id":null,"html_url":"https://github.com/cidm-ph/distmat","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cidm-ph/distmat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cidm-ph%2Fdistmat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cidm-ph%2Fdistmat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cidm-ph%2Fdistmat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cidm-ph%2Fdistmat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cidm-ph","download_url":"https://codeload.github.com/cidm-ph/distmat/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cidm-ph%2Fdistmat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273492661,"owners_count":25115598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bioinformatics","data-structures","distance-matrix"],"created_at":"2025-05-22T04:14:14.692Z","updated_at":"2025-09-03T18:47:05.373Z","avatar_url":"https://github.com/cidm-ph.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# distmat\n\n[![crates-io-v](https://img.shields.io/crates/v/distmat)](https://crates.io/crates/distmat)\n![crates-io-l](https://img.shields.io/crates/l/distmat)\n[![docs-rs](https://img.shields.io/docsrs/distmat)](https://docs.rs/distmat)\n\n\u003e **Distance matrix data types and file formats**\n\nMatrix types specialised for storing pairwise distance data, and parsers for\nsome common file formats for storing such data.\n\n```rust\nuse distmat::{DistMatrix, SquareMatrix};\nuse distmat::formats::{PhylipDialect, Separator, TabularShape};\n\nfn main() {\n    // A symmetric matrix stored as the lower triangle:\n    //   _1__5__3\n    // 1|\n    // 5| 4\n    // 3| 2  2\n    let matrix1 = DistMatrix::from_pw_distances(\u0026[1, 5, 3]);\n    assert_eq!(matrix1.get(1, 2), Some(\u00262));\n    assert_eq!(matrix1.get(2, 1), None);\n        assert_eq!(\n            matrix1.get_symmetric(2, 1).map(|x| x.get_or_default()),\n            Some(2)\n        );\n\n    // A square matrix stored in row major order:\n    //   _1___5___3\n    // 1| 0  -4  -2\n    // 5| 4   0   2\n    // 3| 2  -2   0\n    let matrix2 = SquareMatrix::from_pw_distances_with(\u0026[1, 5, 3], |x, y| x - y);\n    let mut total = 0;\n    for row in matrix2.iter_rows() {\n        total += row.sum::\u003ci32\u003e();\n    }\n    assert_eq!(total, 0);\n\n    let _matrix =\n        SquareMatrix::from_tabular_file(\"snp-dists.dat\", Separator::Char('\\t'), TabularShape::Wide).unwrap();\n    let _matrix =\n        SquareMatrix::from_phylip_file(\"phylip.dist\", PhylipDialect::Strict).unwrap();\n    let _matrix =\n        DistMatrix::from_phylip_file(\"phylip_lt.dist\", PhylipDialect::Relaxed).unwrap();\n}\n\n```\n\n\n## Purpose\nGoals:\n\n  * Read and write pairwise distance data from any reasonable formats,\n    especially those used in bioinformatics.\n  * Provide a convenient API to interact with distance data.\n\nNon-goals:\n\n  * Linear algebra. There are many linear algebra libraries available with\n    matrix data structures. At most distmat will help you export your data to\n    these libraries.\n  * Algorithms. You can provide a closure to distmat to construct a distance\n    matrix, but any specialised algorithms or distance measures are best\n    implemented elsewhere.\n\n\n## License\n\nDual-licensed under [MIT](LICENSE-MIT) or [Apache 2.0](LICENSE-APACHE).\n\n© Western Sydney Local Health District, NSW Health.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcidm-ph%2Fdistmat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcidm-ph%2Fdistmat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcidm-ph%2Fdistmat/lists"}