使用 Sam-tools Java API 如何获得 seq。在开始和结束之间,我正在编写以下方法,它会抛出 Exception 。此方法写入以从文件中获取序列。
方法在这里
private static List<SAMRecord> scan(String chromosome, int start, int end) throws IOException {
List<SAMRecord> records = new ArrayList<SAMRecord>();
CloseableIterator<SAMRecord> iter = null;
try {
iter = inputSam.query(chromosome, start, (start+70), containsbamRecord);
System.out.println("herer : Floe");
SAMRecord s=iter.next();
System.out.println("Value Of Start : "+start+"\t"+"VAlue of End : "+(start+70)+"Value Of iter : "+s.getSAMString());
while (iter.hasNext()) {
SAMRecord rec = iter.next();
//System.out.println("Value Of Start : "+start+"\t"+"VAlue of End : "+end+"Value Of iter : "+rec.get);
records.add(rec);
}
return records;
} catch (Exception e) {
throw new IOException(e);
} finally {
if (iter != null)
iter.close();
}
}
这是发生堆栈跟踪异常
java.io.IOException: java.nio.BufferUnderflowException
at WrapperMain.scan(WrapperMain.java:99)
at WrapperMain.getDataforPosition(WrapperMain.java:119)
at TzurLookupVariant.main(TzurLookupVariant.java:145)
Caused by: java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Buffer.java:506)
at java.nio.DirectByteBuffer.getInt(DirectByteBuffer.java:677)
at net.sf.samtools.AbstractBAMFileIndex$MemoryMappedFileBuffer.readInteger(AbstractBAMFileIndex.java:455)
at net.sf.samtools.AbstractBAMFileIndex.readInteger(AbstractBAMFileIndex.java:406)
at net.sf.samtools.AbstractBAMFileIndex.query(AbstractBAMFileIndex.java:266)
at net.sf.samtools.DiskBasedBAMFileIndex.getSpanOverlapping(DiskBasedBAMFileIndex.java:60)
at net.sf.samtools.BAMFileReader.createIndexIterator(BAMFileReader.java:719)
at net.sf.samtools.BAMFileReader.query(BAMFileReader.java:369)
at net.sf.samtools.SAMFileReader.query(SAMFileReader.java:381)
at WrapperMain.scan(WrapperMain.java:86)
... 2 more
java.lang.NullPointerException
at WrapperMain.getDataPoint(WrapperMain.java:199)
at WrapperMain.getDataforPosition(WrapperMain.java:129)
at TzurLookupVariant.main(TzurLookupVariant.java:145)