diff --git a/src/main/java/gui/core/aptamer/pool/AptamerPoolRootController.java b/src/main/java/gui/core/aptamer/pool/AptamerPoolRootController.java index 5b1308c..2ebdba4 100644 --- a/src/main/java/gui/core/aptamer/pool/AptamerPoolRootController.java +++ b/src/main/java/gui/core/aptamer/pool/AptamerPoolRootController.java @@ -987,8 +987,6 @@ private void computeIndexOrder(ProgressPaneController pp) { // Temporarily store the counts in an array as random access to mapdb is slow but sequential access is fast int[] counts = new int[aptamer_ids.length]; - System.out.println("here"); - // Provide a progress bar for this operation pp.setShowProgressBar(true); @@ -1019,9 +1017,6 @@ public void run() { pp.setProgress(items_to_sort.doubleValue()/cycle_to_sort_by.getUniqueSize() ); pp.setProgressLabel(String.format("Retrieved %s/%s items (%.2f%%)", items_to_sort.get(), cycle_to_sort_by.getUniqueSize(), (items_to_sort.doubleValue()/cycle_to_sort_by.getUniqueSize())*100.0) ); - System.out.println(items_to_sort.get() + " " + cycle_to_sort_by.getUniqueSize()); - System.out.flush(); - // Once every half a second should suffice Thread.sleep(500); diff --git a/src/main/java/gui/wizards/newexperiment/DataModel.java b/src/main/java/gui/wizards/newexperiment/DataModel.java index d68f85d..892387b 100644 --- a/src/main/java/gui/wizards/newexperiment/DataModel.java +++ b/src/main/java/gui/wizards/newexperiment/DataModel.java @@ -79,6 +79,8 @@ public class DataModel { private SimpleIntegerProperty aptaplexParserPrimerTolerance = new SimpleIntegerProperty( Configuration.getDefaults().containsKey("AptaplexParser.PrimerTolerance") ? Configuration.getDefaults().getInt("AptaplexParser.PrimerTolerance") : Configuration.getParameters().getInt("AptaplexParser.PrimerTolerance") ); private File lastSelectedDirectory = null; + + private BooleanProperty noPrimers = new SimpleBooleanProperty(false); /** @@ -438,6 +440,19 @@ public SimpleIntegerProperty getAptaplexParserPrimerTolerance() { public void setAptaplexParserPrimerTolerance(SimpleIntegerProperty aptaplexParserPrimerTolerance) { this.aptaplexParserPrimerTolerance = aptaplexParserPrimerTolerance; } - + + /** + * @return the noPrimers + */ + public BooleanProperty getNoPrimers() { + return noPrimers; + } + + /** + * @param aptaplexParserPrimerTolerance the aptaplexParserPrimerTolerance to set + */ + public void setNoPrimers(BooleanProperty noPrimers) { + this.noPrimers = noPrimers; + } } diff --git a/src/main/java/gui/wizards/newexperiment/Wizard1Controller.java b/src/main/java/gui/wizards/newexperiment/Wizard1Controller.java index 8cff286..d3b9dfb 100644 --- a/src/main/java/gui/wizards/newexperiment/Wizard1Controller.java +++ b/src/main/java/gui/wizards/newexperiment/Wizard1Controller.java @@ -98,6 +98,9 @@ public class Wizard1Controller{ @FXML private CheckBox rangeLengthCheckBox; + @FXML + private CheckBox noPrimersCheckbox; + private List selectionCycleDetailsControllers = new ArrayList(); @@ -141,6 +144,28 @@ public void init() { randomizedRegionSizeLowerSpinner.getValueFactory().valueProperty().bindBidirectional(getDataModel().getRandomizedRegionSizeLower()); randomizedRegionSizeUpperSpinner.getValueFactory().valueProperty().bindBidirectional(getDataModel().getRandomizedRegionSizeUpper()); + noPrimersCheckbox.selectedProperty().bindBidirectional(getDataModel().getNoPrimers()); + + // Prevent access to "No primer" checkbox if data is not demultiplexed or paired end. + noPrimersCheckbox.disableProperty().bind(Bindings.or(getDataModel().getIsDemultiplexed().not(), getDataModel().getIsPairedEnd())); + + // Disable primer input if user has selected the noPrimerCheckbox + primer5TextField.disableProperty().bind(noPrimersCheckbox.selectedProperty()); + primer3TextField.disableProperty().bind(noPrimersCheckbox.selectedProperty()); + + // Clear the primer text fields if the user checks the "No Primer" checkbox + noPrimersCheckbox.selectedProperty().addListener((obs, wasSelected, isNowSelected) -> { + if (isNowSelected) { + primer5TextField.clear(); + primer3TextField.clear(); + } + }); + + // If the checkbox is disabled, we need to unselect it + if (noPrimersCheckbox.isDisabled()) { + getDataModel().getNoPrimers().set(false); + } + // Make sure that either only the exact size or the range or non of them is selected exactLengthCheckBox.selectedProperty().addListener((obs, wasSelected, isNowSelected) -> { if (isNowSelected) { @@ -210,8 +235,8 @@ public boolean validateData() { // First the trivial things: - // Make sure the 5' primer is present - if (primer5TextField.textProperty().isEmpty().get()) { + // Make sure the 5' primer is present, but only if we are not in batch mode + if (primer5TextField.textProperty().isEmpty().get() && noPrimersCheckbox.selectedProperty().not().get()) { ControlFXValidatorFactory.setTemporaryValidation( primer5TextField, @@ -225,8 +250,9 @@ public boolean validateData() { } - // Make sure that either the 3' primer is present or the randomized region size is not 0 - if (primer3TextField.textProperty().isEmpty().get() && randomizedRegionSizeSpinner.getValueFactory().getValue().equals(0)) { + + // Make sure that either the 3' primer is present or the randomized region size is not 0 and we are not in batch mode + if (primer3TextField.textProperty().isEmpty().get() && randomizedRegionSizeSpinner.getValueFactory().getValue().equals(0) && noPrimersCheckbox.selectedProperty().not().get()) { ControlFXValidatorFactory.setTemporaryValidation( primer3TextField, @@ -248,6 +274,36 @@ public boolean validateData() { } + // Make sure that if we are in batch mode we have either a fixed randomized region size or a range + if (noPrimersCheckbox.selectedProperty().get() && exactLengthCheckBox.selectedProperty().not().get() && this.rangeLengthCheckBox.selectedProperty().not().get()) { + + ControlFXValidatorFactory.setTemporaryValidation( + exactLengthCheckBox, + ControlFXValidatorFactory.AllwaysWrongValidator("Either an exact randomized region or a range must be specified."), + this.validationSupport, + ControlFXValidatorFactory.AllwaysCorrectValidator, + false + ); + + is_valid = false; + + } + + // Make sure that if an exact length is specified it must be greater than 0 + if (this.exactLengthCheckBox.isSelected() && randomizedRegionSizeSpinner.getValueFactory().getValue() <= 0) { + + ControlFXValidatorFactory.setTemporaryValidation( + randomizedRegionSizeSpinner, + ControlFXValidatorFactory.AllwaysWrongValidator("Randomized region size must be greater than zero."), + this.validationSupport, + ControlFXValidatorFactory.AllwaysCorrectValidator, + false + ); + + is_valid = false; + + } + // Make sure that if a range for the randomized region size is specified, it is a valid one if (this.rangeLengthCheckBox.isSelected()) { @@ -757,6 +813,12 @@ public boolean validateData() { } + if (getDataModel().getNoPrimers().get()) { + + utilities.Configuration.getParameters().setProperty("AptaplexParser.BatchMode", true); + + } + // Save to file utilities.Configuration.writeConfiguration(); diff --git a/src/main/java/gui/wizards/newexperiment/Wizard2Controller.java b/src/main/java/gui/wizards/newexperiment/Wizard2Controller.java index d3e65b4..dbf1ff1 100644 --- a/src/main/java/gui/wizards/newexperiment/Wizard2Controller.java +++ b/src/main/java/gui/wizards/newexperiment/Wizard2Controller.java @@ -122,7 +122,7 @@ public void init() { /** - * Instaniates a new Experiment and starts AptaPLEX + * Instantiates a new Experiment and starts AptaPLEX * @param event */ @FXML diff --git a/src/main/java/gui/wizards/newexperiment/wizard1.fxml b/src/main/java/gui/wizards/newexperiment/wizard1.fxml index 54dc00d..def6d76 100644 --- a/src/main/java/gui/wizards/newexperiment/wizard1.fxml +++ b/src/main/java/gui/wizards/newexperiment/wizard1.fxml @@ -14,7 +14,7 @@ - + @@ -72,6 +72,11 @@ + + + + +