@@ -1438,7 +1438,6 @@ int sam_passes_filter(const sam_hdr_t *h, const bam1_t *b,
14381438
14391439/// Converts a BAM aux tag to SAM format
14401440/*
1441- * @param b Pointer to the bam record
14421441 * @param key Two letter tag key
14431442 * @param type Single letter type code: ACcSsIifHZB.
14441443 * @param tag Tag data pointer, in BAM format
@@ -1628,6 +1627,29 @@ static inline const uint8_t *sam_format_aux1(const uint8_t *key,
16281627 return NULL ;
16291628}
16301629
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+
16311653/// Return a pointer to an aux record
16321654/** @param b Pointer to the bam record
16331655 @param tag Desired aux tag
@@ -1640,6 +1662,19 @@ static inline const uint8_t *sam_format_aux1(const uint8_t *key,
16401662HTSLIB_EXPORT
16411663uint8_t * bam_aux_get (const bam1_t * b , const char tag [2 ]);
16421664
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+
16431678/// Return a SAM formatting string containing a BAM tag
16441679/** @param b Pointer to the bam record
16451680 @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
17511786HTSLIB_EXPORT
17521787int bam_aux_del (bam1_t * b , uint8_t * s );
17531788
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+
17541805/// Update or add a string-type tag
17551806/* @param b The bam record to update
17561807 @param tag Tag identifier
0 commit comments