From: tcofoegbu Date: Fri, 24 Jun 2016 10:08:59 +0000 (+0100) Subject: JAL-1960 updated unit test to include the test case where a sequences has no PDBId... X-Git-Tag: Release_2_10_0~157 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9a261821861fc0efeb15bf9d0315344022b3f045;p=jalview.git JAL-1960 updated unit test to include the test case where a sequences has no PDBId entry(s) but has Uniprot & PDB dbrefs --- diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index c83f264..8bccc6b 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -45,6 +45,7 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.Vector; import javax.swing.JCheckBox; @@ -249,7 +250,7 @@ public class StructureChooser extends GStructureChooser implements boolean isPDBRefsFound = false; boolean isUniProtRefsFound = false; StringBuilder queryBuilder = new StringBuilder(); - HashSet seqRefs = new LinkedHashSet(); + Set seqRefs = new LinkedHashSet(); if (seq.getAllPDBEntries() != null) { @@ -257,9 +258,8 @@ public class StructureChooser extends GStructureChooser implements { if (isValidSeqName(entry.getId())) { - queryBuilder.append("pdb_id") - .append(":") -.append(entry.getId().toLowerCase()) + queryBuilder.append("pdb_id:") + .append(entry.getId().toLowerCase()) .append(" OR "); isPDBRefsFound = true; // seqRefs.add(entry.getId()); @@ -275,21 +275,18 @@ public class StructureChooser extends GStructureChooser implements { if (dbRef.getSource().equalsIgnoreCase(DBRefSource.UNIPROT)) { - queryBuilder -.append("uniprot_accession").append(":") + queryBuilder.append("uniprot_accession:") .append(getDBRefId(dbRef)) .append(" OR "); - queryBuilder -.append("uniprot_id") - .append(":") - .append(getDBRefId(dbRef)).append(" OR "); + queryBuilder.append("uniprot_id:").append(getDBRefId(dbRef)) + .append(" OR "); isUniProtRefsFound = true; } else if (dbRef.getSource().equalsIgnoreCase(DBRefSource.PDB)) { - queryBuilder.append("pdb_id") - .append(":").append(getDBRefId(dbRef).toLowerCase()) + queryBuilder.append("pdb_id:") + .append(getDBRefId(dbRef).toLowerCase()) .append(" OR "); isPDBRefsFound = true; } diff --git a/test/jalview/gui/StructureChooserTest.java b/test/jalview/gui/StructureChooserTest.java index da2cde5..bad536b 100644 --- a/test/jalview/gui/StructureChooserTest.java +++ b/test/jalview/gui/StructureChooserTest.java @@ -24,6 +24,7 @@ import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; import jalview.datamodel.DBRefEntry; +import jalview.datamodel.DBRefSource; import jalview.datamodel.PDBEntry; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; @@ -80,6 +81,27 @@ public class StructureChooserTest seq.setDBRefs(null); query = StructureChooser.buildQuery(seq); assertEquals("text:4kqy", query); + + DBRefEntry uniprotDBRef = new DBRefEntry(); + uniprotDBRef.setAccessionId("P12345"); + uniprotDBRef.setSource(DBRefSource.UNIPROT); + seq.addDBRef(uniprotDBRef); + + DBRefEntry pdbDBRef = new DBRefEntry(); + pdbDBRef.setAccessionId("1XYZ"); + pdbDBRef.setSource(DBRefSource.PDB); + seq.addDBRef(pdbDBRef); + + for (int x = 1; x < 5; x++) + { + DBRefEntry dbRef = new DBRefEntry(); + dbRef.setAccessionId("XYZ_" + x); + seq.addDBRef(dbRef); + } + query = StructureChooser.buildQuery(seq); + assertEquals( + "uniprot_accession:P12345 OR uniprot_id:P12345 OR pdb_id:1xyz", + query); } @Test(groups = { "Functional" })