Merge branch 'develop' into bug/JAL-2541cutRelocateFeatures
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 17 Jan 2018 14:35:19 +0000 (14:35 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 17 Jan 2018 14:35:19 +0000 (14:35 +0000)
1  2 
src/jalview/datamodel/features/FeatureStore.java
src/jalview/datamodel/features/SequenceFeatures.java
src/jalview/datamodel/features/SequenceFeaturesI.java

@@@ -1,3 -1,23 +1,23 @@@
+ /*
+  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+  * Copyright (C) $$Year-Rel$$ The Jalview Authors
+  * 
+  * This file is part of Jalview.
+  * 
+  * Jalview is free software: you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License 
+  * as published by the Free Software Foundation, either version 3
+  * of the License, or (at your option) any later version.
+  *  
+  * Jalview is distributed in the hope that it will be useful, but 
+  * WITHOUT ANY WARRANTY; without even the implied warranty 
+  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+  * PURPOSE.  See the GNU General Public License for more details.
+  * 
+  * You should have received a copy of the GNU General Public License
+  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+  * The Jalview Authors are detailed in the 'AUTHORS' file.
+  */
  package jalview.datamodel.features;
  
  import jalview.datamodel.ContiguousI;
@@@ -1027,15 -1047,13 +1047,15 @@@ public class FeatureStor
    }
  
    /**
 -   * Adds the shift value to the start and end of all positional features.
 -   * Returns true if at least one feature was updated, else false.
 +   * Adds the shift amount to the start and end of all positional features whose
 +   * start position is at or after fromPosition. Returns true if at least one
 +   * feature was shifted, else false.
     * 
 -   * @param shift
 +   * @param fromPosition
 +   * @param shiftBy
     * @return
     */
 -  public synchronized boolean shiftFeatures(int shift)
 +  public synchronized boolean shiftFeatures(int fromPosition, int shiftBy)
    {
      /*
       * Because begin and end are final fields (to ensure the data store's
      boolean modified = false;
      for (SequenceFeature sf : getPositionalFeatures())
      {
 -      modified = true;
 -      int newBegin = sf.getBegin() + shift;
 -      int newEnd = sf.getEnd() + shift;
 -
 -      /*
 -       * sanity check: don't shift left of the first residue
 -       */
 -      if (newEnd > 0)
 +      if (sf.getBegin() >= fromPosition)
        {
 -        newBegin = Math.max(1, newBegin);
 -        SequenceFeature sf2 = new SequenceFeature(sf, newBegin, newEnd,
 -                sf.getFeatureGroup(), sf.getScore());
 -        addFeature(sf2);
 +        modified = true;
 +        int newBegin = sf.getBegin() + shiftBy;
 +        int newEnd = sf.getEnd() + shiftBy;
 +
 +        /*
 +         * sanity check: don't shift left of the first residue
 +         */
 +        if (newEnd > 0)
 +        {
 +          newBegin = Math.max(1, newBegin);
 +          SequenceFeature sf2 = new SequenceFeature(sf, newBegin, newEnd,
 +                  sf.getFeatureGroup(), sf.getScore());
 +          addFeature(sf2);
 +        }
 +        delete(sf);
        }
 -      delete(sf);
      }
      return modified;
    }
@@@ -1,3 -1,23 +1,23 @@@
+ /*
+  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+  * Copyright (C) $$Year-Rel$$ The Jalview Authors
+  * 
+  * This file is part of Jalview.
+  * 
+  * Jalview is free software: you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License 
+  * as published by the Free Software Foundation, either version 3
+  * of the License, or (at your option) any later version.
+  *  
+  * Jalview is distributed in the hope that it will be useful, but 
+  * WITHOUT ANY WARRANTY; without even the implied warranty 
+  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+  * PURPOSE.  See the GNU General Public License for more details.
+  * 
+  * You should have received a copy of the GNU General Public License
+  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+  * The Jalview Authors are detailed in the 'AUTHORS' file.
+  */
  package jalview.datamodel.features;
  
  import jalview.datamodel.ContiguousI;
@@@ -451,22 -471,13 +471,22 @@@ public class SequenceFeatures implement
     * {@inheritDoc}
     */
    @Override
 -  public boolean shiftFeatures(int shift)
 +  public boolean shiftFeatures(int fromPosition, int shiftBy)
    {
      boolean modified = false;
      for (FeatureStore fs : featureStore.values())
      {
 -      modified |= fs.shiftFeatures(shift);
 +      modified |= fs.shiftFeatures(fromPosition, shiftBy);
      }
      return modified;
    }
 -}
 +
 +  /**
 +   * {@inheritDoc}
 +   */
 +  @Override
 +  public void deleteAll()
 +  {
 +    featureStore.clear();
 +  }
 +}
@@@ -1,3 -1,23 +1,23 @@@
+ /*
+  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+  * Copyright (C) $$Year-Rel$$ The Jalview Authors
+  * 
+  * This file is part of Jalview.
+  * 
+  * Jalview is free software: you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License 
+  * as published by the Free Software Foundation, either version 3
+  * of the License, or (at your option) any later version.
+  *  
+  * Jalview is distributed in the hope that it will be useful, but 
+  * WITHOUT ANY WARRANTY; without even the implied warranty 
+  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+  * PURPOSE.  See the GNU General Public License for more details.
+  * 
+  * You should have received a copy of the GNU General Public License
+  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+  * The Jalview Authors are detailed in the 'AUTHORS' file.
+  */
  package jalview.datamodel.features;
  
  import jalview.datamodel.SequenceFeature;
@@@ -195,17 -215,10 +215,17 @@@ public interface SequenceFeatures
    float getMaximumScore(String type, boolean positional);
  
    /**
 -   * Adds the shift amount to the start and end of all positional features,
 -   * returning true if at least one feature was shifted, else false
 +   * Adds the shift amount to the start and end of all positional features whose
 +   * start position is at or after fromPosition. Returns true if at least one
 +   * feature was shifted, else false.
     * 
 -   * @param shift
 +   * @param fromPosition
 +   * @param shiftBy
     */
 -  abstract boolean shiftFeatures(int shift);
 -}
 +  boolean shiftFeatures(int fromPosition, int shiftBy);
 +
 +  /**
 +   * Deletes all positional and non-positional features
 +   */
 +  void deleteAll();
 +}