From 80ce432493c2c8e841e1ad6e488b29609bb60d81 Mon Sep 17 00:00:00 2001 From: mlamkin7 Date: Thu, 30 Jun 2022 13:58:17 -0700 Subject: [PATCH 1/2] Working example. --- haptools/__main__.py | 2 +- haptools/sim_genotype.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/haptools/__main__.py b/haptools/__main__.py index 7541905d..2f67105d 100644 --- a/haptools/__main__.py +++ b/haptools/__main__.py @@ -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', \ diff --git a/haptools/sim_genotype.py b/haptools/sim_genotype.py index 3dc4cece..4d14f8b1 100644 --- a/haptools/sim_genotype.py +++ b/haptools/sim_genotype.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import re import glob @@ -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): """ @@ -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.") From 54ed5a477c03876cfa35092a17b50879c32a90e6 Mon Sep 17 00:00:00 2001 From: mlamkin7 Date: Thu, 30 Jun 2022 13:59:38 -0700 Subject: [PATCH 2/2] working example --- haptools/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haptools/__main__.py b/haptools/__main__.py index 2f67105d..5830b84c 100644 --- a/haptools/__main__.py +++ b/haptools/__main__.py @@ -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