Skip to content

Commit cc48cab

Browse files
committed
Add CLI entry point for pangenotype matrix
1 parent a51c5e2 commit cc48cab

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

flatgfa/src/cli/cmds.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,26 @@ pub fn bed_intersect(args: BEDIntersect) {
338338
}
339339
}
340340
}
341+
342+
/// construct a pangenotype matrix
343+
#[derive(FromArgs, PartialEq, Debug)]
344+
#[argh(subcommand, name = "matrix")]
345+
pub struct PangenotypeMatrix {
346+
/// the GAF file to use for genotyping
347+
#[argh(positional)]
348+
gaf_file: String,
349+
}
350+
351+
pub fn pangenotype_matrix(gfa: &flatgfa::FlatGFA, args: PangenotypeMatrix) {
352+
let matrix = ops::pangenotype::make_pangenotype_matrix(gfa, vec![args.gaf_file]);
353+
for row in matrix {
354+
for col in row {
355+
if col {
356+
print!("1");
357+
} else {
358+
print!("0");
359+
}
360+
}
361+
println!();
362+
}
363+
}

flatgfa/src/cli/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ enum Command {
4444
GafLookup(cmds::GAFLookup),
4545
Bench(cmds::Bench),
4646
BedIntersect(cmds::BEDIntersect),
47+
PangenotypeMatrix(cmds::PangenotypeMatrix),
4748
}
4849

4950
fn main() -> Result<(), &'static str> {
@@ -146,6 +147,9 @@ fn main() -> Result<(), &'static str> {
146147
Some(Command::BedIntersect(_sub_args)) => {
147148
panic!("Unreachable code");
148149
}
150+
Some(Command::PangenotypeMatrix(sub_args)) => {
151+
cmds::pangenotype_matrix(&gfa, sub_args);
152+
}
149153
None => {
150154
// Just emit the GFA or FlatGFA file.
151155
dump(&gfa, &args.output);

0 commit comments

Comments
 (0)