Search in sources :

Example 1 with BedLineCodec

use of utils.BedLineCodec in project ASCIIGenome by dariober.

the class MakeTabixIndex method addLineToIndex.

/**
 * Set vcfHeader and vcfCodec to null if reading non-vcf line.
 */
private void addLineToIndex(String line, TabixIndexCreator indexCreator, long filePosition, TabixFormat fmt, VCFHeader vcfHeader, VCFCodec vcfCodec) throws InvalidRecordException {
    if (fmt.equals(TabixFormat.BED)) {
        BedLineCodec bedCodec = new BedLineCodec();
        BedLine bed = bedCodec.decode(line);
        indexCreator.addFeature(bed, filePosition);
    } else if (fmt.equals(TabixFormat.GFF)) {
        GtfLine gtf = new GtfLine(line.split("\t"));
        indexCreator.addFeature(gtf, filePosition);
    } else if (fmt.equals(TabixFormat.VCF)) {
        VariantContext vcf = vcfCodec.decode(line);
        indexCreator.addFeature(vcf, filePosition);
    } else {
        System.err.println("Unexpected TabixFormat: " + fmt.sequenceColumn + " " + fmt.startPositionColumn);
        throw new InvalidRecordException();
    }
}
Also used : GtfLine(utils.GtfLine) VariantContext(htsjdk.variant.variantcontext.VariantContext) InvalidRecordException(exceptions.InvalidRecordException) BedLineCodec(utils.BedLineCodec) BedLine(utils.BedLine)

Aggregations

InvalidRecordException (exceptions.InvalidRecordException)1 VariantContext (htsjdk.variant.variantcontext.VariantContext)1 BedLine (utils.BedLine)1 BedLineCodec (utils.BedLineCodec)1 GtfLine (utils.GtfLine)1