X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=f14539b2e5b837b18e95a07ca13774271f70da37;hb=9c39e96af6b84257604da448101505361dced686;hp=1134857428850bf8e49716f31013e37c56b2c37b;hpb=49428d3a57e4f4863acbdeb3f77049ed95efd6c3;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 1134857..f14539b 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -30,6 +30,7 @@ import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import java.util.Hashtable; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -1287,6 +1288,22 @@ public class Alignment implements AlignmentI } } + /** + * adds a set of mappings (while ignoring any duplicates) + */ + @Override + public void addCodonFrames(Iterable codons) + { + if (codons != null) + { + Iterator it = codons.iterator(); + while (it.hasNext()) + { + addCodonFrame(it.next()); + } + } + } + /* * (non-Javadoc) * @@ -1704,31 +1721,13 @@ public class Alignment implements AlignmentI boolean preserveUnmappedGaps) { // TODO should this method signature be the one in the interface? - int count = 0; boolean thisIsNucleotide = this.isNucleotide(); boolean thatIsProtein = !al.isNucleotide(); if (!thatIsProtein && !thisIsNucleotide) { return AlignmentUtils.alignProteinAsDna(this, al); } - - char thisGapChar = this.getGapCharacter(); - String gap = thisIsNucleotide && thatIsProtein ? String - .valueOf(new char[] { thisGapChar, thisGapChar, thisGapChar }) - : String.valueOf(thisGapChar); - - // TODO handle intron regions? Needs a 'holistic' alignment of dna, - // not just sequence by sequence. But how to 'gap' intron regions? - - /* - * Get mappings from 'that' alignment's sequences to this. - */ - for (SequenceI alignTo : getSequences()) - { - count += AlignmentUtils.alignSequenceAs(alignTo, al, gap, - preserveMappedGaps, preserveUnmappedGaps) ? 1 : 0; - } - return count; + return AlignmentUtils.alignAs(this, al); } /** @@ -1811,4 +1810,40 @@ public class Alignment implements AlignmentI } return null; } + + @Override + public int[] getVisibleStartAndEndIndex(List hiddenCols) + { + int[] alignmentStartEnd = new int[] { 0, getWidth() - 1 }; + int startPos = alignmentStartEnd[0]; + int endPos = alignmentStartEnd[1]; + + int[] lowestRange = new int[] { -1, -1 }; + int[] higestRange = new int[] { -1, -1 }; + + for (int[] hiddenCol : hiddenCols) + { + lowestRange = (hiddenCol[0] <= startPos) ? hiddenCol : lowestRange; + higestRange = (hiddenCol[1] >= endPos) ? hiddenCol : higestRange; + } + + if (lowestRange[0] == -1 && lowestRange[1] == -1) + { + startPos = alignmentStartEnd[0]; + } + else + { + startPos = lowestRange[1] + 1; + } + + if (higestRange[0] == -1 && higestRange[1] == -1) + { + endPos = alignmentStartEnd[1]; + } + else + { + endPos = higestRange[0] - 1; + } + return new int[] { startPos, endPos }; + } }