I want to develop RESTful web service which will provide bam reads in JSON format. I used SamFileReader (htsjdk.samtools.SAMFileReader) for reading bam file and then using SAMRecordIterator to get SAMRecord. But when I try to convert it into String/ JSON it throws following error :
Method not implemented for: class htsjdk.samtools.SAMSequenceRecord (through reference chain: htsjdk.samtools.BAMRecord["header"]->htsjdk.samtools.SAMFileHeader["sequenceDictionary"]->htsjdk.samtools.SAMSequenceDictionary["sequences"]->java.util.UnmodifiableRandomAccessList[0]->htsjdk.samtools.SAMSequenceRecord["id"])
I tried following ways to create JSON for SamRecord :
- Used com.fasterxml.jackson.databind.ObjectMapper and ObjectWriter with "writeValueAsString()" API.
- Used directly Response Body annotation for request URL method.
- Tried to use JSONSerializer from "net.sf.json" and same error occured.
Is there any other way to convert SamRecord to JSON/String ?
Thank you Pierre Lindenbaum :)