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

Feat/vcf output #58

Merged
merged 3 commits into from
Jun 30, 2022
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
4 changes: 2 additions & 2 deletions haptools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def karyogram(bp, sample, out, title, centromeres, colors):
@click.option('--model', help="Admixture model in .dat format. See docs for info.", \
type=str, required=True)
@click.option('--mapdir', help="Directory containing files with chr\{1-22,X\} and ending in .map in the file name with genetic map coords.", \
type=str, required=True, type=click.Path(exists=True, file_okay=False, dir_okay=True, readable=True))
required=True, type=click.Path(exists=True, file_okay=False, dir_okay=True, readable=True))
@click.option('--out', help="Prefix to name output files.", \
type=str, required=True)
@click.option('--chroms', help='Sorted and comma delimited list of chromosomes to simulate. ex: 1,2,3,5,6,21,X', \
Expand All @@ -75,7 +75,7 @@ def simgenotype(invcf, sample_info, model, mapdir, out, popsize, seed, chroms):
--mapdir ./tests/map/ \
--chroms 1,2 \
--invcf ./tests/data/outvcf_test.vcf \
--sampleinfo ./tests/data/outvcf_info.tab \
--sample_info ./tests/data/outvcf_info.tab \
--out ./tests/data/example_simgenotype
"""
from .sim_genotype import simulate_gt, write_breakpoints, output_vcf, validate_params
Expand Down
8 changes: 5 additions & 3 deletions haptools/sim_genotype.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import os
import re
import glob
Expand All @@ -7,7 +9,7 @@
from pysam import VariantFile
from collections import defaultdict
from .admix_storage import GeneticMarker, HaplotypeSegment
from __future__ import annotations


def output_vcf(breakpoints, model_file, vcf_file, sampleinfo_file, out):
"""
Expand Down Expand Up @@ -690,8 +692,8 @@ def validate_params(model, mapdir, chroms, popsize, invcf, sample_info):
# validate sample_info file (ensure pops given are in model file and samples in vcf file)
# ensure sample_info col 2 in pops
for line in open(sample_info, 'r'):
sample = line.split('\t')[0]
info_pop = line.split('\t')[1]
sample = line.split()[0]
info_pop = line.split()[1]

if sample not in vcf_samples:
raise Exception("Sample in sampleinfo file is not present in the vcf file.")
Expand Down