cljam.io.bed

Functions to read and write the BED (Browser Extensible Data) format. See
http://genome.ucsc.edu/FAQ/FAQformat#format1 for the detail BED specifications.

bed-columns

complement-fields

(complement-fields refs xs)
Takes a sequence of maps containing :name and :len keys (representing
chromosome's name and length, resp.) and a sequence of BED fields,
and returns a lazy sequence that is the complement of the BED sequence.

The input sequence will first be sorted with sort-fields, which may cause
an extensive memory use for ones with a large number of elements.
Note also that this function assumes the BED sequence contains only valid
regions, and thus :start <= :end holds for each region. Make sure yourself
the BED sequence meets the condition, or the function may return a wrong
result.

intersect-fields

(intersect-fields xs ys)
Returns a lazy sequence that is the intersection of the two BED sequences.

The input sequences will first be sorted with sort-fields, which may cause
an extensive memory use for ones with a large number of elements.
Note also that this function assumes the input sequences contain only valid
regions, and thus :start <= :end holds for each region. Make sure yourself
the input sequences meet the condition, or the function may return a wrong
result.

merge-fields

(merge-fields xs)
Sort and merge overlapped regions.
Currently, this function affects only :end and :name fields.

read-fields

(read-fields rdr)
Returns a lazy sequence of normalized BED fields.

reader

(reader f)
Returns an open cljam.io.bed.BEDReader of f. Should be used inside with-open
to ensure the reader is properly closed.

sort-fields

(sort-fields xs)
Sort BED fields based on :chr, :start and :end.
:chr with common names come first, in order of (chr1, chr2, ..., chrX, chrY, chrM).
Other chromosomes follow after in lexicographic order.

subtract-fields

(subtract-fields xs ys)
Returns a lazy sequence that is the result of subtracting the BED fields
in the sequence ys from the sequence xs.

The input sequences will first be sorted with sort-fields, which may cause
an extensive memory use for ones with a large number of elements.
Note also that this function assumes the input sequences contain only valid
regions, and thus :start <= :end holds for each region. Make sure yourself
the input sequences meet the condition, or the function may return a wrong
result.

write-fields

(write-fields wtr xs)
Write sequence of BED fields to writer.

writer

(writer f)
Returns an open cljam.io.bed.BEDWriter of f. Should be used inside with-open
to ensure the writer is properly closed.