final int end = bedFeature.getEnd();
// NB: do not use an empty name within an interval
String name = bedFeature.getName();
if (name.isEmpty()) name = null;
final SAMSequenceRecord sequenceRecord = header.getSequenceDictionary().getSequence(sequenceName);
// Do some validation
if (null == sequenceRecord) {
throw new PicardException(String.format("Sequence '%s' was not found in the sequence dictionary", sequenceName));
}
else if (start < 1) {
throw new PicardException(String.format("Start on sequence '%s' was less than one: %d", sequenceName, start));
}
else if (sequenceRecord.getSequenceLength() < start) {
throw new PicardException(String.format("Start on sequence '%s' was past the end: %d < %d", sequenceName, sequenceRecord.getSequenceLength(), start));
}
else if (end < 1) {
throw new PicardException(String.format("End on sequence '%s' was less than one: %d", sequenceName, end));
}
else if (sequenceRecord.getSequenceLength() < end) {
throw new PicardException(String.format("End on sequence '%s' was past the end: %d < %d", sequenceName, sequenceRecord.getSequenceLength(), end));
}
else if (end < start - 1) {
throw new PicardException(String.format("On sequence '%s', end < start-1: %d <= %d", sequenceName, end, start));
}