/*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 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
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)\r
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
+ * \r
+ * This file is part of Jalview.\r
+ * \r
+ * Jalview 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 3 of the License, or (at your option) any later version.\r
+ * \r
+ * Jalview is distributed in the hope that it will be useful, but \r
+ * WITHOUT ANY WARRANTY; without even the implied warranty \r
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
+ * PURPOSE. See the GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
package jalview.datamodel;\r
\r
{\r
Vector selected = new Vector();\r
\r
- //Vector of int [] {startCol, endCol}\r
+ // Vector of int [] {startCol, endCol}\r
Vector hiddenColumns;\r
\r
/**\r
* Add a column to the selection\r
- *\r
- * @param col index of column\r
+ * \r
+ * @param col\r
+ * index of column\r
*/\r
public void addElement(int col)\r
{\r
\r
/**\r
* removes col from selection\r
- *\r
- * @param col index of column to be removed\r
+ * \r
+ * @param col\r
+ * index of column to be removed\r
*/\r
public void removeElement(int col)\r
{\r
\r
/**\r
* removes a range of columns from the selection\r
- * @param start int - first column in range to be removed\r
- * @param end int - last col\r
+ * \r
+ * @param start\r
+ * int - first column in range to be removed\r
+ * @param end\r
+ * int - last col\r
*/\r
public void removeElements(int start, int end)\r
{\r
}\r
\r
/**\r
- *\r
+ * \r
* @return Vector containing selected columns as Integers\r
*/\r
public Vector getSelected()\r
}\r
\r
/**\r
- *\r
- * @param col index to search for in column selection\r
- *\r
+ * \r
+ * @param col\r
+ * index to search for in column selection\r
+ * \r
* @return true if Integer(col) is in selection.\r
*/\r
public boolean contains(int col)\r
\r
/**\r
* Column number at position i in selection\r
- *\r
- * @param i index into selected columns\r
- *\r
+ * \r
+ * @param i\r
+ * index into selected columns\r
+ * \r
* @return column number in alignment\r
*/\r
public int columnAt(int i)\r
{\r
- return ( (Integer) selected.elementAt(i)).intValue();\r
+ return ((Integer) selected.elementAt(i)).intValue();\r
}\r
\r
/**\r
* DOCUMENT ME!\r
- *\r
+ * \r
* @return DOCUMENT ME!\r
*/\r
public int size()\r
\r
/**\r
* rightmost selected column\r
- *\r
+ * \r
* @return rightmost column in alignment that is selected\r
*/\r
public int getMax()\r
\r
/**\r
* Leftmost column in selection\r
- *\r
+ * \r
* @return column index of leftmost column in selection\r
*/\r
public int getMin()\r
\r
/**\r
* propagate shift in alignment columns to column selection\r
- *\r
- * @param start beginning of edit\r
- * @param left shift in edit (+ve for removal, or -ve for inserts)\r
+ * \r
+ * @param start\r
+ * beginning of edit\r
+ * @param left\r
+ * shift in edit (+ve for removal, or -ve for inserts)\r
*/\r
public Vector compensateForEdit(int start, int change)\r
{\r
int[] region = (int[]) hiddenColumns.elementAt(i);\r
if (region[0] > start && start + change > region[1])\r
{\r
- deletedHiddenColumns.addElement(\r
- hiddenColumns.elementAt(i));\r
+ deletedHiddenColumns.addElement(hiddenColumns.elementAt(i));\r
\r
hiddenColumns.removeElementAt(i);\r
i--;\r
}\r
\r
/**\r
- * propagate shift in alignment columns to column selection\r
- * special version of compensateForEdit - allowing for edits within hidden regions\r
- * @param start beginning of edit\r
- * @param left shift in edit (+ve for removal, or -ve for inserts)\r
+ * propagate shift in alignment columns to column selection special version of\r
+ * compensateForEdit - allowing for edits within hidden regions\r
+ * \r
+ * @param start\r
+ * beginning of edit\r
+ * @param left\r
+ * shift in edit (+ve for removal, or -ve for inserts)\r
*/\r
private void compensateForDelEdits(int start, int change)\r
{\r
}\r
\r
/**\r
- * Adjust hidden column boundaries based on a series of column\r
- * additions or deletions in visible regions.\r
+ * Adjust hidden column boundaries based on a series of column additions or\r
+ * deletions in visible regions.\r
+ * \r
* @param shiftrecord\r
* @return\r
*/\r
for (int i = 0, j = shifts.size(); i < j; i++)\r
{\r
int[] sh = (int[]) shifts.elementAt(i);\r
- //compensateForEdit(shifted+sh[0], sh[1]);\r
+ // compensateForEdit(shifted+sh[0], sh[1]);\r
compensateForDelEdits(shifted + sh[0], sh[1]);\r
shifted -= sh[1];\r
}\r
}\r
\r
/**\r
- * removes intersection of position,length ranges in deletions\r
- * from the start,end regions marked in intervals.\r
+ * removes intersection of position,length ranges in deletions from the\r
+ * start,end regions marked in intervals.\r
+ * \r
* @param deletions\r
* @param intervals\r
* @return\r
}\r
}\r
}\r
- return pruned; // true if any interval was removed or modified by operations.\r
+ return pruned; // true if any interval was removed or modified by\r
+ // operations.\r
}\r
\r
private boolean pruneColumnList(Vector deletion, Vector list)\r
int i = 0, j = list.size();\r
while (i < j && s <= t)\r
{\r
- int c = ( (Integer) list.elementAt(i++)).intValue();\r
+ int c = ((Integer) list.elementAt(i++)).intValue();\r
if (sr[0] <= c)\r
{\r
if (sr[1] + sr[0] >= c)\r
}\r
\r
/**\r
- * remove any hiddenColumns or selected columns and shift remaining\r
- * based on a series of position, range deletions.\r
+ * remove any hiddenColumns or selected columns and shift remaining based on a\r
+ * series of position, range deletions.\r
+ * \r
* @param deletions\r
*/\r
public void pruneDeletions(ShiftList deletions)\r
}\r
\r
/**\r
- * This Method is used to return all the HiddenColumn regions\r
- * less than the given index.\r
- * @param end int\r
+ * This Method is used to return all the HiddenColumn regions less than the\r
+ * given index.\r
+ * \r
+ * @param end\r
+ * int\r
* @return Vector\r
*/\r
public Vector getHiddenColumns()\r
\r
/**\r
* Return absolute column index for a visible column index\r
- * @param column int column index in alignment view\r
+ * \r
+ * @param column\r
+ * int column index in alignment view\r
* @return alignment column index for column\r
*/\r
public int adjustForHiddenColumns(int column)\r
}\r
\r
/**\r
- * Use this method to find out where a visible column is in the alignment\r
- * when hidden columns exist\r
- * @param hiddenColumn int\r
+ * Use this method to find out where a column will appear in the visible\r
+ * alignment when hidden columns exist. If the column is not visible, then the\r
+ * left-most visible column will always be returned.\r
+ * \r
+ * @param hiddenColumn\r
+ * int\r
* @return int\r
*/\r
public int findColumnPosition(int hiddenColumn)\r
if (hiddenColumns != null)\r
{\r
int index = 0;\r
- int gaps = 0;\r
+ int[] region;\r
do\r
{\r
- int[] region = (int[]) hiddenColumns.elementAt(index);\r
+ region = (int[]) hiddenColumns.elementAt(index++);\r
if (hiddenColumn > region[1])\r
{\r
result -= region[1] + 1 - region[0];\r
}\r
- index++;\r
+ } while ((hiddenColumn > region[1]) && (index < hiddenColumns.size()));\r
+ if (hiddenColumn > region[0] && hiddenColumn < region[1])\r
+ {\r
+ return region[0] + hiddenColumn - result;\r
}\r
- while (index < hiddenColumns.size());\r
-\r
- result -= gaps;\r
}\r
-\r
- return result;\r
+ return result; // return the shifted position after removing hidden columns.\r
}\r
\r
/**\r
gaps += region[1] + 1 - region[0];\r
result = region[1] + 1;\r
index++;\r
- }\r
- while (index < hiddenRegion + 1);\r
+ } while (index < hiddenRegion + 1);\r
\r
result -= gaps;\r
}\r
}\r
\r
/**\r
- * THis method returns the rightmost limit of a\r
- * region of an alignment with hidden columns.\r
- * In otherwords, the next hidden column.\r
- * @param index int\r
+ * THis method returns the rightmost limit of a region of an alignment with\r
+ * hidden columns. In otherwords, the next hidden column.\r
+ * \r
+ * @param index\r
+ * int\r
*/\r
public int getHiddenBoundaryRight(int alPos)\r
{\r
}\r
\r
index++;\r
- }\r
- while (index < hiddenColumns.size());\r
+ } while (index < hiddenColumns.size());\r
}\r
\r
return alPos;\r
}\r
\r
/**\r
- * This method returns the leftmost limit of a\r
- * region of an alignment with hidden columns.\r
- * In otherwords, the previous hidden column.\r
- * @param index int\r
+ * This method returns the leftmost limit of a region of an alignment with\r
+ * hidden columns. In otherwords, the previous hidden column.\r
+ * \r
+ * @param index\r
+ * int\r
*/\r
public int getHiddenBoundaryLeft(int alPos)\r
{\r
}\r
\r
index--;\r
- }\r
- while (index > -1);\r
+ } while (index > -1);\r
}\r
\r
return alPos;\r
{\r
while (size() > 0)\r
{\r
- int column = ( (Integer) getSelected().firstElement()).intValue();\r
+ int column = ((Integer) getSelected().firstElement()).intValue();\r
hideColumns(column);\r
}\r
\r
else if (end < region[0] && start < region[0])\r
{\r
hiddenColumns.insertElementAt(new int[]\r
- {start, end}, i);\r
+ { start, end }, i);\r
added = true;\r
break;\r
}\r
else if (!added)\r
{\r
hiddenColumns.addElement(new int[]\r
- {start, end});\r
+ { start, end });\r
}\r
\r
}\r
\r
/**\r
- * This method will find a range of selected columns\r
- * around the column specified\r
- * @param res int\r
+ * This method will find a range of selected columns around the column\r
+ * specified\r
+ * \r
+ * @param res\r
+ * int\r
*/\r
public void hideColumns(int col)\r
{\r
\r
/**\r
* Copy constructor\r
+ * \r
* @param copy\r
*/\r
public ColumnSelection(ColumnSelection copy)\r
}\r
\r
public String[] getVisibleSequenceStrings(int start, int end,\r
- SequenceI[] seqs)\r
+ SequenceI[] seqs)\r
{\r
int i, iSize = seqs.length;\r
String selection[] = new String[iSize];\r
\r
/**\r
* return all visible segments between the given start and end boundaries\r
- *\r
- * @param start (first column inclusive from 0)\r
- * @param end (last column - not inclusive)\r
- * @return int[] {i_start, i_end, ..} where intervals lie in start<=i_start<=i_end<end\r
+ * \r
+ * @param start\r
+ * (first column inclusive from 0)\r
+ * @param end\r
+ * (last column - not inclusive)\r
+ * @return int[] {i_start, i_end, ..} where intervals lie in\r
+ * start<=i_start<=i_end<end\r
*/\r
public int[] getVisibleContigs(int start, int end)\r
{\r
if (hideStart > vstart)\r
{\r
visiblecontigs.addElement(new int[]\r
- {vstart, hideStart - 1});\r
+ { vstart, hideStart - 1 });\r
}\r
vstart = hideEnd + 1;\r
}\r
if (vstart < end)\r
{\r
visiblecontigs.addElement(new int[]\r
- {vstart, end - 1});\r
+ { vstart, end - 1 });\r
}\r
int[] vcontigs = new int[visiblecontigs.size() * 2];\r
for (int i = 0, j = visiblecontigs.size(); i < j; i++)\r
else\r
{\r
return new int[]\r
- {\r
- start, end - 1};\r
+ { start, end - 1 };\r
}\r
}\r
\r
/**\r
- * delete any columns in alignmentAnnotation that are hidden (including sequence associated annotation).\r
+ * delete any columns in alignmentAnnotation that are hidden (including\r
+ * sequence associated annotation).\r
+ * \r
* @param alignmentAnnotation\r
*/\r
public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)\r
{\r
- makeVisibleAnnotation(-1,-1,alignmentAnnotation);\r
+ makeVisibleAnnotation(-1, -1, alignmentAnnotation);\r
}\r
+\r
/**\r
- * delete any columns in alignmentAnnotation that are hidden (including sequence associated annotation).\r
- * @param start remove any annotation to the right of this column\r
- * @param end remove any annotation to the left of this column\r
- * @param alignmentAnnotation the annotation to operate on\r
+ * delete any columns in alignmentAnnotation that are hidden (including\r
+ * sequence associated annotation).\r
+ * \r
+ * @param start\r
+ * remove any annotation to the right of this column\r
+ * @param end\r
+ * remove any annotation to the left of this column\r
+ * @param alignmentAnnotation\r
+ * the annotation to operate on\r
*/\r
- public void makeVisibleAnnotation(int start, int end, AlignmentAnnotation alignmentAnnotation)\r
+ public void makeVisibleAnnotation(int start, int end,\r
+ AlignmentAnnotation alignmentAnnotation)\r
{\r
- if (alignmentAnnotation.annotations==null)\r
+ if (alignmentAnnotation.annotations == null)\r
{\r
return;\r
}\r
- if (start==end && end==-1)\r
+ if (start == end && end == -1)\r
{\r
start = 0;\r
end = alignmentAnnotation.annotations.length;\r
if (hiddenColumns != null && hiddenColumns.size() > 0)\r
{\r
// then mangle the alignmentAnnotation annotation array\r
- Vector annels = new Vector();\r
- Annotation[] els = null;\r
- Vector regions = getHiddenColumns();\r
- int blockStart = start, blockEnd = end;\r
- int[] region;\r
- int hideStart, hideEnd,w=0;\r
+ Vector annels = new Vector();\r
+ Annotation[] els = null;\r
+ Vector regions = getHiddenColumns();\r
+ int blockStart = start, blockEnd = end;\r
+ int[] region;\r
+ int hideStart, hideEnd, w = 0;\r
\r
- for (int j = 0; j < regions.size(); j++)\r
+ for (int j = 0; j < regions.size(); j++)\r
+ {\r
+ region = (int[]) regions.elementAt(j);\r
+ hideStart = region[0];\r
+ hideEnd = region[1];\r
+\r
+ if (hideStart < start)\r
{\r
- region = (int[]) regions.elementAt(j);\r
- hideStart = region[0];\r
- hideEnd = region[1];\r
+ continue;\r
+ }\r
\r
- if (hideStart < start)\r
- {\r
- continue;\r
- }\r
+ blockStart = Math.min(blockStart, hideEnd + 1);\r
+ blockEnd = Math.min(blockEnd, hideStart);\r
\r
- blockStart = Math.min(blockStart, hideEnd + 1);\r
- blockEnd = Math.min(blockEnd, hideStart);\r
+ if (blockStart > blockEnd)\r
+ {\r
+ break;\r
+ }\r
\r
- if (blockStart > blockEnd)\r
+ annels.addElement(els = new Annotation[blockEnd - blockStart]);\r
+ System.arraycopy(alignmentAnnotation.annotations, blockStart, els,\r
+ 0, els.length);\r
+ w += els.length;\r
+ blockStart = hideEnd + 1;\r
+ blockEnd = end;\r
+ }\r
+\r
+ if (end > blockStart)\r
+ {\r
+ annels.addElement(els = new Annotation[end - blockStart + 1]);\r
+ if ((els.length + blockStart) <= alignmentAnnotation.annotations.length)\r
+ {\r
+ // copy just the visible segment of the annotation row\r
+ System.arraycopy(alignmentAnnotation.annotations, blockStart,\r
+ els, 0, els.length);\r
+ }\r
+ else\r
+ {\r
+ // copy to the end of the annotation row\r
+ System.arraycopy(alignmentAnnotation.annotations, blockStart,\r
+ els, 0,\r
+ (alignmentAnnotation.annotations.length - blockStart));\r
+ }\r
+ w += els.length;\r
+ }\r
+ if (w == 0)\r
+ return;\r
+ Enumeration e = annels.elements();\r
+ alignmentAnnotation.annotations = new Annotation[w];\r
+ w = 0;\r
+ while (e.hasMoreElements())\r
+ {\r
+ Annotation[] chnk = (Annotation[]) e.nextElement();\r
+ System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w,\r
+ chnk.length);\r
+ w += chnk.length;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ alignmentAnnotation.restrict(start, end);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Invert the column selection from first to end-1. leaves hiddenColumns\r
+ * untouched (and unselected)\r
+ * \r
+ * @param first\r
+ * @param end\r
+ */\r
+ public void invertColumnSelection(int first, int width)\r
+ {\r
+ boolean hasHidden = hiddenColumns != null && hiddenColumns.size() > 0;\r
+ for (int i = first; i < width; i++)\r
+ {\r
+ if (contains(i))\r
+ {\r
+ removeElement(i);\r
+ }\r
+ else\r
+ {\r
+ if (!hasHidden || isVisible(i))\r
+ {\r
+ addElement(i);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * add in any unselected columns from the given column selection, excluding\r
+ * any that are hidden.\r
+ * \r
+ * @param colsel\r
+ */\r
+ public void addElementsFrom(ColumnSelection colsel)\r
+ {\r
+ if (colsel != null && colsel.size() > 0)\r
+ {\r
+ Enumeration e = colsel.getSelected().elements();\r
+ while (e.hasMoreElements())\r
+ {\r
+ Object eo = e.nextElement();\r
+ if (hiddenColumns != null && isVisible(((Integer) eo).intValue()))\r
+ {\r
+ if (!selected.contains(eo))\r
{\r
- break;\r
+ selected.addElement(eo);\r
}\r
+ }\r
+ }\r
+ }\r
+ }\r
\r
- annels.addElement(els = new Annotation[blockEnd-blockStart]);\r
- System.arraycopy(alignmentAnnotation.annotations, blockStart, els, 0, els.length);\r
- w+=els.length;\r
- blockStart = hideEnd + 1;\r
- blockEnd = end;\r
+ /**\r
+ * set the selected columns the given column selection, excluding any columns\r
+ * that are hidden.\r
+ * \r
+ * @param colsel\r
+ */\r
+ public void setElementsFrom(ColumnSelection colsel)\r
+ {\r
+ selected = new Vector();\r
+ if (colsel.selected != null && colsel.selected.size() > 0)\r
+ {\r
+ if (hiddenColumns != null && hiddenColumns.size() > 0)\r
+ {\r
+ // only select visible columns in this columns selection\r
+ selected = new Vector();\r
+ addElementsFrom(colsel);\r
+ }\r
+ else\r
+ {\r
+ // add everything regardless\r
+ Enumeration en = colsel.selected.elements();\r
+ while (en.hasMoreElements())\r
+ {\r
+ selected.addElement(en.nextElement());\r
}\r
+ }\r
+ }\r
+ }\r
\r
- if (end > blockStart)\r
+ /**\r
+ * Add gaps into the sequences aligned to profileseq under the given\r
+ * AlignmentView\r
+ * \r
+ * @param profileseq\r
+ * @param al - alignment to have gaps inserted into it\r
+ * @param input - alignment view where sequence corresponding to profileseq is first entry\r
+ * @return new Column selection for new alignment view, with insertions into profileseq marked as hidden.\r
+ */\r
+ public static ColumnSelection propagateInsertions(SequenceI profileseq,\r
+ Alignment al, AlignmentView input)\r
+ {\r
+ int profsqpos=0;\r
+ \r
+// return propagateInsertions(profileseq, al, )\r
+ char gc = al.getGapCharacter();\r
+ Object[] alandcolsel = input.getAlignmentAndColumnSelection(gc);\r
+ ColumnSelection nview = (ColumnSelection) alandcolsel[1];\r
+ SequenceI origseq = ((SequenceI[]) alandcolsel[0])[profsqpos];\r
+ nview.propagateInsertions(profileseq,\r
+ al, origseq);\r
+ return nview;\r
+ }\r
+ /**\r
+ * \r
+ * @param profileseq - sequence in al which corresponds to origseq \r
+ * @param al - alignment which is to have gaps inserted into it\r
+ * @param origseq - sequence corresponding to profileseq which defines gap map for modifying al\r
+ */\r
+ public void propagateInsertions(SequenceI profileseq, AlignmentI al, SequenceI origseq)\r
+ {\r
+ char gc = al.getGapCharacter();\r
+ // recover mapping between sequence's non-gap positions and positions \r
+ // mapping to view.\r
+ pruneDeletions(ShiftList\r
+ .parseMap(origseq\r
+ .gapMap())); \r
+ int[] viscontigs = getVisibleContigs(0, profileseq.getLength());\r
+ int spos = 0;\r
+ int offset = 0;\r
+ // input.pruneDeletions(ShiftList.parseMap(((SequenceI[])\r
+ // alandcolsel[0])[0].gapMap()))\r
+ // add profile to visible contigs\r
+ for (int v = 0; v < viscontigs.length; v += 2)\r
+ {\r
+ if (viscontigs[v] > spos)\r
+ {\r
+ StringBuffer sb = new StringBuffer();\r
+ for (int s = 0, ns = viscontigs[v] - spos; s < ns; s++)\r
{\r
- annels.addElement(els = new Annotation[end-blockStart]);\r
- System.arraycopy(alignmentAnnotation.annotations, blockStart, els, 0, els.length);\r
- w+=els.length;\r
+ sb.append(gc);\r
}\r
- if (w==0)\r
- return;\r
- Enumeration e = annels.elements();\r
- alignmentAnnotation.annotations = new Annotation[w];\r
- w=0;\r
- while (e.hasMoreElements())\r
+ for (int s = 0, ns = al.getHeight(); s < ns; s++)\r
{\r
- Annotation[] chnk = (Annotation[]) e.nextElement();\r
- System.arraycopy(chnk, 0, alignmentAnnotation.annotations, w, chnk.length);\r
- w+=chnk.length;\r
+ SequenceI sqobj = al.getSequenceAt(s);\r
+ if (sqobj != profileseq)\r
+ {\r
+ String sq = al.getSequenceAt(s).getSequenceAsString();\r
+ if (sq.length() <= spos + offset)\r
+ {\r
+ // pad sequence\r
+ int diff = spos + offset - sq.length() - 1;\r
+ if (diff > 0)\r
+ {\r
+ // pad gaps\r
+ sq = sq + sb;\r
+ while ((diff = spos + offset - sq.length() - 1) > 0)\r
+ {\r
+ //sq = sq\r
+ // + ((diff >= sb.length()) ? sb.toString() : sb\r
+ // .substring(0, diff));\r
+ if (diff>=sb.length()) {\r
+ sq+=sb.toString();\r
+ } else {\r
+ char[] buf = new char[diff];\r
+ sb.getChars(0, diff, buf, 0);\r
+ sq+=buf.toString();\r
+ }\r
+ }\r
+ }\r
+ sq += sb.toString();\r
+ }\r
+ else\r
+ {\r
+ al.getSequenceAt(s).setSequence(\r
+ sq.substring(0, spos + offset) + sb.toString()\r
+ + sq.substring(spos + offset));\r
+ }\r
+ }\r
}\r
+ // offset+=sb.length();\r
+ }\r
+ spos = viscontigs[v + 1] + 1;\r
+ }\r
+ if ((offset + spos) < profileseq.getLength())\r
+ {\r
+ // pad the final region with gaps.\r
+ StringBuffer sb = new StringBuffer();\r
+ for (int s = 0, ns = profileseq.getLength() - spos - offset; s < ns; s++)\r
+ {\r
+ sb.append(gc);\r
+ }\r
+ for (int s = 0, ns = al.getHeight(); s < ns; s++)\r
+ {\r
+ SequenceI sqobj = al.getSequenceAt(s);\r
+ if (sqobj==profileseq)\r
+ {\r
+ continue;\r
+ }\r
+ String sq = sqobj.getSequenceAsString();\r
+ // pad sequence\r
+ int diff = origseq.getLength() - sq.length();\r
+ while (diff > 0)\r
+ {\r
+ sq = sq\r
+ + ((diff >= sb.length()) ? sb.toString() : sb\r
+ .substring(0, diff));\r
+ diff = origseq.getLength() - sq.length();\r
+ }\r
+ }\r
}\r
}\r
}\r