package jalview.gui;
import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.jbgui.GStructureChooser;
PDBRestRequest pdbRequest = new PDBRestRequest();
pdbRequest.setAllowEmptySeq(false);
pdbRequest.setResponseSize(500);
- pdbRequest.setFieldToSearchBy("(text:");
+ pdbRequest.setFieldToSearchBy("(");
pdbRequest.setWantedFields(wantedFields);
pdbRequest.setSearchTerm(buildQuery(seq) + ")");
pdbRequest.setAssociatedSequence(seq);
public static String buildQuery(SequenceI seq)
{
+ boolean isPDBRefsFound = false;
+ boolean isUniProtRefsFound = false;
+ StringBuilder queryBuilder = new StringBuilder();
HashSet<String> seqRefs = new LinkedHashSet<String>();
- String seqName = seq.getName();
- String[] names = seqName.toLowerCase().split("\\|");
- for (String name : names)
- {
- // System.out.println("Found name : " + name);
- name.trim();
- if (isValidSeqName(name))
- {
- seqRefs.add(name);
- }
- }
if (seq.getAllPDBEntries() != null)
{
{
if (isValidSeqName(entry.getId()))
{
- seqRefs.add(entry.getId());
+ queryBuilder.append(PDBRestClient.PDBDocField.PDB_ID.getCode())
+ .append(":")
+.append(entry.getId().toLowerCase())
+ .append(" OR ");
+ isPDBRefsFound = true;
+ // seqRefs.add(entry.getId());
}
}
}
if (seq.getDBRefs() != null && seq.getDBRefs().length != 0)
{
- int count = 0;
for (DBRefEntry dbRef : seq.getDBRefs())
{
if (isValidSeqName(getDBRefId(dbRef)))
{
- seqRefs.add(getDBRefId(dbRef));
- }
- ++count;
- if (count > 10)
- {
- break;
+ if (dbRef.getSource().equalsIgnoreCase(DBRefSource.UNIPROT))
+ {
+ queryBuilder
+ .append(PDBRestClient.PDBDocField.UNIPROT_ACCESSION
+ .getCode()).append(":")
+ .append(getDBRefId(dbRef))
+ .append(" OR ");
+ queryBuilder
+ .append(PDBRestClient.PDBDocField.UNIPROT_ID.getCode())
+ .append(":")
+ .append(getDBRefId(dbRef)).append(" OR ");
+ isUniProtRefsFound = true;
+ }
+ else if (dbRef.getSource().equalsIgnoreCase(DBRefSource.PDB))
+ {
+
+ queryBuilder.append(PDBRestClient.PDBDocField.PDB_ID.getCode())
+ .append(":").append(getDBRefId(dbRef).toLowerCase())
+ .append(" OR ");
+ isPDBRefsFound = true;
+ }
+ else
+ {
+ seqRefs.add(getDBRefId(dbRef));
+ }
}
}
}
- StringBuilder queryBuilder = new StringBuilder();
- for (String seqRef : seqRefs)
+ if (!isPDBRefsFound && !isUniProtRefsFound)
{
- queryBuilder.append("text:").append(seqRef).append(" OR ");
+ String seqName = seq.getName();
+ String[] names = seqName.toLowerCase().split("\\|");
+ for (String name : names)
+ {
+ // System.out.println("Found name : " + name);
+ name.trim();
+ if (isValidSeqName(name))
+ {
+ seqRefs.add(name);
+ }
+ }
+
+ for (String seqRef : seqRefs)
+ {
+ queryBuilder.append("text:").append(seqRef).append(" OR ");
+ }
}
- int endIndex = queryBuilder.lastIndexOf(" OR ");
+ int endIndex = queryBuilder.lastIndexOf(" OR ");
if (queryBuilder.toString().length() < 6)
{
return null;
}
- String query = queryBuilder.toString().substring(5, endIndex);
+ String query = queryBuilder.toString().substring(0, endIndex);
return query;
}
PDBRestRequest pdbRequest = new PDBRestRequest();
pdbRequest.setAllowEmptySeq(false);
pdbRequest.setResponseSize(1);
- pdbRequest.setFieldToSearchBy("(text:");
+ pdbRequest.setFieldToSearchBy("(");
pdbRequest.setFieldToSortBy(fieldToFilterBy,
!chk_invertFilter.isSelected());
pdbRequest.setSearchTerm(buildQuery(seq) + ")");
/**
* Handles action event for btn_pdbFromFile
*/
+ @Override
public void pdbFromFile_actionPerformed()
{
jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
* Populates the filter combo-box options dynamically depending on discovered
* structures
*/
+ @Override
protected void populateFilterComboBox()
{
if (isStructuresDiscovered())
/**
* Updates the displayed view based on the selected filter option
*/
+ @Override
protected void updateCurrentView()
{
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
* Validates user selection and activates the view button if all parameters
* are correct
*/
+ @Override
public void validateSelections()
{
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
final StructureViewer sViewer = new StructureViewer(ssm);
new Thread(new Runnable()
{
+ @Override
public void run()
{
if (pdbEntriesToView.length > 1)
* 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)
{
{
new Thread()
{
+ @Override
public void run()
{
errorWarning.setLength(0);