updated to jalview 2.1 and begun ArchiveClient/VamsasClient/VamsasStore updates.
[jalview.git] / src / jalview / datamodel / AlignmentI.java
index 7fe4627..bcfcc81 100755 (executable)
-/*\r
-* Jalview - A Sequence Alignment Editor and Viewer\r
-* Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
-*\r
-* This program is free software; you can redistribute it and/or\r
-* modify it under the terms of the GNU General Public License\r
-* as published by the Free Software Foundation; either version 2\r
-* of the License, or (at your option) any later version.\r
-*\r
-* This program is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with this program; if not, write to the Free Software\r
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
-*/\r
-package jalview.datamodel;\r
-\r
-import java.util.*;\r
-\r
-\r
-/** Data structure to hold and manipulate a multiple sequence alignment\r
- */\r
-public interface AlignmentI\r
-{\r
-    /**\r
-     *  Calculates the number of sequences in an alignment\r
-     *\r
-     * @return Number of sequences in alignment\r
-     */\r
-    public int getHeight();\r
-\r
-    /**\r
-     * Calculates the maximum width of the alignment, including gaps.\r
-     *\r
-     * @return Greatest sequence length within alignment.\r
-     */\r
-    public int getWidth();\r
-\r
-    /**\r
-     * Calculates the longest sequence Id of the alignment\r
-     *\r
-     * @return Number of characters in longest sequence Id.\r
-     */\r
-    public int getMaxIdLength();\r
-\r
-    /**\r
-     * Calculates if this set of sequences is all the same length\r
-     *\r
-     * @return true if all sequences in alignment are the same length\r
-     */\r
-    public boolean isAligned();\r
-\r
-    /**\r
-     * Gets sequences as a Vector\r
-     *\r
-     * @return All sequences in alignment.\r
-     */\r
-    public Vector getSequences();\r
-\r
-    /**\r
-     * Find a specific sequence in this alignment.\r
-     *\r
-     * @param i Index of required sequence.\r
-     *\r
-     * @return SequenceI at given index.\r
-     */\r
-    public SequenceI getSequenceAt(int i);\r
-\r
-    /**\r
-     * Add a new sequence to this alignment.\r
-     *\r
-     * @param seq New sequence will be added at end of alignment.\r
-     */\r
-    public void addSequence(SequenceI seq);\r
-\r
-    /**\r
-     * Used to set a particular index of the alignment with the given sequence.\r
-     *\r
-     * @param i Index of sequence to be updated.\r
-     * @param seq New sequence to be inserted.\r
-     */\r
-    public void setSequenceAt(int i, SequenceI seq);\r
-\r
-    /**\r
-     * Deletes a sequence from the alignment.\r
-     *\r
-     * @param s Sequence to be deleted.\r
-     */\r
-    public void deleteSequence(SequenceI s);\r
-\r
-    /**\r
-     * Deletes a sequence from the alignment.\r
-     *\r
-     * @param i Index of sequence to be deleted.\r
-     */\r
-    public void deleteSequence(int i);\r
-\r
-    /**\r
-     * Deletes all residues in every sequence of alignment within given columns.\r
-     *\r
-     * @param start Start index of columns to delete.\r
-     * @param end End index to columns to delete.\r
-     */\r
-    public void deleteColumns(int start, int end);\r
-\r
-    /**\r
-     * Deletes all residues in every sequence of alignment within given columns.\r
-     *\r
-     * @param seq1 Index of first sequence to delete columns from.\r
-     * @param seq2 Index of last sequence to delete columns from.\r
-     * @param start Start index of columns to delete.\r
-     * @param end End index of columns to delete.\r
-     */\r
-    public void deleteColumns(int seq1, int seq2, int start, int end);\r
-\r
-    /**\r
-     * Finds sequence in alignment using sequence name as query.\r
-     *\r
-     * @param name Id of sequence to search for.\r
-     *\r
-     * @return Sequence matching query, if found. If not found returns null.\r
-     */\r
-    public SequenceI findName(String name);\r
-\r
-\r
-    /**\r
-     * Finds index of a given sequence in the alignment.\r
-     *\r
-     * @param s Sequence to look for.\r
-     *\r
-     * @return Index of sequence within the alignment.\r
-     */\r
-    public int findIndex(SequenceI s);\r
-\r
-    /**\r
-    * All sequences will be cut from beginning to given index.\r
-    *\r
-    * @param i Remove all residues in sequences up to this column.\r
-     */\r
-    public void trimLeft(int i);\r
-\r
-    /**\r
-     * All sequences will be cut from given index.\r
-     *\r
-     * @param i Remove all residues in sequences beyond this column.\r
-     */\r
-    public void trimRight(int i);\r
-\r
-    /**\r
-     * Removes all columns containing entirely gap characters.\r
-     */\r
-    public void removeGaps();\r
-\r
-    /**\r
-     * Removes redundant sequences from alignment.\r
-     *\r
-     * @param threshold Remove all sequences above the given threshold.\r
-     * @param sel Set of sequences which will have redundant sequences removed from.\r
-     *\r
-     * @return All sequences below redundancy threshold.\r
-     */\r
-    public Vector removeRedundancy(float threshold, Vector sel);\r
-\r
-    /**\r
-     * Finds group that sequence at index i in alignment is part of.\r
-     *\r
-     * @param i Index in alignment.\r
-     *\r
-     * @return First group found for sequence at position i. WARNING :\r
-     * Sequences may be members of several groups. This method is incomplete.\r
-     */\r
-    public SequenceGroup findGroup(int i);\r
-\r
-    /**\r
-     * Finds group that given sequence is part of.\r
-     *\r
-     * @param s Sequence in alignment.\r
-     *\r
-     * @return First group found for sequence. WARNING :\r
-     * Sequences may be members of several groups. This method is incomplete.\r
-     */\r
-    public SequenceGroup findGroup(SequenceI s);\r
-\r
-    /**\r
-     * Finds all groups that a given sequence is part of.\r
-     *\r
-     * @param s Sequence in alignment.\r
-     *\r
-     * @return All groups containing given sequence.\r
-     */\r
-    public SequenceGroup[] findAllGroups(SequenceI s);\r
-\r
-    /**\r
-     * Adds a new SequenceGroup to this alignment.\r
-     *\r
-     * @param sg New group to be added.\r
-     */\r
-    public void addGroup(SequenceGroup sg);\r
-\r
-    /**\r
-     * Deletes a specific SequenceGroup\r
-     *\r
-     * @param g Group will be deleted from alignment.\r
-     */\r
-    public void deleteGroup(SequenceGroup g);\r
-\r
-    /**\r
-     * Get all the groups associated with this alignment.\r
-     *\r
-     * @return All groups as a Vector.\r
-     */\r
-    public Vector getGroups();\r
-\r
-    /**\r
-     * Deletes all groups from this alignment.\r
-     */\r
-    public void deleteAllGroups();\r
-\r
-\r
-    /**\r
-     * Adds a new AlignmentAnnotation to this alignment\r
-     */\r
-    public void addAnnotation(AlignmentAnnotation aa);\r
-\r
-    /**\r
-     * Adds a new AlignmentAnnotation to this alignment,\r
-     *  associated to Sequence starting at sequence index\r
-     */\r
-    public AlignmentAnnotation addAnnotation(AlignmentAnnotation aa, SequenceI seqRef);\r
-\r
-    public void setAnnotationIndex(AlignmentAnnotation aa, int index);\r
-\r
-    /**\r
-     * Deletes a specific AlignmentAnnotation from the alignment.\r
-     *\r
-     * @param aa DOCUMENT ME!\r
-     */\r
-    public void deleteAnnotation(AlignmentAnnotation aa);\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public AlignmentAnnotation[] getAlignmentAnnotation();\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @param gc DOCUMENT ME!\r
-     */\r
-    public void setGapCharacter(char gc);\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public char getGapCharacter();\r
-\r
-    /**\r
-     * DOCUMENT ME!\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public Vector getAAFrequency();\r
-\r
-    /**\r
-     * Returns true if alignment is nucleotide sequence\r
-     *\r
-     * @return DOCUMENT ME!\r
-     */\r
-    public boolean isNucleotide();\r
-\r
-    /**\r
-     * Set true if the alignment is a nucleotide sequence\r
-     *\r
-     * @return\r
-     */\r
-    public void setNucleotide(boolean b);\r
-\r
-\r
-    public Alignment getDataset();\r
-\r
-    public void setDataset(Alignment dataset);\r
-    /**\r
-     * pads sequences with gaps (to ensure the set looks like an alignment)\r
-     * @return boolean true if alignment was modified\r
-     */\r
-    public boolean padGaps();\r
-\r
-    public void adjustSequenceAnnotations();\r
-\r
-    public HiddenSequences getHiddenSequences();\r
-\r
-}\r
+/*
+* Jalview - A Sequence Alignment Editor and Viewer
+* 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
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* 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.
+*
+* 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
+*/
+package jalview.datamodel;
+
+import jalview.util.ShiftList;
+
+import java.util.*;
+
+
+/** Data structure to hold and manipulate a multiple sequence alignment
+ */
+public interface AlignmentI
+{
+    /**
+     *  Calculates the number of sequences in an alignment
+     *
+     * @return Number of sequences in alignment
+     */
+    public int getHeight();
+
+    /**
+     * Calculates the maximum width of the alignment, including gaps.
+     *
+     * @return Greatest sequence length within alignment.
+     */
+    public int getWidth();
+
+    /**
+     * Calculates the longest sequence Id of the alignment
+     *
+     * @return Number of characters in longest sequence Id.
+     */
+    public int getMaxIdLength();
+
+    /**
+     * Calculates if this set of sequences is all the same length
+     *
+     * @return true if all sequences in alignment are the same length
+     */
+    public boolean isAligned();
+
+    /**
+     * Gets sequences as a Vector
+     *
+     * @return All sequences in alignment.
+     */
+    public Vector getSequences();
+
+    /**
+     * Gets sequences as a SequenceI[]
+     *
+     * @return All sequences in alignment.
+     */
+    public SequenceI [] getSequencesArray();
+
+    /**
+     * Find a specific sequence in this alignment.
+     *
+     * @param i Index of required sequence.
+     *
+     * @return SequenceI at given index.
+     */
+    public SequenceI getSequenceAt(int i);
+
+    /**
+     * Add a new sequence to this alignment.
+     *
+     * @param seq New sequence will be added at end of alignment.
+     */
+    public void addSequence(SequenceI seq);
+
+    /**
+     * Used to set a particular index of the alignment with the given sequence.
+     *
+     * @param i Index of sequence to be updated.
+     * @param seq New sequence to be inserted.
+     */
+    public void setSequenceAt(int i, SequenceI seq);
+
+    /**
+     * Deletes a sequence from the alignment.
+     *
+     * @param s Sequence to be deleted.
+     */
+    public void deleteSequence(SequenceI s);
+
+    /**
+     * Deletes a sequence from the alignment.
+     *
+     * @param i Index of sequence to be deleted.
+     */
+    public void deleteSequence(int i);
+
+    /**
+     * Deletes all residues in every sequence of alignment within given columns.
+     *
+     * @param start Start index of columns to delete.
+     * @param end End index to columns to delete.
+     */
+    public void deleteColumns(SequenceI seqs [], int start, int end);
+
+
+    /**
+     * Finds sequence in alignment using sequence name as query.
+     *
+     * @param name Id of sequence to search for.
+     *
+     * @return Sequence matching query, if found. If not found returns null.
+     */
+    public SequenceI findName(String name);
+
+    public SequenceI [] findSequenceMatch(String name);
+
+    /**
+     * Finds index of a given sequence in the alignment.
+     *
+     * @param s Sequence to look for.
+     *
+     * @return Index of sequence within the alignment.
+     */
+    public int findIndex(SequenceI s);
+
+    /**
+    * All sequences will be cut from beginning to given index.
+    *
+    * @param i Remove all residues in sequences up to this column.
+     */
+    public void trimLeft(int i);
+
+    /**
+     * All sequences will be cut from given index.
+     *
+     * @param i Remove all residues in sequences beyond this column.
+     */
+    public void trimRight(int i);
+
+    /**
+     * Removes all columns containing entirely gap characters.
+     */
+    public void removeGaps();
+    /**
+     * remove gaps in alignment - recording any frame shifts in shiftrecord
+     * @param shiftrecord
+     */
+    public void removeGaps(ShiftList shiftrecord);
+
+    /**
+     * Finds group that given sequence is part of.
+     *
+     * @param s Sequence in alignment.
+     *
+     * @return First group found for sequence. WARNING :
+     * Sequences may be members of several groups. This method is incomplete.
+     */
+    public SequenceGroup findGroup(SequenceI s);
+
+    /**
+     * Finds all groups that a given sequence is part of.
+     *
+     * @param s Sequence in alignment.
+     *
+     * @return All groups containing given sequence.
+     */
+    public SequenceGroup[] findAllGroups(SequenceI s);
+
+    /**
+     * Adds a new SequenceGroup to this alignment.
+     *
+     * @param sg New group to be added.
+     */
+    public void addGroup(SequenceGroup sg);
+
+    /**
+     * Deletes a specific SequenceGroup
+     *
+     * @param g Group will be deleted from alignment.
+     */
+    public void deleteGroup(SequenceGroup g);
+
+    /**
+     * Get all the groups associated with this alignment.
+     *
+     * @return All groups as a Vector.
+     */
+    public Vector getGroups();
+
+    /**
+     * Deletes all groups from this alignment.
+     */
+    public void deleteAllGroups();
+
+
+    /**
+     * Adds a new AlignmentAnnotation to this alignment
+     */
+    public void addAnnotation(AlignmentAnnotation aa);
+
+
+    public void setAnnotationIndex(AlignmentAnnotation aa, int index);
+
+    /**
+     * Deletes a specific AlignmentAnnotation from the alignment.
+     *
+     * @param aa DOCUMENT ME!
+     */
+    public void deleteAnnotation(AlignmentAnnotation aa);
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public AlignmentAnnotation[] getAlignmentAnnotation();
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @param gc DOCUMENT ME!
+     */
+    public void setGapCharacter(char gc);
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public char getGapCharacter();
+
+    /**
+     * DOCUMENT ME!
+     *
+     * @return DOCUMENT ME!
+     */
+    public Vector getAAFrequency();
+
+    /**
+     * Returns true if alignment is nucleotide sequence
+     *
+     * @return DOCUMENT ME!
+     */
+    public boolean isNucleotide();
+
+    /**
+     * Set true if the alignment is a nucleotide sequence
+     *
+     * @return
+     */
+    public void setNucleotide(boolean b);
+
+
+    public Alignment getDataset();
+
+    public void setDataset(Alignment dataset);
+    /**
+     * pads sequences with gaps (to ensure the set looks like an alignment)
+     * @return boolean true if alignment was modified
+     */
+    public boolean padGaps();
+
+    public void adjustSequenceAnnotations();
+
+    public HiddenSequences getHiddenSequences();
+    /**
+     * Compact representation of alignment
+     * @return CigarArray
+     */
+    public CigarArray getCompactAlignment();
+}