Commit ba6c35d6 authored by Jasper Koehorst's avatar Jasper Koehorst
Browse files

big clean up for assay to stick to assay and additionalTypes

parent ffa40dfb
Pipeline #42477 passed with stage
in 2 minutes and 38 seconds
...@@ -604,24 +604,29 @@ public class ExcelValidator { ...@@ -604,24 +604,29 @@ public class ExcelValidator {
for (observation_unit observation_unit : study.getAllHasPart()) { for (observation_unit observation_unit : study.getAllHasPart()) {
for (Sample sample : observation_unit.getAllHasPart()) { for (Sample sample : observation_unit.getAllHasPart()) {
for (Assay assay : sample.getAllHasPart()) { for (Assay assay : sample.getAllHasPart()) {
if (assay.getClassTypeIri().endsWith("AmpliconLibraryAssay")) { // if (assay.getClassTypeIri().endsWith("AmpliconLibraryAssay")) {
AmpliconLibraryAssay assay1 = (AmpliconLibraryAssay) assay; // AmpliconLibraryAssay assay1 = (AmpliconLibraryAssay) assay;
for (Data_sample data_sample : assay1.getAllHasPart()) { // for (Data_sample data_sample : assay1.getAllHasPart()) {
data_sample.getName(); // data_sample.getName();
} // }
} else if (assay.getClassTypeIri().endsWith("AmpliconAssay")) { // } else if (assay.getClassTypeIri().endsWith("AmpliconAssay")) {
AmpliconAssay assay1 = (AmpliconAssay) assay; // AmpliconAssay assay1 = (AmpliconAssay) assay;
for (Data_sample data_sample : assay1.getAllHasPart()) { // for (Data_sample data_sample : assay1.getAllHasPart()) {
data_sample.getName(); // data_sample.getName();
} // }
} else if (assay.getClassTypeIri().endsWith("RNASeqAssay")) { // } else if (assay.getClassTypeIri().endsWith("RNASeqAssay")) {
RNASeqAssay assay1 = (RNASeqAssay) assay; // RNASeqAssay assay1 = (RNASeqAssay) assay;
for (Data_sample data_sample : assay1.getAllHasPart()) { // for (Data_sample data_sample : assay1.getAllHasPart()) {
data_sample.getName(); // data_sample.getName();
} // }
} else if (assay.getClassTypeIri().endsWith("DNASeqAssay")) { // } else if (assay.getClassTypeIri().endsWith("DNASeqAssay")) {
DNASeqAssay assay1 = (DNASeqAssay) assay; // DNASeqAssay assay1 = (DNASeqAssay) assay;
for (Data_sample data_sample : assay1.getAllHasPart()) { // for (Data_sample data_sample : assay1.getAllHasPart()) {
// data_sample.getName();
// }
// } else
if (assay.getClassTypeIri().endsWith("Assay")) {
for (Data_sample data_sample : assay.getAllHasPart()) {
data_sample.getName(); data_sample.getName();
} }
} else { } else {
...@@ -752,24 +757,30 @@ public class ExcelValidator { ...@@ -752,24 +757,30 @@ public class ExcelValidator {
logger.info("Parsing " + sheet.getSheetName()); logger.info("Parsing " + sheet.getSheetName());
ArrayList<String> header = new ArrayList<>(); ArrayList<String> header = new ArrayList<>();
// Assay type // Assay type after " - " split, strip, camel case it and then remove spaces and turn into a URI
AssayType assayType; String assayTypeIRI;
if (sheet.getSheetName().endsWith("AmpliconAssay")) { if (sheet.getSheetName().contains(" - ")) {
assayType = AssayType.Amplicon; String[] name = sheet.getSheetName().split(" - ");
} else if (sheet.getSheetName().endsWith("AmpliconLibrary")) { String assayName = name[name.length-1];
assayType = AssayType.AmpliconLibrary; boolean validAssayName = false;
} else if (sheet.getSheetName().endsWith("RNA")) { // Check if it is part of the excel package
assayType = AssayType.Transcriptomics; for (Metadata metadata : metadataArrayList) {
} else if (sheet.getSheetName().toLowerCase().endsWith("illumina")) { if (metadata.getPackage().toLowerCase(Locale.ROOT).contains(assayName.toLowerCase(Locale.ROOT))) {
assayType = AssayType.Genomics; validAssayName = true;
} else if (sheet.getSheetName().toLowerCase().endsWith("nanopore")) { break;
assayType = AssayType.Genomics; }
} else if (sheet.getSheetName().endsWith("Proteomics")) { }
assayType = AssayType.Proteomics; if (!validAssayName) {
} else if (sheet.getSheetName().endsWith("Metabolomics")) { throw new Exception("This assay name is not supported: " + assayName);
assayType = AssayType.Metabolomics; }
// Create IRI
assayName = StringUtils.capitalize(assayName).replaceAll(" +", "");
assayTypeIRI = "http://m-unlock.nl/ontology/" + assayName;
} else { } else {
throw new Exception("The sheet " + sheet.getSheetName() + " is of an unsupported assay type"); // some kind of exception
throw new Exception("Assay sheet formatting is not correct should be according to: Assay - type");
} }
// Header capture // Header capture
...@@ -803,8 +814,6 @@ public class ExcelValidator { ...@@ -803,8 +814,6 @@ public class ExcelValidator {
fileCell = row.getCell(header.indexOf(FORWARD_FILENAME), Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); fileCell = row.getCell(header.indexOf(FORWARD_FILENAME), Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
} else if (header.indexOf(FILE_NAME) != -1) { } else if (header.indexOf(FILE_NAME) != -1) {
fileCell = row.getCell(header.indexOf(FILE_NAME), Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); fileCell = row.getCell(header.indexOf(FILE_NAME), Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
} else {
// No file given yet...
} }
// TODO Reduce list to the core elements // TODO Reduce list to the core elements
...@@ -853,65 +862,68 @@ public class ExcelValidator { ...@@ -853,65 +862,68 @@ public class ExcelValidator {
} }
// Setting the assay URL based on the type and identifier // Setting the assay URL based on the type and identifier
String ASSAYIRI = PREFIX + assayType.getIRI().replaceAll(".*/", "") + "/ASY_" + row.getCell(index).getStringCellValue().trim() + ""; String ASSAYIRI = PREFIX + assayTypeIRI.replaceAll(".*/", "") + "/ASY_" + row.getCell(index).getStringCellValue().trim() + "";
// Generic place holders // Generic place holders
Assay assay; Assay assay = domain.make(Assay.class, ASSAYIRI);
assay.addAdditionalType(assayTypeIRI);
// Section for amplicon / library data
if (assayType.equals(AssayType.Amplicon)) { // // Section for amplicon / library data
AmpliconAssay ampliconAssay = domain.make(AmpliconAssay.class, ASSAYIRI); // if (assayType.equals(AssayType.Amplicon)) {
assay = ampliconAssay; // AmpliconAssay ampliconAssay = domain.make(AmpliconAssay.class, ASSAYIRI);
} else if (assayType.equals(AssayType.AmpliconLibrary)) { // assay = ampliconAssay;
// Create amplicon library object // } else if (assayType.equals(AssayType.AmpliconLibrary)) {
if (header.indexOf(LIBRARY_NAME) == -1) { // // Create amplicon library object
logging("Missing LibraryName for AmpliconLibraryAssay"); // if (header.indexOf(LIBRARY_NAME) == -1) {
} // logging("Missing LibraryName for AmpliconLibraryAssay");
String assayLibraryIRI = PREFIX + AssayType.AmpliconLibrary.getIRI().replaceAll(".*/", "") + "/" + getStringValueCell(row.getCell(header.indexOf(LIBRARY_NAME))).trim(); // }
String assayIRI = PREFIX + AssayType.Amplicon.getIRI().replaceAll(".*/", "") + "/" + getStringValueCell(row.getCell(header.indexOf(ASSAY_IDENTIFIER))).trim(); // String assayLibraryIRI = PREFIX + AssayType.AmpliconLibrary.getIRI().replaceAll(".*/", "") + "/" + getStringValueCell(row.getCell(header.indexOf(LIBRARY_NAME))).trim();
// String assayIRI = PREFIX + AssayType.Amplicon.getIRI().replaceAll(".*/", "") + "/" + getStringValueCell(row.getCell(header.indexOf(ASSAY_IDENTIFIER))).trim();
// logger.debug("Library " + assayLibraryIRI); //
// // logger.debug("Library " + assayLibraryIRI);
AmpliconLibraryAssay ampliconLibraryAssay = domain.make(AmpliconLibraryAssay.class, assayLibraryIRI); //
String ampliconLibraryAssayIdentifier = getStringValueCell(row.getCell(header.indexOf(LIBRARY_NAME))).trim(); // AmpliconLibraryAssay ampliconLibraryAssay = domain.make(AmpliconLibraryAssay.class, assayLibraryIRI);
ampliconLibraryAssay.setIdentifier(ampliconLibraryAssayIdentifier); // String ampliconLibraryAssayIdentifier = getStringValueCell(row.getCell(header.indexOf(LIBRARY_NAME))).trim();
ampliconLibraryAssay.setDescription("Amplicon library " + ampliconLibraryAssayIdentifier); // ampliconLibraryAssay.setIdentifier(ampliconLibraryAssayIdentifier);
ampliconLibraryAssay.setLogicalPath("null"); // ampliconLibraryAssay.setDescription("Amplicon library " + ampliconLibraryAssayIdentifier);
// ampliconLibraryAssay.setLogicalPath("null");
// Cell can be numeric //
// Sample sample = getSample(iriCorrector(getStringValueCell(row.getCell(header.indexOf("SampleIdentifier"))))); // // Cell can be numeric
// TODO check if we should do this? Amplicon assay should be a library and attached to assay of type amplicon //// Sample sample = getSample(iriCorrector(getStringValueCell(row.getCell(header.indexOf("SampleIdentifier")))));
// sample.addAssay(ampliconLibraryAssay); // // TODO check if we should do this? Amplicon assay should be a library and attached to assay of type amplicon
// ampliconLibraryAssay.setSample(sample); // // sample.addAssay(ampliconLibraryAssay);
// parsedHeaders.add(LIBRARY_NAME); // // ampliconLibraryAssay.setSample(sample);
// Skip identifier addition due to amplicon assays having many different identifiers for the same library // // parsedHeaders.add(LIBRARY_NAME);
parsedHeaders.add(ASSAY_IDENTIFIER); // // Skip identifier addition due to amplicon assays having many different identifiers for the same library
parsedHeaders.add(ASSAY_DESCRIPTION); // parsedHeaders.add(ASSAY_IDENTIFIER);
// Prevent adding file objects as strings // parsedHeaders.add(ASSAY_DESCRIPTION);
parsedHeaders.add(FORWARD_FILENAME); // // Prevent adding file objects as strings
parsedHeaders.add(REVERSE_FILENAME); // parsedHeaders.add(FORWARD_FILENAME);
// parsedHeaders.add(REVERSE_FILENAME);
otherColumns(header, parsedHeaders, row, ampliconLibraryAssay.getResource().getURI(), metadataArrayList); //
// Remove this for further processing of the assay // otherColumns(header, parsedHeaders, row, ampliconLibraryAssay.getResource().getURI(), metadataArrayList);
parsedHeaders.removeAll(List.of(new String[]{ASSAY_IDENTIFIER, ASSAY_DESCRIPTION})); // // Remove this for further processing of the assay
// parsedHeaders.removeAll(List.of(new String[]{ASSAY_IDENTIFIER, ASSAY_DESCRIPTION}));
// Create amplicon object even though its not demultiplexed yet?... //
AmpliconAssay ampliconAssay = domain.make(AmpliconAssay.class, assayIRI); // // Create amplicon object even though its not demultiplexed yet?...
// Make link to the amplicon library // AmpliconAssay ampliconAssay = domain.make(AmpliconAssay.class, assayIRI);
ampliconAssay.setLibrary(ampliconLibraryAssay); // // Make link to the amplicon library
assay = ampliconAssay; // ampliconAssay.setLibrary(ampliconLibraryAssay);
// assay = ampliconAssay;
// Section for RNA sequencing data //
} else if (assayType.equals(AssayType.Transcriptomics)) { // // Section for RNA sequencing data
RNASeqAssay rnaSeqAssay = domain.make(RNASeqAssay.class, ASSAYIRI); // } else if (assayType.equals(AssayType.Transcriptomics)) {
assay = rnaSeqAssay; // RNASeqAssay rnaSeqAssay = domain.make(RNASeqAssay.class, ASSAYIRI);
// Section for DNA sequencing data // assay = rnaSeqAssay;
} else if (assayType.equals(AssayType.Genomics)) { // // Section for DNA sequencing data
DNASeqAssay dnaSeqAssay = domain.make(DNASeqAssay.class, ASSAYIRI); // } else if (assayType.equals(AssayType.Genomics)) {
assay = dnaSeqAssay; // DNASeqAssay dnaSeqAssay = domain.make(DNASeqAssay.class, ASSAYIRI);
} else { // assay = dnaSeqAssay;
throw new Exception(assayType.getIRI() + " not ready at the moment"); // } else {
} // logger.info("Created default Assay");
// assay = domain.make(Assay.class, ASSAYIRI);
// // TODO add additional type based on sheet name and default IRI
// }
/** /**
* Generic Assay information * Generic Assay information
...@@ -923,7 +935,7 @@ public class ExcelValidator { ...@@ -923,7 +935,7 @@ public class ExcelValidator {
// parsedHeaders.addAll(Arrays.asList(ASSAY_DESCRIPTION, ASSAY_TITLE, ASSAY_IDENTIFIER, PLATFORM)); // parsedHeaders.addAll(Arrays.asList(ASSAY_DESCRIPTION, ASSAY_TITLE, ASSAY_IDENTIFIER, PLATFORM));
if (fileCell.getCellType().equals(CellType.BLANK)) { if (fileCell.getCellType().equals(CellType.BLANK)) {
// logging("No file found for " + assay.getResource().getURI()); logger.debug("No file found for " + assay.getResource().getURI());
} else { } else {
String fileName = getStringValueCell(fileCell); String fileName = getStringValueCell(fileCell);
// Check the FileNameForwardPath and FileNameReversePath first // Check the FileNameForwardPath and FileNameReversePath first
...@@ -970,7 +982,8 @@ public class ExcelValidator { ...@@ -970,7 +982,8 @@ public class ExcelValidator {
parsedHeaders.addAll(Arrays.asList(FORWARD_FILENAME, REVERSE_FILENAME)); parsedHeaders.addAll(Arrays.asList(FORWARD_FILENAME, REVERSE_FILENAME));
} }
} else if (fileName != null) { // If it is one of the sequence assay types
} else if (!assay.getClassTypeIri().endsWith("/Assay")) {
SingleSequenceDataSet singleSequenceDataSet = domain.make(SingleSequenceDataSet.class, PREFIX + fileName); SingleSequenceDataSet singleSequenceDataSet = domain.make(SingleSequenceDataSet.class, PREFIX + fileName);
singleSequenceDataSet.setName(new File(fileName).getName().trim()); singleSequenceDataSet.setName(new File(fileName).getName().trim());
singleSequenceDataSet.setContentUrl("null"); singleSequenceDataSet.setContentUrl("null");
...@@ -987,6 +1000,15 @@ public class ExcelValidator { ...@@ -987,6 +1000,15 @@ public class ExcelValidator {
assay.addHasPart(singleSequenceDataSet); assay.addHasPart(singleSequenceDataSet);
parsedHeaders.addAll(Arrays.asList(FORWARD_FILENAME)); parsedHeaders.addAll(Arrays.asList(FORWARD_FILENAME));
} else {
Data_sample data_sample = domain.make(Data_sample.class, PREFIX + fileName);
data_sample.setName(new File(fileName).getName().trim());
data_sample.setContentUrl("null");
data_sample.setBase64("null");
data_sample.setSha256("null");
data_sample.setContentSize(0L);
data_sample.setFileFormat(setFileFormat(data_sample.getName()));
assay.addHasPart(data_sample);
} }
} }
...@@ -1004,14 +1026,14 @@ public class ExcelValidator { ...@@ -1004,14 +1026,14 @@ public class ExcelValidator {
// parsedHeaders.addAll(Arrays.asList(SAMPLE_IDENTIFIER)); // parsedHeaders.addAll(Arrays.asList(SAMPLE_IDENTIFIER));
// assay is still an amplicon assay but if it has an amplicon library we should move the files from amplicon assay to amplicon library assay // assay is still an amplicon assay but if it has an amplicon library we should move the files from amplicon assay to amplicon library assay
if (assayType.equals(AssayType.AmpliconLibrary)) { // if (assayType.equals(AssayType.AmpliconLibrary)) {
AmpliconAssay ampliconAssay = (AmpliconAssay) assay; // AmpliconAssay ampliconAssay = (AmpliconAssay) assay;
AmpliconLibraryAssay library = ampliconAssay.getLibrary(); // AmpliconLibraryAssay library = ampliconAssay.getLibrary();
for (Data_sample data_sample : ampliconAssay.getAllHasPart()) { // for (Data_sample data_sample : ampliconAssay.getAllHasPart()) {
library.addHasPart(data_sample); // library.addHasPart(data_sample);
ampliconAssay.remHasPart(data_sample); // ampliconAssay.remHasPart(data_sample);
} // }
} // }
// Perform reference incorporation // Perform reference incorporation
if (header.indexOf(REFERENCE) != -1) { if (header.indexOf(REFERENCE) != -1) {
......
...@@ -274,7 +274,9 @@ public class TemplateView extends Div { ...@@ -274,7 +274,9 @@ public class TemplateView extends Div {
VerticalLayout placeholder = new VerticalLayout(); VerticalLayout placeholder = new VerticalLayout();
createPackageSelectionGrid(placeholder, metadata, help, false); createPackageSelectionGrid(placeholder, metadata, help, false);
verticalLayouts.add(placeholder); verticalLayouts.add(placeholder);
assayLayout.add(addAssayButton, removeAssayButton); HorizontalLayout assayButtons = new HorizontalLayout();
assayButtons.add(addAssayButton, removeAssayButton);
assayLayout.add(assayButtons);
assayLayout.add(verticalLayouts.get(0)); assayLayout.add(verticalLayouts.get(0));
// Button to add another assay to the assay layout // Button to add another assay to the assay layout
......
Supports Markdown
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