From ebe0c31476d408f10e968bed024e898c02c7204e Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 19 Jun 2015 17:45:50 +0100 Subject: [PATCH] JAL-653 JAL-1780 refactor getGroups so HTMLfile/JSONfile adopt same pattern as other parsers --- src/jalview/io/AlignFile.java | 9 +++++++++ src/jalview/io/AppletFormatAdapter.java | 22 +++++----------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index b66fb11..e4891f0 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -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); + } + } + } diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 1633212..7810771 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -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) { -- 1.7.10.2