Debian Codegraph @

uk/ac/babraham/FastQC/FastQCConfig.java

raw symbols SCIP
1 /**
2 * Copyright Copyright 2012-17 Simon Andrews
3 *
4 * This file is part of FastQC.
5 *
6 * FastQC is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * FastQC is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with FastQC; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 package uk.ac.babraham.FastQC;
21
22 import java.io.File;
23
24 public class FastQCConfig {
25
26 private static FastQCConfig instance = new FastQCConfig();
27 public boolean nogroup = false;
28 public boolean expgroup = false;
29 public boolean quiet = false;
30 public boolean show_version = false;
31 public Integer kmer_size = null;
32 public Integer threads = null;
33 public boolean showUpdates = true;
34 public File output_dir = null;
35 public boolean casava = false;
36 public boolean nano = false;
37 public boolean nofilter = false;
38 public Boolean do_unzip = null;
39 public boolean delete_after_unzip = false;
40 public String lineSeparator = System.getProperty("line.separator");
41 public String sequence_format = null;
42 public File contaminant_file = null;
43 public File adapter_file = null;
44 public File limits_file = null;
45 public int minLength = 0;
46 public int dupLength = 0;
47 public boolean svg_output = false;
48
49 private FastQCConfig () {
50
51 // Output dir
52 if (System.getProperty("fastqc.output_dir") != null) {
53 output_dir = new File(System.getProperty("fastqc.output_dir"));
54 if (!(output_dir.exists() && output_dir.canWrite())) {
55 throw new IllegalArgumentException("Output dir "+output_dir+" doesn't exist or isn't writeable");
56 }
57 }
58
59 // Contaminant file
60 if (System.getProperty("fastqc.contaminant_file") != null) {
61 contaminant_file = new File(System.getProperty("fastqc.contaminant_file"));
62 if (!(contaminant_file.exists() && contaminant_file.canRead())) {
63 throw new IllegalArgumentException("Contaminant file "+contaminant_file+" doesn't exist or can't be read");
64 }
65 }
66
67 // Adapter file
68 if (System.getProperty("fastqc.adapter_file") != null) {
69 adapter_file = new File(System.getProperty("fastqc.adapter_file"));
70 if (!(adapter_file.exists() && adapter_file.canRead())) {
71 throw new IllegalArgumentException("Adapter file "+adapter_file+" doesn't exist or can't be read");
72 }
73 }
74
75 // Limits file
76 if (System.getProperty("fastqc.limits_file") != null) {
77 limits_file = new File(System.getProperty("fastqc.limits_file"));
78 if (!(limits_file.exists() && limits_file.canRead())) {
79 throw new IllegalArgumentException("Limits file "+limits_file+" doesn't exist or can't be read");
80 }
81 }
82
83 // Threads
84 if (System.getProperty("fastqc.threads") != null) {
85 threads = Integer.parseInt(System.getProperty("fastqc.threads"));
86 if (threads < 1) {
87 throw new IllegalArgumentException("Number of threads must be >= 1");
88 }
89 }
90
91 // Kmer size
92 if (System.getProperty("fastqc.kmer_size") != null) {
93 kmer_size = Integer.parseInt(System.getProperty("fastqc.kmer_size"));
94 }
95
96
97 // Min length
98 if (System.getProperty("fastqc.min_length") != null) {
99 minLength = Integer.parseInt(System.getProperty("fastqc.min_length"));
100 }
101
102 // Dup length
103 if (System.getProperty("fastqc.dup_length") != null) {
104 dupLength = Integer.parseInt(System.getProperty("fastqc.dup_length"));
105 }
106
107
108 // Quiet
109 if (System.getProperty("fastqc.quiet") != null && System.getProperty("fastqc.quiet").equals("true")) {
110 quiet = true;
111 }
112
113 // Casava
114 if (System.getProperty("fastqc.casava") != null && System.getProperty("fastqc.casava").equals("true")) {
115 casava = true;
116 }
117
118 // Nanopore
119 if (System.getProperty("fastqc.nano") != null && System.getProperty("fastqc.nano").equals("true")) {
120 nano = true;
121 }
122
123 // SVG
124 if (System.getProperty("fastqc.svg") != null && System.getProperty("fastqc.svg").equals("true")) {
125 svg_output = true;
126 }
127
128
129 // Nofilter
130 if (System.getProperty("fastqc.nofilter") != null && System.getProperty("fastqc.nofilter").equals("true")) {
131 nofilter = true;
132 }
133
134
135 // No group
136 if (System.getProperty("fastqc.nogroup") != null && System.getProperty("fastqc.nogroup").equals("true")) {
137 nogroup = true;
138 }
139
140 // Exponential group
141 if (System.getProperty("fastqc.expgroup") != null && System.getProperty("fastqc.expgroup").equals("true")) {
142 expgroup = true;
143 }
144
145 // Unzip
146 if (System.getProperty("fastqc.unzip") != null && System.getProperty("fastqc.unzip").equals("true")) {
147 do_unzip = true;
148
149 if (System.getProperty("fastqc.delete") != null && System.getProperty("fastqc.delete").equals("true")) {
150 delete_after_unzip = true;
151 }
152 }
153
154
155 // Sequence Format
156 if (System.getProperty("fastqc.sequence_format") != null) {
157 setSequenceFormat(System.getProperty("fastqc.sequence_format"));
158 }
159
160 };
161
162 public void setSequenceFormat (String sequenceFormat) {
163 if (sequenceFormat.equals("fastq") || sequenceFormat.equals("sam") || sequenceFormat.equals("bam") || sequenceFormat.equals("sam_mapped") || sequenceFormat.equals("bam_mapped")) {
164 sequence_format = sequenceFormat;
165 }
166 else {
167 throw new IllegalArgumentException("Sequence format '"+sequenceFormat+"' wasn't recognised");
168 }
169 }
170
171 public void setCasavaMode (boolean casava) {
172 this.casava = casava;
173 }
174
175 public static FastQCConfig getInstance() {
176 return instance;
177 }
178
179
180 }