X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FCigarBase.java;h=4e7e03f09f5a8fd80041f1662fdfb8db5d71ce17;hb=62fb9a3042bdc6daaad8218d47b12cb912907354;hp=37024926161b23fd6e9c4de83c03d3897ae96ded;hpb=a8f483d04205bb8273ee311c12968b7e86d205fa;p=jalview.git diff --git a/src/jalview/datamodel/CigarBase.java b/src/jalview/datamodel/CigarBase.java index 3702492..4e7e03f 100644 --- a/src/jalview/datamodel/CigarBase.java +++ b/src/jalview/datamodel/CigarBase.java @@ -1,24 +1,28 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * * 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. + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. * * 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 . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ package jalview.datamodel; -import java.util.*; +import jalview.util.MessageManager; + +import java.util.Vector; public abstract class CigarBase { @@ -79,7 +83,8 @@ public abstract class CigarBase int[][] deletions = new int[length][]; int[][] trunc_deletions = null; StringBuffer sq = new StringBuffer(); - int cursor = 0, alcursor = 0, start = 0, startpos = 0, end = 0, endpos = 0, delcount = -1; + int cursor = 0, alcursor = 0, start = 0, startpos = 0, end = 0, + endpos = 0, delcount = -1; boolean consecutive_del = false; if (length == 0) { @@ -97,8 +102,7 @@ public abstract class CigarBase case D: if (!consecutive_del) { - deletions[++delcount] = new int[] - { cursor, 0, alcursor }; + deletions[++delcount] = new int[] { cursor, 0, alcursor }; } cursor += range[i]; deletions[delcount][1] = cursor - 1; @@ -142,7 +146,9 @@ public abstract class CigarBase endpos = alcursor; break; default: - throw new Error("Unknown SeqCigar operation '" + operation[i] + "'"); + throw new Error(MessageManager.formatMessage( + "error.unknown_seq_cigar_operation", new String[] + { new StringBuffer(operation[i]).toString() })); } } if (++delcount > 0) @@ -151,9 +157,9 @@ public abstract class CigarBase System.arraycopy(deletions, 0, trunc_deletions, 0, delcount); } deletions = null; - return new Object[] - { ((reference != null) ? sq.toString() : null), new int[] - { start, startpos, end, endpos }, trunc_deletions }; + return new Object[] { ((reference != null) ? sq.toString() : null), + new int[] + { start, startpos, end, endpos }, trunc_deletions }; } protected void compact_operations() @@ -221,7 +227,8 @@ public abstract class CigarBase } while (c >= '0' && c <= '9' && j < l); if (j >= l && c >= '0' && c <= '9') { - throw new Exception("Unterminated cigar string."); + throw new Exception(MessageManager + .getString("exception.unterminated_cigar_string")); } try { @@ -230,7 +237,8 @@ public abstract class CigarBase i = j; } catch (Exception e) { - throw new Error("Implementation bug in parseCigarString"); + throw new Error(MessageManager + .getString("error.implementation_bug_parse_cigar_string")); } if (c >= 'a' && c <= 'z') { @@ -242,13 +250,14 @@ public abstract class CigarBase } else { - throw new Exception("Unexpected operation '" + c - + "' in cigar string (position " + i + " in '" - + cigarString + "'"); + throw new Exception(MessageManager.formatMessage( + "exception.unexpected_operation_cigar_string_pos", + new String[] + { new StringBuffer(c).toString(), + Integer.valueOf(i).toString(), cigarString })); } } - return new Object[] - { operation, range }; + return new Object[] { operation, range }; } /** @@ -267,7 +276,8 @@ public abstract class CigarBase } if (op != M && op != D && op != I) { - throw new Error("Implementation error. Invalid operation string."); + throw new Error(MessageManager.getString( + "error.implementation_error_invalid_operation_string")); } if (range == 0) { @@ -276,7 +286,7 @@ public abstract class CigarBase if (range < 0) { throw new Error( - "Invalid range string (must be zero or positive number)"); + MessageManager.getString("error.invalid_range_string")); } int lngth = 0; if (operation == null) @@ -335,14 +345,14 @@ public abstract class CigarBase * 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; + * 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. - @@ -388,8 +398,8 @@ public abstract class CigarBase } if (start < 0 || start > end) { - throw new Error( - "Implementation Error: deleteRange out of bounds: start must be non-negative and less than end."); + throw new Error(MessageManager.getString( + "error.implementation_error_delete_range_out_of_bounds")); } // find beginning int cursor = 0; // mark the position for the current operation being edited. @@ -461,10 +471,14 @@ public abstract class CigarBase } break; case D: - throw new Error("Implementation error."); // do nothing; + throw new Error( + MessageManager.getString("error.implementation_error")); // do + // nothing; default: - throw new Error("Implementation Error! Unknown operation '" - + oldops[o] + "'"); + throw new Error(MessageManager.formatMessage( + "error.implementation_error_unknown_operation", + new String[] + { new StringBuffer(oldops[o]).toString() })); } rlength -= remain; remain = oldrange[++o]; // number of op characters left to edit @@ -519,12 +533,12 @@ public abstract class CigarBase { case M: cursor += range[i]; + break; case I: vcursor += range[i]; break; case D: - dr.addElement(new int[] - { vcursor, cursor, range[i] }); + dr.addElement(new int[] { vcursor, cursor, range[i] }); cursor += range[i]; } }