comparison PsiCLASS-1.0.2/samtools-0.1.19/bamtk.c @ 0:903fc43d6227 draft default tip

Uploaded
author lsong10
date Fri, 26 Mar 2021 16:52:45 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:903fc43d6227
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <assert.h>
4 #include <fcntl.h>
5 #include "bam.h"
6
7 #ifdef _USE_KNETFILE
8 #include "knetfile.h"
9 #endif
10
11 int bam_taf2baf(int argc, char *argv[]);
12 int bam_mpileup(int argc, char *argv[]);
13 int bam_merge(int argc, char *argv[]);
14 int bam_index(int argc, char *argv[]);
15 int bam_sort(int argc, char *argv[]);
16 int bam_tview_main(int argc, char *argv[]);
17 int bam_mating(int argc, char *argv[]);
18 int bam_rmdup(int argc, char *argv[]);
19 int bam_flagstat(int argc, char *argv[]);
20 int bam_fillmd(int argc, char *argv[]);
21 int bam_idxstats(int argc, char *argv[]);
22 int main_samview(int argc, char *argv[]);
23 int main_import(int argc, char *argv[]);
24 int main_reheader(int argc, char *argv[]);
25 int main_cut_target(int argc, char *argv[]);
26 int main_phase(int argc, char *argv[]);
27 int main_cat(int argc, char *argv[]);
28 int main_depth(int argc, char *argv[]);
29 int main_bam2fq(int argc, char *argv[]);
30 int main_pad2unpad(int argc, char *argv[]);
31 int main_bedcov(int argc, char *argv[]);
32 int main_bamshuf(int argc, char *argv[]);
33
34 int faidx_main(int argc, char *argv[]);
35
36 static int usage()
37 {
38 fprintf(stderr, "\n");
39 fprintf(stderr, "Program: samtools (Tools for alignments in the SAM format)\n");
40 fprintf(stderr, "Version: %s\n\n", BAM_VERSION);
41 fprintf(stderr, "Usage: samtools <command> [options]\n\n");
42 fprintf(stderr, "Command: view SAM<->BAM conversion\n");
43 fprintf(stderr, " sort sort alignment file\n");
44 fprintf(stderr, " mpileup multi-way pileup\n");
45 fprintf(stderr, " depth compute the depth\n");
46 fprintf(stderr, " faidx index/extract FASTA\n");
47 #if _CURSES_LIB != 0
48 fprintf(stderr, " tview text alignment viewer\n");
49 #endif
50 fprintf(stderr, " index index alignment\n");
51 fprintf(stderr, " idxstats BAM index stats (r595 or later)\n");
52 fprintf(stderr, " fixmate fix mate information\n");
53 fprintf(stderr, " flagstat simple stats\n");
54 fprintf(stderr, " calmd recalculate MD/NM tags and '=' bases\n");
55 fprintf(stderr, " merge merge sorted alignments\n");
56 fprintf(stderr, " rmdup remove PCR duplicates\n");
57 fprintf(stderr, " reheader replace BAM header\n");
58 fprintf(stderr, " cat concatenate BAMs\n");
59 fprintf(stderr, " bedcov read depth per BED region\n");
60 fprintf(stderr, " targetcut cut fosmid regions (for fosmid pool only)\n");
61 fprintf(stderr, " phase phase heterozygotes\n");
62 fprintf(stderr, " bamshuf shuffle and group alignments by name\n");
63 // fprintf(stderr, " depad convert padded BAM to unpadded BAM\n"); // not stable
64 fprintf(stderr, "\n");
65 #ifdef _WIN32
66 fprintf(stderr, "\
67 Note: The Windows version of SAMtools is mainly designed for read-only\n\
68 operations, such as viewing the alignments and generating the pileup.\n\
69 Binary files generated by the Windows version may be buggy.\n\n");
70 #endif
71 return 1;
72 }
73
74 int main(int argc, char *argv[])
75 {
76 #ifdef _WIN32
77 setmode(fileno(stdout), O_BINARY);
78 setmode(fileno(stdin), O_BINARY);
79 #ifdef _USE_KNETFILE
80 knet_win32_init();
81 #endif
82 #endif
83 if (argc < 2) return usage();
84 if (strcmp(argv[1], "view") == 0) return main_samview(argc-1, argv+1);
85 else if (strcmp(argv[1], "import") == 0) return main_import(argc-1, argv+1);
86 else if (strcmp(argv[1], "mpileup") == 0) return bam_mpileup(argc-1, argv+1);
87 else if (strcmp(argv[1], "merge") == 0) return bam_merge(argc-1, argv+1);
88 else if (strcmp(argv[1], "sort") == 0) return bam_sort(argc-1, argv+1);
89 else if (strcmp(argv[1], "index") == 0) return bam_index(argc-1, argv+1);
90 else if (strcmp(argv[1], "idxstats") == 0) return bam_idxstats(argc-1, argv+1);
91 else if (strcmp(argv[1], "faidx") == 0) return faidx_main(argc-1, argv+1);
92 else if (strcmp(argv[1], "fixmate") == 0) return bam_mating(argc-1, argv+1);
93 else if (strcmp(argv[1], "rmdup") == 0) return bam_rmdup(argc-1, argv+1);
94 else if (strcmp(argv[1], "flagstat") == 0) return bam_flagstat(argc-1, argv+1);
95 else if (strcmp(argv[1], "calmd") == 0) return bam_fillmd(argc-1, argv+1);
96 else if (strcmp(argv[1], "fillmd") == 0) return bam_fillmd(argc-1, argv+1);
97 else if (strcmp(argv[1], "reheader") == 0) return main_reheader(argc-1, argv+1);
98 else if (strcmp(argv[1], "cat") == 0) return main_cat(argc-1, argv+1);
99 else if (strcmp(argv[1], "targetcut") == 0) return main_cut_target(argc-1, argv+1);
100 else if (strcmp(argv[1], "phase") == 0) return main_phase(argc-1, argv+1);
101 else if (strcmp(argv[1], "depth") == 0) return main_depth(argc-1, argv+1);
102 else if (strcmp(argv[1], "bam2fq") == 0) return main_bam2fq(argc-1, argv+1);
103 else if (strcmp(argv[1], "pad2unpad") == 0) return main_pad2unpad(argc-1, argv+1);
104 else if (strcmp(argv[1], "depad") == 0) return main_pad2unpad(argc-1, argv+1);
105 else if (strcmp(argv[1], "bedcov") == 0) return main_bedcov(argc-1, argv+1);
106 else if (strcmp(argv[1], "bamshuf") == 0) return main_bamshuf(argc-1, argv+1);
107 else if (strcmp(argv[1], "pileup") == 0) {
108 fprintf(stderr, "[main] The `pileup' command has been removed. Please use `mpileup' instead.\n");
109 return 1;
110 }
111 #if _CURSES_LIB != 0
112 else if (strcmp(argv[1], "tview") == 0) return bam_tview_main(argc-1, argv+1);
113 #endif
114 else {
115 fprintf(stderr, "[main] unrecognized command '%s'\n", argv[1]);
116 return 1;
117 }
118 return 0;
119 }