edit jws2 job parameters before running job
[jalview.git] / src / jalview / gui / Jalview2XML.java
index 51e26b8..af8b2c0 100755 (executable)
@@ -1,20 +1,19 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
  * 
- * This program 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 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
  * 
- * This program 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.
+ * 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.
  * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ * 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/>.
  */
 package jalview.gui;
 
@@ -586,9 +585,9 @@ public class Jalview2XML
                                       jmol.pdbentry.getId().toLowerCase())))
                 continue;
               matchedFile = jmol.pdbentry.getFile(); // record the file so we
-                                                     // can get at it if the ID
-                                                     // match is ambiguous (e.g.
-                                                     // 1QIP==1qipA)
+              // can get at it if the ID
+              // match is ambiguous (e.g.
+              // 1QIP==1qipA)
               StructureState state = new StructureState();
               state.setVisible(true);
               state.setXpos(jmol.getX());
@@ -782,7 +781,6 @@ public class Jalview2XML
 
         an.setId(aa[i].annotationId);
 
-        
         an.setVisible(aa[i].visible);
 
         an.setDescription(aa[i].description);
@@ -793,22 +791,25 @@ public class Jalview2XML
           // sequence rather than its display name
           an.setSequenceRef(aa[i].sequenceRef.getName());
         }
-        if (aa[i].groupRef!=null)
+        if (aa[i].groupRef != null)
         {
           Object groupIdr = groupRefs.get(aa[i].groupRef);
-          if (groupIdr==null)
+          if (groupIdr == null)
           {
             // make a locally unique String
-            groupRefs.put(aa[i].groupRef, groupIdr = (""+System.currentTimeMillis()+aa[i].groupRef.getName()+groupRefs.size()));
+            groupRefs.put(aa[i].groupRef,
+                    groupIdr = ("" + System.currentTimeMillis()
+                            + aa[i].groupRef.getName() + groupRefs.size()));
           }
           an.setGroupRef(groupIdr.toString());
         }
         if (aa[i] == av.quality || aa[i] == av.conservation
                 || aa[i] == av.consensus || aa[i].autoCalculated)
         {
-          // new way of indicating autocalculated annotation - 
+          // new way of indicating autocalculated annotation -
           an.setAutoCalculated(aa[i].autoCalculated);
-          // write a stub for this annotation - indicate presence of autocalc rows
+          // write a stub for this annotation - indicate presence of autocalc
+          // rows
           an.setLabel(aa[i].label);
           an.setGraph(true);
           vamsasSet.addAnnotation(an);
@@ -895,9 +896,10 @@ public class Jalview2XML
                 .getGroups().elementAt(i);
         groups[i].setStart(sg.getStartRes());
         groups[i].setEnd(sg.getEndRes());
-        groups[i].setName(sg.getName()); 
-        if (groupRefs.containsKey(sg)) {
-          // group has references so set it's ID field 
+        groups[i].setName(sg.getName());
+        if (groupRefs.containsKey(sg))
+        {
+          // group has references so set it's ID field
           groups[i].setId(groupRefs.get(sg).toString());
         }
         if (sg.cs != null)
@@ -944,10 +946,10 @@ public class Jalview2XML
         groups[i].setTextCol1(sg.textColour.getRGB());
         groups[i].setTextCol2(sg.textColour2.getRGB());
         groups[i].setTextColThreshold(sg.thresholdTextColour);
-        groups[i].setShowUnconserved(sg.getShowunconserved());
+        groups[i].setShowUnconserved(sg.getShowNonconserved());
         groups[i].setIgnoreGapsinConsensus(sg.getIgnoreGapsConsensus());
         groups[i].setShowConsensusHistogram(sg.isShowConsensusHistogram());
-        groups[i].setShowConsensusProfile(sg.isIncludeAllConsSymbols());
+        groups[i].setShowSequenceLogo(sg.isShowSequenceLogo());
         for (int s = 0; s < sg.getSize(); s++)
         {
           jalview.datamodel.Sequence seq = (jalview.datamodel.Sequence) sg
@@ -1060,7 +1062,7 @@ public class Jalview2XML
     view.setTextCol2(av.textColour2.getRGB());
     view.setTextColThreshold(av.thresholdTextColour);
     view.setShowConsensusHistogram(av.isShowConsensusHistogram());
-    view.setShowConsensusProfile(av.isShowConsensusProfile());
+    view.setShowSequenceLogo(av.isShowSequenceLogo());
     view.setShowGroupConsensus(av.isShowGroupConsensus());
     view.setShowGroupConservation(av.isShowGroupConservation());
     view.setShowNPfeatureTooltip(av.isShowNpFeats());
@@ -1075,15 +1077,17 @@ public class Jalview2XML
       String[] renderOrder = ap.seqPanel.seqCanvas.getFeatureRenderer().renderOrder;
 
       Vector settingsAdded = new Vector();
-      Object gstyle=null;
-      GraduatedColor gcol = null; 
+      Object gstyle = null;
+      GraduatedColor gcol = null;
       for (int ro = 0; ro < renderOrder.length; ro++)
       {
-        gstyle = ap.seqPanel.seqCanvas.getFeatureRenderer().getFeatureStyle(renderOrder[ro]);
+        gstyle = ap.seqPanel.seqCanvas.getFeatureRenderer()
+                .getFeatureStyle(renderOrder[ro]);
         Setting setting = new Setting();
         setting.setType(renderOrder[ro]);
-        if (gstyle instanceof GraduatedColor) {
-          gcol  = (GraduatedColor) gstyle;
+        if (gstyle instanceof GraduatedColor)
+        {
+          gcol = (GraduatedColor) gstyle;
           setting.setColour(gcol.getMaxColor().getRGB());
           setting.setMincolour(gcol.getMinColor().getRGB());
           setting.setMin(gcol.getMin());
@@ -1092,10 +1096,13 @@ public class Jalview2XML
           setting.setAutoScale(gcol.isAutoScale());
           setting.setThreshold(gcol.getThresh());
           setting.setThreshstate(gcol.getThreshType());
-        } else {
-          setting.setColour(ap.seqPanel.seqCanvas.getFeatureRenderer()      .getColour(renderOrder[ro]).getRGB());
         }
-        
+        else
+        {
+          setting.setColour(ap.seqPanel.seqCanvas.getFeatureRenderer()
+                  .getColour(renderOrder[ro]).getRGB());
+        }
+
         setting.setDisplay(av.featuresDisplayed
                 .containsKey(renderOrder[ro]));
         float rorder = ap.seqPanel.seqCanvas.getFeatureRenderer().getOrder(
@@ -1391,14 +1398,15 @@ public class Jalview2XML
   {
     String id = null;
     jalview.schemes.UserColourScheme ucs = (jalview.schemes.UserColourScheme) cs;
-    boolean newucs=false;
+    boolean newucs = false;
     if (!userColours.contains(ucs))
     {
       userColours.add(ucs);
-      newucs=true;
+      newucs = true;
     }
     id = "ucs" + userColours.indexOf(ucs);
-    if (newucs) {
+    if (newucs)
+    {
       // actually create the scheme's entry in the XML model
       java.awt.Color[] colours = ucs.getColours();
       jalview.schemabinding.version2.UserColours uc = new jalview.schemabinding.version2.UserColours();
@@ -2048,7 +2056,7 @@ public class Jalview2XML
         {
           hideConsensus = false;
           continue;
-        }        
+        }
         // set visiblity for other annotation in this view
         if (an[i].getId() != null
                 && annotationIds.containsKey(an[i].getId()))
@@ -2137,9 +2145,9 @@ public class Jalview2XML
           }
         }
         // and make a note of any group association
-        if (an[i].getGroupRef()!=null && an[i].getGroupRef().length()>0)
+        if (an[i].getGroupRef() != null && an[i].getGroupRef().length() > 0)
         {
-          groupAnnotRefs.put(an[i].getGroupRef(),jaa);
+          groupAnnotRefs.put(an[i].getGroupRef(), jaa);
         }
 
         if (an[i].hasScore())
@@ -2148,18 +2156,20 @@ public class Jalview2XML
         }
         if (an[i].hasVisible())
           jaa.visible = an[i].getVisible();
-        
+
         if (an[i].hasCentreColLabels())
           jaa.centreColLabels = an[i].getCentreColLabels();
-        
+
         if (an[i].hasScaleColLabels())
         {
           jaa.scaleColLabel = an[i].getScaleColLabels();
         }
         if (an[i].hasAutoCalculated() && an[i].isAutoCalculated())
         {
-          // newer files have an 'autoCalculated' flag and store calculation state in viewport properties
-          jaa.autoCalculated = true; // means annotation will be marked for update at end of load. 
+          // newer files have an 'autoCalculated' flag and store calculation
+          // state in viewport properties
+          jaa.autoCalculated = true; // means annotation will be marked for
+          // update at end of load.
         }
         al.addAnnotation(jaa);
       }
@@ -2223,14 +2233,19 @@ public class Jalview2XML
 
         sg.textColour = new java.awt.Color(groups[i].getTextCol1());
         sg.textColour2 = new java.awt.Color(groups[i].getTextCol2());
-        sg.setShowunconserved(groups[i].hasShowUnconserved() ? groups[i]
+        sg.setShowNonconserved(groups[i].hasShowUnconserved() ? groups[i]
                 .isShowUnconserved() : false);
         sg.thresholdTextColour = groups[i].getTextColThreshold();
-        if (groups[i].hasShowConsensusHistogram()) {
-          sg.setShowConsensusHistogram(groups[i].isShowConsensusHistogram());
-        };
-        if (groups[i].hasShowConsensusProfile()) {
-          sg.setIncludeAllConsSymbols(groups[i].isShowConsensusProfile());
+        if (groups[i].hasShowConsensusHistogram())
+        {
+          sg
+                  .setShowConsensusHistogram(groups[i]
+                          .isShowConsensusHistogram());
+        }
+        ;
+        if (groups[i].hasShowSequenceLogo())
+        {
+          sg.setshowSequenceLogo(groups[i].isShowSequenceLogo());
         }
         if (groups[i].hasIgnoreGapsinConsensus())
         {
@@ -2245,19 +2260,19 @@ public class Jalview2XML
           c.verdict(false, 25);
           sg.cs.setConservation(c);
         }
-        
-        if (groups[i].getId()!=null
-                && groupAnnotRefs.size()>0)
+
+        if (groups[i].getId() != null && groupAnnotRefs.size() > 0)
         {
           // re-instate unique group/annotation row reference
-          jalview.datamodel.AlignmentAnnotation jaa = (jalview.datamodel.AlignmentAnnotation) groupAnnotRefs.get(groups[i].getId());
-          if (jaa!=null)
+          jalview.datamodel.AlignmentAnnotation jaa = (jalview.datamodel.AlignmentAnnotation) groupAnnotRefs
+                  .get(groups[i].getId());
+          if (jaa != null)
           {
             jaa.groupRef = sg;
           }
         }
         al.addGroup(sg);
-        
+
       }
     }
 
@@ -2683,85 +2698,91 @@ public class Jalview2XML
       else if (view.getBgColour().startsWith("Annotation"))
       {
         // int find annotation
-        for (int i = 0; i < af.viewport.alignment.getAlignmentAnnotation().length; i++)
+        if (af.viewport.alignment.getAlignmentAnnotation() != null)
         {
-          if (af.viewport.alignment.getAlignmentAnnotation()[i].label
-                  .equals(view.getAnnotationColours().getAnnotation()))
+          for (int i = 0; i < af.viewport.alignment
+                  .getAlignmentAnnotation().length; i++)
           {
-            if (af.viewport.alignment.getAlignmentAnnotation()[i]
-                    .getThreshold() == null)
+            if (af.viewport.alignment.getAlignmentAnnotation()[i].label
+                    .equals(view.getAnnotationColours().getAnnotation()))
             {
-              af.viewport.alignment.getAlignmentAnnotation()[i]
-                      .setThreshold(new jalview.datamodel.GraphLine(view
-                              .getAnnotationColours().getThreshold(),
-                              "Threshold", java.awt.Color.black)
-
-                      );
-            }
+              if (af.viewport.alignment.getAlignmentAnnotation()[i]
+                      .getThreshold() == null)
+              {
+                af.viewport.alignment.getAlignmentAnnotation()[i]
+                        .setThreshold(new jalview.datamodel.GraphLine(view
+                                .getAnnotationColours().getThreshold(),
+                                "Threshold", java.awt.Color.black)
 
-            if (view.getAnnotationColours().getColourScheme()
-                    .equals("None"))
-            {
-              cs = new AnnotationColourGradient(af.viewport.alignment
-                      .getAlignmentAnnotation()[i], new java.awt.Color(view
-                      .getAnnotationColours().getMinColour()),
-                      new java.awt.Color(view.getAnnotationColours()
-                              .getMaxColour()), view.getAnnotationColours()
-                              .getAboveThreshold());
-            }
-            else if (view.getAnnotationColours().getColourScheme()
-                    .startsWith("ucs"))
-            {
-              cs = new AnnotationColourGradient(af.viewport.alignment
-                      .getAlignmentAnnotation()[i], GetUserColourScheme(
-                      jms, view.getAnnotationColours().getColourScheme()),
-                      view.getAnnotationColours().getAboveThreshold());
-            }
-            else
-            {
-              cs = new AnnotationColourGradient(af.viewport.alignment
-                      .getAlignmentAnnotation()[i], ColourSchemeProperty
-                      .getColour(al, view.getAnnotationColours()
-                              .getColourScheme()), view
-                      .getAnnotationColours().getAboveThreshold());
-            }
+                        );
+              }
 
-            // Also use these settings for all the groups
-            if (al.getGroups() != null)
-            {
-              for (int g = 0; g < al.getGroups().size(); g++)
+              if (view.getAnnotationColours().getColourScheme().equals(
+                      "None"))
+              {
+                cs = new AnnotationColourGradient(af.viewport.alignment
+                        .getAlignmentAnnotation()[i], new java.awt.Color(
+                        view.getAnnotationColours().getMinColour()),
+                        new java.awt.Color(view.getAnnotationColours()
+                                .getMaxColour()), view
+                                .getAnnotationColours().getAboveThreshold());
+              }
+              else if (view.getAnnotationColours().getColourScheme()
+                      .startsWith("ucs"))
               {
-                jalview.datamodel.SequenceGroup sg = (jalview.datamodel.SequenceGroup) al
-                        .getGroups().elementAt(g);
+                cs = new AnnotationColourGradient(af.viewport.alignment
+                        .getAlignmentAnnotation()[i],
+                        GetUserColourScheme(jms, view
+                                .getAnnotationColours().getColourScheme()),
+                        view.getAnnotationColours().getAboveThreshold());
+              }
+              else
+              {
+                cs = new AnnotationColourGradient(af.viewport.alignment
+                        .getAlignmentAnnotation()[i], ColourSchemeProperty
+                        .getColour(al, view.getAnnotationColours()
+                                .getColourScheme()), view
+                        .getAnnotationColours().getAboveThreshold());
+              }
 
-                if (sg.cs == null)
+              // Also use these settings for all the groups
+              if (al.getGroups() != null)
+              {
+                for (int g = 0; g < al.getGroups().size(); g++)
                 {
-                  continue;
-                }
+                  jalview.datamodel.SequenceGroup sg = (jalview.datamodel.SequenceGroup) al
+                          .getGroups().elementAt(g);
 
-                /*
-                 * if
-                 * (view.getAnnotationColours().getColourScheme().equals("None"
-                 * )) { sg.cs = new AnnotationColourGradient(
-                 * af.viewport.alignment.getAlignmentAnnotation()[i], new
-                 * java.awt.Color(view.getAnnotationColours(). getMinColour()),
-                 * new java.awt.Color(view.getAnnotationColours().
-                 * getMaxColour()),
-                 * view.getAnnotationColours().getAboveThreshold()); } else
-                 */
-                {
-                  sg.cs = new AnnotationColourGradient(
-                          af.viewport.alignment.getAlignmentAnnotation()[i],
-                          sg.cs, view.getAnnotationColours()
-                                  .getAboveThreshold());
-                }
+                  if (sg.cs == null)
+                  {
+                    continue;
+                  }
+
+                  /*
+                   * if
+                   * (view.getAnnotationColours().getColourScheme().equals("None"
+                   * )) { sg.cs = new AnnotationColourGradient(
+                   * af.viewport.alignment.getAlignmentAnnotation()[i], new
+                   * java.awt.Color(view.getAnnotationColours().
+                   * getMinColour()), new
+                   * java.awt.Color(view.getAnnotationColours().
+                   * getMaxColour()),
+                   * view.getAnnotationColours().getAboveThreshold()); } else
+                   */
+                  {
+                    sg.cs = new AnnotationColourGradient(
+                            af.viewport.alignment.getAlignmentAnnotation()[i],
+                            sg.cs, view.getAnnotationColours()
+                                    .getAboveThreshold());
+                  }
 
+                }
               }
+
+              break;
             }
 
-            break;
           }
-
         }
       }
       else
@@ -2798,7 +2819,8 @@ public class Jalview2XML
     }
     if (view.hasIgnoreGapsinConsensus())
     {
-      af.viewport.ignoreGapsInConsensusCalculation=view.getIgnoreGapsinConsensus();
+      af.viewport.ignoreGapsInConsensusCalculation = view
+              .getIgnoreGapsinConsensus();
     }
     if (view.hasFollowHighlight())
     {
@@ -2810,11 +2832,20 @@ public class Jalview2XML
     }
     if (view.hasShowConsensusHistogram())
     {
-      af.viewport.setShowConsensusHistogram(view.getShowConsensusHistogram());
+      af.viewport.setShowConsensusHistogram(view
+              .getShowConsensusHistogram());
     }
-    if (view.hasShowConsensusProfile())
+    else
     {
-      af.viewport.setShowConsensusProfile(view.getShowConsensusProfile());
+      af.viewport.setShowConsensusHistogram(true);
+    }
+    if (view.hasShowSequenceLogo())
+    {
+      af.viewport.setShowSequenceLogo(view.getShowSequenceLogo());
+    }
+    else
+    {
+      af.viewport.setShowSequenceLogo(false);
     }
     if (view.hasShowDbRefTooltip())
     {
@@ -2828,11 +2859,19 @@ public class Jalview2XML
     {
       af.viewport.setShowGroupConsensus(view.getShowGroupConsensus());
     }
+    else
+    {
+      af.viewport.setShowGroupConsensus(false);
+    }
     if (view.hasShowGroupConservation())
     {
       af.viewport.setShowGroupConservation(view.getShowGroupConservation());
     }
-    
+    else
+    {
+      af.viewport.setShowGroupConservation(false);
+    }
+
     // recover featre settings
     if (jms.getFeatureSettings() != null)
     {
@@ -2844,12 +2883,12 @@ public class Jalview2XML
         Setting setting = jms.getFeatureSettings().getSetting(fs);
         if (setting.hasMincolour())
         {
-          GraduatedColor gc = setting.hasMin() ? new GraduatedColor(new java.awt.Color(setting
-                  .getMincolour()),
-                  new java.awt.Color(setting.getColour()), setting.getMin(), setting.getMax())
-          : new GraduatedColor(new java.awt.Color(setting
-                  .getMincolour()),
-                  new java.awt.Color(setting.getColour()), 0,1);
+          GraduatedColor gc = setting.hasMin() ? new GraduatedColor(
+                  new java.awt.Color(setting.getMincolour()),
+                  new java.awt.Color(setting.getColour()),
+                  setting.getMin(), setting.getMax()) : new GraduatedColor(
+                  new java.awt.Color(setting.getMincolour()),
+                  new java.awt.Color(setting.getColour()), 0, 1);
           if (setting.hasThreshold())
           {
             gc.setThresh(setting.getThreshold());
@@ -2865,7 +2904,8 @@ public class Jalview2XML
             gc.setColourByLabel(setting.getColourByLabel());
           }
           // and put in the feature colour table.
-          af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(setting.getType(),gc);
+          af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().setColour(
+                  setting.getType(), gc);
         }
         else
         {
@@ -2908,10 +2948,10 @@ public class Jalview2XML
     }
 
     af.setMenusFromViewport(af.viewport);
-    af.alignPanel.updateAnnotation(false); // recompute any autoannotation
     // TODO: we don't need to do this if the viewport is aready visible.
     Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(), view
             .getHeight());
+    af.alignPanel.updateAnnotation(false); // recompute any autoannotation
     return af;
   }
 
@@ -3278,9 +3318,9 @@ public class Jalview2XML
     {
       uniqueSetSuffix = "";
       jm.getJalviewModelSequence().getViewport(0).setId(null); // we don't
-                                                               // overwrite the
-                                                               // view we just
-                                                               // copied
+      // overwrite the
+      // view we just
+      // copied
     }
     if (this.frefedSequence == null)
     {