| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 92 |
if (System.getProperty("fastqc.kmer_size") != null) { |
| 93 |
kmer_size = Integer.parseInt(System.getProperty("fastqc.kmer_size")); |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
if (System.getProperty("fastqc.min_length") != null) { |
| 99 |
minLength = Integer.parseInt(System.getProperty("fastqc.min_length")); |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
if (System.getProperty("fastqc.dup_length") != null) { |
| 104 |
dupLength = Integer.parseInt(System.getProperty("fastqc.dup_length")); |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
if (System.getProperty("fastqc.quiet") != null && System.getProperty("fastqc.quiet").equals("true")) { |
| 110 |
quiet = true; |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
if (System.getProperty("fastqc.casava") != null && System.getProperty("fastqc.casava").equals("true")) { |
| 115 |
casava = true; |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
if (System.getProperty("fastqc.nano") != null && System.getProperty("fastqc.nano").equals("true")) { |
| 120 |
nano = true; |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
if (System.getProperty("fastqc.svg") != null && System.getProperty("fastqc.svg").equals("true")) { |
| 125 |
svg_output = true; |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
if (System.getProperty("fastqc.nofilter") != null && System.getProperty("fastqc.nofilter").equals("true")) { |
| 131 |
nofilter = true; |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
if (System.getProperty("fastqc.nogroup") != null && System.getProperty("fastqc.nogroup").equals("true")) { |
| 137 |
nogroup = true; |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
if (System.getProperty("fastqc.expgroup") != null && System.getProperty("fastqc.expgroup").equals("true")) { |
| 142 |
expgroup = true; |
| 143 |
} |
| 144 |
|
| 145 |
|
| 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 |
|
| 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 |
} |