annotate PsiCLASS-1.0.2/samtools-0.1.19/misc/wgsim.c @ 0:903fc43d6227 draft default tip

Uploaded
author lsong10
date Fri, 26 Mar 2021 16:52:45 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
1 /* The MIT License
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
2
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
3 Copyright (c) 2008 Genome Research Ltd (GRL).
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
4 2011 Heng Li <lh3@live.co.uk>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
5
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
6 Permission is hereby granted, free of charge, to any person obtaining
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
7 a copy of this software and associated documentation files (the
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
8 "Software"), to deal in the Software without restriction, including
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
9 without limitation the rights to use, copy, modify, merge, publish,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
10 distribute, sublicense, and/or sell copies of the Software, and to
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
11 permit persons to whom the Software is furnished to do so, subject to
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
12 the following conditions:
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
13
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
14 The above copyright notice and this permission notice shall be
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
15 included in all copies or substantial portions of the Software.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
16
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
21 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
22 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
24 SOFTWARE.
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
25 */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
26
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
27 /* This program is separated from maq's read simulator with Colin
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
28 * Hercus' modification to allow longer indels. */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
29
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
30 #include <stdlib.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
31 #include <math.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
32 #include <time.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
33 #include <assert.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
34 #include <stdio.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
35 #include <unistd.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
36 #include <stdint.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
37 #include <ctype.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
38 #include <string.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
39 #include <zlib.h>
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
40 #include "kseq.h"
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
41 KSEQ_INIT(gzFile, gzread)
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
42
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
43 #define PACKAGE_VERSION "0.3.0"
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
44
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
45 const uint8_t nst_nt4_table[256] = {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
46 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
47 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
48 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5 /*'-'*/, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
49 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
50 4, 0, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
51 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
52 4, 0, 4, 1, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
53 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
54 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
55 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
56 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
57 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
58 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
59 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
60 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
61 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
62 };
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
63
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
64 /* Simple normal random number generator, copied from genran.c */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
65
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
66 double ran_normal()
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
67 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
68 static int iset = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
69 static double gset;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
70 double fac, rsq, v1, v2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
71 if (iset == 0) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
72 do {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
73 v1 = 2.0 * drand48() - 1.0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
74 v2 = 2.0 * drand48() - 1.0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
75 rsq = v1 * v1 + v2 * v2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
76 } while (rsq >= 1.0 || rsq == 0.0);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
77 fac = sqrt(-2.0 * log(rsq) / rsq);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
78 gset = v1 * fac;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
79 iset = 1;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
80 return v2 * fac;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
81 } else {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
82 iset = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
83 return gset;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
84 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
85 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
86
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
87 /* wgsim */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
88
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
89 enum muttype_t {NOCHANGE = 0, INSERT = 0x1000, SUBSTITUTE = 0xe000, DELETE = 0xf000};
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
90 typedef unsigned short mut_t;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
91 static mut_t mutmsk = (mut_t)0xf000;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
92
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
93 typedef struct {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
94 int l, m; /* length and maximum buffer size */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
95 mut_t *s; /* sequence */
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
96 } mutseq_t;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
97
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
98 static double ERR_RATE = 0.02;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
99 static double MUT_RATE = 0.001;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
100 static double INDEL_FRAC = 0.15;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
101 static double INDEL_EXTEND = 0.3;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
102 static double MAX_N_RATIO = 0.1;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
103
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
104 void wgsim_mut_diref(const kseq_t *ks, int is_hap, mutseq_t *hap1, mutseq_t *hap2)
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
105 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
106 int i, deleting = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
107 mutseq_t *ret[2];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
108
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
109 ret[0] = hap1; ret[1] = hap2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
110 ret[0]->l = ks->seq.l; ret[1]->l = ks->seq.l;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
111 ret[0]->m = ks->seq.m; ret[1]->m = ks->seq.m;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
112 ret[0]->s = (mut_t *)calloc(ks->seq.m, sizeof(mut_t));
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
113 ret[1]->s = (mut_t *)calloc(ks->seq.m, sizeof(mut_t));
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
114 for (i = 0; i != ks->seq.l; ++i) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
115 int c;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
116 c = ret[0]->s[i] = ret[1]->s[i] = (mut_t)nst_nt4_table[(int)ks->seq.s[i]];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
117 if (deleting) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
118 if (drand48() < INDEL_EXTEND) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
119 if (deleting & 1) ret[0]->s[i] |= DELETE;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
120 if (deleting & 2) ret[1]->s[i] |= DELETE;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
121 continue;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
122 } else deleting = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
123 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
124 if (c < 4 && drand48() < MUT_RATE) { // mutation
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
125 if (drand48() >= INDEL_FRAC) { // substitution
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
126 double r = drand48();
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
127 c = (c + (int)(r * 3.0 + 1)) & 3;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
128 if (is_hap || drand48() < 0.333333) { // hom
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
129 ret[0]->s[i] = ret[1]->s[i] = SUBSTITUTE|c;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
130 } else { // het
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
131 ret[drand48()<0.5?0:1]->s[i] = SUBSTITUTE|c;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
132 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
133 } else { // indel
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
134 if (drand48() < 0.5) { // deletion
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
135 if (is_hap || drand48() < 0.333333) { // hom-del
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
136 ret[0]->s[i] = ret[1]->s[i] = DELETE;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
137 deleting = 3;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
138 } else { // het-del
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
139 deleting = drand48()<0.5?1:2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
140 ret[deleting-1]->s[i] = DELETE;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
141 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
142 } else { // insertion
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
143 int num_ins = 0, ins = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
144 do {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
145 num_ins++;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
146 ins = (ins << 2) | (int)(drand48() * 4.0);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
147 } while (num_ins < 4 && drand48() < INDEL_EXTEND);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
148
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
149 if (is_hap || drand48() < 0.333333) { // hom-ins
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
150 ret[0]->s[i] = ret[1]->s[i] = (num_ins << 12) | (ins << 4) | c;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
151 } else { // het-ins
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
152 ret[drand48()<0.5?0:1]->s[i] = (num_ins << 12) | (ins << 4) | c;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
153 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
154 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
155 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
156 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
157 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
158 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
159 void wgsim_print_mutref(const char *name, const kseq_t *ks, mutseq_t *hap1, mutseq_t *hap2)
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
160 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
161 int i;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
162 for (i = 0; i != ks->seq.l; ++i) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
163 int c[3];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
164 c[0] = nst_nt4_table[(int)ks->seq.s[i]];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
165 c[1] = hap1->s[i]; c[2] = hap2->s[i];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
166 if (c[0] >= 4) continue;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
167 if ((c[1] & mutmsk) != NOCHANGE || (c[2] & mutmsk) != NOCHANGE) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
168 printf("%s\t%d\t", name, i+1);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
169 if (c[1] == c[2]) { // hom
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
170 if ((c[1]&mutmsk) == SUBSTITUTE) { // substitution
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
171 printf("%c\t%c\t-\n", "ACGTN"[c[0]], "ACGTN"[c[1]&0xf]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
172 } else if ((c[1]&mutmsk) == DELETE) { // del
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
173 printf("%c\t-\t-\n", "ACGTN"[c[0]]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
174 } else if (((c[1] & mutmsk) >> 12) <= 5) { // ins
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
175 printf("-\t");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
176 int n = (c[1]&mutmsk) >> 12, ins = c[1] >> 4;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
177 while (n > 0) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
178 putchar("ACGTN"[ins & 0x3]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
179 ins >>= 2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
180 n--;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
181 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
182 printf("\t-\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
183 } else assert(0);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
184 } else { // het
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
185 if ((c[1]&mutmsk) == SUBSTITUTE || (c[2]&mutmsk) == SUBSTITUTE) { // substitution
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
186 printf("%c\t%c\t+\n", "ACGTN"[c[0]], "XACMGRSVTWYHKDBN"[1<<(c[1]&0x3)|1<<(c[2]&0x3)]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
187 } else if ((c[1]&mutmsk) == DELETE) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
188 printf("%c\t-\t+\n", "ACGTN"[c[0]]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
189 } else if ((c[2]&mutmsk) == DELETE) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
190 printf("%c\t-\t+\n", "ACGTN"[c[0]]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
191 } else if (((c[1] & mutmsk) >> 12) <= 4) { // ins1
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
192 printf("-\t");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
193 int n = (c[1]&mutmsk) >> 12, ins = c[1] >> 4;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
194 while (n > 0) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
195 putchar("ACGTN"[ins & 0x3]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
196 ins >>= 2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
197 n--;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
198 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
199 printf("\t+\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
200 } else if (((c[2] & mutmsk) >> 12) <= 5) { // ins2
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
201 printf("-\t");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
202 int n = (c[2]&mutmsk) >> 12, ins = c[2] >> 4;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
203 while (n > 0) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
204 putchar("ACGTN"[ins & 0x3]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
205 ins >>= 2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
206 n--;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
207 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
208 printf("\t+\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
209 } else assert(0);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
210 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
211 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
212 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
213 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
214
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
215 void wgsim_core(FILE *fpout1, FILE *fpout2, const char *fn, int is_hap, uint64_t N, int dist, int std_dev, int size_l, int size_r)
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
216 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
217 kseq_t *ks;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
218 mutseq_t rseq[2];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
219 gzFile fp_fa;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
220 uint64_t tot_len, ii;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
221 int i, l, n_ref;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
222 char *qstr;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
223 int size[2], Q, max_size;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
224 uint8_t *tmp_seq[2];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
225 mut_t *target;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
226
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
227 l = size_l > size_r? size_l : size_r;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
228 qstr = (char*)calloc(l+1, 1);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
229 tmp_seq[0] = (uint8_t*)calloc(l+2, 1);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
230 tmp_seq[1] = (uint8_t*)calloc(l+2, 1);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
231 size[0] = size_l; size[1] = size_r;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
232 max_size = size_l > size_r? size_l : size_r;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
233
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
234 Q = (ERR_RATE == 0.0)? 'I' : (int)(-10.0 * log(ERR_RATE) / log(10.0) + 0.499) + 33;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
235
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
236 fp_fa = gzopen(fn, "r");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
237 ks = kseq_init(fp_fa);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
238 tot_len = n_ref = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
239 fprintf(stderr, "[%s] calculating the total length of the reference sequence...\n", __func__);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
240 while ((l = kseq_read(ks)) >= 0) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
241 tot_len += l;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
242 ++n_ref;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
243 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
244 fprintf(stderr, "[%s] %d sequences, total length: %llu\n", __func__, n_ref, (long long)tot_len);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
245 kseq_destroy(ks);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
246 gzclose(fp_fa);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
247
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
248 fp_fa = gzopen(fn, "r");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
249 ks = kseq_init(fp_fa);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
250 while ((l = kseq_read(ks)) >= 0) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
251 uint64_t n_pairs = (uint64_t)((long double)l / tot_len * N + 0.5);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
252 if (l < dist + 3 * std_dev) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
253 fprintf(stderr, "[%s] skip sequence '%s' as it is shorter than %d!\n", __func__, ks->name.s, dist + 3 * std_dev);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
254 continue;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
255 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
256
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
257 // generate mutations and print them out
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
258 wgsim_mut_diref(ks, is_hap, rseq, rseq+1);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
259 wgsim_print_mutref(ks->name.s, ks, rseq, rseq+1);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
260
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
261 for (ii = 0; ii != n_pairs; ++ii) { // the core loop
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
262 double ran;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
263 int d, pos, s[2], is_flip = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
264 int n_sub[2], n_indel[2], n_err[2], ext_coor[2], j, k;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
265 FILE *fpo[2];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
266
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
267 do { // avoid boundary failure
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
268 ran = ran_normal();
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
269 ran = ran * std_dev + dist;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
270 d = (int)(ran + 0.5);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
271 d = d > max_size? d : max_size;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
272 pos = (int)((l - d + 1) * drand48());
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
273 } while (pos < 0 || pos >= ks->seq.l || pos + d - 1 >= ks->seq.l);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
274
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
275 // flip or not
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
276 if (drand48() < 0.5) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
277 fpo[0] = fpout1; fpo[1] = fpout2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
278 s[0] = size[0]; s[1] = size[1];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
279 } else {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
280 fpo[1] = fpout1; fpo[0] = fpout2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
281 s[1] = size[0]; s[0] = size[1];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
282 is_flip = 1;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
283 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
284
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
285 // generate the read sequences
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
286 target = rseq[drand48()<0.5?0:1].s; // haplotype from which the reads are generated
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
287 n_sub[0] = n_sub[1] = n_indel[0] = n_indel[1] = n_err[0] = n_err[1] = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
288
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
289 #define __gen_read(x, start, iter) do { \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
290 for (i = (start), k = 0, ext_coor[x] = -10; i >= 0 && i < ks->seq.l && k < s[x]; iter) { \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
291 int c = target[i], mut_type = c & mutmsk; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
292 if (ext_coor[x] < 0) { \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
293 if (mut_type != NOCHANGE && mut_type != SUBSTITUTE) continue; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
294 ext_coor[x] = i; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
295 } \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
296 if (mut_type == DELETE) ++n_indel[x]; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
297 else if (mut_type == NOCHANGE || mut_type == SUBSTITUTE) { \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
298 tmp_seq[x][k++] = c & 0xf; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
299 if (mut_type == SUBSTITUTE) ++n_sub[x]; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
300 } else { \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
301 int n, ins; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
302 ++n_indel[x]; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
303 tmp_seq[x][k++] = c & 0xf; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
304 for (n = mut_type>>12, ins = c>>4; n > 0 && k < s[x]; --n, ins >>= 2) \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
305 tmp_seq[x][k++] = ins & 0x3; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
306 } \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
307 } \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
308 if (k != s[x]) ext_coor[x] = -10; \
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
309 } while (0)
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
310
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
311 __gen_read(0, pos, ++i);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
312 __gen_read(1, pos + d - 1, --i);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
313 for (k = 0; k < s[1]; ++k) tmp_seq[1][k] = tmp_seq[1][k] < 4? 3 - tmp_seq[1][k] : 4; // complement
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
314 if (ext_coor[0] < 0 || ext_coor[1] < 0) { // fail to generate the read(s)
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
315 --ii;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
316 continue;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
317 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
318
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
319 // generate sequencing errors
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
320 for (j = 0; j < 2; ++j) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
321 int n_n = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
322 for (i = 0; i < s[j]; ++i) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
323 int c = tmp_seq[j][i];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
324 if (c >= 4) { // actually c should be never larger than 4 if everything is correct
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
325 c = 4;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
326 ++n_n;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
327 } else if (drand48() < ERR_RATE) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
328 // c = (c + (int)(drand48() * 3.0 + 1)) & 3; // random sequencing errors
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
329 c = (c + 1) & 3; // recurrent sequencing errors
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
330 ++n_err[j];
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
331 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
332 tmp_seq[j][i] = c;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
333 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
334 if ((double)n_n / s[j] > MAX_N_RATIO) break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
335 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
336 if (j < 2) { // too many ambiguous bases on one of the reads
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
337 --ii;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
338 continue;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
339 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
340
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
341 // print
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
342 for (j = 0; j < 2; ++j) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
343 for (i = 0; i < s[j]; ++i) qstr[i] = Q;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
344 qstr[i] = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
345 fprintf(fpo[j], "@%s_%u_%u_%d:%d:%d_%d:%d:%d_%llx/%d\n", ks->name.s, ext_coor[0]+1, ext_coor[1]+1,
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
346 n_err[0], n_sub[0], n_indel[0], n_err[1], n_sub[1], n_indel[1],
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
347 (long long)ii, j==0? is_flip+1 : 2-is_flip);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
348 for (i = 0; i < s[j]; ++i)
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
349 fputc("ACGTN"[(int)tmp_seq[j][i]], fpo[j]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
350 fprintf(fpo[j], "\n+\n%s\n", qstr);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
351 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
352 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
353 free(rseq[0].s); free(rseq[1].s);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
354 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
355 kseq_destroy(ks);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
356 gzclose(fp_fa);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
357 free(qstr);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
358 free(tmp_seq[0]); free(tmp_seq[1]);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
359 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
360
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
361 static int simu_usage()
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
362 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
363 fprintf(stderr, "\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
364 fprintf(stderr, "Program: wgsim (short read simulator)\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
365 fprintf(stderr, "Version: %s\n", PACKAGE_VERSION);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
366 fprintf(stderr, "Contact: Heng Li <lh3@sanger.ac.uk>\n\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
367 fprintf(stderr, "Usage: wgsim [options] <in.ref.fa> <out.read1.fq> <out.read2.fq>\n\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
368 fprintf(stderr, "Options: -e FLOAT base error rate [%.3f]\n", ERR_RATE);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
369 fprintf(stderr, " -d INT outer distance between the two ends [500]\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
370 fprintf(stderr, " -s INT standard deviation [50]\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
371 fprintf(stderr, " -N INT number of read pairs [1000000]\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
372 fprintf(stderr, " -1 INT length of the first read [70]\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
373 fprintf(stderr, " -2 INT length of the second read [70]\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
374 fprintf(stderr, " -r FLOAT rate of mutations [%.4f]\n", MUT_RATE);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
375 fprintf(stderr, " -R FLOAT fraction of indels [%.2f]\n", INDEL_FRAC);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
376 fprintf(stderr, " -X FLOAT probability an indel is extended [%.2f]\n", INDEL_EXTEND);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
377 fprintf(stderr, " -S INT seed for random generator [-1]\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
378 fprintf(stderr, " -h haplotype mode\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
379 fprintf(stderr, "\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
380 return 1;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
381 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
382
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
383 int main(int argc, char *argv[])
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
384 {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
385 int64_t N;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
386 int dist, std_dev, c, size_l, size_r, is_hap = 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
387 FILE *fpout1, *fpout2;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
388 int seed = -1;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
389
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
390 N = 1000000; dist = 500; std_dev = 50;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
391 size_l = size_r = 70;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
392 while ((c = getopt(argc, argv, "e:d:s:N:1:2:r:R:hX:S:")) >= 0) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
393 switch (c) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
394 case 'd': dist = atoi(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
395 case 's': std_dev = atoi(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
396 case 'N': N = atoi(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
397 case '1': size_l = atoi(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
398 case '2': size_r = atoi(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
399 case 'e': ERR_RATE = atof(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
400 case 'r': MUT_RATE = atof(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
401 case 'R': INDEL_FRAC = atof(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
402 case 'X': INDEL_EXTEND = atof(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
403 case 'S': seed = atoi(optarg); break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
404 case 'h': is_hap = 1; break;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
405 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
406 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
407 if (argc - optind < 3) return simu_usage();
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
408 fpout1 = fopen(argv[optind+1], "w");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
409 fpout2 = fopen(argv[optind+2], "w");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
410 if (!fpout1 || !fpout2) {
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
411 fprintf(stderr, "[wgsim] file open error\n");
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
412 return 1;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
413 }
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
414 srand48(seed > 0? seed : time(0));
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
415 wgsim_core(fpout1, fpout2, argv[optind], is_hap, N, dist, std_dev, size_l, size_r);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
416
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
417 fclose(fpout1); fclose(fpout2);
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
418 return 0;
903fc43d6227 Uploaded
lsong10
parents:
diff changeset
419 }