Skip to content

Commit 7d13fe7

Browse files
authored
Merge pull request #6 from P2GX/write-hpoa
Support writing HPO annotations into HPOA format
2 parents 3d01b03 + 005397c commit 7d13fe7

File tree

8 files changed

+1194
-212
lines changed

8 files changed

+1194
-212
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ Cargo.lock
2020
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
2121
#.idea/
2222

23-
.vscode/
23+
.vscode/
24+
.idea/

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ authors = [
1818
[dependencies]
1919
clap = { version = "4.5", features = ["derive"], optional = true }
2020
flate2 = { version = "1.0", optional = true }
21-
ontolius = { version = "0.7", default-features = false }
21+
ontolius = { version = "0.7.1", default-features = false }
2222
regex = "1.11.1"
2323
serde = { version = "1.0.197", features = ["derive"], optional = true }
2424
serde_json = { version = "1.0.140", optional = true }

src/format.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! The data formats of ontology annotations.
2+
3+
/// Human Phenotype Ontology annotation format.
4+
pub struct Hpoa;
5+
6+
/// Gene Ontology annotation format.
7+
pub struct Gaf;

src/go.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
//! Parse Gene Ontology annotations.
2-
//!
3-
//! Use [`GoGafAnnotationLoader`] to parse GAF file into [`GoAnnotations`].
2+
3+
use crate::format::Gaf;
4+
use crate::io::{AnnotationLoadError, AnnotationLoader, ValidationIssue};
45
use ontolius::TermId;
56
#[cfg(feature = "serde")]
67
use serde::{Deserialize, Serialize};
78
use std::fmt::{Display, Formatter};
89
use std::io::BufRead;
910
use std::str::FromStr;
1011

11-
use crate::io::{AnnotationLoadError, AnnotationLoader, ValidationIssue};
12-
1312
/// The number of columns in GO GAF file.
1413
const GOA_EXPECTED_FIELDS: usize = 17;
1514

@@ -223,10 +222,8 @@ pub struct GoAnnotations {
223222
pub negated_annotation_count: usize,
224223
}
225224

226-
pub struct GoGafAnnotationLoader;
227-
228-
impl AnnotationLoader<GoAnnotations> for GoGafAnnotationLoader {
229-
fn load_from_buf_read<R>(&self, read: R) -> Result<GoAnnotations, AnnotationLoadError>
225+
impl AnnotationLoader<Gaf> for GoAnnotations {
226+
fn load_from_buf_read<R>(read: R) -> Result<GoAnnotations, AnnotationLoadError>
230227
where
231228
R: BufRead,
232229
{
@@ -377,7 +374,6 @@ pub mod stats {
377374

378375
#[cfg(test)]
379376
mod tests {
380-
381377
use super::*;
382378

383379
#[test]

0 commit comments

Comments
 (0)