From: gmungoc Date: Thu, 17 Nov 2016 11:02:34 +0000 (+0000) Subject: JAL-2327 add isContactFeature X-Git-Tag: Release_2_10_1~10^2~1^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4c4998c1524e4d567720c42ca41adbfe74d60d90;p=jalview.git JAL-2327 add isContactFeature --- diff --git a/src/jalview/datamodel/SequenceFeature.java b/src/jalview/datamodel/SequenceFeature.java index 0baa78e..15f54b9 100755 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@ -532,4 +532,20 @@ public class SequenceFeature return s.hashCode() + getBegin() + getEnd() + (int) getScore() + getStrand(); } + + /** + * Answers true if the feature's start/end values represent two related + * positions, rather than ends of a range. Such features may be visualised or + * reported differently to features on a range. + */ + public boolean isContactFeature() + { + // TODO abstract one day to a FeatureType class + if ("disulfide bond".equalsIgnoreCase(type) + || "disulphide bond".equalsIgnoreCase(type)) + { + return true; + } + return false; + } } diff --git a/test/jalview/datamodel/SequenceFeatureTest.java b/test/jalview/datamodel/SequenceFeatureTest.java index 5150337..23812ea 100644 --- a/test/jalview/datamodel/SequenceFeatureTest.java +++ b/test/jalview/datamodel/SequenceFeatureTest.java @@ -197,4 +197,24 @@ public class SequenceFeatureTest sf1.setStatus("new"); assertTrue(sf1.equals(sf2)); } + + @Test(groups = { "Functional" }) + public void testIsContactFeature() + { + SequenceFeature sf = new SequenceFeature("type", "desc", 22, 33, 12.5f, + "group"); + assertFalse(sf.isContactFeature()); + sf.setType(""); + assertFalse(sf.isContactFeature()); + sf.setType(null); + assertFalse(sf.isContactFeature()); + sf.setType("Disulfide Bond"); + assertTrue(sf.isContactFeature()); + sf.setType("disulfide bond"); + assertTrue(sf.isContactFeature()); + sf.setType("Disulphide Bond"); + assertTrue(sf.isContactFeature()); + sf.setType("disulphide bond"); + assertTrue(sf.isContactFeature()); + } }