Commit a34fd632 authored by Koehorst, Jasper's avatar Koehorst, Jasper
Browse files

yaml check and fixed min read length vs max read length

parent 83be6ed1
Pipeline #15129 failed with stage
in 1 minute and 11 seconds
......@@ -5,6 +5,7 @@ import com.esotericsoftware.yamlbeans.YamlWriter;
import nl.munlock.Generic;
import nl.munlock.irods.Connection;
import nl.munlock.ontology.domain.AmpliconAssay;
import nl.munlock.ontology.domain.PairedSequenceDataSet;
import nl.munlock.ontology.domain.SequenceDataSet;
import nl.munlock.options.workflow.CommandOptionsNGTAX;
import nl.munlock.objects.WorkflowNgtax;
......@@ -73,18 +74,21 @@ public class NGTax {
IRODSFile destFile;
log.debug("Read length set to " + commandOptions.read_len);
// if (commandOptions.read_len > 0) {
// workflow.for_read_len = commandOptions.read_len;
// workflow.rev_read_len = commandOptions.read_len;
// }
// Set yaml filename
if (commandOptions.read_len > 0) {
yamlFileName = commandOptions.id + "_" + commandOptions.read_len + ".yaml";
} else {
yamlFileName = commandOptions.id + "_" + workflow.getFor_read_len() + ".yaml";
}
if (files.size() == 0) {
log.warn("No files found");
} else if (files.size() == 1) {
log.debug("Single end files detected");
if (files.get(0).getClassTypeIri().endsWith("PairedSequenceDataSet")) {
log.error("Paired sequence dataset detected but only 1 file was found\n" +
"Paired dataset should not be interleaved");
log.error("Paired sequence dataset detected but only 1 file was found");
log.error("Paired dataset should not be interleaved");
continue;
}
// IN PROGRESS... mr..DNA -.-
......@@ -111,25 +115,30 @@ public class NGTax {
workflow.addForward_reads(files.get(0).getFilePath());
workflow.addReverse_reads(files.get(1).getFilePath());
SequenceDataSet sequenceDataSet1 = (SequenceDataSet) ampliconAssay.getAllFile().get(0);
SequenceDataSet sequenceDataSet2 = (SequenceDataSet) ampliconAssay.getAllFile().get(1);
PairedSequenceDataSet sequenceDataSet1 = (PairedSequenceDataSet) ampliconAssay.getAllFile().get(0);
PairedSequenceDataSet sequenceDataSet2 = sequenceDataSet1.getPaired();
Long maxReadLength = sequenceDataSet1.getReadLength();
if (maxReadLength < sequenceDataSet2.getReadLength()) {
maxReadLength = sequenceDataSet2.getReadLength();
Long minReadLength = sequenceDataSet1.getReadLength();
if (minReadLength > sequenceDataSet2.getReadLength()) {
minReadLength = sequenceDataSet2.getReadLength();
}
// Evaluate if the set read length matches / smaller than the raw read length
if (commandOptions.read_len == 0 && maxReadLength > 0) {
if (commandOptions.read_len == 0 && minReadLength > 0) {
log.debug("Obtaining read length information from RDF file");
workflow.setFor_read_len(Math.toIntExact(sequenceDataSet1.getReadLength()));
workflow.setRev_read_len(Math.toIntExact(sequenceDataSet2.getReadLength()));
} else if (commandOptions.read_len > 0) {
// If set read length greater then file 1 OR file 2 skip
if (commandOptions.read_len > maxReadLength) {
log.error("Skipping!!! As read length of " + commandOptions.read_len + " is larger than " + maxReadLength);
if (commandOptions.read_len > minReadLength) {
log.error("Skipping!!! As read length of " + commandOptions.read_len + " is larger than " + minReadLength);
destFile = connection.fileFactory.instanceIRODSFile(ampliconAssay.getLogicalPath() + "/" + yamlFileName);
if (destFile.exists()) {
log.error("File exists!?");
destFile.delete();
}
continue;
}
log.debug("Setting read length to " + commandOptions.read_len + " of " + maxReadLength);
log.debug("Setting read length to " + commandOptions.read_len + " of " + minReadLength);
workflow.setRev_read_len(Math.toIntExact(commandOptions.read_len));
workflow.setFor_read_len(Math.toIntExact(commandOptions.read_len));
} else {
......@@ -143,14 +152,6 @@ public class NGTax {
throw new Exception("More than 2 files detected...");
}
// Save to nl.wur.ssb.yaml format
// Generate own nl.wur.ssb.yaml name...
if (commandOptions.read_len > 0) {
yamlFileName = commandOptions.id + "_" + commandOptions.read_len + ".yaml";
} else {
yamlFileName = commandOptions.id + "_" + workflow.getFor_read_len() + ".yaml";
}
// Parent folder check with metadata alignment... TODO remove this as this is a temp check
IRODSFile parent = connection.fileFactory.instanceIRODSFile(ampliconAssay.getLogicalPath());
if (parent.exists()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment