X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=71e76aff2f6835cc26c329b4a32c23c2cae4fa1c;hb=582d39cb05dfbb5f956f74d4a97a17d9f63b0786;hp=62852a21985e55c36e6ce60a2c97b552a4ec3969;hpb=608832fec5a504b4c56e5837b2b3dfc1993fe734;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 62852a2..71e76af 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -131,7 +131,6 @@ public class Alignment implements AlignmentI { if(snew.getDatasetSequence()!=null) { - System.out.println(snew.getName()); getDataset().addSequence(snew.getDatasetSequence()); } else @@ -146,8 +145,9 @@ public class Alignment implements AlignmentI getDataset().addSequence(ds); } } - sequences.addElement(snew); + + hiddenSequences.adjustHeightSequenceAdded(); } @@ -172,136 +172,6 @@ public class Alignment implements AlignmentI { return groups; } - /** Takes out columns consisting entirely of gaps (-,.," ") - */ - public void removeGaps() { - removeGaps((ShiftList)null); - } - /** - * remove gaps in alignment - recording any frame shifts in shiftrecord - * intended to be passed to ColumnSelection.compensateForEdits(shiftrecord) - * @param shiftrecord - */ - public void removeGaps(ShiftList shiftrecord) { - SequenceI[] seqs = getVisibleAndRepresentedSeqs(); - int j, jSize = seqs.length; - - int width = 0; - for (int i = 0; i < jSize; i++) - { - if (seqs[i].getLength() > width) - { - width = seqs[i].getLength(); - } - } - - int startCol = -1, endCol = -1; - boolean delete = true; - for (int i = 0; i < width; i++) - { - delete = true; - - for (j = 0; j < jSize; j++) - { - if (seqs[j].getLength() > i) - { - if (!jalview.util.Comparison.isGap(seqs[j].getCharAt(i))) - { - if(delete) - endCol = i; - - delete = false; - break; - } - } - } - - if(delete && startCol==-1) - { - startCol = i; - } - - - if (!delete && startCol > -1) - { - deleteColumns(seqs, startCol, endCol); - if (shiftrecord!=null) { - shiftrecord.addShift(startCol, 1+endCol-startCol); - } - width -= (endCol - startCol); - i -= (endCol - startCol); - startCol = -1; - endCol = -1; - } - } - - if (delete && startCol > -1) - { - deleteColumns(seqs, startCol, endCol); - if (shiftrecord!=null) { - shiftrecord.addShift(startCol, 1+endCol-startCol); - } - } - } - - /** Removes a range of columns (start to end inclusive). - * - * @param seqs Sequences to remove columns from - * @param start Start column in the alignment - * @param end End column in the alignment - */ - public void deleteColumns(SequenceI [] seqs, int start, int end) - { - for(int i=0; iseqs[j].getLength()) - { - sequences.removeElement(seqs[j]); - j--; - jSize--; - } - else - { - seqs[j].setStart(newstart); - seqs[j].setSequence(seqs[j].getSequence().substring(i)); - } - } - } - - /** - * DOCUMENT ME! - * - * @param i DOCUMENT ME! - */ - public void trimRight(int i) - { - SequenceI[] seqs = getVisibleAndRepresentedSeqs(); - int j, jSize = seqs.length; - for (j = 0; j < jSize; j++) - { - int newend = seqs[j].findPosition(i); - - seqs[j].setEnd(newend); - if(seqs[j].getLength()>i) - seqs[j].setSequence(seqs[j].getSequence().substring(0, i + 1)); - } - } /** * DOCUMENT ME! @@ -310,13 +180,7 @@ public class Alignment implements AlignmentI */ public void deleteSequence(SequenceI s) { - for (int i = 0; i < getHeight(); i++) - { - if (getSequenceAt(i) == s) - { - deleteSequence(i); - } - } + deleteSequence(findIndex(s)); } /** @@ -326,7 +190,11 @@ public class Alignment implements AlignmentI */ public void deleteSequence(int i) { + if(i>-1 && i max) - { - max = tmp.length(); - } - - i++; - } - - return max; - } /** * DOCUMENT ME! @@ -565,15 +398,6 @@ public class Alignment implements AlignmentI return gapCharacter; } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public Vector getAAFrequency() - { - return AAFrequency.calculate(sequences, 0, getWidth()); - } /** * DOCUMENT ME! @@ -609,6 +433,9 @@ public class Alignment implements AlignmentI aSize = annotations.length; } + if(aSize<1) + return; + AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize - 1]; int tIndex = 0; @@ -730,22 +557,25 @@ public class Alignment implements AlignmentI // Can only be done once, if dataset is not null // This will not be performed Sequence[] seqs = new Sequence[getHeight()]; + SequenceI currentSeq; for (int i = 0; i < getHeight(); i++) { - if(getSequenceAt(i).getDatasetSequence()!=null) + currentSeq = getSequenceAt(i); + if(currentSeq.getDatasetSequence()!=null) { - seqs[i] = (Sequence)getSequenceAt(i).getDatasetSequence(); + seqs[i] = (Sequence)currentSeq.getDatasetSequence(); } else { - seqs[i] = new Sequence(getSequenceAt(i).getName(), + seqs[i] = new Sequence(currentSeq.getName(), AlignSeq.extractGaps( jalview.util.Comparison.GapChars, - getSequenceAt(i).getSequence() + currentSeq.getSequence() ), - getSequenceAt(i).getStart(), - getSequenceAt(i).getEnd()); - seqs[i].sequenceFeatures = getSequenceAt(i).getSequenceFeatures(); + currentSeq.getStart(), + currentSeq.getEnd()); + seqs[i].sequenceFeatures = currentSeq.getSequenceFeatures(); + seqs[i].setDescription(currentSeq.getDescription()); getSequenceAt(i).setSequenceFeatures(null); getSequenceAt(i).setDatasetSequence(seqs[i]); } @@ -764,7 +594,8 @@ public class Alignment implements AlignmentI return dataset; } - public boolean padGaps() { + public boolean padGaps() + { boolean modified=false; //Remove excess gaps from the end of alignment @@ -787,14 +618,17 @@ public class Alignment implements AlignmentI maxLength++; + int cLength; for (int i = 0; i < sequences.size(); i++) { current = getSequenceAt(i); + cLength = current.getLength(); - if (current.getLength() < maxLength) + if (cLength < maxLength) { - current.insertCharAt(maxLength - 1, gapCharacter); + current.insertCharAt(cLength, + maxLength-cLength, gapCharacter); modified=true; } else if(current.getLength() > maxLength) @@ -844,7 +678,9 @@ public class Alignment implements AlignmentI for (int i=0; i