Skip to content

Commit

Permalink
work on csq
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Jun 9, 2024
1 parent a519759 commit d96f82b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env_logger = "0.11.3"
log = "0.4.21"
parking_lot = { version = "0.12.1", features = ["arc_lock"] }
#libc = "0.2.153"
libc = "0.2"

[[bin]]
name = "vcfexpr"
Expand Down
8 changes: 4 additions & 4 deletions scripts/csq.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ function CSQ.new(fields, header)
end
-- now fill a table with keys from header and values from fields
local self = setmetatable({}, CSQ)
for i, field in ipairs(fields) do
self[header[i]] = field
for i, h in ipairs(header) do
self[h] = fields[i]
end
return self
end
Expand All @@ -36,12 +36,12 @@ NUMBER_FIELDS = { "AF", "AFR_AF", "AMR_AF", "ASN_AF", "EUR_AF", "EAS_AF", "SAS_A
"gnomAD_NFE_TSI_AF", "gnomAD_NFE_FOE_AF", "gnomAD_NFE_NWE_AF", "gnomAD_NFE_SEU_AF", "gnomAD_NFE_SWE_AF",
"gnomAD_NFE_ONF_AF", "gnomAD_NFE_EST_AF", "gnomAD_NFE_MED_AF",
"gnomAD_NFE_SCA_AF", "gnomAD_NFE_BAL_AF", "gnomAD_NFE_IB",
"MAX_AF", "MAX_AF_POPS", }
"MAX_AF", "MAX_AF_POPS", "ALLELE_NUM", "DISTANCE"
}
-- if the field starts with gnomAD_ also add gnomADe_... and gnomADg_...
add_gnomad = {}
for _, field in ipairs(NUMBER_FIELDS) do
if string.match(field, "^gnomAD_") then
print(string.gsub(field, "^gnomAD_", "gnomADe_"))
add_gnomad[#add_gnomad + 1] = string.gsub(field, "^gnomAD_", "gnomADe_")
add_gnomad[#add_gnomad + 1] = string.gsub(field, "^gnomAD_", "gnomADg_")
end
Expand Down
8 changes: 8 additions & 0 deletions scripts/csq_header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ for i, v in ipairs(parsed_table3) do
print(i, v)
end
desc =
'Functional annotations: \'Allele | Annotation | Annotation_Impact | Gene_Name | Gene_ID | Feature_Type | Feature_ID | Transcript_BioType | Rank | HGVS.c | HGVS.p | cDNA.pos / cDNA.length | CDS.pos / CDS.length | AA.pos / AA.length | Distance | ERRORS / WARNINGS / INFO\'"'
for i, v in ipairs(parse_description(desc)) do
print(i, v)
end
--]]
1 change: 1 addition & 0 deletions scripts/h.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
desc = parse_description(header_desc)
4 changes: 4 additions & 0 deletions scripts/pre.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
header:add_info({ID="af_copy", Number=1, Description="adding a single field", Type="Float"})
--print(header:info_get("af_copy").Description)

header_desc = header:info_get("vep").Description
1 change: 1 addition & 0 deletions scripts/t.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./target/debug/vcfexpr filter -e "print(CSQ.new(variant:info('vep', 0), desc).Allele); return variant.id == 'rs2124717267'" -o var.bcf gnomad.genomes.v4.0.sites.chrY.vcf.bgz -p scripts/pre.lua -s 'af_copy=return variant:info("AF", 0)' -l scripts/csq.lua -l scripts/csq_header.lua -l scripts/h.lua

0 comments on commit d96f82b

Please sign in to comment.