X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fdatamodel%2FSequenceFeatureTest.java;h=9111e5ac2720320bbf39e594216e665a3c6d0957;hb=89bee60470f83e553493a40460f1f135a02d0696;hp=7b0bc0c1697725c1f6f0a7488dc1c001fd899a45;hpb=35ad61aaa9de6d49465fdb9435685ea0e9766418;p=jalview.git
diff --git a/test/jalview/datamodel/SequenceFeatureTest.java b/test/jalview/datamodel/SequenceFeatureTest.java
index 7b0bc0c..9111e5a 100644
--- a/test/jalview/datamodel/SequenceFeatureTest.java
+++ b/test/jalview/datamodel/SequenceFeatureTest.java
@@ -42,13 +42,13 @@ public class SequenceFeatureTest
}
@Test(groups = { "Functional" })
- public void testCopyConstructor()
+ public void testCopyConstructors()
{
SequenceFeature sf1 = new SequenceFeature("type", "desc", 22, 33,
12.5f, "group");
sf1.setValue("STRAND", "+");
sf1.setValue("Note", "Testing");
- Integer count = new Integer(7);
+ Integer count = Integer.valueOf(7);
sf1.setValue("Count", count);
SequenceFeature sf2 = new SequenceFeature(sf1);
@@ -56,10 +56,41 @@ public class SequenceFeatureTest
assertEquals("desc", sf2.getDescription());
assertEquals(22, sf2.getBegin());
assertEquals(33, sf2.getEnd());
+ assertEquals(12.5f, sf2.getScore());
assertEquals("+", sf2.getValue("STRAND"));
assertEquals("Testing", sf2.getValue("Note"));
// shallow clone of otherDetails map - contains the same object values!
assertSame(count, sf2.getValue("Count"));
+
+ /*
+ * copy constructor modifying begin/end/group/score
+ */
+ SequenceFeature sf3 = new SequenceFeature(sf1, 11, 14, "group2", 17.4f);
+ assertEquals("type", sf3.getType());
+ assertEquals("desc", sf3.getDescription());
+ assertEquals(11, sf3.getBegin());
+ assertEquals(14, sf3.getEnd());
+ assertEquals(17.4f, sf3.getScore());
+ assertEquals("+", sf3.getValue("STRAND"));
+ assertEquals("Testing", sf3.getValue("Note"));
+ // shallow clone of otherDetails map - contains the same object values!
+ assertSame(count, sf3.getValue("Count"));
+
+ /*
+ * copy constructor modifying type/begin/end/group/score
+ */
+ SequenceFeature sf4 = new SequenceFeature(sf1, "Disulfide bond", 12,
+ 15, "group3", -9.1f);
+ assertEquals("Disulfide bond", sf4.getType());
+ assertTrue(sf4.isContactFeature());
+ assertEquals("desc", sf4.getDescription());
+ assertEquals(12, sf4.getBegin());
+ assertEquals(15, sf4.getEnd());
+ assertEquals(-9.1f, sf4.getScore());
+ assertEquals("+", sf4.getValue("STRAND"));
+ assertEquals("Testing", sf4.getValue("Note"));
+ // shallow clone of otherDetails map - contains the same object values!
+ assertSame(count, sf4.getValue("Count"));
}
/**
@@ -75,7 +106,7 @@ public class SequenceFeatureTest
assertEquals("+", sf1.getValue("STRAND"));
assertNull(sf1.getValue("strand")); // case-sensitive
assertEquals(".", sf1.getValue("unknown", "."));
- Integer i = new Integer(27);
+ Integer i = Integer.valueOf(27);
assertSame(i, sf1.getValue("Unknown", i));
}
@@ -137,41 +168,47 @@ public class SequenceFeatureTest
// changing score breaks equals:
float restoref = sf2.getScore();
- sf2.setScore(12.4f);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(),
+ sf2.getFeatureGroup(), 10f);
assertFalse(sf1.equals(sf2));
- sf2.setScore(restoref);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(),
+ sf2.getFeatureGroup(), restoref);
// NaN doesn't match a number
restoref = sf2.getScore();
- sf2.setScore(Float.NaN);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(),
+ sf2.getFeatureGroup(), Float.NaN);
assertFalse(sf1.equals(sf2));
// NaN matches NaN
- sf1.setScore(Float.NaN);
+ sf1 = new SequenceFeature(sf1, sf1.getBegin(), sf1.getEnd(),
+ sf1.getFeatureGroup(), Float.NaN);
assertTrue(sf1.equals(sf2));
- sf1.setScore(restoref);
- sf2.setScore(restoref);
+ sf1 = new SequenceFeature(sf1, sf1.getBegin(), sf1.getEnd(),
+ sf1.getFeatureGroup(), restoref);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(),
+ sf2.getFeatureGroup(), restoref);
// changing start position breaks equals:
int restorei = sf2.getBegin();
- sf2 = new SequenceFeature(sf2, 21, sf2.getEnd(), sf2.getFeatureGroup());
+ sf2 = new SequenceFeature(sf2, 21, sf2.getEnd(), sf2.getFeatureGroup(), sf2.getScore());
assertFalse(sf1.equals(sf2));
sf2 = new SequenceFeature(sf2, restorei, sf2.getEnd(),
- sf2.getFeatureGroup());
+ sf2.getFeatureGroup(), sf2.getScore());
// changing end position breaks equals:
restorei = sf2.getEnd();
sf2 = new SequenceFeature(sf2, sf2.getBegin(), 32,
- sf2.getFeatureGroup());
+ sf2.getFeatureGroup(), sf2.getScore());
assertFalse(sf1.equals(sf2));
sf2 = new SequenceFeature(sf2, sf2.getBegin(), restorei,
- sf2.getFeatureGroup());
+ sf2.getFeatureGroup(), sf2.getScore());
// changing feature group breaks equals:
restores = sf2.getFeatureGroup();
- sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), "Group");
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), "Group", sf2.getScore());
assertFalse(sf1.equals(sf2));
- sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), restores);
+ sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), restores, sf2.getScore());
// changing ID breaks equals:
restores = (String) sf2.getValue("ID");
@@ -236,4 +273,47 @@ public class SequenceFeatureTest
"group");
assertTrue(sf.isContactFeature());
}
+
+ @Test(groups = { "Functional" })
+ public void testGetDetailsReport()
+ {
+ // single locus, no group, no score
+ SequenceFeature sf = new SequenceFeature("variant", "G,C", 22, 22, null);
+ String expected = "
Type | variant | |
"
+ + "Start/end | 22 | |
"
+ + "Description | G,C | |
";
+ assertEquals(expected, sf.getDetailsReport());
+
+ // contact feature
+ sf = new SequenceFeature("Disulphide Bond", "a description", 28, 31,
+ null);
+ expected = "
Type | Disulphide Bond | |
"
+ + "Start/end | 28:31 | |
"
+ + "Description | a description | |
";
+ assertEquals(expected, sf.getDetailsReport());
+
+ sf = new SequenceFeature("variant", "G,C", 22, 33,
+ 12.5f, "group");
+ sf.setValue("Parent", "ENSG001");
+ sf.setValue("Child", "ENSP002");
+ expected = "
Type | variant | |
"
+ + "Start/end | 22-33 | |
"
+ + "Description | G,C | |
"
+ + "Score | 12.5 | |
"
+ + "Group | group | |
"
+ + "Child | | ENSP002 |
"
+ + "Parent | | ENSG001 |
";
+ assertEquals(expected, sf.getDetailsReport());
+
+ /*
+ * feature with embedded html link in description
+ */
+ String desc = "Fer2 Status: True Positive Pfam 8_8";
+ sf = new SequenceFeature("Pfam", desc, 8, 83, "Uniprot");
+ expected = "
Type | Pfam | |
"
+ + "Start/end | 8-83 | |
"
+ + "Description | Fer2 Status: True Positive Pfam 8_8 | |
"
+ + "Group | Uniprot | |
";
+ assertEquals(expected, sf.getDetailsReport());
+ }
}