package com.cipres.mrBayesPlugin.ui; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.prefs.Preferences; import javax.swing.JFileChooser; import javax.swing.JPanel; import org.json.simple.JSONObject; import org.virion.jam.util.SimpleListener; import com.biomatters.geneious.publicapi.components.Dialogs; import com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument; import com.biomatters.geneious.publicapi.documents.sequence.SequenceAlignmentDocument; import com.biomatters.geneious.publicapi.documents.sequence.SequenceDocument; import com.biomatters.geneious.publicapi.plugin.DocumentOperationException; import com.biomatters.geneious.publicapi.plugin.Options; import com.biomatters.geneious.publicapi.plugin.Options.BooleanOption; import com.biomatters.geneious.publicapi.plugin.Options.ButtonOption; import com.biomatters.geneious.publicapi.plugin.Options.FileSelectionOption; import com.biomatters.geneious.publicapi.plugin.Options.MultipleLineStringOption; import com.biomatters.geneious.publicapi.plugin.Options.Option; import com.biomatters.geneious.publicapi.plugin.Options.StringOption; import com.biomatters.geneious.publicapi.utilities.FileUtilities; import com.cipres.mrBayesPlugin.utilities.MrBayesUtilities; import jebl.util.SafePrintWriter; public class RAxMLBBOptions extends CipresOptions { //private static final String OPTION_NAME = "RAxMLBB_CIPRES"; //private static final String GENEIOUS_NEX = "geneious.phylip"; //private static final String NEWLINE = System.getProperty("line.separator"); //private static final String SPACE = " "; //public static final String PROTEIN = "Protein"; //public static final String NUCLEOTIDE = "Nucleotide"; //private static final String DNA = "dna"; //private static final String ONE = "1"; //private static final String ZERO = "0"; //private static final String INVARIABLE = "I"; private static final String FREQUENCY = "F"; private static final String UNDERSCORE = "_"; private static final String DOT = "."; public static final String YES = "yes"; public static final String NO = "no"; /* public static final String DAYHOFF ="DAYHOFF"; public static final String DCMUT = "DCMUT"; public static final String JTT = "JTT"; public static final String MTREV = "MTREV"; public static final String WAG = "WAG"; public static final String RTREV = "RTREV"; public static final String CPREV = "CPREV"; public static final String VT = "VT"; public static final String BLOSUM62= "BLOSUM62"; public static final String MTMAM = "MTMAM"; public static final String LG = "LG"; public static final String GTR = "GTR"; */ // Options private static BooleanOption useCustomCommandBlock; private static MultipleLineStringOption commandBlockOption; private ButtonOption restoreButton; private ButtonOption restoreButton2; private static BooleanOption bootstrappingHaltAuto; private static IntegerOption numOfBootstraps; private static DoubleOption maxHoursToRun; private static IntegerOption nchars_; private static DoubleOption spaceBuffer; private static ComboBoxOption sequenceType; private static StringOption outgroup; private static StringOption constraint; private static ButtonOption constraintBrowse; private static StringOption binaryBackbone; private static ButtonOption binaryBackboneBrowse; //private static FileSelectionOption mixedPartitionedModel; private static StringOption mixedPartitionedModel; private static ButtonOption mixedPartitionedModelBrowse; private static BooleanOption many_partitions_; private static DoubleOption spaceBuffer2; private static StringOption excludeRangeOfPositionsFile; private static ButtonOption excludeRangeOfPositionsFileBrowse; private static ComboBoxOption proportionOfInvariableSites; private static ComboBoxOption proteinSubstitutionMatrix; private static ComboBoxOption useEmpiricalBaseFrequencies; private static BooleanOption maximumLikelihoodSearch; private static BooleanOption notUseBFGS; private static BooleanOption printBranchLengths; //private static JFileChooser jfc = new JFileChooser(); private static NameAndLabel[] nameAndLabels; private enum OptionIndex {USECUSTOMCOMMANDBLOCK, BOOTSTRAPPINGHALTAUTO, NUMOFBOOTSTRAPS, SPACEBUFFER, MAXHOURSTORUN, NCHARS_, SEQUENCETYPE, OUTGROUP, CONSTRAINT, BINARYBACKBONE, MIXEDPARTITIONEDMODEL, MANY_PARTITIONS_, SPACEBUFFER2, EXCLUDERANGEOFPOSITIONSFILE, PROPORTIONOFINVARIABLESITES, PROTEINSUBSTITUTIONMATRIX, USEEMPIRICALBASEFREQUENCIES, MAXIMUMLIKELIHOODSEARCH, NOTUSEBFGS, PRINTBRANCHLENGTHS} //private enum ParamType {VParam, InputParam, MetaData} static { GENEIOUS_FORMAT = "geneious.phylip"; nameAndLabels = new NameAndLabel[OptionIndex.values().length]; nameAndLabels[OptionIndex.USECUSTOMCOMMANDBLOCK.ordinal()] = new NameAndLabel("useCustomCommandBlock", "Use custom command block", "", ""); nameAndLabels[OptionIndex.BOOTSTRAPPINGHALTAUTO.ordinal()] = new NameAndLabel("bootstrappingHaltAuto", "Let RAxML halt bootstrapping automatically (HIGHLY recommended)", "use_bootstopping_", "This option instructs Raxml to automatically halt bootstrapping when certain criteria are met, instead of specifying the number of bootstraps for an analysis.
The exact criteria are specified/configured using subsequent entry fields."); nameAndLabels[OptionIndex.NUMOFBOOTSTRAPS.ordinal()] = new NameAndLabel("numOfBootstraps", "Number of bootstraps", "bootstop_", ""); nameAndLabels[OptionIndex.SPACEBUFFER.ordinal()] = new NameAndLabel("spaceBuffer", "SpaceBuffer", "", ""); nameAndLabels[OptionIndex.MAXHOURSTORUN.ordinal()] = new NameAndLabel("maxHoursToRun", "Maximum Hours to Run", "runtime_", "Estimate the maximum time your job will need to run.
" + "We recommend testimg initially with a < 0.5hr test run because Jobs set for 0.5 h or less depedendably run immediately in the \"debug\" queue.
" + "Once you are sure the configuration is correct, you then increase the time.
" + "The reason is that jobs > 0.5 h are submitted to the \"normal\" queue, where jobs configured for 1 or a few hours times may run sooner than jobs configured for the full 168 hours."); nameAndLabels[OptionIndex.SPACEBUFFER.ordinal()] = new NameAndLabel("spaceBuffer", "SpaceBuffer", "", ""); nameAndLabels[OptionIndex.NCHARS_.ordinal()] = new NameAndLabel("nchars_", "Number of patterns in your dataset", "nchars_", ""); nameAndLabels[OptionIndex.SEQUENCETYPE.ordinal()] = new NameAndLabel("sequenceType", "Sequence Type", "datatype_", ""); nameAndLabels[OptionIndex.OUTGROUP.ordinal()] = new NameAndLabel("outgroup", "Outgroup (one or more comma-separated outgroups)", "outgroup_", "The correct syntax for the box is outgroup1,outgroup2,outgroupn.
" + "If white space is introduced (e.g. outgroup1, outgroup2, outgroupn) the program will fail with the message \"Error, you must specify a model of substitution with the '-m' option\""); nameAndLabels[OptionIndex.CONSTRAINT.ordinal()] = new NameAndLabel("constraint", "Constraint (-g)", "constraint_", "This option allows you to specify an incomplete or comprehensive multifurcating constraint tree for the RAxML search in NEWICK format.
" + "Initially, multifurcations are resolved randomly.
" + "If the tree is incomplete (does not contain all taxa) the remaining taxa are added by using the MP criterion.
" + "Once a comprehensive (containing all taxa) bifurcating tree is computed, it is further optimized under ML respecting the given constraints.
" + "Important: If you specify a non-comprehensive constraint, e.g., a constraint tree that does not contain all taxa, RAxML will assume that any taxa that not found in the constraint topology are unconstrained, i.e., these taxa can be placed in any part of the tree.
" + "As an example consider an alignment with 10 taxa: Loach, Chicken, Human, Cow, Mouse, Whale, Seal, Carp, Rat, Frog. If, for example you would like Loach, Chicken, Human, Cow to be monophyletic you would specify the constraint tree as follows: ((Loach, Chicken, Human, Cow),(Mouse, Whale, Seal, Carp, Rat, Frog));
" + "Moreover, if you would like Loach, Chicken, Human, Cow to be monophyletic and in addition Human, Cow to be monophyletic within that clade you could specify: ((Loach, Chicken, (Human, Cow)),(Mouse, Whale, Seal, Carp, Rat, Frog));
" + "If you specify an incomplete constraint: ((Loach, Chicken, Human, Cow),(Mouse, Whale, Seal, Carp)); the two groups Loach, Chicken, Human, Cow and Mouse, Whale, Seal, Carp will be monophyletic, while Rat and Frog can end up anywhere in the tree."); nameAndLabels[OptionIndex.BINARYBACKBONE.ordinal()] = new NameAndLabel("binaryBackbone", "Binary Backbone (-r)", "binary_backbone_", "This option allows you to pass a binary/bifurcating constraint/backbone tree in NEWICK format to RAxML.
" + "Note that using this option only makes sense if this tree contains fewer taxa than the input alignment.
" + "The remaining taxa will initially be added by using the MP criterion. Once a comprehensive tree with all taxa has been obtained it will be optimized under ML respecting the restrictions of the constraint tree."); nameAndLabels[OptionIndex.MIXEDPARTITIONEDMODEL.ordinal()] = new NameAndLabel("mixedPartitionedModel", "Use a mixed/partitioned model? (-q)", "partition_", "The multipleModelFileName parameter (-q) allows you to upload a file that specifies the regions of your alignment for which an individual model of nucleotide substitution should be estimated.
" + "This will typically be used to infer trees for long (in terms of base pairs) multi-gene alignments.
" + "For example, if -m GTRGAMMA is used, individual alpha-shape parameters, GTR-rates, and empirical base frequencies will be estimated and optimized for each partition.
" + "Since Raxml can now handle mixed Amino Acid and DNA alignments, you must specify the data type in the partition file, before the partition name.
" + "For DNA, this means you have to add DNA to each line in the partition.
" + "For AA data you must specify the transition matrices for each partition: The AA substitution model must be the first entry in each line and must be separated by a comma from the gene name, just like the DNA token above.
" + "You can not assign different models of rate heterogeneity to different partitions, i.e. it will be CAT or CATI. for all partitions.
" + "Finally, if you have a concatenated DNA and AA alignments, with DNA data at positions 1 - 500 and AA data at 501-1000 with the WAG model the partition file should look as follows: DNA, gene1 = 1-500; WAG, gene2 = 501-1000.
" + "For more help see http://phylobench.vital-it.ch/raxml-bb/index.php?help=model."); nameAndLabels[OptionIndex.MANY_PARTITIONS_.ordinal()] = new NameAndLabel("many_partitions_", "My dataset has more than 99 partitions", "many_partitions_", ""); nameAndLabels[OptionIndex.SPACEBUFFER2.ordinal()] = new NameAndLabel("spaceBuffer2", "SpaceBuffer", "", ""); nameAndLabels[OptionIndex.EXCLUDERANGEOFPOSITIONSFILE.ordinal()] = new NameAndLabel("excludeRangeOfPositionsFile", "Create an input file that excludes the range of positions specifed in this file (-E)", "exclude_file_", "This option is used to excludes specific positions in the matrix.
" + "For example, uploading a file that contains the text: 100-200 300-400 will create a file that excludes all columns between positions 100 and 200 as well as all columns between positions 300 and 400.
" + "Note that the boundary numbers (positions 100, 200, 300, and 400) will also be excluded.
" + "To exclude a single column write (100-100). This option does not run an analysis but just prints an alignment file without the excluded columns.
" + "Save this file to your data area, and then run the real analysis.
" + "If you use a mixed model, an appropriately adapted model file will also be written.
" + "The ntax element of the phylip files is automatically corrected Example: raxmlHPC -E excl -s infile -m GTRCAT -q part -n TEST. In this case the files with columns excluded will be named infile.excl and part.excl."); nameAndLabels[OptionIndex.PROPORTIONOFINVARIABLESITES.ordinal()] = new NameAndLabel("proportionOfInvariableSites", "Estimate proportion of invariable sites (GTRGAMMA + I)", "invariable_", ""); nameAndLabels[OptionIndex.PROTEINSUBSTITUTIONMATRIX.ordinal()] = new NameAndLabel("proteinSubstitutionMatrix", "Protein Substitution Matrix", "prot_matrix_spec_", "Note: FLOAT and invariable sites (I) options are not exposed here.
" + "If you require this option, please contact mmiller@sdsc.edu.
" + "-m PROTCATmatrixName: analyses using the specified AA matrix + Optimization of substitution rates + Optimization of site-specific evolutionary rates which are categorized into numberOfCategories distinct rate categories for greater computational efficiency.
" + "Final tree might be evaluated automatically under PROTGAMMAmatrixName[f], depending on the tree search option.
" + "-m PROTGAMMAmatrixName[F] anyses use the specified AA matrix + Optimization of substitution rates + GAMMA model of rate heterogeneity (alpha parameter will be estimated).
" + "Available AA substitution models: DAYHOFF, DCMUT, JTT, MTREV, WAG, RTREV, CPREV, VT, BLOSUM62, MTMAM, LG, GTR.
" + "You can specify if you want to use empirical base frequencies.
" + "Please note that for mixed models you can in addition specify the per-gene AA model in the mixed model file (see manual for details).
" + "Also note that if you estimate AA GTR parameters on a partitioned dataset, they will be linked (estimated jointly) across all partitions to avoid over-parametrization."); nameAndLabels[OptionIndex.USEEMPIRICALBASEFREQUENCIES.ordinal()] = new NameAndLabel("useEmpiricalBaseFrequencies", "Use empirical base frequencies?", "empirical_", "The empirical base frequency command is relevant for the protein datatype, and is used as a suffix to the -m model string PROTGAMMA_____"); nameAndLabels[OptionIndex.MAXIMUMLIKELIHOODSEARCH.ordinal()] = new NameAndLabel("maximumLikelihoodSearch", "Find best tree using maximum likelihood search", "mlsearch_", "Tell RAxML to conduct a Rapid Bootstrap analysis (-x) and search for the best-scoring ML tree in one single program run."); nameAndLabels[OptionIndex.NOTUSEBFGS.ordinal()] = new NameAndLabel("notUseBFGS", "Don't use BFGS searching algorithm (--no-bfgs)", "no_bfgs_", "BFGS is a more efficient optimization algorithm for optimizing branch lengths and GTR parameters simultaneously. YUOu can disable it using this option"); nameAndLabels[OptionIndex.PRINTBRANCHLENGTHS.ordinal()] = new NameAndLabel("printBranchLengths", "Print branch lengths (-k)", "printbrlength_", "The -k option causes bootstrapped trees to be printed with branch lengths.
" + "The bootstraps will require a bit longer to run under this option because model parameters will be optimized at the end of each run under GAMMA or GAMMA+P-Invar respectively."); //nameAndLabels[OptionIndex.COMMANDBLOCKOPTION.ordinal()].name = "editCommandBlock"; //nameAndLabels[OptionIndex.COMMANDBLOCKOPTION.ordinal()].label = "Edit command block"; } //AnnotatedPluginDocument[] selectedDocuments = null; public RAxMLBBOptions(final AnnotatedPluginDocument[] selectedDocuments) throws DocumentOperationException { OPTION_NAME = "RAxML_BlackBox_CIPRES"; this.selectedDocuments = selectedDocuments; jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); //jfc.addActionListener(actionListener); /* beginAlignHorizontally(null, false); useCustomCommandBlock = addBooleanOption(nameAndLabels[OptionIndex.USECUSTOMCOMMANDBLOCK.ordinal()].name, nameAndLabels[OptionIndex.USECUSTOMCOMMANDBLOCK.ordinal()].label, false); final ButtonOption editCommandBlock = addButtonOption("editCommandBlock", "", "Edit command block"); final StringOption customCommandBlockStorage = addStringOption("customCommandBlock", "", ""); customCommandBlockStorage.setVisible(false); endAlignHorizontally(); useCustomCommandBlock.setValue(false); editCommandBlock.setEnabled(false); useCustomCommandBlock.addChangeListener(new SimpleListener() { public void objectChanged() { //set the edit button enabled state Boolean useCustomBlock = useCustomCommandBlock.getValue(); editCommandBlock.setEnabled(useCustomBlock); //store the custom command block if (useCustomBlock) { customCommandBlockStorage.setValue("Will set up some values here....."); } //set the enabled state of everything else // //for (Option o : allOptions) { // o.setEnabled(!useCustomCommandBlock.getValue()); //} // } }); editCommandBlock.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String commandBlock = ""; commandBlock = "Will set up some values here..."; final AutoHideLabelOption warning = new AutoHideLabelOption("warning", "If you change the command block in a way that affects the output files, Geneious may have trouble importing your results."); Options commandBlockOptions = new Options(MrBayesOptions.class) { protected JPanel createPanel() { JPanel panel = new JPanel(new BorderLayout()); panel.add(warning.getComponent(), BorderLayout.NORTH); panel.add(commandBlockOption.getComponent(), BorderLayout.CENTER); JPanel buttonHolder = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonHolder.add(restoreButton2.getComponent()); buttonHolder.add(restoreButton.getComponent()); panel.add(buttonHolder, BorderLayout.SOUTH); return panel; } }; warning.setSpanningComponent(true); commandBlockOptions.addCustomOption(warning); commandBlockOption = commandBlockOptions.addMultipleLineStringOption("commandBlock", "", commandBlock, 20, false); //commandBlockOption.setSpanningComponent(true); commandBlockOption.setValue(customCommandBlockStorage.getValue()); final String previousBlock = Preferences.userNodeForPackage(MrBayesOptions.class).get("mrbayesPreviousRunCommandBlock", ""); commandBlockOptions.beginAlignHorizontally("", false); restoreButton = commandBlockOptions.addButtonOption("restoreButton", "", "Restore from previous run"); restoreButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { commandBlockOption.setValue(previousBlock); } }); restoreButton2 = commandBlockOptions.addButtonOption("restoreButton2", "", "Restore from basic options"); restoreButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { commandBlockOption.setValue(commandBlockOption.getDefaultValue()); } }); if (previousBlock.equals("")) restoreButton.setEnabled(false); commandBlockOptions.endAlignHorizontally(); Dialogs.DialogOptions dopt = new Dialogs.DialogOptions(Dialogs.OK_CANCEL, "Custom command block"); dopt.setMaxWidth(999); if (Dialogs.showDialog(dopt, commandBlockOptions.getPanel()).equals(Dialogs.OK)) { customCommandBlockStorage.setValue(commandBlockOption.getValue()); } } }); */ addLabel(" "); addJobNameOption(this, selectedDocuments, 3); beginAlignHorizontally(null, false); final OptionValue[] sqType = new OptionValue[2]; sqType[0] = new OptionValue(PROTEIN.toLowerCase(), PROTEIN); sqType[1] = new OptionValue(DNA, NUCLEOTIDE); sequenceType = addComboBoxOption(nameAndLabels[OptionIndex.SEQUENCETYPE.ordinal()].name, nameAndLabels[OptionIndex.SEQUENCETYPE.ordinal()].label, sqType, sqType[1]); addLabel(" "); maxHoursToRun = addDoubleOption(nameAndLabels[OptionIndex.MAXHOURSTORUN.ordinal()].name, nameAndLabels[OptionIndex.MAXHOURSTORUN.ordinal()].label, 0.25, 0.1, 168.00); maxHoursToRun.setIncrement(0.1); nchars_ = addIntegerOption(nameAndLabels[OptionIndex.NCHARS_.ordinal()].name, nameAndLabels[OptionIndex.NCHARS_.ordinal()].label, 1000, 1, Integer.MAX_VALUE); //maxHoursToRun.setPreferredWidth(220); //addLabel(" "); //addLabel(" "); //addLabel(" "); addBuffer(this); endAlignHorizontally(); beginAlignHorizontally(null, false); bootstrappingHaltAuto = addBooleanOption(nameAndLabels[OptionIndex.BOOTSTRAPPINGHALTAUTO.ordinal()].name, nameAndLabels[OptionIndex.BOOTSTRAPPINGHALTAUTO.ordinal()].label, true); numOfBootstraps = addIntegerOption(nameAndLabels[OptionIndex.NUMOFBOOTSTRAPS.ordinal()].name, nameAndLabels[OptionIndex.NUMOFBOOTSTRAPS.ordinal()].label, 1, 1, Integer.MAX_VALUE); numOfBootstraps.setEnabled(false); //numOfBootstraps.setPreferredWidthForNumberOfDigits(12); //addLabel(" "); //addLabel(" "); //addLabel(" "); addBuffer(this); endAlignHorizontally(); /* bootstrappingHaltAuto.addChangeListener(new SimpleListener() { @Override public void objectChanged() { Boolean autoBootstrappingHalt = bootstrappingHaltAuto.getValue(); numOfBootstraps.setEnabled(!autoBootstrappingHalt); }; }); */ /* beginAlignHorizontally(null, true); spaceBuffer = addDoubleOption(nameAndLabels[OptionIndex.SPACEBUFFER.ordinal()].name, nameAndLabels[OptionIndex.SPACEBUFFER.ordinal()].label, 0.25, 0.25, Double.MAX_VALUE); maxHoursToRun = addDoubleOption(nameAndLabels[OptionIndex.MAXHOURSTORUN.ordinal()].name, nameAndLabels[OptionIndex.MAXHOURSTORUN.ordinal()].label, 0.25, 0.25, Double.MAX_VALUE); maxHoursToRun.setIncrement(0.25); spaceBuffer.setVisible(false); endAlignHorizontally(); */ beginAlignHorizontally(null, false); /* final OptionValue[] sqType = new OptionValue[2]; sqType[0] = new OptionValue(PROTEIN, PROTEIN); sqType[1] = new OptionValue(DNA, NUCLEOTIDE); addLabel(" "); sequenceType = addComboBoxOption(nameAndLabels[OptionIndex.SEQUENCETYPE.ordinal()].name, nameAndLabels[OptionIndex.SEQUENCETYPE.ordinal()].label, sqType, sqType[1]); */ //addLabel(" "); outgroup = addStringOption(nameAndLabels[OptionIndex.OUTGROUP.ordinal()].name, nameAndLabels[OptionIndex.OUTGROUP.ordinal()].label, ""); endAlignHorizontally(); beginAlignHorizontally(null, false); //addLabel(" "); constraint = addStringOption(nameAndLabels[OptionIndex.CONSTRAINT.ordinal()].name, nameAndLabels[OptionIndex.CONSTRAINT.ordinal()].label, ""); constraintBrowse = addButtonOption("constraintBrowse", "", "Browse"); constraintBrowse.addActionListener(new BrowseButtonActionListener(constraint, jfc)); ButtonOption constraintClear = addButtonOption("constraintClear", "", "Clear"); constraintClear.addActionListener(new ClearButtonActionListener(constraint)); binaryBackbone = addStringOption(nameAndLabels[OptionIndex.BINARYBACKBONE.ordinal()].name, nameAndLabels[OptionIndex.BINARYBACKBONE.ordinal()].label, ""); binaryBackboneBrowse = addButtonOption("binaryBackboneBrowse", "", "Browse"); binaryBackboneBrowse.addActionListener(new BrowseButtonActionListener(binaryBackbone, jfc)); ButtonOption binaryBackboneClear = addButtonOption("binaryBackboneClear", "", "Clear"); binaryBackboneClear.addActionListener(new ClearButtonActionListener(binaryBackbone)); //constraint.setPreferredWidth(200); setEnabled(OptionIndex.CONSTRAINT, false); //binaryBackbone.setPreferredWidth(200); endAlignHorizontally(); beginAlignHorizontally(null, false); //addLabel(" "); //mixedPartitionedModel = addFileSelectionOption(nameAndLabels[OptionIndex.MIXEDPARTITIONEDMODEL.ordinal()].name, nameAndLabels[OptionIndex.MIXEDPARTITIONEDMODEL.ordinal()].label, ""); mixedPartitionedModel = addStringOption(nameAndLabels[OptionIndex.MIXEDPARTITIONEDMODEL.ordinal()].name, nameAndLabels[OptionIndex.MIXEDPARTITIONEDMODEL.ordinal()].label, ""); mixedPartitionedModelBrowse = addButtonOption("mixedPartitionedModelBrowse", "", "Browse"); mixedPartitionedModelBrowse.addActionListener(new BrowseButtonActionListener(mixedPartitionedModel, jfc)); //mixedPartitionedModel.setAllowMultipleSelection(true); ButtonOption mixedPartitionedModelClear = addButtonOption("mixedPartitionedModelClear", "", "Clear"); mixedPartitionedModelClear.addActionListener(new ClearButtonActionListener(mixedPartitionedModel)); //spaceBuffer2 = addDoubleOption(nameAndLabels[OptionIndex.SPACEBUFFER2.ordinal()].name, nameAndLabels[OptionIndex.SPACEBUFFER2.ordinal()].label, 0.25, 0.25, Double.MAX_VALUE); //spaceBuffer2.setVisible(false); many_partitions_ = addBooleanOption(nameAndLabels[OptionIndex.MANY_PARTITIONS_.ordinal()].name, nameAndLabels[OptionIndex.MANY_PARTITIONS_.ordinal()].label, false); endAlignHorizontally(); beginAlignHorizontally(null, false); //addLabel(" "); excludeRangeOfPositionsFile = addStringOption(nameAndLabels[OptionIndex.EXCLUDERANGEOFPOSITIONSFILE.ordinal()].name, nameAndLabels[OptionIndex.EXCLUDERANGEOFPOSITIONSFILE.ordinal()].label, ""); excludeRangeOfPositionsFileBrowse = addButtonOption("excludeRangeOfPositionsFileBrowse", "", "Browse"); excludeRangeOfPositionsFileBrowse.addActionListener(new BrowseButtonActionListener(excludeRangeOfPositionsFile, jfc)); //excludeRangeOfPositionsFile.setShouldSaveValue(false); ButtonOption excludeRangeOfPositionsFileClear = addButtonOption("excludeRangeOfPositionsFileClear", "", "Clear"); excludeRangeOfPositionsFileClear.addActionListener(new ClearButtonActionListener(excludeRangeOfPositionsFile)); endAlignHorizontally(); beginAlignHorizontally(null, false); final OptionValue[] yesOrNo= new OptionValue[2]; yesOrNo[0] = new OptionValue(INVARIABLE, YES); yesOrNo[1] = new OptionValue("", NO); proportionOfInvariableSites = addComboBoxOption(nameAndLabels[OptionIndex.PROPORTIONOFINVARIABLESITES.ordinal()].name, nameAndLabels[OptionIndex.PROPORTIONOFINVARIABLESITES.ordinal()].label, yesOrNo, yesOrNo[1]); addLabel(" "); final OptionValue[] matrix= new OptionValue[12]; int idx = 0; matrix[idx++] = new OptionValue(DAYHOFF, DAYHOFF); matrix[idx++] = new OptionValue(DCMUT, DCMUT); matrix[idx++] = new OptionValue(JTT, JTT); matrix[idx++] = new OptionValue(MTREV, MTREV); matrix[idx++] = new OptionValue(WAG, WAG); matrix[idx++] = new OptionValue(RTREV, RTREV); matrix[idx++] = new OptionValue(CPREV, CPREV); matrix[idx++] = new OptionValue(VT, VT); matrix[idx++] = new OptionValue(BLOSUM62, BLOSUM62); matrix[idx++] = new OptionValue(MTMAM, MTMAM); matrix[idx++] = new OptionValue(LG, LG); matrix[idx++] = new OptionValue(GTR, GTR); proteinSubstitutionMatrix = addComboBoxOption(nameAndLabels[OptionIndex.PROTEINSUBSTITUTIONMATRIX.ordinal()].name, nameAndLabels[OptionIndex.PROTEINSUBSTITUTIONMATRIX.ordinal()].label, matrix, matrix[2]); proteinSubstitutionMatrix.setEnabled(false); yesOrNo[0] = new OptionValue(FREQUENCY, YES); addLabel(" "); useEmpiricalBaseFrequencies = addComboBoxOption(nameAndLabels[OptionIndex.USEEMPIRICALBASEFREQUENCIES.ordinal()].name, nameAndLabels[OptionIndex.USEEMPIRICALBASEFREQUENCIES.ordinal()].label, yesOrNo, yesOrNo[1]); useEmpiricalBaseFrequencies.setEnabled(false); addBuffer(this); //addLabel(" "); endAlignHorizontally(); beginAlignHorizontally(null, false); maximumLikelihoodSearch = addBooleanOption(nameAndLabels[OptionIndex.MAXIMUMLIKELIHOODSEARCH.ordinal()].name, nameAndLabels[OptionIndex.MAXIMUMLIKELIHOODSEARCH.ordinal()].label, true); addLabel(" "); notUseBFGS = addBooleanOption(nameAndLabels[OptionIndex.NOTUSEBFGS.ordinal()].name, nameAndLabels[OptionIndex.NOTUSEBFGS.ordinal()].label, false); addLabel(" "); printBranchLengths = addBooleanOption(nameAndLabels[OptionIndex.PRINTBRANCHLENGTHS.ordinal()].name, nameAndLabels[OptionIndex.PRINTBRANCHLENGTHS.ordinal()].label, false); //addLabel(" "); addBuffer(this); endAlignHorizontally(); addLabel(" "); beginAlignHorizontally(null, false); addLabel(OPTION_NAME); endAlignHorizontally(); constraint.setShouldSaveValue(false); binaryBackbone.setShouldSaveValue(false); mixedPartitionedModel.setShouldSaveValue(false); excludeRangeOfPositionsFile.setShouldSaveValue(false); many_partitions_.setEnabled(false); setDescription(OptionIndex.BOOTSTRAPPINGHALTAUTO); setDescription(OptionIndex.MAXHOURSTORUN); setDescription(OptionIndex.OUTGROUP); setDescription(OptionIndex.CONSTRAINT); setDescription(OptionIndex.BINARYBACKBONE); setDescription(OptionIndex.MIXEDPARTITIONEDMODEL); setDescription(OptionIndex.EXCLUDERANGEOFPOSITIONSFILE); setDescription(OptionIndex.PROTEINSUBSTITUTIONMATRIX); setDescription(OptionIndex.USEEMPIRICALBASEFREQUENCIES); setDescription(OptionIndex.MAXIMUMLIKELIHOODSEARCH); setDescription(OptionIndex.NOTUSEBFGS); setDescription(OptionIndex.PRINTBRANCHLENGTHS); buildRelationshipAmongOptions(); /* beginAlignHorizontally(null, false); //JFileChooser jfc = new JFileChooser(); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); ButtonOption bOption = this.addButtonOption("test", "", "Test"); bOption.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //JFileChooser jfc = new JFileChooser(); //jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); jfc.showOpenDialog(null); } }); endAlignHorizontally();*/ // bootstrappingHaltAuto.addDependent(numOfBootstraps, false); /* SimpleListener sl = new SimpleListener() { @Override public void objectChanged() { Boolean autoBootstrappingHalt = bootstrappingHaltAuto.getValue(); numOfBootstraps.setEnabled(!autoBootstrappingHalt); if (autoBootstrappingHalt) constraint.setEnabled(false); else { String bb = binaryBackbone.getValue(); if ((bb == null || bb.isBlank()) && !autoBootstrappingHalt) constraint.setEnabled(true); else constraint.setEnabled(false); } String cst = constraint.getValue(); if (cst == null || cst.isBlank() ) binaryBackbone.setEnabled(true); else binaryBackbone.setEnabled(false); Boolean mlSearch = maximumLikelihoodSearch.getValue(); proportionOfInvariableSites.setEnabled(mlSearch); String st= sequenceType.getValueAsString(); proteinSubstitutionMatrix.setEnabled(st.equals(PROTEIN)); useEmpiricalBaseFrequencies.setEnabled(st.equals(PROTEIN)); } }; */ /* bootstrappingHaltAuto.addChangeListener(new SimpleListener() { @Override public void objectChanged() { Boolean autoBootstrappingHalt = bootstrappingHaltAuto.getValue(); numOfBootstraps.setEnabled(!autoBootstrappingHalt); constraint.setEnabled(!autoBootstrappingHalt); }; }); */ } @Override //public String verifyOptionsAreValid() public boolean areValuesGoodEnoughToContinue() { StringBuilder sb = new StringBuilder(); String jobName = getJobName(); if (jobName == null || jobName.isBlank()) sb.append("Job name cannot be empty!"); String nchars_Value = getValueAsString(OptionIndex.NCHARS_); if (nchars_Value == null || nchars_Value.isBlank()) sb.append("Please enter a value for the number of characters in your data matrix"); if (sb.length() > 0) { sb.insert(0, ""); sb.append(""); //return sb.toString(); Dialogs.showMessageDialog(sb.toString(), "Invalid Parameter(s)", this.getPanel(), Dialogs.DialogIcon.ERROR); return false; } else { StringBuilder sbWarn = new StringBuilder(); int nchars_Int = Integer.parseInt(nchars_Value); String sequenceType_Value = getValueAsString(OptionIndex.SEQUENCETYPE); String bootstrappingHaltAuto_Value = getBooleanValueAsString(OptionIndex.BOOTSTRAPPINGHALTAUTO); String numOfBootstraps_Value = getValueAsString(OptionIndex.NUMOFBOOTSTRAPS); String mixedPartitionedModel_Value = getValueAsString(OptionIndex.MIXEDPARTITIONEDMODEL); String many_partitions_Value = getBooleanValueAsString(OptionIndex.MANY_PARTITIONS_); int numOfBootstraps_Int = 0; if (numOfBootstraps_Value != null) numOfBootstraps_Int = Integer.parseInt(numOfBootstraps_Value); String runtime_Value = getValueAsString(OptionIndex.MAXHOURSTORUN); boolean protein = (sequenceType_Value.equals(PROTEIN) || sequenceType_Value.equals(PROTEIN.toLowerCase())); boolean useBootstopping = bootstrappingHaltAuto_Value != null && bootstrappingHaltAuto_Value.equals(ONE); boolean manyPartitions = many_partitions_Value != null && many_partitions_Value.equals(ONE); if (nchars_Int < 10000 && !protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 40 processors as configured. If it runs for the entire configured time, it will consume 40 x %s cpu hours
", runtime_Value)); if (nchars_Int > 9999 && nchars_Int > 40000 && !protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 125 processors as configured. If it runs for the entire configured time, it will consume 125 x %s cpu hours
", runtime_Value)); if (nchars_Int > 39999 && nchars_Int < 500000 && !protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 128 processors as configured. If it runs for the entire configured time, it will consume 128 x %s cpu hours
", runtime_Value)); if (!protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (manyPartitions)) sbWarn.append(String.format("The job will run on 120 processors as configured. If it runs for the entire configured time, it will consume 120 x %s cpu hours
", runtime_Value)); if (nchars_Int > 49999 && !protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 128 processors as configured. If it runs for the entire configured time, it will consume 128 x %s cpu hours
", runtime_Value)); if (nchars_Int < 4000 && !protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 8 processors as configured. If it runs for the entire configured time, it will consume 8 x %s cpu hours
", runtime_Value)); if (nchars_Int > 3999 && nchars_Int < 16000 && !protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 16 processors as configured. If it runs for the entire configured time, it will consume 16 x %s cpu hours
", runtime_Value)); if (nchars_Int > 15999 && nchars_Int < 60000 && !protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 24 processors as configured. If it runs for the entire configured time, it will consume 24 x %s cpu hours
", runtime_Value)); if (nchars_Int > 59999 && nchars_Int < 250000 && !protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 48 processors as configured. If it runs for the entire configured time, it will consume 48 x %s cpu hours
", runtime_Value)); if (nchars_Int > 249999 && !protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 128 processors as configured. If it runs for the entire configured time, it will consume 128 x %s cpu hours
", runtime_Value)); if (!protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (manyPartitions)) sbWarn.append(String.format("The job will run on 16 processors as configured. If it runs for the entire configured time, it will consume 16 x %s cpu hours
", runtime_Value)); if (nchars_Int < 3000 && protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 40 processors as configured. If it runs for the entire configured time, it will consume 40 x %s cpu hours
", runtime_Value)); if (nchars_Int > 2999 && nchars_Int < 12000 && protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 120 processors as configured. If it runs for the entire configured time, it will consume 120 x %s cpu hours
", runtime_Value)); if (nchars_Int > 11999 && nchars_Int < 30000 && protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 125 processors as configured. If it runs for the entire configured time, it will consume 125 x %s cpu hours
", runtime_Value)); if (nchars_Int > 29999 && nchars_Int < 200000 && protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 128 processors as configured. If it runs for the entire configured time, it will consume 128 x %s cpu hours
", runtime_Value)); if (nchars_Int > 199999 && protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 128 processors as configured. If it runs for the entire configured time, it will consume 128 x %s cpu hours
", runtime_Value)); if (protein && ((useBootstopping) || numOfBootstraps_Int > 9) && (manyPartitions)) sbWarn.append(String.format("The job will run on 120 processors as configured. If it runs for the entire configured time, it will consume 120 x %s cpu hours
", runtime_Value)); if (nchars_Int < 3000 && protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 12 processors as configured. If it runs for the entire configured time, it will consume 12 x %s cpu hours
", runtime_Value)); if (nchars_Int > 2999 && nchars_Int < 4500 && protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 24 processors as configured. If it runs for the entire configured time, it will consume 24 x %s cpu hours
", runtime_Value)); if (nchars_Int > 4499 && nchars_Int < 15000 && protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 32 processors as configured. If it runs for the entire configured time, it will consume 32 x %s cpu hours
", runtime_Value)); if (nchars_Int > 14999 && nchars_Int < 100000 && protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 64 processors as configured. If it runs for the entire configured time, it will consume 64 x %s cpu hours
", runtime_Value)); if (nchars_Int > 99999 && protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (!manyPartitions)) sbWarn.append(String.format("The job will run on 128 processors as configured. If it runs for the entire configured time, it will consume 128 x %s cpu hours
", runtime_Value)); if (protein && ((!useBootstopping) && numOfBootstraps_Int < 10) && (manyPartitions)) sbWarn.append(String.format("The job will run on 120 processors as configured. If it runs for the entire configured time, it will consume 120 x %s cpu hours
", runtime_Value)); if (sbWarn.length() > 0) { sbWarn.insert(0, ""); sbWarn.append(""); return (Dialogs.showContinueCancelDialog(sbWarn.toString(), "Continue with job submission?", this.getPanel(), Dialogs.DialogIcon.QUESTION)); } } return true; } private void buildRelationshipAmongOptions() { SimpleListener sl = new SimpleListener() { @Override public void objectChanged() { Boolean autoBootstrappingHalt = bootstrappingHaltAuto.getValue(); numOfBootstraps.setEnabled(!autoBootstrappingHalt); if (autoBootstrappingHalt) setEnabled(OptionIndex.CONSTRAINT, false); else { String bb = binaryBackbone.getValue(); if ((bb == null || bb.isBlank()) && !autoBootstrappingHalt) setEnabled(OptionIndex.CONSTRAINT, true); else setEnabled(OptionIndex.CONSTRAINT, false); } String cst = constraint.getValue(); if (cst == null || cst.isBlank() || !constraint.isEnabled() ) setEnabled(OptionIndex.BINARYBACKBONE, true); else setEnabled(OptionIndex.BINARYBACKBONE, false); Boolean mlSearch = maximumLikelihoodSearch.getValue(); proportionOfInvariableSites.setEnabled(mlSearch); String st= sequenceType.getValueAsString(); proteinSubstitutionMatrix.setEnabled(st.equals(PROTEIN.toLowerCase())); useEmpiricalBaseFrequencies.setEnabled(st.equals(PROTEIN.toLowerCase())); String mixedPartitionedModel_Value = getValueAsString(OptionIndex.MIXEDPARTITIONEDMODEL); if (mixedPartitionedModel_Value != null && !mixedPartitionedModel_Value.isBlank()) many_partitions_.setEnabled(true); else many_partitions_.setEnabled(false); } }; bootstrappingHaltAuto.addChangeListener(sl); constraint.addChangeListener(sl); binaryBackbone.addChangeListener(sl); maximumLikelihoodSearch.addChangeListener(sl); sequenceType.addChangeListener(sl); mixedPartitionedModel.addChangeListener(sl); } private void setEnabled(OptionIndex index, boolean enabled) { if (index == OptionIndex.CONSTRAINT) { constraint.setEnabled(enabled); constraintBrowse.setEnabled(enabled); } else if (index == OptionIndex.BINARYBACKBONE) { binaryBackbone.setEnabled(enabled); binaryBackboneBrowse.setEnabled(enabled); } else if (index == OptionIndex.MIXEDPARTITIONEDMODEL) { mixedPartitionedModel.setEnabled(enabled); mixedPartitionedModelBrowse.setEnabled(enabled); } else if (index == OptionIndex.EXCLUDERANGEOFPOSITIONSFILE) { excludeRangeOfPositionsFile.setEnabled(enabled); excludeRangeOfPositionsFileBrowse.setEnabled(enabled); } else { Option opt = this.getOption(nameAndLabels[index.ordinal()].name); if (opt != null) opt.setEnabled(enabled); } } private void setDescription(OptionIndex index) { Option opt = this.getOption(nameAndLabels[index.ordinal()].name); if (opt == null || nameAndLabels[index.ordinal()].description == null || nameAndLabels[index.ordinal()].description.isBlank()) return; opt.setDescription(nameAndLabels[index.ordinal()].description); } private JSONObject jsonCommand = new JSONObject(); private Map inputParams = new HashMap(); @SuppressWarnings("unchecked") public void populateJsonCommand() { //String sequence = getValueAsString(OptionIndex.SEQUENCETYPE); //System.out.println("sequence = " + sequence); /* jsonCommand.put("datatype_", getValueAsString(OptionIndex.SEQUENCETYPE)); //jsonCommand.put("datatype_", "protein"); //jsonCommand.put("empirical", "F"); jsonCommand.put("mlsearch_", getBooleanValueAsString(OptionIndex.MAXIMUMLIKELIHOODSEARCH)); jsonCommand.put("no_bfgs_", getBooleanValueAsString(OptionIndex.NOTUSEBFGS)); jsonCommand.put("printbrlength_", getBooleanValueAsString(OptionIndex.PRINTBRANCHLENGTHS)); jsonCommand.put("use_bootstopping_", getBooleanValueAsString(OptionIndex.BOOTSTRAPPINGHALTAUTO)); jsonCommand.put("runtime_", getValueAsString(OptionIndex.MAXHOURSTORUN)); */ setParam(OptionIndex.SEQUENCETYPE, ParamType.VParam); setParam(OptionIndex.MAXHOURSTORUN, ParamType.VParam); setParam(OptionIndex.BOOTSTRAPPINGHALTAUTO, ParamType.VParam); setParam(OptionIndex.NUMOFBOOTSTRAPS, ParamType.VParam); setParam(OptionIndex.OUTGROUP, ParamType.VParam); //String invariable = getValueAsString(OptionIndex.PROPORTIONOFINVARIABLESITES); //if (invariable != null && invariable.equals(INVARIABLE)) setParam(OptionIndex.PROPORTIONOFINVARIABLESITES, ParamType.VParam); setParam(OptionIndex.PROTEINSUBSTITUTIONMATRIX, ParamType.VParam); //String emperical = getValueAsString(OptionIndex.USEEMPIRICALBASEFREQUENCIES); //if ( emperical != null && emperical .equals(FREQUENCY)) setParam(OptionIndex.USEEMPIRICALBASEFREQUENCIES, ParamType.VParam); setParam(OptionIndex.MAXIMUMLIKELIHOODSEARCH, ParamType.VParam); setParam(OptionIndex.NOTUSEBFGS, ParamType.VParam); setParam(OptionIndex.PRINTBRANCHLENGTHS, ParamType.VParam); setParam(OptionIndex.NCHARS_, ParamType.VParam); setParam(OptionIndex.MANY_PARTITIONS_, ParamType.VParam); } public JSONObject getJsonCommand() { return jsonCommand; } @SuppressWarnings("unchecked") private void setParam(OptionIndex index, ParamType type) { Option opt = this.getOption(nameAndLabels[index.ordinal()].name); if (opt == null || !opt.isEnabled()) return; String value = null; if (opt instanceof BooleanOption) value = getBooleanValueAsString(index); else value = getValueAsString(index); if (value != null && !value.isBlank()) { if (type.equals(ParamType.VParam)) jsonCommand.put(nameAndLabels[index.ordinal()].parameter, value); else if (type.equals(ParamType.InputParam)) inputParams.put(nameAndLabels[index.ordinal()].parameter, value); } } public Map> getVParams() { return MrBayesUtilities.getVParams(jsonCommand); } public Map getInputParams() { List files = new ArrayList(); final AnnotatedPluginDocument doc = selectedDocuments[0]; try { final SequenceAlignmentDocument alignmentDoc = (SequenceAlignmentDocument) doc.getDocument(); File tempFolder; tempFolder = FileUtilities.createTempFile("Geneious", "RAxMLBB", false); tempFolder.delete(); tempFolder.mkdirs(); StringBuilder inFileBldr = new StringBuilder(); List seqDocList = alignmentDoc.getSequences(); for(SequenceDocument seqDocument: seqDocList){ //MrBayes does not like space or dot(s) in taxa name String seqName = seqDocument.getName().trim() .replaceAll(SPACE, UNDERSCORE) .replaceAll("\\"+ DOT, "") .replaceAll("\\(","") .replaceAll("\\)",""); String seqString = seqDocument.getSequenceString().trim(); //System.out.println(seqString); //System.out.println(seqName + TAB + seqString); inFileBldr.append( ">" + seqName + NEWLINE + seqString + NEWLINE); } File outputFile = new File(tempFolder, GENEIOUS_FORMAT); files.add(outputFile); SafePrintWriter out = new SafePrintWriter(new FileWriter(outputFile)); out.println(inFileBldr.toString()); out.close(); } catch (IOException | DocumentOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } //Map inputParams = new HashMap(); //inputParams.put("infile_", "C:\\Users\\mzhuang\\Cipres_input\\infile1"); inputParams.put("infile_", files.get(0).toString()); String partition = getValueAsString(OptionIndex.MIXEDPARTITIONEDMODEL); System.out.println("mix partitioned = " + partition); setParam(OptionIndex.CONSTRAINT, ParamType.InputParam); setParam(OptionIndex.BINARYBACKBONE, ParamType.InputParam); setParam(OptionIndex.MIXEDPARTITIONEDMODEL, ParamType.InputParam); setParam(OptionIndex.EXCLUDERANGEOFPOSITIONSFILE, ParamType.InputParam); /* if (partition != null && !partition.isBlank()) { inputParams.put("partition_", partition); }*/ return inputParams; } public HashMap getMetadata(String jobName){ jobName = getJobName(); return MrBayesUtilities.getMetadata(jobName); } private String getValueAsString(OptionIndex index) { Option opt = this.getOption(nameAndLabels[index.ordinal()].name); if (opt != null && opt.isEnabled() ) return getValueAsString(nameAndLabels[index.ordinal()].name); else return null; //return (value.toLowerCase()); } /* private String getValueAsString(OptionIndex index) { return filterOutExceptions(index, getValueAsString(getOptionsFromIndex(index), nameAndLabels[index.ordinal()].name)); }*/ private String getBooleanValueAsString(OptionIndex index) { BooleanOption bo = (BooleanOption) this.getOption(nameAndLabels[index.ordinal()].name); if (!bo.isEnabled()) return null; if (bo.getValue()) return ONE; else return ZERO; //return this.getOption() getValueAsBoolean(nameAndLabels[index.ordinal()].name); //return (value.toLowerCase()); } private boolean isDNA(List seqDocumentList){ boolean check = true; for(SequenceDocument seqDocument: seqDocumentList){ if(seqDocument.getSequenceString().toUpperCase().contains("U")){ check = false; break; } } return check; } } /* class NameAndLabel { //improve this by make them private and add getXXX() methods public String name; public String label; public String parameter; public String description; public NameAndLabel(String name, String label, String parameter, String description) { this.name = name; this.label = label; this.parameter = parameter; this.description = description; } } class ClearButtonActionListener implements ActionListener { private Option option; public ClearButtonActionListener(Option option) { this.option = option; } @Override public void actionPerformed(ActionEvent e) { if (option != null) option.setValueFromString(""); //if (option instanceof FileSelectionOption) //{ // FileSelectionOption fso = (FileSelectionOption)option; // fso.restoreDefault(); //} } } class BrowseButtonActionListener implements ActionListener { private Option option = null; private JFileChooser fileChooser = null; public BrowseButtonActionListener(Option option, JFileChooser fileChooser) { this.option = option; this.fileChooser = fileChooser; } @Override public void actionPerformed(ActionEvent e) { if (fileChooser != null) { int ret = fileChooser.showOpenDialog(null); if (ret == JFileChooser.APPROVE_OPTION) { option.setValueFromString(fileChooser.getSelectedFile().getAbsolutePath()); } } //if (option != null) // option.setValueFromString(""); //if (option instanceof FileSelectionOption) //{ // FileSelectionOption fso = (FileSelectionOption)option; // fso.restoreDefault(); //} } } */