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.net.URL;
28 import java.util.regex.Pattern;
29
30 import org.utgenome.UTGBException;
31 import org.utgenome.format.fasta.CompactFASTAGenerator;
32 import org.xerial.util.StopWatch;
33 import org.xerial.util.log.Logger;
34 import org.xerial.util.opt.Argument;
35 import org.xerial.util.opt.Option;
36
37
38
39
40
41
42
43 public class Pack extends UTGBShellCommand {
44
45 private static Logger _logger = Logger.getLogger(Pack.class);
46
47 @Argument(index = 0)
48 private String inputFile = null;
49
50 @Option(symbol = "o", description = "output directory. default = db")
51 private String outputDir = "db";
52
53 @Override
54 public void execute(String[] args) throws Exception {
55
56 if (inputFile == null)
57 throw new UTGBException("missing an input file");
58
59 _logger.info("input file: " + inputFile);
60 _logger.info("output dir: " + outputDir);
61
62 StopWatch sw = new StopWatch();
63 CompactFASTAGenerator g = new CompactFASTAGenerator();
64 g.setWorkDir(outputDir);
65
66 if (Pattern.matches("^\\w+:\\/.*", inputFile)) {
67 g.packFASTA(new URL(inputFile));
68 }
69 else
70 g.packFASTA(inputFile);
71
72 _logger.info(String.format("elapsed time %s sec.", sw.getElapsedTime()));
73 }
74
75 @Override
76 public String getOneLinerDescription() {
77 return "create a pack file of the input FASTA sequences";
78 }
79
80 @Override
81 public String name() {
82 return "pack";
83 }
84
85 }