use of com.compomics.util.parameters.UtilitiesUserParameters in project peptide-shaker by compomics.
the class PrideSearchParametersDialog method okButtonActionPerformed.
// GEN-LAST:event_cancelButtonActionPerformed
/**
* Open SearchGUI with the given search parameters.
*
* @param evt
*/
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_okButtonActionPerformed
prideReShakeGUI.setVisible(false);
this.setVisible(false);
boolean openSearchGUI = true;
// check if we have a valid SearchGUI location.
try {
UtilitiesUserParameters utilitiesUserPreferences = UtilitiesUserParameters.loadUserParameters();
if (utilitiesUserPreferences.getSearchGuiPath() == null || !(new File(utilitiesUserPreferences.getSearchGuiPath()).exists())) {
SearchGuiSetupDialog searchGuiSetupDialog = new SearchGuiSetupDialog(prideReShakeGUI, true);
openSearchGUI = !searchGuiSetupDialog.isDialogCanceled();
}
} catch (Exception e) {
prideReShakeGUI.getPeptideShakerGUI().catchException(e);
}
if (openSearchGUI) {
new Thread(new Runnable() {
public void run() {
try {
File outputFolder = null;
if (!mgfFiles.isEmpty() || !rawFiles.isEmpty()) {
if (!mgfFiles.isEmpty()) {
outputFolder = new File(mgfFiles.get(0).getParentFile(), "search_results");
} else {
outputFolder = new File(rawFiles.get(0).getParentFile(), "search_results");
}
if (!outputFolder.exists()) {
boolean success = outputFolder.mkdir();
if (!success) {
outputFolder = null;
}
}
}
ToolFactory.startSearchGUI(prideReShakeGUI, mgfFiles, rawFiles, fastaFile, prideSearchParametersFile, outputFolder, species, speciesType, psProjectName);
prideReShakeGUI.getPeptideShakerGUI().close();
} catch (Exception e) {
prideReShakeGUI.getPeptideShakerGUI().catchException(e);
}
}
}, "StartSearchGUI").start();
}
}
use of com.compomics.util.parameters.UtilitiesUserParameters in project peptide-shaker by compomics.
the class WelcomeDialog method downloadSearchGUI.
/**
* Download SearchGUI.
*
* @return true if not canceled
*/
public boolean downloadSearchGUI() {
boolean firstTimeInstall = true;
String installPath = null;
UtilitiesUserParameters utilitiesUserPreferences = peptideShakerGUI.getUtilitiesUserParameters();
if (utilitiesUserPreferences.getSearchGuiPath() != null) {
if (new File(utilitiesUserPreferences.getSearchGuiPath()).getParentFile() != null && new File(utilitiesUserPreferences.getSearchGuiPath()).getParentFile().getParentFile() != null) {
installPath = new File(utilitiesUserPreferences.getSearchGuiPath()).getParentFile().getParent();
}
}
final File downloadFolder;
if (installPath == null) {
installPath = "user.home";
downloadFolder = FileChooserUtil.getUserSelectedFolder(this, "Select SearchGUI Folder", installPath, "SearchGUI Folder", "Select", false);
} else {
firstTimeInstall = false;
downloadFolder = new File(installPath);
}
final boolean finalFirstTimeInstall = firstTimeInstall;
if (downloadFolder != null) {
progressDialog = new ProgressDialogX(DUMMY_PARENT_FRAME, Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker.gif")), Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/peptide-shaker-orange.gif")), true);
progressDialog.setPrimaryProgressCounterIndeterminate(true);
progressDialog.setTitle("Downloading SearchGUI. Please Wait...");
new Thread(new Runnable() {
public void run() {
try {
progressDialog.setVisible(true);
} catch (IndexOutOfBoundsException e) {
// ignore
}
}
}, "ProgressDialog").start();
Thread thread = new Thread("DownloadThread") {
@Override
public void run() {
try {
URL jarRepository = new URL("http", "genesis.ugent.be", "/maven2/");
if (finalFirstTimeInstall) {
downloadLatestZipFromRepo(downloadFolder, "SearchGUI", "eu.isas.searchgui", "SearchGUI", "searchgui.ico", null, jarRepository, false, true, new GUIFileDAO(), progressDialog);
} else {
downloadLatestZipFromRepo(new File(peptideShakerGUI.getUtilitiesUserParameters().getSearchGuiPath()).toURI().toURL(), "SearchGUI", false, "searchgui.ico", null, jarRepository, false, true, new GUIFileDAO(), progressDialog);
}
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (XMLStreamException e) {
e.printStackTrace();
}
}
};
thread.start();
try {
thread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
if (progressDialog.isRunCanceled()) {
progressDialog.setRunFinished();
return false;
} else if (!progressDialog.isRunFinished()) {
progressDialog.setRunFinished();
}
return true;
}
return false;
}
use of com.compomics.util.parameters.UtilitiesUserParameters in project peptide-shaker by compomics.
the class DatabaseHelpDialog method browseDatabaseSettingsActionPerformed.
// </editor-fold>//GEN-END:initComponents
/**
* Opens a file chooser where the user can select the database file.
*
* @param evt
*/
private void browseDatabaseSettingsActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_browseDatabaseSettingsActionPerformed
File startLocation = null;
File utilitiesDbFolder = utilitiesUserParameters.getDbFolder();
if (utilitiesDbFolder != null && utilitiesDbFolder.exists()) {
startLocation = utilitiesDbFolder;
}
if (startLocation == null) {
startLocation = new File(getLastSelectedFolder(lastSelectedFolder));
}
UtilitiesUserParameters utilitiesUserPreferences = UtilitiesUserParameters.loadUserParameters();
if (utilitiesUserPreferences.getDbFolder() != null && utilitiesUserPreferences.getDbFolder().exists()) {
startLocation = utilitiesUserPreferences.getDbFolder();
}
if (selectedFastaFile != null) {
File fastaFile = new File(selectedFastaFile);
if (fastaFile.exists()) {
startLocation = fastaFile.getParentFile();
}
}
JFileChooser fc = new JFileChooser(startLocation);
FileFilter filter = new FileFilter() {
@Override
public boolean accept(File myFile) {
return myFile.getName().toLowerCase().endsWith("fasta") || myFile.isDirectory();
}
@Override
public String getDescription() {
return "Supported formats: FASTA (.fasta)";
}
};
fc.setFileFilter(filter);
int result = fc.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
File selectedFile = fc.getSelectedFile();
selectedFastaFile = selectedFile.getAbsolutePath();
if (selectedFile.getName().contains(" ")) {
renameFastaFileName();
} else {
databaseSettingsTxt.setText(selectedFastaFile);
}
lastSelectedFolder.setLastSelectedFolder(SequenceDbDetailsDialog.lastFolderKey, selectedFastaFile);
targetDecoySettingsButton.setEnabled(true);
// check if the database contains decoys
if (!selectedFastaFile.endsWith(fastaParameters.getTargetDecoyFileNameSuffix() + ".fasta")) {
int value = JOptionPane.showConfirmDialog(this, "The selected FASTA file does not seem to contain decoy sequences.\n" + "Decoys are required by PeptideShaker. Add decoys?", "Add Decoy Sequences?", JOptionPane.YES_NO_OPTION);
if (value == JOptionPane.YES_OPTION) {
targetDecoySettingsButtonActionPerformed(null);
}
}
validateParametersInput(false);
}
}
Aggregations