From: kiramt Date: Fri, 16 Feb 2018 10:16:28 +0000 (+0000) Subject: JAL-2909 Removed buggy CIGAR parsing code which was not used X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c471de0bd58af67bc91d413f3bf1209c4113a601;p=jalview.git JAL-2909 Removed buggy CIGAR parsing code which was not used --- diff --git a/src/jalview/datamodel/CigarBase.java b/src/jalview/datamodel/CigarBase.java index 4e7e03f..a44d74b 100644 --- a/src/jalview/datamodel/CigarBase.java +++ b/src/jalview/datamodel/CigarBase.java @@ -191,76 +191,6 @@ public abstract class CigarBase } /** - * turn a cigar string into a series of operation range pairs - * - * @param cigarString - * String - * @return object[] {char[] operation, int[] range} - * @throws java.lang.Exception - * for improperly formated cigar strings or ones with unknown - * operations - */ - public static Object[] parseCigarString(String cigarString) - throws Exception - { - int ops = 0; - for (int i = 0, l = cigarString.length(); i < l; i++) - { - char c = cigarString.charAt(i); - if (c == M || c == (M - _case_shift) || c == I - || c == (I - _case_shift) || c == D || c == (D - _case_shift)) - { - ops++; - } - } - char[] operation = new char[ops]; - int[] range = new int[ops]; - int op = 0; - int i = 0, l = cigarString.length(); - while (i < l) - { - char c; - int j = i; - do - { - c = cigarString.charAt(j++); - } while (c >= '0' && c <= '9' && j < l); - if (j >= l && c >= '0' && c <= '9') - { - throw new Exception(MessageManager - .getString("exception.unterminated_cigar_string")); - } - try - { - String rangeint = cigarString.substring(i, j - 1); - range[op] = Integer.parseInt(rangeint); - i = j; - } catch (Exception e) - { - throw new Error(MessageManager - .getString("error.implementation_bug_parse_cigar_string")); - } - if (c >= 'a' && c <= 'z') - { - c -= _case_shift; - } - if ((c == M || c == I || c == D)) - { - operation[op++] = c; - } - else - { - 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 }; - } - - /** * add an operation to cigar string * * @param op diff --git a/src/jalview/datamodel/SeqCigar.java b/src/jalview/datamodel/SeqCigar.java index c2a6a9c..afe10fc 100644 --- a/src/jalview/datamodel/SeqCigar.java +++ b/src/jalview/datamodel/SeqCigar.java @@ -467,25 +467,6 @@ public class SeqCigar extends CigarSimple } /** - * Create a cigar object from a cigar string like '[]+' Will - * fail if the given seq already contains gaps (JBPNote: future implementation - * will fix) - * - * @param seq - * SequenceI object resolvable to a dataset sequence - * @param cigarString - * String - * @return Cigar - */ - public static SeqCigar parseCigar(SequenceI seq, String cigarString) - throws Exception - { - Object[] opsandrange = parseCigarString(cigarString); - return new SeqCigar(seq, (char[]) opsandrange[0], - (int[]) opsandrange[1]); - } - - /** * create an alignment from the given array of cigar sequences and gap * character, and marking the given segments as visible in the given * hiddenColumns. diff --git a/test/jalview/datamodel/SeqCigarTest.java b/test/jalview/datamodel/SeqCigarTest.java index 89169d6..57f1156 100644 --- a/test/jalview/datamodel/SeqCigarTest.java +++ b/test/jalview/datamodel/SeqCigarTest.java @@ -90,11 +90,6 @@ public class SeqCigarTest assertEquals("Failed to recover ungapped sequence cigar operations", "42M", cs_null); testCigar_string(s_gapped, ex_cs_gapped); - SeqCigar gen_sgapped = SeqCigar.parseCigar(s, ex_cs_gapped); - assertEquals("Failed parseCigar", ex_cs_gapped, - gen_sgapped.getCigarstring()); - - testSeqRecovery(gen_sgapped, s_gapped); /* * Test dataset resolution