JAL-2505 use constructors to set (what will be) final fields in
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 9 May 2017 07:46:21 +0000 (08:46 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 9 May 2017 07:46:21 +0000 (08:46 +0100)
SequenceFeature

src/MCview/PDBChain.java
src/jalview/analysis/AlignmentUtils.java
src/jalview/datamodel/Mapping.java
src/jalview/datamodel/SequenceFeature.java
src/jalview/ext/ensembl/EnsemblSeqProxy.java
src/jalview/io/gff/Gff3Helper.java

index ba93046..1f47014 100755 (executable)
@@ -207,11 +207,13 @@ public class PDBChain
       if (features[i].getFeatureGroup() != null
               && features[i].getFeatureGroup().equals(pdbid))
       {
-        SequenceFeature tx = new SequenceFeature(features[i]);
-        tx.setBegin(1 + residues.elementAt(tx.getBegin() - offset).atoms
-                .elementAt(0).alignmentMapping);
-        tx.setEnd(1 + residues.elementAt(tx.getEnd() - offset).atoms
-                .elementAt(0).alignmentMapping);
+        int newBegin = 1 + residues.elementAt(features[i].getBegin()
+                - offset).atoms
+                .elementAt(0).alignmentMapping;
+        int newEnd = 1 + residues.elementAt(features[i].getEnd() - offset).atoms
+                .elementAt(0).alignmentMapping;
+        SequenceFeature tx = new SequenceFeature(features[i], newBegin,
+                newEnd, features[i].getFeatureGroup());
         tx.setStatus(status
                 + ((tx.getStatus() == null || tx.getStatus().length() == 0) ? ""
                         : ":" + tx.getStatus()));
index 232cb5d..955de28 100644 (file)
@@ -2133,9 +2133,10 @@ public class AlignmentUtils
         }
         if (mappedTo != null)
         {
-          SequenceFeature copy = new SequenceFeature(sf);
-          copy.setBegin(Math.min(mappedTo[0], mappedTo[1]));
-          copy.setEnd(Math.max(mappedTo[0], mappedTo[1]));
+          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());
           copyTo.addSequenceFeature(copy);
           count++;
         }
index 1c196be..4dea30c 100644 (file)
@@ -530,9 +530,8 @@ public class Mapping
         SequenceFeature[] vf = new SequenceFeature[frange.length / 2];
         for (int i = 0, v = 0; i < frange.length; i += 2, v++)
         {
-          vf[v] = new SequenceFeature(f);
-          vf[v].setBegin(frange[i]);
-          vf[v].setEnd(frange[i + 1]);
+          vf[v] = new SequenceFeature(f, frange[i], frange[i + 1],
+                  f.getFeatureGroup());
           if (frange.length > 2)
           {
             vf[v].setDescription(f.getDescription() + "\nPart " + (v + 1));
index 8eacb68..719cf52 100755 (executable)
@@ -178,6 +178,24 @@ public class SequenceFeature implements FeatureLocationI
   }
 
   /**
+   * A copy constructor that allows the begin and end positions and group to be
+   * modified
+   * 
+   * @param sf
+   * @param newBegin
+   * @param newEnd
+   * @param newGroup
+   */
+  public SequenceFeature(SequenceFeature sf, int newBegin, int newEnd,
+          String newGroup)
+  {
+    this(sf);
+    begin = newBegin;
+    end = newEnd;
+    featureGroup = newGroup;
+  }
+
+  /**
    * 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.
index 233707b..2d0e3fe 100644 (file)
@@ -658,13 +658,15 @@ public abstract class EnsemblSeqProxy extends EnsemblRestClient
 
     if (mappedRange != null)
     {
-      SequenceFeature copy = new SequenceFeature(sf);
-      copy.setBegin(Math.min(mappedRange[0], mappedRange[1]));
-      copy.setEnd(Math.max(mappedRange[0], mappedRange[1]));
-      if (".".equals(copy.getFeatureGroup()))
+      String group = sf.getFeatureGroup();
+      if (".".equals(group))
       {
-        copy.setFeatureGroup(getDbSource());
+        group = getDbSource();
       }
+      int newBegin = Math.min(mappedRange[0], mappedRange[1]);
+      int newEnd = Math.max(mappedRange[0], mappedRange[1]);
+      SequenceFeature copy = new SequenceFeature(sf, newBegin, newEnd,
+              group);
       targetSequence.addSequenceFeature(copy);
 
       /*
index 82e5313..0273f9b 100644 (file)
@@ -310,10 +310,9 @@ public class Gff3Helper extends GffHelperBase
          * give the mapped sequence a copy of the sequence feature, with 
          * start/end range adjusted 
          */
-        SequenceFeature sf2 = new SequenceFeature(sf);
-        sf2.setBegin(1);
         int sequenceFeatureLength = 1 + sf.getEnd() - sf.getBegin();
-        sf2.setEnd(sequenceFeatureLength);
+        SequenceFeature sf2 = new SequenceFeature(sf, 1,
+                sequenceFeatureLength, sf.getFeatureGroup());
         mappedSequence.addSequenceFeature(sf2);
 
         /*