Skip to content

Commit

Permalink
Switch to vcfpy
Browse files Browse the repository at this point in the history
  • Loading branch information
pvanheus committed May 31, 2024
1 parent d2ef28d commit 351a34d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ click>=8.0.1
flake8>=3.9.2
jinja2>=3.0.1
neo4j>=4.2.1
pyvcf==0.6.8
vcfpy>=0.13.0
pytest>=6.2.4

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"click",
"neo4j",
"jinja2",
"pyvcf",
"vcfpy",
],
entry_points={"console_scripts": ["tbvcfreport=tbvcfreport.tbvcfreport:cli"]},
project_urls={
Expand Down
4 changes: 2 additions & 2 deletions tbvcfreport/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def generate_txt_report(file_name, data):
"GENE",
"IDENTIFIER",
"PRODUCT",
"TYPE",
"IS_SNV",
"ANNOTATION",
"POS",
"REF",
Expand All @@ -95,7 +95,7 @@ def generate_txt_report(file_name, data):
s[3],
s[4],
s[21]["protein"]["uniquename"] if "protein" in s[21] and s[21]["protein"] else "NOPROTEIN",
s[19],
str(s[19]),
s[1],
str(s[17]),
s[18],
Expand Down
4 changes: 2 additions & 2 deletions tbvcfreport/templates/report-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<th scope="col">GENE</th>
<th scope="col">LOCUS</th>
<th scope="col">PRODUCT</th>
<th scope="col">TYPE</th>
<th scope="col">IS_SNV</th>
<th scope="col">EFFECT</th>
<th scope="col">POS</th>
<th scope="col">REF</th>
Expand Down Expand Up @@ -68,7 +68,7 @@
<p>{{ "NA" }}</p>
{% endif %}
</td>
<td>{{ item[19] or "NA" }}</td>
<td>{{ item[19] }}</td>
<td>{{ item[1] or "NA" }}</td>
<td>
<a href="https://explorer.sanbi.ac.za/jbrowse/?loc=NC_000962.3%3A{{ item[20] }}&tracks=DNA%2CGenes&highlight=NC_000962.3%3A{{ item[20] }}"
Expand Down
14 changes: 7 additions & 7 deletions tbvcfreport/vcfproc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Interface to handle VCF files."""
import vcf
import vcfpy

from .dbconn import CombatTbDb

Expand All @@ -22,7 +22,7 @@ def parse(self):
"""Parse VCF."""
variants, rv_tags = [], []
with open(self.vcf_file) as _vcf:
vcf_reader = vcf.Reader(_vcf)
vcf_reader = vcfpy.Reader.from_stream(_vcf)
for i, record in enumerate(vcf_reader):
if record.INFO.get("ANN"):
annotations = self.get_variant_ann(record=record)
Expand All @@ -35,12 +35,12 @@ def parse(self):
rv_tags = list(set(rv_tags))
gene_info = self.gene_info_to_dict(self.db.query_by_gene_list(rv_tags))
with open(self.vcf_file) as _vcf:
vcf_reader = vcf.Reader(_vcf)
vcf_reader = vcfpy.Reader.from_stream(_vcf)
for i, record in enumerate(vcf_reader):
if record.var_type == "snp":
record.affected_start += 1
if record.is_snv():
record.begin += 1
affected_region = "..".join(
[str(record.affected_start), str(record.affected_end)]
[str(record.begin), str(record.end)]
)
if record.INFO.get("ANN"):
annotations = self.get_variant_ann(record=record)
Expand All @@ -60,7 +60,7 @@ def parse(self):
record.CHROM,
record.POS,
record.REF,
record.var_type,
record.is_snv(),
affected_region,
variant_data,
]
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py310,py311,py312
envlist = py{310,311,312}

[testenv]
deps = -rrequirements.txt
Expand Down

0 comments on commit 351a34d

Please sign in to comment.