private void traitComboBoxActionPerformed(java.awt.event.ActionEvent evt) { if (this.traitSetComboBox.getSelectedObjects().length == 0 || this.traitSetComboBox.getSelectedIndex() < 0) { return; } String s = this.markerSetComboBox.getSelectedItem().toString(); markerSetComboBox.removeAllItems(); Project project = Model.getInstance().getProject(this.projectComboBox.getSelectedItem().toString()); TraitSet ts = project.getTrait(this.traitSetComboBox.getSelectedItem().toString()); MarkerSet ms = null; if (!s.equals("")) ; { ms = project.getMarker(s); } if ((ts.getHasData() && ms == null) || (ts.getHasData() && ms != null && ms.hasData())) { algorithmComboBox.setEnabled(true); this.createAssociationRadioButton.setEnabled(true); this.createAssociationRadioButton.setSelected(true); } else { this.algorithmComboBox.setEnabled(false); this.createAssociationRadioButton.setEnabled(false); this.loadAssociationRadioButton.setSelected(true); } for (MarkerSet m : project.getMarkers()) { if (isSameSampleSet( m, project.getTrait(this.traitSetComboBox.getSelectedItem().toString()))) { markerSetComboBox.addItem(m.getName()); } } for (int i = 0; i < markerSetComboBox.getItemCount(); i++) { if (markerSetComboBox.getItemAt(i).equals(s)) { markerSetComboBox.setSelectedIndex(i); } } int structtype = algorithmComboBox.getSelectedIndex() < 0 ? -1 : Algorithms.AssociationAlgorithms.inputStructure() .get(algorithmComboBox.getSelectedIndex()); if (algorithmComboBox.getSelectedIndex() < 0 || !(structtype > 0) || structtype == 3 || !this.algorithmComboBox.isEnabled()) { this.networkComboBox.setEnabled(false); return; } else { this.networkComboBox.setEnabled(true); } this.networkComboBox.removeAllItems(); if (structtype == 1) { TraitSet t = project.getTrait(this.traitSetComboBox.getSelectedItem().toString()); for (int i = 0; i < t.getNetworkIdentifiers().size(); i++) { this.networkComboBox.addItem(t.getNetworkIdentifiers().get(i)); } } else if (structtype == 2) { MarkerSet m = project.getMarker(this.markerSetComboBox.getSelectedItem().toString()); if (m == null) { return; } for (int i = 0; i < m.getPopulations().size(); i++) { this.networkComboBox.addItem(m.getPopulations().get(i)); } } }
private boolean isSameSampleSet(MarkerSet m, TraitSet trait) { if (m.getNumSamples() != trait.getNumSamples()) { return false; } return true; }
/** * Checks conditions and starts the algorithm. * * @param evt */ private void runButtonActionPerformed(java.awt.event.ActionEvent evt) { if (this.projectComboBox.getSelectedItem().equals("")) { UIMessages.showErrorMessage("Please select a project", "Error"); return; } if (this.traitSetComboBox.getSelectedIndex() < 0) { UIMessages.showErrorMessage("Please select a trait option", "Error"); return; } String projectName = projectComboBox.getSelectedItem().toString(); String traitName = traitSetComboBox.getSelectedItem().toString(); String markerName = markerSetComboBox.getSelectedItem().toString(); Project ap = Model.getInstance().getProject(projectName); TraitSet ts = ap.getTrait(traitName); MarkerSet ms = ap.getMarker(markerName); if (this.algorithmComboBox.getSelectedIndex() < 0 && !this.loadAssociationRadioButton.isSelected()) { UIMessages.showErrorMessage("Please select an algorithm", "Error"); return; } if (this.algorithmComboBox.getSelectedItem().equals("Adaptive Multi-Task Lasso")) { ArrayList<String> where = new ArrayList<String>(); where.add("markersetid = " + ms.getId()); if (Integer.parseInt( DataManager.runSelectQuery("count(*)", "feature", true, where, null).get(0)) < 1) { UIMessages.showErrorMessage("Selected marker set does not have features", "Error"); return; } } if (this.markerSetComboBox.getSelectedIndex() < 0) { UIMessages.showErrorMessage("Please select a marker", "Error"); return; } if (this.networkComboBox.getSelectedIndex() < 0 && this.networkComboBox.isEnabled()) { UIMessages.showErrorMessage( "Please select a valid network option for selected algorithm", "Error"); return; } if (this.networkComboBox.getSelectedIndex() < 0 && this.networkComboBox.isEnabled()) { UIMessages.showErrorMessage( "Please select a valid Population option for selected algorithm", "Error"); return; } if (this.numberComboBox.isEnabled() && this.numberComboBox.getSelectedIndex() < 0) { UIMessages.showErrorMessage( "Please select a valid Population option for this algorithm", "Error"); return; } if (this.nameTextField.getText().equals("")) { UIMessages.showErrorMessage("Please specify a valid name", "Error"); return; } if (Model.getInstance() .getProject(projectComboBox.getSelectedItem().toString()) .isAssocNamePresentInProject(this.nameTextField.getText())) { UIMessages.showErrorMessage("Specified name already exists for this project", "Error"); return; } String networkName = this.networkComboBox.getSelectedItem().toString(); String algoName = this.algorithmComboBox.getSelectedItem().toString(); String popno = this.numberComboBox.getSelectedItem().toString(); if (!this.numberComboBox.isEnabled()) { popno = "1"; } algoName = (algoName.equals("")) ? null : algoName; Network net = (Network) ts.getTraitStructure(networkName); if (ts.getNetworks().size() == 0) // without a network, we will be unable // to view this visualization, so we add it here. { try { view.addAlgorithm( Algorithms.NetworkAlgorithms.algonames().get(0), Algorithms.NetworkAlgorithms.jobTypeID().get(0), ap.getId(), ts.getId(), ms.getId()); } catch (Exception e) { } } if (this.createAssociationRadioButton.isSelected()) { int structtype = algorithmComboBox.getSelectedIndex() < 0 ? -1 : Algorithms.AssociationAlgorithms.inputStructure() .get(algorithmComboBox.getSelectedIndex()); IOFilesForIOLasso ioffio = null; if (structtype == 3) { ioffio = new IOFilesForIOLasso(currentComponentReference); ioffio.setVisible(true); if (ioffio.getInputFilePath() == null || ioffio.getInputFilePath().length() < 5 || ioffio.getOutputFilePath() == null || ioffio.getOutputFilePath().length() < 5) { UIMessages.showErrorMessage("I/O Lasso needs valid group files", "Error"); return; } } AssociationParameterObject apo = new AssociationParameterObject( (Network) ts.getTraitStructure(networkName), this.nameTextField.getText(), ms.getPopulation(networkName), popno, ioffio); int idx = this.algorithmComboBox.getSelectedIndex() - 1; view.addAlgorithm( Algorithms.AssociationAlgorithms.algonames().get(idx), Algorithms.AssociationAlgorithms.jobTypeID().get(idx), ap.getId(), ts.getId(), ms.getId(), apo); } else { DataAddRemoveHandler.getInstance() .addAssociation( ap.getId(), ts, ms, this.nameTextField.getText(), this.associationFilePathTextField.getText(), null); } this.dispose(); }