Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2545,4 +2545,4 @@ bin/
/javafx/src/javafx.web/javafx/scene/web/WebView.java
/javafx/src/javafx.web/module-info.java
/javafx/src.zip
/test_output/ynb.xlsx
/test_output/ynb.xlsx
1 change: 1 addition & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
requires javafx.graphics;
requires javafx.controls;
requires org.apache.commons.compress;
requires java.logging;
exports org.awdevelopment.smithlab;
exports org.awdevelopment.smithlab.gui;
exports org.awdevelopment.smithlab.gui.controllers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public class MainApplication extends javafx.application.Application {
private static final FXMLResourceType DEFAULT_FXML_RESOURCE = FXMLResourceType.APPLICATION;

public static void main(String[] args) {
if (args.length == 0) launch();
if (args.length == 0) {
launch();

}
else {
Arguments arguments = new Arguments(args, LOGGER);
try {
Expand Down

This file was deleted.

5 changes: 5 additions & 0 deletions src/main/java/org/awdevelopment/smithlab/io/Headers.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public void addHeader(String header, int index) {
}
}

public Optional<Header> getConditionColumn() {
if (!conditionColumn) return Optional.empty();
return headers.stream().filter(header -> header.type() == HeaderType.CONDITION).findFirst();
}

public void addDay(short dayNumber, int index) {
for (short i = 0; i < 3; i++) {
days.add(new Day(dayNumber, index + i, i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class XlsxInputReader {
private final HashSet<Strain> strains;
private final HashSet<Condition> conditions;
private final LoggerHelper LOGGER;
private static final Condition DEFAULT_CONDITION = new Condition("Unknown");

public XlsxInputReader(File xlsxFile, LoggerHelper logger) {
this.xlsxFile = xlsxFile;
Expand Down Expand Up @@ -75,7 +76,13 @@ private Optional<Sample> readSampleFromRow(Headers headers, XSSFRow row) {
}
case HeaderType.STRAIN -> {
try {
strainOptional = Optional.of(readStrain(curCell));
Condition condition;
if (conditionOptional.isEmpty()) {
LOGGER.atWarn("Strain cell \"" + curCell.getRawValue() + "\" is missing a condition label! Labeling with \"Unknown\"");
condition = DEFAULT_CONDITION;
}
else condition = conditionOptional.get();
strainOptional = Optional.of(readStrain(curCell, condition));
} catch (InvalidStrainValueException e) {
LOGGER.atWarn(e + ": " + e.getMessage());
strainOptional = Optional.empty();
Expand Down Expand Up @@ -190,8 +197,29 @@ private int getInteger(XSSFCell cell) {
}

private Dilution readDilution(XSSFCell cell) throws InvalidDilutionValueException {
if (cell.getCellType() != CellType.NUMERIC) throw new InvalidDilutionValueException(cell.getRawValue(), cell.getRowIndex(), cell.getColumnIndex());
double cellValue = cell.getNumericCellValue();
double cellValue = -1.0;
LOGGER.atFatal("Reading dilution from cell with raw content: \""+cell.getRawValue()+"\"");
LOGGER.atFatal("Cell string value: \""+cell.getStringCellValue()+"\"");
LOGGER.atFatal("Cell address: "+cell.getAddress());
LOGGER.atFatal("Cell type: "+cell.getCellType());
if (cell.getCellType() == CellType.NUMERIC) {
cellValue = cell.getNumericCellValue();
} else if (cell.getCellType() == CellType.STRING) {
String cellContent = cell.getStringCellValue();
if (cellContent.equalsIgnoreCase("x1000")) {
return Dilution.x1000;
} else if (cellContent.equalsIgnoreCase("x100")) {
return Dilution.x100;
} else if (cellContent.equalsIgnoreCase("x10")) {
return Dilution.x10;
} else if (cellContent.equalsIgnoreCase("1")) {
return Dilution.x1000;
} else if (cellContent.equalsIgnoreCase("0.1")) {
return Dilution.x100;
} else if (cellContent.equalsIgnoreCase("0.01")) {
return Dilution.x10;
}
}
if (Math.abs(cellValue - 1) < DELTA) {
return Dilution.x1000;
} else if (Math.abs(cellValue - 0.1) < DELTA) {
Expand Down Expand Up @@ -225,22 +253,23 @@ private Condition readCondition(XSSFCell cell) throws InvalidConditionValueExcep
}
}

private Strain readStrain(XSSFCell cell) throws InvalidStrainValueException {
private Strain readStrain(XSSFCell cell, Condition condition) throws InvalidStrainValueException {
CellType cellType = cell.getCellType();
if (cellType == CellType.STRING) {
String cellContent = cell.getStringCellValue();
for (Strain strain : strains) {
if (strain.getName().equalsIgnoreCase(cellContent)) return strain;
}
Strain newStrain = new Strain(cellContent);
newStrain.setCondition(condition);
strains.add(newStrain);
return newStrain;
} else if (cellType == CellType.BLANK || cellType == CellType._NONE) {
int rowIndex = cell.getRowIndex();
int colIndex = cell.getColumnIndex();
for (int i = rowIndex - 1; i > 1; i--) {
XSSFCell nextCell = cell.getSheet().getRow(i).getCell(colIndex);
if (nextCell.getCellType() == CellType.STRING) return readStrain(nextCell);
if (nextCell.getCellType() == CellType.STRING) return readStrain(nextCell, condition);
}
throw new InvalidStrainValueException(cell.getRawValue(), cell.getRowIndex(), cell.getColumnIndex());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.awdevelopment.smithlab.config.SortOption;
import org.awdevelopment.smithlab.data.DayOutOfBoundsException;
import org.awdevelopment.smithlab.data.experiment.Experiment;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.awdevelopment.smithlab.data.Sample;
import org.awdevelopment.smithlab.io.exceptions.NoStrainsOrConditionsException;

import java.util.logging.Logger;

public class PrismOutputStyle extends OutputStyle {

public PrismOutputStyle(SortOption sortOption) {
Expand Down Expand Up @@ -43,9 +46,16 @@ private void generateData(XSSFSheet sheet, Experiment experiment) {
XSSFCell cell = row.createCell(j + 1);
String sheetName = sample.getBaselineCell().getSheet().getSheetName();
String baselineCellAddress = getStringCellAddress(sample.getBaselineCell());
String timepointCellAddress = getStringCellAddress(sample.getTimepointByDay(dayNumber).originalCell());
String dilutionCellAddress = getStringCellAddress(sample.getTimepointByDay(dayNumber).dilutionCell());
String cellFormula = "'" + sheetName + "'!" + timepointCellAddress + "*" + "'" + sheetName + "'!" + dilutionCellAddress + "/'" + sheetName + "'!" + baselineCellAddress;
String timepointCellAddress, dilutionCellAddress;
try {
timepointCellAddress = getStringCellAddress(sample.getTimepointByDay(dayNumber).originalCell());
dilutionCellAddress = getStringCellAddress(sample.getTimepointByDay(dayNumber).dilutionCell());
} catch (DayOutOfBoundsException d) {
Logger.getLogger(PrismOutputStyle.class.getName()).warning("Day " + dayNumber + " is out of bounds for sample " + sample.getOutputName() + ". Skipping...");
continue;
}
String dilutionMultiplierFormula = "IF('" + sheetName + "'!" + dilutionCellAddress + "=\"x1000\",1,IF('" + sheetName + "'!" + dilutionCellAddress + "=\"x100\",0.1,IF('" + sheetName + "'!" + dilutionCellAddress + "=\"x10\",0.01," + dilutionCellAddress + ")))";
String cellFormula = "'" + sheetName + "'!" + timepointCellAddress + "*" + dilutionMultiplierFormula + "/'" + sheetName + "'!" + baselineCellAddress;
cell.setCellFormula(cellFormula);
cell.setCellStyle(sheet.getWorkbook().createCellStyle());
cell.getCellStyle().setDataFormat(sheet.getWorkbook().createDataFormat().getFormat("0.000"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.awdevelopment.smithlab.config.SortOption;
import org.awdevelopment.smithlab.data.DayOutOfBoundsException;
import org.awdevelopment.smithlab.data.experiment.Experiment;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.awdevelopment.smithlab.data.Sample;
import org.awdevelopment.smithlab.io.exceptions.NoStrainsOrConditionsException;

import java.util.logging.Logger;

public class StatisticalTestsOutputStyle extends OutputStyle {

private final short numberOfReplicates;
Expand Down Expand Up @@ -125,9 +128,16 @@ private void generatePrimaryData(XSSFSheet sheet, Experiment experiment) {
case SAMPLE_NUMBER -> experiment.getSampleNumber(sampleCounter + 1);
};
String sheetName = sample.getBaselineCell().getSheet().getSheetName();
String timepointCellAddress = getStringCellAddress(sample.getTimepointByDay(experiment.getDayNumbers()[j]).originalCell());
String dilutionCellAddress = getStringCellAddress(sample.getTimepointByDay(experiment.getDayNumbers()[j]).dilutionCell());
String cellFormula = "'" + sheetName + "'!" + timepointCellAddress + "*" + "'" + sheetName + "'!" + dilutionCellAddress;
String timepointCellAddress, dilutionCellAddress;
try {
timepointCellAddress = getStringCellAddress(sample.getTimepointByDay(experiment.getDayNumbers()[j]).originalCell());
dilutionCellAddress = getStringCellAddress(sample.getTimepointByDay(experiment.getDayNumbers()[j]).dilutionCell());
} catch (DayOutOfBoundsException d) {
Logger.getLogger(StatisticalTestsOutputStyle.class.getName()).warning("Day " + experiment.getDayNumbers()[j] + " is out of bounds for sample " + sample.getOutputName() + ". Skipping...");
continue;
}
String dilutionMultiplierFormula = "IF('" + sheetName + "'!" + dilutionCellAddress + "=\"x1000\",1,IF('" + sheetName + "'!" + dilutionCellAddress + "=\"x100\",0.1,IF('" + sheetName + "'!" + dilutionCellAddress + "=\"x10\",0.01," + dilutionCellAddress + ")))";
String cellFormula = "'" + sheetName + "'!" + timepointCellAddress + "*" + dilutionMultiplierFormula;
cell.setCellFormula(cellFormula);
}
cell.setCellStyle(sheet.getWorkbook().createCellStyle());
Expand Down
Loading