This is a test version of Biostars. For the public version, visit https://www.biostars.org.
using SAMTOOLs API I am trying to get BAM ...follwing Excption occur..How to Handle it Any suggestion...

I am writing the following method to get Seq, but it throws an exception. I need help.

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.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:85)
    at WrapperMain.getDataforPosition(WrapperMain.java:119)
htsjdk sequence java alignment

Give us the full stack trace and the line numbers.

0 answers

No answers yet.

Log in to answer this question.