Skip to content

Commit d58c39c

Browse files
committed
Overhaul the Python-related config panels.
1 parent c7317d1 commit d58c39c

File tree

4 files changed

+20
-108
lines changed

4 files changed

+20
-108
lines changed

MSFragger-GUI/src/com/dmtavt/fragpipe/tabs/TabConfig.java

Lines changed: 17 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@
8585
import java.awt.BorderLayout;
8686
import java.awt.Color;
8787
import java.awt.Component;
88-
import java.awt.Container;
89-
import java.awt.Dimension;
9088
import java.awt.FlowLayout;
9189
import java.awt.Font;
9290
import java.awt.event.ActionEvent;
@@ -152,10 +150,7 @@ public class TabConfig extends JPanelWithEnablement {
152150
private UiText uiTextBinPython;
153151
private HtmlStyledJEditorPane epPythonVer;
154152
private HtmlStyledJEditorPane epDbsplitText;
155-
private HtmlStyledJEditorPane epDbsplitErr;
156-
private Container epDbsplitErrParent;
157153
private HtmlStyledJEditorPane epEasyPQPText;
158-
private Container epSpeclibgenParent;
159154
private JButton btnAbout;
160155

161156
public static final String TIP_MSFRAGGER_BIN = "tip.msfragger.bin";
@@ -219,8 +214,6 @@ private void init() {
219214
add(createPanelTools(), new CC().growX().wrap());
220215
add(createPanelDiann(), new CC().growX().wrap());
221216
add(createPanelPython(), new CC().growX().wrap());
222-
add(createPanelDbsplit(), new CC().growX().wrap());
223-
add(createPanelSpeclibgen(), new CC().growX().wrap());
224217
add(createPanelBottomInfo(), new CC().growX().wrap());
225218
add(createPanelBottomLink(), new CC().growX().wrap());
226219
}
@@ -896,65 +889,42 @@ private String textDbsplitEnabled(boolean isEnabled) {
896889
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN_ORDERED)
897890
public void on(NoteConfigDbsplit m) {
898891
if (m.ex != null) {
899-
log.debug("Got NoteDbsplitConfig with exception set");
900-
if (epDbsplitErrParent != null && !epDbsplitErrParent.isAncestorOf(epDbsplitErr)) {
901-
epDbsplitErrParent.add(epDbsplitErr, new CC().wrap());
902-
epDbsplitErr.setVisible(true);
903-
}
904892
epDbsplitText.setText(textDbsplitEnabled(false));
905-
if (m.ex instanceof ValidationException) {
906-
epDbsplitErr.setText(m.ex.getMessage());
907-
} else {
908-
showConfigError(m.ex, TIP_DBSPLIT, epDbsplitText, false);
909-
}
910893
this.revalidate();
911894
return;
912895
}
913896
if (m.instance == null) {
914897
throw new IllegalStateException("If no exception is reported from DBSplit init, instance should not be null");
915898
}
916-
log.debug("Got NoteDbsplitConfig without exceptions");
917-
918-
epDbsplitErrParent = epDbsplitErr.getParent();
919-
if (epDbsplitErrParent != null) {
920-
epDbsplitErrParent.remove(epDbsplitErr);
921-
}
922899
epDbsplitText.setText(textDbsplitEnabled(true));
923900
this.revalidate();
924901
}
925902

926-
private String textEasyPQP(String easypqpLocalVersion, String easypqpLatestVersion, String pandasLocalVersion, String numpyLocalVersion, boolean enableEasypqp, String errMsg) {
903+
private String textEasyPQP(String easypqpLocalVersion, String easypqpLatestVersion, boolean enableEasypqp, String errMsg) {
927904
StringBuilder sb = new StringBuilder();
928905
if (enableEasypqp && !easypqpLocalVersion.contentEquals("N/A")) {
929906
if (!easypqpLatestVersion.contentEquals("N/A") && VersionComparator.cmp(easypqpLocalVersion, easypqpLatestVersion) < 0) {
930-
sb.append("EasyPQP: <b>Available</b>. Version: " + easypqpLocalVersion + "<br>"
931-
+ "<p style=\"color:red\">There is a new version (" + easypqpLatestVersion + "). Please upgrade it by clicking the button below and waiting.<br>");
932-
sb.append("Pandas: <b>Available</b>. Version: ").append(pandasLocalVersion).append("<br>");
933-
sb.append("Numpy: <b>Available</b>. Version: ").append(numpyLocalVersion).append("<br>");
907+
sb.append("EasyPQP: <b>Available</b>. Version: " + easypqpLocalVersion + ". Used for spectral library building.<br><br>"
908+
+ "<p style=\"color:red\">There is a new version (" + easypqpLatestVersion + "). Please upgrade it by clicking the button below and waiting.<br><br>");
934909
} else {
935-
sb.append("EasyPQP: <b>Available</b>. Version: " + easypqpLocalVersion + "<br>");
936-
sb.append("Pandas: <b>Available</b>. Version: ").append(pandasLocalVersion).append("<br>");
937-
sb.append("Numpy: <b>Available</b>. Version: ").append(numpyLocalVersion).append("<br>");
910+
sb.append("EasyPQP: <b>Available</b>. Version: " + easypqpLocalVersion + ". Used for spectral library building.<br><br>");
938911
}
939912
} else {
940913
if (errMsg.isEmpty()) {
941-
sb.append("EasyPQP: <b>Not available</b><br>"
942-
+ "Please make sure that Python is installed, and then click the button below and wait.<br>");
914+
sb.append("EasyPQP: <b>Not available</b>. Used for spectral library building.<br><br>");
943915
} else {
944-
sb.append("EasyPQP: <b>Not available</b><br>"
945-
+ "Please make sure that Python is installed, and then click the button below and wait.<br>").append(errMsg);
916+
sb.append("EasyPQP: <b>Not available</b>. Used for spectral library building.<br><br>").append(errMsg);
946917
}
947918
}
948919
return sb.toString();
949920
}
950921

951922
@Subscribe(sticky = true, threadMode = ThreadMode.MAIN_ORDERED)
952923
public void on(NoteConfigSpeclibgen m) {
953-
epSpeclibgenParent = epEasyPQPText.getParent();
954924
epEasyPQPText.setVisible(true);
955925
if (m.ex != null) {
956926
log.debug("Got NoteConfigSpeclibgen with exception set");
957-
epEasyPQPText.setText(textEasyPQP("N/A", "N/A", "N/A", "N/A", false, m.ex.getMessage()));
927+
epEasyPQPText.setText(textEasyPQP("N/A", "N/A", false, m.ex.getMessage()));
958928
showConfigError(m.ex, TIP_SPECLIBGEN, epEasyPQPText, false);
959929
this.revalidate();
960930
return;
@@ -1021,7 +991,7 @@ public void on(NoteConfigSpeclibgen m) {
1021991
easypqpLatestVersion = "N/A";
1022992
}
1023993

1024-
epEasyPQPText.setText(textEasyPQP(m.easypqpLocalVersion, easypqpLatestVersion, m.pandasLocalVersion, m.numpyLocalVersion, true, ""));
994+
epEasyPQPText.setText(textEasyPQP(m.easypqpLocalVersion, easypqpLatestVersion, true, ""));
1025995

1026996
this.revalidate();
1027997
}
@@ -1118,29 +1088,17 @@ private JPanel createPanelPython() {
11181088
.createButton("Download", e -> SwingUtils.openBrowserOrThrow(url));
11191089
p.add(btnDonwload, ccL().wrap());
11201090
}
1091+
11211092
epPythonVer = new HtmlStyledJEditorPane("Python version: N/A");
1122-
p.add(epPythonVer, ccL().wrap());
1093+
epDbsplitText = new HtmlStyledJEditorPane(textDbsplitEnabled(false));
1094+
epEasyPQPText = new HtmlStyledJEditorPane(textEasyPQP("N/A", "N/A", false, ""));
1095+
1096+
final JButton btnFinishPythonInstall = UiUtils.createButton("Finish Python Install", e -> Bus.post(new MessageInstallEasyPQP(console)));
11231097

1124-
// final Runnable pipList = () -> {
1125-
// final ProcessBuilder pb = new ProcessBuilder(uiTextBinPython.getNonGhostText(), "-m", "pip", "freeze");
1126-
// String pythonPipOutputNew;
1127-
// try {
1128-
// pythonPipOutputNew = ProcessUtils.captureOutput(pb);
1129-
// } catch (UnexpectedException ex) {
1130-
// pythonPipOutputNew = null;
1131-
// }
1132-
// if (pythonPipOutputNew != null && !pythonPipOutput.equals(pythonPipOutputNew)) {
1133-
// pythonPipOutput = pythonPipOutputNew;
1134-
// Bus.post(new MessageUiRevalidate());
1135-
// }
1136-
// };
1137-
// final javax.swing.Timer timer = new javax.swing.Timer(5000, e -> {
1138-
// final String binPython = uiTextBinPython.getNonGhostText();
1139-
// if (StringUtils.isNotBlank(binPython))
1140-
// javax.swing.SwingUtilities.invokeLater(pipList);
1141-
// });
1142-
// timer.setInitialDelay(0);
1143-
// timer.start();
1098+
p.add(epPythonVer, ccL().wrap());
1099+
mu.add(p, epDbsplitText).growX().wrap();
1100+
mu.add(p, epEasyPQPText).growX().wrap();
1101+
mu.add(p, btnFinishPythonInstall).split().wrap();
11441102

11451103
return p;
11461104
}
@@ -1191,52 +1149,6 @@ public void on(MessageInstallEasyPQP m) {
11911149
Bus.post(new MessageUiRevalidate(false, true));
11921150
}
11931151

1194-
private JPanel createPanelDbsplit() {
1195-
JPanel p = mu.newPanel("Database Splitting", true);
1196-
1197-
StringBuilder tip = new StringBuilder()
1198-
.append("Used for searching very large databases by splitting into smaller chunks.<br/>")
1199-
.append("Requires <b>Python " + pythonMinVersion + "+</b> with packages <b>Numpy, Pandas</b>.\n")
1200-
.append("Ways to get everything set up:").append("<ul>")
1201-
.append("<li>Install Python " + pythonMinVersion + "+ if you don't yet have it.</li>")
1202-
.append(
1203-
"<li>Install required python modules using <i>pip</i>, the python package manager, with command:</li>")
1204-
.append("<ul>").append("<li>pip install numpy pandas</li>").append("</ul>")
1205-
.append("</ul>");
1206-
String tipHtml = SwingUtils.makeHtml(tip.toString());
1207-
p.setToolTipText(tipHtml);
1208-
1209-
Dimension dim = new Dimension(400, 25);
1210-
epDbsplitText = new HtmlStyledJEditorPane(textDbsplitEnabled(false));
1211-
epDbsplitText.setToolTipText(tipHtml);
1212-
epDbsplitText.setPreferredSize(dim);
1213-
epDbsplitErr = new HtmlStyledJEditorPane("Requires Python " + pythonMinVersion + "+ with modules Numpy and Pandas.");
1214-
epDbsplitErr.setPreferredSize(dim);
1215-
1216-
mu.add(p, epDbsplitText).growX().pushX().wrap();
1217-
mu.add(p, epDbsplitErr).growX().pushX().wrap();
1218-
1219-
return p;
1220-
}
1221-
1222-
private JPanel createPanelSpeclibgen() {
1223-
JPanel p = mu.newPanel("Spectral Library Generation", true);
1224-
1225-
p.setToolTipText(SwingUtils.makeHtml("EasyPQP: Requires <b>Python " + pythonMinVersion + "+</b> with package <b>EasyPQP</b> and <b>lxml</b>"));
1226-
Dimension dim = new Dimension(200, 25);
1227-
1228-
epEasyPQPText = new HtmlStyledJEditorPane("Configuring EasyPQP.");
1229-
epEasyPQPText.setToolTipText(SwingUtils.makeHtml("EasyPQP: Requires <b>Python " + pythonMinVersion + "+</b> with package <b>EasyPQP</b> and <b>lxml</b>"));
1230-
epEasyPQPText.setPreferredSize(dim);
1231-
1232-
final JButton btnInstallEasyPQP = UiUtils.createButton("Finish Python Install", e -> Bus.post(new MessageInstallEasyPQP(console)));
1233-
1234-
mu.add(p, epEasyPQPText).growX().wrap();
1235-
mu.add(p, btnInstallEasyPQP).split().wrap();
1236-
1237-
return p;
1238-
}
1239-
12401152
private JFileChooser createDiannFilechooser() {
12411153
JFileChooser fc = FileChooserUtils.create("Select DIA-NN binary", "Select", false, FcMode.FILES_ONLY, true);
12421154
if (OsUtils.isWindows()) {

MSFragger-GUI/src/com/dmtavt/fragpipe/tools/dbsplit/DbSplit2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private void checkPythonModules(PyInfo pi) throws ValidationException {
146146
byStatus.add(bad.get(status) + " - " + list.stream().map(pm -> pm.installName).collect(Collectors.joining(", ")));
147147
}
148148
}
149-
throw new ValidationException("Python modules: " + String.join(", ", byStatus));
149+
throw new ValidationException("Click 'Finish Python Install' and wait.");
150150
}
151151

152152
this.pi = pi;

MSFragger-GUI/src/com/dmtavt/fragpipe/tools/fpop/FpopScript.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private void checkPythonModules(PyInfo pi) throws ValidationException {
134134
byStatus.add(bad.get(status) + " - " + list.stream().map(pm -> pm.installName).collect(Collectors.joining(", ")));
135135
}
136136
}
137-
throw new ValidationException("Python modules: " + String.join(", ", byStatus));
137+
throw new ValidationException("Click 'Finish Python Install' and wait.");
138138
}
139139

140140
this.pi = pi;

MSFragger-GUI/src/com/dmtavt/fragpipe/tools/speclibgen/SpecLibGen2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private List<PythonModule> checkForMissingModules(PyInfo pi, List<PythonModule>
138138
private void checkPythonSpeclibgen(PyInfo pi) throws ValidationException {
139139
List<PythonModule> missingModulesSpeclibgen = checkForMissingModules(pi, REQUIRED_FOR_EASYPQP);
140140
if (!missingModulesSpeclibgen.isEmpty()) {
141-
throw new ValidationException("Python modules missing: " + Seq.seq(missingModulesSpeclibgen).map(pm -> pm.installName).toString(", "));
141+
throw new ValidationException("Click 'Finish Python Install' and wait.");
142142
}
143143
}
144144

0 commit comments

Comments
 (0)