f749015964226458297282a66117dd0e6c84142c larrym Wed Jan 4 14:05:55 2012 -0800 add bamChromList diff --git src/inc/bamFile.h src/inc/bamFile.h index 01ce1e8..8ecc78c 100644 --- src/inc/bamFile.h +++ src/inc/bamFile.h @@ -18,30 +18,36 @@ #else // no USE_BAM typedef struct { } bam1_t; typedef struct { } bam_index_t; typedef struct { } samfile_t; typedef int (*bam_fetch_f)(const bam1_t *b, void *data); #define COMPILE_WITH_SAMTOOLS "%s: in order to use this functionality you must " \ "install the samtools library (<A HREF=\"http://samtools.sourceforge.net\" " \ "TARGET=_BLANK>http://samtools.sourceforge.net</A>) and recompile kent/src with " \ "USE_BAM=1 in your environment " \ "(see <A HREF=\"http://genomewiki.ucsc.edu/index.php/Build_Environment_Variables\" " \ "TARGET=_BLANK>http://genomewiki.ucsc.edu/index.php/Build_Environment_Variables</A>)." #endif // USE_BAM +struct bamChromInfo + { + struct bamChromInfo *next; + char *name; /* Chromosome name */ + bits32 size; /* Chromosome size in bases */ + }; boolean bamFileExists(char *bamFileName); /* Return TRUE if we can successfully open the bam file and its index file. */ samfile_t *bamOpen(char *fileOrUrl, char **retBamFileName); /* Return an open bam file as well as the filename of the bam. */ void bamFetchAlreadyOpen(samfile_t *samfile, bam_index_t *idx, char *bamFileName, char *position, bam_fetch_f callbackFunc, void *callbackData); /* With the open bam file, return items the same way with the callbacks as with bamFetch() */ /* except in this case use an already-open bam file and index (use bam_index_load and free() for */ /* the index). It seems a little strange to pass the filename in with the open bam, but */ /* it's just used to report errors. */ void bamFetch(char *fileOrUrl, char *position, bam_fetch_f callbackFunc, void *callbackData, @@ -120,16 +126,22 @@ bam1_t *bamClone(const bam1_t *bam); /* Return a newly allocated copy of bam. */ void bamShowTags(const bam1_t *bam); /* Print out tags in HTML: bold key, no type indicator for brevity. */ char *bamGetTagString(const bam1_t *bam, char *tag, char *buf, size_t bufSize); /* If bam's tags include the given 2-character tag, place the value into * buf (zero-terminated, trunc'd if nec) and return a pointer to buf, * or NULL if tag is not present. */ void bamUnpackAux(const bam1_t *bam, struct dyString *dy); /* Unpack the tag:type:val part of bam into dy */ +struct bamChromInfo *bamChromList(samfile_t *fh); +/* Return list of chromosomes from bam header. We normalize chromosome names to UCSC format. */ + +void bamChromInfoFreeList(struct bamChromInfo **pList); +/* Free a list of dynamically allocated bamChromInfo's */ + #endif//ndef BAMFILE_H