X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FCigarBase.java;h=5152a2c5ed24d5cb9369b159de6da71458036c3c;hb=842559f239380e94327db76808eef6c4b28fdd89;hp=b0efe6c1ae3ec0d0f1a267ef3dcb5e64a7355e39;hpb=506d60f0e188723ddc91c26824b41ac7034df3fe;p=jalview.git
diff --git a/src/jalview/datamodel/CigarBase.java b/src/jalview/datamodel/CigarBase.java
index b0efe6c..5152a2c 100644
--- a/src/jalview/datamodel/CigarBase.java
+++ b/src/jalview/datamodel/CigarBase.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.5)
+ * Copyright (C) 2010 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;
@@ -35,7 +34,8 @@ public abstract class CigarBase
protected int length = 0;
protected int _inc_length = 10; // extension range for addition of new
- // operations
+
+ // operations
protected char[] operation = null;
@@ -63,11 +63,11 @@ public abstract class CigarBase
* and the deletion regions as an array of int pairs May return null for an
* empty cigar string. May return null for deletion ranges if there are none.
*
- * @param reference -
- * the symbol sequence to apply the cigar operations to (or
- * null if no sequence)
- * @param GapChar -
- * the symbol to use for Insert operations
+ * @param reference
+ * - the symbol sequence to apply the cigar operations to (or null if
+ * no sequence)
+ * @param GapChar
+ * - the symbol to use for Insert operations
* @return Object[] { String, int[] {start, startcol, end, endcol}, int[][3]
* {start, end, col} or null} the gapped sequence, first and last
* residue index, and the deletion ranges on the reference sequence
@@ -187,11 +187,11 @@ public abstract class CigarBase
* turn a cigar string into a series of operation range pairs
*
* @param cigarString
- * String
+ * String
* @return object[] {char[] operation, int[] range}
* @throws java.lang.Exception
- * for improperly formated cigar strings or ones with unknown
- * operations
+ * for improperly formated cigar strings or ones with unknown
+ * operations
*/
public static Object[] parseCigarString(String cigarString)
throws Exception
@@ -254,9 +254,9 @@ public abstract class CigarBase
* add an operation to cigar string
*
* @param op
- * char
+ * char
* @param range
- * int
+ * int
*/
public void addOperation(char op, int range)
{
@@ -316,60 +316,61 @@ public abstract class CigarBase
* M, Ds changed to M. (ie "5I5M".insert(4,M,3)->"4I8M") - effectively shifts
* sequence left by 1 residue and extends it by 3 (
* "10D5M".insert(-1,M,3)->"3M7D5M") ( "10D5M".insert(0,M,3)->"7D8M") (
- * "10D5M".insert(1,M,3)->"10D8M")
- * ( "1M10D5M".insert(0,M,3)->"1M10D8M") ( "1M10D5M".insert(1,M,3)->"
+ * "10D5M".insert(1,M,3)->"10D8M") ( "1M10D5M".insert(0,M,3)->"1M10D8M") (
+ * "1M10D5M".insert(1,M,3)->"
*
* if pos is beyond width - I operations are added before the operation
*
* @param pos
- * int -1, 0-length of visible region, or greater to append new
- * ops (with insertions in between)
+ * int -1, 0-length of visible region, or greater to append new ops
+ * (with insertions in between)
* @param op
- * char
+ * char
* @param range
- * int public void addOperationAt(int pos, char op, int range) {
- * int cursor = -1; // mark the position for the current
- * operation being edited. int o = 0; boolean last_d = false; //
- * previous op was a deletion. if (pos < -1) throw new
- * Error("pos<-1 is not supported."); while (o0)
- * addInsertion(pos-cursor); // then just add the new
- * operation. Regardless of what it is. addOperation(op,
- * range); } else { int diff = pos - cursor;
+ * int public void addOperationAt(int pos, char op, int range) { int
+ * cursor = -1; // mark the position for the current operation being
+ * edited. int o = 0; boolean last_d = false; // previous op was a
+ * deletion. if (pos < -1) throw new
+ * Error("pos<-1 is not supported."); while (o0) addInsertion(pos-cursor);
+ * // then just add the new operation. Regardless of what it is.
+ * addOperation(op, range); } else { int diff = pos - cursor;
*
- * int e_length = length-o; // new edit operation array length. // diff<0 -
- * can only happen before first insertion or match. - affects op and all
- * following // dif==0 - only when at first position of existing op - //
- * diff>0 - must preserve some existing operations int[] e_range = new
- * int[e_length]; System.arraycopy(this.range, o, e_range, 0, e_length);
- * char[] e_op = new char[e_length]; System.arraycopy(this.operation, o, e_op,
- * 0, e_length); length = o; // can now use add_operation to extend list. int
- * e_o=0; // current operation being edited. switch (op) { case M: switch
- * (e_op[e_o]) { case M: if (last_d && diff <= 0) { // reduce D's, if possible
- * if (range<=this.range[o-1]) { this.range[o - 1] -= range; } else {
- * this.range[o-1]=0; } if (this.range[o-1]==0) o--; // lose this op. }
- * e_range[e_o] += range; // just add more matched residues break; case I: //
- * change from insertion to match if (last_d && diff<=0) { // reduce D's, if
- * possible if (range<=this.range[o-1]) { this.range[o - 1] -= range; } else {
- * this.range[o-1]=0; } if (this.range[o-1]==0) o--; // lose this op. }
- * e_range[e_o] break; default: throw new Inp }
+ * int e_length = length-o; // new edit operation array length. //
+ * diff<0 - can only happen before first insertion or match. -
+ * affects op and all following // dif==0 - only when at first
+ * position of existing op - // diff>0 - must preserve some existing
+ * operations int[] e_range = new int[e_length];
+ * System.arraycopy(this.range, o, e_range, 0, e_length); char[] e_op
+ * = new char[e_length]; System.arraycopy(this.operation, o, e_op, 0,
+ * e_length); length = o; // can now use add_operation to extend
+ * list. int e_o=0; // current operation being edited. switch (op) {
+ * case M: switch (e_op[e_o]) { case M: if (last_d && diff <= 0) { //
+ * reduce D's, if possible if (range<=this.range[o-1]) { this.range[o
+ * - 1] -= range; } else { this.range[o-1]=0; } if
+ * (this.range[o-1]==0) o--; // lose this op. } e_range[e_o] +=
+ * range; // just add more matched residues break; case I: // change
+ * from insertion to match if (last_d && diff<=0) { // reduce D's, if
+ * possible if (range<=this.range[o-1]) { this.range[o - 1] -= range;
+ * } else { this.range[o-1]=0; } if (this.range[o-1]==0) o--; // lose
+ * this op. } e_range[e_o] break; default: throw new Inp }
*
- * break; case I: break; case D: } break; default: throw new
- * Error("Implementation Error: Unknown operation in addOperation!"); } //
- * finally, add remaining ops. while (e_o 0) { // find operation bracketing
* start of the range do { if (operation[op] != D) { width +=
- * range[prevop = op]; } op++; } while (op < length && width < start); }
- * if (width < start) { // run off end - add more operations up to
+ * range[prevop = op]; } op++; } while (op < length && width < start);
+ * } if (width < start) { // run off end - add more operations up to
* deletion. addInsertion(start - width); } else { // edit existing
* operations. op = prevop; width -= range[prevop]; int[] oldrange =
* range; char[] oldops = operation; range = new int[oldrange.length];