From: Jim Procter Date: Fri, 10 Sep 2021 12:45:07 +0000 (+0100) Subject: JAL-3829 insert title for structures from PDBe X-Git-Tag: Release_2_11_2_0~39^2~8 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4f452e7f601b3afc4b6380632586b04d9fa081bb;p=jalview.git JAL-3829 insert title for structures from PDBe --- diff --git a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java index e5f96be..2c6afe8 100644 --- a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java @@ -157,9 +157,24 @@ public class ThreeDBStructureChooserQuerySource resultList = tdbRestClient.executeRequest(tdbRequest); lastTdbRequest = tdbRequest; + + // Query the PDB and add additional metadata + FTSRestResponse pdbResponse = fetchStructuresMetaDataFor(getPDBQuerySource(), resultList); + FTSRestResponse joinedResp = joinResponses(resultList, + pdbResponse); return resultList; } + PDBStructureChooserQuerySource pdbQuerySource=null; + private PDBStructureChooserQuerySource getPDBQuerySource() + { + if (pdbQuerySource==null) + { + pdbQuerySource = new PDBStructureChooserQuerySource(); + } + return pdbQuerySource; + } + private FTSRestRequest getTDBeaconsRequest(SequenceI seq, Collection wantedFields) { @@ -369,27 +384,31 @@ public class ThreeDBStructureChooserQuerySource int idx_provider = getLastFTSRequest().getFieldIndex("Provider"); // join on int idx_modelId = getLastFTSRequest().getFieldIndex("Model id"); - int pdbIdx = lastPdbRequest.getFieldIndex("pdb_id"); - for (FTSData row : upResponse.getSearchSummary()) + int pdbIdx = lastPdbRequest.getFieldIndex("PDB Id"); + int pdbTitle_idx = lastPdbRequest.getFieldIndex("Title"); + int tdbTitle_idx = getLastFTSRequest().getFieldIndex("Title"); + + List joinedRows = new ArrayList(); + for (final FTSData row : upResponse.getSearchSummary()) { String id = (String) row.getSummaryData()[idx_modelId]; String provider = (String) row.getSummaryData()[idx_provider]; if ("PDBe".equalsIgnoreCase(provider)) { - for (FTSData pdbrow : pdbResponse.getSearchSummary()) + for (final FTSData pdbrow : pdbResponse.getSearchSummary()) { String pdbid = (String) pdbrow.getSummaryData()[pdbIdx]; if (id.equalsIgnoreCase(pdbid)) { - // often multiple entries per PDB ID so we bail after first - // get wanted fields - // append to FTSRestResponse array + row.getSummaryData()[tdbTitle_idx] = pdbrow + .getSummaryData()[pdbTitle_idx]; } } + } else { + row.getSummaryData()[tdbTitle_idx] = "Model from TDB"; } } - // TODO Auto-generated method stub - return null; + return upResponse; } } \ No newline at end of file diff --git a/test/jalview/gui/structurechooser/StructureChooserQuerySourceTest.java b/test/jalview/gui/structurechooser/StructureChooserQuerySourceTest.java index acedfed..59c4a50 100644 --- a/test/jalview/gui/structurechooser/StructureChooserQuerySourceTest.java +++ b/test/jalview/gui/structurechooser/StructureChooserQuerySourceTest.java @@ -175,7 +175,9 @@ public class StructureChooserQuerySourceTest { System.out.println("seq >>>> " + upSeq); TDBeaconsFTSRestClientTest.setMock(); + PDBFTSRestClient.setMock(); StructureChooserQuerySource scquery = StructureChooserQuerySource.getQuerySourceFor(new SequenceI[] { upSeq}); + // gets the lightweight proxy rather than the ThreeDBStructureChooserQuerySource AssertJUnit.assertTrue(scquery instanceof ThreeDBStructureChooserQuerySource); String query = scquery.buildQuery(upSeq); AssertJUnit.assertEquals("P38398", query); @@ -264,7 +266,7 @@ public class StructureChooserQuerySourceTest upResponse = tdbquery.fetchStructuresMetaData(upSeq, tdbquery.getDocFieldPrefs().getStructureSummaryFields(), null, false); // test ranking without additional PDBe data FTSRestResponse firstRanked = tdbquery.selectFirstRankedQuery(upSeq, upResponse.getSearchSummary(), tdbquery.getDocFieldPrefs().getStructureSummaryFields(), "", false); - assertTrue(firstRanked.getNumberOfItemsFound()==upResponse.getNumberOfItemsFound()); + assertTrue(firstRanked.getNumberOfItemsFound()0);