private static int parseIntOrThrowFormatException(final String str, final String error, final String input) { try { return Integer.parseInt(str); } catch (final NumberFormatException ex) { throw new FormatException(error + " in interval '" + input + "': '" + str + "'"); } } }
/** * Reads the next key/value pair from the input for processing. */ public boolean next(Text key, SequencedFragment value) throws IOException { if (pos >= end) return false; // past end of slice int bytesRead = 0; boolean goodRecord; do { bytesRead = lowLevelQseqRead(key, value); // if bytesRead <= 0 EOF has been reached goodRecord = (bytesRead > 0) && (!filterFailedQC || value.getFilterPassed() == null || value.getFilterPassed()); } while (bytesRead > 0 && !goodRecord); if (goodRecord) // post process the record only if it's going to be used { try { postProcessSequencedFragment(value); } catch (FormatException e) { throw new FormatException(e.getMessage() + " Position: " + makePositionMessage(this.pos - bytesRead) + "; line: " + buffer); // last line read is still in the buffer } } return goodRecord; }
/** * Reads the next key/value pair from the input for processing. */ public boolean next(Text key, SequencedFragment value) throws IOException { if (pos >= end) return false; // past end of slice int bytesRead = 0; boolean goodRecord; do { bytesRead = lowLevelQseqRead(key, value); // if bytesRead <= 0 EOF has been reached goodRecord = (bytesRead > 0) && (!filterFailedQC || value.getFilterPassed() == null || value.getFilterPassed()); } while (bytesRead > 0 && !goodRecord); if (goodRecord) // post process the record only if it's going to be used { try { postProcessSequencedFragment(value); } catch (FormatException e) { throw new FormatException(e.getMessage() + " Position: " + makePositionMessage(this.pos - bytesRead) + "; line: " + buffer); // last line read is still in the buffer } } return goodRecord; }
/** * Reads the next key/value pair from the input for processing. */ public boolean next(Text key, SequencedFragment value) throws IOException { if (pos >= end) return false; // past end of slice int bytesRead = 0; boolean goodRecord; do { bytesRead = lowLevelQseqRead(key, value); // if bytesRead <= 0 EOF has been reached goodRecord = (bytesRead > 0) && (!filterFailedQC || value.getFilterPassed() == null || value.getFilterPassed()); } while (bytesRead > 0 && !goodRecord); if (goodRecord) // post process the record only if it's going to be used { try { postProcessSequencedFragment(value); } catch (FormatException e) { throw new FormatException(e.getMessage() + " Position: " + makePositionMessage(this.pos - bytesRead) + "; line: " + buffer); // last line read is still in the buffer } } return goodRecord; }
private static int parseIntOrThrowFormatException(final String str, final String error, final String input) { try { return Integer.parseInt(str); } catch (final NumberFormatException ex) { throw new FormatException(error + " in interval '" + input + "': '" + str + "'"); } } }
BaseQualityEncoding.Illumina, BaseQualityEncoding.Sanger); } catch (FormatException e) { throw new FormatException(e.getMessage() + " Position: " + makePositionMessage() + "; Sequence ID: " + key); BaseQualityEncoding.Sanger); if (outOfRangeElement >= 0) { throw new FormatException("Base quality out of range for Sanger Phred+33 format (found " + (value.getQuality().getBytes()[outOfRangeElement] - FormatConstants.SANGER_OFFSET) + ").\n"
throw new FormatException( "base quality score out of range for Illumina Phred+64 format (found " + (bytes[i] - FormatConstants.ILLUMINA_OFFSET) + " but acceptable range is [0," + FormatConstants.ILLUMINA_MAX + "]).\n" + throw new FormatException( "base quality score out of range for Sanger Phred+64 format (found " + (bytes[i] - FormatConstants.SANGER_OFFSET) + " but acceptable range is [0," + FormatConstants.SANGER_MAX + "]).\n" +
throw new FormatException(e.getMessage() + " Position: " + makePositionMessage() + "; Sequence ID: " + key); if (outOfRangeElement >= 0) throw new FormatException("fastq base quality score out of range for Sanger Phred+33 format (found " + (value.getQuality().getBytes()[outOfRangeElement] - FormatConstants.SANGER_OFFSET) + ").\n" + "Although Sanger format has been requested, maybe qualities are in Illumina Phred+64 format?\n" +
throw new FormatException( "base quality score out of range for Illumina Phred+64 format (found " + (bytes[i] - FormatConstants.ILLUMINA_OFFSET) + " but acceptable range is [0," + FormatConstants.ILLUMINA_MAX + "]).\n" + throw new FormatException( "base quality score out of range for Sanger Phred+64 format (found " + (bytes[i] - FormatConstants.SANGER_OFFSET) + " but acceptable range is [0," + FormatConstants.SANGER_MAX + "]).\n" +
throw new FormatException(e.getMessage() + " Position: " + makePositionMessage() + "; Sequence ID: " + key); if (outOfRangeElement >= 0) throw new FormatException("fastq base quality score out of range for Sanger Phred+33 format (found " + (value.getQuality().getBytes()[outOfRangeElement] - FormatConstants.SANGER_OFFSET) + ").\n" + "Although Sanger format has been requested, maybe qualities are in Illumina Phred+64 format?\n" +
throw new FormatException( "base quality score out of range for Illumina Phred+64 format (found " + (bytes[i] - FormatConstants.ILLUMINA_OFFSET) + " but acceptable range is [0," + FormatConstants.ILLUMINA_MAX + "]).\n" + throw new FormatException( "base quality score out of range for Sanger Phred+64 format (found " + (bytes[i] - FormatConstants.SANGER_OFFSET) + " but acceptable range is [0," + FormatConstants.SANGER_MAX + "]).\n" +
throw new FormatException(e.getMessage() + " Position: " + makePositionMessage() + "; Sequence ID: " + key); if (outOfRangeElement >= 0) throw new FormatException("fastq base quality score out of range for Sanger Phred+33 format (found " + (value.getQuality().getBytes()[outOfRangeElement] - FormatConstants.SANGER_OFFSET) + ").\n" + "Although Sanger format has been requested, maybe qualities are in Illumina Phred+64 format?\n" +
private void setFieldPositionsAndLengths(Text line) { int pos = 0; // the byte position within the record int fieldno = 0; // the field index within the record while (pos < line.getLength() && fieldno < NUM_QSEQ_COLS) // iterate over each field { int endpos = line.find(Delim, pos); // the field's end position if (endpos < 0) endpos = line.getLength(); fieldPositions[fieldno] = pos; fieldLengths[fieldno] = endpos - pos; pos = endpos + 1; // the next starting position is the current end + 1 fieldno += 1; } if (fieldno != NUM_QSEQ_COLS) throw new FormatException("found " + fieldno + " fields instead of 11 at " + makePositionMessage(this.pos - line.getLength()) + ". Line: " + line); }
private void setFieldPositionsAndLengths(Text line) { int pos = 0; // the byte position within the record int fieldno = 0; // the field index within the record while (pos < line.getLength() && fieldno < NUM_QSEQ_COLS) // iterate over each field { int endpos = line.find(Delim, pos); // the field's end position if (endpos < 0) endpos = line.getLength(); fieldPositions[fieldno] = pos; fieldLengths[fieldno] = endpos - pos; pos = endpos + 1; // the next starting position is the current end + 1 fieldno += 1; } if (fieldno != NUM_QSEQ_COLS) throw new FormatException("found " + fieldno + " fields instead of 11 at " + makePositionMessage(this.pos - line.getLength()) + ". Line: " + line); }
private void setFieldPositionsAndLengths(Text line) { int pos = 0; // the byte position within the record int fieldno = 0; // the field index within the record while (pos < line.getLength() && fieldno < NUM_QSEQ_COLS) // iterate over each field { int endpos = line.find(Delim, pos); // the field's end position if (endpos < 0) endpos = line.getLength(); fieldPositions[fieldno] = pos; fieldLengths[fieldno] = endpos - pos; pos = endpos + 1; // the next starting position is the current end + 1 fieldno += 1; } if (fieldno != NUM_QSEQ_COLS) throw new FormatException("found " + fieldno + " fields instead of 11 at " + makePositionMessage(this.pos - line.getLength()) + ". Line: " + line); }
final int lastColonIdx = s.lastIndexOf(':'); if (lastColonIdx < 0) { throw new FormatException("no colon found in interval string: " + s); throw new FormatException("no hyphen found after colon interval string: " + s);
final int lastColonIdx = s.lastIndexOf(':'); if (lastColonIdx < 0) { throw new FormatException("no colon found in interval string: " + s); throw new FormatException("no hyphen found after colon interval string: " + s);
private void postProcessSequencedFragment(SequencedFragment fragment) { byte[] bytes = fragment.getSequence().getBytes(); // replace . with N for (int i = 0; i < fieldLengths[8]; ++i) if (bytes[i] == '.') bytes[i] = 'N'; if (qualityEncoding == BaseQualityEncoding.Illumina) { // convert illumina to sanger scale SequencedFragment.convertQuality(fragment.getQuality(), BaseQualityEncoding.Illumina, BaseQualityEncoding.Sanger); } else // sanger qualities. { int outOfRangeElement = SequencedFragment.verifyQuality(fragment.getQuality(), BaseQualityEncoding.Sanger); if (outOfRangeElement >= 0) { throw new FormatException("qseq base quality score out of range for Sanger Phred+33 format (found " + (fragment.getQuality().getBytes()[outOfRangeElement] - FormatConstants.SANGER_OFFSET) + ").\n" + "Although Sanger format has been requested, maybe qualities are in Illumina Phred+64 format?\n"); } } } }
private void postProcessSequencedFragment(SequencedFragment fragment) { byte[] bytes = fragment.getSequence().getBytes(); // replace . with N for (int i = 0; i < fieldLengths[8]; ++i) if (bytes[i] == '.') bytes[i] = 'N'; if (qualityEncoding == BaseQualityEncoding.Illumina) { // convert illumina to sanger scale SequencedFragment.convertQuality(fragment.getQuality(), BaseQualityEncoding.Illumina, BaseQualityEncoding.Sanger); } else // sanger qualities. { int outOfRangeElement = SequencedFragment.verifyQuality(fragment.getQuality(), BaseQualityEncoding.Sanger); if (outOfRangeElement >= 0) { throw new FormatException("qseq base quality score out of range for Sanger Phred+33 format (found " + (fragment.getQuality().getBytes()[outOfRangeElement] - FormatConstants.SANGER_OFFSET) + ").\n" + "Although Sanger format has been requested, maybe qualities are in Illumina Phred+64 format?\n"); } } } }
private void postProcessSequencedFragment(SequencedFragment fragment) { byte[] bytes = fragment.getSequence().getBytes(); // replace . with N for (int i = 0; i < fieldLengths[8]; ++i) if (bytes[i] == '.') bytes[i] = 'N'; if (qualityEncoding == BaseQualityEncoding.Illumina) { // convert illumina to sanger scale SequencedFragment.convertQuality(fragment.getQuality(), BaseQualityEncoding.Illumina, BaseQualityEncoding.Sanger); } else // sanger qualities. { int outOfRangeElement = SequencedFragment.verifyQuality(fragment.getQuality(), BaseQualityEncoding.Sanger); if (outOfRangeElement >= 0) { throw new FormatException("qseq base quality score out of range for Sanger Phred+33 format (found " + (fragment.getQuality().getBytes()[outOfRangeElement] - FormatConstants.SANGER_OFFSET) + ").\n" + "Although Sanger format has been requested, maybe qualities are in Illumina Phred+64 format?\n"); } } } }