package jalview.gui;
import jalview.jbgui.GPDBSearchPanel;
+import jalview.jbgui.PDBDocFieldPreferences;
import jalview.util.MessageManager;
import jalview.ws.dbsources.PDBRestClient;
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
import jalview.ws.uimodel.PDBRestRequest;
import jalview.ws.uimodel.PDBRestResponse;
-import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import javax.swing.DefaultListModel;
-
@SuppressWarnings("serial")
public class PDBSearchPanel extends GPDBSearchPanel
{
private IProgressIndicator progressIdicator;
+ private Collection<PDBDocField> wantedFields;
+
public PDBSearchPanel(SequenceFetcher seqFetcher)
{
this.seqFetcher = seqFetcher;
}
+ /**
+ * Action performed when an input is detected on txt_search field.
+ */
@Override
public void txt_search_ActionPerformed()
{
boolean allowEmptySequence = false;
- lst_searchResult.setModel(new DefaultListModel<PDBResponseSummary>());
mainFrame.setTitle(MessageManager
.getString("label.pdb_sequence_getcher"));
if (txt_search.getText().trim().length() > 0)
String searchTarget = ((PDBDocField) cmb_searchTarget
.getSelectedItem()).getCode();
- 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);
- // wantedFields.add(PDBDocField.RESOLUTION);
- // wantedFields.add(PDBDocField.EXPERIMENTAL_METHOD);
+ wantedFields = PDBDocFieldPreferences
+ .getSearchSummaryFields();
PDBRestRequest request = new PDBRestRequest();
request.setAllowEmptySeq(allowEmptySequence);
PDBRestResponse resultList = pdbRestCleint.executeRequest(request);
if (resultList.getSearchSummary() != null)
{
- lst_searchResult.setModel(PDBRestResponse
- .getListModel(resultList.getSearchSummary()));
+ tbl_summary.setModel(PDBRestResponse.getTableModel(request,
+ resultList.getSearchSummary()));
}
long endTime = System.currentTimeMillis();
{
mainFrame.dispose();
StringBuilder selectedIds = new StringBuilder();
- for (PDBResponseSummary dataSelected : lst_searchResult
- .getSelectedValuesList())
+ int pdbIdCol = PDBRestClient.getPDBIdColumIndex(wantedFields, false);
+ int[] selectedRows = tbl_summary.getSelectedRows();
+ for (int summaryRow : selectedRows)
{
- selectedIds.append(";").append(dataSelected.getPdbId());
+ String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdCol)
+ .toString();
+ selectedIds.append(";").append(pdbIdStr);
}
+
String ids = selectedIds.deleteCharAt(0).toString();
seqFetcher.textArea.setText(ids);
Thread worker = new Thread(seqFetcher);
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.jbgui.GStructureChooser;
+import jalview.jbgui.PDBDocFieldPreferences;
import jalview.util.MessageManager;
import jalview.ws.dbsources.PDBRestClient;
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
public void fetchStructuresMetaData()
{
long startTime = System.currentTimeMillis();
- 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);
+ Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
+ .getStructureSummaryFields();
+
pdbRequest = new PDBRestRequest();
pdbRequest.setAllowEmptySeq(false);
pdbRequest.setResponseSize(500);
filterThread.start();
}
- /**
- * Determines the column index for the pdb id in the summary table. The pdb id
- * serves as a unique identifier for a given row in the summary table
- *
- * @param wantedFeilds
- * the available table columns in no particular order
- * @return the pdb id field column index
- */
- public static int getPDBIdColumIndex(Collection<PDBDocField> wantedFeilds)
- {
- int pdbFeildIndex = 1;
- for (PDBDocField feild : wantedFeilds)
- {
- if (feild.equals(PDBDocField.PDB_ID))
- {
- break;
- }
- ++pdbFeildIndex;
- }
- return pdbFeildIndex;
- }
+
/**
* Handles action event for btn_pdbFromFile
String currentView = selectedFilterOpt.getView();
if (currentView == VIEWS_FILTER)
{
- int pdbIdCol = getPDBIdColumIndex(pdbRequest.getWantedFields());
+ int pdbIdCol = PDBRestClient.getPDBIdColumIndex(
+ pdbRequest.getWantedFields(), true);
int[] selectedRows = tbl_summary.getSelectedRows();
PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
int count = 0;
import jalview.gui.Desktop;
import jalview.util.MessageManager;
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
-import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
-import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
+import javax.swing.JTable;
import javax.swing.JTextField;
-import javax.swing.ListSelectionModel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
protected JTextField txt_search = new JTextField(20);
- protected JList<PDBResponseSummary> lst_searchResult = new JList<PDBResponseSummary>();
+ // protected JList<PDBResponseSummary> lst_searchResult = new
+ // JList<PDBResponseSummary>();
+
+ // protected JScrollPane scrl_searchResult = new JScrollPane(
+ // lst_searchResult);
+
+ protected JTable tbl_summary = new JTable();
protected JScrollPane scrl_searchResult = new JScrollPane(
- lst_searchResult);
+tbl_summary);
private JPanel pnl_actions = new JPanel();
pnl_actions.add(btn_ok);
pnl_actions.add(btn_cancel);
- lst_searchResult
- .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- lst_searchResult.setLayoutOrientation(JList.VERTICAL);
- lst_searchResult.setVisibleRowCount(-1);
+ // lst_searchResult
+ // .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ // lst_searchResult.setLayoutOrientation(JList.VERTICAL);
+ // lst_searchResult.setVisibleRowCount(-1);
+
scrl_searchResult.setPreferredSize(new Dimension(500, 300));
scrl_searchResult
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
protected JTextField chimeraPath = new JTextField();
+
/*
* Colours tab components
*/
.getString("label.structure_options")));
structureTab.setLayout(null);
final int width = 400;
- final int height = 23;
- final int lineSpacing = 30;
+ final int height = 22;
+ final int lineSpacing = 25;
int ypos = 30;
structFromPdb.setFont(verdana11);
});
structureTab.add(chimeraPath);
+ ypos += lineSpacing;
+ // scrl_pdbDocFieldConfig.setPreferredSize(new Dimension(450, 100));
+ // scrl_pdbDocFieldConfig
+ // .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ // scrl_pdbDocFieldConfig.setBounds();
+ PDBDocFieldPreferences docFieldPref = new PDBDocFieldPreferences(
+ new Rectangle(10, ypos + 5, 450, 120));
+ structureTab.add(docFieldPref);
+
+
+
+
return structureTab;
}
+
/**
* Action on choosing a structure viewer from combobox options.
*
--- /dev/null
+package jalview.jbgui;
+
+import jalview.ws.dbsources.PDBRestClient.PDBDocField;
+
+import java.awt.Rectangle;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.table.AbstractTableModel;
+
+@SuppressWarnings("serial")
+public class PDBDocFieldPreferences extends JScrollPane
+{
+
+ protected JTable tbl_pdbDocFieldConfig = new JTable();
+
+ protected JScrollPane scrl_pdbDocFieldConfig = new JScrollPane(
+ tbl_pdbDocFieldConfig);
+
+ private HashMap<String, PDBDocField> map = new HashMap<String, PDBDocField>();
+
+ private static Collection<PDBDocField> searchSummaryFields = new HashSet<PDBDocField>();
+
+ private static Collection<PDBDocField> structureSummaryFields = new HashSet<PDBDocField>();
+
+ static
+ {
+ searchSummaryFields.add(PDBDocField.PDB_ID);
+ searchSummaryFields.add(PDBDocField.TITLE);
+ structureSummaryFields.add(PDBDocField.PDB_ID);
+ structureSummaryFields.add(PDBDocField.TITLE);
+ }
+
+ public PDBDocFieldPreferences(Rectangle position)
+ {
+ this.setBounds(position);
+ this.getViewport().add(tbl_pdbDocFieldConfig);
+
+ Object[][] data = new Object[PDBDocField.values().length - 1][3];
+ int x = 0;
+ for (PDBDocField field : PDBDocField.values())
+ {
+ if (field.getName().equalsIgnoreCase("all"))
+ {
+ continue;
+ }
+
+ data[x++] = new Object[]
+ { field.getName(), searchSummaryFields.contains(field),
+ structureSummaryFields.contains(field) };
+ map.put(field.getName(), field);
+ }
+
+ PDBFieldTableModel model = new PDBFieldTableModel(data);
+ tbl_pdbDocFieldConfig.setModel(model);
+ }
+
+ public static Collection<PDBDocField> getSearchSummaryFields()
+ {
+ return searchSummaryFields;
+ }
+
+ public static void setSearchSummaryFields(
+ Collection<PDBDocField> searchSummaryFields)
+ {
+ PDBDocFieldPreferences.searchSummaryFields = searchSummaryFields;
+ }
+
+ public static Collection<PDBDocField> getStructureSummaryFields()
+ {
+ return structureSummaryFields;
+ }
+
+ public static void setStructureSummaryFields(
+ Collection<PDBDocField> structureSummaryFields)
+ {
+ PDBDocFieldPreferences.structureSummaryFields = structureSummaryFields;
+ }
+
+ class PDBFieldTableModel extends AbstractTableModel
+ {
+
+ public PDBFieldTableModel(Object[][] data)
+ {
+ this.data = data;
+ }
+
+ private String[] columnNames = new String[]
+ { "PDB Feild", "Show in search summary",
+ "Show in structure chooser summary" };
+
+ private Object[][] data;
+
+ public int getColumnCount()
+ {
+ return columnNames.length;
+ }
+
+ public int getRowCount()
+ {
+ return data.length;
+ }
+
+ public String getColumnName(int col)
+ {
+ return columnNames[col];
+ }
+
+ public Object getValueAt(int row, int col)
+ {
+ return data[row][col];
+ }
+
+ /*
+ * JTable uses this method to determine the default renderer/ editor for
+ * each cell. If we didn't implement this method, then the last column would
+ * contain text ("true"/"false"), rather than a check box.
+ */
+ public Class getColumnClass(int c)
+ {
+ return getValueAt(0, c).getClass();
+ }
+
+ /*
+ * Don't need to implement this method unless your table's editable.
+ */
+ public boolean isCellEditable(int row, int col)
+ {
+ // Note that the data/cell address is constant,
+ // no matter where the cell appears onscreen.
+ return col == 1 || col == 2;
+
+ }
+
+ /*
+ * Don't need to implement this method unless your table's data can change.
+ */
+ public void setValueAt(Object value, int row, int col)
+ {
+ data[row][col] = value;
+ fireTableCellUpdated(row, col);
+
+ String name = getValueAt(row, 0).toString();
+ boolean selected = ((Boolean) value).booleanValue();
+
+ PDBDocField pdbField = map.get(name);
+
+ if (col == 1)
+ {
+ if (searchSummaryFields.contains(pdbField) && !selected)
+ {
+ searchSummaryFields.remove(pdbField);
+ }
+
+ if (!searchSummaryFields.contains(pdbField) && selected)
+ {
+ searchSummaryFields.add(pdbField);
+ }
+ }
+ else if (col == 2)
+ {
+ if (structureSummaryFields.contains(pdbField) && !selected)
+ {
+ structureSummaryFields.remove(pdbField);
+ }
+
+ if (!structureSummaryFields.contains(pdbField) && selected)
+ {
+ structureSummaryFields.add(pdbField);
+ }
+ }
+
+ }
+ }
+}
import jalview.ws.uimodel.PDBRestResponse.PDBResponseSummary;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
* @return
*/
public static String getPDBDocFieldsAsCommaDelimitedString(
- List<PDBDocField> pdbDocfields)
+ Collection<PDBDocField> pdbDocfields)
{
String result = "";
if (pdbDocfields != null && !pdbDocfields.isEmpty())
return result;
}
+ /**
+ * Determines the column index for the pdb id in the summary table. The pdb id
+ * serves as a unique identifier for a given row in the summary table
+ *
+ * @param wantedFeilds
+ * the available table columns in no particular order
+ * @return the pdb id field column index
+ */
+ public static int getPDBIdColumIndex(
+ Collection<PDBDocField> wantedFeilds, boolean hasRefSeq)
+ {
+ int pdbFeildIndex = hasRefSeq ? 1 : 0;
+ for (PDBDocField feild : wantedFeilds)
+ {
+ if (feild.equals(PDBDocField.PDB_ID))
+ {
+ break;
+ }
+ ++pdbFeildIndex;
+ }
+ return pdbFeildIndex;
+ }
/**
* Represents the fields retrievable from a PDB Document response
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"), EXPERIMENTAL_METHOD(
- "Experimental Method", "experimental_method"), ALL("ALL",
+ "molecule_sequence"), PFAM_ACCESSION("PFAM Accession",
+ "pfam_accession"), PFAM_NAME("PFAM Name", "pfam_name"), INTERPRO_NAME(
+ "InterPro Name", "interpro_name"), INTERPRO_ACCESSION(
+ "InterPro Accession", "interpro_accession"), UNIPROT_ID(
+ "UniProt Id", "uniprot_id"), UNIPROT_ACCESSION(
+ "UniProt Accession", "uniprot_accession"), UNIPROT_COVERAGE(
+ "UniProt Coverage", "uniprot_coverage"), UNIPROT_FEATURES(
+ "Uniprot Features", "uniprot_features"), R_FACTOR("R Factor",
+ "r_factor"), RESOLUTION("Resolution", "resolution"), DATA_QUALITY(
+ "Data Quality", "data_quality"), OVERALL_QUALITY(
+ "Overall Quality", "overall_quality"), POLYMER_COUNT(
+ "Number of Polymers", "number_of_polymers"), PROTEIN_CHAIN_COUNT(
+ "Number of Protein Chains", "number_of_protein_chains"), BOUND_MOLECULE_COUNT(
+ "Number of Bound Molecule", "number_of_bound_molecules"), POLYMER_RESIDUE_COUNT(
+ "Number of Polymer Residue", "number_of_polymer_residues"), GENUS(
+ "GENUS", "genus"), GENE_NAME("Gene Name", "gene_name"), EXPERIMENTAL_METHOD(
+ "Experimental Method", "experimental_method"), GO_ID("GO Id",
+ "go_id"), ASSEMBLY_ID("Assembly Id", "assembly_form"), ASSEMBLY_FORM(
+ "Assembly Form", "assembly_id"), ASSEMBLY_TYPE("Assembly Type",
+ "assembly_type"), SPACE_GROUP("Space Group", "spacegroup"), CATH_CODE(
+ "Cath Code", "cath_code"), TAX_ID("Tax Id", "tax_id"), TAX_QUERY(
+ "Tax Query", "tax_query"), INTERACTING_ENTRY_ID(
+ "Interacting Entry Id", "interacting_entry_id"), INTERACTING_ENTITY_ID(
+ "Interacting Entity Id", "interacting_entity_id"), INTERACTING_MOLECULES(
+ "Interacting Molecules", "interacting_molecules"), PUBMED_ID(
+ "Pubmed Id", "pubmed_id"), STATUS("Status", "status"), MODEL_QUALITY(
+ "Model Quality", "model_quality"), PIVOT_RESOLUTION(
+ "Pivot Resolution", "pivot_resolution"), DATA_REDUCTION_SOFTWARE(
+ "Data reduction software", "data_reduction_software"), MAX_OBSERVED_RES(
+ "Max observed residues", "max_observed_residues"), ORG_SCI_NAME(
+ "Organism scientific name", "organism_scientific_name"), SUPER_KINGDOM(
+ "Super kingdom", "superkingdom"), RANK("Rank", "rank"), CRYSTALLISATION_PH(
+ "Crystallisation Ph", "crystallisation_ph"), BIO_FUNCTION(
+ "Biological Function", "biological_function"), BIO_PROCESS(
+ "Biological Process", "biological_process"), BIO_CELL_COMP(
+ "Biological Cell Component", "biological_cell_component"), COMPOUND_NAME(
+ "Compound Name", "compound_name"), COMPOUND_ID("Compound Id",
+ "compound_id"), COMPOUND_WEIGHT("Compound Weight",
+ "compound_weight"), COMP_SYS_NAME("Compound Systematic Name",
+ "compound_systematic_name"), INTERACTING_LIG(
+ "Interacting Ligands", "interacting_ligands"), JOURNAL(
+ "Journal", "journal"), ALL_AUTHORS("All Authors", "all_authors"), EXPERIMENTAL_DATA_AVAILABLE(
+ "Experiment Data Available", "experiment_data_available"), DIFFRACTION_PROTOCOL(
+ "Diffraction Protocol", "diffraction_protocol"), REFINEMENT_SOFTWARE(
+ "Refinement Software", "refinement_software"), STRUCTURE_DETERMINATION_METHOD(
+ "Structure Determination Method",
+ "structure_determination_method"), SYNCHROTON_SITE(
+ "Synchrotron Site", "synchrotron_site"), SAMPLE_PREP_METHOD(
+ "Sample Preparation Method", "sample_preparation_method"), ENTRY_AUTHORS(
+ "Entry Authors", "entry_authors"), CITATION_TITLE(
+ "Citation Title", "citation_title"), STRUCTURE_SOLUTION_SOFTWARE(
+ "Structure Solution Software", "structure_solution_software"), ENTRY_ENTITY(
+ "Entry Entity", "entry_entity"), R_FREE("R Free", "r_free"), NO_OF_POLYMER_ENTITIES(
+ "Number of Polymer Entities", "number_of_polymer_entities"), NO_OF_BOUND_ENTITIES(
+ "Number of Bound Entities", "number_of_bound_entities"), CRYSTALLISATION_RESERVOIR(
+ "Crystallisation Reservoir", "crystallisation_reservoir"), DATA_SCALING_SW(
+ "Data Scalling Software", "data_scaling_software"), DETECTOR(
+ "Detector", "detector"), DETECTOR_TYPE("Detector Type",
+ "detector_type"), MODIFIED_RESIDUE_FLAG(
+ "Modified Residue Flag", "modified_residue_flag"), NUMBER_OF_COPIES(
+ "Number of Copies", "number_of_copies"), STRUCT_ASYM_ID(
+ "Struc Asym Id", "struct_asym_id"), HOMOLOGUS_PDB_ENTITY_ID(
+ "Homologus PDB Entity Id", "homologus_pdb_entity_id"), MOLECULE_SYNONYM(
+ "Molecule Synonym", "molecule_synonym"), DEPOSITION_SITE(
+ "Deposition Site", "deposition_site"), SYNCHROTRON_BEAMLINE(
+ "Synchrotron Beamline", "synchrotron_beamline"), ENTITY_ID(
+ "Entity Id", "entity_id"), BEAM_SOURCE_NAME("Beam Source Name",
+ "beam_source_name"), PROCESSING_SITE("Processing Site",
+ "processing_site"), ENTITY_WEIGHT("Entity Weight",
+ "entity_weight"), VERSION("Version", "_version_"), ALL("ALL",
"text");
private String name;
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
/**
* Represents the PDB request to be consumed by the PDBRestClient
private boolean isSortAscending;
- private List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
+ private Collection<PDBDocField> wantedFields;// = new
+ // Collection<PDBDocField>();
public String getFieldToSearchBy()
{
this.responseSize = responseSize;
}
- public List<PDBDocField> getWantedFields()
+ public Collection<PDBDocField> getWantedFields()
{
return wantedFields;
}
- public void setWantedFields(List<PDBDocField> wantedFields)
+ public void setWantedFields(Collection<PDBDocField> wantedFields)
{
this.wantedFields = wantedFields;
}
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
import java.util.Collection;
-import java.util.List;
import java.util.Objects;
import javax.swing.DefaultListModel;
public PDBResponseSummary(JSONObject doc, PDBRestRequest request)
{
- StringBuilder summaryBuilder = new StringBuilder();
- List<PDBDocField> diplayFields = request.getWantedFields();
+ StringBuilder summaryBuilder = new StringBuilder();
+ Collection<PDBDocField> diplayFields = request.getWantedFields();
String associatedSeq = request.getAssociatedSequence();
int colCounter = 0;
summaryData = new String[(associatedSeq != null) ? diplayFields
for (PDBDocField field : diplayFields)
{
- if (field.equals(PDBDocField.MOLECULE_TYPE)
- && doc.get(PDBDocField.MOLECULE_TYPE.getCode()) != null)
- {
- String moleculeType = doc
- .get(PDBDocField.MOLECULE_TYPE.getCode()).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() + "\">");
- }
- summaryData[colCounter++] = moleculeType;
- }
- else if (field.equals(PDBDocField.PDB_ID)
+ if (field.equals(PDBDocField.PDB_ID)
&& doc.get(PDBDocField.PDB_ID.getCode()) != null)
{
this.pdbId = doc.get(PDBDocField.PDB_ID.getCode()).toString();
- summaryBuilder.append(this.pdbId).append(" | ");
summaryData[colCounter++] = this.pdbId;
}
- else if (doc.get(field.getCode()) != null)
+ else
{
- summaryBuilder.append(field.getName()).append(": ")
- .append(doc.get(field.getCode())).append(" | ");
- summaryData[colCounter++] = doc.get(field.getCode()).toString();
+ String value = (doc.get(field.getCode()) == null) ? "" : doc.get(
+ field.getCode()).toString();
+ summaryBuilder.append(field.getName()).append(": ").append(value)
+ .append(" | ");
+ summaryData[colCounter++] = value;
}
}
- int endIndex = summaryBuilder.lastIndexOf(" | ");
- String fSummary = summaryBuilder.toString().substring(0, endIndex);
- this.concatenatedSummaryData = fSummary.trim();
+ this.concatenatedSummaryData = summaryBuilder.toString();
summaryBuilder = null;
}
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
-import jalview.ws.dbsources.PDBRestClient.PDBDocField;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Vector;
import org.junit.After;
seq = null;
}
- @Test
- public void getPDBIdColumIndexTest()
- {
- List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
- wantedFields.add(PDBDocField.MOLECULE_TYPE);
- wantedFields.add(PDBDocField.GENUS);
- wantedFields.add(PDBDocField.GENE_NAME);
- wantedFields.add(PDBDocField.TITLE);
- wantedFields.add(PDBDocField.PDB_ID);
- assertEquals(5, StructureChooser.getPDBIdColumIndex(wantedFields));
- }
+
@Test
public void buildQueryTest()
assertTrue(response.getSearchSummary().size() == 14);
}
+ @Test
+ public void getPDBIdColumIndexTest()
+ {
+ List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
+ wantedFields.add(PDBDocField.MOLECULE_TYPE);
+ wantedFields.add(PDBDocField.GENUS);
+ wantedFields.add(PDBDocField.GENE_NAME);
+ wantedFields.add(PDBDocField.TITLE);
+ wantedFields.add(PDBDocField.PDB_ID);
+ assertEquals(5, PDBRestClient.getPDBIdColumIndex(wantedFields, true));
+ assertEquals(4, PDBRestClient.getPDBIdColumIndex(wantedFields, false));
+ }
+
public String readJsonStringFromFile(String filePath) throws IOException
{
String fileContent;