示例#1
0
 /** generates the index file using the latest java index generating code */
 private File createIndexFile(File bamFile) throws IOException {
   final File bamIndexFile = File.createTempFile("Bai.", ".bai");
   final SAMFileReader bam = new SAMFileReader(bamFile);
   BuildBamIndex.createIndex(bam, bamIndexFile);
   verbose("Wrote BAM Index file " + bamIndexFile);
   return bamIndexFile;
 }
示例#2
0
  @Test(enabled = true)
  public void testWriteBinary() throws Exception {
    // Compare java-generated bai file with c-generated and sorted bai file
    final File javaBaiFile = File.createTempFile("javaBai.", ".bai");
    final SAMFileReader bam = new SAMFileReader(BAM_FILE);
    BuildBamIndex.createIndex(bam, javaBaiFile);
    verbose("Wrote binary java BAM Index file " + javaBaiFile);

    final File cRegeneratedBaiFile = File.createTempFile("cBai.", ".bai");
    BAMIndexer.createAndWriteIndex(BAI_FILE, cRegeneratedBaiFile, false);
    verbose("Wrote sorted C binary BAM Index file " + cRegeneratedBaiFile);

    // Binary compare of javaBaiFile and cRegeneratedBaiFile should be the same
    verbose("diff " + javaBaiFile + " " + cRegeneratedBaiFile);
    IoUtil.assertFilesEqual(javaBaiFile, cRegeneratedBaiFile);
    javaBaiFile.deleteOnExit();
    cRegeneratedBaiFile.deleteOnExit();
  }
示例#3
0
  @Test(enabled = true)
  public void testWriteText() throws Exception {
    // Compare the text form of the c-generated bai file and a java-generated one
    final File cBaiTxtFile = File.createTempFile("cBai.", ".bai.txt");
    BAMIndexer.createAndWriteIndex(BAI_FILE, cBaiTxtFile, true);
    verbose("Wrote textual C BAM Index file " + cBaiTxtFile);

    final File javaBaiFile = File.createTempFile("javaBai.", "java.bai");
    final File javaBaiTxtFile = new File(javaBaiFile.getAbsolutePath() + ".txt");
    final SAMFileReader bam = new SAMFileReader(BAM_FILE);
    BuildBamIndex.createIndex(bam, javaBaiFile);
    verbose("Wrote binary Java BAM Index file " + javaBaiFile);

    // now, turn the bai file into text
    BAMIndexer.createAndWriteIndex(javaBaiFile, javaBaiTxtFile, true);
    // and compare them
    verbose("diff " + javaBaiTxtFile + " " + cBaiTxtFile);
    IoUtil.assertFilesEqual(javaBaiTxtFile, cBaiTxtFile);
    cBaiTxtFile.deleteOnExit();
    javaBaiFile.deleteOnExit();
    javaBaiTxtFile.deleteOnExit();
  }