Examples of SAMFormatException


Examples of net.sf.samtools.SAMFormatException

            if (byteBuffer.get() != BlockCompressedStreamConstants.GZIP_ID1 ||
                    byteBuffer.get() != (byte)BlockCompressedStreamConstants.GZIP_ID2 ||
                    byteBuffer.get() != BlockCompressedStreamConstants.GZIP_CM_DEFLATE ||
                    byteBuffer.get() != BlockCompressedStreamConstants.GZIP_FLG
                    ) {
                throw new SAMFormatException("Invalid GZIP header");
            }
            // Skip MTIME, XFL, OS fields
            byteBuffer.position(byteBuffer.position() + 6);
            if (byteBuffer.getShort() != BlockCompressedStreamConstants.GZIP_XLEN) {
                throw new SAMFormatException("Invalid GZIP header");
            }
            // Skip blocksize subfield intro
            byteBuffer.position(byteBuffer.position() + 4);
            // Read ushort
            final int totalBlockSize = (byteBuffer.getShort() & 0xffff) + 1;
            if (totalBlockSize != compressedLength) {
                throw new SAMFormatException("GZIP blocksize disagreement");
            }

            // Read expected size and CRD from end of GZIP block
            final int deflatedSize = compressedLength - BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH - BlockCompressedStreamConstants.BLOCK_FOOTER_LENGTH;
            byteBuffer.position(byteBuffer.position() + deflatedSize);
            int expectedCrc = byteBuffer.getInt();
            int uncompressedSize = byteBuffer.getInt();
            inflater.reset();

            // Decompress
            inflater.setInput(compressedBlock, BlockCompressedStreamConstants.BLOCK_HEADER_LENGTH, deflatedSize);
            final int inflatedBytes = inflater.inflate(uncompressedBlock, 0, uncompressedSize);
            if (inflatedBytes != uncompressedSize) {
                throw new SAMFormatException("Did not inflate expected amount");
            }

            // Validate CRC
            crc32.reset();
            crc32.update(uncompressedBlock, 0, uncompressedSize);
            final long crc = crc32.getValue();
            if ((int)crc != expectedCrc) {
                throw new SAMFormatException("CRC mismatch");
            }
        } catch (DataFormatException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of net.sf.samtools.SAMFormatException

      break;
    case 'B':
      writeArray(value, isUnsignedArray, buf);
      break;
    default:
      throw new SAMFormatException("Unrecognized tag type: "
          + (char) tagType);
    }

    buf.flip();
    byte[] bytes = new byte[buf.limit()];
View Full Code Here

Examples of net.sf.samtools.SAMFormatException

    case 'B':
      final TagValueAndUnsignedArrayFlag valueAndFlag = readArray(
          byteBuffer, validationStringency);
      return valueAndFlag.value ;
    default:
      throw new SAMFormatException("Unrecognized tag type: "
          + (char) tagType);
    }
  }
View Full Code Here

Examples of net.sf.samtools.SAMFormatException

      }
      break;
    }

    default:
      throw new SAMFormatException("Unrecognized tag array type: "
          + (char) arrayType);
    }
    return new TagValueAndUnsignedArrayFlag(value, isUnsigned);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.