@@ -1438,7 +1438,6 @@ int sam_passes_filter(const sam_hdr_t *h, const bam1_t *b,
1438
1438
1439
1439
/// Converts a BAM aux tag to SAM format
1440
1440
/*
1441
- * @param b Pointer to the bam record
1442
1441
* @param key Two letter tag key
1443
1442
* @param type Single letter type code: ACcSsIifHZB.
1444
1443
* @param tag Tag data pointer, in BAM format
@@ -1628,6 +1627,29 @@ static inline const uint8_t *sam_format_aux1(const uint8_t *key,
1628
1627
return NULL ;
1629
1628
}
1630
1629
1630
+ /// Return a pointer to a BAM record's first aux field
1631
+ /** @param b Pointer to the BAM record
1632
+ @return Aux field pointer, or NULL if the record has none
1633
+
1634
+ When NULL is returned, errno will also be set to ENOENT. ("Aux field pointers"
1635
+ point to the TYPE byte within the auxiliary data for that field; but in general
1636
+ it is unnecessary for user code to be aware of this.)
1637
+ */
1638
+ HTSLIB_EXPORT
1639
+ uint8_t * bam_aux_first (const bam1_t * b );
1640
+
1641
+ /// Return a pointer to a BAM record's next aux field
1642
+ /** @param b Pointer to the BAM record
1643
+ @param s Aux field pointer, as returned by bam_aux_first()/_next()/_get()
1644
+ @return Pointer to the next aux field, or NULL if no next field or error
1645
+
1646
+ Whenever NULL is returned, errno will also be set: ENOENT if @p s was the
1647
+ record's last aux field; otherwise EINVAL, indicating that the BAM record's
1648
+ aux data is corrupt.
1649
+ */
1650
+ HTSLIB_EXPORT
1651
+ uint8_t * bam_aux_next (const bam1_t * b , const uint8_t * s );
1652
+
1631
1653
/// Return a pointer to an aux record
1632
1654
/** @param b Pointer to the bam record
1633
1655
@param tag Desired aux tag
@@ -1640,6 +1662,19 @@ static inline const uint8_t *sam_format_aux1(const uint8_t *key,
1640
1662
HTSLIB_EXPORT
1641
1663
uint8_t * bam_aux_get (const bam1_t * b , const char tag [2 ]);
1642
1664
1665
+ /// Return the aux field's 2-character tag
1666
+ /** @param s Aux field pointer, as returned by bam_aux_first()/_next()/_get()
1667
+ @return Pointer to the tag characters, NOT NUL-terminated
1668
+ */
1669
+ static inline
1670
+ const char * bam_aux_tag (const uint8_t * s ) { return (const char * ) (s - 2 ); }
1671
+
1672
+ /// Return the aux field's type character
1673
+ /** @param s Aux field pointer, as returned by bam_aux_first()/_next()/_get()
1674
+ @return The type character: one of cCsSiI/fd/A/Z/H/B
1675
+ */
1676
+ static inline char bam_aux_type (const uint8_t * s ) { return * s ; }
1677
+
1643
1678
/// Return a SAM formatting string containing a BAM tag
1644
1679
/** @param b Pointer to the bam record
1645
1680
@param tag Desired aux tag
@@ -1751,6 +1786,22 @@ int bam_aux_append(bam1_t *b, const char tag[2], char type, int len, const uint8
1751
1786
HTSLIB_EXPORT
1752
1787
int bam_aux_del (bam1_t * b , uint8_t * s );
1753
1788
1789
+ /// Delete an aux field from a BAM record
1790
+ /* @param b The BAM record to update
1791
+ @param s Pointer to the aux field to delete, as returned by
1792
+ bam_aux_first()/_next()/_get()
1793
+ @return Pointer to the following aux field, or NULL if none or on error
1794
+
1795
+ Identical to @c bam_aux_del() apart from the return value, which is an
1796
+ aux iterator suitable for use with @c bam_aux_next()/etc.
1797
+
1798
+ Whenever NULL is returned, errno will also be set: ENOENT if the aux field
1799
+ deleted was the record's last one; otherwise EINVAL, indicating that the
1800
+ BAM record's aux data is corrupt.
1801
+ */
1802
+ HTSLIB_EXPORT
1803
+ uint8_t * bam_aux_remove (bam1_t * b , uint8_t * s );
1804
+
1754
1805
/// Update or add a string-type tag
1755
1806
/* @param b The bam record to update
1756
1807
@param tag Tag identifier
0 commit comments