check for null ss character
authoramwaterhouse <Andrew Waterhouse>
Thu, 26 Apr 2007 15:14:51 +0000 (15:14 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 26 Apr 2007 15:14:51 +0000 (15:14 +0000)
src/jalview/gui/Jalview2XML.java

index f0551e8..b90f497 100755 (executable)
@@ -349,6 +349,7 @@ public class Jalview2XML
               if (!jmol.pdbentry.getId().equals(entry.getId()))
                 continue;
 
+
               StructureState state = new StructureState();
               state.setVisible(true);
               state.setXpos(jmol.getX());
@@ -356,8 +357,11 @@ public class Jalview2XML
               state.setWidth(jmol.getWidth());
               state.setHeight(jmol.getHeight());
 
-              state.setContent(jmol.viewer.getStateInfo().replaceAll("\n", ""));
-
+              String statestring = jmol.viewer.getStateInfo();
+              if(state!=null)
+              {
+                state.setContent(statestring.replaceAll("\n", ""));
+              }
               for (int s = 0; s < jmol.sequence.length; s++)
               {
                 if (jal.findIndex(jmol.sequence[s]) > -1)
@@ -530,7 +534,7 @@ public class Jalview2XML
         }
 
         an.setLabel(aa[i].label);
-        if (aa[i].hasScore())
+        if (!Float.isNaN(aa[i].score))
         {
           an.setScore(aa[i].getScore());
         }
@@ -546,15 +550,22 @@ public class Jalview2XML
             }
 
             ae = new AnnotationElement();
-            ae.setDescription(aa[i].annotations[a].description);
-            ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter);
-            ae.setValue(aa[i].annotations[a].value);
+            if (aa[i].annotations[a].description != null)
+              ae.setDescription(aa[i].annotations[a].description);
+            if(aa[i].annotations[a].displayCharacter!=null)
+              ae.setDisplayCharacter(aa[i].annotations[a].displayCharacter);
+
+            if (!Float.isNaN(aa[i].annotations[a].value))
+              ae.setValue(aa[i].annotations[a].value);
+
             ae.setPosition(a);
-            ae
-                    .setSecondaryStructure(aa[i].annotations[a].secondaryStructure
-                            + "");
+            if (aa[i].annotations[a].secondaryStructure != ' '
+                && aa[i].annotations[a].secondaryStructure != '\0')
+              ae.setSecondaryStructure(aa[i].annotations[a].secondaryStructure
+                                       + "");
 
-            if (aa[i].annotations[a].colour != java.awt.Color.black)
+            if (aa[i].annotations[a].colour!=null
+                && aa[i].annotations[a].colour != java.awt.Color.black)
             {
               ae.setColour(aa[i].annotations[a].colour.getRGB());
             }
@@ -769,7 +780,7 @@ public class Jalview2XML
         fs.addSetting(setting);
         settingsAdded.addElement(renderOrder[ro]);
       }
-      
+
       //Make sure we save none displayed feature settings
       Enumeration en =
           ap.seqPanel.seqCanvas.getFeatureRenderer().featureColours.keys();
@@ -789,7 +800,7 @@ public class Jalview2XML
 
         setting.setDisplay(false);
         float rorder = ap.seqPanel.seqCanvas.getFeatureRenderer().getOrder(key);
-        if (rorder>-1) 
+        if (rorder>-1)
         {
           setting.setOrder(rorder);
         }
@@ -797,11 +808,11 @@ public class Jalview2XML
         settingsAdded.addElement(key);
       }
       en = ap.seqPanel.seqCanvas.getFeatureRenderer().featureGroups.keys();
-      Vector groupsAdded=new Vector(); 
+      Vector groupsAdded=new Vector();
       while (en.hasMoreElements())
       {
         String grp = en.nextElement().toString();
-        if (groupsAdded.contains(grp)) 
+        if (groupsAdded.contains(grp))
         {
           continue;
         }
@@ -1319,21 +1330,28 @@ public class Jalview2XML
 
         AnnotationElement[] ae = an[i].getAnnotationElement();
         jalview.datamodel.Annotation[] anot = null;
+
         if (!an[i].getScoreOnly())
-        { 
+        {
           anot = new jalview.datamodel.Annotation[
                     al.getWidth()];
 
           for (int aa = 0; aa < ae.length && aa < anot.length; aa++)
           {
-            anot[ae[aa].getPosition()] = new jalview.datamodel.Annotation(ae[aa].
-                    getDisplayCharacter(),
+
+            anot[ae[aa].getPosition()] = new jalview.datamodel.Annotation(
+
+                    ae[aa].getDisplayCharacter(),
                     ae[aa].getDescription(),
-                    ae[aa].getSecondaryStructure().length() == 0 ? ' ' :
+                    ae[aa].getSecondaryStructure()==null ? ' ' :
                       ae[aa].getSecondaryStructure().charAt(0),
-                      ae[aa].getValue());
-            anot[ae[aa].getPosition()].colour = new java.awt.Color(ae[aa].
-                    getColour());
+                      ae[aa].getValue()
+
+                            );
+
+
+              anot[ae[aa].getPosition()].colour = new java.awt.Color(ae[aa].
+                  getColour());
           }
         }
         jalview.datamodel.AlignmentAnnotation jaa = null;
@@ -1751,13 +1769,13 @@ public class Jalview2XML
           renderOrder;
       Hashtable fgtable;
       af.alignPanel.seqPanel.seqCanvas.getFeatureRenderer().featureGroups = fgtable=new Hashtable();
-      for (int gs=0;gs<jms.getFeatureSettings().getGroupCount(); gs++) 
+      for (int gs=0;gs<jms.getFeatureSettings().getGroupCount(); gs++)
       {
         Group grp = jms.getFeatureSettings().getGroup(gs);
         fgtable.put(grp.getName(), new Boolean(grp.getDisplay()));
       }
     }
-    
+
     if (view.getHiddenColumnsCount() > 0)
     {
       for (int c = 0; c < view.getHiddenColumnsCount(); c++)