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 {
for (observation_unit observation_unit : study.getAllHasPart()) {
for (Sample sample : observation_unit.getAllHasPart()) {
for (Assay assay : sample.getAllHasPart()) {
if (assay.getClassTypeIri().endsWith("AmpliconLibraryAssay")) {
AmpliconLibraryAssay assay1 = (AmpliconLibraryAssay) assay;
for (Data_sample data_sample : assay1.getAllHasPart()) {
data_sample.getName();
}
} else if (assay.getClassTypeIri().endsWith("AmpliconAssay")) {
AmpliconAssay assay1 = (AmpliconAssay) assay;
for (Data_sample data_sample : assay1.getAllHasPart()) {
data_sample.getName();
}
} else if (assay.getClassTypeIri().endsWith("RNASeqAssay")) {
RNASeqAssay assay1 = (RNASeqAssay) assay;
for (Data_sample data_sample : assay1.getAllHasPart()) {
data_sample.getName();
}
} else if (assay.getClassTypeIri().endsWith("DNASeqAssay")) {
DNASeqAssay assay1 = (DNASeqAssay) assay;
for (Data_sample data_sample : assay1.getAllHasPart()) {
// if (assay.getClassTypeIri().endsWith("AmpliconLibraryAssay")) {
// AmpliconLibraryAssay assay1 = (AmpliconLibraryAssay) assay;
// for (Data_sample data_sample : assay1.getAllHasPart()) {
// data_sample.getName();
// }
// } else if (assay.getClassTypeIri().endsWith("AmpliconAssay")) {
// AmpliconAssay assay1 = (AmpliconAssay) assay;
// for (Data_sample data_sample : assay1.getAllHasPart()) {
// data_sample.getName();
// }
// } else if (assay.getClassTypeIri().endsWith("RNASeqAssay")) {
// RNASeqAssay assay1 = (RNASeqAssay) assay;
// for (Data_sample data_sample : assay1.getAllHasPart()) {
// data_sample.getName();
// }
// } else if (assay.getClassTypeIri().endsWith("DNASeqAssay")) {
// DNASeqAssay assay1 = (DNASeqAssay) assay;
// 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();
}
} else {
......@@ -752,24 +757,30 @@ public class ExcelValidator {
logger.info("Parsing " + sheet.getSheetName());
ArrayList<String> header = new ArrayList<>();
// Assay type
AssayType assayType;
if (sheet.getSheetName().endsWith("AmpliconAssay")) {
assayType = AssayType.Amplicon;
} else if (sheet.getSheetName().endsWith("AmpliconLibrary")) {
assayType = AssayType.AmpliconLibrary;
} else if (sheet.getSheetName().endsWith("RNA")) {
assayType = AssayType.Transcriptomics;
} else if (sheet.getSheetName().toLowerCase().endsWith("illumina")) {
assayType = AssayType.Genomics;
} else if (sheet.getSheetName().toLowerCase().endsWith("nanopore")) {
assayType = AssayType.Genomics;
} else if (sheet.getSheetName().endsWith("Proteomics")) {
assayType = AssayType.Proteomics;
} else if (sheet.getSheetName().endsWith("Metabolomics")) {
assayType = AssayType.Metabolomics;
// Assay type after " - " split, strip, camel case it and then remove spaces and turn into a URI
String assayTypeIRI;
if (sheet.getSheetName().contains(" - ")) {
String[] name = sheet.getSheetName().split(" - ");
String assayName = name[name.length-1];
boolean validAssayName = false;
// Check if it is part of the excel package
for (Metadata metadata : metadataArrayList) {
if (metadata.getPackage().toLowerCase(Locale.ROOT).contains(assayName.toLowerCase(Locale.ROOT))) {
validAssayName = true;
break;
}
}
if (!validAssayName) {
throw new Exception("This assay name is not supported: " + assayName);
}
// Create IRI
assayName = StringUtils.capitalize(assayName).replaceAll(" +", "");
assayTypeIRI = "http://m-unlock.nl/ontology/" + assayName;
} 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
......@@ -803,8 +814,6 @@ public class ExcelValidator {
fileCell = row.getCell(header.indexOf(FORWARD_FILENAME), Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
} else if (header.indexOf(FILE_NAME) != -1) {
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
......@@ -853,65 +862,68 @@ public class ExcelValidator {
}
// 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
Assay assay;
// Section for amplicon / library data
if (assayType.equals(AssayType.Amplicon)) {
AmpliconAssay ampliconAssay = domain.make(AmpliconAssay.class, ASSAYIRI);
assay = ampliconAssay;
} else if (assayType.equals(AssayType.AmpliconLibrary)) {
// Create amplicon library object
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();
// logger.debug("Library " + assayLibraryIRI);
AmpliconLibraryAssay ampliconLibraryAssay = domain.make(AmpliconLibraryAssay.class, assayLibraryIRI);
String ampliconLibraryAssayIdentifier = getStringValueCell(row.getCell(header.indexOf(LIBRARY_NAME))).trim();
ampliconLibraryAssay.setIdentifier(ampliconLibraryAssayIdentifier);
ampliconLibraryAssay.setDescription("Amplicon library " + ampliconLibraryAssayIdentifier);
ampliconLibraryAssay.setLogicalPath("null");
// Cell can be numeric
// Sample sample = getSample(iriCorrector(getStringValueCell(row.getCell(header.indexOf("SampleIdentifier")))));
// TODO check if we should do this? Amplicon assay should be a library and attached to assay of type amplicon
// sample.addAssay(ampliconLibraryAssay);
// ampliconLibraryAssay.setSample(sample);
// parsedHeaders.add(LIBRARY_NAME);
// Skip identifier addition due to amplicon assays having many different identifiers for the same library
parsedHeaders.add(ASSAY_IDENTIFIER);
parsedHeaders.add(ASSAY_DESCRIPTION);
// Prevent adding file objects as strings
parsedHeaders.add(FORWARD_FILENAME);
parsedHeaders.add(REVERSE_FILENAME);
otherColumns(header, parsedHeaders, row, ampliconLibraryAssay.getResource().getURI(), metadataArrayList);
// 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);
// Make link to the amplicon library
ampliconAssay.setLibrary(ampliconLibraryAssay);
assay = ampliconAssay;
// Section for RNA sequencing data
} else if (assayType.equals(AssayType.Transcriptomics)) {
RNASeqAssay rnaSeqAssay = domain.make(RNASeqAssay.class, ASSAYIRI);
assay = rnaSeqAssay;
// Section for DNA sequencing data
} else if (assayType.equals(AssayType.Genomics)) {
DNASeqAssay dnaSeqAssay = domain.make(DNASeqAssay.class, ASSAYIRI);
assay = dnaSeqAssay;
} else {
throw new Exception(assayType.getIRI() + " not ready at the moment");
}
Assay assay = domain.make(Assay.class, ASSAYIRI);
assay.addAdditionalType(assayTypeIRI);
// // Section for amplicon / library data
// if (assayType.equals(AssayType.Amplicon)) {
// AmpliconAssay ampliconAssay = domain.make(AmpliconAssay.class, ASSAYIRI);
// assay = ampliconAssay;
// } else if (assayType.equals(AssayType.AmpliconLibrary)) {
// // Create amplicon library object
// 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();
//
// // logger.debug("Library " + assayLibraryIRI);
//
// AmpliconLibraryAssay ampliconLibraryAssay = domain.make(AmpliconLibraryAssay.class, assayLibraryIRI);
// String ampliconLibraryAssayIdentifier = getStringValueCell(row.getCell(header.indexOf(LIBRARY_NAME))).trim();
// ampliconLibraryAssay.setIdentifier(ampliconLibraryAssayIdentifier);
// ampliconLibraryAssay.setDescription("Amplicon library " + ampliconLibraryAssayIdentifier);
// ampliconLibraryAssay.setLogicalPath("null");
//
// // Cell can be numeric
//// Sample sample = getSample(iriCorrector(getStringValueCell(row.getCell(header.indexOf("SampleIdentifier")))));
// // TODO check if we should do this? Amplicon assay should be a library and attached to assay of type amplicon
// // sample.addAssay(ampliconLibraryAssay);
// // ampliconLibraryAssay.setSample(sample);
// // parsedHeaders.add(LIBRARY_NAME);
// // Skip identifier addition due to amplicon assays having many different identifiers for the same library
// parsedHeaders.add(ASSAY_IDENTIFIER);
// parsedHeaders.add(ASSAY_DESCRIPTION);
// // Prevent adding file objects as strings
// parsedHeaders.add(FORWARD_FILENAME);
// parsedHeaders.add(REVERSE_FILENAME);
//
// otherColumns(header, parsedHeaders, row, ampliconLibraryAssay.getResource().getURI(), metadataArrayList);
// // 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);
// // Make link to the amplicon library
// ampliconAssay.setLibrary(ampliconLibraryAssay);
// assay = ampliconAssay;
//
// // Section for RNA sequencing data
// } else if (assayType.equals(AssayType.Transcriptomics)) {
// RNASeqAssay rnaSeqAssay = domain.make(RNASeqAssay.class, ASSAYIRI);
// assay = rnaSeqAssay;
// // Section for DNA sequencing data
// } else if (assayType.equals(AssayType.Genomics)) {
// DNASeqAssay dnaSeqAssay = domain.make(DNASeqAssay.class, ASSAYIRI);
// assay = dnaSeqAssay;
// } 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
......@@ -923,7 +935,7 @@ public class ExcelValidator {
// parsedHeaders.addAll(Arrays.asList(ASSAY_DESCRIPTION, ASSAY_TITLE, ASSAY_IDENTIFIER, PLATFORM));
if (fileCell.getCellType().equals(CellType.BLANK)) {
// logging("No file found for " + assay.getResource().getURI());
logger.debug("No file found for " + assay.getResource().getURI());
} else {
String fileName = getStringValueCell(fileCell);
// Check the FileNameForwardPath and FileNameReversePath first
......@@ -970,7 +982,8 @@ public class ExcelValidator {
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.setName(new File(fileName).getName().trim());
singleSequenceDataSet.setContentUrl("null");
......@@ -987,6 +1000,15 @@ public class ExcelValidator {
assay.addHasPart(singleSequenceDataSet);
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 {
// 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
if (assayType.equals(AssayType.AmpliconLibrary)) {
AmpliconAssay ampliconAssay = (AmpliconAssay) assay;
AmpliconLibraryAssay library = ampliconAssay.getLibrary();
for (Data_sample data_sample : ampliconAssay.getAllHasPart()) {
library.addHasPart(data_sample);
ampliconAssay.remHasPart(data_sample);
}
}
// if (assayType.equals(AssayType.AmpliconLibrary)) {
// AmpliconAssay ampliconAssay = (AmpliconAssay) assay;
// AmpliconLibraryAssay library = ampliconAssay.getLibrary();
// for (Data_sample data_sample : ampliconAssay.getAllHasPart()) {
// library.addHasPart(data_sample);
// ampliconAssay.remHasPart(data_sample);
// }
// }
// Perform reference incorporation
if (header.indexOf(REFERENCE) != -1) {
......
......@@ -274,7 +274,9 @@ public class TemplateView extends Div {
VerticalLayout placeholder = new VerticalLayout();
createPackageSelectionGrid(placeholder, metadata, help, false);
verticalLayouts.add(placeholder);
assayLayout.add(addAssayButton, removeAssayButton);
HorizontalLayout assayButtons = new HorizontalLayout();
assayButtons.add(addAssayButton, removeAssayButton);
assayLayout.add(assayButtons);
assayLayout.add(verticalLayouts.get(0));
// 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