| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ws.seqfetcher; |
| 22 |
|
|
| 23 |
|
import static org.testng.AssertJUnit.assertEquals; |
| 24 |
|
import static org.testng.AssertJUnit.assertFalse; |
| 25 |
|
import static org.testng.AssertJUnit.assertNotNull; |
| 26 |
|
import static org.testng.AssertJUnit.assertTrue; |
| 27 |
|
|
| 28 |
|
import java.util.ArrayList; |
| 29 |
|
import java.util.Arrays; |
| 30 |
|
import java.util.List; |
| 31 |
|
|
| 32 |
|
import org.junit.Assert; |
| 33 |
|
import org.testng.annotations.AfterClass; |
| 34 |
|
import org.testng.annotations.BeforeClass; |
| 35 |
|
import org.testng.annotations.Test; |
| 36 |
|
|
| 37 |
|
import jalview.analysis.CrossRef; |
| 38 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 39 |
|
import jalview.datamodel.AlignmentI; |
| 40 |
|
import jalview.datamodel.DBRefEntry; |
| 41 |
|
import jalview.datamodel.DBRefSource; |
| 42 |
|
import jalview.datamodel.FeatureProperties; |
| 43 |
|
import jalview.datamodel.Sequence; |
| 44 |
|
import jalview.datamodel.SequenceFeature; |
| 45 |
|
import jalview.datamodel.SequenceI; |
| 46 |
|
import jalview.gui.JvOptionPane; |
| 47 |
|
import jalview.util.DBRefUtils; |
| 48 |
|
import jalview.ws.DBRefFetcher; |
| 49 |
|
import jalview.ws.SequenceFetcher; |
| 50 |
|
import jalview.ws.dbsources.EBIAlfaFold; |
| 51 |
|
import jalview.ws.dbsources.Pdb; |
| 52 |
|
import jalview.ws.dbsources.Uniprot; |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
@author |
| 56 |
|
|
| 57 |
|
|
| |
|
| 36.4% |
Uncovered Elements: 56 (88) |
Complexity: 14 |
Complexity Density: 0.2 |
|
| 58 |
|
public class DbRefFetcherTest |
| 59 |
|
{ |
| 60 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 61 |
1 |
@BeforeClass(alwaysRun = true)... |
| 62 |
|
public void setUpJvOptionPane() |
| 63 |
|
{ |
| 64 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 65 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
@throws |
| 70 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 71 |
1 |
@BeforeClass(alwaysRun = true)... |
| 72 |
|
public static void setUpBeforeClass() throws Exception |
| 73 |
|
{ |
| 74 |
1 |
jalview.bin.Console.initLogger(); |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
@throws |
| 79 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 80 |
1 |
@AfterClass(alwaysRun = true)... |
| 81 |
|
public static void tearDownAfterClass() throws Exception |
| 82 |
|
{ |
| 83 |
|
} |
| 84 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
4-
|
|
| 85 |
0 |
@Test(groups = { "Network" })... |
| 86 |
|
public void checkUniprotCanonicalFlagSet() |
| 87 |
|
{ |
| 88 |
|
|
| 89 |
0 |
SequenceI uniprotSeq = new Sequence("FER1_SPIOL", |
| 90 |
|
"MAATTTTMMGMATTFVPKPQAPPMMAALPSNTGRSLFGLKTGSRGGRMTMAAYKVTLVTPTGNVEFQCPDDV" |
| 91 |
|
+ "YILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDDQSFLDDDQIDEGWVLTCAAYPVSDVTIETHKEEE" |
| 92 |
|
+ "LTA"); |
| 93 |
0 |
DBRefFetcher dbr = new DBRefFetcher(new SequenceI[] { uniprotSeq }); |
| 94 |
0 |
dbr.fetchDBRefs(true); |
| 95 |
0 |
List<DBRefEntry> primRefs = uniprotSeq.getPrimaryDBRefs(); |
| 96 |
0 |
assertNotNull(primRefs); |
| 97 |
0 |
assertTrue(primRefs.size() > 0); |
| 98 |
0 |
boolean canonicalUp = false; |
| 99 |
0 |
for (DBRefEntry ref : primRefs) |
| 100 |
|
{ |
| 101 |
0 |
assertEquals(DBRefSource.UNIPROT, ref.getCanonicalSourceName()); |
| 102 |
0 |
canonicalUp |= ref.isCanonical(); |
| 103 |
|
} |
| 104 |
0 |
assertTrue("No Canonical Uniprot reference detected", canonicalUp); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| |
|
| 96.2% |
Uncovered Elements: 1 (26) |
Complexity: 5 |
Complexity Density: 0.25 |
1PASS
|
|
| 112 |
1 |
@Test(groups = { "Functional" })... |
| 113 |
|
public void testStandardProtDbs() |
| 114 |
|
{ |
| 115 |
1 |
List<String> defdb = new ArrayList<String>(); |
| 116 |
1 |
defdb.addAll(Arrays.asList(DBRefSource.PROTEINDBS)); |
| 117 |
1 |
defdb.add(DBRefSource.PDB); |
| 118 |
1 |
List<DbSourceProxy> srces = new ArrayList<DbSourceProxy>(); |
| 119 |
1 |
SequenceFetcher sfetcher = new SequenceFetcher(); |
| 120 |
1 |
boolean pdbFound = false; |
| 121 |
|
|
| 122 |
1 |
for (String ddb : defdb) |
| 123 |
|
{ |
| 124 |
5 |
List<DbSourceProxy> srcesfordb = sfetcher.getSourceProxy(ddb); |
| 125 |
|
|
| 126 |
5 |
if (srcesfordb != null) |
| 127 |
|
{ |
| 128 |
|
|
| 129 |
5 |
srces.addAll(srcesfordb); |
| 130 |
|
} |
| 131 |
|
} |
| 132 |
|
|
| 133 |
1 |
int i = 0; |
| 134 |
1 |
int uniprotPos = -1; |
| 135 |
1 |
for (DbSourceProxy s : srces) |
| 136 |
|
{ |
| 137 |
4 |
if (s instanceof Uniprot && uniprotPos == -1) |
| 138 |
|
{ |
| 139 |
1 |
uniprotPos = i; |
| 140 |
|
} |
| 141 |
4 |
if (s instanceof Pdb) |
| 142 |
|
{ |
| 143 |
1 |
pdbFound = true; |
| 144 |
|
} |
| 145 |
4 |
i++; |
| 146 |
|
} |
| 147 |
|
|
| 148 |
1 |
assertTrue("Failed to find Uniprot source as first source amongst " |
| 149 |
|
+ srces.size() + " sources (source was at position " |
| 150 |
|
+ uniprotPos + ")", uniprotPos == 0); |
| 151 |
1 |
assertTrue("Failed to find PDB source amongst " + srces.size() |
| 152 |
|
+ " sources", pdbFound); |
| 153 |
|
} |
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
@throws |
| 160 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 161 |
0 |
@Test(groups = { "External" })... |
| 162 |
|
public void testEmblUniprotProductRecovery() throws Exception |
| 163 |
|
{ |
| 164 |
0 |
String retrievalId = "V00488"; |
| 165 |
0 |
DbSourceProxy embl = new SequenceFetcher() |
| 166 |
|
.getSourceProxy(DBRefSource.EMBL).get(0); |
| 167 |
0 |
assertNotNull("Couldn't find the EMBL retrieval client", embl); |
| 168 |
0 |
verifyProteinNucleotideXref(retrievalId, embl); |
| 169 |
|
} |
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
@throws |
| 176 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
| 177 |
0 |
@Test(groups = { "External" })... |
| 178 |
|
public void testEmblCDSUniprotProductRecovery() throws Exception |
| 179 |
|
{ |
| 180 |
0 |
String retrievalId = "AAH29712"; |
| 181 |
0 |
DbSourceProxy embl = new SequenceFetcher() |
| 182 |
|
.getSourceProxy(DBRefSource.EMBLCDS).get(0); |
| 183 |
0 |
assertNotNull("Couldn't find the EMBL retrieval client", embl); |
| 184 |
0 |
verifyProteinNucleotideXref(retrievalId, embl); |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
@param |
| 191 |
|
@param |
| 192 |
|
@throws |
| 193 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
|
| 194 |
0 |
private void verifyProteinNucleotideXref(String retrievalId,... |
| 195 |
|
DbSourceProxy embl) throws Exception |
| 196 |
|
{ |
| 197 |
0 |
AlignmentI alsq = embl.getSequenceRecords(retrievalId); |
| 198 |
0 |
assertNotNull("Couldn't find the EMBL record " + retrievalId, alsq); |
| 199 |
0 |
assertEquals("Didn't retrieve right number of records", 1, |
| 200 |
|
alsq.getHeight()); |
| 201 |
0 |
SequenceI seq = alsq.getSequenceAt(0); |
| 202 |
0 |
assertEquals("Wrong sequence name", |
| 203 |
|
embl.getDbSource() + "|" + retrievalId, seq.getName()); |
| 204 |
0 |
List<SequenceFeature> sfs = seq.getSequenceFeatures(); |
| 205 |
0 |
assertFalse("Sequence features missing", sfs.isEmpty()); |
| 206 |
0 |
assertTrue("Feature not CDS", FeatureProperties |
| 207 |
|
.isCodingFeature(embl.getDbSource(), sfs.get(0).getType())); |
| 208 |
0 |
assertEquals(embl.getDbSource(), sfs.get(0).getFeatureGroup()); |
| 209 |
0 |
List<DBRefEntry> dr = DBRefUtils.selectRefs(seq.getDBRefs(), |
| 210 |
|
new String[] |
| 211 |
|
{ DBRefSource.UNIPROT }); |
| 212 |
0 |
assertNotNull(dr); |
| 213 |
0 |
assertEquals("Expected a single Uniprot cross reference", 1, dr.size()); |
| 214 |
0 |
assertEquals("Expected cross reference map to be one amino acid", |
| 215 |
|
dr.get(0).getMap().getMappedWidth(), 1); |
| 216 |
0 |
assertEquals("Expected local reference map to be 3 nucleotides", |
| 217 |
|
dr.get(0).getMap().getWidth(), 3); |
| 218 |
0 |
AlignmentI sprods = new CrossRef(alsq.getSequencesArray(), alsq) |
| 219 |
|
.findXrefSequences(dr.get(0).getSource(), true); |
| 220 |
0 |
assertNotNull( |
| 221 |
|
"Couldn't recover cross reference sequence from dataset. Was it ever added ?", |
| 222 |
|
sprods); |
| 223 |
0 |
assertEquals("Didn't xref right number of records", 1, |
| 224 |
|
sprods.getHeight()); |
| 225 |
0 |
SequenceI proteinSeq = sprods.getSequenceAt(0); |
| 226 |
0 |
assertEquals(proteinSeq.getSequenceAsString(), |
| 227 |
|
dr.get(0).getMap().getTo().getSequenceAsString()); |
| 228 |
0 |
assertEquals(dr.get(0).getSource() + "|" + dr.get(0).getAccessionId(), |
| 229 |
|
proteinSeq.getName()); |
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
@throws |
| 237 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
1PASS
|
|
| 238 |
0 |
@Test(groups = { "External" })... |
| 239 |
|
public void testAlphaFoldClien() throws Exception |
| 240 |
|
{ |
| 241 |
0 |
DbSourceProxy alphafold = new EBIAlfaFold(); |
| 242 |
0 |
AlignmentI resp = alphafold |
| 243 |
|
.getSequenceRecords(alphafold.getTestQuery()); |
| 244 |
0 |
assertNotNull(resp); |
| 245 |
0 |
assertEquals("One sequence only", resp.getHeight(), 1); |
| 246 |
0 |
for (AlignmentAnnotation aa : resp.getAlignmentAnnotation()) |
| 247 |
|
{ |
| 248 |
0 |
if (aa.graph == AlignmentAnnotation.CONTACT_MAP) |
| 249 |
|
{ |
| 250 |
0 |
assertTrue("Contact map didn't provide valid contact", |
| 251 |
|
resp.getContactListFor(aa, 1).getContactAt(1) != -1d); |
| 252 |
|
|
| 253 |
0 |
return; |
| 254 |
|
} |
| 255 |
|
} |
| 256 |
0 |
Assert.fail("No pAE matrix found for alphafold structure."); |
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
} |