JAL-1807 explicit imports (jalview.structure)
[jalview.git] / src / jalview / io / VamsasAppDatastore.java
index 735f415..7608e51 100644 (file)
@@ -1,25 +1,29 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
- *
+ * 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
+ * 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/>.
+ * 
+ * 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.io;
 
 import jalview.bin.Cache;
 import jalview.datamodel.AlignedCodonFrame;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentI;
 import jalview.datamodel.GraphLine;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
@@ -30,6 +34,10 @@ import jalview.io.vamsas.Datasetsequence;
 import jalview.io.vamsas.DatastoreItem;
 import jalview.io.vamsas.DatastoreRegistry;
 import jalview.io.vamsas.Rangetype;
+import jalview.util.MapList;
+import jalview.util.MessageManager;
+import jalview.viewmodel.AlignmentViewport;
+
 import java.io.IOException;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -37,12 +45,35 @@ import java.util.Hashtable;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 import java.util.Vector;
 import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
 
-import uk.ac.vamsas.client.*;
-import uk.ac.vamsas.objects.core.*;
+import uk.ac.vamsas.client.IClientAppdata;
+import uk.ac.vamsas.client.IClientDocument;
+import uk.ac.vamsas.client.Vobject;
+import uk.ac.vamsas.client.VorbaId;
+import uk.ac.vamsas.objects.core.Alignment;
+import uk.ac.vamsas.objects.core.AlignmentSequence;
+import uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation;
+import uk.ac.vamsas.objects.core.AnnotationElement;
+import uk.ac.vamsas.objects.core.DataSet;
+import uk.ac.vamsas.objects.core.DataSetAnnotations;
+import uk.ac.vamsas.objects.core.DbRef;
+import uk.ac.vamsas.objects.core.Entry;
+import uk.ac.vamsas.objects.core.Glyph;
+import uk.ac.vamsas.objects.core.Local;
+import uk.ac.vamsas.objects.core.MapType;
+import uk.ac.vamsas.objects.core.Mapped;
+import uk.ac.vamsas.objects.core.Property;
+import uk.ac.vamsas.objects.core.Provenance;
+import uk.ac.vamsas.objects.core.RangeAnnotation;
+import uk.ac.vamsas.objects.core.RangeType;
+import uk.ac.vamsas.objects.core.Seg;
+import uk.ac.vamsas.objects.core.Sequence;
+import uk.ac.vamsas.objects.core.SequenceType;
+import uk.ac.vamsas.objects.core.VAMSAS;
 import uk.ac.vamsas.objects.utils.Properties;
 
 /*
@@ -122,7 +153,7 @@ public class VamsasAppDatastore
   private void buildSkipList()
   {
     skipList = new Hashtable();
-    AlignFrame[] al = Desktop.getAlignframes();
+    AlignFrame[] al = Desktop.getAlignFrames();
     for (int f = 0; al != null && f < al.length; f++)
     {
       skipList.put(al[f].getViewport().getSequenceSetId(), al[f]);
@@ -178,7 +209,7 @@ public class VamsasAppDatastore
   }
 
   /**
-   *
+   * 
    * @param vobj
    * @return Jalview datamodel object bound to the vamsas document object
    */
@@ -219,8 +250,7 @@ public class VamsasAppDatastore
     {
       Cache.log.debug(
               "Warning? Overwriting existing vamsas id binding for "
-                      + vobj.getVorbaId(), new Exception(
-                      "Overwriting vamsas id binding."));
+                      + vobj.getVorbaId(), new Exception(MessageManager.getString("exception.overwriting_vamsas_id_binding")));
     }
     else if (jv2vobj.containsKey(jvobj)
             && !((VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
@@ -245,7 +275,7 @@ public class VamsasAppDatastore
 
   /**
    * put the alignment viewed by AlignViewport into cdoc.
-   *
+   * 
    * @param av
    *          alignViewport to be stored
    * @param aFtitle
@@ -257,8 +287,8 @@ public class VamsasAppDatastore
   {
     try
     {
-      jalview.datamodel.AlignmentI jal = av.getAlignment();
-      jalview.datamodel.AlignmentI jds = jal.getDataset();
+      AlignmentI jal = av.getAlignment();
+      AlignmentI jds = jal.getDataset();
       boolean nw = false;
       VAMSAS root = null; // will be resolved based on Dataset Parent.
       // /////////////////////////////////////////
@@ -307,8 +337,7 @@ public class VamsasAppDatastore
                 if (vbound.getV_parent() != null
                         && dataset != vbound.getV_parent())
                 {
-                  throw new Error(
-                          "IMPLEMENTATION ERROR: Cannot map an alignment of sequences from different datasets into a single alignment in the vamsas document.");
+                  throw new Error(MessageManager.getString("error.implementation_error_cannot_map_alignment_sequences"));
                   // This occurs because the dataset for the alignment we are
                   // trying to
                 }
@@ -486,14 +515,14 @@ public class VamsasAppDatastore
           /*
            * We do not put local Alignment Sequence Features into the vamsas
            * document yet.
-           *
-           *
+           * 
+           * 
            * jalview.datamodel.SequenceFeature[] features = alseq
            * .getSequenceFeatures(); for (int f = 0; f < features.length; f++) {
            * if (features[f] != null) { AlignmentSequenceAnnotation valseqf = (
            * AlignmentSequenceAnnotation) getjv2vObj(features[i]); if (valseqf
            * == null) {
-           *
+           * 
            * valseqf = (AlignmentSequenceAnnotation) getDSAnnotationFromJalview(
            * new AlignmentSequenceAnnotation(), features[i]);
            * valseqf.setGraph(false);
@@ -511,7 +540,7 @@ public class VamsasAppDatastore
       // SAVE ANNOTATIONS
       if (jal.getAlignmentAnnotation() != null)
       {
-        jalview.datamodel.AlignmentAnnotation[] aa = jal
+        AlignmentAnnotation[] aa = jal
                 .getAlignmentAnnotation();
         java.util.HashMap AlSeqMaps = new HashMap(); // stores int maps from
         // alignment columns to
@@ -541,7 +570,8 @@ public class VamsasAppDatastore
             else
             {
               // first find the alignment sequence to associate this with.
-              for (SequenceI jvalsq:av.getAlignment().getSequences()) {
+              for (SequenceI jvalsq : av.getAlignment().getSequences())
+              {
                 // saveDatasetSequenceAnnotation(AlSeqMaps,(uk.ac.vamsas.objects.core.Sequence)
                 // sref, aa[i]);
                 if (jvalsq.getDatasetSequence() == aa[i].sequenceRef)
@@ -639,7 +669,7 @@ public class VamsasAppDatastore
               }
               setAnnotationType(an, aa[i]);
 
-              if (aa[i].graph != jalview.datamodel.AlignmentAnnotation.NO_GRAPH)
+              if (aa[i].graph != AlignmentAnnotation.NO_GRAPH)
               {
                 an.setGraph(true);
                 an.setGroup(Integer.toString(aa[i].graphGroup));
@@ -719,17 +749,17 @@ public class VamsasAppDatastore
    * very quick test to see if the viewport would be stored in the vamsas
    * document. Reasons for not storing include the unaligned flag being false
    * (for all sequences, including the hidden ones!)
-   *
+   * 
    * @param av
    * @return true if alignment associated with this view will be stored in
    *         document.
    */
-  public boolean alignmentWillBeSkipped(AlignViewport av)
+  public boolean alignmentWillBeSkipped(AlignmentViewport av)
   {
     return (!av.getAlignment().isAligned());
   }
 
-  private void addToSkipList(AlignViewport av)
+  private void addToSkipList(AlignmentViewport av)
   {
     if (skipList == null)
     {
@@ -741,7 +771,7 @@ public class VamsasAppDatastore
   /**
    * remove docseqs from the given alignment marking provenance appropriately
    * and removing any references to the sequences.
-   *
+   * 
    * @param alignment
    * @param docseqs
    */
@@ -809,7 +839,7 @@ public class VamsasAppDatastore
    * vamsas alignment sequence for jvalsq and adds it to the alignment if
    * necessary. unbounddocseq is a duplicate of the vamsas alignment sequences
    * and these are removed after being processed w.r.t a bound jvalsq
-   *
+   * 
    */
   private boolean syncToAlignmentSequence(SequenceI jvalsq,
           Alignment alignment, Vector unbounddocseq)
@@ -1013,7 +1043,7 @@ public class VamsasAppDatastore
       // of
       // utf8
       // translation
-      if (alan.graph != jalview.datamodel.AlignmentAnnotation.NO_GRAPH)
+      if (alan.graph != AlignmentAnnotation.NO_GRAPH)
       {
         ae.addValue(alan.annotations[a].value);
       }
@@ -1064,8 +1094,10 @@ public class VamsasAppDatastore
         an.addProperty(Properties.newProperty(THRESHOLD,
                 Properties.FLOATTYPE, "" + alan.getThreshold().value));
         if (alan.getThreshold().label != null)
+        {
           an.addProperty(Properties.newProperty(THRESHOLD + "Name",
                   Properties.STRINGTYPE, "" + alan.getThreshold().label));
+        }
       }
       ((DataSet) sref.getV_parent()).addDataSetAnnotations(an);
       bindjvvobj(alan, an);
@@ -1158,7 +1190,7 @@ public class VamsasAppDatastore
 
   /**
    * set vamsas annotation object type from jalview annotation
-   *
+   * 
    * @param an
    * @param alan
    */
@@ -1206,7 +1238,7 @@ public class VamsasAppDatastore
   /**
    * get start<end range of segment, adjusting for inclusivity flag and
    * polarity.
-   *
+   * 
    * @param visSeg
    * @param ensureDirection
    *          when true - always ensure start is less than end.
@@ -1233,7 +1265,7 @@ public class VamsasAppDatastore
   }
 
   /**
-   *
+   * 
    * @param annotation
    * @return true if annotation is not to be stored in document
    */
@@ -1293,14 +1325,14 @@ public class VamsasAppDatastore
               @Override
               public JarInputStream getJarInputStream() throws IOException
               {
-                jalview.bin.Cache.log
+                Cache.log
                         .debug("Returning client input stream for Jalview from Vamsas Document.");
                 return new JarInputStream(cappdata.getClientInputStream());
               }
             };
             if (dojvsync)
             {
-              fromxml.LoadJalviewAlign(jprovider);
+              fromxml.loadJalviewAlign(jprovider);
             }
           } catch (Exception e)
           {
@@ -1341,14 +1373,14 @@ public class VamsasAppDatastore
             @Override
             public JarInputStream getJarInputStream() throws IOException
             {
-              jalview.bin.Cache.log
+              Cache.log
                       .debug("Returning user input stream for Jalview from Vamsas Document.");
               return new JarInputStream(cappdata.getUserInputStream());
             }
           };
           if (dojvsync)
           {
-            fromxml.LoadJalviewAlign(jarstream);
+            fromxml.loadJalviewAlign(jarstream);
           }
         } catch (Exception e)
         {
@@ -1377,12 +1409,12 @@ public class VamsasAppDatastore
     // sync,
     // and if any contain more than one view, then remove the one generated by
     // document update.
-    AlignViewport views[], av = null;
+    AlignmentViewport views[], av = null;
     AlignFrame af = null;
     Iterator newviews = newAlignmentViews.iterator();
     while (newviews.hasNext())
     {
-      av = (AlignViewport) newviews.next();
+      av = (AlignmentViewport) newviews.next();
       af = Desktop.getAlignFrameFor(av);
       // TODO implement this : af.getNumberOfViews
       String seqsetidobj = av.getSequenceSetId();
@@ -1399,7 +1431,8 @@ public class VamsasAppDatastore
         // to the align frames.
         boolean gathered = false;
         String newviewid = null;
-        AlignedCodonFrame[] mappings = av.getAlignment().getCodonFrames();
+        Set<AlignedCodonFrame> mappings = av.getAlignment()
+                .getCodonFrames();
         for (int i = 0; i < views.length; i++)
         {
           if (views[i] != av)
@@ -1434,10 +1467,11 @@ public class VamsasAppDatastore
         {
           // ensure sequence mappings from vamsas document view still
           // active
-          if (mappings != null && mappings.length > 0)
+          if (mappings != null)
           {
             jalview.structure.StructureSelectionManager
-                    .getStructureSelectionManager(Desktop.instance).addMappings(mappings);
+                    .getStructureSelectionManager(Desktop.instance)
+                    .addMappings(mappings);
           }
         }
       }
@@ -1456,7 +1490,7 @@ public class VamsasAppDatastore
   /**
    * replaces oldjvobject with newjvobject in the Jalview Object <> VorbaID
    * binding tables
-   *
+   * 
    * @param oldjvobject
    * @param newjvobject
    *          (may be null)
@@ -1466,10 +1500,9 @@ public class VamsasAppDatastore
     Object vobject = jv2vobj.remove(oldjvobject);
     if (vobject == null)
     {
-      // NOTE: this happens if user deletes object in one session then updates from another client
-      throw new Error(
-              "IMPLEMENTATION ERROR: old jalview object is not bound ! ("
-                      + oldjvobject + ")");
+      // NOTE: this happens if user deletes object in one session then updates
+      // from another client
+      throw new Error(MessageManager.formatMessage("error.implementation_error_old_jalview_object_not_bound", new String[]{oldjvobject.toString()}));
     }
     if (newjvobject != null)
     {
@@ -1494,28 +1527,28 @@ public class VamsasAppDatastore
         jxml.setSkipList(skipList);
         if (dojvsync)
         {
-          jxml.SaveState(new JarOutputStream(cappdata
+          jxml.saveState(new JarOutputStream(cappdata
                   .getClientOutputStream()));
         }
 
       } catch (Exception e)
       {
         // TODO raise GUI warning if user requests it.
-        jalview.bin.Cache.log
+        Cache.log
                 .error("Couldn't update jalview client application data. Giving up - local settings probably lost.",
                         e);
       }
     }
     else
     {
-      jalview.bin.Cache.log
+      Cache.log
               .error("Couldn't access client application data for vamsas session. This is probably a vamsas client bug.");
     }
   }
 
   /**
    * translate the Vobject keys to strings for use in Jalview2XML
-   *
+   * 
    * @param jv2vobj2
    * @return
    */
@@ -1533,7 +1566,7 @@ public class VamsasAppDatastore
 
   /**
    * translate the Vobject values to strings for use in Jalview2XML
-   *
+   * 
    * @param vobj2jv2
    * @return hashtable with string values
    */
@@ -1551,7 +1584,7 @@ public class VamsasAppDatastore
 
   /**
    * synchronize Jalview from the vamsas document
-   *
+   * 
    * @return number of new views from document
    */
   public int updateToJalview()
@@ -1637,7 +1670,7 @@ public class VamsasAppDatastore
               // annotations
               if (dsSeq == null)
               {
-                jalview.bin.Cache.log
+                Cache.log
                         .warn("Couldn't resolve jalview sequenceI for dataset object reference "
                                 + ((Vobject) dataset.getDataSetAnnotations(
                                         dsa).getSeqRef(0)).getVorbaId()
@@ -1678,9 +1711,9 @@ public class VamsasAppDatastore
             uk.ac.vamsas.objects.core.Alignment alignment = dataset
                     .getAlignment(al);
             // TODO check this handles multiple views properly
-            AlignViewport av = findViewport(alignment);
+            AlignmentViewport av = findViewport(alignment);
 
-            jalview.datamodel.AlignmentI jal = null;
+            AlignmentI jal = null;
             if (av != null)
             {
               // TODO check that correct alignment object is retrieved when
@@ -1722,7 +1755,7 @@ public class VamsasAppDatastore
                         .getAlignmentSequenceAnnotation();
                 for (int a = 0; a < vasannot.length; a++)
                 {
-                  jalview.datamodel.AlignmentAnnotation asa = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(vasannot[a]); // TODO:
+                  AlignmentAnnotation asa = (AlignmentAnnotation) getvObj2jv(vasannot[a]); // TODO:
                   // 1:many
                   // jalview
                   // alignment
@@ -1778,7 +1811,7 @@ public class VamsasAppDatastore
               for (i = 0, iSize = dsseqs.size(); i < iSize; i++)
               {
                 seqs[i] = dsseqs.get(i);
-                dsseqs.set(i,null);
+                dsseqs.set(i, null);
               }
               jal = new jalview.datamodel.Alignment(seqs);
               Cache.log.debug("New vamsas alignment imported into jalview "
@@ -1808,7 +1841,7 @@ public class VamsasAppDatastore
 
               for (int j = 0; j < an.length; j++)
               {
-                jalview.datamodel.AlignmentAnnotation jan = (jalview.datamodel.AlignmentAnnotation) getvObj2jv(an[j]);
+                AlignmentAnnotation jan = (AlignmentAnnotation) getvObj2jv(an[j]);
                 if (jan != null)
                 {
                   // update or stay the same.
@@ -1952,10 +1985,10 @@ public class VamsasAppDatastore
     return newAlignmentViews.size();
   }
 
-  public AlignViewport findViewport(Alignment alignment)
+  public AlignmentViewport findViewport(Alignment alignment)
   {
-    AlignViewport av = null;
-    AlignViewport[] avs = Desktop
+    AlignmentViewport av = null;
+    AlignmentViewport[] avs = Desktop
             .getViewports((String) getvObj2jv(alignment));
     if (avs != null)
     {
@@ -1982,7 +2015,7 @@ public class VamsasAppDatastore
    * jalview.datamodel.Annotation[] rows Two annotation rows are made if there
    * are distinct annotation for both at 'pos' and 'after pos' at any particular
    * site.
-   *
+   * 
    * @param annotation
    * @return { boolean[static int constants ], int[ae.length] - map to annotated
    *         object frame, jalview.datamodel.Annotation[],
@@ -2154,8 +2187,8 @@ public class VamsasAppDatastore
    * @param annotation
    * @return unbound jalview alignment annotation object.
    */
-  private jalview.datamodel.AlignmentAnnotation getjAlignmentAnnotation(
-          jalview.datamodel.AlignmentI jal,
+  private AlignmentAnnotation getjAlignmentAnnotation(
+          AlignmentI jal,
           uk.ac.vamsas.objects.core.RangeAnnotation annotation)
   {
     if (annotation == null)
@@ -2203,6 +2236,7 @@ public class VamsasAppDatastore
             Cache.log.warn("Failed to parse threshold property");
           }
           if (val != null)
+          {
             if (gl == null)
             {
               gl = new GraphLine(val.floatValue(), "", java.awt.Color.black);
@@ -2211,16 +2245,19 @@ public class VamsasAppDatastore
             {
               gl.value = val.floatValue();
             }
+          }
         }
         else if (props[p].getName().equalsIgnoreCase(THRESHOLD + "Name"))
         {
           if (gl == null)
+          {
             gl = new GraphLine(0, "", java.awt.Color.black);
+          }
           gl.label = props[p].getContent();
         }
       }
     }
-    jalview.datamodel.AlignmentAnnotation jan = null;
+    AlignmentAnnotation jan = null;
     if (a_label == null || a_label.length() == 0)
     {
       a_label = annotation.getType();
@@ -2262,14 +2299,14 @@ public class VamsasAppDatastore
       {
         if (type == 0)
         {
-          type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH; // default
+          type = AlignmentAnnotation.BAR_GRAPH; // default
           // type of
           // value
           // annotation
           if (has[HASHPHOB])
           {
             // no hints - so we ensure HPHOB display is like this.
-            type = jalview.datamodel.AlignmentAnnotation.BAR_GRAPH;
+            type = AlignmentAnnotation.BAR_GRAPH;
           }
         }
         // make bounds and automatic description strings for jalview user's
@@ -2341,7 +2378,7 @@ public class VamsasAppDatastore
             }
           }
         }
-        jan = new jalview.datamodel.AlignmentAnnotation(a_label, a_descr,
+        jan = new AlignmentAnnotation(a_label, a_descr,
                 arow, min, max, type);
       }
       else
@@ -2353,7 +2390,7 @@ public class VamsasAppDatastore
           // width - if it is not complete, then mark regions on the annotation
           // row.
         }
-        jan = new jalview.datamodel.AlignmentAnnotation(a_label, a_descr,
+        jan = new AlignmentAnnotation(a_label, a_descr,
                 arow);
         jan.setThreshold(null);
         jan.annotationId = annotation.getVorbaId().toString(); // keep all the
@@ -2400,7 +2437,7 @@ public class VamsasAppDatastore
    * get real bounds of a RangeType's specification. start and end are an
    * inclusive range within which all segments and positions lie. TODO: refactor
    * to vamsas utils
-   *
+   * 
    * @param dseta
    * @return int[] { start, end}
    */
@@ -2411,8 +2448,7 @@ public class VamsasAppDatastore
       int[] se = null;
       if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0)
       {
-        throw new Error(
-                "Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!");
+        throw new Error(MessageManager.getString("error.invalid_vamsas_rangetype_cannot_resolve_lists"));
       }
       if (dseta.getSegCount() > 0)
       {
@@ -2458,7 +2494,7 @@ public class VamsasAppDatastore
   /**
    * map from a rangeType's internal frame to the referenced object's coordinate
    * frame.
-   *
+   * 
    * @param dseta
    * @return int [] { ref(pos)...} for all pos in rangeType's frame.
    */
@@ -2470,8 +2506,7 @@ public class VamsasAppDatastore
       int[] se = null;
       if (dseta.getSegCount() > 0 && dseta.getPosCount() > 0)
       {
-        throw new Error(
-                "Invalid vamsas RangeType - cannot resolve both lists of Pos and Seg from choice!");
+          throw new Error(MessageManager.getString("error.invalid_vamsas_rangetype_cannot_resolve_lists"));
       }
       if (dseta.getSegCount() > 0)
       {
@@ -2510,7 +2545,7 @@ public class VamsasAppDatastore
   }
 
   /**
-   *
+   * 
    * @param maprange
    *          where the from range is the local mapped range, and the to range
    *          is the 'mapped' range in the MapRangeType
@@ -2518,46 +2553,46 @@ public class VamsasAppDatastore
    * @param default unit for mapped
    * @return MapList
    */
-  private jalview.util.MapList parsemapType(MapType maprange, int localu,
+  private MapList parsemapType(MapType maprange, int localu,
           int mappedu)
   {
-    jalview.util.MapList ml = null;
+    MapList ml = null;
     int[] localRange = getMapping(maprange.getLocal());
     int[] mappedRange = getMapping(maprange.getMapped());
     long lu = maprange.getLocal().hasUnit() ? maprange.getLocal().getUnit()
             : localu;
     long mu = maprange.getMapped().hasUnit() ? maprange.getMapped()
             .getUnit() : mappedu;
-    ml = new jalview.util.MapList(localRange, mappedRange, (int) lu,
+    ml = new MapList(localRange, mappedRange, (int) lu,
             (int) mu);
     return ml;
   }
 
   /**
    * initialise a range type object from a set of start/end inclusive intervals
-   *
+   * 
    * @param mrt
-   * @param range
+   * @param ranges
    */
-  private void initRangeType(RangeType mrt, int[] range)
+  private void initRangeType(RangeType mrt, List<int[]> ranges)
   {
-    for (int i = 0; i < range.length; i += 2)
+    for (int[] range : ranges)
     {
       Seg vSeg = new Seg();
-      vSeg.setStart(range[i]);
-      vSeg.setEnd(range[i + 1]);
+      vSeg.setStart(range[0]);
+      vSeg.setEnd(range[1]);
       mrt.addSeg(vSeg);
     }
   }
 
   /**
    * initialise a MapType object from a MapList object.
-   *
+   * 
    * @param maprange
    * @param ml
    * @param setUnits
    */
-  private void initMapType(MapType maprange, jalview.util.MapList ml,
+  private void initMapType(MapType maprange, MapList ml,
           boolean setUnits)
   {
     maprange.setLocal(new Local());
@@ -2577,12 +2612,12 @@ public class VamsasAppDatastore
    * App and Action here. Provenance prov = new Provenance();
    * org.exolab.castor.types.Date date = new org.exolab.castor.types.Date( new
    * java.util.Date()); Entry provEntry;
-   *
+   * 
    * if (jprov != null) { entries = jprov.getEntries(); for (int i = 0; i <
    * entries.length; i++) { provEntry = new Entry(); try { date = new
    * org.exolab.castor.types.Date(entries[i].getDate()); } catch (Exception ex)
    * { ex.printStackTrace();
-   *
+   * 
    * date = new org.exolab.castor.types.Date(entries[i].getDate()); }
    * provEntry.setDate(date); provEntry.setUser(entries[i].getUser());
    * provEntry.setAction(entries[i].getAction()); prov.addEntry(provEntry); } }
@@ -2590,7 +2625,7 @@ public class VamsasAppDatastore
    * provEntry.setUser(System.getProperty("user.name")); // TODO: ext string
    * provEntry.setApp("JVAPP"); // TODO: ext string provEntry.setAction(action);
    * prov.addEntry(provEntry); }
-   *
+   * 
    * return prov; }
    */
   jalview.datamodel.Provenance getJalviewProvenance(Provenance prov)
@@ -2608,7 +2643,7 @@ public class VamsasAppDatastore
   }
 
   /**
-   *
+   * 
    * @return default initial provenance list for a Jalview created vamsas
    *         object.
    */
@@ -2668,13 +2703,13 @@ public class VamsasAppDatastore
     return vobj2jv;
   }
 
-  public void storeSequenceMappings(AlignViewport viewport, String title)
+  public void storeSequenceMappings(AlignmentViewport viewport, String title)
           throws Exception
   {
-    AlignViewport av = viewport;
+    AlignmentViewport av = viewport;
     try
     {
-      jalview.datamodel.AlignmentI jal = av.getAlignment();
+      AlignmentI jal = av.getAlignment();
       // /////////////////////////////////////////
       // SAVE THE DATASET
       DataSet dataset = null;
@@ -2693,18 +2728,15 @@ public class VamsasAppDatastore
 
       }
       // Store any sequence mappings.
-      if (av.getAlignment().getCodonFrames() != null
-              && av.getAlignment().getCodonFrames().length > 0)
+      Set<AlignedCodonFrame> cframes = av.getAlignment().getCodonFrames();
+      if (cframes != null)
       {
-        jalview.datamodel.AlignedCodonFrame[] cframes = av.getAlignment()
-                .getCodonFrames();
-        for (int cf = 0; cf < cframes.length; cf++)
+        for (AlignedCodonFrame acf : cframes)
         {
-          if (cframes[cf].getdnaSeqs() != null
-                  && cframes[cf].getdnaSeqs().length > 0)
+          if (acf.getdnaSeqs() != null && acf.getdnaSeqs().length > 0)
           {
-            jalview.datamodel.SequenceI[] dmps = cframes[cf].getdnaSeqs();
-            jalview.datamodel.Mapping[] mps = cframes[cf].getProtMappings();
+            jalview.datamodel.SequenceI[] dmps = acf.getdnaSeqs();
+            jalview.datamodel.Mapping[] mps = acf.getProtMappings();
             for (int smp = 0; smp < mps.length; smp++)
             {
               uk.ac.vamsas.objects.core.SequenceType mfrom = (SequenceType) getjv2vObj(dmps[smp]);
@@ -2727,8 +2759,7 @@ public class VamsasAppDatastore
       }
     } catch (Exception e)
     {
-      throw new Exception("Couldn't store sequence mappings for " + title,
-              e);
+      throw new Exception(MessageManager.formatMessage("exception.couldnt_store_sequence_mappings", new String[]{title}),e);
     }
   }