Skip to content

Commit

Permalink
Fix large format
Browse files Browse the repository at this point in the history
  • Loading branch information
endast committed Nov 15, 2023
1 parent c311944 commit 5028329
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fake_vcf/vcf_faker.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ def __init__(
'##INFO=<ID=AF,Number=A,Type=Float,Description="Estimated allele frequency in the range (0,1)">',
'##INFO=<ID=DP,Number=1,Type=Integer,Description="Approximate read depth; some reads may have been filtered">',
'##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">',
"",
]
) # VCF file format header

if self.large_format:
"\n".join(
self.header += "\n".join(
[
'##FORMAT=<ID=AD,Number=R,Type=Integer,Description="Allelic depths for the ref and alt alleles in the order listed">',
'##FORMAT=<ID=DP,Number=1,Type=Integer,Description="Approximate read depth (reads with MQ=255 or with bad mates are filtered)">',
'##FORMAT=<ID=GQ,Number=1,Type=Integer,Description="Genotype Quality">',
'##FORMAT=<ID=PL,Number=G,Type=Integer,Description="Phred-scaled genotype Likelihoods">',
"",
]
)

self.header += "\n"

if num_samples < 1 or num_rows < 1:
raise ValueError(f"Nr of samples and rows must be greater or equal to 1")

Expand Down Expand Up @@ -154,7 +154,10 @@ def _generate_vcf_row(self):
qual = f"{self.random.randint(10, 100)}"
filt = self.random.choice(["PASS"])
info = f"DP=10;AF=0.5;NS={self.num_samples}"
fmt = "GT"
if self.large_format:
fmt = "GT:AD:DP:GQ:PL"
else:
fmt = "GT"

# Generate random values for each sample by rotating the sample list randomly
max_rotation = (
Expand Down
1 change: 1 addition & 0 deletions tests/test_example/test_vcf_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def run_vcf_validator(vcf_file_path, result_path):
(["-r", "10", "--no-large-format"],),
(["-r", "50", "--no-large-format"],),
(["-r", "100", "--no-large-format"],),
(["-r", "10", "--large-format"],),
],
)
def test_vcf_file_validation(cli_args: list, tmp_path):
Expand Down

0 comments on commit 5028329

Please sign in to comment.