Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use json string to store additional metadata in fasta headers #101

Merged
merged 1 commit into from
Jan 3, 2025
Merged
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
17 changes: 16 additions & 1 deletion packages/pangraph/src/pangraph/pangraph_block.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::io::json::{json_write_str, JsonPretty};
use crate::io::seq::reverse_complement;
use crate::pangraph::edits::Edit;
use crate::pangraph::pangraph::Pangraph;
Expand All @@ -10,6 +11,7 @@ use getset::{CopyGetters, Getters};
use maplit::btreemap;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::collections::{BTreeMap, BTreeSet};
use std::hash::Hash;

Expand Down Expand Up @@ -154,7 +156,20 @@ impl PangraphBlock {
let path_name = &graph.paths[&node.path_id()].name().as_ref().unwrap();
let (start, end) = node.position();
let strand = node.strand();
format!("{node_id} {path_name}-{block_id} [{start}-{end}|{strand}]")

let meta = json_write_str(
&json! ({
"path_name": path_name,
"block_id": block_id,
"start": start,
"end": end,
"strand": strand,
}),
JsonPretty(false),
)
.unwrap();

format!("{node_id} {meta}")
}
RecordNaming::Path => {
let path_id = graph.nodes[node_id].path_id();
Expand Down
Loading