From 31048f4b0d153fac79a6508b717030851bc33525 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 1 Mar 2018 10:07:46 +0000 Subject: [PATCH] JAL-2629 revising hmmer annotation updating (wip) --- src/jalview/appletgui/AlignViewport.java | 23 ++-- src/jalview/datamodel/SequenceGroup.java | 1 + src/jalview/gui/AlignViewport.java | 36 +++--- src/jalview/viewmodel/AlignmentViewport.java | 158 ++++++++++++-------------- 4 files changed, 102 insertions(+), 116 deletions(-) diff --git a/src/jalview/appletgui/AlignViewport.java b/src/jalview/appletgui/AlignViewport.java index 0c85925..7ce6837 100644 --- a/src/jalview/appletgui/AlignViewport.java +++ b/src/jalview/appletgui/AlignViewport.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * Copyright (C) $$Year-Rel$$ The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) * * This file is part of Jalview. * @@ -25,14 +25,11 @@ import jalview.api.FeatureSettingsModelI; import jalview.bin.JalviewLite; import jalview.commands.CommandI; import jalview.datamodel.AlignmentI; -import jalview.datamodel.Annotation; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenColumns; import jalview.datamodel.SearchResults; import jalview.datamodel.SearchResultsI; -import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; import jalview.renderer.ResidueShader; import jalview.schemes.ColourSchemeProperty; import jalview.schemes.UserColourScheme; @@ -59,6 +56,12 @@ public class AlignViewport extends AlignmentViewport private AnnotationColumnChooser annotationColumnSelectionState; + java.awt.Frame nullFrame; + + protected FeatureSettings featureSettings = null; + + private float heightScale = 1, widthScale = 1; + public AlignViewport(AlignmentI al, JalviewLite applet) { super(al); @@ -200,7 +203,8 @@ public class AlignViewport extends AlignmentViewport if (colour != null) { residueShading = new ResidueShader( - ColourSchemeProperty.getColourScheme(alignment, colour)); + ColourSchemeProperty.getColourScheme(getAlignment(), + colour)); if (residueShading != null) { residueShading.setConsensus(hconsensus); @@ -214,15 +218,8 @@ public class AlignViewport extends AlignmentViewport } } initAutoAnnotation(); - } - java.awt.Frame nullFrame; - - protected FeatureSettings featureSettings = null; - - private float heightScale = 1, widthScale = 1; - /** * {@inheritDoc} */ @@ -417,6 +414,4 @@ public class AlignViewport extends AlignmentViewport return normaliseHMMSequenceLogo; } - - } diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index d1e7b83..676f318 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -278,6 +278,7 @@ public class SequenceGroup implements AnnotatedCollectionI seqs[ipos].setDescription(seq.getDescription()); seqs[ipos].setDBRefs(seq.getDBRefs()); seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures()); + seqs[ipos].setIsHMMConsensusSequence(seq.isHMMConsensusSequence()); if (seq.getDatasetSequence() != null) { seqs[ipos].setDatasetSequence(seq.getDatasetSequence()); diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index b490a4b..ef95161 100644 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -94,6 +94,12 @@ public class AlignViewport extends AlignmentViewport private AnnotationColumnChooser annotationColumnSelectionState; + boolean validCharWidth; + + public boolean followSelection = true; + + private Hashtable calcIdParams = new Hashtable<>(); + /** * Creates a new AlignViewport object. * @@ -256,14 +262,14 @@ public class AlignViewport extends AlignmentViewport setFont(new Font(fontName, style, Integer.parseInt(fontSize)), true); - alignment - .setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0)); + AlignmentI al = getAlignment(); + al.setGapCharacter(Cache.getDefault("GAP_SYMBOL", "-").charAt(0)); // We must set conservation and consensus before setting colour, // as Blosum and Clustal require this to be done if (hconsensus == null && !isDataset) { - if (!alignment.isNucleotide()) + if (!al.isNucleotide()) { showConservation = Cache.getDefault("SHOW_CONSERVATION", true); showQuality = Cache.getDefault("SHOW_QUALITY", true); @@ -281,10 +287,9 @@ public class AlignViewport extends AlignmentViewport showOccupancy = Cache.getDefault(Preferences.SHOW_OCCUPANCY, true); } initAutoAnnotation(); - initInformation(); + // initInformation(); - - String colourProperty = alignment.isNucleotide() + String colourProperty = al.isNucleotide() ? Preferences.DEFAULT_COLOUR_NUC : Preferences.DEFAULT_COLOUR_PROT; String schemeName = Cache.getProperty(colourProperty); @@ -295,7 +300,7 @@ public class AlignViewport extends AlignmentViewport ResidueColourScheme.NONE); } ColourSchemeI colourScheme = ColourSchemeProperty - .getColourScheme(alignment, schemeName); + .getColourScheme(al, schemeName); residueShading = new ResidueShader(colourScheme); if (colourScheme instanceof UserColourScheme) @@ -311,8 +316,6 @@ public class AlignViewport extends AlignmentViewport } } - boolean validCharWidth; - /** * {@inheritDoc} */ @@ -395,9 +398,9 @@ public class AlignViewport extends AlignmentViewport /* * replace mappings on our alignment */ - if (alignment != null && align != null) + if (getAlignment() != null && align != null) { - alignment.setCodonFrames(align.getCodonFrames()); + getAlignment().setCodonFrames(align.getCodonFrames()); } } @@ -466,9 +469,10 @@ public class AlignViewport extends AlignmentViewport } else { - end = alignment.getWidth(); + end = getAlignment().getWidth(); } - viscontigs = alignment.getHiddenColumns().getVisibleContigs(start, end); + viscontigs = getAlignment().getHiddenColumns().getVisibleContigs(start, + end); return viscontigs; } @@ -518,8 +522,6 @@ public class AlignViewport extends AlignmentViewport return false; } - public boolean followSelection = true; - /** * @return true if view selection should always follow the selections * broadcast by other selection sources @@ -597,7 +599,7 @@ public class AlignViewport extends AlignmentViewport for (PDBEntry pdb : pdbEntries) { List choosenSeqs = new ArrayList<>(); - for (SequenceI sq : alignment.getSequences()) + for (SequenceI sq : getAlignment().getSequences()) { Vector pdbRefEntries = sq.getDatasetSequence() .getAllPDBEntries(); @@ -664,8 +666,6 @@ public class AlignViewport extends AlignmentViewport return validCharWidth; } - private Hashtable calcIdParams = new Hashtable<>(); - public AutoCalcSetting getCalcIdSettingsFor(String calcId) { return calcIdParams.get(calcId); diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 46ebe01..ecca699 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -99,11 +99,73 @@ public abstract class AlignmentViewport protected Deque redoList = new ArrayDeque<>(); + protected String sequenceSetID; + + /* + * probably unused indicator that view is of a dataset rather than an + * alignment + */ + protected boolean isDataset = false; + + private Map hiddenRepSequences; + + protected ColumnSelection colSel = new ColumnSelection(); + + public boolean autoCalculateConsensus = true; + + public boolean autoCalculateInformation = true; + + protected boolean autoCalculateStrucConsensus = true; + + protected boolean ignoreGapsInConsensusCalculation = false; + + protected boolean ignoreBelowBackGroundFrequencyCalculation = false; + + protected boolean infoLetterHeight = false; + + protected ResidueShaderI residueShading = new ResidueShader(); + + protected AlignmentAnnotation consensus; + + protected AlignmentAnnotation complementConsensus; + + protected AlignmentAnnotation occupancy; + + protected AlignmentAnnotation strucConsensus; + + protected AlignmentAnnotation conservation; + + protected AlignmentAnnotation quality; + + protected List information = new ArrayList<>(); + + /** + * alignment displayed in the viewport + */ + private AlignmentI alignment; + + /** + * results of alignment consensus analysis for visible portion of view + */ + protected ProfilesI hconsensus = null; + + /** + * results of information annotation analysis for the visible portion of view + */ + protected List hinformation = new ArrayList<>(); + + /** + * results of cDNA complement consensus visible portion of view + */ + protected Hashtable[] hcomplementConsensus = null; /** - * alignment displayed in the viewport. Please use get/setter + * results of secondary structure base pair consensus for visible portion of + * view */ - protected AlignmentI alignment; + protected Hashtable[] hStrucConsensus = null; + + protected Conservation hconservation = null; public AlignmentViewport(AlignmentI al) { @@ -584,14 +646,6 @@ public abstract class AlignmentViewport return alignment.getGapCharacter(); } - protected String sequenceSetID; - - /** - * probably unused indicator that view is of a dataset rather than an - * alignment - */ - protected boolean isDataset = false; - public void setDataset(boolean b) { isDataset = b; @@ -602,24 +656,6 @@ public abstract class AlignmentViewport return isDataset; } - private Map hiddenRepSequences; - - protected ColumnSelection colSel = new ColumnSelection(); - - public boolean autoCalculateConsensus = true; - - public boolean autoCalculateInformation = true; - - protected boolean autoCalculateStrucConsensus = true; - - protected boolean ignoreGapsInConsensusCalculation = false; - - protected boolean ignoreBelowBackGroundFrequencyCalculation = false; - - protected boolean infoLetterHeight = false; - - protected ResidueShaderI residueShading = new ResidueShader(); - @Override public void setGlobalColourScheme(ColourSchemeI cs) { @@ -692,50 +728,6 @@ public abstract class AlignmentViewport { return residueShading; } - - protected AlignmentAnnotation consensus; - - protected AlignmentAnnotation complementConsensus; - - protected AlignmentAnnotation gapcounts; - - protected AlignmentAnnotation strucConsensus; - - protected AlignmentAnnotation conservation; - - protected AlignmentAnnotation quality; - - protected AlignmentAnnotation[] groupConsensus; - - protected AlignmentAnnotation[] groupConservation; - - protected List groupInformation = new ArrayList<>(); - - protected List information = new ArrayList<>(); - - /** - * results of alignment consensus analysis for visible portion of view - */ - protected ProfilesI hconsensus = null; - - /** - * results of information annotation analysis for the visible portion of view - */ - protected List hinformation = new ArrayList<>(); - - /** - * results of cDNA complement consensus visible portion of view - */ - protected Hashtable[] hcomplementConsensus = null; - - /** - * results of secondary structure base pair consensus for visible portion of - * view - */ - protected Hashtable[] hStrucConsensus = null; - - protected Conservation hconservation = null; - @Override public void setConservation(Conservation cons) { @@ -846,7 +838,7 @@ public abstract class AlignmentViewport @Override public AlignmentAnnotation getAlignmentGapAnnotation() { - return gapcounts; + return occupancy; } @Override @@ -1012,12 +1004,10 @@ public abstract class AlignmentViewport strucConsensus = null; conservation = null; quality = null; - groupConsensus = null; - groupConservation = null; hconsensus = null; hconservation = null; hcomplementConsensus = null; - gapcounts = null; + occupancy = null; calculator = null; residueShading = null; // may hold a reference to Consensus changeSupport = null; @@ -2099,7 +2089,7 @@ public abstract class AlignmentViewport new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH); initConsensus(consensus); - initGapCounts(); + initOccupancy(); initComplementConsensus(); } @@ -2182,20 +2172,20 @@ public abstract class AlignmentViewport // these should be extracted from the view model - style and settings for // derived annotation - private void initGapCounts() + private void initOccupancy() { if (showOccupancy) { - gapcounts = new AlignmentAnnotation("Occupancy", + occupancy = new AlignmentAnnotation("Occupancy", MessageManager.getString("label.occupancy_descr"), new Annotation[1], 0f, alignment.getHeight(), AlignmentAnnotation.BAR_GRAPH); - gapcounts.hasText = true; - gapcounts.autoCalculated = true; - gapcounts.scaleColLabel = true; - gapcounts.graph = AlignmentAnnotation.BAR_GRAPH; + occupancy.hasText = true; + occupancy.autoCalculated = true; + occupancy.scaleColLabel = true; + occupancy.graph = AlignmentAnnotation.BAR_GRAPH; - alignment.addAnnotation(gapcounts); + alignment.addAnnotation(occupancy); } } -- 1.7.10.2