MCPcopy Create free account
hub / github.com/alignoth/alignoth / from_bam

Method from_bam

src/cli.rs:243–265  ·  view source on GitHub ↗
(bam_path: &Path)

Source from the content-addressed store, hash-verified

241
242impl FromBam for Region {
243 fn from_bam(bam_path: &Path) -> Result<Self> {
244 let mut bam = bam::IndexedReader::from_path(bam_path)?;
245 let header = bam.header();
246 let target = header.target_names()[0];
247 let target = std::str::from_utf8(target)?.to_string();
248 bam.fetch(FetchDefinition::All)?;
249 let start = bam
250 .records()
251 .next()
252 .context(
253 "Could not find first alignment in bam file. Please specify a region with -g.",
254 )??
255 .pos();
256 let end = bam
257 .records()
258 .last()
259 .context(
260 "Could not find last alignment in bam file. Please specify a region with -g.",
261 )??
262 .cigar()
263 .end_pos();
264 Ok(Region { target, start, end })
265 }
266}
267
268#[derive(Debug, Clone, Eq, PartialEq)]

Callers

nothing calls this directly

Calls 2

OkFunction · 0.85
contextMethod · 0.45

Tested by

no test coverage detected