}
if (filePointers == null || filePointers.length == 0)
return emptyIterator;
SeekableStream s = null;
if (file != null) {
try {
s = new SeekableFileStream(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
} else if (is instanceof SeekableStream)
s = (SeekableStream) is;
SAMIterator si = null;
try {
s.seek(0);
si = new SAMIterator(s, referenceSequenceFile);
si.setValidationStringency(validationStringency);
it = si;
} catch (IOException e) {
throw new RuntimeEOFException(e);
}
Container c = null;
for (int i = 0; i < filePointers.length; i += 2) {
long containerOffset = filePointers[i] >>> 16;
int sliceIndex = (int) ((filePointers[i] << 48) >>> 48);
try {
s.seek(containerOffset);
// the following is not optimal because this is container-level
// access, not slice:
// CountingInputStream cis = new CountingInputStream(s) ;
c = ReadWrite.readContainerHeader(s);
// long headerSize = cis.getCount() ;
// int sliceOffset = c.landmarks[sliceIndex] ;
if (c.alignmentStart + c.alignmentSpan > start) {
s.seek(containerOffset);
// s.seek(containerOffset + headerSize + sliceOffset);
return si;
}
} catch (IOException e) {
throw new RuntimeException(e);