Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve smart-read backend with new mapping of defined formats, extensions, context and parsers #37

Merged
merged 5 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export(as_sublinks)
export(bins)
export(check_strand)
export(combine_strands)
export(def_formats)
export(def_names)
export(def_types)
export(drop_feat_layout)
Expand All @@ -103,7 +104,6 @@ export(drop_seq_layout)
export(ex)
export(feats)
export(feats0)
export(file_formats)
export(flip)
export(flip_by_links)
export(flip_seqs)
Expand Down
41 changes: 19 additions & 22 deletions R/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,25 @@
# manipulated by other packages.
gggenomes_global <- new.env(parent = emptyenv())

# list of contexts of dictionaryish vectors mapping suffixes to file formats
gggenomes_global$file_formats <- map(list(
feats = list(
gff3 = qc(gff, gff3),
gbk = qc(gbk, gb, gbff),
bed = qc(bed),
fasta = qc(fa, fas, fasta, ffn, fna, faa),
blast = qc(m8, o6, o7),
paf = qc(paf),
ambigious = qc(txt, tsv, csv)
),
seqs = list(
fai = qc(fai),
seq_len = qc(fa, fas, fasta, ffn, fna, faa, gff, gbk),
ambigious = qc(txt, tsv, csv)
),
zips = list(
bz2 = qc(bz, bz2),
gz = qc(gz),
xz = qc(xz),
zip = qc(zip))
), ~deframe(stack(.x) %>% mutate(ind=as.character(ind))))
# Mapping of file formats, extensions, contexts, and parsers
#
# parser is a function name, like "read_tsv", ...
#
# context=NA defines fallback parser that is used if no parser is defined for
# the specific context
gggenomes_global$def_formats <- tribble(
~format, ~ext, ~context, ~parser,
"ambigious", qc(txt,tsv,csv), NA, "read_ambigious",
"fasta", qc(fa,fas,fasta,ffn,fna,faa), qc(seqs), qc(read_seq_len),
"fai", qc(fai), qc(seqs), qc(read_fai),
"gff3", qc(gff,gff3), qc(feats, seqs), qc(read_gff3, read_seq_len),
"gbk", qc(gbk,gb,gbff,gpff), qc(feats, seqs), qc(read_gbk, read_seq_len),
"bed", qc(bed), "feats", "read_bed",
"blast", qc(m8,o6,o7), "feats", "read_blast",
"paf", qc(paf), "feats", "read_paf",
"alitv", qc(json), qc(feats, seqs, links),
qc(read_alitv_genes, read_alitv_seqs, read_alitv_links)
)

# Default column names for different formats
gggenomes_global$def_names <- list(
Expand Down
Loading