JAL-2050 make SequenceFeature.score final, adjust constructor calls
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 25 May 2017 10:54:39 +0000 (11:54 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 25 May 2017 10:54:39 +0000 (11:54 +0100)
28 files changed:
src/MCview/PDBChain.java
src/jalview/analysis/AlignmentUtils.java
src/jalview/analysis/Rna.java
src/jalview/appletgui/APopupMenu.java
src/jalview/appletgui/FeatureRenderer.java
src/jalview/appletgui/Finder.java
src/jalview/commands/EditCommand.java
src/jalview/datamodel/Mapping.java
src/jalview/datamodel/SequenceFeature.java
src/jalview/datamodel/features/FeatureStore.java
src/jalview/datamodel/xdb/embl/EmblEntry.java
src/jalview/ext/ensembl/EnsemblSeqProxy.java
src/jalview/gui/FeatureRenderer.java
src/jalview/gui/Finder.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/Jalview2XML_V1.java
src/jalview/gui/PopupMenu.java
src/jalview/io/FeaturesFile.java
src/jalview/io/StockholmFile.java
src/jalview/io/gff/Gff3Helper.java
src/jalview/io/vamsas/Sequencefeature.java
src/jalview/ws/dbsources/Uniprot.java
src/jalview/ws/jws2/AADisorderClient.java
test/jalview/analysis/SeqsetUtilsTest.java
test/jalview/analysis/scoremodels/FeatureDistanceModelTest.java
test/jalview/datamodel/SequenceFeatureTest.java
test/jalview/datamodel/SequenceTest.java
test/jalview/schemes/FeatureColourTest.java

index 1f47014..ef86cfd 100755 (executable)
@@ -204,16 +204,16 @@ public class PDBChain
     }
     for (int i = 0; i < features.length; i++)
     {
-      if (features[i].getFeatureGroup() != null
-              && features[i].getFeatureGroup().equals(pdbid))
+      SequenceFeature feature = features[i];
+      if (feature.getFeatureGroup() != null
+              && feature.getFeatureGroup().equals(pdbid))
       {
-        int newBegin = 1 + residues.elementAt(features[i].getBegin()
-                - offset).atoms
+        int newBegin = 1 + residues.elementAt(feature.getBegin() - offset).atoms
                 .elementAt(0).alignmentMapping;
-        int newEnd = 1 + residues.elementAt(features[i].getEnd() - offset).atoms
+        int newEnd = 1 + residues.elementAt(feature.getEnd() - offset).atoms
                 .elementAt(0).alignmentMapping;
-        SequenceFeature tx = new SequenceFeature(features[i], newBegin,
-                newEnd, features[i].getFeatureGroup());
+        SequenceFeature tx = new SequenceFeature(feature, newBegin, newEnd,
+                feature.getFeatureGroup(), feature.getScore());
         tx.setStatus(status
                 + ((tx.getStatus() == null || tx.getStatus().length() == 0) ? ""
                         : ":" + tx.getStatus()));
@@ -355,25 +355,25 @@ public class PDBChain
               && !residues.isEmpty()
               && residues.lastElement().atoms.get(0).resNumber == currAtom.resNumber)
       {
-        SequenceFeature sf = new SequenceFeature("INSERTION",
-                currAtom.resName + ":" + currAtom.resNumIns + " " + pdbid
-                        + id, "", offset + count - 1, offset + count - 1,
-                "PDB_INS");
+        String desc = currAtom.resName + ":" + currAtom.resNumIns + " "
+                + pdbid + id;
+        SequenceFeature sf = new SequenceFeature("INSERTION", desc, offset
+                + count - 1, offset + count - 1, "PDB_INS");
         resFeatures.addElement(sf);
         residues.lastElement().atoms.addAll(resAtoms);
       }
       else
       {
-
         // Make a new Residue object with the new atoms vector
         residues.addElement(new Residue(resAtoms, resNumber - 1, count));
 
         Residue tmpres = residues.lastElement();
         Atom tmpat = tmpres.atoms.get(0);
         // Make A new SequenceFeature for the current residue numbering
-        SequenceFeature sf = new SequenceFeature(RESNUM_FEATURE, tmpat.resName
-                + ":" + tmpat.resNumIns + " " + pdbid + id, "", offset
-                + count, offset + count, pdbid);
+        String desc = tmpat.resName
+                + ":" + tmpat.resNumIns + " " + pdbid + id;
+        SequenceFeature sf = new SequenceFeature(RESNUM_FEATURE, desc,
+                offset + count, offset + count, pdbid);
         resFeatures.addElement(sf);
         resAnnotation.addElement(new Annotation(tmpat.tfactor));
         // Keep totting up the sequence
index 66be623..69ac947 100644 (file)
@@ -2134,7 +2134,7 @@ public class AlignmentUtils
         int newBegin = Math.min(mappedTo[0], mappedTo[1]);
         int newEnd = Math.max(mappedTo[0], mappedTo[1]);
         SequenceFeature copy = new SequenceFeature(sf, newBegin, newEnd,
-                sf.getFeatureGroup());
+                sf.getFeatureGroup(), sf.getScore());
         copyTo.addSequenceFeature(copy);
         count++;
       }
@@ -2439,10 +2439,9 @@ public class AlignmentUtils
       String trans3Char = StringUtils
               .toSentenceCase(ResidueProperties.aa2Triplet.get(trans));
       String desc = "p." + residue3Char + peptidePos + trans3Char;
-      // set score to 0f so 'graduated colour' option is offered! JAL-2060
       SequenceFeature sf = new SequenceFeature(
               SequenceOntologyI.SEQUENCE_VARIANT, desc, peptidePos,
-              peptidePos, 0f, var.getSource());
+              peptidePos, var.getSource());
       StringBuilder attributes = new StringBuilder(32);
       String id = (String) var.variant.getValue(ID);
       if (id != null)
index 34233f0..3108ef3 100644 (file)
@@ -466,7 +466,7 @@ public class Rna
       helices.put(close, helix);
 
       // Record helix as featuregroup
-      result.add(new SequenceFeature("RNA helix", "", "", open, close,
+      result.add(new SequenceFeature("RNA helix", "", open, close,
               String.valueOf(helix)));
 
       lastopen = open;
index 8fd317a..83e8cf8 100644 (file)
@@ -830,7 +830,7 @@ public class APopupMenu extends java.awt.PopupMenu implements
         if (start <= end)
         {
           seqs[rsize] = sg.getSequenceAt(i);
-          features[rsize] = new SequenceFeature(null, null, null, start,
+          features[rsize] = new SequenceFeature(null, null, start,
                   end, "Jalview");
           rsize++;
         }
index 81b207f..b9e92e2 100644 (file)
@@ -431,7 +431,7 @@ public class FeatureRenderer extends
          */
         sequences[0].deleteFeature(sf);
         SequenceFeature newSf = new SequenceFeature(sf, newBegin, newEnd,
-                enteredGroup);
+                enteredGroup, sf.getScore());
         newSf.setDescription(enteredDesc);
         ffile.parseDescriptionHTML(newSf, false);
         // amend features dialog only updates one sequence at a time
@@ -463,8 +463,7 @@ public class FeatureRenderer extends
         {
           SequenceFeature sf = features[i];
           SequenceFeature sf2 = new SequenceFeature(enteredType,
-                  enteredDesc, sf.getBegin(), sf.getEnd(), Float.NaN,
-                  enteredGroup);
+                  enteredDesc, sf.getBegin(), sf.getEnd(), enteredGroup);
           ffile.parseDescriptionHTML(sf2, false);
           sequences[i].addSequenceFeature(sf2);
         }
index a342736..cd5030a 100644 (file)
@@ -123,9 +123,8 @@ public class Finder extends Panel implements ActionListener
     {
       seqs[i] = match.getSequence().getDatasetSequence();
 
-      features[i] = new SequenceFeature(searchString,
-              "Search Results", null, match.getStart(), match.getEnd(),
-              "Search Results");
+      features[i] = new SequenceFeature(searchString, "Search Results",
+              match.getStart(), match.getEnd(), "Search Results");
       i++;
     }
 
index 388c533..f36b55f 100644 (file)
@@ -1152,7 +1152,7 @@ public class EditCommand implements CommandI
         int newBegin = copy.getBegin() - cSize;
         int newEnd = copy.getEnd() - cSize;
         SequenceFeature newSf = new SequenceFeature(feature, newBegin,
-                newEnd, feature.getFeatureGroup());
+                newEnd, feature.getFeatureGroup(), feature.getScore());
         sequence.deleteFeature(feature);
         sequence.addSequenceFeature(newSf);
         // feature.setBegin(newBegin);
@@ -1180,7 +1180,7 @@ public class EditCommand implements CommandI
       if (newEnd >= newBegin)
       {
         sequence.addSequenceFeature(new SequenceFeature(feature, newBegin,
-                newEnd, feature.getFeatureGroup()));
+                newEnd, feature.getFeatureGroup(), feature.getScore()));
       }
       // if (feature.getBegin() > feature.getEnd())
       // {
index 5a4689d..c741603 100644 (file)
@@ -531,7 +531,7 @@ public class Mapping
         for (int i = 0, v = 0; i < frange.length; i += 2, v++)
         {
           vf[v] = new SequenceFeature(f, frange[i], frange[i + 1],
-                  f.getFeatureGroup());
+                  f.getFeatureGroup(), f.getScore());
           if (frange.length > 2)
           {
             vf[v].setDescription(f.getDescription() + "\nPart " + (v + 1));
index 4df57ef..045bbbd 100755 (executable)
@@ -70,7 +70,7 @@ public class SequenceFeature implements FeatureLocationI
 
   public final String featureGroup;
 
-  public float score;
+  public final float score;
 
   public String description;
 
@@ -91,7 +91,8 @@ public class SequenceFeature implements FeatureLocationI
    */
   public SequenceFeature(SequenceFeature cpy)
   {
-    this(cpy, cpy.getBegin(), cpy.getEnd(), cpy.getFeatureGroup());
+    this(cpy, cpy.getBegin(), cpy.getEnd(), cpy.getFeatureGroup(), cpy
+            .getScore());
   }
 
   /**
@@ -127,25 +128,29 @@ public class SequenceFeature implements FeatureLocationI
   public SequenceFeature(String theType, String theDesc, int theBegin,
           int theEnd, float theScore, String group)
   {
-    this(theType, theDesc, theBegin, theEnd, group);
+    this.type = theType;
+    this.description = theDesc;
+    this.begin = theBegin;
+    this.end = theEnd;
+    this.featureGroup = group;
     this.score = theScore;
   }
 
   /**
-   * A copy constructor that allows the begin and end positions and group to be
-   * modified
+   * A copy constructor that allows the value of final fields to be 'modified'
    * 
    * @param sf
    * @param newBegin
    * @param newEnd
    * @param newGroup
+   * @param newScore
    */
   public SequenceFeature(SequenceFeature sf, int newBegin, int newEnd,
-          String newGroup)
+          String newGroup, float newScore)
   {
-    this(sf.getType(), newBegin, newEnd, newGroup);
-    score = sf.score;
-    description = sf.description;
+    this(sf.getType(), sf.getDescription(), newBegin, newEnd, newScore,
+            newGroup);
+
     if (sf.otherDetails != null)
     {
       otherDetails = new HashMap<String, Object>();
@@ -165,23 +170,6 @@ public class SequenceFeature implements FeatureLocationI
   }
 
   /**
-   * Constructor that sets the final fields type, begin, end, group
-   * 
-   * @param theType
-   * @param theBegin
-   * @param theEnd
-   * @param theGroup
-   */
-  private SequenceFeature(String theType, int theBegin, int theEnd,
-          String theGroup)
-  {
-    type = theType;
-    begin = theBegin;
-    end = theEnd;
-    featureGroup = theGroup;
-  }
-
-  /**
    * Two features are considered equal if they have the same type, group,
    * description, start, end, phase, strand, and (if present) 'Name', ID' and
    * 'Parent' attributes.
@@ -339,11 +327,6 @@ public class SequenceFeature implements FeatureLocationI
     return score;
   }
 
-  public void setScore(float value)
-  {
-    score = value;
-  }
-
   /**
    * Used for getting values which are not in the basic set. eg STRAND, PHASE
    * for GFF file
index 7218b38..332e9ec 100644 (file)
@@ -1046,7 +1046,7 @@ public class FeatureStore
       {
         newBegin = Math.max(1, newBegin);
         SequenceFeature sf2 = new SequenceFeature(sf, newBegin, newEnd,
-                sf.getFeatureGroup());
+                sf.getFeatureGroup(), sf.getScore());
         addFeature(sf2);
       }
       delete(sf);
index 6f9c884..c3d4e66 100644 (file)
@@ -594,8 +594,7 @@ public class EmblEntry
   protected SequenceFeature makeCdsFeature(String type, String desc,
           int begin, int end, String group, Map<String, String> vals)
   {
-    SequenceFeature sf = new SequenceFeature(type, desc, begin, end,
-            Float.NaN, group);
+    SequenceFeature sf = new SequenceFeature(type, desc, begin, end, group);
 
     if (!vals.isEmpty())
     {
index dcf2eb4..79d6c0a 100644 (file)
@@ -691,7 +691,7 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
       int newBegin = Math.min(mappedRange[0], mappedRange[1]);
       int newEnd = Math.max(mappedRange[0], mappedRange[1]);
       SequenceFeature copy = new SequenceFeature(sf, newBegin, newEnd,
-              group);
+              group, sf.getScore());
       targetSequence.addSequenceFeature(copy);
 
       /*
index c6610e1..ac56590 100644 (file)
@@ -449,7 +449,7 @@ public class FeatureRenderer extends
          */
         sequences.get(0).deleteFeature(sf);
         SequenceFeature newSf = new SequenceFeature(sf, newBegin, newEnd,
-                enteredGroup);
+                enteredGroup, sf.getScore());
         sf.setDescription(enteredDescription);
         ffile.parseDescriptionHTML(newSf, false);
         // amend features dialog only updates one sequence at a time
@@ -471,7 +471,7 @@ public class FeatureRenderer extends
           SequenceFeature sf = features.get(i);
           SequenceFeature sf2 = new SequenceFeature(enteredType,
                   enteredDescription, sf.getBegin(), sf.getEnd(),
-                  Float.NaN, enteredGroup);
+                  enteredGroup);
           ffile.parseDescriptionHTML(sf2, false);
           sequences.get(i).addSequenceFeature(sf2);
         }
index 625fc27..81de48f 100755 (executable)
@@ -222,7 +222,8 @@ public class Finder extends GFinder
     for (SearchResultMatchI match : searchResults.getResults())
     {
       seqs.add(match.getSequence().getDatasetSequence());
-      features.add(new SequenceFeature(searchString, desc, null, match
+      features.add(new SequenceFeature(searchString, desc,
+              match
               .getStart(), match.getEnd(), desc));
     }
 
index 6361caf..d6e0123 100644 (file)
@@ -32,6 +32,7 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.GraphLine;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.RnaViewerModel;
+import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.StructureViewerModel;
@@ -2986,12 +2987,11 @@ public class Jalview2XML
           Features[] features = jseqs[i].getFeatures();
           for (int f = 0; f < features.length; f++)
           {
-            jalview.datamodel.SequenceFeature sf = new jalview.datamodel.SequenceFeature(
-                    features[f].getType(), features[f].getDescription(),
-                    features[f].getStatus(), features[f].getBegin(),
-                    features[f].getEnd(), features[f].getFeatureGroup());
-
-            sf.setScore(features[f].getScore());
+            SequenceFeature sf = new SequenceFeature(features[f].getType(),
+                    features[f].getDescription(), features[f].getBegin(),
+                    features[f].getEnd(), features[f].getScore(),
+                    features[f].getFeatureGroup());
+            sf.setStatus(features[f].getStatus());
             for (int od = 0; od < features[f].getOtherDataCount(); od++)
             {
               OtherData keyValue = features[f].getOtherData(od);
index cc2f636..b17d060 100755 (executable)
@@ -36,6 +36,7 @@ import jalview.binding.Tree;
 import jalview.binding.UserColours;
 import jalview.binding.Viewport;
 import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceFeature;
 import jalview.io.FileFormat;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemeProperty;
@@ -224,11 +225,10 @@ public class Jalview2XML_V1
         Features[] features = JSEQ[i].getFeatures();
         for (int f = 0; f < features.length; f++)
         {
-          jalview.datamodel.SequenceFeature sf = new jalview.datamodel.SequenceFeature(
-                  features[f].getType(), features[f].getDescription(),
-                  features[f].getStatus(), features[f].getBegin(),
+          SequenceFeature sf = new SequenceFeature(features[f].getType(),
+                  features[f].getDescription(), features[f].getBegin(),
                   features[f].getEnd(), null);
-
+          sf.setStatus(features[f].getStatus());
           al.getSequenceAt(i).getDatasetSequence().addSequenceFeature(sf);
         }
       }
index 3de7c3c..c27aeee 100644 (file)
@@ -1904,7 +1904,7 @@ public class PopupMenu extends JPopupMenu implements ColourChangeListener
       if (start <= end)
       {
         seqs.add(sg.getSequenceAt(i).getDatasetSequence());
-        features.add(new SequenceFeature(null, null, null, start, end, null));
+        features.add(new SequenceFeature(null, null, start, end, null));
       }
     }
 
index a3cab6b..e1fccaf 100755 (executable)
@@ -373,20 +373,23 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI
       Color colour = ColorUtils.createColourFromName(ft);
       featureColours.put(ft, new FeatureColour(colour));
     }
-    SequenceFeature sf = new SequenceFeature(ft, desc, "", startPos,
-            endPos, featureGroup);
+    SequenceFeature sf = null;
     if (gffColumns.length > 6)
     {
       float score = Float.NaN;
       try
       {
         score = new Float(gffColumns[6]).floatValue();
-        // update colourgradient bounds if allowed to
       } catch (NumberFormatException ex)
       {
-        // leave as NaN
+        sf = new SequenceFeature(ft, desc, startPos, endPos, featureGroup);
       }
-      sf.setScore(score);
+      sf = new SequenceFeature(ft, desc, startPos, endPos, score,
+              featureGroup);
+    }
+    else
+    {
+      sf = new SequenceFeature(ft, desc, startPos, endPos, featureGroup);
     }
 
     parseDescriptionHTML(sf, removeHTML);
index c2f3683..8fe7f82 100644 (file)
@@ -412,7 +412,7 @@ public class StockholmFile extends AlignFile
                     int new_pos = posmap[k]; // look up nearest seqeunce
                     // position to this column
                     SequenceFeature feat = new SequenceFeature(type, desc,
-                            new_pos, new_pos, 0f, null);
+                            new_pos, new_pos, null);
 
                     seqO.addSequenceFeature(feat);
                   }
index 8af3933..28941f5 100644 (file)
@@ -312,7 +312,7 @@ public class Gff3Helper extends GffHelperBase
          */
         int sequenceFeatureLength = 1 + sf.getEnd() - sf.getBegin();
         SequenceFeature sf2 = new SequenceFeature(sf, 1,
-                sequenceFeatureLength, sf.getFeatureGroup());
+                sequenceFeatureLength, sf.getFeatureGroup(), sf.getScore());
         mappedSequence.addSequenceFeature(sf2);
 
         /*
index 61491b2..363f6f1 100644 (file)
@@ -284,9 +284,39 @@ public class Sequencefeature extends Rangetype
   private SequenceFeature getJalviewSeqFeature(RangeAnnotation dseta)
   {
     int[] se = getBounds(dseta);
-    SequenceFeature sf = new jalview.datamodel.SequenceFeature(
-            dseta.getType(), dseta.getDescription(), dseta.getStatus(),
-            se[0], se[1], dseta.getGroup());
+
+    /*
+     * try to identify feature score
+     */
+    boolean scoreFound = false;
+    float theScore = 0f;
+    String featureType = dseta.getType();
+    if (dseta.getScoreCount() > 0)
+    {
+      Enumeration scr = dseta.enumerateScore();
+      while (scr.hasMoreElements())
+      {
+        Score score = (Score) scr.nextElement();
+        if (score.getName().equals(featureType))
+        {
+          theScore = score.getContent();
+          scoreFound = true;
+        }
+      }
+    }
+
+    SequenceFeature sf = null;
+    if (scoreFound)
+    {
+      sf = new SequenceFeature(featureType, dseta.getDescription(), se[0],
+              se[1], theScore, dseta.getGroup());
+    }
+    else
+    {
+      sf = new SequenceFeature(featureType, dseta.getDescription(), se[0],
+              se[1], dseta.getGroup());
+    }
+    sf.setStatus(dseta.getStatus());
     if (dseta.getLinkCount() > 0)
     {
       Link[] links = dseta.getLink();
@@ -302,11 +332,7 @@ public class Sequencefeature extends Rangetype
       while (scr.hasMoreElements())
       {
         Score score = (Score) scr.nextElement();
-        if (score.getName().equals(sf.getType()))
-        {
-          sf.setScore(score.getContent());
-        }
-        else
+        if (!score.getName().equals(sf.getType()))
         {
           sf.setValue(score.getName(), "" + score.getContent());
         }
index 6ddd828..7261cba 100644 (file)
@@ -263,8 +263,8 @@ public class Uniprot extends DbSourceProxyImpl
       for (UniprotFeature uf : entry.getFeature())
       {
         SequenceFeature copy = new SequenceFeature(uf.getType(),
-                uf.getDescription(), uf.getStatus(), uf.getBegin(),
-                uf.getEnd(), "Uniprot");
+                uf.getDescription(), uf.getBegin(), uf.getEnd(), "Uniprot");
+        copy.setStatus(uf.getStatus());
         sequence.addSequenceFeature(copy);
       }
     }
index 001f6a8..b877d20 100644 (file)
@@ -20,7 +20,6 @@
  */
 package jalview.ws.jws2;
 
-import jalview.api.AlignCalcWorkerI;
 import jalview.api.FeatureColourI;
 import jalview.bin.Cache;
 import jalview.datamodel.AlignmentAnnotation;
@@ -238,14 +237,14 @@ public class AADisorderClient extends JabawsCalcWorker
                 }
                 if (vals.hasNext())
                 {
+                  val = vals.next().floatValue();
                   sf = new SequenceFeature(type[0], type[1],
-                          base + rn.from, base + rn.to, val = vals.next()
-                                  .floatValue(), methodName);
+                          base + rn.from, base + rn.to, val, methodName);
                 }
                 else
                 {
-                  sf = new SequenceFeature(type[0], type[1], null, base
-                          + rn.from, base + rn.to, methodName);
+                  sf = new SequenceFeature(type[0], type[1],
+                          base + rn.from, base + rn.to, methodName);
                 }
                 dseq.addSequenceFeature(sf);
                 if (last != val && !Float.isNaN(last))
index 11cb10c..ee364c9 100644 (file)
@@ -62,9 +62,8 @@ public class SeqsetUtilsTest
     AlignmentI al = new Alignment(sqset);
     al.setDataset(null);
     AlignmentI ds = al.getDataset();
-    SequenceFeature sf1 = new SequenceFeature("f1", "foo", "bleh", 2, 3,
-            "far"), sf2 = new SequenceFeature("f2", "foo", "bleh", 2, 3,
-            "far");
+    SequenceFeature sf1 = new SequenceFeature("f1", "foo", 2, 3, "far");
+    SequenceFeature sf2 = new SequenceFeature("f2", "foo", 2, 3, "far");
     ds.getSequenceAt(0).addSequenceFeature(sf1);
     Hashtable unq = SeqsetUtils.uniquify(sqset, true);
     SequenceI[] sqset2 = new SequenceI[] {
index 4bcf5ab..263844f 100644 (file)
@@ -85,18 +85,18 @@ public class FeatureDistanceModelTest
       SequenceI ds = al.getSequenceAt(i).getDatasetSequence();
       if (sf1[i * 2] > 0)
       {
-        ds.addSequenceFeature(new SequenceFeature("sf1", "sf1", "sf1",
-                sf1[i * 2], sf1[i * 2 + 1], "sf1"));
+        ds.addSequenceFeature(new SequenceFeature("sf1", "sf1", sf1[i * 2],
+                sf1[i * 2 + 1], "sf1"));
       }
       if (sf2[i * 2] > 0)
       {
-        ds.addSequenceFeature(new SequenceFeature("sf2", "sf2", "sf2",
-                sf2[i * 2], sf2[i * 2 + 1], "sf2"));
+        ds.addSequenceFeature(new SequenceFeature("sf2", "sf2", sf2[i * 2],
+                sf2[i * 2 + 1], "sf2"));
       }
       if (sf3[i * 2] > 0)
       {
-        ds.addSequenceFeature(new SequenceFeature("sf3", "sf3", "sf3",
-                sf3[i * 2], sf3[i * 2 + 1], "sf3"));
+        ds.addSequenceFeature(new SequenceFeature("sf3", "sf3", sf3[i * 2],
+                sf3[i * 2 + 1], "sf3"));
       }
     }
     alf.setShowSeqFeatures(true);
index 7b0bc0c..d105cc5 100644 (file)
@@ -137,41 +137,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");
index e3e39f7..d7e720e 100644 (file)
@@ -466,7 +466,7 @@ public class SequenceTest
      * Note JAL-2046: spurious: we have no use case for this at the moment.
      * This test also buggy - as sf2.equals(sf), no new feature is added
      */
-    SequenceFeature sf2 = new SequenceFeature("Scop", "desc", 2, 5, 1f,
+    SequenceFeature sf2 = new SequenceFeature("Cath", "desc", 2, 4, 2f,
             null);
     sq.getDatasetSequence().addSequenceFeature(sf2);
     sfs = sq.getSequenceFeatures();
index 822fcd4..1beca80 100644 (file)
@@ -114,13 +114,15 @@ public class FeatureColourTest
     assertEquals(Color.WHITE, fc.getColor(sf));
 
     // score 120 is adjusted to top of range
-    sf.setScore(120f);
+    sf = new SequenceFeature(sf, sf.getBegin(), sf.getEnd(),
+            sf.getFeatureGroup(), 120f);
     assertEquals(Color.BLACK, fc.getColor(sf));
 
     // value below threshold is still rendered
     // setting threshold has no effect yet...
     fc.setThreshold(60f);
-    sf.setScore(36f);
+    sf = new SequenceFeature(sf, sf.getBegin(), sf.getEnd(),
+            sf.getFeatureGroup(), 36f);
     assertTrue(fc.isColored(sf));
     assertEquals(new Color(204, 204, 204), fc.getColor(sf));
 
@@ -130,7 +132,9 @@ public class FeatureColourTest
     // colour is still returned though ?!?
     assertEquals(new Color(204, 204, 204), fc.getColor(sf));
 
-    sf.setScore(84); // above threshold now
+    sf = new SequenceFeature(sf, sf.getBegin(), sf.getEnd(),
+            sf.getFeatureGroup(), 84f);
+    // above threshold now
     assertTrue(fc.isColored(sf));
     assertEquals(new Color(51, 51, 51), fc.getColor(sf));
   }