Ejemplo n.º 1
0
  /** Lays out the appropriate components in the panel for this partition model. */
  private void setupPanel() {

    switch (model.getDataType().getType()) {
      case DataType.NUCLEOTIDES:
        addComponentWithLabel("Substitution Model:", nucSubstCombo);
        addComponentWithLabel("Base frequencies:", frequencyCombo);
        addComponentWithLabel("Site Heterogeneity Model:", heteroCombo);
        heteroCombo.setSelectedIndex(0);
        gammaCatLabel = addComponentWithLabel("Number of Gamma Categories:", gammaCatCombo);
        gammaCatCombo.setEnabled(false);

        addSeparator();

        addComponentWithLabel("Partition into codon positions:", codingCombo);

        JPanel panel2 = new JPanel();
        panel2.setOpaque(false);
        panel2.setLayout(new BoxLayout(panel2, BoxLayout.PAGE_AXIS));
        panel2.setBorder(BorderFactory.createTitledBorder("Link/Unlink parameters:"));
        panel2.add(substUnlinkCheck);
        panel2.add(heteroUnlinkCheck);
        panel2.add(freqsUnlinkCheck);

        addComponent(panel2);

        addComponent(setYang96Button);
        addComponent(setSRD06Button);

        break;

      case DataType.AMINO_ACIDS:
        addComponentWithLabel("Substitution Model:", aaSubstCombo);
        addComponentWithLabel("Citation:", citationText);

        addComponentWithLabel("Site Heterogeneity Model:", heteroCombo);
        heteroCombo.setSelectedIndex(0);
        gammaCatLabel = addComponentWithLabel("Number of Gamma Categories:", gammaCatCombo);
        gammaCatCombo.setEnabled(false);

        break;

      case DataType.TWO_STATES:
      case DataType.COVARION:
        addComponentWithLabel("Substitution Model:", binarySubstCombo);
        addComponentWithLabel("Base frequencies:", frequencyCombo);
        addComponentWithLabel("Site Heterogeneity Model:", heteroCombo);
        heteroCombo.setSelectedIndex(0);
        gammaCatLabel = addComponentWithLabel("Number of Gamma Categories:", gammaCatCombo);
        gammaCatCombo.setEnabled(false);

        addSeparator();

        addComponentWithLabel("", useAmbiguitiesTreeLikelihoodCheck);

        // Easy XML specification is currently only available for binary models
        if (ENABLE_STOCHASTIC_DOLLO) {
          addSeparator();
          addComponent(dolloCheck);
        }

        break;

      case DataType.GENERAL:
        addComponentWithLabel("Discrete Trait Substitution Model:", discreteTraitSiteModelCombo);
        addComponent(activateBSSVS);
        break;

      case DataType.CONTINUOUS:
        addComponentWithLabel("Continuous Trait Model:", continuousTraitSiteModelCombo);
        addComponent(latLongCheck);
        addSeparator();
        addComponent(useLambdaCheck);
        break;

      case DataType.MICRO_SAT:
        addComponentWithLabel("Microsatellite Name:", microsatName);
        addComponentWithLabel("Max of Length:", microsatMax);
        addComponentWithLabel("Min of Length:", microsatMin);
        addComponent(shareMicroSatCheck);

        addSeparator();

        addComponentWithLabel("Rate Proportionality:", rateProportionCombo);
        addComponentWithLabel("Mutational Bias:", mutationBiasCombo);
        addComponentWithLabel("Phase:", phaseCombo);
        break;

      default:
        throw new IllegalArgumentException("Unknown data type");
    }

    setOptions();
  }
Ejemplo n.º 2
0
  /**
   * Sets the components up according to the partition model - but does not layout the top level
   * options panel.
   */
  public void setOptions() {

    if (SiteModelsPanel.DEBUG) {
      String modelName = (model == null) ? "null" : model.getName();
      Logger.getLogger("dr.app.beauti").info("ModelsPanel.setModelOptions(" + modelName + ")");
    }

    if (model == null) {
      return;
    }

    int dataType = model.getDataType().getType();
    switch (dataType) {
      case DataType.NUCLEOTIDES:
        nucSubstCombo.setSelectedItem(model.getNucSubstitutionModel());
        frequencyCombo.setSelectedItem(model.getFrequencyPolicy());

        break;

      case DataType.AMINO_ACIDS:
        aaSubstCombo.setSelectedItem(model.getAaSubstitutionModel());

        break;

      case DataType.TWO_STATES:
      case DataType.COVARION:
        binarySubstCombo.setSelectedItem(model.getBinarySubstitutionModel());
        useAmbiguitiesTreeLikelihoodCheck.setSelected(model.isUseAmbiguitiesTreeLikelihood());

        break;

      case DataType.GENERAL:
        discreteTraitSiteModelCombo.setSelectedItem(model.getDiscreteSubstType());
        activateBSSVS.setSelected(model.isActivateBSSVS());
        break;

      case DataType.CONTINUOUS:
        continuousTraitSiteModelCombo.setSelectedItem(model.getContinuousSubstModelType());

        ContinuousComponentOptions component =
            (ContinuousComponentOptions)
                model.getOptions().getComponentOptions(ContinuousComponentOptions.class);

        latLongCheck.setSelected(model.isLatitudeLongitude());
        latLongCheck.setEnabled(model.getContinuousTraitCount() == 2);
        useLambdaCheck.setSelected(component.useLambda(model));
        break;
      case DataType.MICRO_SAT:
        microsatName.setText(model.getMicrosatellite().getName());
        microsatMax.setText(Integer.toString(model.getMicrosatellite().getMax()));
        microsatMin.setText(Integer.toString(model.getMicrosatellite().getMin()));
        shareMicroSatCheck.setSelected(model.getOptions().shareMicroSat);
        rateProportionCombo.setSelectedItem(model.getRatePorportion());
        mutationBiasCombo.setSelectedItem(model.getMutationBias());
        phaseCombo.setSelectedItem(model.getPhase());
        shareMicroSatCheck.setEnabled(
            model.getOptions().getPartitionSubstitutionModels(Microsatellite.INSTANCE).size() > 1);
        break;

      default:
        throw new IllegalArgumentException("Unknown data type");
    }

    if (model.isGammaHetero() && !model.isInvarHetero()) {
      heteroCombo.setSelectedIndex(1);
    } else if (!model.isGammaHetero() && model.isInvarHetero()) {
      heteroCombo.setSelectedIndex(2);
    } else if (model.isGammaHetero() && model.isInvarHetero()) {
      heteroCombo.setSelectedIndex(3);
    } else {
      heteroCombo.setSelectedIndex(0);
    }

    gammaCatCombo.setSelectedIndex(model.getGammaCategories() - 4);

    if (model.getCodonHeteroPattern() == null) {
      codingCombo.setSelectedIndex(0);
    } else if (model.getCodonHeteroPattern().equals("112")) {
      codingCombo.setSelectedIndex(1);
    } else {
      codingCombo.setSelectedIndex(2);
    }

    substUnlinkCheck.setSelected(model.isUnlinkedSubstitutionModel());
    heteroUnlinkCheck.setSelected(model.isUnlinkedHeterogeneityModel());
    freqsUnlinkCheck.setSelected(model.isUnlinkedFrequencyModel());

    dolloCheck.setSelected(model.isDolloModel());
  }