Package org.broadinstitute.gatk.utils.exceptions

Examples of org.broadinstitute.gatk.utils.exceptions.UserException$MalformedFile


                List<SAMSequenceRecord> x = findDisequalCommonContigs(getCommonContigsByName(dict1, dict2), dict1, dict2);
                SAMSequenceRecord elt1 = x.get(0);
                SAMSequenceRecord elt2 = x.get(1);

                // todo -- replace with toString when SAMSequenceRecord has a nice toString routine
                UserException ex = new UserException.IncompatibleSequenceDictionaries(String.format("Found contigs with the same name but different lengths:\n  contig %s = %s / %d\n  contig %s = %s / %d",
                        name1, elt1.getSequenceName(), elt1.getSequenceLength(),
                        name2, elt2.getSequenceName(), elt2.getSequenceLength()),
                        name1, dict1, name2, dict2);

                if ( allowNonFatalIncompabilities(validationExclusion) )
                    logger.warn(ex.getMessage());
                else
                    throw ex;
                break;
            }

            case NON_CANONICAL_HUMAN_ORDER: {
                UserException ex;
                if ( nonCanonicalHumanContigOrder(dict1) )
                    ex = new UserException.LexicographicallySortedSequenceDictionary(name1, dict1);
                else
                    ex = new UserException.LexicographicallySortedSequenceDictionary(name2, dict2);
               
                if ( allowNonFatalIncompabilities(validationExclusion) )
                    logger.warn(ex.getMessage());
                else
                    throw ex;
                break;
            }

            case OUT_OF_ORDER: {
                UserException ex = new UserException.IncompatibleSequenceDictionaries("Relative ordering of overlapping contigs differs, which is unsafe", name1, dict1, name2, dict2);
                if ( allowNonFatalIncompabilities(validationExclusion) )
                    logger.warn(ex.getMessage());
                else
                    throw ex;
                break;
            }

            case DIFFERENT_INDICES: {
                // This is currently only known to be problematic when the index mismatch is between a bam and the
                // reference AND when the user's intervals actually include one or more of the contigs that are
                // indexed differently from the reference. In this case, the engine will fail to correctly serve
                // up the reads from those contigs, so throw an exception unless unsafe operations are enabled.
                if ( isReadsToReferenceComparison && intervals != null ) {

                     final Set<String> misindexedContigs = findMisindexedContigsInIntervals(intervals, dict1, dict2);

                     if ( ! misindexedContigs.isEmpty() ) {
                         final String msg = String.format("The following contigs included in the intervals to process have " +
                                                          "different indices in the sequence dictionaries for the reads vs. " +
                                                          "the reference: %s.  As a result, the GATK engine will not correctly " +
                                                          "process reads from these contigs. You should either fix the sequence " +
                                                          "dictionaries for your reads so that these contigs have the same indices " +
                                                          "as in the sequence dictionary for your reference, or exclude these contigs " +
                                                          "from your intervals. This error can be disabled via -U %s, " +
                                                          "however this is not recommended as the GATK engine will not behave correctly.",
                                                          misindexedContigs, ValidationExclusion.TYPE.ALLOW_SEQ_DICT_INCOMPATIBILITY);
                         final UserException ex = new UserException.IncompatibleSequenceDictionaries(msg, name1, dict1, name2, dict2);

                         if ( allowNonFatalIncompabilities(validationExclusion) )
                             logger.warn(ex.getMessage());
                         else
                             throw ex;
                     }
                }
                break;
View Full Code Here


     * reserve as a delimiter within each key file.
     */
    private void validateEmailAddress() {
        for ( byte b : emailAddress.getBytes() ) {
            if ( b == GATK_KEY_SECTIONAL_DELIMITER ) {
                throw new UserException(String.format("Email address must not contain a byte with value %d", GATK_KEY_SECTIONAL_DELIMITER));
            }
        }
    }
View Full Code Here

        catch ( InterruptedException e ) {
            shutdownAttemptSucceeded = false;
        }

        if ( ! shutdownAttemptSucceeded ) {
            throw new UserException(String.format("Failed to terminate lock acquisition thread while trying to lock file %s. " +
                                                  "Exiting because it's not safe to proceed with this run of the GATK.",
                                                  file.getAbsolutePath()));
        }
    }
View Full Code Here

        }
        catch ( ClosedChannelException e ) {
            // if the channel was already closed we don't have to worry
        }
        catch ( IOException e ) {
            throw new UserException(String.format("An error occurred while releasing the lock for file %s", file.getAbsolutePath()), e);
        }
    }
View Full Code Here

        try {
            if ( channel != null )
                channel.close();
        }
        catch ( IOException e ) {
            throw new UserException(String.format("An error occurred while closing channel for file %s", file.getAbsolutePath()), e);
        }
    }
View Full Code Here

        // This will ensure that if the two sets of contigs don't quite match (b36 male vs female ref, hg19 Epstein-Barr), then
        // we'll be using the correct contig index for the BAMs.
        // TODO: Warning: assumes all BAMs use the same sequence dictionary!  Get around this with contig aliasing.
        SAMSequenceRecord currentContigSequenceRecord = dataSource.getHeader().getSequence(currentLocus.getContig());
        if ( currentContigSequenceRecord == null ) {
            throw new UserException(String.format("Contig %s not present in sequence dictionary for merged BAM header: %s",
                                                  currentLocus.getContig(),
                                                  ReadUtils.prettyPrintSequenceRecords(dataSource.getHeader().getSequenceDictionary())));
        }

        final int currentContigIndex = currentContigSequenceRecord.getSequenceIndex();
View Full Code Here

        logger.debug("Attempting to load " + inputFile + " as a tabix indexed file without validating it");
        try {
            // getFeatureReader will detect that it's Tabix
            return new Pair<>(AbstractFeatureReader.getFeatureReader(inputFile.getAbsolutePath(), createCodec(descriptor, name, inputFile)), null);
        } catch (TribbleException e) {
            throw new UserException(e.getMessage(), e);
        }
    }
View Full Code Here

                }

                featureSource = AbstractFeatureReader.getFeatureReader(inputFile.getAbsolutePath(), createCodec(descriptor, name, inputFile), index);
            }
            catch (TribbleException e) {
                throw new UserException(e.getMessage());
            }
            catch (IOException e) {
                throw new UserException("I/O error loading or writing tribble index file for " + inputFile.getAbsolutePath(), e);
            }
        }
        else {
            featureSource = AbstractFeatureReader.getFeatureReader(inputFile.getAbsolutePath(), createCodec(descriptor, name, inputFile), false);
        }
View Full Code Here

        reader.setValidationStringency(ValidationStringency.SILENT);

        Pattern regionPattern = Pattern.compile("(\\d+):(\\d+)-(\\d+):(\\d+)");
        Matcher matcher = regionPattern.matcher(region);
        if(!matcher.matches())
            throw new UserException("BAM region to process must be in chunk format (mmmm:nn-xxxx:yy)");

        long firstBlock = Long.parseLong(matcher.group(1));
        int firstOffset = Integer.parseInt(matcher.group(2));
        long lastBlock = Long.parseLong(matcher.group(3));
        int lastOffset = Integer.parseInt(matcher.group(4));

        if(firstBlock < MIN_BLOCK_SIZE || firstBlock > MAX_BLOCK_SIZE)
            throw new UserException(String.format("First block is invalid; must be between %d and %d; actually is %d",MIN_BLOCK_SIZE,MAX_BLOCK_SIZE,firstBlock));
        if(lastBlock < MIN_BLOCK_SIZE || lastBlock > MAX_BLOCK_SIZE)
            throw new UserException(String.format("Last block is invalid; must be between %d and %d; actually is %d",MIN_BLOCK_SIZE,MAX_BLOCK_SIZE,lastBlock));
        if(firstOffset < MIN_OFFSET_SIZE || firstOffset > MAX_OFFSET_SIZE)
            throw new UserException(String.format("First offset is invalid; must be between %d and %d; actually is %d",MIN_OFFSET_SIZE,MAX_OFFSET_SIZE,firstOffset));
        if(lastOffset < MIN_OFFSET_SIZE || lastOffset > MAX_OFFSET_SIZE)
            throw new UserException(String.format("Last offset is invalid; must be between %d and %d; actually is %d",MIN_OFFSET_SIZE,MAX_OFFSET_SIZE,lastOffset));

        GATKChunk chunk = new GATKChunk(firstBlock<<16 | firstOffset,lastBlock<<16 | lastOffset);
        GATKBAMFileSpan fileSpan = new GATKBAMFileSpan(chunk);

        SAMRecordIterator iterator = reader.iterator(fileSpan);
View Full Code Here

             GenomeLoc currentContig = parser.createOverEntireContig(curr_contig);
             GenomeLoc thatContig = r.getLocation();

             if ( currentContig.isPast(thatContig) )
                 throw new UserException("LocationAwareSeekableRODIterator: contig " +r.getLocation().getContig() +
                         " occurs out of order in track " + r.getName() );
             if ( currentContig.isBefore(thatContig) ) break; // next record is on a higher contig, we do not need it yet...

             if ( r.getLocation().getStart() < curr_position )
                 throw new UserException("LocationAwareSeekableRODIterator: track "+r.getName() +
                         " is out of coordinate order on contig "+r.getLocation() + " compared to " + curr_contig + ":" + curr_position);

             if ( r.getLocation().getStart() > curr_position ) break; // next record starts after the current position; we do not need it yet

             r = it.next(); // we got here only if we do need next record, time to load it for real
View Full Code Here

TOP

Related Classes of org.broadinstitute.gatk.utils.exceptions.UserException$MalformedFile

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.