Package org.broadinstitute.gatk.utils.exceptions

Examples of org.broadinstitute.gatk.utils.exceptions.ReviewedGATKException


            sig.initVerify(publicKey);
            sig.update(emailAddress.getBytes());
            return sig.verify(signature);
        }
        catch ( NoSuchAlgorithmException e ) {
            throw new ReviewedGATKException(String.format("Signing algorithm %s not found", signingAlgorithm), e);
        }
        catch ( InvalidKeyException e ) {
            // If the GATK public key is invalid, it's likely our problem, not the user's:
            throw new ReviewedGATKException(String.format("Public key %s is invalid", publicKey), e);
        }
        catch ( SignatureException e ) {
            throw new UserException.UnreadableKeyException("Signature is invalid or signing algorithm was unable to process the input data", e);
        }
    }
View Full Code Here


            sig.initSign(privateKey, CryptUtils.createRandomnessSource());
            sig.update(emailAddress.getBytes());
            signature = sig.sign();
        }
        catch ( NoSuchAlgorithmException e ) {
            throw new ReviewedGATKException(String.format("Signing algorithm %s not found", signingAlgorithm), e);
        }
        catch ( InvalidKeyException e ) {
            throw new ReviewedGATKException(String.format("Private key %s is invalid", privateKey), e);
        }
        catch ( SignatureException e ) {
            throw new ReviewedGATKException(String.format("Error creating signature for email address %s", emailAddress), e);
        }
    }
View Full Code Here

        final int goal = refCoord - alignmentStart;  // The goal is to move this many reference bases
        if (goal < 0) {
            if (allowGoalNotReached) {
                return new Pair<Integer, Boolean>(CLIPPING_GOAL_NOT_REACHED, false);
            } else {
                throw new ReviewedGATKException("Somehow the requested coordinate is not covered by the read. Too many deletions?");
            }
        }
        boolean goalReached = refBases == goal;

        Iterator<CigarElement> cigarElementIterator = cigar.getCigarElements().iterator();
        while (!goalReached && cigarElementIterator.hasNext()) {
            final CigarElement cigarElement = cigarElementIterator.next();
            int shift = 0;

            if (cigarElement.getOperator().consumesReferenceBases() || cigarElement.getOperator() == CigarOperator.SOFT_CLIP) {
                if (refBases + cigarElement.getLength() < goal)
                    shift = cigarElement.getLength();
                else
                    shift = goal - refBases;

                refBases += shift;
            }
            goalReached = refBases == goal;

            if (!goalReached && cigarElement.getOperator().consumesReadBases())
                readBases += cigarElement.getLength();

            if (goalReached) {
                // Is this base's reference position within this cigar element? Or did we use it all?
                final boolean endsWithinCigar = shift < cigarElement.getLength();

                // If it isn't, we need to check the next one. There should *ALWAYS* be a next one
                // since we checked if the goal coordinate is within the read length, so this is just a sanity check.
                if (!endsWithinCigar && !cigarElementIterator.hasNext()) {
                    if (allowGoalNotReached) {
                        return new Pair<Integer, Boolean>(CLIPPING_GOAL_NOT_REACHED, false);
                    } else {
                        throw new ReviewedGATKException(String.format("Reference coordinate corresponds to a non-existent base in the read. This should never happen -- check read with alignment start: %s  and cigar: %s", alignmentStart, cigar));
                    }
                }

                CigarElement nextCigarElement = null;

                // if we end inside the current cigar element, we just have to check if it is a deletion (or skipped region)
                if (endsWithinCigar)
                    fallsInsideDeletionOrSkippedRegion = (cigarElement.getOperator() == CigarOperator.DELETION || cigarElement.getOperator() == CigarOperator.SKIPPED_REGION) ;

                // if we end outside the current cigar element, we need to check if the next element is an insertion, deletion or skipped region.
                else {
                    nextCigarElement = cigarElementIterator.next();

                    // if it's an insertion, we need to clip the whole insertion before looking at the next element
                    if (nextCigarElement.getOperator() == CigarOperator.INSERTION) {
                        readBases += nextCigarElement.getLength();
                        if (!cigarElementIterator.hasNext()) {
                            if (allowGoalNotReached) {
                                return new Pair<Integer, Boolean>(CLIPPING_GOAL_NOT_REACHED, false);
                            } else {
                                throw new ReviewedGATKException(String.format("Reference coordinate corresponds to a non-existent base in the read. This should never happen -- check read with alignment start: %s  and cigar: %s", alignmentStart, cigar));
                            }
                        }

                        nextCigarElement = cigarElementIterator.next();
                    }

                    // if it's a deletion (or skipped region), we will pass the information on to be handled downstream.
                    endJustBeforeDeletionOrSkippedRegion = (nextCigarElement.getOperator() == CigarOperator.DELETION || nextCigarElement.getOperator() == CigarOperator.SKIPPED_REGION);
                }

                fallsInsideOrJustBeforeDeletionOrSkippedRegion = endJustBeforeDeletionOrSkippedRegion || fallsInsideDeletionOrSkippedRegion;

                // If we reached our goal outside a deletion (or skipped region), add the shift
                if (!fallsInsideOrJustBeforeDeletionOrSkippedRegion && cigarElement.getOperator().consumesReadBases())
                    readBases += shift;

                // If we reached our goal just before a deletion (or skipped region) we need
                // to add the shift of the current cigar element but go back to it's last element to return the last
                // base before the deletion (or skipped region) (see warning in function contracts)
                else if (endJustBeforeDeletionOrSkippedRegion && cigarElement.getOperator().consumesReadBases())
                    readBases += shift - 1;

                // If we reached our goal inside a deletion (or skipped region), or just between a deletion and a skipped region,
                // then we must backtrack to the last base before the deletion (or skipped region)
                else if (fallsInsideDeletionOrSkippedRegion ||
                        (endJustBeforeDeletionOrSkippedRegion && nextCigarElement.getOperator().equals(CigarOperator.N)) ||
                        (endJustBeforeDeletionOrSkippedRegion && nextCigarElement.getOperator().equals(CigarOperator.D)))
                    readBases--;
            }
        }

        if (!goalReached) {
            if (allowGoalNotReached) {
                return new Pair<Integer, Boolean>(CLIPPING_GOAL_NOT_REACHED, false);
            } else {
                throw new ReviewedGATKException("Somehow the requested coordinate is not covered by the read. Alignment " + alignmentStart + " | " + cigar);
            }
        }

        return new Pair<Integer, Boolean>(readBases, fallsInsideOrJustBeforeDeletionOrSkippedRegion);
    }
View Full Code Here

                    break;
                case 4:
                    bases[i] = 'N';
                    break;
                default:
                    throw new ReviewedGATKException("Something went wrong, this is just impossible");
            }
        }
        return bases;
    }
View Full Code Here

     * @param offset the base in the read (coordinate in the read)
     * @return the reference coordinate correspondent to this base
     */
    public static long getReferenceCoordinateForReadCoordinate(GATKSAMRecord read, int offset) {
        if (offset > read.getReadLength())
            throw new ReviewedGATKException(String.format(OFFSET_OUT_OF_BOUNDS_EXCEPTION, offset, read.getReadLength()));

        long location = read.getAlignmentStart();
        Iterator<CigarElement> cigarElementIterator = read.getCigar().getCigarElements().iterator();
        while (offset > 0 && cigarElementIterator.hasNext()) {
            CigarElement cigarElement = cigarElementIterator.next();
            long move = 0;
            if (cigarElement.getOperator().consumesReferenceBases()) 
                move = (long) Math.min(cigarElement.getLength(), offset);
            location += move;
            offset -= move;
        }
        if (offset > 0 && !cigarElementIterator.hasNext())
            throw new ReviewedGATKException(OFFSET_NOT_ZERO_EXCEPTION);

        return location;
    }
View Full Code Here

                break;
            }
        }

        if (refAllele == null)
            throw new ReviewedGATKException("BUG: no ref alleles in input to makeHaplotypeListfrom Alleles at loc: "+ startPos);

        final byte[] refBases = ref.getBases();

        final int startIdxInReference = 1 + startPos - numPrefBases - ref.getWindow().getStart();
        final String basesBeforeVariant = new String(Arrays.copyOfRange(refBases, startIdxInReference, startIdxInReference + numPrefBases));
View Full Code Here

        System.exit(1);
    }

    public static void exitSystemWithUserError(final Exception e) {
        if ( e.getMessage() == null )
            throw new ReviewedGATKException("UserException found with no message!", e);

        errorPrintf("------------------------------------------------------------------------------------------%n");
        errorPrintf("A USER ERROR has occurred (version %s): %n", CommandLineGATK.getVersionNumber());
        errorPrintf("%n");
        errorPrintf("This means that one or more arguments or inputs in your command are incorrect.%n");
View Full Code Here

        System.exit(1);
    }

    public static void exitSystemWithSamError(final Throwable t) {
        if ( t.getMessage() == null )
            throw new ReviewedGATKException("SamException found with no message!", t);

        errorPrintf("------------------------------------------------------------------------------------------%n");
        errorPrintf("A BAM ERROR has occurred (version %s): %n", CommandLineGATK.getVersionNumber());
        errorPrintf("%n");
        errorPrintf("This means that there is something wrong with the BAM file(s) you provided.%n");
View Full Code Here

                    break;
                case H:
                case P:
                    break;
                default:
                    throw new ReviewedGATKException("The " + ce.getOperator() + " cigar element is not currently supported");
            }
        }

        return delta;
    }
View Full Code Here

                    break;
                case H:
                case P:
                    break;
                default:
                    throw new ReviewedGATKException("The " + ce.getOperator() + " cigar element is not currently supported");
            }

        }
        return mc;
    }
View Full Code Here

TOP

Related Classes of org.broadinstitute.gatk.utils.exceptions.ReviewedGATKException

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.