{"id":23191921,"url":"https://github.com/moold/kseq-rs","last_synced_at":"2025-08-18T19:32:37.204Z","repository":{"id":36951775,"uuid":"390374999","full_name":"moold/kseq-rs","owner":"moold","description":"A FASTA/FASTQ format parser library","archived":false,"fork":false,"pushed_at":"2024-03-01T01:32:02.000Z","size":79,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-29T13:42:42.475Z","etag":null,"topics":["fasta","fastq"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moold.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-07-28T14:10:19.000Z","updated_at":"2024-04-14T09:09:52.000Z","dependencies_parsed_at":"2024-03-01T02:37:14.007Z","dependency_job_id":null,"html_url":"https://github.com/moold/kseq-rs","commit_stats":null,"previous_names":["moold/kseq"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moold%2Fkseq-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moold%2Fkseq-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moold%2Fkseq-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moold%2Fkseq-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moold","download_url":"https://codeload.github.com/moold/kseq-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230078869,"owners_count":18169306,"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","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":["fasta","fastq"],"created_at":"2024-12-18T12:19:26.214Z","updated_at":"2024-12-18T12:19:26.816Z","avatar_url":"https://github.com/moold.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Crates.io](https://img.shields.io/crates/d/kseq?logo=rust)](https://github.com/moold/kseq/archive/refs/heads/main.zip)\n[![Crates.io](https://img.shields.io/crates/v/kseq)](https://crates.io/crates/kseq)\n[![docs.rs](https://img.shields.io/docsrs/kseq)](https://docs.rs/kseq/)\n# kseq\n`kseq` is a simple fasta/fastq (**fastx**) format parser library for [Rust](https://www.rust-lang.org/), its main function is to iterate over the records from fastx files (similar to [kseq](https://attractivechaos.github.io/klib/#Kseq%3A%20stream%20buffer%20and%20FASTA%2FQ%20parser) in `C`). It uses shared buffer to read and store records, so the speed is very fast. It supports a **plain** or **gz** fastx file or [`io::stdin`](https://doc.rust-lang.org/std/io/fn.stdin.html), as well as a **fofn** (file-of-file-names) file, which contains multiple plain or gz fastx files (one per line).\n\nUsing `kseq` is very simple. Users only need to call `parse_path` to parse a path or `parse_reader` to parse a reader, and then use `iter_record` method to get each record.\n\n- `parse_path` This function takes a path that implements [`AsRef\u003cstd::path::Path\u003e`](https://doc.rust-lang.org/std/path/struct.Path.html) as input, a path can be a `fastx` file, `-` for [`io::stdin`](https://doc.rust-lang.org/std/io/fn.stdin.html), or a `fofn` file. It returns a `Result` type:\n\t- `Ok(T)`: A struct `T` with the `iter_record` method.\n\t- `Err(E)`: An error `E` including missing input, can't open or read, wrong fastx format or invalid path or file errors.\n\n- `parse_reader` This function takes a reader that implements [`std::io::Read`](https://doc.rust-lang.org/std/io/trait.Read.html) as input. It returns a `Result` type:\n\t- `Ok(T)`: A struct `T` with the `iter_record` method.\n\t- `Err(E)`: An error `E` including missing input, can't open or read, wrong fastx format or invalid path or file errors.\n\n- `iter_record` This function can be called in a loop, it returns a `Result\u003cOption\u003cRecord\u003e\u003e` type:\n\t- `Ok(Some(Record))`: A struct `Record` with methods:\n\t\t- `head -\u003e \u0026str`: get sequence id/identifier\n\t\t- `seq -\u003e \u0026str`:  get sequence\n\t\t- `des -\u003e \u0026str`:  get sequence description/comment\n\t\t- `sep -\u003e \u0026str`:  get separator\n\t\t- `qual -\u003e \u0026str`: get quality scores\n\t\t- `len -\u003e usize`: get sequence length\n\n\t\t***Note:*** call `des`, `sep` and `qual` will return `\"\"` if `Record` doesn't have these attributes.\n\t- `Ok(None)`: Stream has reached `EOF`.\n\t- `Err(ParseError)`: An error [`ParseError`](https://docs.rs/kseq/0.3.0/kseq/record/enum.ParseError.html) including `IO`, `TruncateFile`, `InvalidFasta` or `InvalidFastq` errors.\n\n## Example\n```no_run \nuse std::env::args;\nuse std::fs::File;\nuse kseq::parse_path;\n\nfn main(){\n\tlet path: String = args().nth(1).unwrap();\n\tlet mut records = parse_path(path).unwrap();\n\t// let mut records = parse_reader(File::open(path).unwrap()).unwrap();\n\twhile let Some(record) = records.iter_record().unwrap() {\n\t\tprintln!(\"head:{} des:{} seq:{} qual:{} len:{}\", \n\t\t\trecord.head(), record.des(), record.seq(), \n\t\t\trecord.qual(), record.len());\n\t}\n}\n```\n\n## Installation\n```text \ncargo add kseq\n```\n\n## Benchmarking \n```text\ncargo bench\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoold%2Fkseq-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoold%2Fkseq-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoold%2Fkseq-rs/lists"}