]> git.donarmstrong.com Git - samtools.git/blobdiff - bam.h
* samtools-0.1.8-19 (r777)
[samtools.git] / bam.h
diff --git a/bam.h b/bam.h
index b418dcd796a171bcdecd71381db6dded02b5ab3a..a8769e26a38c3dc62ee4ded2dc793a90884d19a3 100644 (file)
--- a/bam.h
+++ b/bam.h
@@ -1,6 +1,6 @@
 /* The MIT License
 
-   Copyright (c) 2008 Genome Research Ltd (GRL).
+   Copyright (c) 2008-2010 Genome Research Ltd (GRL).
 
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
@@ -190,7 +190,7 @@ typedef struct {
        uint8_t *data;
 } bam1_t;
 
-typedef struct __bam_iterf_t *bam_iterf_t;
+typedef struct __bam_iter_t *bam_iter_t;
 
 #define bam1_strand(b) (((b)->core.flag&BAM_FREVERSE) != 0)
 #define bam1_mstrand(b) (((b)->core.flag&BAM_FMREVERSE) != 0)
@@ -329,6 +329,7 @@ extern "C" {
          be destroyed in the first place.
         */
        int sam_header_parse(bam_header_t *h);
+       int32_t bam_get_tid(const bam_header_t *header, const char *seq_name);
 
        /*!
          @abstract       Parse @RG lines a update a header struct
@@ -454,6 +455,21 @@ extern "C" {
 
        char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of);
 
+       /*!
+         @abstract       Check whether a BAM record is plausibly valid
+         @param  header  associated header structure, or NULL if unavailable
+         @param  b       alignment to validate
+         @return         0 if the alignment is invalid; non-zero otherwise
+
+         @discussion  Simple consistency check of some of the fields of the
+         alignment record.  If the header is provided, several additional checks
+         are made.  Not all fields are checked, so a non-zero result is not a
+         guarantee that the record is valid.  However it is usually good enough
+         to detect when bam_seek() has been called with a virtual file offset
+         that is not the offset of an alignment record.
+        */
+       int bam_validate1(const bam_header_t *header, const bam1_t *b);
+
        const char *bam_get_library(bam_header_t *header, const bam1_t *b);
 
 
@@ -482,7 +498,7 @@ extern "C" {
                uint32_t is_del:1, is_head:1, is_tail:1;
        } bam_pileup1_t;
 
-       typedef int (*bam_plp_auto_f)(bam1_t *b, void *data);
+       typedef int (*bam_plp_auto_f)(void *data, bam1_t *b);
 
        struct __bam_plp_t;
        typedef struct __bam_plp_t *bam_plp_t;
@@ -594,9 +610,9 @@ extern "C" {
         */
        int bam_fetch(bamFile fp, const bam_index_t *idx, int tid, int beg, int end, void *data, bam_fetch_f func);
 
-       bam_iterf_t bam_iterf_query(const bam_index_t *idx, int tid, int beg, int end);
-       int bam_iterf_read(bamFile fp, bam_iterf_t iter, bam1_t *b);
-       void bam_iterf_destroy(bam_iterf_t iter);
+       bam_iter_t bam_iter_query(const bam_index_t *idx, int tid, int beg, int end);
+       int bam_iter_read(bamFile fp, bam_iter_t iter, bam1_t *b);
+       void bam_iter_destroy(bam_iter_t iter);
 
        /*!
          @abstract       Parse a region in the format: "chr2:100,000-200,000".