2 Copyright (C) 2017 Genome Research Ltd.
4 Author: Petr Danecek <pd3@sanger.ac.uk>
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 Reorder duplicate lines so that compatible variant types are
27 returned together by bcf_sr_next_line()
29 - readers grouped by variants. Even with many readers there will be
30 typically only several groups
34 #ifndef __BCF_SR_SORT_H__
35 #define __BCF_SR_SORT_H__
37 #include "htslib/synced_bcf_reader.h"
38 #include "htslib/kbitset.h"
49 char *str
; // "A>C" for biallelic records or "A>C,A>CC" for multiallelic records
50 int type
; // VCF_SNP, VCF_REF, etc.
51 int nalt
; // number of alternate alleles in this record
52 int nvcf
, mvcf
, *vcf
; // the list of readers with the same variants
53 bcf1_t
**rec
; // list of VCF records in the readers
54 kbitset_t
*mask
; // which groups contain the variant
60 char *key
; // only for debugging
61 int nvar
, mvar
, *var
; // the variants and their type
62 int nvcf
; // number of readers with the same variants
68 int nvar
, mvar
, *var
; // list of compatible variants that can be output together
69 int cnt
; // number of readers in this group
70 kbitset_t
*mask
; // which groups are populated in this set (replace with expandable bitmask)
78 var_t
*var
; // list of all variants from all readers
80 int mpmat
, *pmat
; // pairing matrix, i-th vset and j-th group accessible as i*ngrp+j
82 int mcnt
, *cnt
; // number of VCF covered by a varset
83 grp_t
*grp
; // list of VCF representatives, each with a unique combination of duplicate lines
84 varset_t
*vset
; // list of variant sets - combinations of compatible variants across multiple groups ready for output
85 vcf_buf_t
*vcf_buf
; // records sorted in output order, for each VCF
90 int moff
, noff
, *off
, mcharp
;
98 sr_sort_t
*bcf_sr_sort_init(sr_sort_t
*srt
);
99 int bcf_sr_sort_next(bcf_srs_t
*readers
, sr_sort_t
*srt
, const char *chr
, int pos
);
100 void bcf_sr_sort_destroy(sr_sort_t
*srt
);
101 void bcf_sr_sort_remove_reader(bcf_srs_t
*readers
, sr_sort_t
*srt
, int i
);