annotate pyPRADA_1.2/tools/samtools-0.1.16/bamtk.c @ 3:f17965495ec9 draft default tip

Uploaded
author siyuan
date Tue, 11 Mar 2014 12:14:01 -0400
parents acc2ca1a3ba4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
1 #include <stdio.h>
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
2 #include <unistd.h>
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
3 #include <assert.h>
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
4 #include <fcntl.h>
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
5 #include "bam.h"
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
6
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
7 #ifdef _USE_KNETFILE
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
8 #include "knetfile.h"
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
9 #endif
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
10
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
11 int bam_taf2baf(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
12 int bam_pileup(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
13 int bam_mpileup(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
14 int bam_merge(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
15 int bam_index(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
16 int bam_sort(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
17 int bam_tview_main(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
18 int bam_mating(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
19 int bam_rmdup(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
20 int bam_flagstat(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
21 int bam_fillmd(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
22 int bam_idxstats(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
23 int main_samview(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
24 int main_import(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
25 int main_reheader(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
26 int main_cut_target(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
27 int main_phase(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
28 int main_cat(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
29 int main_depth(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
30
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
31 int faidx_main(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
32 int glf3_view_main(int argc, char *argv[]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
33
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
34 static int usage()
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
35 {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
36 fprintf(stderr, "\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
37 fprintf(stderr, "Program: samtools (Tools for alignments in the SAM format)\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
38 fprintf(stderr, "Version: %s\n\n", BAM_VERSION);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
39 fprintf(stderr, "Usage: samtools <command> [options]\n\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
40 fprintf(stderr, "Command: view SAM<->BAM conversion\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
41 fprintf(stderr, " sort sort alignment file\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
42 fprintf(stderr, " pileup generate pileup output\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
43 fprintf(stderr, " mpileup multi-way pileup\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
44 fprintf(stderr, " depth compute the depth\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
45 fprintf(stderr, " faidx index/extract FASTA\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
46 #if _CURSES_LIB != 0
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
47 fprintf(stderr, " tview text alignment viewer\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
48 #endif
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
49 fprintf(stderr, " index index alignment\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
50 fprintf(stderr, " idxstats BAM index stats (r595 or later)\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
51 fprintf(stderr, " fixmate fix mate information\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
52 fprintf(stderr, " glfview print GLFv3 file\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
53 fprintf(stderr, " flagstat simple stats\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
54 fprintf(stderr, " calmd recalculate MD/NM tags and '=' bases\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
55 fprintf(stderr, " merge merge sorted alignments\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
56 fprintf(stderr, " rmdup remove PCR duplicates\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
57 fprintf(stderr, " reheader replace BAM header\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
58 fprintf(stderr, " cat concatenate BAMs\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
59 fprintf(stderr, " targetcut cut fosmid regions (for fosmid pool only)\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
60 fprintf(stderr, " phase phase heterozygotes\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
61 fprintf(stderr, "\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
62 #ifdef _WIN32
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
63 fprintf(stderr, "\
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
64 Note: The Windows version of SAMtools is mainly designed for read-only\n\
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
65 operations, such as viewing the alignments and generating the pileup.\n\
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
66 Binary files generated by the Windows version may be buggy.\n\n");
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
67 #endif
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
68 return 1;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
69 }
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
70
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
71 int main(int argc, char *argv[])
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
72 {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
73 #ifdef _WIN32
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
74 setmode(fileno(stdout), O_BINARY);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
75 setmode(fileno(stdin), O_BINARY);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
76 #ifdef _USE_KNETFILE
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
77 knet_win32_init();
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
78 #endif
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
79 #endif
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
80 if (argc < 2) return usage();
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
81 if (strcmp(argv[1], "view") == 0) return main_samview(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
82 else if (strcmp(argv[1], "import") == 0) return main_import(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
83 else if (strcmp(argv[1], "pileup") == 0) return bam_pileup(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
84 else if (strcmp(argv[1], "mpileup") == 0) return bam_mpileup(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
85 else if (strcmp(argv[1], "merge") == 0) return bam_merge(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
86 else if (strcmp(argv[1], "sort") == 0) return bam_sort(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
87 else if (strcmp(argv[1], "index") == 0) return bam_index(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
88 else if (strcmp(argv[1], "idxstats") == 0) return bam_idxstats(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
89 else if (strcmp(argv[1], "faidx") == 0) return faidx_main(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
90 else if (strcmp(argv[1], "fixmate") == 0) return bam_mating(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
91 else if (strcmp(argv[1], "rmdup") == 0) return bam_rmdup(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
92 else if (strcmp(argv[1], "glfview") == 0) return glf3_view_main(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
93 else if (strcmp(argv[1], "flagstat") == 0) return bam_flagstat(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
94 else if (strcmp(argv[1], "calmd") == 0) return bam_fillmd(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
95 else if (strcmp(argv[1], "fillmd") == 0) return bam_fillmd(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
96 else if (strcmp(argv[1], "reheader") == 0) return main_reheader(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
97 else if (strcmp(argv[1], "cat") == 0) return main_cat(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
98 else if (strcmp(argv[1], "targetcut") == 0) return main_cut_target(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
99 else if (strcmp(argv[1], "phase") == 0) return main_phase(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
100 else if (strcmp(argv[1], "depth") == 0) return main_depth(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
101 #if _CURSES_LIB != 0
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
102 else if (strcmp(argv[1], "tview") == 0) return bam_tview_main(argc-1, argv+1);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
103 #endif
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
104 else {
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
105 fprintf(stderr, "[main] unrecognized command '%s'\n", argv[1]);
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
106 return 1;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
107 }
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
108 return 0;
acc2ca1a3ba4 Uploaded
siyuan
parents:
diff changeset
109 }