1 /* The MIT License 2 3 Copyright (c) 2021 Genome Research Ltd. 4 5 Author: Petr Danecek <pd3@sanger.ac.uk> 6 7 Permission is hereby granted, free of charge, to any person obtaining a copy 8 of this software and associated documentation files (the "Software"), to deal 9 in the Software without restriction, including without limitation the rights 10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 copies of the Software, and to permit persons to whom the Software is 12 furnished to do so, subject to the following conditions: 13 14 The above copyright notice and this permission notice shall be included in 15 all copies or substantial portions of the Software. 16 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 THE SOFTWARE. 24 25 */ 26 27 /* 28 Atomize/deatomize complex variants 29 */ 30 31 #ifndef __ABUF_H__ 32 #define __ABUF_H__ 33 34 #include <htslib/vcf.h> 35 36 typedef struct _abuf_t abuf_t; 37 38 // Modes of operation 39 typedef enum 40 { 41 NONE, 42 43 // mode of operation, to be passed to abuf_init 44 SPLIT, 45 JOIN, 46 47 BCF_HDR, // should the records be annotated, a writable bcf header is required 48 INFO_TAG, // set BCF_HDR first 49 STAR_ALLELE // 1: use STAR allele (the default), 0: set overlaps to missing 50 } 51 abuf_opt_t; 52 53 #define abuf_set_opt(buf,type,key,value) { type tmp = value; abuf_set(buf, key, (void*)&tmp); } 54 void abuf_set(abuf_t *buf, abuf_opt_t key, void *value); 55 56 /* 57 * abuf_init() - init buffer 58 * @win: number of sites (>0) or bp (<0) 59 */ 60 abuf_t *abuf_init(const bcf_hdr_t *hdr, abuf_opt_t mode); 61 void abuf_destroy(abuf_t *buf); 62 63 /* 64 * abuf_push() - Push a new site for analysis 65 */ 66 void abuf_push(abuf_t *buf, bcf1_t *rec); 67 68 /* 69 * abuf_flush() - Return next buffered record 70 * @flush_all: Set to 1 if no more overlapping records are coming (e.g. end of chromosome or end of file), 71 * the buffer can be emptied. 72 * return: The next atomized/deatomized VCF record or NULL if no record is ready. The returned 73 * structure will be cleaned by abuf. 74 */ 75 bcf1_t *abuf_flush(abuf_t *buf, int flush_all); 76 77 #endif 78 79