From: Jim Procter Date: Wed, 23 Feb 2022 12:47:31 +0000 (+0000) Subject: Merge branch 'features/JAL-3417_sdppred_calcs' into features/r2_11_2_JAL-3417_sdppred X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6abfeb94aa315e799cb9196c82cfcbe86221f428;hp=-c;p=jalview.git Merge branch 'features/JAL-3417_sdppred_calcs' into features/r2_11_2_JAL-3417_sdppred --- 6abfeb94aa315e799cb9196c82cfcbe86221f428 diff --combined src/jalview/datamodel/Alignment.java index c4098e2,09c69e2..15423b1 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@@ -21,6 -21,7 +21,7 @@@ package jalview.datamodel; import jalview.analysis.AlignmentUtils; + import jalview.analysis.Conservation; import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; import jalview.io.FastaFile; import jalview.util.Comparison; @@@ -71,6 -72,12 +72,12 @@@ public class Alignment implements Align private List codonFrameList; + private Conservation conservation; + + private ProfilesI consensus; + + private Hashtable[] codonConsensus, rnaStructureConsensus; + private void initAlignment(SequenceI[] seqs) { groups = Collections.synchronizedList(new ArrayList()); @@@ -195,7 -202,6 +202,7 @@@ { synchronized (sequences) { + if (i > -1 && i < sequences.size()) { return sequences.get(i); @@@ -595,12 -601,11 +602,12 @@@ int i = 0; SequenceI sq = null; String sqname = null; + int nseq = sequences.size(); if (startAfter != null) { // try to find the sequence in the alignment boolean matched = false; - while (i < sequences.size()) + while (i < nseq) { if (getSequenceAt(i++) == startAfter) { @@@ -613,7 -618,7 +620,7 @@@ i = 0; } } - while (i < sequences.size()) + while (i < nseq) { sq = getSequenceAt(i); sqname = sq.getName(); @@@ -1195,8 -1200,7 +1202,8 @@@ int maxLength = -1; SequenceI current; - for (int i = 0; i < sequences.size(); i++) + int nseq = sequences.size(); + for (int i = 0; i < nseq; i++) { current = getSequenceAt(i); for (int j = current.getLength(); j > maxLength; j--) @@@ -1213,7 -1217,7 +1220,7 @@@ maxLength++; int cLength; - for (int i = 0; i < sequences.size(); i++) + for (int i = 0; i < nseq; i++) { current = getSequenceAt(i); cLength = current.getLength(); @@@ -2032,4 -2036,55 +2039,55 @@@ } } + @Override + public Hashtable[] getComplementConsensusHash() + { + return codonConsensus; + } + + @Override + public Conservation getConservation() + { + return conservation; + } + + @Override + public Hashtable[] getRnaStructureConsensusHash() + { + return rnaStructureConsensus; + } + + @Override + public ProfilesI getSequenceConsensusHash() + { + return consensus; + } + + @Override + public void setComplementConsensusHash(Hashtable[] hconsensus) + { + codonConsensus = hconsensus; + + } + + @Override + public void setConservation(Conservation cons) + { + conservation = cons; + + } + + @Override + public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus) + { + rnaStructureConsensus = hStrucConsensus; + + } + + @Override + public void setSequenceConsensusHash(ProfilesI hconsensus) + { + consensus = hconsensus; + + } } diff --combined src/jalview/datamodel/SequenceGroup.java index 861595c,1b8181b..fbf39ac --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@@ -31,6 -31,7 +31,7 @@@ import java.beans.PropertyChangeListene import java.beans.PropertyChangeSupport; import java.util.ArrayList; import java.util.Arrays; + import java.util.Hashtable; import java.util.List; import java.util.Map; @@@ -269,15 -270,16 +270,15 @@@ public class SequenceGroup implements A for (int i = 0, ipos = 0; i < inorder.length; i++) { SequenceI seq = inorder[i]; - - seqs[ipos] = seq.getSubSequence(startRes, endRes + 1); - if (seqs[ipos] != null) + SequenceI seqipos = seqs[ipos] = seq.getSubSequence(startRes, endRes + 1); + if (seqipos != null) { - seqs[ipos].setDescription(seq.getDescription()); - seqs[ipos].setDBRefs(seq.getDBRefs()); - seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures()); + seqipos.setDescription(seq.getDescription()); + seqipos.setDBRefs(seq.getDBRefs()); + seqipos.setSequenceFeatures(seq.getSequenceFeatures()); if (seq.getDatasetSequence() != null) { - seqs[ipos].setDatasetSequence(seq.getDatasetSequence()); + seqipos.setDatasetSequence(seq.getDatasetSequence()); } if (seq.getAnnotation() != null) @@@ -291,7 -293,7 +292,7 @@@ if (alann != null) { boolean found = false; - for (int pos = 0; pos < alann.length; pos++) + for (int pos = 0, np = alann.length; pos < np; pos++) { if (alann[pos] == tocopy) { @@@ -309,7 -311,7 +310,7 @@@ newannot.restrict(startRes, endRes); newannot.setSequenceRef(seqs[ipos]); newannot.adjustForAlignment(); - seqs[ipos].addAlignmentAnnotation(newannot); + seqipos.addAlignmentAnnotation(newannot); } } ipos++; @@@ -502,6 -504,7 +503,7 @@@ * * @return DOCUMENT ME! */ + @Override public Conservation getConservation() { return conserve; @@@ -674,6 -677,26 +676,26 @@@ public ProfilesI consensusData = null; + @Override + public ProfilesI getSequenceConsensusHash() + { + return consensusData; + } + + @Override + public Hashtable[] getComplementConsensusHash() + { + // TODO: Groupwise CDS Consensus + return null; + } + + @Override + public Hashtable[] getRnaStructureConsensusHash() + { + // TODO Groupwise RNA Consensus + return null; + } + private void _updateConsensusRow(ProfilesI cnsns, long nseq) { if (consensus == null) diff --combined src/jalview/viewmodel/AlignmentViewport.java index 75cb45b,979f6ad..3691a69 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@@ -24,7 -24,6 +24,7 @@@ import jalview.analysis.AnnotationSorte import jalview.analysis.Conservation; import jalview.analysis.TreeModel; import jalview.api.AlignCalcManagerI; +import jalview.api.AlignExportSettingsI; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.api.FeaturesDisplayedI; @@@ -32,7 -31,6 +32,7 @@@ import jalview.api.ViewStyleI import jalview.commands.CommandI; import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentExportData; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; import jalview.datamodel.Annotation; @@@ -711,19 -709,20 +711,20 @@@ public abstract class AlignmentViewpor /** * results of cDNA complement consensus visible portion of view */ - protected Hashtable[] hcomplementConsensus = null; + protected Hashtable[] hcomplementConsensus = null; /** * results of secondary structure base pair consensus for visible portion of * view */ - protected Hashtable[] hStrucConsensus = null; + protected Hashtable[] hStrucConsensus = null; protected Conservation hconservation = null; @Override public void setConservation(Conservation cons) { + alignment.setConservation(cons); hconservation = cons; } @@@ -742,13 -741,14 +743,15 @@@ @Override public void setSequenceConsensusHash(ProfilesI hconsensus) { + alignment.setSequenceConsensusHash(hconsensus); this.hconsensus = hconsensus; } @Override - public void setComplementConsensusHash(Hashtable[] hconsensus) + public void setComplementConsensusHash( + Hashtable[] hconsensus) { + alignment.setComplementConsensusHash(hconsensus); this.hcomplementConsensus = hconsensus; } @@@ -759,21 -759,21 +762,22 @@@ } @Override - public Hashtable[] getComplementConsensusHash() + public Hashtable[] getComplementConsensusHash() { return hcomplementConsensus; } @Override - public Hashtable[] getRnaStructureConsensusHash() + public Hashtable[] getRnaStructureConsensusHash() { return hStrucConsensus; } @Override - public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus) + public void setRnaStructureConsensusHash( + Hashtable[] hStrucConsensus) { + alignment.setRnaStructureConsensusHash(hStrucConsensus); this.hStrucConsensus = hStrucConsensus; } @@@ -963,7 -963,6 +967,7 @@@ ranges = null; currentTree = null; selectionGroup = null; + colSel = null; setAlignment(null); } @@@ -1803,7 -1802,7 +1807,7 @@@ } } while (end < max); - int[][] startEnd = new int[regions.size()][2]; + // int[][] startEnd = new int[regions.size()][2]; return regions; } @@@ -2158,7 -2157,7 +2162,7 @@@ * TODO reorder the annotation rows according to group/sequence ordering on * alignment */ - boolean sortg = true; + // boolean sortg = true; // remove old automatic annotation // add any new annotation @@@ -2268,7 -2267,7 +2272,7 @@@ public void clearSequenceColours() { sequenceColours.clear(); - }; + } @Override public AlignViewportI getCodingComplement() @@@ -2986,36 -2985,6 +2990,36 @@@ return currentTree; } + @Override + public AlignmentExportData getAlignExportData(AlignExportSettingsI options) + { + AlignmentI alignmentToExport = null; + String[] omitHidden = null; + alignmentToExport = null; + + if (hasHiddenColumns() && !options.isExportHiddenColumns()) + { + omitHidden = getViewAsString(false, + options.isExportHiddenSequences()); + } + + int[] alignmentStartEnd = new int[2]; + if (hasHiddenRows() && options.isExportHiddenSequences()) + { + alignmentToExport = getAlignment().getHiddenSequences() + .getFullAlignment(); + } + else + { + alignmentToExport = getAlignment(); + } + alignmentStartEnd = getAlignment().getHiddenColumns() + .getVisibleStartAndEndIndex(alignmentToExport.getWidth()); + AlignmentExportData ed = new AlignmentExportData(alignmentToExport, + omitHidden, alignmentStartEnd); + return ed; + } + /** * flag set to indicate if structure views might be out of sync with sequences * in the alignment @@@ -3079,22 -3048,4 +3083,22 @@@ codingComplement.setUpdateStructures(needToUpdateStructureViews); } } + + @Override + public Iterator getViewAsVisibleContigs(boolean selectedRegionOnly) + { + int start = 0; + int end = 0; + if (selectedRegionOnly && selectionGroup != null) + { + start = selectionGroup.getStartRes(); + end = selectionGroup.getEndRes() + 1; + } + else + { + end = alignment.getWidth(); + } + return (alignment.getHiddenColumns().getVisContigsIterator(start, end, + false)); + } }