Merge branch 'develop' into trialMerge
[jalview.git] / src / jalview / ws / dbsources / Pdb.java
index 11fe95e..0aae38f 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
  * Copyright (C) $$Year-Rel$$ The Jalview Authors
@@ -28,6 +29,9 @@ import jalview.datamodel.DBRefSource;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
 import jalview.io.FormatAdapter;
 import jalview.io.PDBFeatureSettings;
 import jalview.structure.StructureImportSettings;
@@ -36,6 +40,7 @@ import jalview.ws.ebi.EBIFetchClient;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Vector;
 
 import com.stevesoft.pat.Regex;
 
@@ -137,13 +142,12 @@ public class Pdb extends EbiFileRetrievedProxy
       stopQuery();
       return null;
     }
-    String ext = StructureImportSettings.getDefaultStructureFileFormat()
-            .equalsIgnoreCase(Type.MMCIF.toString()) ? ".cif" : ".xml";
+    Type pdbFileFormat = StructureImportSettings
+            .getDefaultStructureFileFormat();
+    String ext = "." + pdbFileFormat.getExtension();
     EBIFetchClient ebi = new EBIFetchClient();
-    file = ebi.fetchDataAsFile(
-            "pdb:" + id,
-            StructureImportSettings.getDefaultStructureFileFormat()
-                    .toLowerCase(), ext).getAbsolutePath();
+    file = ebi.fetchDataAsFile("pdb:" + id, pdbFileFormat.getFormat(), ext)
+            .getAbsolutePath();
     stopQuery();
     if (file == null)
     {
@@ -151,10 +155,11 @@ public class Pdb extends EbiFileRetrievedProxy
     }
     try
     {
-
+      // convert Type.PDB/MMCIF to FileFormat.PDB/MMCIF
+      // todo get rid of Type?
+      FileFormatI fileFormat = FileFormat.valueOf(pdbFileFormat.toString());
       pdbAlignment = new FormatAdapter().readFile(file,
-              jalview.io.AppletFormatAdapter.FILE,
-              StructureImportSettings.getDefaultStructureFileFormat());
+              DataSourceType.FILE, fileFormat);
       if (pdbAlignment != null)
       {
         List<SequenceI> toremove = new ArrayList<SequenceI>();