Is secondary structure label modified
[jalview.git] / src / jalview / datamodel / AlignmentAnnotation.java
index 470497e..a97ca7f 100755 (executable)
@@ -103,21 +103,57 @@ public class AlignmentAnnotation
         this.description = description;
         this.annotations = annotations;
 
-        for (int i = 0; i < annotations.length; i++)
+       areLabelsSecondaryStructure();
+    }
+
+    void areLabelsSecondaryStructure()
+    {
+      boolean nonSSLabel = false;
+      for (int i = 0; i < annotations.length; i++)
+      {
+        if(annotations[i]==null)
+          continue;
+
+        if (annotations[i].secondaryStructure == 'H' ||
+            annotations[i].secondaryStructure == 'E')
         {
-            if ((annotations[i] != null) &&
-                    ((annotations[i].secondaryStructure == 'H') ||
-                    (annotations[i].secondaryStructure == 'E')))
-            {
-                hasIcons = true;
-            }
+          hasIcons = true;
+        }
+
+        if (annotations[i].displayCharacter.length()==1
+            && !annotations[i].displayCharacter.equals("H")
+            && !annotations[i].displayCharacter.equals("E")
+            && !annotations[i].displayCharacter.equals("-"))
+        {
+          if(jalview.schemes.ResidueProperties.aaIndex
+             [annotations[i].displayCharacter.charAt(0)]>0)
+          {
+            nonSSLabel = true;
+          }
+        }
+
+        if (annotations[i].displayCharacter.length() > 0)
+        {
+          hasText = true;
+        }
+      }
+
+      if(nonSSLabel)
+      {
+        hasIcons = false;
+        for (int j = 0; j < annotations.length; j++)
+        {
+          if(annotations[j] !=null && annotations[j].secondaryStructure!=' ')
+          {
+            annotations[j].displayCharacter
+                =String.valueOf(annotations[j].secondaryStructure);
+            annotations[j].secondaryStructure = ' ';
+          }
 
-            if ((annotations[i] != null) &&
-                    (annotations[i].displayCharacter.length() > 0))
-            {
-                hasText = true;
-            }
         }
+
+      }
+
     }
 
     /**
@@ -171,23 +207,7 @@ public class AlignmentAnnotation
         graphMin = min;
         graphMax = max;
 
-        for (int i = 0; i < annotations.length; i++)
-        {
-            if (!hasIcons
-                && annotations[i] != null
-                && ((annotations[i].secondaryStructure == 'H') ||
-                    (annotations[i].secondaryStructure == 'E')))
-            {
-                hasIcons = true;
-            }
-
-            if (!hasText
-                && annotations[i]!=null
-                && annotations[i].displayCharacter.length() > 0)
-            {
-                hasText = true;
-            }
-        }
+        areLabelsSecondaryStructure();
 
         if(!drawValues && graphType!=NO_GRAPH)
         {
@@ -258,9 +278,10 @@ public class AlignmentAnnotation
       }
 
       /**
-       * Attach the annotation to seqRef, starting from startRes position.
+       * Attach the annotation to seqRef, starting from startRes position. If alreadyMapped is true then the indices of the annotation[] array are sequence positions rather than alignment column positions.
        * @param seqRef
        * @param startRes
+       * @param alreadyMapped
        */
       public void createSequenceMapping(SequenceI seqRef,
                                         int startRes,