import jalview.io.gff.SequenceOntologyI;
import jalview.util.MapList;
import jalview.util.MappingUtils;
+import jalview.ws.params.InvalidArgumentException;
import java.io.IOException;
import java.util.ArrayList;
assertTrue(AlignmentUtils.haveCrossRef(seq2, seq1));
// now the other way round
- seq1.setDBRefs(null);
+ try {
+ seq1.setDBRefs(null);
+ } catch (InvalidArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
seq2.addDBRef(new DBRefEntry("EMBL", "1", "A12345"));
assertTrue(AlignmentUtils.haveCrossRef(seq1, seq2));
assertTrue(AlignmentUtils.haveCrossRef(seq2, seq1));
DBRefEntry dna1xref = new DBRefEntry("UNIPROT", "ENSEMBL", "pep1",
new Mapping(mapfordna1));
dna1.addDBRef(dna1xref);
- assertEquals(2, dna1.getDBRefs().length); // to self and to pep1
+ assertEquals(2, dna1.getDBRefs().size()); // to self and to pep1
DBRefEntry dna2xref = new DBRefEntry("UNIPROT", "ENSEMBL", "pep2",
new Mapping(mapfordna2));
dna2.addDBRef(dna2xref);
- assertEquals(2, dna2.getDBRefs().length); // to self and to pep2
+ assertEquals(2, dna2.getDBRefs().size()); // to self and to pep2
/*
* execute method under test:
* verify CDS has a dbref with mapping to peptide
*/
assertNotNull(cds1Dss.getDBRefs());
- assertEquals(2, cds1Dss.getDBRefs().length);
- dbref = cds1Dss.getDBRefs()[0];
+ assertEquals(2, cds1Dss.getDBRefs().size());
+ dbref = cds1Dss.getDBRefs().get(0);
assertEquals(dna1xref.getSource(), dbref.getSource());
// version is via ensembl's primary ref
assertEquals(dna1xref.getVersion(), dbref.getVersion());
*/
assertNotNull(pep1.getDBRefs());
// FIXME pep1.getDBRefs() is 1 - is that the correct behaviour ?
- assertEquals(2, pep1.getDBRefs().length);
- dbref = pep1.getDBRefs()[1];
+ assertEquals(2, pep1.getDBRefs().size());
+ dbref = pep1.getDBRefs().get(1);
assertEquals("ENSEMBL", dbref.getSource());
assertEquals("0", dbref.getVersion());
assertEquals("CDS|dna1", dbref.getAccessionId());
/*
* verify cDNA has added a dbref with mapping to CDS
*/
- assertEquals(3, dna1.getDBRefs().length);
- DBRefEntry dbRefEntry = dna1.getDBRefs()[2];
+ assertEquals(3, dna1.getDBRefs().size());
+ DBRefEntry dbRefEntry = dna1.getDBRefs().get(2);
assertSame(cds1Dss, dbRefEntry.getMap().getTo());
MapList dnaToCdsMapping = new MapList(new int[] { 4, 6, 10, 12 },
new int[] { 1, 6 }, 1, 1);
assertEquals(dnaToCdsMapping, dbRefEntry.getMap().getMap());
- assertEquals(3, dna2.getDBRefs().length);
- dbRefEntry = dna2.getDBRefs()[2];
+ assertEquals(3, dna2.getDBRefs().size());
+ dbRefEntry = dna2.getDBRefs().get(2);
assertSame(cds2Dss, dbRefEntry.getMap().getTo());
dnaToCdsMapping = new MapList(new int[] { 1, 3, 7, 9, 13, 15 },
new int[] { 1, 9 }, 1, 1);
/*
* verify CDS has added a dbref with mapping to cDNA
*/
- assertEquals(2, cds1Dss.getDBRefs().length);
- dbRefEntry = cds1Dss.getDBRefs()[1];
+ assertEquals(2, cds1Dss.getDBRefs().size());
+ dbRefEntry = cds1Dss.getDBRefs().get(1);
assertSame(dna1.getDatasetSequence(), dbRefEntry.getMap().getTo());
MapList cdsToDnaMapping = new MapList(new int[] { 1, 6 }, new int[] {
4, 6, 10, 12 }, 1, 1);
assertEquals(cdsToDnaMapping, dbRefEntry.getMap().getMap());
- assertEquals(2, cds2Dss.getDBRefs().length);
- dbRefEntry = cds2Dss.getDBRefs()[1];
+ assertEquals(2, cds2Dss.getDBRefs().size());
+ dbRefEntry = cds2Dss.getDBRefs().get(1);
assertSame(dna2.getDatasetSequence(), dbRefEntry.getMap().getTo());
cdsToDnaMapping = new MapList(new int[] { 1, 9 }, new int[] { 1, 3, 7,
9, 13, 15 }, 1, 1);
import jalview.util.MapList;
import jalview.ws.SequenceFetcher;
import jalview.ws.SequenceFetcherFactory;
+import jalview.ws.params.InvalidArgumentException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.testng.annotations.AfterClass;
DBRefEntry ref8 = new DBRefEntry("PFAM", "1", "A123");
// ENSEMBL is a source of either dna or protein sequence data
DBRefEntry ref9 = new DBRefEntry("ENSEMBL", "1", "A123");
- DBRefEntry[] refs = new DBRefEntry[] { ref1, ref2, ref3, ref4, ref5,
- ref6, ref7, ref8, ref9 };
+ List<DBRefEntry> refs = Arrays.asList(new DBRefEntry[] { ref1, ref2, ref3, ref4, ref5,
+ ref6, ref7, ref8, ref9 });
/*
* Just the DNA refs:
*/
- DBRefEntry[] found = DBRefUtils.selectDbRefs(true, refs);
- assertEquals(4, found.length);
- assertSame(ref5, found[0]);
- assertSame(ref6, found[1]);
- assertSame(ref7, found[2]);
- assertSame(ref9, found[3]);
+ List<DBRefEntry> found = DBRefUtils.selectDbRefs(true, refs);
+ assertEquals(4, found.size());
+ assertSame(ref5, found.get(0));
+ assertSame(ref6, found.get(1));
+ assertSame(ref7, found.get(2));
+ assertSame(ref9, found.get(3));
/*
* Just the protein refs:
*/
found = DBRefUtils.selectDbRefs(false, refs);
- assertEquals(4, found.length);
- assertSame(ref1, found[0]);
- assertSame(ref2, found[1]);
- assertSame(ref4, found[2]);
- assertSame(ref9, found[3]);
+ assertEquals(4, found.size());
+ assertSame(ref1, found.get(0));
+ assertSame(ref2, found.get(1));
+ assertSame(ref4, found.get(2));
+ assertSame(ref9, found.get(3));
}
/**
* and others to dna coding databases
*/
sources.clear();
- seq.setDBRefs(null);
+ try {
+ seq.setDBRefs(null);
+ } catch (InvalidArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
seq.addDBRef(new DBRefEntry("UNIPROT", "0", "A1234"));
seq.addDBRef(new DBRefEntry("EMBLCDS", "0", "E2347"));
SequenceI seq2 = new Sequence("Seq2", "MGKYQARLSS");
CrossRef testee = new CrossRef(al.getSequencesArray(), al);
AlignedCodonFrame acf = new AlignedCodonFrame();
boolean found = testee.searchDataset(true, dna1, dbref, result, acf,
- true);
+ true, DBRefUtils.SEARCH_MODE_FULL);
assertFalse(found);
assertTrue(result.isEmpty());
assertTrue(acf.isEmpty());
acf = new AlignedCodonFrame();
dbref = new DBRefEntry("UNIPROT", "0", "Q9ZTS2");
found = testee.searchDataset(!dna1.isProtein(), dna1, dbref, result,
- acf, false); // search dataset with a protein xref from a dna
+ acf, false, DBRefUtils.SEARCH_MODE_FULL); // search dataset with a protein xref from a dna
// sequence to locate the protein product
assertTrue(found);
assertEquals(1, result.size());
acf = new AlignedCodonFrame();
dbref = new DBRefEntry("UNIPROT", "0", "Q9ZTS2");
found = testee.searchDataset(!pep1.isProtein(), pep1, dbref, result,
- acf, false); // search dataset with a protein's direct dbref to
+ acf, false, DBRefUtils.SEARCH_MODE_FULL); // search dataset with a protein's direct dbref to
// locate dna sequences with matching xref
assertTrue(found);
assertEquals(1, result.size());
/*
* verify mappings added to Uniprot-to-EMBL dbrefs
*/
- Mapping mapping = p0ce19.getDBRefs()[0].getMap();
+ Mapping mapping = p0ce19.getDBRefs().get(0).getMap();
assertSame(j03321, mapping.getTo());
- mapping = p0ce19.getDBRefs()[1].getMap();
+ mapping = p0ce19.getDBRefs().get(1).getMap();
assertSame(x06707, mapping.getTo());
- mapping = p0ce20.getDBRefs()[0].getMap();
+ mapping = p0ce20.getDBRefs().get(0).getMap();
assertSame(j03321, mapping.getTo());
- mapping = p0ce20.getDBRefs()[1].getMap();
+ mapping = p0ce20.getDBRefs().get(1).getMap();
assertSame(x06707, mapping.getTo());
/*
* verify dbrefs on EMBL are mapped to alignment seqs
*/
- assertSame(p0ce19, j03321.getDBRefs()[0].getMap().getTo());
- assertSame(p0ce20, j03321.getDBRefs()[1].getMap().getTo());
- assertSame(p0ce19, x06707.getDBRefs()[0].getMap().getTo());
- assertSame(p0ce20, x06707.getDBRefs()[1].getMap().getTo());
+
+ assertSame(p0ce19, j03321.getDBRefs().get(0).getMap().getTo());
+ assertSame(p0ce20, j03321.getDBRefs().get(1).getMap().getTo());
+ assertSame(p0ce19, x06707.getDBRefs().get(0).getMap().getTo());
+ assertSame(p0ce20, x06707.getDBRefs().get(1).getMap().getTo());
/*
* verify new dbref on EMBL dbref mapping is copied to the
* original Uniprot sequence
*/
- assertEquals(4, p0ce19.getDBRefs().length);
- assertEquals("PIR", p0ce19.getDBRefs()[3].getSource());
- assertEquals("S01875", p0ce19.getDBRefs()[3].getAccessionId());
+ assertEquals(4, p0ce19.getDBRefs().size());
+ assertEquals("PIR", p0ce19.getDBRefs().get(3).getSource());
+ assertEquals("S01875", p0ce19.getDBRefs().get(3).getAccessionId());
}
@Test(groups = "Functional")
/*
* verify peptide.cdsdbref.peptidedbref is now mapped to peptide dataset
*/
- DBRefEntry[] dbRefs = pep.getDBRefs();
- assertEquals(2, dbRefs.length);
- assertSame(dna, dbRefs[0].map.to);
- assertSame(cds, dbRefs[1].map.to);
- assertEquals(1, dna.getDBRefs().length);
- assertSame(pep.getDatasetSequence(), dna.getDBRefs()[0].map.to);
- assertEquals(1, cds.getDBRefs().length);
- assertSame(pep.getDatasetSequence(), cds.getDBRefs()[0].map.to);
+ List<DBRefEntry> dbRefs = pep.getDBRefs();
+ assertEquals(2, dbRefs.size());
+ assertSame(dna, dbRefs.get(0).map.to);
+ assertSame(cds, dbRefs.get(1).map.to);
+ assertEquals(1, dna.getDBRefs().size());
+ assertSame(pep.getDatasetSequence(), dna.getDBRefs().get(0).map.to);
+ assertEquals(1, cds.getDBRefs().size());
+ assertSame(pep.getDatasetSequence(), cds.getDBRefs().get(0).map.to);
}
@Test(groups = { "Functional" })
import jalview.datamodel.PDBEntry.Type;
import jalview.gui.JvOptionPane;
import jalview.util.MapList;
+import jalview.ws.params.InvalidArgumentException;
import java.io.File;
import java.util.ArrayList;
assertNotNull(newDs);
assertNotSame(ds, newDs);
assertNotNull(sq.getDBRefs());
- assertEquals(1, sq.getDBRefs().length);
- assertNotSame(dbr1, sq.getDBRefs()[0]);
- assertEquals(dbr1, sq.getDBRefs()[0]);
+ assertEquals(1, sq.getDBRefs().size());
+ assertNotSame(dbr1, sq.getDBRefs().get(0));
+ assertEquals(dbr1, sq.getDBRefs().get(0));
/*
* internal delete with sequence features
assertEquals(4, sq.getEnd());
assertSame(ds, PA.getValue(sq, "datasetSequence"));
assertNotNull(sq.getDBRefs());
- assertEquals(1, sq.getDBRefs().length);
- assertSame(dbr1, sq.getDBRefs()[0]);
+ assertEquals(1, sq.getDBRefs().size());
+ assertSame(dbr1, sq.getDBRefs().get(0));
}
@Test(groups = { "Functional" })
new AlignmentAnnotation("Test annot", "Test annot description",
annots));
Assert.assertEquals(sq.getDescription(), "Test sequence description..");
- Assert.assertEquals(sq.getDBRefs().length, 5); // DBRefs are on dataset
+ Assert.assertEquals(sq.getDBRefs().size(), 5); // DBRefs are on dataset
// sequence
Assert.assertEquals(sq.getAllPDBEntries().size(), 4);
Assert.assertNotNull(sq.getAnnotation());
Assert.assertEquals(sq.getAnnotation()[0].annotations.length, 2);
- Assert.assertEquals(sq.getDatasetSequence().getDBRefs().length, 5); // same
+ Assert.assertEquals(sq.getDatasetSequence().getDBRefs().size(), 5); // same
// as
// sq.getDBRefs()
Assert.assertEquals(sq.getDatasetSequence().getAllPDBEntries().size(),
Assert.assertEquals(derived.getDescription(),
"Test sequence description..");
- Assert.assertEquals(derived.getDBRefs().length, 5); // come from dataset
+ Assert.assertEquals(derived.getDBRefs().size(), 5); // come from dataset
Assert.assertEquals(derived.getAllPDBEntries().size(), 4);
Assert.assertNotNull(derived.getAnnotation());
Assert.assertEquals(derived.getAnnotation()[0].annotations.length, 2);
- Assert.assertEquals(derived.getDatasetSequence().getDBRefs().length, 5);
+ Assert.assertEquals(derived.getDatasetSequence().getDBRefs().size(), 5);
Assert.assertEquals(derived.getDatasetSequence().getAllPDBEntries()
.size(), 4);
Assert.assertNotNull(derived.getDatasetSequence().getAnnotation());
// but that doesn't distinguish it from an aligned sequence
// which has not yet generated a dataset sequence
// NB getDBRef looks inside dataset sequence if not null
- DBRefEntry[] dbrefs = copy.getDBRefs();
- assertEquals(1, dbrefs.length);
- assertFalse(dbrefs[0] == seq1.getDBRefs()[0]);
- assertTrue(dbrefs[0].equals(seq1.getDBRefs()[0]));
+ List<DBRefEntry> dbrefs = copy.getDBRefs();
+ assertEquals(1, dbrefs.size());
+ assertFalse(dbrefs.get(0) == seq1.getDBRefs().get(0));
+ assertTrue(dbrefs.get(0).equals(seq1.getDBRefs().get(0)));
}
@Test(groups = { "Functional" })
// getDBRef looks inside dataset sequence and this is shared,
// so holds the same dbref objects
- DBRefEntry[] dbrefs = copy.getDBRefs();
- assertEquals(1, dbrefs.length);
- assertSame(dbrefs[0], seq1.getDBRefs()[0]);
+ List<DBRefEntry> dbrefs = copy.getDBRefs();
+ assertEquals(1, dbrefs.size());
+ assertSame(dbrefs.get(0), seq1.getDBRefs().get(0));
}
/**
assertNull(sq.getDBRefs());
DBRefEntry dbref = new DBRefEntry("Uniprot", "1", "P00340");
sq.addDBRef(dbref);
- assertEquals(1, sq.getDBRefs().length);
- assertSame(dbref, sq.getDBRefs()[0]);
+ assertEquals(1, sq.getDBRefs().size());
+ assertSame(dbref, sq.getDBRefs().get(0));
/*
* change of version - new entry
*/
DBRefEntry dbref2 = new DBRefEntry("Uniprot", "2", "P00340");
sq.addDBRef(dbref2);
- assertEquals(2, sq.getDBRefs().length);
- assertSame(dbref, sq.getDBRefs()[0]);
- assertSame(dbref2, sq.getDBRefs()[1]);
+ assertEquals(2, sq.getDBRefs().size());
+ assertSame(dbref, sq.getDBRefs().get(0));
+ assertSame(dbref2, sq.getDBRefs().get(1));
/*
* matches existing entry - not added
*/
sq.addDBRef(new DBRefEntry("UNIPROT", "1", "p00340"));
- assertEquals(2, sq.getDBRefs().length);
+ assertEquals(2, sq.getDBRefs().size());
/*
* different source = new entry
*/
DBRefEntry dbref3 = new DBRefEntry("UniRef", "1", "p00340");
sq.addDBRef(dbref3);
- assertEquals(3, sq.getDBRefs().length);
- assertSame(dbref3, sq.getDBRefs()[2]);
+ assertEquals(3, sq.getDBRefs().size());
+ assertSame(dbref3, sq.getDBRefs().get(2));
/*
* different ref = new entry
*/
DBRefEntry dbref4 = new DBRefEntry("UniRef", "1", "p00341");
sq.addDBRef(dbref4);
- assertEquals(4, sq.getDBRefs().length);
- assertSame(dbref4, sq.getDBRefs()[3]);
+ assertEquals(4, sq.getDBRefs().size());
+ assertSame(dbref4, sq.getDBRefs().get(3));
/*
* matching ref with a mapping - map updated
1, 1 }, 3, 1));
dbref5.setMap(map);
sq.addDBRef(dbref5);
- assertEquals(4, sq.getDBRefs().length);
- assertSame(dbref4, sq.getDBRefs()[3]);
+ assertEquals(4, sq.getDBRefs().size());
+ assertSame(dbref4, sq.getDBRefs().get(3));
assertSame(map, dbref4.getMap());
/*
DBRefEntry dbref6 = new DBRefEntry(dbref2.getSource(), "3",
dbref2.getAccessionId());
sq.addDBRef(dbref6);
- assertEquals(4, sq.getDBRefs().length);
- assertSame(dbref2, sq.getDBRefs()[1]);
+ assertEquals(4, sq.getDBRefs().size());
+ assertSame(dbref2, sq.getDBRefs().get(1));
assertEquals("3", dbref2.getVersion());
/*
DBRefEntry dbref7 = new DBRefEntry(dbref3.getSource(), "3",
dbref3.getAccessionId());
sq.addDBRef(dbref7);
- assertEquals(4, sq.getDBRefs().length);
- assertSame(dbref3, sq.getDBRefs()[2]);
+ assertEquals(4, sq.getDBRefs().size());
+ assertSame(dbref3, sq.getDBRefs().get(2));
assertEquals("3", dbref2.getVersion());
}
assertTrue(primaryDBRefs.isEmpty());
// empty dbrefs
- sq.setDBRefs(new DBRefEntry[] {});
+ try {
+ sq.setDBRefs(new ArrayList<DBRefEntry>());
+ } catch (InvalidArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
primaryDBRefs = sq.getPrimaryDBRefs();
assertTrue(primaryDBRefs.isEmpty());
import jalview.datamodel.DBRefEntry;
import jalview.gui.JvOptionPane;
+import jalview.util.JSONUtils;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.StringReader;
import java.net.URL;
import java.util.List;
+import org.json.simple.parser.ParseException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
EnsemblXref testee = new EnsemblXref("http://rest.ensembl.org", dbName,
dbVers)
{
- @Override
- protected BufferedReader getHttpResponse(URL url, List<String> ids)
- throws IOException
- {
- return new BufferedReader(new StringReader(JSON));
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Object getJSON(URL url, List<String> ids, int msDelay, int mode, String mapKey) throws IOException, ParseException
+ {
+ return ((List<Object>)JSONUtils.parse(JSON)).iterator();
+ }
+
};
// synonyms and GO terms are not returned
import jalview.datamodel.SequenceI;
import jalview.fts.api.FTSData;
import jalview.jbgui.GStructureChooser.FilterOption;
+import jalview.ws.params.InvalidArgumentException;
import java.util.Collection;
import java.util.Vector;
assertEquals(
"text:XYZ_1 OR text:XYZ_2 OR text:XYZ_3 OR text:XYZ_4 OR text:4kqy",
query);
- seq.setDBRefs(null);
+ try {
+ seq.setDBRefs(null);
+ } catch (InvalidArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
query = StructureChooser.buildQuery(seq);
assertEquals("text:4kqy", query);
* verify SNP variant feature(s) computed and added to protein
* first codon AGC varies to ACC giving S/T
*/
- DBRefEntry[] dbRefs = al.getSequenceAt(1).getDBRefs();
+ List<DBRefEntry> dbRefs = al.getSequenceAt(1).getDBRefs();
SequenceI peptide = null;
for (DBRefEntry dbref : dbRefs)
{
* verify variant feature(s) computed and added to protein
* last codon GCT varies to GGT giving A/G in the last peptide position
*/
- DBRefEntry[] dbRefs = al.getSequenceAt(3).getDBRefs();
+ List<DBRefEntry> dbRefs = al.getSequenceAt(3).getDBRefs();
SequenceI peptide = null;
for (DBRefEntry dbref : dbRefs)
{
* and GAG/GGG which is E/G in position 4
* the insertion variant is not transferred to the peptide
*/
- DBRefEntry[] dbRefs = al.findName("transcript3").getDBRefs();
+ List<DBRefEntry> dbRefs = al.findName("transcript3").getDBRefs();
SequenceI peptide = null;
for (DBRefEntry dbref : dbRefs)
{
PDBID);
AlignmentAnnotation subseq_tf=null;
- assertTrue(seq.getDBRefs() != null && seq.getDBRefs().length > 0);
+ assertTrue(seq.getDBRefs() != null && seq.getDBRefs().size() > 0);
if (!al.findAnnotations(seq, null, TEMP_FACTOR_AA).iterator().hasNext())
{
import jalview.datamodel.SequenceI;
import jalview.gui.JvOptionPane;
+import java.util.Arrays;
import java.util.List;
import org.testng.annotations.BeforeClass;
DBRefEntry ref2 = new DBRefEntry("UNIPROT", "1.2", "A12346");
// Source is converted to upper-case by this constructor!
DBRefEntry ref3 = new DBRefEntry("Uniprot", "1.2", "A12347");
- DBRefEntry[] dbrefs = new DBRefEntry[] { ref1, ref2, ref3 };
+ List<DBRefEntry> dbrefs = Arrays.asList(new DBRefEntry[] { ref1, ref2, ref3 });
String[] sources = new String[] { "EMBL", "UNIPROT" };
- DBRefEntry[] selected = DBRefUtils.selectRefs(dbrefs, sources);
- assertEquals(3, selected.length);
- assertSame(ref1, selected[0]);
- assertSame(ref2, selected[1]);
- assertSame(ref3, selected[2]);
+ List<DBRefEntry> selected = DBRefUtils.selectRefs(dbrefs, sources);
+ assertEquals(3, selected.size());
+ assertSame(ref1, selected.get(0));
+ assertSame(ref2, selected.get(1));
+ assertSame(ref3, selected.get(2));
sources = new String[] { "EMBL" };
selected = DBRefUtils.selectRefs(dbrefs, sources);
- assertEquals(1, selected.length);
- assertSame(ref1, selected[0]);
+ assertEquals(1, selected.size());
+ assertSame(ref1, selected.get(0));
sources = new String[] { "UNIPROT" };
selected = DBRefUtils.selectRefs(dbrefs, sources);
- assertEquals(2, selected.length);
- assertSame(ref2, selected[0]);
- assertSame(ref3, selected[1]);
+ assertEquals(2, selected.size());
+ assertSame(ref2, selected.get(0));
+ assertSame(ref3, selected.get(1));
sources = new String[] { "EMBLCDS" };
selected = DBRefUtils.selectRefs(dbrefs, sources);
sources = new String[] { "embl", "uniprot" };
selected = DBRefUtils.selectRefs(dbrefs, sources);
- assertEquals(3, selected.length);
- assertSame(ref1, selected[0]);
- assertSame(ref2, selected[1]);
- assertSame(ref3, selected[2]);
+ assertEquals(3, selected.size());
+ assertSame(ref1, selected.get(0));
+ assertSame(ref2, selected.get(1));
+ assertSame(ref3, selected.get(2));
}
/**
{
SequenceI seq = new Sequence("Seq1", "ABCD");
DBRefEntry ref = DBRefUtils.parseToDbRef(seq, "EMBL", "1.2", "a7890");
- DBRefEntry[] refs = seq.getDBRefs();
- assertEquals(1, refs.length);
- assertSame(ref, refs[0]);
+ List<DBRefEntry> refs = seq.getDBRefs();
+ assertEquals(1, refs.size());
+ assertSame(ref, refs.get(0));
assertEquals("EMBL", ref.getSource());
assertEquals("1.2", ref.getVersion());
assertEquals("a7890", ref.getAccessionId());
// TODO: correct PDBEntry and PDB DBRef accessions need to be generated for
// PDB ref in Stockholm
- DBRefEntry[] refs = seq.getDBRefs();
- assertEquals(1, refs.length);
- assertSame(ref, refs[0]);
+ List<DBRefEntry> refs = seq.getDBRefs();
+ assertEquals(1, refs.size());
+ assertSame(ref, refs.get(0));
assertEquals("PDB", ref.getSource());
assertEquals("1.2", ref.getVersion());
// DBRef id is pdbId + chain code
ref5.setMap(new Mapping(new MapList(new int[] { 1, 1 }, new int[] { 1,
1 }, 1, 1)));
- List<DBRefEntry> matches = DBRefUtils.searchRefs(new DBRefEntry[] {
- ref1, ref2, ref3, ref4, ref5 }, target);
+ List<DBRefEntry> matches = DBRefUtils.searchRefs(
+ Arrays.asList(new DBRefEntry[] {
+ ref1, ref2, ref3, ref4, ref5 }), target, DBRefUtils.SEARCH_MODE_FULL);
assertEquals(3, matches.size());
assertSame(ref1, matches.get(0));
assertSame(ref2, matches.get(1));
new int[] { 1, 1 }, 2, 2));
ref3.setMap(map3);
- List<DBRefEntry> matches = DBRefUtils.searchRefs(new DBRefEntry[] {
- ref1, ref2, ref3 }, target);
+ List<DBRefEntry> matches = DBRefUtils.searchRefs(
+ Arrays.asList(new DBRefEntry[] {
+ ref1, ref2, ref3 }), target, DBRefUtils.SEARCH_MODE_FULL);
assertEquals(2, matches.size());
assertSame(ref1, matches.get(0));
assertSame(ref2, matches.get(1));
ref5.setMap(new Mapping(new MapList(new int[] { 1, 1 }, new int[] { 1,
1 }, 1, 1)));
- DBRefEntry[] dbrefs = new DBRefEntry[] { ref1, ref2, ref3, ref4, ref5 };
+ List<DBRefEntry> dbrefs = Arrays.asList(new DBRefEntry[] {
+ ref1, ref2, ref3, ref4, ref5 });
List<DBRefEntry> matches = DBRefUtils.searchRefs(dbrefs, "A1234");
assertEquals(3, matches.size());
assertSame(ref1, matches.get(0));
ref5.setMap(new Mapping(new MapList(new int[] { 1, 1 }, new int[] { 1,
1 }, 1, 1)));
- List<DBRefEntry> matches = DBRefUtils.searchRefs(new DBRefEntry[] {
- ref1, ref2, ref3, ref4, ref5 }, target);
+ List<DBRefEntry> matches = DBRefUtils.searchRefs(
+ Arrays.asList(new DBRefEntry[] {
+ ref1, ref2, ref3, ref4, ref5 }), target, DBRefUtils.SEARCH_MODE_FULL);
assertEquals(4, matches.size());
assertSame(ref1, matches.get(0));
assertSame(ref2, matches.get(1));
@Test(groups = "Functional")
public void testArrayToList() throws JSONException
{
- assertNull(JSONUtils.arrayToList(null));
+ assertNull(JSONUtils.arrayToStringList(null));
JSONArray ja = new JSONArray();
- assertNull(JSONUtils.arrayToList(null));
+ assertNull(JSONUtils.arrayToStringList(null));
ja.add("hello");
- assertEquals(JSONUtils.arrayToList(ja), "hello");
+ assertEquals(JSONUtils.arrayToStringList(ja), "hello");
ja.add("world");
- assertEquals(JSONUtils.arrayToList(ja), "hello,world");
+ assertEquals(JSONUtils.arrayToStringList(ja), "hello,world");
}
}
MapList cds3Map = new MapList(new int[] { 4, 6, 10, 15 }, new int[] {
1, 3 }, 3, 1);
- DBRefEntry[] dbrefs = dna.getDBRefs();
- assertEquals(7, dbrefs.length);
+ List<DBRefEntry> dbrefs = dna.getDBRefs();
+ assertEquals(7, dbrefs.size());
- DBRefEntry dbRefEntry = dbrefs[0];
+ DBRefEntry dbRefEntry = dbrefs.get(0);
assertEquals("EMBL", dbRefEntry.getSource());
assertEquals("X07547", dbRefEntry.getAccessionId());
assertEquals("1", dbRefEntry.getVersion());
assertNull(dbRefEntry.getMap().getTo());
assertEquals(mapToSelf, dbRefEntry.getMap().getMap());
- dbRefEntry = dbrefs[1];
+ dbRefEntry = dbrefs.get(1);
// DBRefEntry constructor puts dbSource in upper case
assertEquals("EUROPEPMC", dbRefEntry.getSource());
assertEquals("PMC107176", dbRefEntry.getAccessionId());
assertEquals("9573186", dbRefEntry.getVersion());
assertNull(dbRefEntry.getMap());
- dbRefEntry = dbrefs[2];
+ dbRefEntry = dbrefs.get(2);
assertEquals("MD5", dbRefEntry.getSource());
assertEquals("ac73317", dbRefEntry.getAccessionId());
assertEquals("0", dbRefEntry.getVersion());
assertNull(dbRefEntry.getMap());
- dbRefEntry = dbrefs[3];
+ dbRefEntry = dbrefs.get(3);
assertEquals("UNIPROT", dbRefEntry.getSource());
assertEquals("B0BCM4", dbRefEntry.getAccessionId());
assertSame(peptides.get(1), dbRefEntry.getMap().getTo());
assertEquals(cds1Map, dbRefEntry.getMap().getMap());
- dbRefEntry = dbrefs[4];
+ dbRefEntry = dbrefs.get(4);
assertEquals("UNIPROT", dbRefEntry.getSource());
assertEquals("P0CE20", dbRefEntry.getAccessionId());
assertSame(peptides.get(2), dbRefEntry.getMap().getTo());
assertEquals(cds1Map, dbRefEntry.getMap().getMap());
- dbRefEntry = dbrefs[5];
+ dbRefEntry = dbrefs.get(5);
assertEquals("UNIPROT", dbRefEntry.getSource());
assertEquals("B0BCM3", dbRefEntry.getAccessionId());
assertSame(peptides.get(4), dbRefEntry.getMap().getTo());
assertEquals(cds2Map, dbRefEntry.getMap().getMap());
- dbRefEntry = dbrefs[6];
+ dbRefEntry = dbrefs.get(6);
assertEquals("EMBLCDSPROTEIN", dbRefEntry.getSource());
assertEquals("CAA12345.6", dbRefEntry.getAccessionId());
assertSame(peptides.get(5), dbRefEntry.getMap().getTo());
// dbrefs for first CDS EMBL product CAA30420.1
dbrefs = peptides.get(0).getDBRefs();
- assertEquals(5, dbrefs.length);
- assertEquals(DBRefSource.EMBL, dbrefs[0].getSource());
- assertEquals("CAA30420.1", dbrefs[0].getAccessionId());
+ assertEquals(5, dbrefs.size());
+ assertEquals(DBRefSource.EMBL, dbrefs.get(0).getSource());
+ assertEquals("CAA30420.1", dbrefs.get(0).getAccessionId());
// TODO: verify getPrimaryDBRefs() for peptide products
- assertEquals(cds1Map.getInverse(), dbrefs[0].getMap().getMap());
- assertEquals(DBRefSource.EMBLCDS, dbrefs[1].getSource());
- assertEquals("CAA30420.1", dbrefs[1].getAccessionId());
- assertEquals(proteinToCdsMap1, dbrefs[1].getMap().getMap());
- assertEquals(DBRefSource.EMBLCDSProduct, dbrefs[2].getSource());
- assertEquals("CAA30420.1", dbrefs[2].getAccessionId());
- assertNull(dbrefs[2].getMap());
+ assertEquals(cds1Map.getInverse(), dbrefs.get(0).getMap().getMap());
+ assertEquals(DBRefSource.EMBLCDS, dbrefs.get(1).getSource());
+ assertEquals("CAA30420.1", dbrefs.get(1).getAccessionId());
+ assertEquals(proteinToCdsMap1, dbrefs.get(1).getMap().getMap());
+ assertEquals(DBRefSource.EMBLCDSProduct, dbrefs.get(2).getSource());
+ assertEquals("CAA30420.1", dbrefs.get(2).getAccessionId());
+ assertNull(dbrefs.get(2).getMap());
assertEquals(new DBRefEntry(DBRefSource.UNIPROT, "2.1", "B0BCM4"),
- dbrefs[3]);
- assertNull(dbrefs[3].getMap());
+ dbrefs.get(3));
+ assertNull(dbrefs.get(3).getMap());
assertEquals(new DBRefEntry(DBRefSource.UNIPROT, "0", "P0CE20"),
- dbrefs[4]);
- assertNull(dbrefs[4].getMap());
+ dbrefs.get(4));
+ assertNull(dbrefs.get(4).getMap());
// dbrefs for first CDS first Uniprot xref
dbrefs = peptides.get(1).getDBRefs();
- assertEquals(2, dbrefs.length);
+ assertEquals(2, dbrefs.size());
assertEquals(new DBRefEntry(DBRefSource.UNIPROT, "2.1", "B0BCM4"),
- dbrefs[0]);
- assertNull(dbrefs[0].getMap());
- assertEquals(DBRefSource.EMBL, dbrefs[1].getSource());
- assertEquals("X07547", dbrefs[1].getAccessionId());
- assertEquals(cds1Map.getInverse(), dbrefs[1].getMap().getMap());
+ dbrefs.get(0));
+ assertNull(dbrefs.get(0).getMap());
+ assertEquals(DBRefSource.EMBL, dbrefs.get(1).getSource());
+ assertEquals("X07547", dbrefs.get(1).getAccessionId());
+ assertEquals(cds1Map.getInverse(), dbrefs.get(1).getMap().getMap());
// dbrefs for first CDS second Uniprot xref
dbrefs = peptides.get(2).getDBRefs();
- assertEquals(2, dbrefs.length);
+ assertEquals(2, dbrefs.size());
assertEquals(new DBRefEntry(DBRefSource.UNIPROT, "0", "P0CE20"),
- dbrefs[0]);
- assertNull(dbrefs[0].getMap());
- assertEquals(DBRefSource.EMBL, dbrefs[1].getSource());
- assertEquals("X07547", dbrefs[1].getAccessionId());
- assertEquals(cds1Map.getInverse(), dbrefs[1].getMap().getMap());
+ dbrefs.get(0));
+ assertNull(dbrefs.get(0).getMap());
+ assertEquals(DBRefSource.EMBL, dbrefs.get(1).getSource());
+ assertEquals("X07547", dbrefs.get(1).getAccessionId());
+ assertEquals(cds1Map.getInverse(), dbrefs.get(1).getMap().getMap());
// dbrefs for second CDS EMBL product CAA30421.1
dbrefs = peptides.get(3).getDBRefs();
- assertEquals(4, dbrefs.length);
- assertEquals(DBRefSource.EMBL, dbrefs[0].getSource());
- assertEquals("CAA30421.1", dbrefs[0].getAccessionId());
- assertEquals(cds2Map.getInverse(), dbrefs[0].getMap().getMap());
- assertEquals(DBRefSource.EMBLCDS, dbrefs[1].getSource());
- assertEquals("CAA30421.1", dbrefs[1].getAccessionId());
- assertEquals(proteinToCdsMap1, dbrefs[1].getMap().getMap());
- assertEquals(DBRefSource.EMBLCDSProduct, dbrefs[2].getSource());
- assertEquals("CAA30421.1", dbrefs[2].getAccessionId());
- assertNull(dbrefs[2].getMap());
+ assertEquals(4, dbrefs.size());
+ assertEquals(DBRefSource.EMBL, dbrefs.get(0).getSource());
+ assertEquals("CAA30421.1", dbrefs.get(0).getAccessionId());
+ assertEquals(cds2Map.getInverse(), dbrefs.get(0).getMap().getMap());
+ assertEquals(DBRefSource.EMBLCDS, dbrefs.get(1).getSource());
+ assertEquals("CAA30421.1", dbrefs.get(1).getAccessionId());
+ assertEquals(proteinToCdsMap1, dbrefs.get(1).getMap().getMap());
+ assertEquals(DBRefSource.EMBLCDSProduct, dbrefs.get(2).getSource());
+ assertEquals("CAA30421.1", dbrefs.get(2).getAccessionId());
+ assertNull(dbrefs.get(2).getMap());
assertEquals(new DBRefEntry(DBRefSource.UNIPROT, "0", "B0BCM3"),
- dbrefs[3]);
- assertNull(dbrefs[3].getMap());
+ dbrefs.get(3));
+ assertNull(dbrefs.get(3).getMap());
// dbrefs for second CDS second Uniprot xref
dbrefs = peptides.get(4).getDBRefs();
- assertEquals(2, dbrefs.length);
+ assertEquals(2, dbrefs.size());
assertEquals(new DBRefEntry(DBRefSource.UNIPROT, "0", "B0BCM3"),
- dbrefs[0]);
- assertNull(dbrefs[0].getMap());
- assertEquals(DBRefSource.EMBL, dbrefs[1].getSource());
- assertEquals("X07547", dbrefs[1].getAccessionId());
- assertEquals(cds2Map.getInverse(), dbrefs[1].getMap().getMap());
+ dbrefs.get(0));
+ assertNull(dbrefs.get(0).getMap());
+ assertEquals(DBRefSource.EMBL, dbrefs.get(1).getSource());
+ assertEquals("X07547", dbrefs.get(1).getAccessionId());
+ assertEquals(cds2Map.getInverse(), dbrefs.get(1).getMap().getMap());
// dbrefs for third CDS inferred EMBL product CAA12345.6
dbrefs = peptides.get(5).getDBRefs();
- assertEquals(3, dbrefs.length);
- assertEquals(DBRefSource.EMBL, dbrefs[0].getSource());
- assertEquals("CAA12345.6", dbrefs[0].getAccessionId());
- assertEquals(cds3Map.getInverse(), dbrefs[0].getMap().getMap());
- assertEquals(DBRefSource.EMBLCDS, dbrefs[1].getSource());
- assertEquals("CAA12345.6", dbrefs[1].getAccessionId());
- assertEquals(proteinToCdsMap2, dbrefs[1].getMap().getMap());
- assertEquals(DBRefSource.EMBLCDSProduct, dbrefs[2].getSource());
- assertEquals("CAA12345.6", dbrefs[2].getAccessionId());
- assertNull(dbrefs[2].getMap());
+ assertEquals(3, dbrefs.size());
+ assertEquals(DBRefSource.EMBL, dbrefs.get(0).getSource());
+ assertEquals("CAA12345.6", dbrefs.get(0).getAccessionId());
+ assertEquals(cds3Map.getInverse(), dbrefs.get(0).getMap().getMap());
+ assertEquals(DBRefSource.EMBLCDS, dbrefs.get(1).getSource());
+ assertEquals("CAA12345.6", dbrefs.get(1).getAccessionId());
+ assertEquals(proteinToCdsMap2, dbrefs.get(1).getMap().getMap());
+ assertEquals(DBRefSource.EMBLCDSProduct, dbrefs.get(2).getSource());
+ assertEquals("CAA12345.6", dbrefs.get(2).getAccessionId());
+ assertNull(dbrefs.get(2).getMap());
}
@Test(groups = "Functional")
SequenceI sq = al.getSequenceAt(0);
// suppress this check as only Uniprot and PDB acquire PDB refs
// assertTrue(sq.getAllPDBEntries().size() > 0, "No PDBEntry on sequence.");
- assertTrue(sq.getDBRefs().length > 0, "No DBRef on sequence.");
+ assertTrue(sq.getDBRefs().size() > 0, "No DBRef on sequence.");
// suppress this test as only certain databases provide 'primary' dbrefs
// assertFalse(sq.getPrimaryDBRefs().isEmpty());
int length = AlignSeq.extractGaps("-. ", sq.getSequenceAsString())
is).get(0);
SequenceI seq = new Uniprot().uniprotEntryToSequence(entry);
assertNotNull(seq);
- assertEquals(6, seq.getDBRefs().length); // 2*Uniprot, PDB, PDBsum, 2*EMBL
+ assertEquals(6, seq.getDBRefs().size()); // 2*Uniprot, PDB, PDBsum, 2*EMBL
}
FeatureProperties.isCodingFeature(embl.getDbSource(),
sfs.get(0).getType()));
assertEquals(embl.getDbSource(), sfs.get(0).getFeatureGroup());
- DBRefEntry[] dr = DBRefUtils.selectRefs(seq.getDBRefs(),
+ List<DBRefEntry> dr = DBRefUtils.selectRefs(seq.getDBRefs(),
new String[] { DBRefSource.UNIPROT });
assertNotNull(dr);
- assertEquals("Expected a single Uniprot cross reference", 1, dr.length);
- assertEquals("Expected cross reference map to be one amino acid", dr[0]
+ assertEquals("Expected a single Uniprot cross reference", 1, dr.size());
+ assertEquals("Expected cross reference map to be one amino acid", dr.get(0)
.getMap().getMappedWidth(), 1);
- assertEquals("Expected local reference map to be 3 nucleotides", dr[0]
+ assertEquals("Expected local reference map to be 3 nucleotides", dr.get(0)
.getMap().getWidth(), 3);
AlignmentI sprods = new CrossRef(alsq.getSequencesArray(), alsq)
- .findXrefSequences(dr[0].getSource(), true);
+ .findXrefSequences(dr.get(0).getSource(), true);
assertNotNull(
"Couldn't recover cross reference sequence from dataset. Was it ever added ?",
sprods);
assertEquals("Didn't xref right number of records", 1,
sprods.getHeight());
SequenceI proteinSeq = sprods.getSequenceAt(0);
- assertEquals(proteinSeq.getSequenceAsString(), dr[0].getMap().getTo()
+ assertEquals(proteinSeq.getSequenceAsString(), dr.get(0).getMap().getTo()
.getSequenceAsString());
- assertEquals(dr[0].getSource() + "|" + dr[0].getAccessionId(),
+ assertEquals(dr.get(0).getSource() + "|" + dr.get(0).getAccessionId(),
proteinSeq.getName());
}
}