annotate java-genomics-toolkit/src/edu/unc/genomics/wigmath/WigSummary.java @ 0:1daf3026d231

Upload alpha version
author timpalpant
date Mon, 13 Feb 2012 21:55:55 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
1 package edu.unc.genomics.wigmath;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
2
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
3 import java.io.BufferedWriter;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
4 import java.io.IOException;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
5 import java.nio.charset.Charset;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
6 import java.nio.file.Files;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
7 import java.nio.file.Path;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
8
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
9 import org.apache.log4j.Logger;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
10
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
11 import com.beust.jcommander.Parameter;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
12
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
13 import edu.unc.genomics.CommandLineTool;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
14 import edu.unc.genomics.io.WigFile;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
15 import edu.unc.genomics.io.WigFileException;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
16 import edu.unc.genomics.ngs.Autocorrelation;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
17
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
18 public class WigSummary extends CommandLineTool {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
19
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
20 private static final Logger log = Logger.getLogger(Autocorrelation.class);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
21
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
22 @Parameter(names = {"-i", "--input"}, description = "Input file", required = true)
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
23 public WigFile inputFile;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
24 @Parameter(names = {"-o", "--output"}, description = "Output file")
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
25 public Path outputFile;
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
26
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
27 public void run() throws IOException {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
28 String summary = inputFile.toString();
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
29
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
30 if (outputFile != null) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
31 log.debug("Writing to output file");
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
32 try (BufferedWriter writer = Files.newBufferedWriter(outputFile, Charset.defaultCharset())) {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
33 writer.write(summary);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
34 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
35 } else {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
36 System.out.println(summary);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
37 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
38 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
39
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
40 public static void main(String[] args) throws IOException, WigFileException {
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
41 new WigSummary().instanceMain(args);
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
42 }
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
43
1daf3026d231 Upload alpha version
timpalpant
parents:
diff changeset
44 }