Entering edit mode
2.4 years ago
matejm469
•
0
I'm working on a program and I want it to have an option to generate an index file from inputted sorted BAM file. My code looks like this:
File chosenFile = fileChooser.getSelectedFile();
File output;
String path = chosenFile.getPath();
int lastSlash = path.lastIndexOf("/");
String baseFileName = path.substring(lastSlash + 1, path.length());
if (baseFileName.endsWith(BamFileIoUtils.BAM_FILE_EXTENSION)) {
final int index = baseFileName.lastIndexOf(".");
output = new File(baseFileName.substring(0, index) + BAMIndex.BAMIndexSuffix);
} else {
output = new File(baseFileName + BAMIndex.BAMIndexSuffix);
}
IOUtil.assertFileIsWritable(output);
final SamReader bam;
IOUtil.assertFileIsReadable(chosenFile);
bam = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).open(chosenFile);
SAMFileSource source = bam.getfi
if (!bam.getFileHeader().getSortOrder().equals(SAMFileHeader.SortOrder.coordinate)) {
throw new SAMException("Input bam file must be sorted by coordinates.");
}
BAMIndexer.createIndex(bam, output);
CloserUtil.close(bam);
The BAM files that I'm using are 100% sorted so that's not the issue. Anyone got any idea why am I getting this error and maybe how to fix it?
cross posted: https://stackoverflow.com/questions/72683380/
what is the outout of