Skip to content

Commit fc9d56d

Browse files
Merge pull request #37 from rust-bio/improve-cigar-api
More improvements to CIGAR API.
2 parents 2584e45 + 3283cac commit fc9d56d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [0.11.0] - 2017-05-1
6+
### Changed
7+
- Improved CIGAR string API using a newtype wrapper.
8+
9+
510
## [0.10.0] - 2016-11-10
611
### Added
712
- Prelude module to easily import all relevant traits.

src/bam/record.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Record {
8787
self.inner_mut().core.pos = pos;
8888
}
8989

90-
pub fn end_pos(&self, cigar: &[Cigar]) -> i32 {
90+
pub fn end_pos(&self, cigar: &CigarString) -> i32 {
9191
let mut pos = self.pos();
9292
for c in cigar {
9393
match c {
@@ -174,7 +174,7 @@ impl Record {
174174
}
175175

176176
/// Set variable length data (qname, cigar, seq, qual).
177-
pub fn set(&mut self, qname: &[u8], cigar: &[Cigar], seq: &[u8], qual: &[u8]) {
177+
pub fn set(&mut self, qname: &[u8], cigar: &CigarString, seq: &[u8], qual: &[u8]) {
178178
self.inner_mut().l_data = (qname.len() + 1 + cigar.len() * 4 + ((seq.len() as f32 / 2.0).ceil() as usize) + qual.len()) as i32;
179179

180180
if self.inner().m_data < self.inner().l_data {
@@ -552,6 +552,7 @@ custom_derive! {
552552
#[derive(NewtypeDeref,
553553
NewtypeIndex(usize),
554554
NewtypeIndexMut(usize),
555+
NewtypeFrom,
555556
PartialEq,
556557
Eq,
557558
NewtypeDebug,
@@ -561,6 +562,13 @@ custom_derive! {
561562
}
562563

563564

565+
impl<'a> CigarString {
566+
pub fn iter(&'a self) -> ::std::slice::Iter<'a, Cigar> {
567+
self.into_iter()
568+
}
569+
}
570+
571+
564572
impl<'a> IntoIterator for &'a CigarString {
565573
type Item = &'a Cigar;
566574
type IntoIter = ::std::slice::Iter<'a, Cigar>;

0 commit comments

Comments
 (0)