JAL-3919 use model format field to ensure we get the file extension correct when...
[jalview.git] / src / jalview / gui / structurechooser / ThreeDBStructureChooserQuerySource.java
index cdf456c..ffc6c66 100644 (file)
@@ -370,6 +370,7 @@ public class ThreeDBStructureChooserQuerySource
     int urlColumnIndex = restable.getColumn("Url").getModelIndex();
     int typeColumnIndex = restable.getColumn("Provider").getModelIndex();
     int humanUrl = restable.getColumn("Page URL").getModelIndex();
+    int modelformat = restable.getColumn("Model Format").getModelIndex();
     int categoryColumnIndex = restable.getColumn("Model Category")
             .getModelIndex();
     final int up_start_idx = restable.getColumn("Uniprot Start")
@@ -408,6 +409,8 @@ public class ThreeDBStructureChooserQuerySource
               .toString();
       String modelPage = humanUrl < 1 ? null
               : (String) restable.getValueAt(row, humanUrl);
+      String strucFormat = restable.getValueAt(row, modelformat).toString();
+
       SequenceI selectedSeq = (SequenceI) restable.getValueAt(row,
               refSeqColIndex);
       selectedSeqsToView.add(selectedSeq);
@@ -421,11 +424,15 @@ public class ThreeDBStructureChooserQuerySource
       {
         pdbEntry = new PDBEntry();
         pdbEntry.setId(pdbIdStr);
-        boolean hasCif = urlStr.toLowerCase(Locale.ENGLISH).endsWith("cif");
-        boolean probablyPdb = urlStr.toLowerCase(Locale.ENGLISH)
-                .contains("pdb");
-        pdbEntry.setType(hasCif ? PDBEntry.Type.MMCIF
-                : probablyPdb ? PDBEntry.Type.PDB : PDBEntry.Type.FILE);
+        try
+        {
+          pdbEntry.setType(PDBEntry.Type.valueOf(strucFormat));
+        } catch (Exception q)
+        {
+          Cache.log.warn("Unknown filetype for 3D Beacons Model from: "
+                  + strucFormat + " - " + pdbIdStr + " - " + modelPage);
+        }
+
         if (!"PDBe".equalsIgnoreCase(typeColumn))
         {
           pdbEntry.setRetrievalUrl(urlStr);