{
if (sq.getDatasetSequence() != null)
{
- sq.getDatasetSequence().getPDBId().clear();
+ sq.getDatasetSequence().getAllPDBEntries().clear();
}
else
{
- sq.getPDBId().clear();
+ sq.getAllPDBEntries().clear();
}
}
replaceAndUpdateChains(prot, al, AlignSeq.PEP, false);
{
if (sq.getDatasetSequence() != null)
{
- if (sq.getDatasetSequence().getPDBId() != null)
+ if (sq.getDatasetSequence().getAllPDBEntries() != null)
{
- sq.getDatasetSequence().getPDBId().clear();
+ sq.getDatasetSequence().getAllPDBEntries().clear();
}
}
else
{
- if (sq.getPDBId() != null)
+ if (sq.getAllPDBEntries() != null)
{
- sq.getPDBId().clear();
+ sq.getAllPDBEntries().clear();
}
}
}
}
}
sqinfo.put("SeqFeatures", sfeat);
- sqinfo.put("PdbId", (seq.getPDBId() != null) ? seq.getPDBId()
+ sqinfo.put("PdbId", (seq.getAllPDBEntries() != null) ? seq.getAllPDBEntries()
: new Vector<PDBEntry>());
sqinfo.put("datasetSequence",
(seq.getDatasetSequence() != null) ? seq.getDatasetSequence()
void addPDB()
{
- if (seq.getPDBId() != null)
+ if (seq.getAllPDBEntries() != null)
{
- PDBEntry entry = seq.getPDBId().firstElement();
+ PDBEntry entry = seq.getAllPDBEntries().firstElement();
if (ap.av.applet.jmolAvailable)
{
boolean needtoadd = false;
if (toaddpdb != null)
{
- Vector pdbe = toaddpdb.getPDBId();
+ Vector pdbe = toaddpdb.getAllPDBEntries();
PDBEntry pdbentry = null;
if (pdbe != null && pdbe.size() > 0)
{
SequenceI[] sq = ap.av.getAlignment().getSequencesArray();
for (int s = 0; s < sq.length; s++)
{
- Vector<PDBEntry> pdbids = sq[s].getPDBId();
+ Vector<PDBEntry> pdbids = sq[s].getAllPDBEntries();
if (pdbids != null)
{
for (int pe = 0, peSize = pdbids.size(); pe < peSize; pe++)
this.chainCode = chainCode;
}
+ public String toString()
+ {
+ return id;
+ }
}
}
}
}
- if (seq.getPDBId() != null)
+ if (seq.getAllPDBEntries() != null)
{
- Vector ids = seq.getPDBId();
+ Vector ids = seq.getAllPDBEntries();
Enumeration e = ids.elements();
while (e.hasMoreElements())
{
* @return DOCUMENT ME!
*/
@Override
- public Vector<PDBEntry> getPDBId()
+ public Vector<PDBEntry> getAllPDBEntries()
{
return pdbIds;
}
// move database references onto dataset sequence
datasetSequence.setDBRef(getDBRef());
setDBRef(null);
- datasetSequence.setPDBId(getPDBId());
+ datasetSequence.setPDBId(getAllPDBEntries());
setPDBId(null);
datasetSequence.updatePDBIds();
if (annotation != null)
}
// transfer PDB entries
- if (entry.getPDBId() != null)
+ if (entry.getAllPDBEntries() != null)
{
- Enumeration e = entry.getPDBId().elements();
+ Enumeration e = entry.getAllPDBEntries().elements();
while (e.hasMoreElements())
{
PDBEntry pdb = (PDBEntry) e.nextElement();
return getDisplayId(false);
}
+ @Override
+ public PDBEntry getPDBEntry(String pdbIdStr)
+ {
+ if (getDatasetSequence() == null
+ || getDatasetSequence().getAllPDBEntries() == null)
+ {
+ return null;
+ }
+ List<PDBEntry> entries = getDatasetSequence().getAllPDBEntries();
+ for (PDBEntry entry : entries)
+ {
+ if (entry.getId().equalsIgnoreCase(pdbIdStr))
+ {
+ return entry;
+ }
+ }
+ return null;
+ }
+
}
*
* @return DOCUMENT ME!
*/
- public Vector<PDBEntry> getPDBId();
+ public Vector<PDBEntry> getAllPDBEntries();
/**
* add entry to the vector of PDBIds, if it isn't in the list already
*/
public List<int[]> getInsertions();
+ /**
+ * Given a pdbId String, return the equivalent PDBEntry if available in the
+ * given sequence
+ *
+ * @param pdbId
+ * @return
+ */
+ public PDBEntry getPDBEntry(String pdbId);
}
for (SequenceI sq : alignment.getSequences())
{
Vector<PDBEntry> pdbs = sq
- .getDatasetSequence().getPDBId();
+ .getDatasetSequence().getAllPDBEntries();
if (pdbs == null)
{
continue;
{
// just transfer the file name from the first sequence's first
// PDBEntry
- file = new File(pdbseq.getSequenceAt(0).getPDBId()
+ file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
.elementAt(0).getFile()).getAbsolutePath();
jmb.getPdbEntry(pi).setFile(file);
String chain = null;
if (seq.getDatasetSequence() != null)
{
- Vector<PDBEntry> pdbrefs = seq.getDatasetSequence().getPDBId();
+ Vector<PDBEntry> pdbrefs = seq.getDatasetSequence().getAllPDBEntries();
if (pdbrefs != null && pdbrefs.size() > 0)
{
chain = pdbrefs.get(0).getChainCode();
if (pdbseq != null && pdbseq.getHeight() > 0)
{
// just use the file name from the first sequence's first PDBEntry
- filePath = new File(pdbseq.getSequenceAt(0).getPDBId()
+ filePath = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
.elementAt(0).getFile()).getAbsolutePath();
processingEntry.setFile(filePath);
}
}
}
- if (jdatasq.getPDBId() != null)
+ if (jdatasq.getAllPDBEntries() != null)
{
- Enumeration en = jdatasq.getPDBId().elements();
+ Enumeration en = jdatasq.getAllPDBEntries().elements();
while (en.hasMoreElements())
{
Pdbids pdb = new Pdbids();
SequenceI sqass = null;
for (SequenceI sq : ap.av.getSequenceSelection())
{
- Vector<PDBEntry> pes = sq.getDatasetSequence().getPDBId();
+ Vector<PDBEntry> pes = sq.getDatasetSequence().getAllPDBEntries();
if (pes != null && pes.size() > 0)
{
reppdb.put(pes.get(0).getId(), pes.get(0));
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import java.util.Hashtable;
import java.util.LinkedHashSet;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
-import javax.swing.table.DefaultTableModel;
+import javax.swing.table.AbstractTableModel;
/**
* Provides the behaviors for the Structure chooser Panel
private boolean isValidPBDEntry;
- private static Hashtable<String, PDBEntry> cachedEntryMap;
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
&& !resultList.getSearchSummary().isEmpty())
{
discoveredStructuresSet.addAll(resultList.getSearchSummary());
- updateSequencePDBEntries(seq, resultList.getSearchSummary());
}
}
if (errors.size() > 0)
{
StringBuilder errorMsg = new StringBuilder();
- // "Operation was unsuccessful due to the following: \n");
for (String error : errors)
{
errorMsg.append(error).append("\n");
public void loadLocalCachedPDBEntries()
{
- DefaultTableModel tableModel = new DefaultTableModel()
- {
- @Override
- public boolean isCellEditable(int row, int column)
- {
- return false;
- }
- };
- tableModel.addColumn("Ref Sequence");
- tableModel.addColumn("PDB Id");
- tableModel.addColumn("Chain");
- tableModel.addColumn("Type");
- tableModel.addColumn("File");
- cachedEntryMap = new Hashtable<String, PDBEntry>();
+ ArrayList<CachedPDB> entries = new ArrayList<CachedPDB>();
for (SequenceI seq : selectedSequences)
{
if (seq.getDatasetSequence() != null
- && seq.getDatasetSequence().getPDBId() != null)
+ && seq.getDatasetSequence().getAllPDBEntries() != null)
{
- for (PDBEntry pdbEntry : seq.getDatasetSequence().getPDBId())
+ for (PDBEntry pdbEntry : seq.getDatasetSequence().getAllPDBEntries())
{
-
- String chain = pdbEntry.getChainCode() == null ? "_" : pdbEntry
- .getChainCode();
- Object[] pdbEntryRowData = new Object[]
- { seq, pdbEntry.getId(), chain, pdbEntry.getType(),
- pdbEntry.getFile() };
if (pdbEntry.getFile() != null)
{
- tableModel.addRow(pdbEntryRowData);
+ entries.add(new CachedPDB(seq, pdbEntry));
}
- cachedEntryMap.put(pdbEntry.getId().toLowerCase(), pdbEntry);
}
}
}
- tbl_local_pdb.setModel(tableModel);
- }
- /**
- * Update the PDBEntry for a given sequence with values retrieved from
- * PDBResponseSummary
- *
- * @param seq
- * the Sequence to update its DBRef entry
- * @param responseSummaries
- * a collection of PDBResponseSummary
- */
- public void updateSequencePDBEntries(SequenceI seq,
- Collection<PDBResponseSummary> responseSummaries)
- {
- for (PDBResponseSummary response : responseSummaries)
- {
- String pdbIdStr = response.getPdbId();
- PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
- if (pdbEntry == null)
- {
- pdbEntry = new PDBEntry();
- pdbEntry.setId(pdbIdStr);
- pdbEntry.setType(PDBEntry.Type.PDB);
- }
- seq.getDatasetSequence().addPDBId(pdbEntry);
- }
+ PDBEntryTableModel tableModelx = new PDBEntryTableModel(entries);
+ tbl_local_pdb.setModel(tableModelx);
}
+
/**
* Builds a query string for a given sequences using its DBRef entries
*
}
}
- if (seq.getPDBId() != null)
+ if (seq.getAllPDBEntries() != null)
{
- for (PDBEntry entry : seq.getPDBId())
+ for (PDBEntry entry : seq.getAllPDBEntries())
{
if (isValidSeqName(entry.getId()))
{
PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
int count = 0;
ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
- for (int summaryRow : selectedRows)
+ for (int row : selectedRows)
{
- String pdbIdStr = tbl_summary.getValueAt(summaryRow, pdbIdColIndex)
+ String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
.toString();
- SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(
- summaryRow, refSeqColIndex);
+ SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
+ refSeqColIndex);
selectedSeqsToView.add(selectedSeq);
- PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
+ PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
if (pdbEntry == null)
{
pdbEntry = new PDBEntry();
pdbEntry.setId(pdbIdStr);
pdbEntry.setType(PDBEntry.Type.PDB);
+ selectedSeq.getDatasetSequence().addPDBId(pdbEntry);
}
pdbEntriesToView[count++] = pdbEntry;
}
ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
for (int row : selectedRows)
{
- String entryKey = tbl_local_pdb.getValueAt(row, pdbIdColIndex)
- .toString().toLowerCase();
- pdbEntriesToView[count++] = cachedEntryMap.get(entryKey);
+ PDBEntry pdbEntry = (PDBEntry) tbl_local_pdb.getValueAt(row,
+ pdbIdColIndex);
+ pdbEntriesToView[count++] = pdbEntry;
SequenceI selectedSeq = (SequenceI) tbl_local_pdb.getValueAt(row,
refSeqColIndex);
selectedSeqsToView.add(selectedSeq);
-
}
SequenceI[] selectedSeqs = selectedSeqsToView
.toArray(new SequenceI[selectedSeqsToView.size()]);
}
String pdbIdStr = txt_search.getText();
- PDBEntry pdbEntry = cachedEntryMap.get(pdbIdStr.toLowerCase());
+ PDBEntry pdbEntry = selectedSequence.getPDBEntry(pdbIdStr);
if (pdbEntry == null)
{
pdbEntry = new PDBEntry();
- pdbEntry.setId(txt_search.getText());
+ pdbEntry.setId(pdbIdStr);
pdbEntry.setType(PDBEntry.Type.PDB);
+ selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
}
- selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
PDBEntry[] pdbEntriesToView = new PDBEntry[]
{ pdbEntry };
launchStructureViewer(ap.getStructureSelectionManager(),
}
SequenceI[][] collatedSeqs = seqsMap.toArray(new SequenceI[0][0]);
sViewer.viewStructures(pdbEntriesToView, collatedSeqs, alignPanel);
- // sViewer.viewStructures(pdbEntriesToView,
- // alignPanel.av.collateForPDB(pdbEntriesToView),
- // alignPanel);
}
else
{
cmb_assSeq.removeAllItems();
cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-",
null));
- // cmb_assSeq.addItem(new AssociateSeqOptions("Auto Detect", null));
lbl_associateSeq.setVisible(false);
if (selectedSequences.length > 1)
{
}
}
+ 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<CachedPDB>(pdbEntries);
+ }
+
+ @Override
+ public String getColumnName(int columnIndex)
+ {
+ return columns[columnIndex];
+ }
+
+ @Override
+ public int getRowCount()
+ {
+ return pdbEntries.size();
+ }
+
+ @Override
+ public int getColumnCount()
+ {
+ return columns.length;
+ }
+
+ @Override
+ public boolean isCellEditable(int row, int column)
+ {
+ return false;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ Object value = "??";
+ CachedPDB entry = pdbEntries.get(rowIndex);
+ switch (columnIndex)
+ {
+ case 0:
+ value = entry.getSequence();
+ break;
+ case 1:
+ value = entry.getPdbEntry();
+ break;
+ case 2:
+ value = entry.getPdbEntry().getChainCode() == null ? "_" : entry
+ .getPdbEntry().getChainCode();
+ break;
+ case 3:
+ value = entry.getPdbEntry().getType();
+ break;
+ case 4:
+ value = entry.getPdbEntry().getFile();
+ break;
+ }
+ return value;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex)
+ {
+ return columnIndex == 0 ? SequenceI.class : PDBEntry.class;
+ }
+
+ public CachedPDB getPDBEntryAt(int row)
+ {
+ return pdbEntries.get(row);
+ }
+
+ }
+
+ private class CachedPDB
+ {
+ private SequenceI sequence;
+
+ private PDBEntry pdbEntry;
+
+ public CachedPDB(SequenceI sequence, PDBEntry pdbEntry)
+ {
+ this.sequence = sequence;
+ this.pdbEntry = pdbEntry;
+ }
+
+ public SequenceI getSequence()
+ {
+ return sequence;
+ }
+
+ public PDBEntry getPdbEntry()
+ {
+ return pdbEntry;
+ }
+
+ }
}
{
sq = sq.getDatasetSequence();
}
- if (sq.getPDBId() != null)
+ if (sq.getAllPDBEntries() != null)
{
- for (PDBEntry pdbe : sq.getPDBId())
+ for (PDBEntry pdbe : sq.getAllPDBEntries())
{
// register PDB entries with desktop's structure selection
// manager
{
String chid = null;
// Mapping map=null;
- for (PDBEntry pid : pdbcs.getPDBId())
+ for (PDBEntry pid : pdbcs.getAllPDBEntries())
{
if (pid.getFile() == file)
{
assertTrue(chainA.sequence.getSequenceAsString().endsWith("WNVEVY"));
assertEquals("3W5V|A", chainA.sequence.getName());
assertNull(chainA.sequence.getAnnotation());
- assertEquals(1, chainA.sequence.getPDBId().size());
- PDBEntry pdb = chainA.sequence.getPDBId().get(0);
+ assertEquals(1, chainA.sequence.getAllPDBEntries().size());
+ PDBEntry pdb = chainA.sequence.getAllPDBEntries().get(0);
assertEquals("A", pdb.getChainCode());
assertEquals("PDB", pdb.getType());
assertEquals("3W5V", pdb.getId());
assertEquals("3W5V|B", seqs.get(1).getName());
assertEquals("3W5V|C", seqs.get(2).getName());
assertEquals("3W5V|D", seqs.get(3).getName());
- assertEquals(1, seqs.get(0).getPDBId().size());
- PDBEntry pdbe = seqs.get(0).getPDBId().get(0);
+ assertEquals(1, seqs.get(0).getAllPDBEntries().size());
+ PDBEntry pdbe = seqs.get(0).getAllPDBEntries().get(0);
assertEquals("A", pdbe.getChainCode());
assertEquals("3W5V", pdbe.getId());
assertEquals(PDBEntry.Type.PDB.toString(), pdbe.getType());
{
dsq = dsq.getDatasetSequence();
}
- if (dsq.getPDBId() != null && dsq.getPDBId().size() > 0)
+ if (dsq.getAllPDBEntries() != null && dsq.getAllPDBEntries().size() > 0)
{
- for (int q = 0; q < dsq.getPDBId().size(); q++)
+ for (int q = 0; q < dsq.getAllPDBEntries().size(); q++)
{
final StructureViewer structureViewer = new StructureViewer(af
.getViewport().getStructureSelectionManager());
structureViewer.setViewerType(ViewerType.JMOL);
JalviewStructureDisplayI jmolViewer = structureViewer
- .viewStructures(dsq.getPDBId().elementAt(q),
+ .viewStructures(dsq.getAllPDBEntries().elementAt(q),
new SequenceI[]
{ sq }, af.getCurrentView().getAlignPanel());
/*
{
dsq = dsq.getDatasetSequence();
}
- if (dsq.getPDBId() != null && dsq.getPDBId().size() > 0)
+ if (dsq.getAllPDBEntries() != null && dsq.getAllPDBEntries().size() > 0)
{
- for (int q = 0; q < dsq.getPDBId().size(); q++)
+ for (int q = 0; q < dsq.getAllPDBEntries().size(); q++)
{
final StructureViewer structureViewer = new StructureViewer(af
.getViewport().getStructureSelectionManager());
structureViewer.setViewerType(ViewerType.CHIMERA);
JalviewStructureDisplayI chimeraViewer = structureViewer
- .viewStructures(dsq.getPDBId().elementAt(q),
+ .viewStructures(dsq.getAllPDBEntries().elementAt(q),
new SequenceI[]
{ sq }, af.getCurrentView().getAlignPanel());
/*
AlignFrame af = loader.LoadFileWaitTillLoaded(pdbStr,
FormatAdapter.FILE);
al = af.getViewport().getAlignment();
- pdbId = al.getSequenceAt(0).getDatasetSequence().getPDBId()
+ pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries()
.get(0).getId();
}
{
sq = sq.getDatasetSequence();
}
- assertNotNull(sq.getPDBId());
- assertEquals("Expected only one PDB ID", sq.getPDBId().size(), 1);
- for (PDBEntry pdbentry : sq.getPDBId())
+ assertNotNull(sq.getAllPDBEntries());
+ assertEquals("Expected only one PDB ID", sq.getAllPDBEntries().size(), 1);
+ for (PDBEntry pdbentry : sq.getAllPDBEntries())
{
System.err.println("PDB Entry " + pdbentry.getId() + " "
+ pdbentry.getFile());
int numpdb = 0;
for (SequenceI sq : al.getSequences())
{
- if (sq.getPDBId() != null)
+ if (sq.getAllPDBEntries() != null)
{
- numpdb += sq.getPDBId().size();
+ numpdb += sq.getAllPDBEntries().size();
}
}
assertTrue(
assertEquals("EMBL", ref.getSource());
assertEquals("1.2", ref.getVersion());
assertEquals("a7890", ref.getAccessionId());
- assertNull(seq.getPDBId());
+ assertNull(seq.getAllPDBEntries());
}
/**
assertEquals("1.2", ref.getVersion());
// DBRef id is pdbId + chain code
assertEquals("1WRIA", ref.getAccessionId());
- assertEquals(1, seq.getPDBId().size());
- PDBEntry pdbRef = seq.getPDBId().get(0);
+ assertEquals(1, seq.getAllPDBEntries().size());
+ PDBEntry pdbRef = seq.getAllPDBEntries().get(0);
assertEquals("1WRI", pdbRef.getId());
assertNull(pdbRef.getFile());
assertEquals("A", pdbRef.getChainCode());
{
assertTrue("No annotation transfered to sequence.",
sq.getAnnotation().length > 0);
- assertTrue("No PDBEntry on sequence.", sq.getPDBId().size() > 0);
+ assertTrue("No PDBEntry on sequence.", sq.getAllPDBEntries().size() > 0);
assertTrue("No RNA annotation on sequence.", sq.getRNA() != null);
}
}