Merge branch 'develop' into features/JAL-2094_colourInterface
[jalview.git] / src / jalview / ws / dbsources / Pdb.java
index 358c838..04c23a2 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
  * Copyright (C) $$Year-Rel$$ The Jalview Authors
  */
 package jalview.ws.dbsources;
 
+import jalview.api.FeatureSettingsModelI;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.DBRefSource;
 import jalview.datamodel.PDBEntry;
+import jalview.datamodel.PDBEntry.Type;
 import jalview.datamodel.SequenceI;
 import jalview.io.FormatAdapter;
+import jalview.io.PDBFeatureSettings;
+import jalview.structure.StructureImportSettings;
 import jalview.util.MessageManager;
 import jalview.ws.ebi.EBIFetchClient;
 
@@ -47,7 +52,9 @@ public class Pdb extends EbiFileRetrievedProxy
     super();
   }
 
-  private static String currentDefaultFomart = DBRefSource.MMCIF;
+  public static final String FEATURE_INSERTION = "INSERTION";
+
+  public static final String FEATURE_RES_NUM = "RESNUM";
 
   /*
    * (non-Javadoc)
@@ -126,11 +133,12 @@ public class Pdb extends EbiFileRetrievedProxy
       stopQuery();
       return null;
     }
-    String ext = getCurrentDefaultFomart().equalsIgnoreCase("mmcif") ? ".cif"
-            : ".xml";
+    String ext = StructureImportSettings.getDefaultStructureFileFormat()
+            .equalsIgnoreCase(Type.MMCIF.toString()) ? ".cif" : ".xml";
     EBIFetchClient ebi = new EBIFetchClient();
     file = ebi.fetchDataAsFile("pdb:" + id,
-            getCurrentDefaultFomart().toLowerCase(), "raw", ext)
+            StructureImportSettings.getDefaultStructureFileFormat().toLowerCase(),
+            ext)
             .getAbsolutePath();
     stopQuery();
     if (file == null)
@@ -142,7 +150,7 @@ public class Pdb extends EbiFileRetrievedProxy
 
       pdbAlignment = new FormatAdapter().readFile(file,
               jalview.io.AppletFormatAdapter.FILE,
-              getCurrentDefaultFomart());
+              StructureImportSettings.getDefaultStructureFileFormat());
       if (pdbAlignment != null)
       {
         List<SequenceI> toremove = new ArrayList<SequenceI>();
@@ -165,6 +173,8 @@ public class Pdb extends EbiFileRetrievedProxy
                           || chid.trim().equals(chain.trim()) || (chain
                           .trim().length() == 0 && chid.equals("_")))))
           {
+            // FIXME seems to result in 'PDB|1QIP|1qip|A' - 1QIP is redundant.
+            // TODO: suggest simplify naming to 1qip|A as default name defined
             pdbcs.setName(jalview.datamodel.DBRefSource.PDB + "|" + id
                     + "|" + pdbcs.getName());
             // Might need to add more metadata to the PDBEntry object
@@ -237,12 +247,12 @@ public class Pdb extends EbiFileRetrievedProxy
   }
 
   /**
-   * obtain human glyoxalase chain A sequence
+   * human glyoxalase
    */
   @Override
   public String getTestQuery()
   {
-    return "1QIPA";
+    return "1QIP";
   }
 
   @Override
@@ -257,13 +267,19 @@ public class Pdb extends EbiFileRetrievedProxy
     return 0;
   }
 
-  public static String getCurrentDefaultFomart()
-  {
-    return currentDefaultFomart;
-  }
 
-  public static void setCurrentDefaultFomart(String currentDefaultFomart)
+  /**
+   * Returns a descriptor for suitable feature display settings with
+   * <ul>
+   * <li>ResNums or insertions features visible</li>
+   * <li>insertions features coloured red</li>
+   * <li>ResNum features coloured by label</li>
+   * <li>Insertions displayed above (on top of) ResNums</li>
+   * </ul>
+   */
+  @Override
+  public FeatureSettingsModelI getFeatureColourScheme()
   {
-    Pdb.currentDefaultFomart = currentDefaultFomart;
+    return new PDBFeatureSettings();
   }
 }