-
Notifications
You must be signed in to change notification settings - Fork 3
/
candidate_region_extractor.h
143 lines (118 loc) · 4.18 KB
/
candidate_region_extractor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* The MIT License
Copyright (c) 2015 Adrian Tan <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef CANDIDATE_REGION_EXTRACTOR_H
#define CANDIDATE_REGION_EXTRACTOR_H
#include "hts_utils.h"
#include "utils.h"
#include "ahmm.h"
#include "variant_manip.h"
#include "vntr.h"
#include "reference_sequence.h"
//modes for extracting candidate repeat region
#define REFERENCE 0
#define EXACT_LEFT_RIGHT_ALIGNMENT 1
#define FUZZY_LEFT_RIGHT_ALIGNMENT 2
/**
* Extract a candidate repeat region without knowledge of repeat unit.
*/
class CandidateRegionExtractor
{
public:
//optiona
bool debug;
///////
//tools
///////
VariantManip *vm;
ReferenceSequence* rs;
/**
* Constructor.
*/
CandidateRegionExtractor(std::string& ref_fasta_file, bool debug=false);
/**
* Destructor.
*/
~CandidateRegionExtractor();
/**
* Annotates VNTR characteristics.
* RU,RL,LFLANK,RFLANK,LFLANKPOS,RFLANKPOS,MOTIF_CONCORDANCE
*/
void annotate(bcf_hdr_t* h, bcf1_t* v, Variant& variant, std::string mode);
/**
* Pick candidate region.
*
* @mode - REFERENCE use refence field
* - ALLELE_EXACT by exact alignment
* - ALLELE_FUZZY by fuzzy alignment
*/
void pick_candidate_region(Variant& variant, int32_t mode, int32_t amode);
/**
* Chooses a phase of the motif that is appropriate for the alignment
*/
std::string choose_repeat_unit(std::string& ref, std::string& motif);
/**
* Trim alleles.
*/
void trim(int32_t& pos1, std::string& ref, std::string& alt);
/**
* Checks if a vntr is a homopolymer.
*/
bool is_homopolymer(bcf_hdr_t* h, bcf1_t* v);
/**
* Extract region to for motif discovery.
*/
void extract_regions_by_exact_alignment(Variant& variant);
/**
* Left align alleles.
*/
void left_align(std::string& chrom, int32_t& pos1, std::string& ref, std::string& alt);
/**
* Right align alleles.
*/
void right_align(std::string& chrom, int32_t& pos1, std::string& ref, std::string& alt);
/**
* Extract reference sequence region for motif discovery in a fuzzy fashion.
*/
void extract_regions_by_fuzzy_alignment(Variant& variant);
/**
* Fuzzy left align alleles allowing for mismatches and indels defined by penalty.
*
* @chrom - chromosome
* @pos1 - 1 based position
* @ref - reference sequence
* @alt - alternative sequence
* @penalty - mismatch/indels allowed
*
* Returns left aligned position.
*/
uint32_t fuzzy_left_align(std::string& chrom, int32_t pos1, std::string ref, std::string alt, uint32_t penalty);
/**
* Fuzzy right align alleles allowing for mismatches and indels defined by penalty.
*
* @chrom - chromosome
* @pos1 - 1 based position
* @ref - reference sequence
* @alt - alternative sequence
* @penalty - mismatch/indels allowed
*
* Returns right aligned position.
*/
uint32_t fuzzy_right_align(std::string& chrom, int32_t pos1, std::string ref, std::string alt, uint32_t penalty);
};
#endif