isNucleotide
authoramwaterhouse <Andrew Waterhouse>
Thu, 22 Sep 2005 15:50:47 +0000 (15:50 +0000)
committeramwaterhouse <Andrew Waterhouse>
Thu, 22 Sep 2005 15:50:47 +0000 (15:50 +0000)
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentI.java

index 61735ee..ac8f47a 100755 (executable)
@@ -33,6 +33,8 @@ public class Alignment implements AlignmentI
     protected Vector groups = new Vector();\r
     protected Vector superGroup = new Vector();\r
     protected char gapCharacter = '-';\r
+    protected boolean isNucleotide = true;\r
+\r
 \r
     /** DOCUMENT ME!! */\r
     public AlignmentAnnotation[] annotations;\r
@@ -46,9 +48,25 @@ public class Alignment implements AlignmentI
      */\r
     public Alignment(SequenceI[] seqs)\r
     {\r
+        int i=0, iSize = seqs.length, j, jSize;\r
+        while(isNucleotide && i<iSize)\r
+        {\r
+            jSize = seqs[i].getLength();\r
+            for(j=0; j<jSize; j++)\r
+            {\r
+              if(!jalview.schemes.ResidueProperties.nucleotideHash.containsKey(seqs[i].getSequence(j, j+1))\r
+              && !jalview.util.Comparison.isGap(seqs[i].getSequence().charAt(j)))\r
+              {\r
+                isNucleotide = false;\r
+                break;\r
+              }\r
+            }\r
+            i++;\r
+        }\r
+\r
         sequences = new Vector();\r
 \r
-        for (int i = 0; i < seqs.length; i++)\r
+        for (i = 0; i < seqs.length; i++)\r
         {\r
             sequences.addElement(seqs[i]);\r
         }\r
@@ -683,4 +701,14 @@ public class Alignment implements AlignmentI
     {\r
         return annotations;\r
     }\r
+\r
+    public void setNucleotide(boolean b)\r
+    {\r
+      isNucleotide = b;\r
+    }\r
+\r
+    public boolean isNucleotide()\r
+    {\r
+      return isNucleotide;\r
+    }\r
 }\r
index 416be69..4399b39 100755 (executable)
@@ -289,4 +289,19 @@ public interface AlignmentI
      * @return DOCUMENT ME!\r
      */\r
     public Vector getAAFrequency();\r
+\r
+    /**\r
+     * Returns true if alignment is nucleotide sequence\r
+     *\r
+     * @return DOCUMENT ME!\r
+     */\r
+    public boolean isNucleotide();\r
+\r
+    /**\r
+     * Set true if the alignment is a nucleotide sequence\r
+     *\r
+     * @return\r
+     */\r
+    public void setNucleotide(boolean b);\r
+\r
 }\r