*/
package jalview.datamodel;
+import java.util.Locale;
+
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
assertEquals("getInsertionsAsBits didn't mark expected number of gaps",
6, gapfield.cardinality());
- assertEquals("getInsertionsAsBits not correct.", expectedgaps, gapfield);
+ assertEquals("getInsertionsAsBits not correct.", expectedgaps,
+ gapfield);
}
@Test(groups = ("Functional"))
@Test(groups = ("Functional"))
public void testIsProteinWithXorNAmbiguityCodes()
{
- // test Protein with N - poly asparagine
+ // test Protein with N - poly asparagine
assertTrue(new Sequence("prot", "ASDFASDFASDFNNNNNNNNN").isProtein());
assertTrue(new Sequence("prot", "NNNNNNNNNNNNNNNNNNNNN").isProtein());
// test Protein with X
assertTrue(seq.getAlignmentAnnotations(null, null).isEmpty());
}
-
@Test(groups = { "Functional" })
public void testGetAlignmentAnnotations_forCalcIdLabelAndDescription()
{
/**
* null matching should fail
*/
- assertTrue(seq.getAlignmentAnnotations("calcId3", "label2",null).isEmpty());
-
- assertTrue(seq.getAlignmentAnnotations("calcId2", "label3",null).isEmpty());
- assertTrue(seq.getAlignmentAnnotations("calcId3", "label5",null).isEmpty());
- assertTrue(seq.getAlignmentAnnotations("calcId2", null,null).isEmpty());
- assertTrue(seq.getAlignmentAnnotations(null, "label3",null).isEmpty());
- assertTrue(seq.getAlignmentAnnotations(null, null,null).isEmpty());
+ assertTrue(seq.getAlignmentAnnotations("calcId3", "label2", null)
+ .isEmpty());
+
+ assertTrue(seq.getAlignmentAnnotations("calcId2", "label3", null)
+ .isEmpty());
+ assertTrue(seq.getAlignmentAnnotations("calcId3", "label5", null)
+ .isEmpty());
+ assertTrue(
+ seq.getAlignmentAnnotations("calcId2", null, null).isEmpty());
+ assertTrue(seq.getAlignmentAnnotations(null, "label3", null).isEmpty());
+ assertTrue(seq.getAlignmentAnnotations(null, null, null).isEmpty());
}
/**
public void testAddAlignmentAnnotation()
{
assertNull(seq.getAnnotation());
- final AlignmentAnnotation annotation = new AlignmentAnnotation("a",
- "b", 2d);
+ final AlignmentAnnotation annotation = new AlignmentAnnotation("a", "b",
+ 2d);
assertNull(annotation.sequenceRef);
seq.addAlignmentAnnotation(annotation);
assertSame(seq, annotation.sequenceRef);
/*
* SequenceFeature on sequence
*/
- SequenceFeature sf = new SequenceFeature("Cath", "desc", 2, 4, 2f, null);
+ SequenceFeature sf = new SequenceFeature("Cath", "desc", 2, 4, 2f,
+ null);
sq.addSequenceFeature(sf);
List<SequenceFeature> sfs = sq.getSequenceFeatures();
assertEquals(1, sfs.size());
try
{
sq.getDatasetSequence().setDatasetSequence(sq); // loop!
- Assert.fail("Expected Error to be raised when calling setDatasetSequence with self reference");
+ Assert.fail(
+ "Expected Error to be raised when calling setDatasetSequence with self reference");
} catch (IllegalArgumentException e)
{
// TODO Jalview error/exception class for raising implementation errors
- assertTrue(e.getMessage().toLowerCase()
+ assertTrue(e.getMessage().toLowerCase(Locale.ROOT)
.contains("implementation error"));
}
assertTrue(sq.getSequenceFeatures().isEmpty());
public void testCreateDatasetSequence()
{
SequenceI sq = new Sequence("my", "ASDASD");
- sq.addSequenceFeature(new SequenceFeature("type", "desc", 1, 10, 1f,
- "group"));
+ sq.addSequenceFeature(
+ new SequenceFeature("type", "desc", 1, 10, 1f, "group"));
sq.addDBRef(new DBRefEntry("source", "version", "accession"));
assertNull(sq.getDatasetSequence());
assertNotNull(PA.getValue(sq, "sequenceFeatureStore"));
DBRefEntry pdb1pdb = new DBRefEntry("PDB", "version1", "1PDB");
DBRefEntry pdb2pdb = new DBRefEntry("PDB", "version2", "2PDB");
- List<DBRefEntry> primRefs = Arrays.asList(new DBRefEntry[] { pdb1pdb,
- pdb2pdb });
+ List<DBRefEntry> primRefs = Arrays
+ .asList(new DBRefEntry[]
+ { pdb1pdb, pdb2pdb });
sq.getDatasetSequence().addDBRef(pdb1pdb); // should do nothing
sq.getDatasetSequence().addDBRef(pdb2pdb); // should do nothing
- sq.getDatasetSequence().addDBRef(
- new DBRefEntry("PDB", "version3", "3PDB")); // should do nothing
- sq.getDatasetSequence().addDBRef(
- new DBRefEntry("PDB", "version4", "4PDB")); // should do nothing
+ sq.getDatasetSequence()
+ .addDBRef(new DBRefEntry("PDB", "version3", "3PDB")); // should do
+ // nothing
+ sq.getDatasetSequence()
+ .addDBRef(new DBRefEntry("PDB", "version4", "4PDB")); // should do
+ // nothing
PDBEntry pdbe1a = new PDBEntry("1PDB", "A", Type.PDB, "filePath/test1");
PDBEntry pdbe1b = new PDBEntry("1PDB", "B", Type.PDB, "filePath/test1");
/*
* test we added pdb entries to the dataset sequence
*/
- Assert.assertEquals(sq.getDatasetSequence().getAllPDBEntries(), Arrays
- .asList(new PDBEntry[] { pdbe1a, pdbe1b, pdbe2a, pdbe2b }),
+ Assert.assertEquals(sq.getDatasetSequence().getAllPDBEntries(),
+ Arrays.asList(new PDBEntry[]
+ { pdbe1a, pdbe1b, pdbe2a, pdbe2b }),
"PDB Entries were not found on dataset sequence.");
/*
* we should recover a pdb entry that is on the dataset sequence via PDBEntry
*/
- Assert.assertEquals(pdbe1a,
- sq.getDatasetSequence().getPDBEntry("1PDB"),
+ Assert.assertEquals(pdbe1a, sq.getDatasetSequence().getPDBEntry("1PDB"),
"PDB Entry '1PDB' not found on dataset sequence via getPDBEntry.");
ArrayList<Annotation> annotsList = new ArrayList<>();
System.out.println(">>>>>> " + sq.getSequenceAsString().length());
Annotation[] annots = annotsList.toArray(new Annotation[0]);
sq.addAlignmentAnnotation(new AlignmentAnnotation("Test annot",
"Test annot description", annots));
- sq.getDatasetSequence().addAlignmentAnnotation(
- new AlignmentAnnotation("Test annot", "Test annot description",
- annots));
+ sq.getDatasetSequence().addAlignmentAnnotation(new AlignmentAnnotation(
+ "Test annot", "Test annot description", annots));
Assert.assertEquals(sq.getDescription(), "Test sequence description..");
Assert.assertEquals(sq.getDBRefs().size(), 5); // DBRefs are on dataset
// sequence
Assert.assertNotNull(derived.getAnnotation());
Assert.assertEquals(derived.getAnnotation()[0].annotations.length, 2);
Assert.assertEquals(derived.getDatasetSequence().getDBRefs().size(), 5);
- Assert.assertEquals(derived.getDatasetSequence().getAllPDBEntries()
- .size(), 4);
+ Assert.assertEquals(
+ derived.getDatasetSequence().getAllPDBEntries().size(), 4);
Assert.assertNotNull(derived.getDatasetSequence().getAnnotation());
assertEquals("CD", derived.getSequenceAsString());
assertEquals(6, sq.getEnd());
SequenceI derived = sq.deriveSequence();
assertEquals("ABCDEF", derived.getSequenceAsString());
- assertEquals("ABCDEF", derived.getDatasetSequence()
- .getSequenceAsString());
+ assertEquals("ABCDEF",
+ derived.getDatasetSequence().getSequenceAsString());
}
/**
assertNull(sq.getDatasetSequence());
SequenceI derived = sq.deriveSequence();
assertEquals("AB-C.D EF", derived.getSequenceAsString());
- assertEquals("ABCDEF", derived.getDatasetSequence()
- .getSequenceAsString());
+ assertEquals("ABCDEF",
+ derived.getDatasetSequence().getSequenceAsString());
}
@Test(groups = { "Functional" })
{
SequenceI seq1 = new Sequence("Seq1", "AB-C.D EF");
seq1.setDescription("description");
- seq1.addAlignmentAnnotation(new AlignmentAnnotation("label", "desc",
- 1.3d));
- seq1.addSequenceFeature(new SequenceFeature("type", "desc", 22, 33,
- 12.4f, "group"));
+ seq1.addAlignmentAnnotation(
+ new AlignmentAnnotation("label", "desc", 1.3d));
+ seq1.addSequenceFeature(
+ new SequenceFeature("type", "desc", 22, 33, 12.4f, "group"));
seq1.addPDBId(new PDBEntry("1A70", "B", Type.PDB, "File"));
seq1.addDBRef(new DBRefEntry("EMBL", "1.2", "AZ12345"));
SequenceI seq1 = new Sequence("Seq1", "AB-C.D EF");
seq1.createDatasetSequence();
seq1.setDescription("description");
- seq1.addAlignmentAnnotation(new AlignmentAnnotation("label", "desc",
- 1.3d));
+ seq1.addAlignmentAnnotation(
+ new AlignmentAnnotation("label", "desc", 1.3d));
// JAL-2046 - what is the contract for using a derived sequence's
// addSequenceFeature ?
- seq1.addSequenceFeature(new SequenceFeature("type", "desc", 22, 33,
- 12.4f, "group"));
+ seq1.addSequenceFeature(
+ new SequenceFeature("type", "desc", 22, 33, 12.4f, "group"));
seq1.addPDBId(new PDBEntry("1A70", "B", Type.PDB, "File"));
// here we add DBRef to the dataset sequence:
- seq1.getDatasetSequence().addDBRef(
- new DBRefEntry("EMBL", "1.2", "AZ12345"));
+ seq1.getDatasetSequence()
+ .addDBRef(new DBRefEntry("EMBL", "1.2", "AZ12345"));
SequenceI copy = new Sequence(seq1);
{
SequenceI sq = new Sequence("", "abcde");
// type may not be null
- assertFalse(sq.addSequenceFeature(new SequenceFeature(null, "desc", 4,
- 8, 0f, null)));
- assertTrue(sq.addSequenceFeature(new SequenceFeature("Cath", "desc", 4,
- 8, 0f, null)));
+ assertFalse(sq.addSequenceFeature(
+ new SequenceFeature(null, "desc", 4, 8, 0f, null)));
+ assertTrue(sq.addSequenceFeature(
+ new SequenceFeature("Cath", "desc", 4, 8, 0f, null)));
// can't add a duplicate feature
- assertFalse(sq.addSequenceFeature(new SequenceFeature("Cath", "desc",
- 4, 8, 0f, null)));
+ assertFalse(sq.addSequenceFeature(
+ new SequenceFeature("Cath", "desc", 4, 8, 0f, null)));
// can add a different feature
- assertTrue(sq.addSequenceFeature(new SequenceFeature("Scop", "desc", 4,
- 8, 0f, null))); // different type
- assertTrue(sq.addSequenceFeature(new SequenceFeature("Cath",
- "description", 4, 8, 0f, null)));// different description
- assertTrue(sq.addSequenceFeature(new SequenceFeature("Cath", "desc", 3,
- 8, 0f, null))); // different start position
- assertTrue(sq.addSequenceFeature(new SequenceFeature("Cath", "desc", 4,
- 9, 0f, null))); // different end position
- assertTrue(sq.addSequenceFeature(new SequenceFeature("Cath", "desc", 4,
- 8, 1f, null))); // different score
- assertTrue(sq.addSequenceFeature(new SequenceFeature("Cath", "desc", 4,
- 8, Float.NaN, null))); // score NaN
- assertTrue(sq.addSequenceFeature(new SequenceFeature("Cath", "desc", 4,
- 8, 0f, "Metal"))); // different group
+ assertTrue(sq.addSequenceFeature(
+ new SequenceFeature("Scop", "desc", 4, 8, 0f, null))); // different
+ // type
+ assertTrue(sq.addSequenceFeature(
+ new SequenceFeature("Cath", "description", 4, 8, 0f, null)));// different
+ // description
+ assertTrue(sq.addSequenceFeature(
+ new SequenceFeature("Cath", "desc", 3, 8, 0f, null))); // different
+ // start
+ // position
+ assertTrue(sq.addSequenceFeature(
+ new SequenceFeature("Cath", "desc", 4, 9, 0f, null))); // different
+ // end
+ // position
+ assertTrue(sq.addSequenceFeature(
+ new SequenceFeature("Cath", "desc", 4, 8, 1f, null))); // different
+ // score
+ assertTrue(sq.addSequenceFeature(
+ new SequenceFeature("Cath", "desc", 4, 8, Float.NaN, null))); // score
+ // NaN
+ assertTrue(sq.addSequenceFeature(
+ new SequenceFeature("Cath", "desc", 4, 8, 0f, "Metal"))); // different
+ // group
assertEquals(8, sq.getFeatures().getAllFeatures().size());
}
* matching ref with a mapping - map updated
*/
DBRefEntry dbref5 = new DBRefEntry("UniRef", "1", "p00341");
- Mapping map = new Mapping(new MapList(new int[] { 1, 3 }, new int[] {
- 1, 1 }, 3, 1));
+ Mapping map = new Mapping(
+ new MapList(new int[]
+ { 1, 3 }, new int[] { 1, 1 }, 3, 1));
dbref5.setMap(map);
sq.addDBRef(dbref5);
assertEquals(4, sq.getDBRefs().size());
assertTrue(primaryDBRefs.isEmpty());
// empty dbrefs
- sq.setDBRefs(null);
+ sq.setDBRefs(null);
primaryDBRefs = sq.getPrimaryDBRefs();
assertTrue(primaryDBRefs.isEmpty());
// primary - uniprot with congruent map
DBRefEntry upentry2 = new DBRefEntry("UNIPROT", "0", "Q04762");
- upentry2.setMap(new Mapping(null, new MapList(new int[] { 10, 22 },
- new int[] { 10, 22 }, 1, 1)));
+ upentry2.setMap(
+ new Mapping(null, new MapList(new int[]
+ { 10, 22 }, new int[] { 10, 22 }, 1, 1)));
sq.addDBRef(upentry2);
// primary - uniprot with map of enclosing sequence
DBRefEntry upentry3 = new DBRefEntry("UNIPROT", "0", "Q04763");
- upentry3.setMap(new Mapping(null, new MapList(new int[] { 8, 24 },
- new int[] { 8, 24 }, 1, 1)));
+ upentry3.setMap(
+ new Mapping(null, new MapList(new int[]
+ { 8, 24 }, new int[] { 8, 24 }, 1, 1)));
sq.addDBRef(upentry3);
// not primary - uniprot with map of sub-sequence (5')
DBRefEntry upentry4 = new DBRefEntry("UNIPROT", "0", "Q04764");
- upentry4.setMap(new Mapping(null, new MapList(new int[] { 10, 18 },
- new int[] { 10, 18 }, 1, 1)));
+ upentry4.setMap(
+ new Mapping(null, new MapList(new int[]
+ { 10, 18 }, new int[] { 10, 18 }, 1, 1)));
sq.addDBRef(upentry4);
// not primary - uniprot with map that overlaps 3'
DBRefEntry upentry5 = new DBRefEntry("UNIPROT", "0", "Q04765");
- upentry5.setMap(new Mapping(null, new MapList(new int[] { 12, 22 },
- new int[] { 12, 22 }, 1, 1)));
+ upentry5.setMap(
+ new Mapping(null, new MapList(new int[]
+ { 12, 22 }, new int[] { 12, 22 }, 1, 1)));
sq.addDBRef(upentry5);
// not primary - uniprot with map to different coordinates frame
DBRefEntry upentry6 = new DBRefEntry("UNIPROT", "0", "Q04766");
- upentry6.setMap(new Mapping(null, new MapList(new int[] { 12, 18 },
- new int[] { 112, 118 }, 1, 1)));
+ upentry6.setMap(
+ new Mapping(null, new MapList(new int[]
+ { 12, 18 }, new int[] { 112, 118 }, 1, 1)));
sq.addDBRef(upentry6);
// not primary - dbref to 'non-core' database
// add corroborating PDB entry for primary DBref -
// needs to have a file as well as matching ID
// note PDB ID is not treated as case sensitive
- sq.addPDBId(new PDBEntry("1QIP", null, Type.PDB, new File("/blah")
- .toString()));
+ sq.addPDBId(new PDBEntry("1QIP", null, Type.PDB,
+ new File("/blah").toString()));
// not valid DBRef - no file..
sq.addPDBId(new PDBEntry("1AAA", null, null, null));
@Test(groups = { "Functional" })
public void testGetPrimaryDBRefs_nucleotide()
{
- SequenceI sq = new Sequence("aseq", "TGATCACTCGACTAGCATCAGCATA", 10, 34);
+ SequenceI sq = new Sequence("aseq", "TGATCACTCGACTAGCATCAGCATA", 10,
+ 34);
// primary - Ensembl
DBRefEntry dbr1 = new DBRefEntry("ENSEMBL", "0", "ENSG1234");
// not primary - Ensembl 'transcript' mapping of sub-sequence
DBRefEntry dbr2 = new DBRefEntry("ENSEMBL", "0", "ENST1234");
- dbr2.setMap(new Mapping(null, new MapList(new int[] { 15, 25 },
- new int[] { 1, 11 }, 1, 1)));
+ dbr2.setMap(
+ new Mapping(null, new MapList(new int[]
+ { 15, 25 }, new int[] { 1, 11 }, 1, 1)));
sq.addDBRef(dbr2);
// primary - EMBL with congruent map
DBRefEntry dbr3 = new DBRefEntry("EMBL", "0", "J1234");
- dbr3.setMap(new Mapping(null, new MapList(new int[] { 10, 34 },
- new int[] { 10, 34 }, 1, 1)));
+ dbr3.setMap(
+ new Mapping(null, new MapList(new int[]
+ { 10, 34 }, new int[] { 10, 34 }, 1, 1)));
sq.addDBRef(dbr3);
// not primary - to non-core database
seq.addPDBId(pdbe5);
assertEquals(4, seq.getAllPDBEntries().size());
assertSame(pdbe5, seq.getAllPDBEntries().get(3));
-
- // add with a fake pdbid
+
+ // add with a fake pdbid
// (models don't have an embedded ID)
String realId = "RealIDQ";
- PDBEntry pdbe6 = new PDBEntry(realId,null,Type.PDB,"real/localpath");
- PDBEntry pdbe7 = new PDBEntry("RealID/real/localpath","C",Type.MMCIF,"real/localpath");
+ PDBEntry pdbe6 = new PDBEntry(realId, null, Type.PDB, "real/localpath");
+ PDBEntry pdbe7 = new PDBEntry("RealID/real/localpath", "C", Type.MMCIF,
+ "real/localpath");
pdbe7.setFakedPDBId(true);
seq.addPDBId(pdbe6);
- assertEquals(5,seq.getAllPDBEntries().size());
+ assertEquals(5, seq.getAllPDBEntries().size());
seq.addPDBId(pdbe7);
- assertEquals(5,seq.getAllPDBEntries().size());
+ assertEquals(5, seq.getAllPDBEntries().size());
assertFalse(pdbe6.fakedPDBId());
- assertSame(pdbe6,seq.getAllPDBEntries().get(4));
- assertEquals("C",pdbe6.getChainCode());
+ assertSame(pdbe6, seq.getAllPDBEntries().get(4));
+ assertEquals("C", pdbe6.getChainCode());
assertEquals(realId, pdbe6.getId());
}
@Test(
- groups = { "Functional" },
- expectedExceptions = { IllegalArgumentException.class })
+ groups =
+ { "Functional" },
+ expectedExceptions =
+ { IllegalArgumentException.class })
public void testSetDatasetSequence_toSelf()
{
seq.setDatasetSequence(seq);
}
@Test(
- groups = { "Functional" },
- expectedExceptions = { IllegalArgumentException.class })
+ groups =
+ { "Functional" },
+ expectedExceptions =
+ { IllegalArgumentException.class })
public void testSetDatasetSequence_cascading()
{
SequenceI seq2 = new Sequence("Seq2", "xyz");
"desc", 13, 14, 2f, null);
sq.addSequenceFeature(sfContactFG);
// add single position feature at [I]
- SequenceFeature sfI = new SequenceFeature("Disulfide Bond",
- "desc", 16, 16, null);
+ SequenceFeature sfI = new SequenceFeature("Disulfide Bond", "desc", 16,
+ 16, null);
sq.addSequenceFeature(sfI);
// no features in columns 1-2 (-A)
Sequence sq = new Sequence("test/8-13", "-A--BCD-EF--");
final int tok = (int) PA.getValue(sq, "changeCount");
assertEquals(1, tok);
-
+
// find F pos given A - lastCol gets set in cursor
assertEquals(13,
sq.findPosition(10, new SequenceCursor(sq, 8, 2, tok)));
sq.findPosition(2, new SequenceCursor(sq, 13, 10, tok)));
assertEquals("test:Pos8:Col2:startCol2:endCol10:tok1",
PA.getValue(sq, "cursor").toString());
-
+
// find C pos given C (neither startCol nor endCol is set)
assertEquals(10,
sq.findPosition(6, new SequenceCursor(sq, 10, 6, tok)));
public void testFindPosition_withCursorAndEdits()
{
Sequence sq = new Sequence("test/8-13", "-A--BCD-EF--");
-
+
// find F pos given A
assertEquals(13, sq.findPosition(10, new SequenceCursor(sq, 8, 2, 0)));
int token = (int) PA.getValue(sq, "changeCount"); // 0
*/
SequenceI sq = new Sequence("test", "-ABC--DEF--", 1, 20);
sq.createDatasetSequence();
-
+
assertTrue(sq.findFeatures(1, 9).isEmpty());
// should be no array bounds exception - JAL-2772
assertTrue(sq.findFeatures(1, 15).isEmpty());
-
+
// add feature on BCD
SequenceFeature sfBCD = new SequenceFeature("Cath", "desc", 2, 4, 2f,
null);
sq.addSequenceFeature(sfBCD);
-
+
// no features in columns 1-2 (-A)
List<SequenceFeature> found = sq.findFeatures(1, 2);
assertTrue(found.isEmpty());
-
+
// columns 1-6 (-ABC--) includes BCD
found = sq.findFeatures(1, 6);
assertEquals(1, found.size());
assertEquals(0, seq.firstResidueOutsideIterator(cs.iterator()));
}
- @Test(groups= {"Functional"})
- public void testTransferAnnotation() {
- Sequence origSeq = new Sequence("MYSEQ","THISISASEQ");
- Sequence toSeq = new Sequence("MYSEQ","THISISASEQ");
+
+ @Test(groups = { "Functional" })
+ public void testTransferAnnotation()
+ {
+ Sequence origSeq = new Sequence("MYSEQ", "THISISASEQ");
+ Sequence toSeq = new Sequence("MYSEQ", "THISISASEQ");
origSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "Q12345", null, true));
toSeq.transferAnnotation(origSeq, null);
- assertTrue(toSeq.getDBRefs().size()==1);
-
+ assertTrue(toSeq.getDBRefs().size() == 1);
+
assertTrue(toSeq.getDBRefs().get(0).isCanonical());
-
- // check for promotion of non-canonical
+
+ // check for promotion of non-canonical
// to canonical (e.g. fetch-db-refs on a jalview project pre 2.11.2)
toSeq.setDBRefs(null);
toSeq.addDBRef(new DBRefEntry("UNIPROT", "0", "Q12345", null, false));
toSeq.transferAnnotation(origSeq, null);
- assertTrue(toSeq.getDBRefs().size()==1);
-
- assertTrue("Promotion of non-canonical DBRefEntry failed",toSeq.getDBRefs().get(0).isCanonical());
-
-
+ assertTrue(toSeq.getDBRefs().size() == 1);
+
+ assertTrue("Promotion of non-canonical DBRefEntry failed",
+ toSeq.getDBRefs().get(0).isCanonical());
+
}
}