JAL-2505 remove setters for SequenceFeature.begin,end,type,featureGroup
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 24 May 2017 14:55:19 +0000 (15:55 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 24 May 2017 14:55:19 +0000 (15:55 +0100)
src/jalview/datamodel/SequenceFeature.java
test/jalview/datamodel/SequenceFeatureTest.java
test/jalview/ext/ensembl/EnsemblCdnaTest.java
test/jalview/ext/ensembl/EnsemblCdsTest.java
test/jalview/ext/ensembl/EnsemblGeneTest.java
test/jalview/ext/ensembl/EnsemblGenomeTest.java

index 719cf52..fa29ffd 100755 (executable)
@@ -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)
index 2da8918..7b0bc0c 100644 (file)
@@ -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());
   }
 }
index fb0204b..6611e05 100644 (file)
@@ -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));
   }
 
index b7f9f8d..8482c90 100644 (file)
@@ -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));
   }
 
index edecc23..a8c491c 100644 (file)
@@ -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));
   }
 
index 654797c..8687da9 100644 (file)
@@ -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));
   }