jpayne@68: from cpython cimport bool jpayne@68: from libcpp.vector cimport vector jpayne@68: from libcpp.string cimport string jpayne@68: from cython.operator cimport dereference as deref jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: jpayne@68: """ jpayne@68: Create Cython definitions for the Interval API defined in Interval.h jpayne@68: """ jpayne@68: cdef extern from "bedFile.h": jpayne@68: cdef enum BedLineStatus: jpayne@68: BED_MALFORMED = -2 jpayne@68: BED_INVALID = -1 jpayne@68: BED_HEADER = 0 jpayne@68: BED_BLANK = 1 jpayne@68: BED_VALID = 2 jpayne@68: jpayne@68: ctypedef unsigned int CHRPOS jpayne@68: ctypedef bint BOOL jpayne@68: jpayne@68: cdef cppclass BED: jpayne@68: string chrom jpayne@68: CHRPOS start jpayne@68: CHRPOS end jpayne@68: string name jpayne@68: string score jpayne@68: string strand jpayne@68: CHRPOS o_start # the start of an overlap with another interval jpayne@68: CHRPOS o_end # the end of an overlap with another interval jpayne@68: unsigned short bedType jpayne@68: string file_type jpayne@68: BedLineStatus status jpayne@68: vector[string] fields jpayne@68: jpayne@68: # constructors jpayne@68: BED() jpayne@68: BED(string chrom, CHRPOS start, CHRPOS end, string name, jpayne@68: string score, string strand, vector[string] fields, jpayne@68: CHRPOS o_start, CHRPOS o_end, jpayne@68: unsigned short bedType, string file_type, BedLineStatus status) jpayne@68: jpayne@68: BED(string chrom, CHRPOS start, CHRPOS end) jpayne@68: BED(string chrom, CHRPOS start, CHRPOS end, string strand) jpayne@68: BED(string chrom, CHRPOS start, CHRPOS end, string name, jpayne@68: string score, string strand, vector[string] fields) jpayne@68: jpayne@68: # methods jpayne@68: string reportBed() jpayne@68: jpayne@68: jpayne@68: cdef cppclass BedFile: jpayne@68: BedFile(string) jpayne@68: int Open() jpayne@68: void Rewind() jpayne@68: void Seek(unsigned long offset) jpayne@68: void Close() jpayne@68: BED GetNextBed() jpayne@68: void loadBedFileIntoMap() jpayne@68: jpayne@68: ### "all" ### jpayne@68: # this version doesn't care if the strands match. jpayne@68: vector[BED] FindOverlapsPerBin(BED bed, float overlapFraction) jpayne@68: # if forceStrand is true, require that the strands match, jpayne@68: vector[BED] FindOverlapsPerBin(BED bed, bool forceStrand, float overlapFraction) jpayne@68: jpayne@68: ### "any" ### jpayne@68: int FindAnyOverlapsPerBin(BED bed, float overlapFraction) jpayne@68: # if forceStrand is true, require that the strands match, jpayne@68: int FindAnyOverlapsPerBin(BED bed, bool forceStrand, float overlapFraction) jpayne@68: jpayne@68: jpayne@68: ### "count" ### jpayne@68: int CountOverlapsPerBin(BED bed, float overlapFraction) jpayne@68: # if forceStrand is true, require that the strands match, jpayne@68: int CountOverlapsPerBin(BED bed, bool forceStrand, float overlapFraction) jpayne@68: string file_type jpayne@68: bint _typeIsKnown jpayne@68: jpayne@68: jpayne@68: cdef class Interval: jpayne@68: cdef BED *_bed jpayne@68: cdef object _attrs jpayne@68: cpdef append(Interval self, object value) jpayne@68: cpdef deparse_attrs(Interval self)