JAL-653 JAL-1780 refactor getGroups so HTMLfile/JSONfile adopt same pattern as other...
authorJim Procter <jprocter@issues.jalview.org>
Fri, 19 Jun 2015 16:45:50 +0000 (17:45 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Fri, 19 Jun 2015 16:45:50 +0000 (17:45 +0100)
src/jalview/io/AlignFile.java
src/jalview/io/AppletFormatAdapter.java

index b66fb11..e4891f0 100755 (executable)
@@ -378,4 +378,13 @@ public abstract class AlignFile extends FileParse
     return newickStrings == null ? 0 : newickStrings.size();
   }
 
+  public void addGroups(AlignmentI al)
+  {
+
+    for (SequenceGroup sg : getSeqGroups())
+    {
+      al.addGroup(sg);
+    }
+  }
+
 }
index 1633212..7810771 100755 (executable)
@@ -285,26 +285,10 @@ public class AppletFormatAdapter
       else if (format.equals(JSONFile.FILE_DESC))
       {
         alignFile = new JSONFile(inFile, type);
-        al = new Alignment(alignFile.getSeqsAsArray());
-        alignFile.addAnnotations(al);
-        ((JSONFile) alignFile).setViewport(viewport);
-        for (SequenceGroup sg : alignFile.getSeqGroups())
-        {
-          al.addGroup(sg);
-        }
-
-        return al;
       }
       else if (format.equals(HtmlFile.FILE_DESC))
       {
         alignFile = new HtmlFile(inFile, type);
-        al = new Alignment(alignFile.getSeqsAsArray());
-        alignFile.addAnnotations(al);
-        for (SequenceGroup sg : alignFile.getSeqGroups())
-        {
-          al.addGroup(sg);
-        }
-        return al;
       }
       else if (format.equals("RNAML"))
       {
@@ -314,11 +298,15 @@ public class AppletFormatAdapter
       {
         alignFile = new Gff3File(inFile, type);
       }
-
+      // Standard boilerplate for creating alignment from parser
+      alignFile.setViewport(viewport);
+      
       al = new Alignment(alignFile.getSeqsAsArray());
 
       alignFile.addAnnotations(al);
 
+      alignFile.addGroups(al);
+
       return al;
     } catch (Exception e)
     {