Merge branch 'develop' into features/JAL-1705_ensembl
[jalview.git] / src / jalview / datamodel / Alignment.java
index 81046f1..7ea9985 100755 (executable)
  */
 package jalview.datamodel;
 
+import jalview.analysis.AlignmentUtils;
+import jalview.io.FastaFile;
+import jalview.util.MessageManager;
+
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashSet;
@@ -30,10 +34,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.Vector;
 
-import jalview.analysis.AlignmentUtils;
-import jalview.io.FastaFile;
-import jalview.util.MessageManager;
-
 /**
  * Data structure to hold and manipulate a multiple sequence alignment
  */
@@ -147,7 +147,9 @@ public class Alignment implements AlignmentI
    */
   public static AlignmentI createAlignment(CigarArray compactAlignment)
   {
-    throw new Error(MessageManager.getString("error.alignment_cigararray_not_implemented"));
+    throw new Error(
+            MessageManager
+                    .getString("error.alignment_cigararray_not_implemented"));
     // this(compactAlignment.refCigars);
   }
 
@@ -236,8 +238,7 @@ public class Alignment implements AlignmentI
     }
     if (sequences == null)
     {
-      initAlignment(new SequenceI[]
-      { snew });
+      initAlignment(new SequenceI[] { snew });
     }
     else
     {
@@ -1588,38 +1589,37 @@ public class Alignment implements AlignmentI
     }
   }
 
+  private SequenceI seqrep = null;
 
- private SequenceI seqrep=null;
-
- /**
-  * 
-  * @return the representative sequence for this group
-  */
- public SequenceI getSeqrep()
- {
-   return seqrep;
- }
+  /**
+   * 
+   * @return the representative sequence for this group
+   */
+  public SequenceI getSeqrep()
+  {
+    return seqrep;
+  }
 
- /**
-  * set the representative sequence for this group. Note - this affects the
-  * interpretation of the Hidereps attribute.
-  * 
-  * @param seqrep
-  *          the seqrep to set (null means no sequence representative)
-  */
- public void setSeqrep(SequenceI seqrep)
- {
-   this.seqrep = seqrep;
- }
+  /**
+   * set the representative sequence for this group. Note - this affects the
+   * interpretation of the Hidereps attribute.
+   * 
+   * @param seqrep
+   *          the seqrep to set (null means no sequence representative)
+   */
+  public void setSeqrep(SequenceI seqrep)
+  {
+    this.seqrep = seqrep;
+  }
 
- /**
-  * 
-  * @return true if group has a sequence representative
-  */
- public boolean hasSeqrep()
- {
-   return seqrep != null;
- }
+  /**
+   * 
+   * @return true if group has a sequence representative
+   */
+  public boolean hasSeqrep()
+  {
+    return seqrep != null;
+  }
 
   @Override
   public int getEndRes()
@@ -1678,7 +1678,7 @@ public class Alignment implements AlignmentI
    * @param preserveUnmappedGaps
    *          if true, gaps within and between unmapped codons are preserved
    */
-//  @Override
+  // @Override
   public int alignAs(AlignmentI al, boolean preserveMappedGaps,
           boolean preserveUnmappedGaps)
   {
@@ -1693,9 +1693,8 @@ public class Alignment implements AlignmentI
 
     char thisGapChar = this.getGapCharacter();
     String gap = thisIsNucleotide && thatIsProtein ? String
-            .valueOf(new char[]
-            { thisGapChar, thisGapChar, thisGapChar }) : String
-            .valueOf(thisGapChar);
+            .valueOf(new char[] { thisGapChar, thisGapChar, thisGapChar })
+            : String.valueOf(thisGapChar);
 
     // TODO handle intron regions? Needs a 'holistic' alignment of dna,
     // not just sequence by sequence. But how to 'gap' intron regions?
@@ -1705,8 +1704,8 @@ public class Alignment implements AlignmentI
      */
     for (SequenceI alignTo : getSequences())
     {
-      count += AlignmentUtils.alignSequenceAs(alignTo, al, gap, preserveMappedGaps,
-              preserveUnmappedGaps) ? 1 : 0;
+      count += AlignmentUtils.alignSequenceAs(alignTo, al, gap,
+              preserveMappedGaps, preserveUnmappedGaps) ? 1 : 0;
     }
     return count;
   }
@@ -1734,4 +1733,19 @@ public class Alignment implements AlignmentI
     }
     return names;
   }
+
+  @Override
+  public boolean hasValidSequence()
+  {
+    boolean hasValidSeq = false;
+    for (SequenceI seq : getSequences())
+    {
+      if ((seq.getEnd() - seq.getStart()) > 0)
+      {
+        hasValidSeq = true;
+        break;
+      }
+    }
+    return hasValidSeq;
+  }
 }