From 3ac9a19998fe3b2f4e4583bed327a13ca80c874b Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 21 Jan 2005 18:27:11 +0000 Subject: [PATCH] SuperGroups added --- src/jalview/datamodel/Alignment.java | 34 +++++++++-- src/jalview/datamodel/AlignmentI.java | 8 ++- src/jalview/datamodel/SequenceGroup.java | 61 +++++++++---------- src/jalview/datamodel/SuperGroup.java | 95 ++++++++++++++++++++++++++++++ src/jalview/gui/AlignFrame.java | 17 +++++- 5 files changed, 172 insertions(+), 43 deletions(-) create mode 100755 src/jalview/datamodel/SuperGroup.java diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index dd02bc1..f78f958 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -11,7 +11,8 @@ public class Alignment implements AlignmentI protected Vector sequences; protected Vector groups = new Vector(); - protected char gapCharacter = '-'; + protected ArrayList superGroup = new ArrayList(); + protected char gapCharacter = '-'; /** Make an alignment from an array of Sequences. * @@ -328,6 +329,7 @@ public class Alignment implements AlignmentI for (int i = 0; i < this.groups.size();i++) { SequenceGroup sg = (SequenceGroup)groups.elementAt(i); + if (sg.sequences.contains(s)) temp.add(sg); } @@ -356,17 +358,37 @@ public class Alignment implements AlignmentI } } + public void addSuperGroup(SuperGroup sg) + { + superGroup.add(sg); + } + + public void removeSuperGroup(SuperGroup sg) + { + superGroup.remove(sg); + } + + public SuperGroup getSuperGroup(SequenceGroup sg) + { + for (int i = 0; i < this.superGroup.size(); i++) + { + SuperGroup temp = (SuperGroup) superGroup.get(i); + if (temp.sequenceGroups.contains(sg)) + return temp; + } + return null; + } + /** */ public void addGroup(SequenceGroup sg) { if(!groups.contains(sg)) groups.addElement(sg); } - /** */ - public SequenceGroup addGroup() { - SequenceGroup sg = new SequenceGroup(); - groups.addElement(sg); - return sg; + public void deleteAllGroups() + { + groups.clear(); + superGroup.clear(); } /** */ diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 660a4fa..80b22ae 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -29,7 +29,7 @@ public interface AlignmentI { public void insertColumns(SequenceI[] seqs, int pos) ; public SequenceI findName(String name) ; - public SequenceI findbyDisplayId(String name); + public SequenceI findbyDisplayId(String name); public int findIndex(SequenceI s) ; @@ -48,9 +48,13 @@ public interface AlignmentI { public void addToGroup(SequenceGroup g, SequenceI s) ; public void removeFromGroup(SequenceGroup g,SequenceI s) ; public void addGroup(SequenceGroup sg) ; - public SequenceGroup addGroup() ; public void deleteGroup(SequenceGroup g) ; public Vector getGroups(); + public void deleteAllGroups(); + + public void addSuperGroup(SuperGroup sg); + public void removeSuperGroup(SuperGroup sg); + public SuperGroup getSuperGroup(SequenceGroup sg); // Sorting public void sortGroups() ; diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index d8c5c93..4d7509d 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -8,13 +8,11 @@ import java.util.Vector; public class SequenceGroup { String groupName; - boolean isSelected; + Conservation conserve; + Vector aaFrequency; boolean displayBoxes; boolean displayText; boolean colourText; - boolean display; - Conservation conserve; - Vector aaFrequency; boolean aaFrequencyValid = false; public Vector sequences = new Vector(); int width = -1; @@ -25,29 +23,23 @@ public class SequenceGroup public SequenceGroup() { groupName = "Group"; - this.isSelected = false; this.displayBoxes = true; this.displayText = true; this.colourText = false; - this.display = true; cs = null; } public SequenceGroup(String groupName, ColourSchemeI scheme, - boolean isSelected, boolean displayBoxes, boolean displayText, boolean colourText, - boolean display, int start, int end) { this.groupName = groupName; - this.isSelected = isSelected; this.displayBoxes = displayBoxes; this.displayText = displayText; this.colourText = colourText; - this.display = display; this.cs = scheme; startRes = start; endRes = end; @@ -92,64 +84,65 @@ public class SequenceGroup sequences.removeElement(s); } - public void setColourText(boolean state) + + public int getStartRes() { - colourText = state; + return startRes; } - public boolean getColourText() + public int getEndRes() { - return colourText; + return endRes; } - public void setDisplayText(boolean state) + public void setStartRes(int i) { - displayText = state; + startRes = i; } - public boolean getDisplayText() + public void setEndRes(int i) { - return displayText; + endRes = i; } - public void setDisplayBoxes(boolean state) + public int getSize() { - displayBoxes = state; + return sequences.size(); } - public boolean getDisplayBoxes() + public SequenceI getSequenceAt(int i) { - return displayBoxes; + return (SequenceI) sequences.elementAt(i); } - public int getStartRes() + public void setColourText(boolean state) { - return startRes; + colourText = state; } - public int getEndRes() + public boolean getColourText() { - return endRes; + return colourText; } - public void setStartRes(int i) + public void setDisplayText(boolean state) { - startRes = i; + displayText = state; } - public void setEndRes(int i) + public boolean getDisplayText() { - endRes = i; + return displayText; } - public int getSize() + public void setDisplayBoxes(boolean state) { - return sequences.size(); + displayBoxes = state; } - public SequenceI getSequenceAt(int i) + public boolean getDisplayBoxes() { - return (SequenceI) sequences.elementAt(i); + return displayBoxes; } public Vector getAAFrequency() diff --git a/src/jalview/datamodel/SuperGroup.java b/src/jalview/datamodel/SuperGroup.java new file mode 100755 index 0000000..6c4da29 --- /dev/null +++ b/src/jalview/datamodel/SuperGroup.java @@ -0,0 +1,95 @@ +package jalview.datamodel; + +import jalview.schemes.*; +import jalview.analysis.*; +import jalview.datamodel.*; +import java.util.*; + +public class SuperGroup +{ + String groupName; + boolean displayBoxes; + boolean displayText; + boolean colourText; + public ColourSchemeI cs; + ArrayList sequenceGroups = new ArrayList(); + + public SuperGroup() + { + groupName = "Super group"; + this.displayBoxes = true; + this.displayText = true; + this.colourText = false; + cs = null; + } + + + public SuperGroup(String groupName, ColourSchemeI scheme, + boolean displayBoxes, boolean displayText, + boolean colourText) + { + this.groupName = groupName; + this.displayBoxes = displayBoxes; + this.displayText = displayText; + this.colourText = colourText; + this.cs = scheme; + } + + public String getName() + { + return groupName; + } + + public void setName(String name) + { + groupName = name; + } + + + public void addGroup(SequenceGroup sg) + { + if(!sequenceGroups.contains(sg)) + sequenceGroups.add(sg); + } + + public void addOrRemove(SequenceGroup sg) + { + if(sequenceGroups.contains(sg)) + deleteGroup(sg); + else + addGroup(sg); + } + + public void deleteGroup(SequenceGroup sg) + { + sequenceGroups.remove(sg); + } + + public void setSuperGroupProperties(SequenceGroup sg) + { + cs = sg.cs; + colourText = sg.colourText; + displayText = sg.displayText; + displayBoxes = sg.displayBoxes; + + for(int i=0; i