From 35ad61aaa9de6d49465fdb9435685ea0e9766418 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 24 May 2017 15:55:19 +0100 Subject: [PATCH] JAL-2505 remove setters for SequenceFeature.begin,end,type,featureGroup --- src/jalview/datamodel/SequenceFeature.java | 20 ----------- test/jalview/datamodel/SequenceFeatureTest.java | 42 ++++++++++++++--------- test/jalview/ext/ensembl/EnsemblCdnaTest.java | 17 +++++---- test/jalview/ext/ensembl/EnsemblCdsTest.java | 14 +++++--- test/jalview/ext/ensembl/EnsemblGeneTest.java | 19 ++++++---- test/jalview/ext/ensembl/EnsemblGenomeTest.java | 20 +++++++---- 6 files changed, 70 insertions(+), 62 deletions(-) diff --git a/src/jalview/datamodel/SequenceFeature.java b/src/jalview/datamodel/SequenceFeature.java index 719cf52..fa29ffd 100755 --- a/src/jalview/datamodel/SequenceFeature.java +++ b/src/jalview/datamodel/SequenceFeature.java @@ -294,11 +294,6 @@ public class SequenceFeature implements FeatureLocationI return begin; } - public void setBegin(int start) - { - this.begin = start; - } - /** * DOCUMENT ME! * @@ -310,11 +305,6 @@ public class SequenceFeature implements FeatureLocationI return end; } - public void setEnd(int end) - { - this.end = end; - } - /** * DOCUMENT ME! * @@ -325,11 +315,6 @@ public class SequenceFeature implements FeatureLocationI return type; } - public void setType(String type) - { - this.type = type; - } - /** * DOCUMENT ME! * @@ -350,11 +335,6 @@ public class SequenceFeature implements FeatureLocationI return featureGroup; } - public void setFeatureGroup(String featureGroup) - { - this.featureGroup = featureGroup; - } - public void addLink(String labelLink) { if (links == null) diff --git a/test/jalview/datamodel/SequenceFeatureTest.java b/test/jalview/datamodel/SequenceFeatureTest.java index 2da8918..7b0bc0c 100644 --- a/test/jalview/datamodel/SequenceFeatureTest.java +++ b/test/jalview/datamodel/SequenceFeatureTest.java @@ -123,13 +123,14 @@ public class SequenceFeatureTest assertEquals(sf1.hashCode(), sf2.hashCode()); // changing type breaks equals: - String restores = sf2.getType(); - sf2.setType("Type"); - assertFalse(sf1.equals(sf2)); - sf2.setType(restores); + SequenceFeature sf3 = new SequenceFeature("type", "desc", 22, 33, + 12.5f, "group"); + SequenceFeature sf4 = new SequenceFeature("Type", "desc", 22, 33, + 12.5f, "group"); + assertFalse(sf3.equals(sf4)); // changing description breaks equals: - restores = sf2.getDescription(); + String restores = sf2.getDescription(); sf2.setDescription("Desc"); assertFalse(sf1.equals(sf2)); sf2.setDescription(restores); @@ -153,21 +154,24 @@ public class SequenceFeatureTest // changing start position breaks equals: int restorei = sf2.getBegin(); - sf2.setBegin(21); + sf2 = new SequenceFeature(sf2, 21, sf2.getEnd(), sf2.getFeatureGroup()); assertFalse(sf1.equals(sf2)); - sf2.setBegin(restorei); + sf2 = new SequenceFeature(sf2, restorei, sf2.getEnd(), + sf2.getFeatureGroup()); // changing end position breaks equals: restorei = sf2.getEnd(); - sf2.setEnd(32); + sf2 = new SequenceFeature(sf2, sf2.getBegin(), 32, + sf2.getFeatureGroup()); assertFalse(sf1.equals(sf2)); - sf2.setEnd(restorei); + sf2 = new SequenceFeature(sf2, sf2.getBegin(), restorei, + sf2.getFeatureGroup()); // changing feature group breaks equals: restores = sf2.getFeatureGroup(); - sf2.setFeatureGroup("Group"); + sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), "Group"); assertFalse(sf1.equals(sf2)); - sf2.setFeatureGroup(restores); + sf2 = new SequenceFeature(sf2, sf2.getBegin(), sf2.getEnd(), restores); // changing ID breaks equals: restores = (String) sf2.getValue("ID"); @@ -215,17 +219,21 @@ public class SequenceFeatureTest SequenceFeature sf = new SequenceFeature("type", "desc", 22, 33, 12.5f, "group"); assertFalse(sf.isContactFeature()); - sf.setType(""); + sf = new SequenceFeature("", "desc", 22, 33, 12.5f, "group"); assertFalse(sf.isContactFeature()); - sf.setType(null); + sf = new SequenceFeature(null, "desc", 22, 33, 12.5f, "group"); assertFalse(sf.isContactFeature()); - sf.setType("Disulfide Bond"); + sf = new SequenceFeature("Disulfide Bond", "desc", 22, 33, 12.5f, + "group"); assertTrue(sf.isContactFeature()); - sf.setType("disulfide bond"); + sf = new SequenceFeature("disulfide bond", "desc", 22, 33, 12.5f, + "group"); assertTrue(sf.isContactFeature()); - sf.setType("Disulphide Bond"); + sf = new SequenceFeature("Disulphide Bond", "desc", 22, 33, 12.5f, + "group"); assertTrue(sf.isContactFeature()); - sf.setType("disulphide bond"); + sf = new SequenceFeature("disulphide bond", "desc", 22, 33, 12.5f, + "group"); assertTrue(sf.isContactFeature()); } } diff --git a/test/jalview/ext/ensembl/EnsemblCdnaTest.java b/test/jalview/ext/ensembl/EnsemblCdnaTest.java index fb0204b..6611e05 100644 --- a/test/jalview/ext/ensembl/EnsemblCdnaTest.java +++ b/test/jalview/ext/ensembl/EnsemblCdnaTest.java @@ -212,14 +212,16 @@ public class EnsemblCdnaTest 20500, 0f, null); assertFalse(testee.retainFeature(sf, accId)); - sf.setType("aberrant_processed_transcript"); + sf = new SequenceFeature("aberrant_processed_transcript", "", 20000, + 20500, 0f, null); assertFalse(testee.retainFeature(sf, accId)); - sf.setType("NMD_transcript_variant"); + sf = new SequenceFeature("NMD_transcript_variant", "", 20000, 20500, + 0f, null); assertFalse(testee.retainFeature(sf, accId)); // other feature with no parent is retained - sf.setType("sequence_variant"); + sf = new SequenceFeature("sequence_variant", "", 20000, 20500, 0f, null); assertTrue(testee.retainFeature(sf, accId)); // other feature with desired parent is retained @@ -254,15 +256,18 @@ public class EnsemblCdnaTest assertTrue(testee.identifiesSequence(sf, accId)); // exon sub-type with right parent is valid - sf.setType("coding_exon"); + sf = new SequenceFeature("coding_exon", "", 1, 2, 0f, null); + sf.setValue("Parent", "transcript:" + accId); assertTrue(testee.identifiesSequence(sf, accId)); // transcript not valid: - sf.setType("transcript"); + sf = new SequenceFeature("transcript", "", 1, 2, 0f, null); + sf.setValue("Parent", "transcript:" + accId); assertFalse(testee.identifiesSequence(sf, accId)); // CDS not valid: - sf.setType("CDS"); + sf = new SequenceFeature("CDS", "", 1, 2, 0f, null); + sf.setValue("Parent", "transcript:" + accId); assertFalse(testee.identifiesSequence(sf, accId)); } diff --git a/test/jalview/ext/ensembl/EnsemblCdsTest.java b/test/jalview/ext/ensembl/EnsemblCdsTest.java index b7f9f8d..8482c90 100644 --- a/test/jalview/ext/ensembl/EnsemblCdsTest.java +++ b/test/jalview/ext/ensembl/EnsemblCdsTest.java @@ -130,11 +130,12 @@ public class EnsemblCdsTest null); assertFalse(testee.retainFeature(sf, accId)); - sf.setType("CDS_predicted"); + sf = new SequenceFeature("CDS_predicted", "", 20000, 20500, 0f, null); assertFalse(testee.retainFeature(sf, accId)); // other feature with no parent is retained - sf.setType("sequence_variant"); + sf = new SequenceFeature("CDS_psequence_variantredicted", "", 20000, + 20500, 0f, null); assertTrue(testee.retainFeature(sf, accId)); // other feature with desired parent is retained @@ -169,15 +170,18 @@ public class EnsemblCdsTest assertTrue(testee.identifiesSequence(sf, accId)); // cds sub-type with right parent is valid - sf.setType("CDS_predicted"); + sf = new SequenceFeature("CDS_predicted", "", 1, 2, 0f, null); + sf.setValue("Parent", "transcript:" + accId); assertTrue(testee.identifiesSequence(sf, accId)); // transcript not valid: - sf.setType("transcript"); + sf = new SequenceFeature("transcript", "", 1, 2, 0f, null); + sf.setValue("Parent", "transcript:" + accId); assertFalse(testee.identifiesSequence(sf, accId)); // exon not valid: - sf.setType("exon"); + sf = new SequenceFeature("exon", "", 1, 2, 0f, null); + sf.setValue("Parent", "transcript:" + accId); assertFalse(testee.identifiesSequence(sf, accId)); } diff --git a/test/jalview/ext/ensembl/EnsemblGeneTest.java b/test/jalview/ext/ensembl/EnsemblGeneTest.java index edecc23..a8c491c 100644 --- a/test/jalview/ext/ensembl/EnsemblGeneTest.java +++ b/test/jalview/ext/ensembl/EnsemblGeneTest.java @@ -211,22 +211,24 @@ public class EnsemblGeneTest sf.setValue("ID", "gene:" + geneId); assertFalse(testee.retainFeature(sf, geneId)); - sf.setType("transcript"); + sf = new SequenceFeature("transcript", "", 20000, 20500, 0f, null); sf.setValue("Parent", "gene:" + geneId); assertTrue(testee.retainFeature(sf, geneId)); - sf.setType("mature_transcript"); + sf = new SequenceFeature("mature_transcript", "", 20000, 20500, 0f, + null); sf.setValue("Parent", "gene:" + geneId); assertTrue(testee.retainFeature(sf, geneId)); - sf.setType("NMD_transcript_variant"); + sf = new SequenceFeature("NMD_transcript_variant", "", 20000, 20500, + 0f, null); sf.setValue("Parent", "gene:" + geneId); assertTrue(testee.retainFeature(sf, geneId)); sf.setValue("Parent", "gene:XYZ"); assertFalse(testee.retainFeature(sf, geneId)); - sf.setType("anything"); + sf = new SequenceFeature("anything", "", 20000, 20500, 0f, null); assertTrue(testee.retainFeature(sf, geneId)); } @@ -253,15 +255,18 @@ public class EnsemblGeneTest assertTrue(testee.identifiesSequence(sf, accId)); // gene sub-type with right ID is valid - sf.setType("snRNA_gene"); + sf = new SequenceFeature("snRNA_gene", "", 1, 2, 0f, null); + sf.setValue("ID", "gene:" + accId); assertTrue(testee.identifiesSequence(sf, accId)); // transcript not valid: - sf.setType("transcript"); + sf = new SequenceFeature("transcript", "", 1, 2, 0f, null); + sf.setValue("ID", "gene:" + accId); assertFalse(testee.identifiesSequence(sf, accId)); // exon not valid: - sf.setType("exon"); + sf = new SequenceFeature("exon", "", 1, 2, 0f, null); + sf.setValue("ID", "gene:" + accId); assertFalse(testee.identifiesSequence(sf, accId)); } diff --git a/test/jalview/ext/ensembl/EnsemblGenomeTest.java b/test/jalview/ext/ensembl/EnsemblGenomeTest.java index 654797c..8687da9 100644 --- a/test/jalview/ext/ensembl/EnsemblGenomeTest.java +++ b/test/jalview/ext/ensembl/EnsemblGenomeTest.java @@ -136,14 +136,16 @@ public class EnsemblGenomeTest 20500, 0f, null); assertFalse(testee.retainFeature(sf, accId)); - sf.setType("mature_transcript"); + sf = new SequenceFeature("mature_transcript", "", 20000, 20500, 0f, + null); assertFalse(testee.retainFeature(sf, accId)); - sf.setType("NMD_transcript_variant"); + sf = new SequenceFeature("NMD_transcript_variant", "", 20000, 20500, + 0f, null); assertFalse(testee.retainFeature(sf, accId)); // other feature with no parent is kept - sf.setType("anything"); + sf = new SequenceFeature("anything", "", 20000, 20500, 0f, null); assertTrue(testee.retainFeature(sf, accId)); // other feature with correct parent is kept @@ -179,19 +181,23 @@ public class EnsemblGenomeTest assertTrue(testee.identifiesSequence(sf, accId)); // transcript sub-type with right ID is valid - sf.setType("ncRNA"); + sf = new SequenceFeature("ncRNA", "", 1, 2, 0f, null); + sf.setValue("ID", "transcript:" + accId); assertTrue(testee.identifiesSequence(sf, accId)); // Ensembl treats NMD_transcript_variant as if a transcript - sf.setType("NMD_transcript_variant"); + sf = new SequenceFeature("NMD_transcript_variant", "", 1, 2, 0f, null); + sf.setValue("ID", "transcript:" + accId); assertTrue(testee.identifiesSequence(sf, accId)); // gene not valid: - sf.setType("gene"); + sf = new SequenceFeature("gene", "", 1, 2, 0f, null); + sf.setValue("ID", "transcript:" + accId); assertFalse(testee.identifiesSequence(sf, accId)); // exon not valid: - sf.setType("exon"); + sf = new SequenceFeature("exon", "", 1, 2, 0f, null); + sf.setValue("ID", "transcript:" + accId); assertFalse(testee.identifiesSequence(sf, accId)); } -- 1.7.10.2