X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignmentI.java;h=be1bff76535140afcf72914349cee473cc10d80b;hb=a45774ee31d9f35d4eff46d54d7deab719afb092;hp=4de17e79fc02647be00757c00325bb3257067676;hpb=483c80a859264f9d743cc7ff801c65b3884d8e88;p=jalview.git diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 4de17e7..be1bff7 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * This file is part of Jalview. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . */ package jalview.datamodel; @@ -40,13 +39,23 @@ public interface AlignmentI public int getWidth(); /** - * Calculates if this set of sequences is all the same length + * Calculates if this set of sequences (visible and invisible) are all the + * same length * * @return true if all sequences in alignment are the same length */ public boolean isAligned(); /** + * Calculates if this set of sequences is all the same length + * + * @param includeHidden + * optionally exclude hidden sequences from test + * @return true if all (or just visible) sequences are the same length + */ + public boolean isAligned(boolean includeHidden); + + /** * Gets sequences as a Vector * * @return All sequences in alignment. @@ -64,7 +73,7 @@ public interface AlignmentI * Find a specific sequence in this alignment. * * @param i - * Index of required sequence. + * Index of required sequence. * * @return SequenceI at given index. */ @@ -74,7 +83,7 @@ public interface AlignmentI * Add a new sequence to this alignment. * * @param seq - * New sequence will be added at end of alignment. + * New sequence will be added at end of alignment. */ public void addSequence(SequenceI seq); @@ -82,9 +91,9 @@ public interface AlignmentI * Used to set a particular index of the alignment with the given sequence. * * @param i - * Index of sequence to be updated. + * Index of sequence to be updated. * @param seq - * New sequence to be inserted. + * New sequence to be inserted. */ public void setSequenceAt(int i, SequenceI seq); @@ -92,7 +101,7 @@ public interface AlignmentI * Deletes a sequence from the alignment * * @param s - * Sequence to be deleted. + * Sequence to be deleted. */ public void deleteSequence(SequenceI s); @@ -100,7 +109,7 @@ public interface AlignmentI * Deletes a sequence from the alignment. * * @param i - * Index of sequence to be deleted. + * Index of sequence to be deleted. */ public void deleteSequence(int i); @@ -108,7 +117,7 @@ public interface AlignmentI * Finds sequence in alignment using sequence name as query. * * @param name - * Id of sequence to search for. + * Id of sequence to search for. * * @return Sequence matching query, if found. If not found returns null. */ @@ -120,7 +129,7 @@ public interface AlignmentI * Finds index of a given sequence in the alignment. * * @param s - * Sequence to look for. + * Sequence to look for. * * @return Index of sequence within the alignment or -1 if not found */ @@ -130,7 +139,7 @@ public interface AlignmentI * Finds group that given sequence is part of. * * @param s - * Sequence in alignment. + * Sequence in alignment. * * @return First group found for sequence. WARNING : Sequences may be members * of several groups. This method is incomplete. @@ -141,7 +150,7 @@ public interface AlignmentI * Finds all groups that a given sequence is part of. * * @param s - * Sequence in alignment. + * Sequence in alignment. * * @return All groups containing given sequence. */ @@ -151,7 +160,7 @@ public interface AlignmentI * Adds a new SequenceGroup to this alignment. * * @param sg - * New group to be added. + * New group to be added. */ public void addGroup(SequenceGroup sg); @@ -159,7 +168,7 @@ public interface AlignmentI * Deletes a specific SequenceGroup * * @param g - * Group will be deleted from alignment. + * Group will be deleted from alignment. */ public void deleteGroup(SequenceGroup g); @@ -187,26 +196,41 @@ public interface AlignmentI * moves annotation to a specified index in alignment annotation display stack * * @param aa - * the annotation object to be moved + * the annotation object to be moved * @param index - * the destination position + * the destination position */ public void setAnnotationIndex(AlignmentAnnotation aa, int index); /** * Deletes a specific AlignmentAnnotation from the alignment, and removes its - * reference from any SequenceI object's annotation if and only if aa is + * reference from any SequenceI or SequenceGroup object's annotation if and only if aa is * contained within the alignment's annotation vector. Otherwise, it will do * nothing. * * @param aa - * the annotation to delete + * the annotation to delete * @return true if annotation was deleted from this alignment. */ public boolean deleteAnnotation(AlignmentAnnotation aa); /** - * Get the annotation associated with this alignment + * Deletes a specific AlignmentAnnotation from the alignment, and optionally removes any + * reference from any SequenceI or SequenceGroup object's annotation if and only if aa is + * contained within the alignment's annotation vector. Otherwise, it will do + * nothing. + * + * @param aa + * the annotation to delete + * @param unhook + * flag indicating if any references should be removed from annotation - use this if you intend to add the annotation back into the alignment + * @return true if annotation was deleted from this alignment. + */ + public boolean deleteAnnotation(AlignmentAnnotation aa, boolean unhook); + + /** + * Get the annotation associated with this alignment (this can be null if no + * annotation has ever been created on the alignment) * * @return array of AlignmentAnnotation objects */ @@ -216,7 +240,7 @@ public interface AlignmentI * Change the gap character used in this alignment to 'gc' * * @param gc - * the new gap character. + * the new gap character. */ public void setGapCharacter(char gc); @@ -252,7 +276,7 @@ public interface AlignmentI * Set the associated dataset for the alignment, or create one. * * @param dataset - * The dataset alignment or null to construct one. + * The dataset alignment or null to construct one. */ public void setDataset(Alignment dataset); @@ -335,10 +359,10 @@ public interface AlignmentI * find sequence with given name in alignment * * @param token - * name to find + * name to find * @param b - * true implies that case insensitive matching will - * also be tried + * true implies that case insensitive matching will also be + * tried * @return matched sequence or null */ public SequenceI findName(String token, boolean b); @@ -348,19 +372,21 @@ public interface AlignmentI * sequence * * @param startAfter - * the sequence after which the search will be started (usually - * the result of the last call to findName) + * the sequence after which the search will be started (usually the + * result of the last call to findName) * @param token - * name to find + * name to find * @param b - * true implies that case insensitive matching will - * also be tried + * true implies that case insensitive matching will also be + * tried * @return matched sequence or null */ public SequenceI findName(SequenceI startAfter, String token, boolean b); /** - * find first sequence in alignment which is involved in the given search result object + * find first sequence in alignment which is involved in the given search + * result object + * * @param results * @return -1 or index of sequence in alignment */ @@ -368,12 +394,32 @@ public interface AlignmentI /** * append sequences and annotation from another alignment object to this one. - * Note: this is a straight transfer of object references, and may result in - * toappend's dependent data being transformed to fit the alignment (changing gap characters, etc...). - * If you are uncertain, use the copy Alignment copy constructor to create a new version - * which can be appended without side effect. - * @param toappend - the alignment to be appended. + * Note: this is a straight transfer of object references, and may result in + * toappend's dependent data being transformed to fit the alignment (changing + * gap characters, etc...). If you are uncertain, use the copy Alignment copy + * constructor to create a new version which can be appended without side + * effect. + * + * @param toappend + * - the alignment to be appended. */ public void append(AlignmentI toappend); + /** + * Justify the sequences to the left or right by deleting and inserting gaps + * before the initial residue or after the terminal residue + * + * @param right + * true if alignment padded to right, false to justify to left + * @return true if alignment was changed TODO: return undo object + */ + public boolean justify(boolean right); + + /** + * add given annotation row at given position (0 is start, -1 is end) + * + * @param consensus + * @param i + */ + public void addAnnotation(AlignmentAnnotation consensus, int i); }