From: tcofoegbu Date: Tue, 4 Aug 2015 09:49:26 +0000 (+0100) Subject: JAL-1821 updated the reference sequence column of structure chooser summary table... X-Git-Tag: Release_2_10_0~555 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c394157681d10261bd6f7883b19eaf88d6784609;p=jalview.git JAL-1821 updated the reference sequence column of structure chooser summary table to hold the actual object --- diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index c78ec22..916d785 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1302,5 +1302,9 @@ public class Sequence extends ASequence implements SequenceI return result; } + public String toString() + { + return getDisplayId(false); + } } diff --git a/src/jalview/gui/PDBSearchPanel.java b/src/jalview/gui/PDBSearchPanel.java index 964a7d8..06aa5df 100644 --- a/src/jalview/gui/PDBSearchPanel.java +++ b/src/jalview/gui/PDBSearchPanel.java @@ -98,6 +98,7 @@ public class PDBSearchPanel extends GPDBSearchPanel // System.out.println(">>>>>>>>>>>>>>>" + e.getMessage()); // JOptionPane.showMessageDialog(this, e.getMessage(), // "PDB Web-service Error", JOptionPane.ERROR_MESSAGE); + e.printStackTrace(); errorWarning.append(e.getMessage()); checkForErrors(); return; diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 3540cfc..3db26f3 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -153,7 +153,7 @@ public class StructureChooser extends GStructureChooser pdbRequest.setFieldToSearchBy("(text:"); pdbRequest.setWantedFields(wantedFields); pdbRequest.setSearchTerm(buildQuery(seq) + ")"); - pdbRequest.setAssociatedSequence(seq.getName()); + pdbRequest.setAssociatedSequence(seq); pdbRestCleint = new PDBRestClient(); PDBRestResponse resultList; try @@ -161,6 +161,7 @@ public class StructureChooser extends GStructureChooser resultList = pdbRestCleint.executeRequest(pdbRequest); } catch (Exception e) { + e.printStackTrace(); errors.add(e.getMessage()); continue; } @@ -336,7 +337,7 @@ public class StructureChooser extends GStructureChooser */ public static boolean isValidSeqName(String seqName) { - System.out.println("seqName : " + seqName); + // System.out.println("seqName : " + seqName); String ignoreList = "pdb,uniprot,swiss-prot"; if (seqName.length() < 3) { @@ -392,7 +393,7 @@ public class StructureChooser extends GStructureChooser !chk_invertFilter.isSelected()); pdbRequest.setSearchTerm(buildQuery(seq) + ")"); pdbRequest.setWantedFields(wantedFields); - pdbRequest.setAssociatedSequence(seq.getName()); + pdbRequest.setAssociatedSequence(seq); pdbRestCleint = new PDBRestClient(); PDBRestResponse resultList; try @@ -400,6 +401,7 @@ public class StructureChooser extends GStructureChooser resultList = pdbRestCleint.executeRequest(pdbRequest); } catch (Exception e) { + e.printStackTrace(); errors.add(e.getMessage()); continue; } @@ -675,16 +677,21 @@ public class StructureChooser extends GStructureChooser String currentView = selectedFilterOpt.getView(); if (currentView == VIEWS_FILTER) { - int pdbIdCol = PDBRestClient.getPDBIdColumIndex( - lastPdbRequest.getWantedFields(), true); + int pdbIdColIndex = tbl_summary.getColumn( + PDBRestClient.PDBDocField.PDB_ID.getName()).getModelIndex(); + int refSeqColIndex = tbl_summary.getColumn("Ref Sequence") + .getModelIndex(); int[] selectedRows = tbl_summary.getSelectedRows(); PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length]; int count = 0; + ArrayList selectedSeqsToView = new ArrayList(); for (int summaryRow : selectedRows) { - String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdCol) + String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdColIndex) .toString(); - + SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt( + summaryRow, refSeqColIndex); + selectedSeqsToView.add(selectedSeq); PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase()); if (pdbEntry == null) { @@ -694,8 +701,10 @@ public class StructureChooser extends GStructureChooser } pdbEntriesToView[count++] = pdbEntry; } + SequenceI[] selectedSeqs = selectedSeqsToView + .toArray(new SequenceI[selectedSeqsToView.size()]); launchStructureViewer(ap.getStructureSelectionManager(), - pdbEntriesToView, ap, selectedSequences); + pdbEntriesToView, ap, selectedSeqs); } else if(currentView == VIEWS_LOCAL_PDB){ int[] selectedRows = tbl_local_pdb.getSelectedRows(); @@ -832,7 +841,7 @@ public class StructureChooser extends GStructureChooser pdbRequest.setFieldToSearchBy("(pdb_id:"); pdbRequest.setWantedFields(wantedFields); pdbRequest.setSearchTerm(txt_search.getText() + ")"); - pdbRequest.setAssociatedSequence(selectedSequence.getName()); + pdbRequest.setAssociatedSequence(selectedSequence); pdbRestCleint = new PDBRestClient(); PDBRestResponse resultList; try diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index d0f2328..9c016f9 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -181,6 +181,7 @@ public abstract class GStructureChooser extends JPanel implements private void jbInit() throws Exception { tbl_summary.setAutoCreateRowSorter(true); + tbl_summary.getTableHeader().setReorderingAllowed(false); tbl_local_pdb.setAutoCreateRowSorter(true); tbl_local_pdb.addMouseListener(new MouseAdapter() { diff --git a/src/jalview/ws/dbsources/PDBRestClient.java b/src/jalview/ws/dbsources/PDBRestClient.java index 09c10ef..7e80126 100644 --- a/src/jalview/ws/dbsources/PDBRestClient.java +++ b/src/jalview/ws/dbsources/PDBRestClient.java @@ -59,7 +59,6 @@ public class PDBRestClient .getFieldToSortBy().trim().isEmpty()) ? "" : (pdbRestRequest .getFieldToSortBy() + (pdbRestRequest.isAscending() ? " asc" : " desc")); - // Build request parameters for the REST Request WebResource webResource = client.resource(PDB_SEARCH_ENDPOINT) .queryParam("wt", "json").queryParam("fl", wantedFields) diff --git a/src/jalview/ws/uimodel/PDBRestRequest.java b/src/jalview/ws/uimodel/PDBRestRequest.java index 58d7aeb..1bf8b35 100644 --- a/src/jalview/ws/uimodel/PDBRestRequest.java +++ b/src/jalview/ws/uimodel/PDBRestRequest.java @@ -22,6 +22,7 @@ package jalview.ws.uimodel; +import jalview.datamodel.SequenceI; import jalview.ws.dbsources.PDBRestClient.PDBDocField; import java.util.Collection; @@ -40,7 +41,7 @@ public class PDBRestRequest private String fieldToSortBy; - private String associatedSequence; + private SequenceI associatedSequence; private boolean allowEmptySequence; @@ -117,12 +118,12 @@ public class PDBRestRequest return isSortAscending; } - public String getAssociatedSequence() + public SequenceI getAssociatedSequence() { return associatedSequence; } - public void setAssociatedSequence(String associatedSequence) + public void setAssociatedSequence(SequenceI associatedSequence) { this.associatedSequence = associatedSequence; } diff --git a/src/jalview/ws/uimodel/PDBRestResponse.java b/src/jalview/ws/uimodel/PDBRestResponse.java index 0a33672..b82b997 100644 --- a/src/jalview/ws/uimodel/PDBRestResponse.java +++ b/src/jalview/ws/uimodel/PDBRestResponse.java @@ -21,6 +21,7 @@ package jalview.ws.uimodel; +import jalview.datamodel.SequenceI; import jalview.ws.dbsources.PDBRestClient.PDBDocField; import java.util.Collection; @@ -101,7 +102,7 @@ public class PDBRestResponse }; if (request.getAssociatedSequence() != null) { - tableModel.addColumn("Sequence"); // Create sequence column header if + tableModel.addColumn("Ref Sequence"); // Create sequence column header if // exists in the request } for (PDBDocField field : request.getWantedFields()) @@ -127,16 +128,16 @@ public class PDBRestResponse { private String pdbId; - private String[] summaryRowData; + private Object[] summaryRowData; - private String associatedSequence; + private SequenceI associatedSequence; public PDBResponseSummary(JSONObject pdbJsonDoc, PDBRestRequest request) { Collection diplayFields = request.getWantedFields(); - String associatedSeq = request.getAssociatedSequence(); + SequenceI associatedSeq = request.getAssociatedSequence(); int colCounter = 0; - summaryRowData = new String[(associatedSeq != null) ? diplayFields + summaryRowData = new Object[(associatedSeq != null) ? diplayFields .size() + 1 : diplayFields.size()]; if (associatedSeq != null) { @@ -172,7 +173,7 @@ public class PDBRestResponse this.pdbId = pdbId; } - public String[] getSummaryData() + public Object[] getSummaryData() { return summaryRowData; } @@ -189,9 +190,9 @@ public class PDBRestResponse public String toString() { StringBuilder summaryFieldValues = new StringBuilder(); - for (String summaryField : summaryRowData) + for (Object summaryField : summaryRowData) { - summaryFieldValues.append(summaryField).append("\t"); + summaryFieldValues.append(summaryField.toString()).append("\t"); } return summaryFieldValues.toString(); }