Ejemplo n.º 1
0
 private String tryModels() {
   String message = "";
   try {
     SubstitutionModel[] defaultSubstList = {new Kimura3(), new Dayhoff()};
     for (SubstitutionModel model : defaultSubstList) {
       try {
         model.acceptable(manager.inputData.seqs);
         selectModel(model);
         break;
       } catch (RecognitionError e) {
       }
     }
     if (manager.inputData.model == null) {
       double max = 0.0;
       int wrong = 0;
       for (Class<? extends SubstitutionModel> cl : substModels) {
         SubstitutionModel m;
         try {
           m = cl.newInstance();
           if (m.acceptable(manager.inputData.seqs) > max) {
             manager.inputData.model = m;
             max = m.acceptable(manager.inputData.seqs);
             selectModel(m);
           }
         } catch (RecognitionError e) {
           wrong++;
           message += e.message;
         }
       }
     }
   } catch (Exception e) {
     JOptionPane.showMessageDialog(
         this,
         e.getLocalizedMessage(),
         "Error accessing substitution models",
         JOptionPane.ERROR_MESSAGE);
   }
   return message;
 }
Ejemplo n.º 2
0
  /**
   * An ActioListener is implemented, so we have to implement this function. It handles actions on
   * the menu bar.
   */
  @Override
  public void actionPerformed(ActionEvent ev) {
    if (ev.getActionCommand() == "Add sequence(s)...") {
      addSequences();
    } else if (ev.getActionCommand() == "Exit") {
      System.exit(0);
    } else if (ev.getActionCommand() == "Preferences...") {
      // System.out.println("here!!!");
      op = new OutputPreferences(this);
    } else if (ev.getActionCommand() == "Settings") {
      mcmcSettingsDlg.display(this);
    } else if (ev.getActionCommand() == "Set up and run") {
      if (manager.inputData.seqs.sequences.size() < 2) {
        JOptionPane.showMessageDialog(
            this,
            "At least two sequences are needed!!!",
            "Not enough sequences",
            JOptionPane.ERROR_MESSAGE);
        //    			manager.finished();
        return;
      }
      // disableAllButtons();
      mcmcSettingsDlg.display(this);
      // start();

    } else if (ev.getActionCommand() == "Pause") {
      pauseItem.setEnabled(false);
      pauseButton.setEnabled(false);

      resumeItem.setEnabled(true);
      resumeButton.setEnabled(true);
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      final String savTit = getTitle();
      setTitle("Pausing...");
      manager.thread.suspendSoft();
      setTitle(savTit);
      setCursor(Cursor.getDefaultCursor());
    } else if (ev.getActionCommand() == "Resume") {
      manager.thread.resumeSoft();
      pauseItem.setEnabled(true);
      pauseButton.setEnabled(true);
      resumeItem.setEnabled(false);
      resumeButton.setEnabled(false);
    } else if (ev.getActionCommand() == "Stop") {
      setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      final String savTit = getTitle();
      setTitle("Stopping...");
      manager.thread.stopSoft();
      finished();
      setTitle(savTit);
      setCursor(Cursor.getDefaultCursor());
    } else if (ev.getActionCommand() == "RNA mode") {
      if (rnaButton.isSelected()) {
        dlg = new RNASettingsDlg(this);
        dlg.display(this);

        // manager.inputgui = input.inputgui;
        // manager.inputgui.updateSequences();
        // tab.addTab(input.getTabName(), input.getIcon(), input.getJPanel(), input.getTip());
        manager.inputgui = input.inputgui;
        manager.inputgui.updateSequences();
        // System.out.println("SELECTED!!!");

        manager.postProcMan.rnaMode = true;
        // manager.postProcMan.reload();

        int count = tab.getTabCount();
        for (Postprocess plugin : pluginTabs) {
          // System.out.println(plugin.getTabName() + ": " + plugin.screenable);
          if (plugin.rnaAssociated) {
            tabPluginMap.put(count, plugin);
            tab.addTab(plugin.getTabName(), plugin.getIcon(), plugin.getJPanel(), plugin.getTip());
            count++;
          }

          // manager.postProcMan.init();
        }

      } else {

        manager.postProcMan.rnaMode = false;
        // System.out.println("NOT SELECTED!!!");
        manager.inputgui = input.inputgui;
        manager.inputgui.updateSequences();

        int count = 0;
        for (Postprocess plugin : pluginTabs) {
          if (plugin.rnaAssociated) {
            tabPluginMap.remove(plugin);
            String removePlugin = tab.getTitleAt(count + 1);
            tab.remove(count + 1);
            count--;
          }

          count++;
        }
      }

    } else if (ev.getActionCommand() == "About...") {
      new HelpWindow(
          this, "About", getClass().getClassLoader().getResource("doc/about/index.html"), false);
    } else if (ev.getActionCommand() == "Html doc for developers") {
      new HelpWindow(
          this, "Html doc for Developers", ClassLoader.getSystemResource("doc/index.html"), true);
    } else if (ev.getActionCommand() == "Description of plugins") {
      new HelpWindow(
          this,
          "Description of plugins",
          ClassLoader.getSystemResource("doc/plugin_description/index.html"),
          true);

    } else if (ev.getActionCommand() == "Help for users") {
      helpUsers();
    } else { // new substitution model selected
      for (Class<? extends SubstitutionModel> cl : substModels) {
        try {
          if (ev.getActionCommand().equals(SubstitutionModel.getMenuName(cl))) {
            try {
              SubstitutionModel model = cl.newInstance();
              model.acceptable(manager.inputData.seqs);
              manager.inputData.model = model;
              break;
            } catch (RecognitionError e) {
              selectModel(manager.inputData.model);
              JOptionPane.showMessageDialog(
                  this, e.message, "Cannot apply this model...", JOptionPane.ERROR_MESSAGE);
              break;
            }
          }
        } catch (Exception e) {
          ErrorMessage.showPane(this, e, true);
        }
      }
    }
  }