| 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 |
#include <config.h> |
| 26 |
|
| 27 |
#include <ctype.h> |
| 28 |
#include <string.h> |
| 29 |
#include <stdlib.h> |
| 30 |
#include <stdio.h> |
| 31 |
#include <stdint.h> |
| 32 |
#include <unistd.h> |
| 33 |
#include <stdarg.h> |
| 34 |
#include <htslib/sam.h> |
| 35 |
#include "samtools.h" |
| 36 |
|
| 37 |
static void usage(FILE *fp) |
| 38 |
{ |
| 39 |
static const struct { int bit; const char *desc; } *fl, flags[] = { |
| 40 |
{ BAM_FPAIRED, "paired-end / multiple-segment sequencing technology" }, |
| 41 |
{ BAM_FPROPER_PAIR, "each segment properly aligned according to aligner" }, |
| 42 |
{ BAM_FUNMAP, "segment unmapped" }, |
| 43 |
{ BAM_FMUNMAP, "next segment in the template unmapped" }, |
| 44 |
{ BAM_FREVERSE, "SEQ is reverse complemented" }, |
| 45 |
{ BAM_FMREVERSE, "SEQ of next segment in template is rev.complemented" }, |
| 46 |
{ BAM_FREAD1, "the first segment in the template" }, |
| 47 |
{ BAM_FREAD2, "the last segment in the template" }, |
| 48 |
{ BAM_FSECONDARY, "secondary alignment" }, |
| 49 |
{ BAM_FQCFAIL, "not passing quality controls or other filters" }, |
| 50 |
{ BAM_FDUP, "PCR or optical duplicate" }, |
| 51 |
{ BAM_FSUPPLEMENTARY, "supplementary alignment" }, |
| 52 |
{ 0, NULL } |
| 53 |
}; |
| 54 |
|
| 55 |
fprintf(fp, |
| 56 |
"About: Convert between textual and numeric flag representation\n" |
| 57 |
"Usage: samtools flags FLAGS...\n" |
| 58 |
"\n" |
| 59 |
"Each FLAGS argument is either an INT (in decimal/hexadecimal/octal) representing\n" |
| 60 |
"a combination of the following numeric flag values, or a comma-separated string\n" |
| 61 |
"NAME,...,NAME representing a combination of the following flag names:\n" |
| 62 |
"\n"); |
| 63 |
for (fl = flags; fl->desc; fl++) { |
| 64 |
char *name = bam_flag2str(fl->bit); |
| 65 |
fprintf(fp, "%#6x %5d %-15s%s\n", fl->bit, fl->bit, name, fl->desc); |
| 66 |
free(name); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
int main_flags(int argc, char *argv[]) |
| 72 |
{ |
| 73 |
if ( argc < 2 ) { usage(stdout); return 0; } |
| 74 |
|
| 75 |
int i; |
| 76 |
for (i = 1; i < argc; i++) |
| 77 |
{ |
| 78 |
int mask = bam_str2flag(argv[i]); |
| 79 |
if ( mask<0 ) { print_error("flags", "Could not parse \"%s\"", argv[i]); usage(stderr); return 1; } |
| 80 |
char *str = bam_flag2str(mask); |
| 81 |
printf("0x%x\t%d\t%s\n", mask, mask, str); |
| 82 |
free(str); |
| 83 |
} |
| 84 |
return 0; |
| 85 |
} |
| 86 |
|