+ if (SiftsSettings.isMapWithSifts())
+ {
+ List<SequenceI> seqsWithoutSourceDBRef = new ArrayList<>();
+ int p = 0;
+ // TODO: skip PDBEntry:Sequence pairs where PDBEntry doesn't look like a
+ // real PDB ID. For moment, we can also safely do this if there is already
+ // a known mapping between the PDBEntry and the sequence.
+ for (SequenceI seq : sequences)
+ {
+ PDBEntry pdbe = pdbEntriesToView[p++];
+ if (pdbe != null && pdbe.getFile() != null)
+ {
+ StructureMapping[] smm = ssm.getMapping(pdbe.getFile());
+ if (smm != null && smm.length > 0)
+ {
+ for (StructureMapping sm : smm)
+ {
+ if (sm.getSequence() == seq)
+ {
+ continue;
+ }
+ }
+ }
+ }
+ if (seq.getPrimaryDBRefs().size() == 0)
+ {
+ seqsWithoutSourceDBRef.add(seq);
+ continue;
+ }
+ }
+ if (!seqsWithoutSourceDBRef.isEmpty())
+ {
+ int y = seqsWithoutSourceDBRef.size();
+ setProgressBar(MessageManager.formatMessage(
+ "status.fetching_dbrefs_for_sequences_without_valid_refs",
+ y), progressId);
+ SequenceI[] seqWithoutSrcDBRef = new SequenceI[y];
+ int x = 0;
+ for (SequenceI fSeq : seqsWithoutSourceDBRef)
+ {
+ seqWithoutSrcDBRef[x++] = fSeq;
+ }
+
+ DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef);
+ dbRefFetcher.fetchDBRefs(true);
+
+ setProgressBar("Fetch complete.", progressId); // todo i18n
+ }
+ }
+ if (pdbEntriesToView.length > 1)
+ {
+ setProgressBar(MessageManager.getString(
+ "status.fetching_3d_structures_for_selected_entries"),
+ progressId);
+ sViewer.viewStructures(pdbEntriesToView, sequences, alignPanel);
+ }
+ else
+ {
+ setProgressBar(MessageManager.formatMessage(
+ "status.fetching_3d_structures_for",
+ pdbEntriesToView[0].getId()),progressId);
+ sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel);
+ }
+ setProgressBar(null, progressId);
+ }
+
+ /**
+ * Populates the combo-box used in associating manually fetched structures to
+ * a unique sequence when more than one sequence selection is made.
+ */
+ @Override
+ public void populateCmbAssociateSeqOptions(
+ JComboBox<AssociateSeqOptions> cmb_assSeq,
+ JLabel lbl_associateSeq)
+ {
+ cmb_assSeq.removeAllItems();
+ cmb_assSeq.addItem(
+ new AssociateSeqOptions("-Select Associated Seq-", null));
+ lbl_associateSeq.setVisible(false);
+ if (selectedSequences.length > 1)
+ {
+ for (SequenceI seq : selectedSequences)
+ {
+ cmb_assSeq.addItem(new AssociateSeqOptions(seq));
+ }
+ }
+ else
+ {
+ String seqName = selectedSequence.getDisplayId(false);
+ seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39);
+ lbl_associateSeq.setText(seqName);
+ lbl_associateSeq.setVisible(true);
+ cmb_assSeq.setVisible(false);
+ }
+ }
+
+ public boolean isStructuresDiscovered()
+ {
+ return discoveredStructuresSet != null
+ && !discoveredStructuresSet.isEmpty();
+ }
+
+ public Collection<FTSData> getDiscoveredStructuresSet()
+ {
+ return discoveredStructuresSet;
+ }
+
+ @Override
+ protected void txt_search_ActionPerformed()
+ {
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+ errorWarning.setLength(0);
+ isValidPBDEntry = false;
+ if (txt_search.getText().length() > 0)
+ {
+ String searchTerm = txt_search.getText().toLowerCase();
+ searchTerm = searchTerm.split(":")[0];
+ // System.out.println(">>>>> search term : " + searchTerm);
+ List<FTSDataColumnI> wantedFields = new ArrayList<>();
+ FTSRestRequest pdbRequest = new FTSRestRequest();
+ pdbRequest.setAllowEmptySeq(false);
+ pdbRequest.setResponseSize(1);
+ pdbRequest.setFieldToSearchBy("(pdb_id:");
+ pdbRequest.setWantedFields(wantedFields);
+ pdbRequest.setSearchTerm(searchTerm + ")");
+ pdbRequest.setAssociatedSequence(selectedSequence);
+ pdbRestCleint = PDBFTSRestClient.getInstance();
+ wantedFields.add(pdbRestCleint.getPrimaryKeyColumn());
+ FTSRestResponse resultList;
+ try
+ {
+ resultList = pdbRestCleint.executeRequest(pdbRequest);
+ } catch (Exception e)
+ {
+ errorWarning.append(e.getMessage());
+ return;
+ } finally
+ {
+ validateSelections();
+ }
+ if (resultList.getSearchSummary() != null
+ && resultList.getSearchSummary().size() > 0)
+ {
+ isValidPBDEntry = true;
+ }
+ }
+ validateSelections();
+ }
+ }.start();
+ }
+
+ @Override
+ public void tabRefresh()
+ {
+ if (selectedSequences != null)
+ {
+ Thread refreshThread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ fetchStructuresMetaData();
+ filterResultSet(
+ ((FilterOption) cmb_filterOption.getSelectedItem())
+ .getValue());
+ }
+ });
+ refreshThread.start();
+ }
+ }
+
+ public class PDBEntryTableModel extends AbstractTableModel
+ {
+ String[] columns = { "Ref Sequence", "PDB Id", "Chain", "Type",
+ "File" };
+
+ private List<CachedPDB> pdbEntries;
+
+ public PDBEntryTableModel(List<CachedPDB> pdbEntries)
+ {
+ this.pdbEntries = new ArrayList<>(pdbEntries);
+ }
+
+ @Override
+ public String getColumnName(int columnIndex)