JAL-1919 code improvement to make PDB sequence fetcher file format configurable....
[jalview.git] / src / jalview / ws / dbsources / Pdb.java
index 3fd7541..358c838 100644 (file)
@@ -47,6 +47,8 @@ public class Pdb extends EbiFileRetrievedProxy
     super();
   }
 
+  private static String currentDefaultFomart = DBRefSource.MMCIF;
+
   /*
    * (non-Javadoc)
    * 
@@ -124,8 +126,12 @@ public class Pdb extends EbiFileRetrievedProxy
       stopQuery();
       return null;
     }
+    String ext = getCurrentDefaultFomart().equalsIgnoreCase("mmcif") ? ".cif"
+            : ".xml";
     EBIFetchClient ebi = new EBIFetchClient();
-    file = ebi.fetchDataAsFile("pdb:" + id, "pdb", "raw").getAbsolutePath();
+    file = ebi.fetchDataAsFile("pdb:" + id,
+            getCurrentDefaultFomart().toLowerCase(), "raw", ext)
+            .getAbsolutePath();
     stopQuery();
     if (file == null)
     {
@@ -135,7 +141,8 @@ public class Pdb extends EbiFileRetrievedProxy
     {
 
       pdbAlignment = new FormatAdapter().readFile(file,
-              jalview.io.AppletFormatAdapter.FILE, "PDB");
+              jalview.io.AppletFormatAdapter.FILE,
+              getCurrentDefaultFomart());
       if (pdbAlignment != null)
       {
         List<SequenceI> toremove = new ArrayList<SequenceI>();
@@ -249,4 +256,14 @@ public class Pdb extends EbiFileRetrievedProxy
   {
     return 0;
   }
+
+  public static String getCurrentDefaultFomart()
+  {
+    return currentDefaultFomart;
+  }
+
+  public static void setCurrentDefaultFomart(String currentDefaultFomart)
+  {
+    Pdb.currentDefaultFomart = currentDefaultFomart;
+  }
 }