Skip to content

Commit e977abd

Browse files
committed
UPDATE: Refactor the DoradoAction, to be more easier to maintain with future Dorado version. Add support for sample sheet and poly A length estimation.
1 parent e5725bc commit e977abd

File tree

2 files changed

+149
-161
lines changed

2 files changed

+149
-161
lines changed

src/main/java/fr/ens/biologie/genomique/aozan/aozan3/action/DoradoAction.java

+23-82
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import org.apache.commons.cli.Options;
1515
import org.apache.commons.cli.ParseException;
1616

17+
import com.google.common.base.Splitter;
18+
1719
import fr.ens.biologie.genomique.aozan.aozan3.Aozan3Exception;
1820
import fr.ens.biologie.genomique.aozan.aozan3.Common;
1921
import fr.ens.biologie.genomique.aozan.aozan3.Configuration;
@@ -47,19 +49,11 @@ public void action(Configuration conf, List<String> arguments,
4749

4850
final Options options = makeOptions();
4951
final CommandLineParser parser = new DefaultParser();
52+
final Configuration doradoConf = new Configuration();
5053

51-
String flowcell = "";
52-
String kit = "";
53-
String barcodeKits = "";
54-
String modelName = "";
5554
String runId = "";
56-
String doradoVersion = "";
5755
String cudaDevice = "";
58-
int batchSize = -1;
59-
int chunkSize = -1;
60-
boolean trimBarcode = false;
6156
boolean keepTemporaryFiles = false;
62-
String minQscore = "";
6357
List<String> args = null;
6458

6559
try {
@@ -73,69 +67,45 @@ public void action(Configuration conf, List<String> arguments,
7367
help(options);
7468
}
7569

76-
// Trim barcodes option
77-
if (line.hasOption("trim-barcodes")) {
78-
trimBarcode = true;
79-
}
70+
// Set the configuration settings
71+
if (line.hasOption('s')) {
8072

81-
if (line.hasOption("flowcell")) {
82-
flowcell = line.getOptionValue("flowcell");
83-
}
73+
List<String> settings = Arrays.asList(line.getOptionValues('s'));
8474

85-
if (line.hasOption("kit")) {
86-
kit = line.getOptionValue("kit");
87-
}
75+
Splitter splitter = Splitter.on('=').trimResults();
76+
for (String s : settings) {
77+
List<String> elements = splitter.splitToList(s);
78+
if (elements.size() != 2) {
79+
throw new ParseException("Invalid setting format: " + s);
80+
}
81+
doradoConf.set(elements.get(0).trim(), elements.get(1).trim());
82+
}
8883

89-
if (line.hasOption("barcode-kit")) {
90-
barcodeKits = line.getOptionValue("barcode-kit");
9184
}
9285

9386
if (line.hasOption("run-id")) {
9487
runId = line.getOptionValue("run-id");
9588
}
9689

97-
if (line.hasOption("dorado-version")) {
98-
doradoVersion = line.getOptionValue("dorado-version");
99-
}
100-
101-
if (line.hasOption("config")) {
102-
modelName = line.getOptionValue("config");
103-
}
104-
105-
if (line.hasOption("min-qscore")) {
106-
minQscore = line.getOptionValue("min-qscore");
107-
}
108-
10990
if (line.hasOption("device")) {
11091
cudaDevice = line.getOptionValue("device");
11192
}
11293

113-
if (line.hasOption("batch-size")) {
114-
batchSize = Integer.parseInt(line.getOptionValue("batch-size"));
115-
}
116-
117-
if (line.hasOption("chunk-size")) {
118-
chunkSize = Integer.parseInt(line.getOptionValue("chunk-size"));
119-
}
120-
12194
if (line.hasOption("keep-temporary-files")) {
12295
keepTemporaryFiles = true;
12396
}
12497
args = Arrays.asList(line.getArgs());
12598

126-
if (args.size() < 4) {
99+
if (args.size() < 3) {
127100
help(options);
128101
}
129102

130103
final Path inputTar = Paths.get(args.get(0));
131104
final Path outputDir = Paths.get(args.get(1));
132-
final Path modelsPath = Paths.get(args.get(2));
133-
final Path tmpPath = Paths.get(args.get(3));
105+
final Path tmpPath = Paths.get(args.get(2));
134106

135-
DoradoONTBasecallingDataProcessor.run(inputTar, outputDir, modelsPath,
136-
runId, doradoVersion, tmpPath, flowcell, kit, barcodeKits,
137-
trimBarcode, minQscore, modelName, cudaDevice, batchSize, chunkSize,
138-
keepTemporaryFiles, logger);
107+
DoradoONTBasecallingDataProcessor.run(inputTar, outputDir, runId, tmpPath,
108+
cudaDevice, keepTemporaryFiles, doradoConf, logger);
139109

140110
} catch (ParseException e) {
141111
Common.errorExit(e,
@@ -166,52 +136,23 @@ private static Options makeOptions() {
166136
// create Options object
167137
final Options options = new Options();
168138

169-
// Dorado version option
170-
options.addOption(builder("g").longOpt("dorado-version").hasArg()
171-
.argName("version").desc("dorado version").build());
172-
173-
// Flowcell option
174-
options.addOption(builder("f").longOpt("flowcell").hasArg().argName("type")
175-
.desc("flow cell type").build());
176-
177-
// Kit option
178-
options.addOption(builder("k").longOpt("kit").hasArg().argName("kitname")
179-
.desc("kit name").build());
180-
181-
// Config option
182-
options.addOption(builder("c").longOpt("config").hasArg()
183-
.argName("configname").desc("configuration filename").build());
139+
// Define setting
140+
options.addOption(builder("s").longOpt("setting").hasArg()
141+
.argName("property=value").desc("set a configuration setting. This "
142+
+ "option can be used several times")
143+
.build());
184144

185145
// GPU device option
186146
options.addOption(builder("d").longOpt("device").hasArg()
187147
.argName("cudadevice").desc("Cuda device name").build());
188148

189-
// Batch size
190-
options.addOption(builder("u").longOpt("batch-size").hasArg()
191-
.argName("size").desc("batch size").build());
192-
193-
// Chunks size
194-
options.addOption(builder("p").longOpt("chunk-size").hasArg()
195-
.argName("chunks").desc("chunk size").build());
196-
197149
// Run id option
198150
options.addOption(builder("r").longOpt("run-id").hasArg().argName("id")
199151
.desc("run id").build());
200152

201-
// Barcode kits option
202-
options.addOption(builder("").longOpt("barcode-kit").hasArg()
203-
.argName("kits").desc("barcode kit").build());
204-
205-
// Trim barcode option
206-
options.addOption("t", "trim-barcodes", false, "trim barcodes");
207-
208153
// Fast5 output
209154
options.addOption("e", "keep-temporary-files", false, "Fast5 output");
210155

211-
// Barcode kits option
212-
options.addOption(builder("m").longOpt("min-qscore").hasArg()
213-
.argName("value").desc("minimal qscore for pass reads").build());
214-
215156
// Help option
216157
options.addOption("h", "help", false, "display this help");
217158

0 commit comments

Comments
 (0)