Package org.moltools.lib.seq

Examples of org.moltools.lib.seq.SequenceFormatException


          foundPos = true;
          targetPoly = 0;
          variantIndex = pos;
        }
        else if (foundPos) {
          throw new SequenceFormatException("Too many position symbols"); //$NON-NLS-1$
        }
      }
      else if (current == variantSeparator) { //SNP
        //Check the next char, if outofbounds we have an error
        Nucleotide nextnt;
        try {
          nextnt = NucleotideSequenceHandler.getNucleotide(seq.charAt(pos + 1), acidType);
        }
        catch (StringIndexOutOfBoundsException sx) {
          throw new SequenceFormatException(
              "Expected nucleotide at position: " + (pos + 2)); //$NON-NLS-1$
        }
        //Check previous position, this must be a nucleotide
        Nucleotide prevnt = NucleotideSequenceHandler.getNucleotide(previous, acidType);
        if (prevnt == null) {
          throw new SequenceFormatException(
              "Expected nucleotide at position: " + (pos)); //$NON-NLS-1$
        }
        if (nextnt == null) {
          throw new SequenceFormatException(
              "Expected nucleotide at position: " + (pos + 2)); //$NON-NLS-1$
        }
        if (inSNP) { //We are already in the SNP, add the next nucleotide
          SNPNucleotides.push(nextnt);
        }
        else { //Add both the previous and the next
          SNPNucleotides.push(prevnt);
          SNPNucleotides.push(nextnt);
          inSNP = true;
          //and remove the last nucleotide from elements or the top InDel
          SequenceElementContainer e = (SequenceElementContainer) elementStack.peek();
          e.removeFromEnd();
        }
        //Step up one step and check if this was the last separator
        pos++;
        char next = ' ';
        try {
          next = seq.charAt(pos + 1);
        }
        catch (StringIndexOutOfBoundsException sx2) {
          //Don't care
        }
        if (next != variantSeparator) {
          //This was the last separator so make the SNP
          Nucleotide[] nucs = new Nucleotide[SNPNucleotides.size()];
          for (int i = 0; i < nucs.length; i++) {
            nucs[i] = SNPNucleotides.pop();
          }
          SNP snp = new SNP(nucs, "SNP " + (++SNPno)); //$NON-NLS-1$
          //and add it to the element on the stack
          SequenceElementContainer e = (SequenceElementContainer) elementStack.peek();
          e.addToEnd(snp);
          inSNP = false;
        }
      }
      else if (current == inDelBeginSymbol) {
        elementStack.push(new InDel("InDel " + (++InDelno), "", "InDel " + (++InDelno), acidType)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      else if (current == inDelEndSymbol) {
        if (elementStack.size() < 2) {
          throw new SequenceFormatException("Too many InDel end symbols"); //$NON-NLS-1$
        }
        InDel indel = (InDel) elementStack.pop();
        SequenceElementContainer e = (SequenceElementContainer) elementStack.peek();

        e.addToEnd(indel);
      }
      else {
        //No special symbol, so is either nucleotide, degenerate nucleotide or invalid symbol
        Nucleotide n = NucleotideSequenceHandler.getNucleotide(current, acidType);
        if (n == null) { //invalid
          throw new SequenceFormatException(
              "Invalid symbol encountered during sequence parsing: " + current); //$NON-NLS-1$
        }
        if (NucleotideSequenceHandler.isPoly(n)) { //degenerate nucleotide (SNP)
          SNP snp = new SNP( ( (DegenerateNucleotide) n).getPossible(),
                            "SNP" + (++SNPno)); //$NON-NLS-1$
View Full Code Here


        try {
          nextnt = NucleotideSequenceHandler.getNucleotide(seq.charAt(pos + 1),
              acidType);
        }
        catch (StringIndexOutOfBoundsException sx) {
          throw new SequenceFormatException(
              "Expected nucleotide at position: " + (pos + 2)); //$NON-NLS-1$
        }
        //Check previous position, this must be a nucleotide
        Nucleotide prevnt = NucleotideSequenceHandler.getNucleotide(previous, acidType);
        if (prevnt == null) {
          throw new SequenceFormatException(
              "Expected nucleotide at position: " + (pos)); //$NON-NLS-1$
        }
        if (nextnt == null) {
          throw new SequenceFormatException(
              "Expected nucleotide at position: " + (pos + 2)); //$NON-NLS-1$
        }
        if (inSNP) { //We are already in the SNP, add the next nucleotide
          SNPNucleotides.push(nextnt);
        }
View Full Code Here

TOP

Related Classes of org.moltools.lib.seq.SequenceFormatException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.