Skip to content

Commit 10c740a

Browse files
committed
fix: draw multi-sequence fasta support not available currently
1 parent f7c47c3 commit 10c740a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/cgr.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,16 @@ impl DnaToChaos for fasta::Record {
9191
pub fn draw<R: io::Read>(source: R, destination: Option<PathBuf>) -> anyhow::Result<()> {
9292
let mut reader = fasta::Reader::new(BufReader::new(source));
9393

94-
for result in reader.records() {
94+
for (count, result) in reader.records().enumerate() {
9595
let record = result?;
96-
let chaos = record.record_to_chaos();
97-
chaos.draw(destination.clone())?;
96+
if count == 0 {
97+
let chaos = record.record_to_chaos();
98+
chaos.draw(destination.clone())?;
99+
} else {
100+
anyhow::bail!("Cannot draw from multi-sequence fasta");
101+
}
98102
}
103+
99104
Ok(())
100105
}
101106

src/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub struct DrawArgs {
7878
/// Input sequence file in FASTA format
7979
pub file: PathBuf,
8080

81-
/// Output file
81+
/// Output file name (.png), defaults to sequence ID
8282
#[arg(short, value_parser = validate_image_output)]
8383
pub output: Option<PathBuf>,
8484
}
@@ -131,7 +131,7 @@ fn validate_image_output(s: &str) -> Result<PathBuf, String> {
131131
));
132132
}
133133
} else {
134-
return Err("Output file must have an extension".to_string());
134+
return Err("Output file must have png extension (.png)".to_string());
135135
}
136136

137137
Ok(mp)

0 commit comments

Comments
 (0)