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 package org.utgenome.shell;
26
27 import java.io.BufferedWriter;
28 import java.io.File;
29 import java.io.FileWriter;
30 import java.io.OutputStreamWriter;
31 import java.io.Writer;
32
33 import org.utgenome.format.sam.Sam2WigConverter;
34 import org.xerial.util.opt.Argument;
35
36 public class Sam2Wig extends UTGBShellCommand {
37
38 @Argument(index = 0, name = "input", required = false)
39 File input = null;
40 @Argument(index = 1, name = "output", required = false)
41 String output = "-";
42
43 @Override
44 public void execute(String[] args) throws Exception {
45
46 Sam2WigConverter converter = new Sam2WigConverter();
47
48 Writer out = "-".equals(output) ? new OutputStreamWriter(System.out) : new BufferedWriter(new FileWriter(output));
49
50 try {
51 converter.convert(input, out);
52 }
53 finally {
54 out.close();
55 }
56 }
57
58 @Override
59 public String name() {
60 return "readdepth";
61 }
62
63 @Override
64 public String getOneLinerDescription() {
65 return "create a WIG file (coverage depth) from a given BAM (with BAI) file";
66 }
67
68 }