Skip to content

Commit b97bd57

Browse files
author
Yan Gao
committed
v1.5.0
1 parent b388c42 commit b97bd57

4 files changed

Lines changed: 73 additions & 32 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
README.html
12
# simulation file
23
simu/pbsim/*
34
simu/*

README.md

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
[![GitHub Downloads](https://img.shields.io/github/downloads/yangao07/TideHunter/total.svg?style=social&logo=github&label=Download)](https://github.com/yangao07/TideHunter/releases)
1111
-->
1212

13-
## Updates (v1.4.4)
14-
* Skip N bases in the input sequences
13+
## Updates (v1.5.0)
14+
* Output fastq format
1515

1616

1717
## Getting started
1818
Download the [latest release](https://github.com/yangao07/TideHunter/releases):
1919
```
20-
wget https://github.com/yangao07/TideHunter/releases/download/v1.4.4/TideHunter-v1.4.4.tar.gz
21-
tar -zxvf TideHunter-v1.4.4.tar.gz && cd TideHunter-v1.4.4
20+
wget https://github.com/yangao07/TideHunter/releases/download/v1.5.0/TideHunter-v1.5.0.tar.gz
21+
tar -zxvf TideHunter-v1.5.0.tar.gz && cd TideHunter-v1.5.0
2222
```
2323
Make from source and run with test data:
2424
```
@@ -38,8 +38,9 @@ TideHunter ./test_data/test_50x4.fa > cons.fa
3838
- [Pre-built binary executable file for Linux/Unix](#binary)
3939
- [Getting started with toy example in `test_data`](#start)
4040
- [Usage](#usage)
41-
- [To generate consensus sequencesin FASTA format](#fasta_cons)
42-
- [To generate consensus sequencesin tabular format](#tab_cons)
41+
- [To generate consensus sequences in FASTA format](#fasta_cons)
42+
- [To generate consensus sequences in tabular format](#tab_cons)
43+
- [To generate consensus sequences in FASTQ format](#fq_cons)
4344
- [To generate full-length consensus sequences](#full_cons)
4445
- [To generate unit sequences in FASTA format](#fasta_unit)
4546
- [To generate unit sequences in tabular format](#tab_unit)
@@ -49,6 +50,7 @@ TideHunter ./test_data/test_50x4.fa > cons.fa
4950
- [Output](#output)
5051
- [Tabular format](#tabular)
5152
- [FASTA format](#fasta)
53+
- [FASTQ format](#fastq)
5254
- [Unit sequences](#unit)
5355
- [Contact](#contact)
5456

@@ -76,9 +78,9 @@ Make sure you have gcc (>=6.4.0) and zlib installed before compiling.
7678
It is recommended to download the latest release of TideHunter
7779
from the [release page](https://github.com/yangao07/TideHunter/releases).
7880
```
79-
wget https://github.com/yangao07/TideHunter/releases/download/v1.4.4/TideHunter-v1.4.4.tar.gz
80-
tar -zxvf TideHunter-v1.4.4.tar.gz
81-
cd TideHunter-v1.4.4; make
81+
wget https://github.com/yangao07/TideHunter/releases/download/v1.5.0/TideHunter-v1.5.0.tar.gz
82+
tar -zxvf TideHunter-v1.5.0.tar.gz
83+
cd TideHunter-v1.5.0; make
8284
```
8385
Or, you can use `git clone` command to download the source code.
8486
Don't forget to include the `--recursive` to download the codes of [abPOA](https://github.com/yangao07/abPOA).
@@ -91,8 +93,8 @@ cd TideHunter; make
9193
### <a name="binary"></a>Pre-built binary executable file for Linux/Unix
9294
If you meet any compiling issue, please try the pre-built binary file:
9395
```
94-
wget https://github.com/yangao07/TideHunter/releases/download/v1.4.4/TideHunter-v1.4.4_x64-linux.tar.gz
95-
tar -zxvf TideHunter-v1.4.4_x64-linux.tar.gz
96+
wget https://github.com/yangao07/TideHunter/releases/download/v1.5.0/TideHunter-v1.5.0_x64-linux.tar.gz
97+
tar -zxvf TideHunter-v1.5.0_x64-linux.tar.gz
9698
```
9799

98100
## <a name="start"></a>Getting started with toy example in `test_data`
@@ -109,6 +111,10 @@ TideHunter ./test_data/test_1000x10.fa > cons.fa
109111
```
110112
TideHunter -f 2 ./test_data/test_1000x10.fa > cons.out
111113
```
114+
#### <a name="fq_cons"></a>To generate consensus sequences in FASTQ format
115+
```
116+
TideHunter -f 3 ./test_data/test_1000x10.fa > cons.fq
117+
```
112118
#### <a name="full_cons"></a>To generate full-length consensus sequences
113119
```
114120
TideHunter -5 ./test_data/5prime.fa -3 ./test_data/3prime.fa ./test_data/full_length.fa > cons_full.fa
@@ -150,13 +156,18 @@ Options:
150156
-a --ada-mat-rat FLT minimum match ratio of adapter sequence [0.80]
151157
Output:
152158
-o --output STR output file [stdout]
153-
-m --min-len [INT] only output consensus sequence with min. length of [30]
159+
-m --min-len INT only output consensus sequence with min. length of [30]
160+
-r --min-cov FLOAT|INT only output consensus sequence with at least R supporting units for all bases: [0.00]
161+
if r is fraction: R = r * total copy number
162+
if r is integer: R = r
154163
-u --unit-seq only output unit sequences of each tandem repeat, no consensus sequence [False]
155164
-l --longest only output consensus sequence of tandem repeat that covers the longest read sequence [False]
156165
-F --full-len only output full-length consensus sequence [False]
157166
-f --out-fmt INT output format [1]
158167
- 1: FASTA
159168
- 2: Tabular
169+
- 3: FASTQ
170+
qualiy score of each base represents the ratio of the consensus coverage to the # total copies.
160171
Computing resource:
161172
-t --thread INT number of threads to use [4]
162173
@@ -222,6 +233,35 @@ The read name and comment of each consensus sequence have the following format:
222233
>readName_repN_copyNum readLen_start_end_consLen_aveMatch_fullLen_subPos
223234
```
224235

236+
### <a name="fastq"></a>FASTQ format
237+
For FASTQ output format, the read name and comment are the same as described in [FASTA format](#fasta).
238+
TideHunter calculated a customized Phred score as the base quality score of each consensus base:
239+
240+
<p align="center">
241+
<img src="https://latex.codecogs.com/svg.image?Q_{phred}=-10 \cdot log_{10}(p)"/>
242+
<!-- <img src="https://render.githubusercontent.com/render/math?math=Q_{phred}=-10 \cdot log_{10}(p)"> -->
243+
</p>
244+
245+
Here, <img src="https://latex.codecogs.com/svg.image?p"/> is the Sigmoid-smoothed consensus calling error rate for each base:
246+
247+
<p align="center">
248+
<!-- <img src="https://render.githubusercontent.com/render/math?math=p=1-S(N_{cons} / N_{total} \cdot 21)">, -->
249+
<img src="https://latex.codecogs.com/svg.image?p=1-S(13.8 \cdot (1.25 \cdot N_{cons} / N_{total} - 0.25))"/>
250+
</p>
251+
252+
<img src="https://latex.codecogs.com/svg.image?S"/> is the Sigmoid function:
253+
<p align="center">
254+
<img src="https://latex.codecogs.com/svg.image?S(x)=\frac{1}{1+e^{-x}}"/>
255+
</p>
256+
257+
<img src="https://latex.codecogs.com/svg.image?N_{cons}"/> is the coverage of the consensus base and
258+
<img src="https://latex.codecogs.com/svg.image?N_{total}"/> is the number of total copies.
259+
For example, if one base of the consensus sequence has 4 supporting copies and the total copy number is 5,
260+
<img src="https://latex.codecogs.com/svg.image?N_{cons}"/> is 4 and <img src="https://latex.codecogs.com/svg.image?N_{total}"/> is 5.
261+
262+
The Phred quality score was then shifted by 33 and converted to characters based on the ASCII value.
263+
The quality scores range from 0 to 60 and the corresponding ASCII values range from 33 to 93.
264+
225265
### <a name="unit"></a>Unit sequences
226266
TideHunter can output the unit sequences without performing the consensus calling step when option `-u/--unit-seq` is enabled. Then, only the following information will be output for the tabular format:
227267

src/abpoa_cons.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
#include "seq.h"
88
#include "abpoa.h"
99

10+
#define NAT_E 2.718281828459045
11+
1012
abpoa_para_t *mt_abpoa_init_para(mini_tandem_para *mtp) {
1113
abpoa_para_t *abpt = abpoa_init_para();
12-
// abpt->cons_agrm = 1; // 0: HB, 1: RC
14+
abpt->cons_agrm = 1; // 0: HB, 1: RC
1315
abpt->match = mtp->match; // match score
1416
abpt->mismatch = mtp->mismatch; // mismatch penalty
1517
abpt->gap_open1 = mtp->gap_open1; // first gap open penalty
@@ -26,7 +28,7 @@ abpoa_para_t *mt_abpoa_init_para(mini_tandem_para *mtp) {
2628
}
2729

2830
int abpoa_gen_cons(abpoa_t *ab, abpoa_para_t *abpt, uint8_t *bseqs, int seq_len, int *pos, int pos_n, uint8_t *cons_bseq, uint8_t *cons_qual, int min_cov) {
29-
int i, seq_n, cons_len = 0;
31+
int i, n_seqs, cons_len = 0;
3032

3133
/* clean graph if it is re-used */
3234
abpoa_reset_graph(ab, abpt, seq_len);
@@ -35,31 +37,28 @@ int abpoa_gen_cons(abpoa_t *ab, abpoa_para_t *abpt, uint8_t *bseqs, int seq_len,
3537
uint8_t **_bseqs = (uint8_t**)malloc(sizeof(uint8_t*) * (pos_n-1));
3638
/* main graph alignment */
3739
// |pos|-----|pos|-----pos|
38-
for (i = seq_n = 0; i < pos_n-1; ++i) {
40+
for (i = n_seqs = 0; i < pos_n-1; ++i) {
3941
int start = pos[i], end = pos[i+1];
4042
if (start < 0 || end < 0 || start >= seq_len || end+1 >= seq_len) continue;
4143
// fprintf(stdout, ">%d\n", start);
42-
seq_lens[seq_n] = end - start;
43-
_bseqs[seq_n] = bseqs + start + 1;
44-
/*int j;
45-
for (j = start; j < end; ++j)
46-
fprintf(stdout, "%c", "ACGT"[bseqs[j+1]]);
47-
fprintf(stdout, "\n");*/
48-
++seq_n;
44+
seq_lens[n_seqs] = end - start;
45+
_bseqs[n_seqs] = bseqs + start + 1;
46+
/*int j; for (j = start; j < end; ++j) fprintf(stdout, "%c", "ACGT"[bseqs[j+1]]); fprintf(stdout, "\n");*/
47+
++n_seqs;
4948
}
5049
#ifdef __DEBUG__
5150
FILE *outfp = stderr;
5251
#else
5352
FILE *outfp = NULL;
5453
#endif
55-
if (seq_n <= 2) {
56-
if (seq_n == 0) err_fatal_simple("No enough sequences to perform msa.\n");
54+
if (n_seqs <= 2) {
55+
if (n_seqs == 0) err_fatal_simple("No enough sequences to perform msa.\n");
5756
cons_len = seq_lens[0];
5857
for (i = 0; i < cons_len; ++i) cons_bseq[i] = _bseqs[0][i];
5958
} else {
6059
uint8_t **_cons_bseq; int **_cons_cov, *_cons_l, _cons_n = 0;
61-
if (min_cov > 0 || cons_qual != NULL) abpoa_msa(ab, abpt, seq_n, NULL, seq_lens, _bseqs, outfp, &_cons_bseq, &_cons_cov, &_cons_l, &_cons_n, NULL, NULL);
62-
else abpoa_msa(ab, abpt, seq_n, NULL, seq_lens, _bseqs, outfp, &_cons_bseq, NULL, &_cons_l, &_cons_n, NULL, NULL);
60+
if (min_cov > 0 || cons_qual != NULL) abpoa_msa(ab, abpt, n_seqs, NULL, seq_lens, _bseqs, outfp, &_cons_bseq, &_cons_cov, &_cons_l, &_cons_n, NULL, NULL);
61+
else abpoa_msa(ab, abpt, n_seqs, NULL, seq_lens, _bseqs, outfp, &_cons_bseq, NULL, &_cons_l, &_cons_n, NULL, NULL);
6362
if (_cons_n == 1) {
6463
cons_len = _cons_l[0];
6564
int skip = 0;
@@ -72,10 +71,12 @@ int abpoa_gen_cons(abpoa_t *ab, abpoa_para_t *abpt, uint8_t *bseqs, int seq_len,
7271
}
7372
}
7473
if (cons_qual != NULL) {
75-
int phred;
74+
int phred; double x, p;
7675
for (i = 0; i < cons_len; ++i) {
77-
if (_cons_cov[0][i] == seq_n) phred = 73;
78-
else phred = 33 + (int)(-10 * log10((seq_n-_cons_cov[0][i]+0.0) / seq_n));
76+
// min: 0+33=33, max: 60+33=93
77+
x = 13.8 * (1.25 * _cons_cov[0][i] / n_seqs - 0.25);
78+
p = 1 - 1.0 / (1.0 + pow(NAT_E, -1 * x));
79+
phred = 33 + (int)(-10 * log10(p) + 0.499);
7980
cons_qual[i] = phred;
8081
}
8182
}

src/main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "kseq.h"
1111

1212
const char PROG[20] = "TideHunter";
13-
const char VERSION[20] = "1.4.4";
13+
const char VERSION[20] = "1.5.0";
1414
const char CONTACT[30] = "gaoy286@mail.sysu.edu.cn";
1515

1616
const struct option mini_tandem_opt [] = {
@@ -114,7 +114,7 @@ static int usage(void)
114114
err_printf(" -o --output STR output file [stdout]\n");
115115
err_printf(" -m --min-len INT only output consensus sequence with min. length of [%d]\n", DEF_MIN_LEN);
116116
err_printf(" -r --min-cov FLOAT|INT only output consensus sequence with at least \e[4mR\e[0m supporting units for all bases: [%.2f]\n", DEF_MIN_COV);
117-
err_printf(" if \e[4mr\e[0m is fraction: \e[4mR\e[0m = \e[4mr\e[0m * copy number\n");
117+
err_printf(" if \e[4mr\e[0m is fraction: \e[4mR\e[0m = \e[4mr\e[0m * total copy number\n");
118118
err_printf(" if \e[4mr\e[0m is integer: \e[4mR\e[0m = \e[4mr\e[0m\n");
119119
err_printf(" -u --unit-seq only output unit sequences of each tandem repeat, no consensus sequence [False]\n");
120120
err_printf(" -l --longest only output consensus sequence of tandem repeat that covers the longest read sequence [False]\n");
@@ -431,7 +431,6 @@ int mini_tandem(const char *read_fn, mini_tandem_para *mtp)
431431
return 0;
432432
}
433433

434-
// TODO add score para
435434
int main(int argc, char *argv[])
436435
{
437436
mini_tandem_para *mtp = mini_tandem_init_para();

0 commit comments

Comments
 (0)