44 static bool get_end_position(
uint32 *out,
char *info)
50 sc = strchr(info,
';');
58 eq = strchr(info,
'=');
69 if (strcmp(info,
"END") == 0)
73 uint32 position = strtoll(eq + 1, &endptr, 10);
74 if (!endptr || endptr == eq || *endptr !=
'\0')
89 }
while (info && *info);
107 char *comment = strchr(line,
'#');
112 while (*line ==
' ' || *line ==
'\t' || *line ==
'\r')
134 #define NEXT(prev, next) \
138 next = strchr(prev, '\t'); \
156 if (!chrom || !pos || !
id || !ref || !alt || !qual || !filter)
158 log_error(stderr,
"Error parsing VCF file (line %d): incomplete variant\n", line_counter);
166 uint32 position = strtoll(pos, &endptr, 10);
167 if (!endptr || endptr == pos || *endptr !=
'\0')
169 log_error(stderr,
"VCF file error (line %d): invalid position\n", line_counter);
178 quality = (
uint8) strtol(qual, &endptr, 10);
179 if (!endptr || endptr == qual || *endptr !=
'\0')
181 log_warning(stderr,
"VCF file error (line %d): invalid quality\n", line_counter);
186 uint32 stop = position + strlen(ref);
191 ret = get_end_position(&stop, info);
194 log_warning(stderr,
"VCF file error (line %d): error parsing INFO line\n", line_counter);
201 char *next_base = strchr(alt,
',');
208 if (strcmp(alt,
".") == 0)
213 const uint32 ref_len = strlen(ref);
214 const uint32 var_len = strlen(var);
226 output.
variants.resize(index.variant_start + var_len);
235 }
while (alt && *alt !=
'\0');