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: add gfa export #94

Draft
wants to merge 1 commit into
base: rust
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
93 changes: 91 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ eyre = "=0.6.12"
flate2 = "=1.0.33"
gcollections = "=1.5.0"
getset = "0.1.3"
gfa = { version = "=0.10.1", features = ["serde", "serde_json"] }
indoc = "=2.0.5"
intervallum = "=1.4.1"
itertools = "=0.13.0"
lazy_static = "=1.5.0"
Expand Down
2 changes: 2 additions & 0 deletions packages/pangraph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ eyre = { workspace = true }
flate2 = { workspace = true }
gcollections = { workspace = true }
getset = { workspace = true }
gfa = { workspace = true }
indoc = { workspace = true }
intervallum = { workspace = true }
itertools = { workspace = true }
lazy_static = { workspace = true }
Expand Down
30 changes: 9 additions & 21 deletions packages/pangraph/src/commands/export/export_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,17 @@ pub struct PangraphExportArgs {
#[clap(value_hint = ValueHint::Other)]
pub maximum_depth: usize,

/// Path to directory where output will be stored
#[clap(long, short = 'o', default_value = "export")]
#[clap(value_hint = ValueHint::DirPath)]
pub output_directory: PathBuf,

/// Basename of files
#[clap(long, short = 'p', default_value = "pangraph")]
#[clap(value_hint = ValueHint::DirPath)]
pub prefix: String,

/// Do not emit GFA file
#[clap(long, alias = "ng")]
pub no_export_gfa: bool,

/// Emit vis directory to input to panX-visualization
#[clap(long, alias = "px")]
pub export_panx: bool,

/// Do not export any block that contains at least one strain more than once
#[clap(long, alias = "nd")]
pub no_duplications: bool,

/// Random seed
#[clap(long)]
pub seed: Option<u64>,
/// Path to output GFA file
#[clap(long, alias = "gfa")]
#[clap(value_hint = ValueHint::Other)]
pub output_gfa: Option<PathBuf>,

/// Path to output directory where PanX visualization files will be written
#[clap(long, alias = "panx")]
#[clap(value_hint = ValueHint::DirPath)]
pub output_panx: Option<PathBuf>,
}
29 changes: 19 additions & 10 deletions packages/pangraph/src/commands/export/export_run.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::commands::export::export_args::PangraphExportArgs;
use crate::io::gfa::gfa_write_file;
use crate::make_error;
use crate::pangraph::pangraph::Pangraph;
use crate::utils::random::get_random_number_generator;
use eyre::Report;

pub fn export_run(args: &PangraphExportArgs) -> Result<(), Report> {
pub fn export_run(args: PangraphExportArgs) -> Result<(), Report> {
let PangraphExportArgs {
input_json,
edge_minimum_length,
Expand All @@ -14,17 +15,25 @@ pub fn export_run(args: &PangraphExportArgs) -> Result<(), Report> {
maximum_length,
minimum_depth,
maximum_depth,
output_directory,
prefix,
no_export_gfa,
export_panx,
no_duplications,
seed,
} = &args;
output_gfa,
output_panx,
} = args;

let rng = get_random_number_generator(seed);
if [&output_gfa, &output_panx].iter().all(|o| o.is_none()) {
return make_error!("No output formats specified. Specify at least one output path.");
}

let pangraph_json = Pangraph::from_path(input_json)?;
let graph = Pangraph::from_path(&input_json)?;

if let Some(output_gfa) = output_gfa {
gfa_write_file(output_gfa, &graph)?;
}

if let Some(output_panx) = output_panx {
// TODO
// panx_write(output_panx, &graph)?;
}

Ok(())
}
2 changes: 1 addition & 1 deletion packages/pangraph/src/commands/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn pangraph_main() -> Result<(), Report> {

match args.command {
PangraphCommands::Build(args) => build_run(&args),
PangraphCommands::Export(args) => export_run(&args),
PangraphCommands::Export(args) => export_run(args),
PangraphCommands::Simplify(args) => simplify_run(args),
PangraphCommands::Reconstruct(args) => reconstruct_run(&args),
PangraphCommands::Schema(args) => generate_schema(&args),
Expand Down
Loading
Loading