mirror of
https://github.com/MillironX/XAM.jl.git
synced 2024-11-23 10:19:56 +00:00
Align emission symbols for TranscodingStreams
This commit is contained in:
parent
6cd89aba08
commit
12db2c4ea8
1 changed files with 47 additions and 47 deletions
|
@ -185,79 +185,79 @@ const sam_metainfo_machine, sam_record_machine, sam_header_machine, sam_body_mac
|
||||||
|
|
||||||
metainfo = let
|
metainfo = let
|
||||||
tag = re"[A-Z][A-Z]" \ cat("CO")
|
tag = re"[A-Z][A-Z]" \ cat("CO")
|
||||||
tag.actions[:enter] = [:mark1]
|
tag.actions[:enter] = [:pos1]
|
||||||
tag.actions[:exit] = [:metainfo_tag]
|
tag.actions[:exit] = [:metainfo_tag]
|
||||||
|
|
||||||
dict = let
|
dict = let
|
||||||
key = re"[A-Za-z][A-Za-z0-9]"
|
key = re"[A-Za-z][A-Za-z0-9]"
|
||||||
key.actions[:enter] = [:mark2]
|
key.actions[:enter] = [:pos2]
|
||||||
key.actions[:exit] = [:metainfo_dict_key]
|
key.actions[:exit] = [:metainfo_dict_key]
|
||||||
val = re"[ -~]+"
|
val = re"[ -~]+"
|
||||||
val.actions[:enter] = [:mark2]
|
val.actions[:enter] = [:pos2]
|
||||||
val.actions[:exit] = [:metainfo_dict_val]
|
val.actions[:exit] = [:metainfo_dict_val]
|
||||||
keyval = cat(key, ':', val)
|
keyval = cat(key, ':', val)
|
||||||
|
|
||||||
cat(keyval, rep(cat('\t', keyval)))
|
cat(keyval, rep(cat('\t', keyval)))
|
||||||
end
|
end
|
||||||
dict.actions[:enter] = [:mark1]
|
dict.actions[:enter] = [:pos1]
|
||||||
dict.actions[:exit] = [:metainfo_val]
|
dict.actions[:exit] = [:metainfo_val]
|
||||||
|
|
||||||
co = cat("CO")
|
co = cat("CO")
|
||||||
co.actions[:enter] = [:mark1]
|
co.actions[:enter] = [:pos1]
|
||||||
co.actions[:exit] = [:metainfo_tag]
|
co.actions[:exit] = [:metainfo_tag]
|
||||||
|
|
||||||
comment = re"[^\r\n]*"
|
comment = re"[^\r\n]*"
|
||||||
comment.actions[:enter] = [:mark1]
|
comment.actions[:enter] = [:pos1]
|
||||||
comment.actions[:exit] = [:metainfo_val]
|
comment.actions[:exit] = [:metainfo_val]
|
||||||
|
|
||||||
cat('@', alt(cat(tag, '\t', dict), cat(co, '\t', comment)))
|
cat('@', alt(cat(tag, '\t', dict), cat(co, '\t', comment)))
|
||||||
end
|
end
|
||||||
metainfo.actions[:enter] = [:anchor]
|
metainfo.actions[:enter] = [:mark]
|
||||||
metainfo.actions[:exit] = [:metainfo]
|
metainfo.actions[:exit] = [:metainfo]
|
||||||
|
|
||||||
record = let
|
record = let
|
||||||
qname = re"[!-?A-~]+"
|
qname = re"[!-?A-~]+"
|
||||||
qname.actions[:enter] = [:mark]
|
qname.actions[:enter] = [:pos]
|
||||||
qname.actions[:exit] = [:record_qname]
|
qname.actions[:exit] = [:record_qname]
|
||||||
|
|
||||||
flag = re"[0-9]+"
|
flag = re"[0-9]+"
|
||||||
flag.actions[:enter] = [:mark]
|
flag.actions[:enter] = [:pos]
|
||||||
flag.actions[:exit] = [:record_flag]
|
flag.actions[:exit] = [:record_flag]
|
||||||
|
|
||||||
rname = re"\*|[!-()+-<>-~][!-~]*"
|
rname = re"\*|[!-()+-<>-~][!-~]*"
|
||||||
rname.actions[:enter] = [:mark]
|
rname.actions[:enter] = [:pos]
|
||||||
rname.actions[:exit] = [:record_rname]
|
rname.actions[:exit] = [:record_rname]
|
||||||
|
|
||||||
pos = re"[0-9]+"
|
pos = re"[0-9]+"
|
||||||
pos.actions[:enter] = [:mark]
|
pos.actions[:enter] = [:pos]
|
||||||
pos.actions[:exit] = [:record_pos]
|
pos.actions[:exit] = [:record_pos]
|
||||||
|
|
||||||
mapq = re"[0-9]+"
|
mapq = re"[0-9]+"
|
||||||
mapq.actions[:enter] = [:mark]
|
mapq.actions[:enter] = [:pos]
|
||||||
mapq.actions[:exit] = [:record_mapq]
|
mapq.actions[:exit] = [:record_mapq]
|
||||||
|
|
||||||
cigar = re"\*|([0-9]+[MIDNSHPX=])+"
|
cigar = re"\*|([0-9]+[MIDNSHPX=])+"
|
||||||
cigar.actions[:enter] = [:mark]
|
cigar.actions[:enter] = [:pos]
|
||||||
cigar.actions[:exit] = [:record_cigar]
|
cigar.actions[:exit] = [:record_cigar]
|
||||||
|
|
||||||
rnext = re"\*|=|[!-()+-<>-~][!-~]*"
|
rnext = re"\*|=|[!-()+-<>-~][!-~]*"
|
||||||
rnext.actions[:enter] = [:mark]
|
rnext.actions[:enter] = [:pos]
|
||||||
rnext.actions[:exit] = [:record_rnext]
|
rnext.actions[:exit] = [:record_rnext]
|
||||||
|
|
||||||
pnext = re"[0-9]+"
|
pnext = re"[0-9]+"
|
||||||
pnext.actions[:enter] = [:mark]
|
pnext.actions[:enter] = [:pos]
|
||||||
pnext.actions[:exit] = [:record_pnext]
|
pnext.actions[:exit] = [:record_pnext]
|
||||||
|
|
||||||
tlen = re"[-+]?[0-9]+"
|
tlen = re"[-+]?[0-9]+"
|
||||||
tlen.actions[:enter] = [:mark]
|
tlen.actions[:enter] = [:pos]
|
||||||
tlen.actions[:exit] = [:record_tlen]
|
tlen.actions[:exit] = [:record_tlen]
|
||||||
|
|
||||||
seq = re"\*|[A-Za-z=.]+"
|
seq = re"\*|[A-Za-z=.]+"
|
||||||
seq.actions[:enter] = [:mark]
|
seq.actions[:enter] = [:pos]
|
||||||
seq.actions[:exit] = [:record_seq]
|
seq.actions[:exit] = [:record_seq]
|
||||||
|
|
||||||
qual = re"[!-~]+"
|
qual = re"[!-~]+"
|
||||||
qual.actions[:enter] = [:mark]
|
qual.actions[:enter] = [:pos]
|
||||||
qual.actions[:exit] = [:record_qual]
|
qual.actions[:exit] = [:record_qual]
|
||||||
|
|
||||||
field = let
|
field = let
|
||||||
|
@ -272,7 +272,7 @@ const sam_metainfo_machine, sam_record_machine, sam_header_machine, sam_body_mac
|
||||||
|
|
||||||
cat(tag, ':', val)
|
cat(tag, ':', val)
|
||||||
end
|
end
|
||||||
field.actions[:enter] = [:mark]
|
field.actions[:enter] = [:pos]
|
||||||
field.actions[:exit] = [:record_field]
|
field.actions[:exit] = [:record_field]
|
||||||
|
|
||||||
cat(
|
cat(
|
||||||
|
@ -289,7 +289,7 @@ const sam_metainfo_machine, sam_record_machine, sam_header_machine, sam_body_mac
|
||||||
qual,
|
qual,
|
||||||
rep(cat('\t', field)))
|
rep(cat('\t', field)))
|
||||||
end
|
end
|
||||||
record.actions[:enter] = [:anchor]
|
record.actions[:enter] = [:mark]
|
||||||
record.actions[:exit] = [:record]
|
record.actions[:exit] = [:record]
|
||||||
|
|
||||||
newline = let
|
newline = let
|
||||||
|
@ -309,23 +309,23 @@ const sam_metainfo_machine, sam_record_machine, sam_header_machine, sam_body_mac
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
const sam_metainfo_actions = Dict(
|
const sam_metainfo_actions = Dict(
|
||||||
:metainfo_tag => :(record.tag = (mark1:p-1) .- offset),
|
:metainfo_tag => :(record.tag = (pos1:p-1) .- offset),
|
||||||
:metainfo_val => :(record.val = (mark1:p-1) .- offset),
|
:metainfo_val => :(record.val = (pos1:p-1) .- offset),
|
||||||
:metainfo_dict_key => :(push!(record.dictkey, (mark2:p-1) .- offset)),
|
:metainfo_dict_key => :(push!(record.dictkey, (pos2:p-1) .- offset)),
|
||||||
:metainfo_dict_val => :(push!(record.dictval, (mark2:p-1) .- offset)),
|
:metainfo_dict_val => :(push!(record.dictval, (pos2:p-1) .- offset)),
|
||||||
:metainfo => quote
|
:metainfo => quote
|
||||||
resize_and_copy!(record.data, data, offset+1:p-1)
|
resize_and_copy!(record.data, data, offset+1:p-1)
|
||||||
record.filled = (offset+1:p-1) .- offset
|
record.filled = (offset+1:p-1) .- offset
|
||||||
end,
|
end,
|
||||||
:anchor => :(),
|
:mark => :(),
|
||||||
:mark1 => :(mark1 = p),
|
:pos1 => :(pos1 = p),
|
||||||
:mark2 => :(mark2 = p)
|
:pos2 => :(pos2 = p)
|
||||||
)
|
)
|
||||||
|
|
||||||
generate_index_function(
|
generate_index_function(
|
||||||
MetaInfo,
|
MetaInfo,
|
||||||
sam_metainfo_machine,
|
sam_metainfo_machine,
|
||||||
:(mark1 = mark2 = offset = 0),
|
:(pos1 = pos2 = offset = 0),
|
||||||
sam_metainfo_actions
|
sam_metainfo_actions
|
||||||
) |> eval
|
) |> eval
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ generate_readheader_function(
|
||||||
Reader,
|
Reader,
|
||||||
MetaInfo,
|
MetaInfo,
|
||||||
sam_header_machine,
|
sam_header_machine,
|
||||||
:(mark1 = mark2 = offset = 0),
|
:(pos1 = pos2 = offset = 0),
|
||||||
merge(sam_metainfo_actions, Dict(
|
merge(sam_metainfo_actions, Dict(
|
||||||
:metainfo => quote
|
:metainfo => quote
|
||||||
resize_and_copy!(record.data, data, upanchor!(stream):p-1)
|
resize_and_copy!(record.data, data, upanchor!(stream):p-1)
|
||||||
|
@ -345,7 +345,7 @@ generate_readheader_function(
|
||||||
end,
|
end,
|
||||||
:header => :(finish_header = true; @escape),
|
:header => :(finish_header = true; @escape),
|
||||||
:countline => :(linenum += 1),
|
:countline => :(linenum += 1),
|
||||||
:anchor => :(anchor!(stream, p); offset = p - 1))),
|
:mark => :(anchor!(stream, p); offset = p - 1))),
|
||||||
quote
|
quote
|
||||||
if !eof(stream)
|
if !eof(stream)
|
||||||
stream.position -= 1 # cancel look-ahead
|
stream.position -= 1 # cancel look-ahead
|
||||||
|
@ -354,37 +354,37 @@ generate_readheader_function(
|
||||||
) |> eval
|
) |> eval
|
||||||
|
|
||||||
const sam_record_actions = Dict(
|
const sam_record_actions = Dict(
|
||||||
:record_qname => :(record.qname = (mark:p-1) .- offset),
|
:record_qname => :(record.qname = (pos:p-1) .- offset),
|
||||||
:record_flag => :(record.flag = (mark:p-1) .- offset),
|
:record_flag => :(record.flag = (pos:p-1) .- offset),
|
||||||
:record_rname => :(record.rname = (mark:p-1) .- offset),
|
:record_rname => :(record.rname = (pos:p-1) .- offset),
|
||||||
:record_pos => :(record.pos = (mark:p-1) .- offset),
|
:record_pos => :(record.pos = (pos:p-1) .- offset),
|
||||||
:record_mapq => :(record.mapq = (mark:p-1) .- offset),
|
:record_mapq => :(record.mapq = (pos:p-1) .- offset),
|
||||||
:record_cigar => :(record.cigar = (mark:p-1) .- offset),
|
:record_cigar => :(record.cigar = (pos:p-1) .- offset),
|
||||||
:record_rnext => :(record.rnext = (mark:p-1) .- offset),
|
:record_rnext => :(record.rnext = (pos:p-1) .- offset),
|
||||||
:record_pnext => :(record.pnext = (mark:p-1) .- offset),
|
:record_pnext => :(record.pnext = (pos:p-1) .- offset),
|
||||||
:record_tlen => :(record.tlen = (mark:p-1) .- offset),
|
:record_tlen => :(record.tlen = (pos:p-1) .- offset),
|
||||||
:record_seq => :(record.seq = (mark:p-1) .- offset),
|
:record_seq => :(record.seq = (pos:p-1) .- offset),
|
||||||
:record_qual => :(record.qual = (mark:p-1) .- offset),
|
:record_qual => :(record.qual = (pos:p-1) .- offset),
|
||||||
:record_field => :(push!(record.fields, (mark:p-1) .- offset)),
|
:record_field => :(push!(record.fields, (pos:p-1) .- offset)),
|
||||||
:record => quote
|
:record => quote
|
||||||
resize_and_copy!(record.data, data, 1:p-1)
|
resize_and_copy!(record.data, data, 1:p-1)
|
||||||
record.filled = (offset+1:p-1) .- offset
|
record.filled = (offset+1:p-1) .- offset
|
||||||
end,
|
end,
|
||||||
:anchor => :(),
|
:mark => :(),
|
||||||
:mark => :(mark = p)
|
:pos => :(pos = p)
|
||||||
)
|
)
|
||||||
|
|
||||||
generate_index_function(
|
generate_index_function(
|
||||||
Record,
|
Record,
|
||||||
sam_record_machine,
|
sam_record_machine,
|
||||||
:(mark = offset = 0),
|
:(pos = offset = 0),
|
||||||
sam_record_actions
|
sam_record_actions
|
||||||
) |> eval
|
) |> eval
|
||||||
|
|
||||||
generate_read_function(
|
generate_read_function(
|
||||||
Reader,
|
Reader,
|
||||||
sam_body_machine,
|
sam_body_machine,
|
||||||
:(mark = offset = 0),
|
:(pos = offset = 0),
|
||||||
merge(sam_record_actions, Dict(
|
merge(sam_record_actions, Dict(
|
||||||
:record => quote
|
:record => quote
|
||||||
resize_and_copy!(record.data, data, upanchor!(stream):p-1)
|
resize_and_copy!(record.data, data, upanchor!(stream):p-1)
|
||||||
|
@ -393,6 +393,6 @@ generate_read_function(
|
||||||
@escape
|
@escape
|
||||||
end,
|
end,
|
||||||
:countline => :(linenum += 1),
|
:countline => :(linenum += 1),
|
||||||
:anchor => :(anchor!(stream, p); offset = p - 1))
|
:mark => :(anchor!(stream, p); offset = p - 1))
|
||||||
)
|
)
|
||||||
) |> eval
|
) |> eval
|
||||||
|
|
Loading…
Reference in a new issue