private static final Font VERDANA_11PT = new Font("Verdana", 0, 11);
-
private static final int MIN_PAIRWISE_SELECTION = 2;
private static final int MIN_TREE_SELECTION = 3;
private static final int MIN_PCA_SELECTION = 4;
-
+
private String secondaryStructureModelName;
-
- private void getSecondaryStructureModelName() {
-
+
+ private void getSecondaryStructureModelName()
+ {
+
ScoreModels scoreModels = ScoreModels.getInstance();
for (ScoreModelI sm : scoreModels.getModels())
{
secondaryStructureModelName = sm.getName();
}
}
-
+
}
/**
- * minimum number of sequences needed for PASIMAP is 9 (so each has 8 connections)
+ * minimum number of sequences needed for PASIMAP is 9 (so each has 8
+ * connections)
*/
- private static final int MIN_PASIMAP_SELECTION = 9;
+ private static final int MIN_PASIMAP_SELECTION = 9;
AlignFrame af;
JRadioButton pca;
- JRadioButton pasimap;
+ JRadioButton pasimap;
JRadioButton neighbourJoining;
JRadioButton averageDistance;
JComboBox<String> modelNames;
-
+
JComboBox<String> ssSourceDropdown;
JButton calculate;
this.af = alignFrame;
init();
af.alignPanel.setCalculationDialog(this);
-
+
}
/**
MessageManager.getString("label.principal_component_analysis"));
pca.setOpaque(false);
- pasimap = new JRadioButton( // create the JRadioButton for pasimap with label.pasimap as its text
- MessageManager.getString("label.pasimap"));
+ pasimap = new JRadioButton( // create the JRadioButton for pasimap with
+ // label.pasimap as its text
+ MessageManager.getString("label.pasimap"));
pasimap.setOpaque(false);
neighbourJoining = new JRadioButton(
averageDistance = new JRadioButton(
MessageManager.getString("label.tree_calc_av"));
averageDistance.setOpaque(false);
-
- pairwise = new JRadioButton(MessageManager.getString("label.pairwise_alignment"));
+
+ pairwise = new JRadioButton(
+ MessageManager.getString("action.pairwise_alignment"));
pairwise.setOpaque(false);
JPanel calcChoicePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
calcChoicePanel.add(pcaBorderless, FlowLayout.LEFT);
// create pasimap panel
- JPanel pasimapBorderless = new JPanel(new FlowLayout(FlowLayout.LEFT)); // create new JPanel (button) for pasimap
+ JPanel pasimapBorderless = new JPanel(new FlowLayout(FlowLayout.LEFT)); // create
+ // new
+ // JPanel
+ // (button)
+ // for
+ // pasimap
pasimapBorderless.setBorder(
- BorderFactory.createEmptyBorder(2, b.left, 2, b.right)); // set border (margin) for button (same as treePanel and pca)
- pasimapBorderless.setOpaque(false); // false -> stops every pixel inside border from being painted
- pasimapBorderless.add(pasimap, FlowLayout.LEFT); // add pasimap button to the JPanel
- calcChoicePanel.add(pasimapBorderless, FlowLayout.LEFT); // add button with border and everything to the overall ChoicePanel
+ BorderFactory.createEmptyBorder(2, b.left, 2, b.right)); // set
+ // border
+ // (margin)
+ // for
+ // button
+ // (same as
+ // treePanel
+ // and pca)
+ pasimapBorderless.setOpaque(false); // false -> stops every pixel inside
+ // border from being painted
+ pasimapBorderless.add(pasimap, FlowLayout.LEFT); // add pasimap button to
+ // the JPanel
+ calcChoicePanel.add(pasimapBorderless, FlowLayout.LEFT); // add button with
+ // border and
+ // everything to
+ // the overall
+ // ChoicePanel
treePanel.add(neighbourJoining);
treePanel.add(averageDistance);
calcChoicePanel.add(treePanel);
- calcChoicePanel.add(pairwise,FlowLayout.CENTER);
+ calcChoicePanel.add(pairwise, FlowLayout.CENTER);
ButtonGroup calcTypes = new ButtonGroup();
calcTypes.add(pca);
}
};
pca.addActionListener(calcChanged);
- pasimap.addActionListener(calcChanged); // add the calcChanged ActionListener to pasimap --> <++> idk
+ pasimap.addActionListener(calcChanged); // add the calcChanged
+ // ActionListener to pasimap -->
+ // <++> idk
neighbourJoining.addActionListener(calcChanged);
averageDistance.addActionListener(calcChanged);
-
-
- //to do
+
+ // to do
ssSourceDropdown = buildSSSourcesOptionsList();
ssSourceDropdown.setVisible(false); // Initially hide the dropdown
pairwise.addActionListener(calcChanged);
* score models drop-down - with added tooltips!
*/
modelNames = buildModelOptionsList();
-
+
// Step 3: Show or Hide Dropdown Based on Selection
- modelNames.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- String selectedModel = modelNames.getSelectedItem().toString();
-
- if (selectedModel.equals(secondaryStructureModelName)) {
- ssSourceDropdown.setVisible(true);
- } else {
- ssSourceDropdown.setVisible(false);
- }
+ modelNames.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ String selectedModel = modelNames.getSelectedItem().toString();
+
+ if (selectedModel.equals(secondaryStructureModelName))
+ {
+ ssSourceDropdown.setVisible(true);
}
+ else
+ {
+ ssSourceDropdown.setVisible(false);
+ }
+ }
});
-
JPanel scoreModelPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
scoreModelPanel.setOpaque(false);
scoreModelPanel.add(modelNames);
scoreModelPanel.add(ssSourceDropdown);
-
+
/*
* score model parameters
*/
paramsPanel.add(matchGaps);
paramsPanel.add(includeGappedColumns);
paramsPanel.add(shorterSequence);
-
+
/*
* OK / Cancel buttons
*/
* return value of true means enabled and selected
*/
boolean checkPca = checkEnabled(pca, size, MIN_PCA_SELECTION);
- boolean checkPasimap = checkEnabled(pasimap, size, MIN_PASIMAP_SELECTION); // check if pasimap is enabled and min_size is fulfilled
+ boolean checkPasimap = checkEnabled(pasimap, size,
+ MIN_PASIMAP_SELECTION); // check if pasimap is enabled and min_size
+ // is fulfilled
boolean checkNeighbourJoining = checkEnabled(neighbourJoining, size,
MIN_TREE_SELECTION);
boolean checkAverageDistance = checkEnabled(averageDistance, size,
boolean checkPairwise = checkEnabled(pairwise, size,
MIN_PAIRWISE_SELECTION);
- if (checkPca || checkPasimap || checkPca || checkNeighbourJoining || checkAverageDistance || checkPairwise)
+ if (checkPca || checkPasimap || checkPca || checkNeighbourJoining
+ || checkAverageDistance || checkPairwise)
{
calculate.setToolTipText(null);
calculate.setEnabled(true);
return scoreModelsCombo;
}
-
private JComboBox<String> buildSSSourcesOptionsList()
{
curSel = source;
}
sourcesModel.addElement(source);
-
+
}
if (selectedIsPresent)
sourcesModel.setSelectedItem(curSel);
}
comboBox.setModel(sourcesModel);
-
+
return comboBox;
}
-
-
+
private void updateScoreModels(JComboBox<String> comboBox,
List<String> toolTips)
{
* select the score models applicable to the alignment type
*/
boolean nucleotide = af.getViewport().getAlignment().isNucleotide();
- AlignmentAnnotation[] alignmentAnnotations = af.getViewport().getAlignment().getAlignmentAnnotation();
+ AlignmentAnnotation[] alignmentAnnotations = af.getViewport()
+ .getAlignment().getAlignmentAnnotation();
- boolean ssPresent = AlignmentUtils.isSecondaryStructurePresent(alignmentAnnotations);
+ boolean ssPresent = AlignmentUtils
+ .isSecondaryStructurePresent(alignmentAnnotations);
- List<ScoreModelI> models = getApplicableScoreModels(nucleotide, pca.isSelected(),
- ssPresent, pasimap.isSelected());
+ List<ScoreModelI> models = getApplicableScoreModels(nucleotide,
+ pca.isSelected(), ssPresent, pasimap.isSelected());
/*
* now we can actually add entries to the combobox,
}
// finally, update the model
comboBox.setModel(model);
- comboBox.setEnabled(model.getSize()>0);
-
+ comboBox.setEnabled(model.getSize() > 0);
+
}
/**
*
* @param nucleotide
* @param forPca
+ * @param ssPresent - include secondary structure similarity model
+ * @param forPasimap - limit to ScoreMatrix based models - allows use of AlignSeq
* @return
*/
protected static List<ScoreModelI> getApplicableScoreModels(
- boolean nucleotide, boolean forPca, boolean ssPresent, boolean forPasimap)
+ boolean nucleotide, boolean forPca, boolean ssPresent,
+ boolean forPasimap)
{
List<ScoreModelI> filtered = new ArrayList<>();
ScoreModels scoreModels = ScoreModels.getInstance();
for (ScoreModelI sm : scoreModels.getModels())
{
- if (!forPasimap && (!nucleotide && sm.isProtein() || nucleotide && sm.isDNA()
- || sm.isSecondaryStructure() && ssPresent))
-
+ if ((!forPasimap || sm instanceof ScoreMatrix)
+ && (!nucleotide && sm.isProtein() || nucleotide && sm.isDNA()
+ || sm.isSecondaryStructure() && ssPresent))
+
{
filtered.add(sm);
}
}
-
- /*
- * make PaSiMap only use Blosum62 and Pam250
- */
- if (forPasimap && !nucleotide && !forPca)
- {
- filtered.add(scoreModels.getBlosum62());
- filtered.add(scoreModels.getPam250());
- }
/*
* special case: add BLOSUM62 as last option for nucleotide PCA,
{
filtered.add(scoreModels.getBlosum62());
}
-
+
return filtered;
}
-
protected List<String> getApplicableSecondaryStructureSources()
{
- AlignmentAnnotation[] annotations = af.getViewport().getAlignment().getAlignmentAnnotation();
-
- List<String> ssSources = AlignmentUtils.getSecondaryStructureSources(annotations);
- //List<String> ssSources = AlignmentUtils.extractSSSourceInAlignmentAnnotation(annotations);
-
-
+ AlignmentAnnotation[] annotations = af.getViewport().getAlignment()
+ .getAlignmentAnnotation();
+
+ List<String> ssSources = AlignmentUtils
+ .getSecondaryStructureSources(annotations);
+ // List<String> ssSources =
+ // AlignmentUtils.extractSSSourceInAlignmentAnnotation(annotations);
+
return ssSources;
}
-
+
/**
* Open and calculate the selected tree or PCA on 'OK'
*/
{
boolean doPCA = pca.isSelected();
boolean doPaSiMap = pasimap.isSelected();
- boolean doPairwise= pairwise.isSelected();
- String modelName = modelNames.getSelectedItem() == null ? "" : modelNames.getSelectedItem().toString();
+ boolean doPairwise = pairwise.isSelected();
+ String modelName = modelNames.getSelectedItem() == null ? ""
+ : modelNames.getSelectedItem().toString();
String ssSource = "";
Object selectedItem = ssSourceDropdown.getSelectedItem();
- if (selectedItem != null) {
- ssSource = selectedItem.toString();
+ if (selectedItem != null)
+ {
+ ssSource = selectedItem.toString();
}
SimilarityParams params = getSimilarityParameters(doPCA);
- if(ssSource.length()>0)
+ if (ssSource.length() > 0)
{
params.setSecondaryStructureSource(ssSource);
}
if (doPCA)
{
openPcaPanel(modelName, params);
- } else if (doPaSiMap) {
- openPasimapPanel(modelName, params);
- } else if (doPairwise) {
- openPairwisePanel(modelName, params);
- } else {
- openTreePanel(modelName, params);
- }
+ }
+ else if (doPaSiMap)
+ {
+ openPasimapPanel(modelName, params);
+ }
+ else if (doPairwise)
+ {
+ openPairwisePanel(modelName, params);
+ }
+ else
+ {
+ openTreePanel(modelName, params);
+ }
closeFrame();
}
private void openPairwisePanel(String modelName, SimilarityParamsI params)
{
- ScoreModelI sm = ScoreModels.getInstance().getScoreModel(modelName, af.alignPanel);
- if (sm==null || !(sm instanceof ScoreMatrix))
+ ScoreModelI sm = ScoreModels.getInstance().getScoreModel(modelName,
+ af.alignPanel);
+ if (sm == null || !(sm instanceof ScoreMatrix))
{
return;
}
- JInternalFrame frame = new JInternalFrame();
- frame.setFrameIcon(null);
- frame.setContentPane(new PairwiseAlignPanel(af.getViewport(),(ScoreMatrix)sm));
- Desktop.addInternalFrame(frame,
- MessageManager.getString("action.pairwise_alignment"), 600,
- 500);
+ new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ JInternalFrame frame = new JInternalFrame();
+ frame.setFrameIcon(null);
+ frame.setContentPane(
+ new PairwiseAlignPanel(af.getViewport(), (ScoreMatrix) sm));
+ Desktop.addInternalFrame(frame,
+ MessageManager.getString("action.pairwise_alignment"), 600,
+ 500);
+ }
+ }).start();
}
/**
* @param modelName
* @param params
*/
- protected void openPasimapPanel(String modelName, SimilarityParamsI params)
+ protected void openPasimapPanel(String modelName,
+ SimilarityParamsI params)
{
AlignViewport viewport = af.getViewport();
* this check in in case this method gets exposed programmatically in future
*/
if (((viewport.getSelectionGroup() != null)
- && (viewport.getSelectionGroup().getSize() < MIN_PASIMAP_SELECTION)
+ && (viewport.getSelectionGroup()
+ .getSize() < MIN_PASIMAP_SELECTION)
&& (viewport.getSelectionGroup().getSize() > 0))
- || (viewport.getAlignment().getHeight() < MIN_PASIMAP_SELECTION))
+ || (viewport.getAlignment()
+ .getHeight() < MIN_PASIMAP_SELECTION))
{
JvOptionPane.showInternalMessageDialog(this,
MessageManager.formatMessage(