| 1 | /* convert.h -- functions for converting between VCF/BCF and related formats. |
| 2 | |
| 3 | Copyright (C) 2014-2024 Genome Research Ltd. |
| 4 | |
| 5 | Author: Petr Danecek <[email protected]> |
| 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 | #ifndef __CONVERT_H__ |
| 26 | #define __CONVERT_H__ |
| 27 | |
| 28 | #include <htslib/vcf.h> |
| 29 | |
| 30 | typedef struct _convert_t convert_t; |
| 31 | enum convert_option |
| 32 | { |
| 33 | allow_undef_tags, // see `bcftools query --allow-undef-tags`, throws an error if tag is not defined otherwise |
| 34 | subset_samples, // in bracketed expressions (e.g. [ %GT]) consider only marked samples |
| 35 | header_samples, // include sample name in bracketed tags (e.g. SAMPLE1:GT SAMPLE2:GT for [ %GT]) |
| 36 | force_newline, // automatically insert a newline when not part of the formatting expression |
| 37 | print_filtered, // print the provided string instead of discarding samples not included in subset_samples |
| 38 | no_hdr_indices, // drop column indices when printing header, i.e. "#CHROM", not "#[1]CHROM" |
| 39 | }; |
| 40 | |
| 41 | convert_t *convert_init(bcf_hdr_t *hdr, int *samples, int nsamples, const char *str); |
| 42 | void convert_destroy(convert_t *convert); |
| 43 | int convert_set_option(convert_t *convert, enum convert_option opt, ...); |
| 44 | int convert_header(convert_t *convert, kstring_t *str); |
| 45 | int convert_line(convert_t *convert, bcf1_t *rec, kstring_t *str); |
| 46 | int convert_max_unpack(convert_t *convert); |
| 47 | int convert_is_tag_used(convert_t *convert, char *tag); |
| 48 | const char **convert_list_used_tags(convert_t *convert, int *ntags); |
| 49 | |
| 50 | #endif |
| 51 |