<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~  DecontamDialog.fxml Copyright (C) 2020. Daniel H. Huson GPL
  ~   
  ~   (Some files contain contributions from other authors, who are then mentioned separately.)
  ~   
  ~   This program is free software: you can redistribute it and/or modify
  ~   it under the terms of the GNU General Public License as published by
  ~   the Free Software Foundation, either version 3 of the License, or
  ~   (at your option) any later version.
  ~   
  ~   This program is distributed in the hope that it will be useful,
  ~   but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~   GNU General Public License for more details.
  ~   
  ~   You should have received a copy of the GNU General Public License
  ~   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  ~
  -->

<?import javafx.geometry.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="430.0" prefWidth="620.0" xmlns="http://javafx.com/javafx/8.0.111"
            xmlns:fx="http://javafx.com/fxml/1" fx:controller="megan.fx.dialogs.decontam.DecontamDialogController">
    <children>
        <TextField editable="false" focusTraversable="false" prefColumnCount="35"
                   style="-fx-background-color: transparent;"
                   text="Cite:  Davis et al (2018), https://doi.org/10.1186/s40168-018-0605-2"
                   AnchorPane.bottomAnchor="7.0" AnchorPane.leftAnchor="0.0">
            <font>
                <Font size="12.0"/>
            </font>
        </TextField>
        <BorderPane prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
                    AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
            <center>
                <TabPane BorderPane.alignment="CENTER">
                    <tabs>
                        <Tab fx:id="setupTab" text="Setup">
                            <content>
                                <VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0">
                                    <children>
                                        <HBox alignment="CENTER_LEFT" layoutX="20.0" layoutY="193.0" prefHeight="36.0">
                                            <children>
                                                <Label text="Taxonomic rank:">
                                                    <HBox.margin>
                                                        <Insets/>
                                                    </HBox.margin>
                                                </Label>
                                                <ChoiceBox fx:id="taxonomicRankCBox" prefWidth="150.0">
                                                    <HBox.margin>
                                                        <Insets left="27.0"/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip
                                                                text="Taxonomic rank on which to determine contaminants on"/>
                                                    </tooltip>
                                                </ChoiceBox>
                                                <CheckBox fx:id="projectCheckBox" mnemonicParsing="false"
                                                          text="Project on to rank">
                                                    <HBox.margin>
                                                        <Insets left="17.0"/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip text="Project all counts to selected taxonomic rank"/>
                                                    </tooltip>
                                                </CheckBox>
                                            </children>
                                        </HBox>
                                        <Separator layoutX="20.0" layoutY="158.0" prefWidth="200.0"/>
                                        <HBox alignment="CENTER_LEFT" prefHeight="36.0" VBox.vgrow="NEVER">
                                            <children>
                                                <RadioButton fx:id="frequencyMethodRadioButton" mnemonicParsing="false"
                                                             text="Frequency method">
                                                    <HBox.margin>
                                                        <Insets/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip
                                                                text="Contaminants are identified by frequency that varies inversely with sample DNA concentration."/>
                                                    </tooltip>
                                                </RadioButton>
                                                <Label text="Concentration attribute:">
                                                    <HBox.margin>
                                                        <Insets left="23.0"/>
                                                    </HBox.margin>
                                                </Label>
                                                <ChoiceBox fx:id="concentrationAttributeCBox" prefWidth="150.0">
                                                    <HBox.margin>
                                                        <Insets left="5.0"/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip
                                                                text="Sample atttribute containing quantative concentration of amplified DNA"/>
                                                    </tooltip>
                                                </ChoiceBox>
                                            </children>
                                        </HBox>
                                        <HBox alignment="CENTER_LEFT" layoutX="15.0" layoutY="15.0" prefHeight="36.0">
                                            <children>
                                                <RadioButton fx:id="prevelanceMethodRadioButton" mnemonicParsing="false"
                                                             text="Prevelance method">
                                                    <HBox.margin>
                                                        <Insets/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip
                                                                text="Contaminants are identified by increased prevalence in negative controls."/>
                                                    </tooltip>
                                                </RadioButton>
                                                <Label text="Negative control attr.:">
                                                    <HBox.margin>
                                                        <Insets left="20.0"/>
                                                    </HBox.margin>
                                                </Label>
                                                <ChoiceBox fx:id="negativeControlCBox" prefWidth="150.0">
                                                    <HBox.margin>
                                                        <Insets left="18.0"/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip
                                                                text="Attribute indicating which samples are negative controls"/>
                                                    </tooltip>
                                                </ChoiceBox>
                                                <Label layoutX="170.0" layoutY="20.0" text="Value:">
                                                    <HBox.margin>
                                                        <Insets left="10.0"/>
                                                    </HBox.margin>
                                                </Label>
                                                <TextField fx:id="negativeControlTextField" prefColumnCount="6">
                                                    <HBox.margin>
                                                        <Insets left="5.0"/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip text="Value indicating negative control"/>
                                                    </tooltip>
                                                </TextField>
                                            </children>
                                        </HBox>
                                        <HBox alignment="CENTER_LEFT" layoutX="15.0" layoutY="56.0" prefHeight="36.0"
                                              spacing="20.0">
                                            <children>
                                                <RadioButton fx:id="combinedRadioButton" mnemonicParsing="false"
                                                             text="Combined">
                                                    <HBox.margin>
                                                        <Insets/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip
                                                                text="The frequency and prevalence probabilities are combined with Fisher's method and used to identify contaminants"/>
                                                    </tooltip>
                                                </RadioButton>
                                                <RadioButton fx:id="minimumRadioButton" layoutX="10.0" layoutY="19.0"
                                                             mnemonicParsing="false" text="Minimum">
                                                    <tooltip>
                                                        <Tooltip
                                                                text="The minimum of the frequency and prevalence probabilities is used to identify contaminants"/>
                                                    </tooltip>
                                                </RadioButton>
                                                <RadioButton fx:id="eitherRadioButton" layoutX="91.0" layoutY="19.0"
                                                             mnemonicParsing="false" text="Either">
                                                    <tooltip>
                                                        <Tooltip
                                                                text="Contaminants are called if identified by either the frequency or prevalance methods"/>
                                                    </tooltip>
                                                </RadioButton>
                                                <RadioButton fx:id="bothRadioButton" layoutX="172.0" layoutY="19.0"
                                                             mnemonicParsing="false" text="Both">
                                                    <tooltip>
                                                        <Tooltip
                                                                text="Contaminants are called if identified by both the frequency and prevalance methods"/>
                                                    </tooltip>
                                                </RadioButton>
                                            </children>
                                        </HBox>
                                        <Separator prefWidth="200.0"/>
                                        <HBox alignment="CENTER_LEFT" layoutX="15.0" layoutY="15.0" prefHeight="36.0">
                                            <children>
                                                <CheckBox fx:id="batchesCheckBox" mnemonicParsing="false"
                                                          text="Batch attribute:">
                                                    <tooltip>
                                                        <Tooltip
                                                                text="Process samples in batches as defined by attribute (same value means same batch)"/>
                                                    </tooltip>
                                                </CheckBox>
                                                <ChoiceBox fx:id="batchesCBox" prefWidth="150.0">
                                                    <HBox.margin>
                                                        <Insets left="10.0"/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip
                                                                text="Attribute that defines batches (same value indicates same batch)"/>
                                                    </tooltip>
                                                </ChoiceBox>
                                                <Label text="Batch combine:">
                                                    <padding>
                                                        <Insets left="15.0"/>
                                                    </padding>
                                                </Label>
                                                <ChoiceBox fx:id="batchedCombineCBox" prefWidth="150.0">
                                                    <HBox.margin>
                                                        <Insets left="10.0"/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip text="How batches are combined"/>
                                                    </tooltip>
                                                </ChoiceBox>
                                            </children>
                                        </HBox>
                                        <Separator layoutX="15.0" layoutY="138.0" prefWidth="200.0"/>
                                        <HBox alignment="CENTER_LEFT" layoutX="20.0" layoutY="20.0" prefHeight="36.0">
                                            <children>
                                                <Label text="Threshold:">
                                                    <HBox.margin>
                                                        <Insets/>
                                                    </HBox.margin>
                                                </Label>
                                                <TextField fx:id="thresholdTextField" prefColumnCount="11">
                                                    <HBox.margin>
                                                        <Insets left="12.0"/>
                                                    </HBox.margin>
                                                    <tooltip>
                                                        <Tooltip
                                                                text="The probability threshold below which the null-hypothesis (not a contaminant) should be rejected in favor of the alternate hypothesis (contaminant). Two values can be provided when using the either or both methods: the first value is the threshold for the frequency test and the second for the prevalence test."/>
                                                    </tooltip>
                                                </TextField>
                                            </children>
                                        </HBox>
                                    </children>
                                    <padding>
                                        <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
                                    </padding>
                                </VBox>
                            </content>
                        </Tab>
                        <Tab fx:id="frequencyTab" text="Frequency">
                            <content>
                                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                                    <children>
                                        <VBox spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
                                              AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                            <children>
                                                <HBox alignment="CENTER_LEFT" spacing="10.0">
                                                    <children>
                                                        <Label text="Taxon:"/>
                                                        <ChoiceBox fx:id="frequencyPlotTaxonCBox" prefWidth="150.0">
                                                            <tooltip>
                                                                <Tooltip text="Taxon to show in scatterplot"/>
                                                            </tooltip>
                                                        </ChoiceBox>
                                                    </children>
                                                </HBox>
                                                <HBox layoutX="10.0" layoutY="110.0" VBox.vgrow="ALWAYS">
                                                    <children>
                                                        <ScatterChart fx:id="frequencyScatterPlot" legendSide="RIGHT"
                                                                      HBox.hgrow="ALWAYS">
                                                            <xAxis>
                                                                <CategoryAxis side="BOTTOM"/>
                                                            </xAxis>
                                                            <yAxis>
                                                                <NumberAxis side="LEFT"/>
                                                            </yAxis>
                                                        </ScatterChart>
                                                    </children>
                                                </HBox>
                                            </children>
                                            <padding>
                                                <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
                                            </padding>
                                        </VBox>
                                        <HBox AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
                                            <children>
                                                <Button fx:id="addFrequencyTabButton" layoutX="10.0" layoutY="10.0"
                                                        mnemonicParsing="false" text="+">
                                                    <font>
                                                        <Font size="10.0"/>
                                                    </font>
                                                    <tooltip>
                                                        <Tooltip text="Duplicate this tab"/>
                                                    </tooltip>
                                                </Button>
                                            </children>
                                        </HBox>
                                    </children>
                                </AnchorPane>
                            </content>
                        </Tab>
                        <Tab fx:id="prevalenceTab" text="Prevalence">
                            <content>
                                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                                    <children>
                                        <VBox spacing="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
                                              AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                            <children>
                                                <HBox alignment="CENTER_LEFT" spacing="10.0">
                                                    <children>
                                                        <Label text="Taxon:"/>
                                                        <ChoiceBox fx:id="prevalencePlotTaxonCBox" prefWidth="150.0">
                                                            <tooltip>
                                                                <Tooltip text="Taxon to show in scatterplot"/>
                                                            </tooltip>
                                                        </ChoiceBox>
                                                    </children>
                                                </HBox>
                                                <HBox VBox.vgrow="ALWAYS">
                                                    <children>
                                                        <ScatterChart fx:id="prevalenceScatterPlot" legendSide="RIGHT"
                                                                      HBox.hgrow="ALWAYS">
                                                            <xAxis>
                                                                <CategoryAxis side="BOTTOM"/>
                                                            </xAxis>
                                                            <yAxis>
                                                                <NumberAxis side="LEFT"/>
                                                            </yAxis>
                                                        </ScatterChart>
                                                    </children>
                                                </HBox>
                                            </children>
                                            <padding>
                                                <Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
                                            </padding>
                                        </VBox>
                                        <HBox AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
                                            <children>
                                                <Button fx:id="addPrevalenceTabButton" mnemonicParsing="false" text="+">
                                                    <font>
                                                        <Font size="10.0"/>
                                                    </font>
                                                    <tooltip>
                                                        <Tooltip text="Duplicate this tab"/>
                                                    </tooltip>
                                                </Button>
                                            </children>
                                        </HBox>
                                    </children>
                                </AnchorPane>
                            </content>
                        </Tab>
                        <Tab fx:id="saveTab" text="Save">
                            <content>
                                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                                    <children>
                                        <VBox prefHeight="200.0" prefWidth="100.0" spacing="40.0"
                                              AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
                                              AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                            <children>
                                                <HBox alignment="CENTER_LEFT" prefHeight="36.0">
                                                    <children>
                                                        <CheckBox fx:id="saveToFileCheckBox" mnemonicParsing="false"
                                                                  text="Save contaminants to file:">
                                                            <tooltip>
                                                                <Tooltip
                                                                        text="Save list of deterrmined contaminants to file. This can then be used in contamination filter."/>
                                                            </tooltip>
                                                        </CheckBox>
                                                        <TextField fx:id="outputFileTextField" HBox.hgrow="ALWAYS">
                                                            <HBox.margin>
                                                                <Insets left="10.0"/>
                                                            </HBox.margin>
                                                            <tooltip>
                                                                <Tooltip text="Text file to save contaminants to"/>
                                                            </tooltip>
                                                        </TextField>
                                                        <Button fx:id="outputFileBrowseButton" mnemonicParsing="false"
                                                                text="Browse">
                                                            <HBox.margin>
                                                                <Insets left="5.0" right="5.0"/>
                                                            </HBox.margin>
                                                        </Button>
                                                    </children>
                                                </HBox>
                                                <HBox alignment="CENTER_LEFT" layoutX="20.0" layoutY="50.0"
                                                      prefHeight="36.0">
                                                    <children>
                                                        <CheckBox fx:id="saveReportCheckBox" mnemonicParsing="false"
                                                                  text="Save report to file:">
                                                            <tooltip>
                                                                <Tooltip text="Save report to file"/>
                                                            </tooltip>
                                                        </CheckBox>
                                                        <TextField fx:id="reportFileTextField" HBox.hgrow="ALWAYS">
                                                            <HBox.margin>
                                                                <Insets left="10.0"/>
                                                            </HBox.margin>
                                                            <tooltip>
                                                                <Tooltip text="Text file to save report to"/>
                                                            </tooltip>
                                                        </TextField>
                                                        <Button fx:id="reportFileBrowseButton" mnemonicParsing="false"
                                                                text="Browse">
                                                            <HBox.margin>
                                                                <Insets left="5.0" right="5.0"/>
                                                            </HBox.margin>
                                                        </Button>
                                                    </children>
                                                </HBox>
                                                <HBox>
                                                    <children>
                                                        <CheckBox fx:id="previewCheckBox" mnemonicParsing="false"
                                                                  text="Preview in new comparison window"/>
                                                    </children>
                                                </HBox>
                                                <HBox VBox.vgrow="ALWAYS"/>
                                            </children>
                                            <padding>
                                                <Insets bottom="10.0" left="10.0" right="10.0" top="40.0"/>
                                            </padding>
                                        </VBox>
                                    </children>
                                </AnchorPane>
                            </content>
                        </Tab>
                    </tabs>
                </TabPane>
            </center>
            <top>
                <HBox alignment="CENTER" prefHeight="30.0" BorderPane.alignment="CENTER">
                    <children>
                        <Label text="Decontam - determination of contaminants"/>
                    </children>
                </HBox>
            </top>
            <bottom>
                <ButtonBar style="-fx-border-color: lightgray;" BorderPane.alignment="CENTER">
                    <buttons>
                        <Button fx:id="closeButton" cancelButton="true" mnemonicParsing="false" text="Close"/>
                        <Button fx:id="saveButton" mnemonicParsing="false" prefWidth="65.0" text="Save">
                            <tooltip>
                                <Tooltip text="Save contaminant profile"/>
                            </tooltip>
                        </Button>
                        <Button fx:id="applyButton" defaultButton="true" mnemonicParsing="false" text="Apply">
                            <tooltip>
                                <Tooltip text="Apply contam analysis using current setup"/>
                            </tooltip>
                        </Button>
                    </buttons>
                    <padding>
                        <Insets bottom="5.0" left="10.0" right="15.0" top="5.0"/>
                    </padding>
                </ButtonBar>
            </bottom>
        </BorderPane>
    </children>
</AnchorPane>
