JAL-1668 First version JAL-1668
authorCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 4 Mar 2015 20:49:30 +0000 (20:49 +0000)
committerCharles Ofoegbu <tcnofoegbu@dundee.ac.uk>
Wed, 4 Mar 2015 20:49:30 +0000 (20:49 +0000)
14 files changed:
resources/lang/Messages.properties
src/jalview/gui/EBIFetchPanel.java [deleted file]
src/jalview/gui/PDBFetchPanel.java [new file with mode: 0644]
src/jalview/gui/PopupMenu.java
src/jalview/gui/SequenceFetcher.java
src/jalview/gui/StructureChooser.java [new file with mode: 0644]
src/jalview/jbgui/GPDBFetchPanel.java [moved from src/jalview/jbgui/GEBIFetchPanel.java with 89% similarity]
src/jalview/jbgui/GStructureChooser.java [new file with mode: 0644]
src/jalview/ws/dbsources/PDBRestClient.java
src/jalview/ws/uimodel/PDBSearchOptionListModel.java [deleted file]
src/jalview/ws/uimodel/PDBSearchRequest.java [new file with mode: 0644]
src/jalview/ws/uimodel/PDBSearchResponse.java [new file with mode: 0644]
src/jalview/ws/uimodel/PDBSearchResultPojo.java [deleted file]
src/jalview/ws/uimodel/PDBSummaryListModel.java

index 7c2a41a..2e37ee4 100644 (file)
@@ -1193,3 +1193,6 @@ label.display_name = Display Label
 label.description = Description
 label.include_description= Include Description
 action.back = Back
+label.hide_insertions = Hide Insertions
+label.mark_as_representative = Mark as representative
+label.open_jabaws_web_page = Open JABAWS web page
\ No newline at end of file
diff --git a/src/jalview/gui/EBIFetchPanel.java b/src/jalview/gui/EBIFetchPanel.java
deleted file mode 100644 (file)
index 7fe9f2e..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-package jalview.gui;
-
-import jalview.jbgui.GEBIFetchPanel;
-import jalview.ws.dbsources.PDBRestClient;
-import jalview.ws.uimodel.PDBSearchOptionListModel;
-import jalview.ws.uimodel.PDBSearchResultPojo;
-import jalview.ws.uimodel.PDBSummaryListModel;
-
-import javax.swing.DefaultListModel;
-import javax.swing.SwingUtilities;
-
-@SuppressWarnings("serial")
-public class EBIFetchPanel extends GEBIFetchPanel
-{
-  private SequenceFetcher seqFetcher;
-
-  public EBIFetchPanel()
-  {
-  }
-
-  public EBIFetchPanel(SequenceFetcher seqFetcher)
-  {
-    this();
-    this.seqFetcher = seqFetcher;
-  }
-
-  public static void main(String[] args)
-  {
-    SwingUtilities.invokeLater(new Runnable()
-    {
-      public void run()
-      {
-        new EBIFetchPanel();
-      }
-    });
-  }
-
-  @Override
-  public void searchStringAction()
-  {
-
-    jListSearchResult.setModel(new DefaultListModel<PDBSummaryListModel>());
-    mainFrame.setTitle("PDB Sequence Fetcher");
-    if (search.getText().trim().length() > 0)
-    {
-      long startTime = System.currentTimeMillis();
-
-      PDBSearchResultPojo resultList = new PDBRestClient().searchResult(
-              ((PDBSearchOptionListModel) searchFeild.getSelectedItem()).getCode(),
-              search.getText());
-      if (resultList.getSearchSummary() != null)
-      {
-        jListSearchResult.setModel(resultList.getSearchSummary());
-      }
-      long endTime = System.currentTimeMillis();
-      mainFrame.setTitle("PDB Sequence Fetcher - "
-              + resultList.getItemFound() + " results ("
-              + (endTime - startTime) + " milli secs)");
-    }
-
-  }
-
-  @Override
-  public void okActionPerformed()
-  {
-    processPDBResponseData();
-  }
-
-
-  @Override
-  public void backActionPerformed()
-  {
-    System.out.println("back! pressed!");
-  }
-
-  @Override
-  public void cancelActionPerformed()
-  {
-    mainFrame.dispose();
-  }
-
-  private void processPDBResponseData()
-  {
-    mainFrame.dispose();
-    StringBuilder selectedIds = new StringBuilder();
-    for (PDBSummaryListModel dataSelected : jListSearchResult
-            .getSelectedValuesList())
-    {
-      selectedIds.append(";").append(dataSelected.getPdbId());
-    }
-    String ids = selectedIds.deleteCharAt(0).toString();
-    seqFetcher.textArea.setText(ids);
-    Thread worker = new Thread(seqFetcher);
-
-    // Thread worker = new Thread(this);
-    worker.start();
-  }
-
-  // @Override
-  // public void run()
-  // {
-  // for (PDBSummaryListModel sum : jListSearchResult
-  // .getSelectedValuesList())
-  // {
-  // System.out.println("you selected ------------> " + sum.getPdbId());
-  // }
-  // seqFetcher.guiWindow.setProgressBar(MessageManager
-  // .getString("status.processing"), Thread.currentThread()
-  // .hashCode());
-  // try
-  // {
-  // Thread.sleep(1000 * 2);
-  // } catch (InterruptedException e)
-  // {
-  // e.printStackTrace();
-  // }
-  // seqFetcher.guiWindow.setProgressBar(null, Thread.currentThread()
-  // .hashCode());
-  // }
-
-}
diff --git a/src/jalview/gui/PDBFetchPanel.java b/src/jalview/gui/PDBFetchPanel.java
new file mode 100644 (file)
index 0000000..c7e5362
--- /dev/null
@@ -0,0 +1,243 @@
+package jalview.gui;
+
+import jalview.jbgui.GPDBFetchPanel;
+import jalview.ws.dbsources.PDBRestClient;
+import jalview.ws.uimodel.PDBSearchRequest;
+import jalview.ws.uimodel.PDBSearchResponse;
+import jalview.ws.uimodel.PDBSummaryListModel;
+import jalview.ws.uimodel.PDBSummaryListModel.PDBDocField;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.DefaultListModel;
+import javax.swing.SwingUtilities;
+
+@SuppressWarnings("serial")
+public class PDBFetchPanel extends GPDBFetchPanel
+{
+  private SequenceFetcher seqFetcher;
+
+  public enum FieldType
+  {
+    INT, STRING, BOOLEAN;
+  }
+
+  public PDBFetchPanel()
+  {
+  }
+
+  public PDBFetchPanel(SequenceFetcher seqFetcher)
+  {
+    this();
+    this.seqFetcher = seqFetcher;
+  }
+
+  public static void main(String[] args)
+  {
+    SwingUtilities.invokeLater(new Runnable()
+    {
+      public void run()
+      {
+        new PDBFetchPanel();
+      }
+    });
+  }
+
+  @Override
+  public void searchStringAction()
+  {
+    boolean allowEmptySequence = false;
+    jListSearchResult.setModel(new DefaultListModel<PDBSummaryListModel>());
+    mainFrame.setTitle("PDB Sequence Fetcher");
+    if (search.getText().trim().length() > 0)
+    {
+      long startTime = System.currentTimeMillis();
+      PDBRestClient pdbRestCleint = new PDBRestClient();
+      String searchTarget = ((PDBSearchOptionList) searchTargetOptions
+              .getSelectedItem()).getCode();
+
+      PDBSearchRequest request = new PDBSearchRequest();
+      request.setAllowEmptySeq(allowEmptySequence);
+      request.setResponseSize(100);
+      request.setSearchTarget(searchTarget + ":");
+      request.setSearchTerm(search.getText());
+      List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
+      wantedFields.add(PDBDocField.MOLECULE_TYPE);
+      wantedFields.add(PDBDocField.PDB_ID);
+      wantedFields.add(PDBDocField.GENUS);
+      wantedFields.add(PDBDocField.GENE_NAME);
+      wantedFields.add(PDBDocField.TITLE);
+      request.setWantedFields(wantedFields);
+
+      PDBSearchResponse resultList = pdbRestCleint.executeRequest(request);
+
+      if (resultList.getSearchSummary() != null)
+      {
+        jListSearchResult.setModel(PDBSearchResponse
+                .getListModel(resultList.getSearchSummary()));
+      }
+      long endTime = System.currentTimeMillis();
+      mainFrame.setTitle("PDB Sequence Fetcher - "
+              + resultList.getItemsFound() + " results ("
+              + (endTime - startTime) + " milli secs)");
+    }
+
+  }
+
+  @Override
+  public void okActionPerformed()
+  {
+    processPDBResponseData();
+  }
+
+
+  @Override
+  public void backActionPerformed()
+  {
+    System.out.println("back! pressed!");
+  }
+
+  @Override
+  public void cancelActionPerformed()
+  {
+    mainFrame.dispose();
+  }
+
+  private void processPDBResponseData()
+  {
+    mainFrame.dispose();
+    StringBuilder selectedIds = new StringBuilder();
+    for (PDBSummaryListModel dataSelected : jListSearchResult
+            .getSelectedValuesList())
+    {
+      selectedIds.append(";").append(dataSelected.getPdbId());
+    }
+    String ids = selectedIds.deleteCharAt(0).toString();
+    seqFetcher.textArea.setText(ids);
+    Thread worker = new Thread(seqFetcher);
+    worker.start();
+  }
+
+  @SuppressWarnings("unchecked")
+  public void populateSearchOptionCombo()
+
+  {
+    List<PDBSearchOptionList> searchOptions = new ArrayList<PDBSearchOptionList>();
+    searchOptions.add(new PDBSearchOptionList("PDB ID", "pdb_id",
+            FieldType.STRING));
+    searchOptions.add(new PDBSearchOptionList("PFAM Name", "pfam_name",
+            FieldType.STRING));
+    searchOptions.add(new PDBSearchOptionList("ALL", "text",
+            FieldType.STRING));
+    searchOptions.add(new PDBSearchOptionList("Molecule Type",
+            "molecule_type", FieldType.STRING));
+    searchOptions.add(new PDBSearchOptionList("Title", "title",
+            FieldType.STRING));
+    searchOptions.add(new PDBSearchOptionList("Molecule Name",
+            "molecule_name", FieldType.STRING));
+    searchOptions.add(new PDBSearchOptionList("Tax ID", "tax_id",
+            FieldType.STRING));
+    searchOptions.add(new PDBSearchOptionList("UniProt Accession",
+            "uniprot_accession", FieldType.STRING));
+    searchOptions.add(new PDBSearchOptionList("Gene Name", "gene_name",
+            FieldType.STRING));
+    searchOptions.add(new PDBSearchOptionList("Genus", "genus",
+            FieldType.STRING));
+
+    java.util.Collections.sort(searchOptions);
+
+    for (PDBSearchOptionList pdbSO : searchOptions)
+    {
+      searchTargetOptions.addItem(pdbSO);
+    }
+  }
+
+  @SuppressWarnings("rawtypes")
+  public class PDBSearchOptionList implements Comparable
+  {
+    private String name;
+
+    private String code;
+
+    private boolean showInSummary;
+
+    private boolean searchFilter;
+
+    private FieldType type;
+
+    public PDBSearchOptionList(String name, String code, FieldType type)
+    {
+      this.name = name;
+      this.code = code;
+      this.type = type;
+    }
+
+    public String getName()
+    {
+      return name;
+    }
+
+    public void setName(String name)
+    {
+      this.name = name;
+    }
+
+    public String getCode()
+    {
+      return code;
+    }
+
+    public void setCode(String code)
+    {
+      this.code = code;
+    }
+
+    public boolean isShowInSummary()
+    {
+      return showInSummary;
+    }
+
+    public void setShowInSummary(boolean showInSummary)
+    {
+      this.showInSummary = showInSummary;
+    }
+
+    public boolean isSearchFilter()
+    {
+      return searchFilter;
+    }
+
+    public void setSearchFilter(boolean searchFilter)
+    {
+      this.searchFilter = searchFilter;
+    }
+
+    public FieldType getFieldType()
+    {
+      return type;
+    }
+
+    public void setFieldType(FieldType type)
+    {
+      this.type = type;
+    }
+
+    public String toString()
+    {
+      return name;
+    }
+
+    public PDBSearchOptionList()
+    {
+
+    }
+
+    @Override
+    public int compareTo(Object o)
+    {
+      return this.name.compareTo(((PDBSearchOptionList) o).getName());
+    }
+
+  }
+}
index 1137990..72313be 100644 (file)
@@ -212,7 +212,7 @@ public class PopupMenu extends JPopupMenu
 
   JMenu jMenu1 = new JMenu();
 
-  JMenu structureMenu = new JMenu();
+  JMenuItem structureMenu = new JMenuItem();
 
   JMenu viewStructureMenu = new JMenu();
 
@@ -639,50 +639,50 @@ public class PopupMenu extends JPopupMenu
                 new PDBEntry[pdbe.size()]), pr = reppdb.values().toArray(
                 new PDBEntry[reppdb.size()]);
         final JMenuItem gpdbview, rpdbview;
-        if (pdbe.size() == 1)
-        {
-          structureMenu.add(gpdbview = new JMenuItem(MessageManager
-                  .formatMessage("label.view_structure_for", new String[]
-                  { sqass.getDisplayId(false) })));
-        }
-        else
-        {
-          structureMenu.add(gpdbview = new JMenuItem(MessageManager
-                  .formatMessage("label.view_all_structures", new String[]
-                  { new Integer(pdbe.size()).toString() })));
-        }
-        gpdbview.setToolTipText(MessageManager
-                .getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));
-        gpdbview.addActionListener(new ActionListener()
-        {
-
-          @Override
-          public void actionPerformed(ActionEvent e)
-          {
-            new StructureViewer(ap.getStructureSelectionManager())
-                    .viewStructures(ap, pe, ap.av.collateForPDB(pe));
-          }
-        });
-        if (reppdb.size() > 1 && reppdb.size() < pdbe.size())
-        {
-          structureMenu.add(rpdbview = new JMenuItem(MessageManager
-                  .formatMessage(
-                          "label.view_all_representative_structures",
-                          new String[]
-                          { new Integer(reppdb.size()).toString() })));
-          rpdbview.setToolTipText(MessageManager
-                  .getString("label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment"));
-          rpdbview.addActionListener(new ActionListener()
-          {
-
-            @Override
-            public void actionPerformed(ActionEvent e)
-            {
-              new StructureViewer(ap.getStructureSelectionManager())
-                      .viewStructures(ap, pr, ap.av.collateForPDB(pr));
-            }
-          });
-        }
+        // if (pdbe.size() == 1)
+        // {
+        // structureMenu.add(gpdbview = new JMenuItem(MessageManager
+        // .formatMessage("label.view_structure_for", new String[]
+        // { sqass.getDisplayId(false) })));
+        // }
+        // else
+        // {
+        // structureMenu.add(gpdbview = new JMenuItem(MessageManager
+        // .formatMessage("label.view_all_structures", new String[]
+        // { new Integer(pdbe.size()).toString() })));
+        // }
+        // gpdbview.setToolTipText(MessageManager
+        // .getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));
+        // gpdbview.addActionListener(new ActionListener()
+        // {
+        //
+        // @Override
+        // public void actionPerformed(ActionEvent e)
+        // {
+        // new StructureViewer(ap.getStructureSelectionManager())
+        // .viewStructures(ap, pe, ap.av.collateForPDB(pe));
+        // }
+        // });
+        // if (reppdb.size() > 1 && reppdb.size() < pdbe.size())
+        // {
+        // structureMenu.add(rpdbview = new JMenuItem(MessageManager
+        // .formatMessage(
+        // "label.view_all_representative_structures",
+        // new String[]
+        // { new Integer(reppdb.size()).toString() })));
+        // rpdbview.setToolTipText(MessageManager
+        // .getString("label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment"));
+        // rpdbview.addActionListener(new ActionListener()
+        // {
+        //
+        // @Override
+        // public void actionPerformed(ActionEvent e)
+        // {
+        // new StructureViewer(ap.getStructureSelectionManager())
+        // .viewStructures(ap, pr, ap.av.collateForPDB(pr));
+        // }
+        // });
+        // }
       }
     }
     else
@@ -1502,7 +1502,17 @@ public class PopupMenu extends JPopupMenu
       }
     });
     jMenu1.setText(MessageManager.getString("label.group"));
-    structureMenu.setText(MessageManager.getString("label.structure"));
+    // structureMenu.setText(MessageManager.getString("label.structure"));
+    structureMenu.setText(MessageManager.getString("label.view_structure"));
+    structureMenu.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent actionEvent)
+      {
+        new StructureChooser(ap, sequence);
+      }
+    });
+
     viewStructureMenu.setText(MessageManager
             .getString("label.view_structure"));
     // colStructureMenu.setText("Colour By Structure");
@@ -1640,8 +1650,8 @@ public class PopupMenu extends JPopupMenu
     jMenu1.add(showColourText);
     jMenu1.add(outline);
     jMenu1.add(displayNonconserved);
-    structureMenu.add(pdbMenu);
-    structureMenu.add(viewStructureMenu);
+    // structureMenu.add(pdbMenu);
+    // structureMenu.add(viewStructureMenu);
     // structureMenu.add(colStructureMenu);
     noColourmenuItem.setText(MessageManager.getString("label.none"));
     noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
index 2f4ace3..56b4b87 100755 (executable)
@@ -390,7 +390,7 @@ public class SequenceFetcher extends JPanel implements Runnable
   private void pdbSourceAction()
   {
     databaseButt.setText(database.getSelectedItem());
-    new EBIFetchPanel(this);
+    new PDBFetchPanel(this);
     frame.dispose();
   }
 
diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java
new file mode 100644 (file)
index 0000000..07e36ec
--- /dev/null
@@ -0,0 +1,273 @@
+package jalview.gui;
+
+import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.jbgui.GStructureChooser;
+import jalview.util.MessageManager;
+import jalview.ws.dbsources.PDBRestClient;
+import jalview.ws.uimodel.PDBSearchRequest;
+import jalview.ws.uimodel.PDBSearchResponse;
+import jalview.ws.uimodel.PDBSummaryListModel;
+import jalview.ws.uimodel.PDBSummaryListModel.PDBDocField;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+@SuppressWarnings("serial")
+public class StructureChooser extends GStructureChooser
+{
+
+
+  private SequenceI sequence;
+
+
+  public StructureChooser(AlignmentPanel ap, final SequenceI sequence)
+  {
+    this.ap = ap;
+    this.sequence = sequence;
+    fetchStructures();
+  }
+
+  @Override
+  public void ok_ActionPerformed()
+  {
+    jListFoundStructures.setSelectedValue("op1x", true);
+  }
+
+  public void pdbFromFile_actionPerformed()
+  {
+    jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
+            jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
+    chooser.setFileView(new jalview.io.JalviewFileView());
+    chooser.setDialogTitle(MessageManager.formatMessage(
+            "label.select_pdb_file_for", new String[]
+            { sequence.getDisplayId(false) }));
+    chooser.setToolTipText(MessageManager.formatMessage(
+            "label.load_pdb_file_associate_with_sequence", new String[]
+            { sequence.getDisplayId(false) }));
+
+    int value = chooser.showOpenDialog(null);
+
+    if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
+    {
+      String choice = chooser.getSelectedFile().getPath();
+      jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
+      new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
+              jalview.io.AppletFormatAdapter.FILE, sequence, true,
+              Desktop.instance);
+    }
+
+  }
+
+  public void discoverPDB_actionPerformed()
+  {
+
+    final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
+    { sequence }
+            : ap.av.getSequenceSelection());
+    Thread discpdb = new Thread(new Runnable()
+    {
+      @Override
+      public void run()
+      {
+
+        new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
+                .fetchDBRefs(false);
+      }
+
+    });
+    discpdb.start();
+  }
+
+  // rpdbview.addActionListener(new ActionListener()
+  // {
+  //
+  // @Override
+  // public void actionPerformed(ActionEvent e)
+  // {
+  // new StructureViewer(ap.getStructureSelectionManager())
+  // .viewStructures(ap, pr, ap.av.collateForPDB(pr));
+  // }
+  // });
+
+  public void enterPDB_actionPerformed()
+  {
+    String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
+            MessageManager.getString("label.enter_pdb_id"),
+            MessageManager.getString("label.enter_pdb_id"),
+            JOptionPane.QUESTION_MESSAGE);
+    if (id != null && id.length() > 0)
+    {
+      PDBEntry entry = new PDBEntry();
+      entry.setId(id.toUpperCase());
+      sequence.getDatasetSequence().addPDBId(entry);
+    }
+  }
+
+  public static void main(String[] args)
+  {
+    SwingUtilities.invokeLater(new Runnable()
+    {
+      public void run()
+      {
+        new StructureChooser(null, null);
+      }
+    });
+  }
+
+  @SuppressWarnings("unchecked")
+  protected void populateFilterOptions()
+  {
+    filterOptions.addItem(new FilterOptions("- Filter Criteria -", "",
+            VIEWS_AUTO));
+    filterOptions.addItem(new FilterOptions("All", "all", VIEWS_AUTO));
+    filterOptions
+            .addItem(new FilterOptions("Best Coverage", "", VIEWS_AUTO));
+    filterOptions.addItem(new FilterOptions("Best Resolution", "",
+            VIEWS_AUTO));
+    filterOptions
+            .addItem(new FilterOptions("Best Quality", "", VIEWS_AUTO));
+    filterOptions.addItem(new FilterOptions("Enter PDB Id", "", VIEWS_ID));
+    filterOptions.addItem(new FilterOptions("From File", "", VIEWS_FILE));
+  }
+
+  protected void updateCurrentView()
+  {
+    String currentView = ((FilterOptions) filterOptions.getSelectedItem())
+            .getView();
+    switchableViewsLayout.show(switchableViewsPanel, currentView);
+  }
+
+  private void fetchStructures()
+  {
+    long startTime = System.currentTimeMillis();
+    final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
+    { sequence }
+            : ap.av.getSequenceSelection());
+    int foundStructures = 0;
+    PDBSearchRequest request = new PDBSearchRequest();
+    request.setAllowEmptySeq(false);
+    request.setResponseSize(500);
+    request.setSearchTarget("(text:");
+    List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
+    wantedFields.add(PDBDocField.MOLECULE_TYPE);
+    wantedFields.add(PDBDocField.PDB_ID);
+    wantedFields.add(PDBDocField.GENUS);
+    wantedFields.add(PDBDocField.GENE_NAME);
+    wantedFields.add(PDBDocField.TITLE);
+    request.setWantedFields(wantedFields);
+    
+    Collection<PDBSummaryListModel> searchSummaries = new HashSet<PDBSummaryListModel>();
+    // searchSummaries.
+    for (SequenceI seq : sequences)
+    {
+      // System.out.println("Selected : " + seq.getName());
+      request.setSearchTerm(buildQuery(seq) + ")");
+
+      PDBRestClient pdbRestCleint = new PDBRestClient();
+
+      PDBSearchResponse resultList = pdbRestCleint
+              .executeRequest(request);
+      if (resultList.getSearchSummary() != null
+              && !resultList.getSearchSummary().isEmpty())
+      {
+        searchSummaries.addAll(resultList.getSearchSummary());
+      }
+    }
+
+    foundStructures = searchSummaries.size();
+    if (searchSummaries != null)
+    {
+      jListFoundStructures.setModel(PDBSearchResponse
+              .getListModel(searchSummaries));
+    }
+
+    String totalTime = (System.currentTimeMillis() - startTime)
+            + " milli secs";
+    mainFrame.setTitle("Structure Chooser - " + foundStructures
+            + " Found (" + totalTime + ")");
+  }
+
+  private String buildQuery(SequenceI seq)
+  {
+    String query = seq.getName();
+    StringBuilder queryBuilder = new StringBuilder();
+    int count = 0;
+    if (seq.getDBRef() != null && seq.getDBRef().length != 0)
+    {
+      for (DBRefEntry dbRef : seq.getDBRef())
+      {
+        System.out.println("dbref : " + dbRef.getAccessionId());
+        queryBuilder.append("text:").append(dbRef.getAccessionId())
+                .append(" OR ");
+        ++count;
+        if (count > 10)
+        {
+          break;
+        }
+      }
+      // int beginIndex = queryBuilder. firstIndexOf("text");
+      int endIndex = queryBuilder.lastIndexOf(" OR ");
+      query = queryBuilder.toString().substring(5, endIndex);
+    }
+    System.out.println("------------> " + query);
+    return query;
+  }
+
+  public class FilterOptions
+  {
+    private String name;
+
+    private String value;
+
+    private String view;
+
+    public FilterOptions(String name, String value, String view)
+    {
+      this.name = name;
+      this.value = value;
+      this.view = view;
+    }
+
+    public String getName()
+    {
+      return name;
+    }
+
+    public void setName(String name)
+    {
+      this.name = name;
+    }
+
+    public String getValue()
+    {
+      return value;
+    }
+
+    public void setValue(String value)
+    {
+      this.value = value;
+    }
+
+    public String getView()
+    {
+      return view;
+    }
+
+    public void setView(String view)
+    {
+      this.view = view;
+    }
+
+    public String toString()
+    {
+      return this.name;
+    }
+  }
+}
similarity index 89%
rename from src/jalview/jbgui/GEBIFetchPanel.java
rename to src/jalview/jbgui/GPDBFetchPanel.java
index e00830b..18c33cd 100644 (file)
@@ -1,8 +1,8 @@
 package jalview.jbgui;
 
 import jalview.gui.Desktop;
+import jalview.gui.PDBFetchPanel.PDBSearchOptionList;
 import jalview.util.MessageManager;
-import jalview.ws.uimodel.PDBSearchOptionListModel;
 import jalview.ws.uimodel.PDBSummaryListModel;
 
 import java.awt.BorderLayout;
@@ -23,13 +23,13 @@ import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 
 @SuppressWarnings("serial")
-public abstract class GEBIFetchPanel extends JPanel
+public abstract class GPDBFetchPanel extends JPanel
 {
   protected String frameTitle = "PDB Sequence Fetcher";
 
   protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
 
-  protected JComboBox<PDBSearchOptionListModel> searchFeild = new JComboBox<PDBSearchOptionListModel>();
+  protected JComboBox<PDBSearchOptionList> searchTargetOptions = new JComboBox<PDBSearchOptionList>();
 
   protected JButton ok = new JButton();
 
@@ -54,7 +54,7 @@ public abstract class GEBIFetchPanel extends JPanel
 
 
 
-  public GEBIFetchPanel()
+  public GPDBFetchPanel()
   {
     try
     {
@@ -109,8 +109,8 @@ public abstract class GEBIFetchPanel extends JPanel
             .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     resultPanel.add(searchResultScroller);
 
-    searchFeild.setFont(new java.awt.Font("Verdana", 0, 12));
-    searchFeild.addActionListener(new ActionListener()
+    searchTargetOptions.setFont(new java.awt.Font("Verdana", 0, 12));
+    searchTargetOptions.addActionListener(new ActionListener()
     {
       @Override
       public void actionPerformed(ActionEvent e)
@@ -119,7 +119,7 @@ public abstract class GEBIFetchPanel extends JPanel
       }
     });
 
-    PDBSearchOptionListModel.populateCombo(searchFeild);
+    populateSearchOptionCombo();
 
     search.setFont(new java.awt.Font("Verdana", 0, 12));
     search.getDocument().addDocumentListener(new DocumentListener()
@@ -143,7 +143,7 @@ public abstract class GEBIFetchPanel extends JPanel
       }
     });
 
-    inputPanel.add(searchFeild);
+    inputPanel.add(searchTargetOptions);
     inputPanel.add(search);
 
 
@@ -165,4 +165,6 @@ public abstract class GEBIFetchPanel extends JPanel
 
   public abstract void cancelActionPerformed();
 
+  protected abstract void populateSearchOptionCombo();
+
 }
diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java
new file mode 100644 (file)
index 0000000..69b1fe6
--- /dev/null
@@ -0,0 +1,172 @@
+package jalview.jbgui;
+
+import jalview.gui.AlignmentPanel;
+import jalview.gui.Desktop;
+import jalview.util.MessageManager;
+
+import java.awt.BorderLayout;
+import java.awt.CardLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+
+@SuppressWarnings("serial")
+public abstract class GStructureChooser extends JPanel implements
+        ItemListener
+{
+  protected String frameTitle = "Structure Chooser";
+
+  protected JInternalFrame mainFrame = new JInternalFrame(frameTitle);
+
+
+
+  protected JComboBox filterOptions = new JComboBox();
+
+  protected AlignmentPanel ap;
+
+  protected JLabel resultLabel = new JLabel("View : ");
+
+  protected JButton ok = new JButton();
+
+  protected JButton cancel = new JButton();
+
+  protected JButton selectFile = new JButton();
+
+  protected JTextField search = new JTextField(16);
+
+  protected JPanel actionPanel = new JPanel();
+
+  protected JPanel filterPanel = new JPanel();
+
+  protected JPanel idInputPanel = new JPanel();
+
+  protected JPanel fileChooserPanel = new JPanel();
+
+  protected JPanel switchableViewsPanel = new JPanel(new CardLayout());
+
+  protected CardLayout switchableViewsLayout = (CardLayout) (switchableViewsPanel
+          .getLayout());
+
+  protected BorderLayout mainLayout = new BorderLayout();
+
+  protected BorderLayout idInputPanelLayout = new BorderLayout();
+
+  protected BorderLayout fileChooserPanelLayout = new BorderLayout();
+
+  protected JCheckBox rememberSettings = new JCheckBox("Don't ask me again");
+
+
+  protected static final String VIEWS_AUTO = "auto_view";
+
+  protected static final String VIEWS_FILE = "file_view";
+
+  protected static final String VIEWS_ID = "id_view";
+
+  protected JList jListFoundStructures = new JList();
+
+  protected JScrollPane foundStructuresScroller = new JScrollPane(
+          jListFoundStructures);
+
+  public GStructureChooser()
+  {
+    try
+    {
+      jbInit();
+      mainFrame.invalidate();
+      mainFrame.pack();
+    } catch (Exception e)
+    {
+      e.printStackTrace();
+    }
+  }
+
+  private void jbInit() throws Exception
+  {
+
+    ok.setFont(new java.awt.Font("Verdana", 0, 12));
+    ok.setText(MessageManager.getString("action.ok"));
+    ok.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        ok_ActionPerformed();
+      }
+    });
+    cancel.setFont(new java.awt.Font("Verdana", 0, 12));
+    cancel.setText(MessageManager.getString("action.cancel"));
+    cancel.addActionListener(new java.awt.event.ActionListener()
+    {
+      public void actionPerformed(ActionEvent e)
+      {
+        mainFrame.dispose();
+      }
+    });
+
+    jListFoundStructures
+            .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+    jListFoundStructures.setLayoutOrientation(JList.VERTICAL);
+    jListFoundStructures.setVisibleRowCount(-1);
+    foundStructuresScroller.setPreferredSize(new Dimension(500, 300));
+    foundStructuresScroller
+            .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+
+    actionPanel.add(rememberSettings);
+    actionPanel.add(ok);
+    actionPanel.add(cancel);
+
+    filterOptions.addItemListener(this);
+
+    filterPanel.add(resultLabel);
+    filterPanel.add(filterOptions);
+
+    idInputPanel.setLayout(new FlowLayout());
+    idInputPanel.add(search);
+
+
+    selectFile.setText("                Select File             ");
+    fileChooserPanel.setLayout(new FlowLayout());
+    fileChooserPanel.add(selectFile);
+
+    switchableViewsPanel.add(fileChooserPanel, VIEWS_FILE);
+    switchableViewsPanel.add(idInputPanel, VIEWS_ID);
+    switchableViewsPanel.add(foundStructuresScroller, VIEWS_AUTO);
+
+    
+    this.setLayout(mainLayout);
+    this.add(filterPanel, java.awt.BorderLayout.NORTH);
+    this.add(switchableViewsPanel, java.awt.BorderLayout.CENTER);
+    this.add(actionPanel, java.awt.BorderLayout.SOUTH);
+    populateFilterOptions();
+    updateCurrentView();
+    mainFrame.setVisible(true);
+    mainFrame.setContentPane(this);
+    mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+    Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
+  }
+
+  @Override
+  public void itemStateChanged(ItemEvent e)
+  {
+    updateCurrentView();
+  }
+
+  protected abstract void updateCurrentView();
+
+  protected abstract void ok_ActionPerformed();
+
+  protected abstract void populateFilterOptions();
+}
index 0c41d61..bdc507f 100644 (file)
@@ -1,11 +1,14 @@
 package jalview.ws.dbsources;
 
-import jalview.ws.uimodel.PDBSearchResultPojo;
+import jalview.ws.uimodel.PDBSearchRequest;
+import jalview.ws.uimodel.PDBSearchResponse;
 import jalview.ws.uimodel.PDBSummaryListModel;
+import jalview.ws.uimodel.PDBSummaryListModel.PDBDocField;
 
+import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
-import javax.swing.DefaultListModel;
 import javax.ws.rs.core.MediaType;
 
 import org.json.simple.JSONArray;
@@ -24,23 +27,44 @@ public class PDBRestClient
 {
   private String pdbSearchEndpoint = "http://wwwdev.ebi.ac.uk/pdbe/search/pdb/select?";
 
-
   public static void main(String[] args)
   {
-    new PDBRestClient().searchResult("pfam_name", "Lipoc*");
+    PDBSearchRequest request = new PDBSearchRequest();
+    request.setAllowEmptySeq(false);
+    request.setResponseSize(100);
+    request.setSearchTarget("pfam_name");
+    request.setSearchTerm("Lipoc*");
+    List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
+    wantedFields.add(PDBDocField.MOLECULE_TYPE);
+    wantedFields.add(PDBDocField.PDB_ID);
+    wantedFields.add(PDBDocField.GENUS);
+    wantedFields.add(PDBDocField.GENE_NAME);
+    wantedFields.add(PDBDocField.TITLE);
+    request.setWantedFields(wantedFields);
+    new PDBRestClient().executeRequest(request);
   }
 
-  private String executeRestSearch(String qParam,
-          String searchTerm)
+  public PDBSearchResponse executeRequest(PDBSearchRequest request)
   {
     ClientConfig clientConfig = new DefaultClientConfig();
     clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING,
             Boolean.TRUE);
     Client client = Client.create(clientConfig);
+
+    String query = request.getSearchTarget()
+            + request.getSearchTerm()
+            + ((request.isAllowEmptySeq()) ? ""
+                    : " AND molecule_sequence:['' TO *]");
+
+    String wantedFields = getFieldsAsCommaDelimitedString(request
+            .getWantedFields());
+
+    String responseSize = (request.getResponseSize() == 0) ? "200" : String
+            .valueOf(request.getResponseSize());
     WebResource webResource = client.resource(pdbSearchEndpoint)
-            .queryParam("wt", "json")
-.queryParam("rows", "100")
-            .queryParam("q", qParam + ":" + searchTerm);
+            .queryParam("wt", "json").queryParam("fl", wantedFields)
+            .queryParam("rows", responseSize)
+            .queryParam("q", query);
     ClientResponse clientResponse = webResource.accept(
             MediaType.APPLICATION_JSON).get(ClientResponse.class);
 
@@ -50,20 +74,20 @@ public class PDBRestClient
       throw new RuntimeException("Failed : HTTP error code : "
               + clientResponse.getStatus());
     }
-    return responseString;
+    // System.out.println("--------------> " + responseString);
+    return parseResponse(responseString, request.getWantedFields());
   }
 
-  public PDBSearchResultPojo searchResult(String qParam,
-          String searchTerm)
+  private PDBSearchResponse parseResponse(String jsonResponse,
+          List<PDBDocField> wantedFields)
   {
-    String jsonResponseString = executeRestSearch(qParam, searchTerm);
-    PDBSearchResultPojo searchResult = new PDBSearchResultPojo();
-    DefaultListModel<PDBSummaryListModel> result = null;
+    PDBSearchResponse searchResult = new PDBSearchResponse();
+    List<PDBSummaryListModel> result = null;
     try
     {
       JSONParser jsonParser = new JSONParser();
       JSONObject jsonObj = (JSONObject) jsonParser
-              .parse(jsonResponseString);
+.parse(jsonResponse);
 
       JSONObject pdbResponse = (JSONObject) jsonObj.get("response");
       String queryTime = ((JSONObject) jsonObj.get("responseHeader")).get(
@@ -72,18 +96,18 @@ public class PDBRestClient
               .valueOf(pdbResponse.get("numFound").toString());
       if (numFound > 0)
       {
-        result = new DefaultListModel<PDBSummaryListModel>();
+        result = new ArrayList<PDBSummaryListModel>();
         JSONArray docs = (JSONArray) pdbResponse.get("docs");
         for (Iterator<JSONObject> docIter = docs.iterator(); docIter
                 .hasNext();)
         {
           JSONObject doc = docIter.next();
-          if (doc.get("molecule_sequence") != null)
-          {
-            result.addElement(new PDBSummaryListModel(doc));
-          }
+          // if (doc.get("molecule_sequence") != null)
+          // {
+          result.add(new PDBSummaryListModel(doc, wantedFields));
+          // }
         }
-        searchResult.setItemFound(numFound);
+        searchResult.setItemsFound(numFound);
         searchResult.setResponseTime(queryTime);
         searchResult.setSearchSummary(result);
       }
@@ -95,4 +119,21 @@ public class PDBRestClient
     return searchResult;
   }
 
+  private String getFieldsAsCommaDelimitedString(List<PDBDocField> fields)
+  {
+    String result = "";
+    if (fields != null && !fields.isEmpty())
+    {
+      StringBuilder returnedFields = new StringBuilder();
+      for (PDBDocField field : fields)
+      {
+        returnedFields.append(",").append(field.getCode());
+      }
+      returnedFields.deleteCharAt(0);
+      result = returnedFields.toString();
+    }
+    return result;
+  }
+
+
 }
diff --git a/src/jalview/ws/uimodel/PDBSearchOptionListModel.java b/src/jalview/ws/uimodel/PDBSearchOptionListModel.java
deleted file mode 100644 (file)
index 093f038..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-package jalview.ws.uimodel;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.DefaultListModel;
-import javax.swing.JComboBox;
-
-@SuppressWarnings(
-{ "unchecked", "serial", "rawtypes" })
-public class PDBSearchOptionListModel extends DefaultListModel implements Comparable
-{
-  private String name;
-
-  private String code;
-
-  private boolean showInSummary;
-
-  private boolean searchFilter;
-
-  private FieldType type;
-
-  public enum FieldType
-  {
-    INT, STRING, BOOLEAN;
-  };
-
-  public PDBSearchOptionListModel(String name, String code, FieldType type)
-  {
-    this.name = name;
-    this.code = code;
-    this.type = type;
-  }
-
-  public String getName()
-  {
-    return name;
-  }
-
-  public void setName(String name)
-  {
-    this.name = name;
-  }
-
-  public String getCode()
-  {
-    return code;
-  }
-
-  public void setCode(String code)
-  {
-    this.code = code;
-  }
-
-  public boolean isShowInSummary()
-  {
-    return showInSummary;
-  }
-
-  public void setShowInSummary(boolean showInSummary)
-  {
-    this.showInSummary = showInSummary;
-  }
-
-  public boolean isSearchFilter()
-  {
-    return searchFilter;
-  }
-
-  public void setSearchFilter(boolean searchFilter)
-  {
-    this.searchFilter = searchFilter;
-  }
-
-  public FieldType getFieldType()
-  {
-    return type;
-  }
-
-  public void setFieldType(FieldType type)
-  {
-    this.type = type;
-  }
-
-  public String toString()
-  {
-    return name;
-  }
-
-  public PDBSearchOptionListModel()
-  {
-
-  }
-
-  public static void populateCombo(JComboBox searchItems)
-  {
-    List<PDBSearchOptionListModel> searchOptions = new ArrayList<PDBSearchOptionListModel>();
-    searchOptions.add(new PDBSearchOptionListModel("PDB ID", "pdb_id",
-            PDBSearchOptionListModel.FieldType.STRING));
-    searchOptions.add(new PDBSearchOptionListModel("PFAM Name", "pfam_name",
-            PDBSearchOptionListModel.FieldType.STRING));
-    searchOptions.add(new PDBSearchOptionListModel("ALL", "text",
-            PDBSearchOptionListModel.FieldType.STRING));
-    searchOptions.add(new PDBSearchOptionListModel("Molecule Type", "molecule_type",
-            PDBSearchOptionListModel.FieldType.STRING));
-    searchOptions.add(new PDBSearchOptionListModel("Title", "title",
-            PDBSearchOptionListModel.FieldType.STRING));
-    searchOptions.add(new PDBSearchOptionListModel("Molecule Name", "molecule_name",
-            PDBSearchOptionListModel.FieldType.STRING));
-    searchOptions.add(new PDBSearchOptionListModel("Tax ID", "tax_id",
-            PDBSearchOptionListModel.FieldType.STRING));
-    searchOptions.add(new PDBSearchOptionListModel("UniProt Accession",
-            "uniprot_accession", PDBSearchOptionListModel.FieldType.STRING));
-    searchOptions.add(new PDBSearchOptionListModel("Gene Name", "gene_name",
-            PDBSearchOptionListModel.FieldType.STRING));
-    searchOptions.add(new PDBSearchOptionListModel("Genus", "genus",
-            PDBSearchOptionListModel.FieldType.STRING));
-
-    java.util.Collections.sort(searchOptions);
-
-    for (PDBSearchOptionListModel pdbSO : searchOptions)
-    {
-      searchItems.addItem(pdbSO);
-    }
-  }
-
-  @Override
-  public int compareTo(Object o)
-  {
-    return this.name.compareTo(((PDBSearchOptionListModel) o).getName());
-  }
-
-}
diff --git a/src/jalview/ws/uimodel/PDBSearchRequest.java b/src/jalview/ws/uimodel/PDBSearchRequest.java
new file mode 100644 (file)
index 0000000..bb24cf5
--- /dev/null
@@ -0,0 +1,69 @@
+package jalview.ws.uimodel;
+
+import jalview.ws.uimodel.PDBSummaryListModel.PDBDocField;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PDBSearchRequest
+{
+  private String searchTarget;
+
+  private String searchTerm;
+
+  private boolean allowEmptySeq;
+
+  private int responseSize;
+
+  private List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
+
+  public String getSearchTarget()
+  {
+    return searchTarget;
+  }
+
+  public void setSearchTarget(String searchTarget)
+  {
+    this.searchTarget = searchTarget;
+  }
+
+  public String getSearchTerm()
+  {
+    return searchTerm;
+  }
+
+  public void setSearchTerm(String searchTerm)
+  {
+    this.searchTerm = searchTerm;
+  }
+
+  public boolean isAllowEmptySeq()
+  {
+    return allowEmptySeq;
+  }
+
+  public void setAllowEmptySeq(boolean allowEmptySeq)
+  {
+    this.allowEmptySeq = allowEmptySeq;
+  }
+
+  public int getResponseSize()
+  {
+    return responseSize;
+  }
+
+  public void setResponseSize(int responseSize)
+  {
+    this.responseSize = responseSize;
+  }
+
+  public List<PDBDocField> getWantedFields()
+  {
+    return wantedFields;
+  }
+
+  public void setWantedFields(List<PDBDocField> wantedFields)
+  {
+    this.wantedFields = wantedFields;
+  }
+}
diff --git a/src/jalview/ws/uimodel/PDBSearchResponse.java b/src/jalview/ws/uimodel/PDBSearchResponse.java
new file mode 100644 (file)
index 0000000..9f44102
--- /dev/null
@@ -0,0 +1,56 @@
+package jalview.ws.uimodel;
+
+import java.util.Collection;
+
+import javax.swing.DefaultListModel;
+
+public class PDBSearchResponse
+{
+  private int itemsFound;
+
+  private String responseTime;
+
+  private Collection<PDBSummaryListModel> searchSummary;
+
+  public int getItemsFound()
+  {
+    return itemsFound;
+  }
+
+  public void setItemsFound(int itemFound)
+  {
+    this.itemsFound = itemFound;
+  }
+
+  public String getResponseTime()
+  {
+    return responseTime;
+  }
+
+  public void setResponseTime(String responseTime)
+  {
+    this.responseTime = responseTime;
+  }
+
+  public Collection<PDBSummaryListModel> getSearchSummary()
+  {
+    return searchSummary;
+  }
+
+  public void setSearchSummary(Collection<PDBSummaryListModel> searchSummary)
+  {
+    this.searchSummary = searchSummary;
+  }
+
+  public static DefaultListModel<PDBSummaryListModel> getListModel(
+          Collection<PDBSummaryListModel> summariesList)
+  {
+    DefaultListModel<PDBSummaryListModel> defaultListModel = new DefaultListModel<PDBSummaryListModel>();
+    for (PDBSummaryListModel summaryList : summariesList)
+    {
+      defaultListModel.addElement(summaryList);
+    }
+    return defaultListModel;
+  }
+}
+
diff --git a/src/jalview/ws/uimodel/PDBSearchResultPojo.java b/src/jalview/ws/uimodel/PDBSearchResultPojo.java
deleted file mode 100644 (file)
index aef7820..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-package jalview.ws.uimodel;
-
-import javax.swing.DefaultListModel;
-
-public class PDBSearchResultPojo
-{
-  private int itemFound;
-
-  private String responseTime;
-
-  private DefaultListModel<PDBSummaryListModel> searchSummary;
-
-  public int getItemFound()
-  {
-    return itemFound;
-  }
-
-  public void setItemFound(int itemFound)
-  {
-    this.itemFound = itemFound;
-  }
-
-  public String getResponseTime()
-  {
-    return responseTime;
-  }
-
-  public void setResponseTime(String responseTime)
-  {
-    this.responseTime = responseTime;
-  }
-
-  public DefaultListModel<PDBSummaryListModel> getSearchSummary()
-  {
-    return searchSummary;
-  }
-
-  public void setSearchSummary(
-          DefaultListModel<PDBSummaryListModel> searchSummary)
-  {
-    this.searchSummary = searchSummary;
-  }
-}
index 37c0855..3a68e05 100644 (file)
@@ -1,5 +1,7 @@
 package jalview.ws.uimodel;
 
+import java.util.List;
+
 import javax.swing.DefaultListModel;
 
 import org.json.simple.JSONObject;
@@ -13,64 +15,53 @@ public class PDBSummaryListModel extends DefaultListModel
 
   private String summary;
 
-  private JSONObject rawJson;
-
   private int width = 480;
 
 
-  public PDBSummaryListModel(JSONObject doc)
+  public PDBSummaryListModel(JSONObject doc, List<PDBDocField> diplayFields)
   {
-    this.rawJson = doc;
-    StringBuilder summary = new StringBuilder();
-    if (doc.get("molecule_type") != null)
+    StringBuilder summaryBuilder = new StringBuilder();
+    
+    for (PDBDocField field : diplayFields)
     {
-      String moleculeType = doc.get("molecule_type").toString();
-      if (moleculeType.equalsIgnoreCase("protein"))
-      {
-        summary.append("<img src=\""
-                + getClass().getResource("/images/protein.png").toString()
-                + "\">");
-      }
-      if (moleculeType.equalsIgnoreCase("dna"))
+      if (field.equals(PDBDocField.MOLECULE_TYPE)
+              && doc.get("molecule_type") != null)
       {
-        summary.append("<img src=\""
-                + getClass().getResource("/images/dna.png").toString()
-                + "\">");
-      }
-      if (moleculeType.equalsIgnoreCase("rna"))
-      {
-        summary.append("<img src=\""
-                + getClass().getResource("/images/dna.png").toString()
-                + "\">");
-      }
-      if (moleculeType.equalsIgnoreCase("sugar"))
+        String moleculeType = doc.get("molecule_type").toString();
+        if (moleculeType.equalsIgnoreCase("protein"))
+        {
+          summaryBuilder.append("<img src=\""
+                  + getClass().getResource("/images/protein.png").toString()
+                  + "\">");
+        }
+        if (moleculeType.equalsIgnoreCase("dna"))
+        {
+          summaryBuilder.append("<img src=\""
+                  + getClass().getResource("/images/dna.png").toString()
+                  + "\">");
+        }
+        if (moleculeType.equalsIgnoreCase("rna"))
+        {
+          summaryBuilder.append("<img src=\""
+                  + getClass().getResource("/images/dna.png").toString()
+                  + "\">");
+        }
+        if (moleculeType.equalsIgnoreCase("sugar"))
+        {
+          summaryBuilder.append("<img src=\""
+                  + getClass().getResource("/images/sugar.png").toString()
+                  + "\">");
+        }
+      }else if (doc.get(field.getCode()) != null)
       {
-        summary.append("<img src=\""
-                + getClass().getResource("/images/sugar.png").toString()
-                + "\">");
+        summaryBuilder.append(field.getName()).append(": ")
+                .append(doc.get(field.getCode())).append(" | ");
       }
     }
-    this.pdbId = doc.get("pdb_id").toString();
-    summary.append("PDB ID: ").append(pdbId);
+    int endIndex = summaryBuilder.lastIndexOf(" | ");
+    String fSummary = summaryBuilder.toString().substring(0, endIndex);
+    this.summary = fSummary.trim();
 
-    
-    if (doc.get("molecule_name") != null)
-    {
-      summary.append(" | Molecule Name: ").append(doc.get("molecule_name"));
-    }
-    if (doc.get("gene_name") != null)
-    {
-      summary.append(" | Gene Name: ").append(doc.get("gene_name"));
-    }
-    if (doc.get("genus") != null)
-    {
-      summary.append(" | Genus: ").append(doc.get("genus"));
-    }
-    if (doc.get("title") != null)
-    {
-      summary.append(" | Title: ").append(doc.get("title"));
-    }
-    this.summary = summary.toString();
   }
 
   public String getPdbId()
@@ -93,15 +84,6 @@ public class PDBSummaryListModel extends DefaultListModel
     this.summary = summary;
   }
 
-  public JSONObject getRawJson()
-  {
-    return rawJson;
-  }
-
-  public void setRawJson(JSONObject rawJson)
-  {
-    this.rawJson = rawJson;
-  }
 
   public String toString()
   {
@@ -112,4 +94,51 @@ public class PDBSummaryListModel extends DefaultListModel
     html.append("</div></html>");
     return html.toString();
   }
+
+
+  public enum PDBDocField
+  {
+    PDB_ID("PDB Id", "pdb_id"), TITLE("Title", "title"), MOLECULE_NAME(
+            "Molecule", "molecule_name"), MOLECULE_TYPE("Molecule Type",
+            "molecule_type"), MOLECULE_SEQUENCE("Sequence",
+            "molecule_sequence"), UNIPROT_FEATURES("Uniprot Features",
+            "uniprot_features"), PFAM_ACCESSION("PFAM Accession",
+            "pfam_accession"), INTERPRO_ACCESSION("InterPro Accession",
+            "interpro_accession"), UNIPROT_ACCESSION("UniProt Accession",
+            "uniprot_accession"), R_FACTOR("R Factor", "r_factor"), RESOLUTION(
+            "Resolution", "resolution"), DATA_QUALITY("Data Quality",
+            "data_quality"), OVERALL_QUALITY("Overall Quality",
+            "overall_quality"), POLYMER_COUNT("Polymer Count",
+            "number_of_polymers"), PROTEIN_CHAIN_COUNT(
+            "Protein Chain Count", "number_of_protein_chains"), BOUND_MOLECULE_COUNT(
+            "Bound Molecule Count", "number_of_bound_molecules"), POLYMER_RESIDUE_COUNT(
+            "Polymer Residue Count", "number_of_polymer_residues"), UNIPROT_COVERAGE(
+            "UniProt Coverage", "uniprot_coverage"), GENUS("GENUS", "genus"), GENE_NAME(
+            "Gene Name", "gene_name");
+
+    private String name;
+
+    private String code;
+
+    PDBDocField(String name, String code)
+    {
+      this.name = name;
+      this.code = code;
+    }
+
+    public String getName()
+    {
+      return name;
+    }
+
+    public String getCode()
+    {
+      return code;
+    }
+
+    public String toString()
+    {
+      return name;
+    }
+  }
 }