JAL-2629 add hmmbuild validation check which also gets the HMMER version
[jalview.git] / src / jalview / io / HMMFile.java
index bf86c68..0f79c64 100644 (file)
@@ -16,7 +16,7 @@ import java.util.Scanner;
 
 
 /**
- * Adds capability to read in and write out HMMER3 files. Currently only supports HMMER3/f.
+ * Adds capability to read in and write out HMMER3 files. .
  * 
  * 
  * @author TZVanaalten
@@ -247,7 +247,7 @@ public class HMMFile extends AlignFile
    */
   void parseAnnotations(Scanner scanner, int index)
   {
-    if (hmm.mapIsActive())
+    if (hmm.mapIsActive() && scanner.hasNext())
     {
       int column;
       column = scanner.nextInt();
@@ -298,9 +298,10 @@ public class HMMFile extends AlignFile
    * @param numberOfElements
    *          The number of elements in the list to be filled.
    * @return filled list Returns the list of doubles.
+   * @throws IOException
    */
   static List<Double> fillList(Scanner input,
-          int numberOfElements)
+          int numberOfElements) throws IOException
   {
     List<Double> list = new ArrayList<>();
     for (int i = 0; i < numberOfElements; i++)
@@ -321,6 +322,10 @@ public class HMMFile extends AlignFile
         list.add(prob);
       }
     }
+    if (list.size() < numberOfElements)
+    {
+      throw new IOException("Incomplete data");
+    }
     return list;
   }