Java : 什么是 BufferUnderflow Exceptio 使用 Samtools Java API 获取具有特定位置的外来字符串
Java : What is BufferUnderflow Exceptio While using Samtools Java API to get the alienment String with Spcific postion
using Sam-tools Java API how i get seq. between start and end i am write following method it throws Exception . this method write to get Sequences from file .
方法在这里
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();
}
}
This is Stack Trace Exception Occurred
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)
BufferUnderflowException 的 javadoc 说:
"Unchecked exception thrown when a relative get operation reaches the source buffer's limit."
所以一般的解决方案是避免在没有更多数据的缓冲区上调用 get
。
在没有看到您代码的相关部分之前,我们不能比这更具体了。
你说:
... algorithm is correct ...
这可能不是真的,至少在某种程度上是这样。
... when i create new class and make some modification it fire me the exception and now i delete created class but still it throws same Exception ....Why ????
很可能是>>某事<<发生了变化。但也有可能您的问题的根本原因是从那里开始,并且您的应用程序的工作方式存在不确定性。
using Sam-tools Java API how i get seq. between start and end i am write following method it throws Exception . this method write to get Sequences from file .
方法在这里
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();
}
}
This is Stack Trace Exception Occurred
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)
BufferUnderflowException 的 javadoc 说:
"Unchecked exception thrown when a relative get operation reaches the source buffer's limit."
所以一般的解决方案是避免在没有更多数据的缓冲区上调用 get
。
在没有看到您代码的相关部分之前,我们不能比这更具体了。
你说:
... algorithm is correct ...
这可能不是真的,至少在某种程度上是这样。
... when i create new class and make some modification it fire me the exception and now i delete created class but still it throws same Exception ....Why ????
很可能是>>某事<<发生了变化。但也有可能您的问题的根本原因是从那里开始,并且您的应用程序的工作方式存在不确定性。