JAL-629 Guesstimate whether to set pLDDT with PDB file
authorBen Soares <b.soares@dundee.ac.uk>
Mon, 27 Feb 2023 14:16:00 +0000 (14:16 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Mon, 27 Feb 2023 14:16:00 +0000 (14:16 +0000)
src/jalview/gui/StructureChooser.java
src/jalview/jbgui/GStructureChooser.java

index 11e50db..5612469 100644 (file)
@@ -679,7 +679,17 @@ public class StructureChooser extends GStructureChooser
     {
       selectedPdbFileName = chooser.getSelectedFile().getPath();
       Cache.setProperty("LAST_DIRECTORY", selectedPdbFileName);
+      boolean guessTFType = localPdbPaeMatrixFileName == null;
       localPdbPaeMatrixFileName = guessPAEFilename();
+      guessTFType |= localPdbPaeMatrixFileName != null;
+      if (guessTFType
+              && new File(selectedPdbFileName).getName().startsWith("AF-")
+              && !tempFacAsChanged)
+      {
+        // localPdbPaeMatrixFileName was null and now isn't and filename could
+        // well be AlphaFold and user hasn't adjusted the tempFacType
+        combo_tempFacAs.setSelectedItem(TFType.PLDDT);
+      }
       validateSelections();
     }
   }
index ac623bc..d317e97 100644 (file)
@@ -133,6 +133,8 @@ public abstract class GStructureChooser extends JPanel
 
   protected JComboBox<StructureImportSettings.TFType> combo_tempFacAs = new JComboBox<>();
 
+  protected boolean tempFacAsChanged = false;
+
   protected JButton btn_paeMatrixFile = new JButton();
 
   protected JLabel lbl_paeFile = new JLabel();
@@ -577,6 +579,15 @@ public abstract class GStructureChooser extends JPanel
     {
       combo_tempFacAs.addItem(t);
     }
+    combo_tempFacAs.addItemListener(new ItemListener()
+    {
+      @Override
+      public void itemStateChanged(ItemEvent e)
+      {
+        // used to determine if we should guess pLDDT or leave a user-choice
+        tempFacAsChanged = true;
+      }
+    });
 
     btn_paeMatrixFile.setFont(VERDANA_12);
     btn_paeMatrixFile.setText(new StringBuilder()