Metadata-Version: 2.1
Name: haploblock-shuffler
Version: 0.0.5
Summary: Create all possible combinations of phased and unphased blocks in a vcf
Home-page: https://github.com/redmar-van-den-berg/haploblock-shuffler
Author: Redmar van den Berg
Author-email: RedmarvandenBerg@lumc.nl
License: MIT
Project-URL: Changelog, https://github.com/redmar-van-den-berg/haploblock-shuffler/blob/master/CHANGELOG.rst
Project-URL: Issue Tracker, https://github.com/redmar-van-den-berg/haploblock-shuffler/issues
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Utilities
Requires-Python: >=3.7.*
Description-Content-Type: text/markdown
Requires-Dist: pyvcf3

[![Continous integration](https://github.com/Redmar-van-den-Berg/haploblock-shuffler/actions/workflows/ci.yml/badge.svg)](https://github.com/Redmar-van-den-Berg/haploblock-shuffler/actions/workflows/ci.yml)

# Haploblock-shuffler
Create all possible combinations of phased and unphased blocks in a vcf

------------------------------------------------------------------------
## Background
This tool takes a phase, unphased or partially phased VCF file, and generates
all possible combinations of phase blocks that are consistent with the phasing
that is present in the VCF file.


## Details
First, this tool reads all variants from a VCF file, and groups variants
together if they are compatible.
1. If a variant is phased (using the `PS` tag), it is only compatible with
   other phased variants that have the same phase ID.
2. Homozygous variants are always compatible with other variants, since they
   are part of every phase group
3. Heterozygous variants are only compatible when they are phased, and the
   phase ID matches.

To produce all possible combinations of grouped variants, haplotype-suffler
uses a counter to produce a binary pattern that determines which calls should
be modified. To modify a variant, we simply invert the order of the `GT` field,
so that `0/1` becomes `1/0`, or vice versa.

Since there are two alleles for every variant, we only have to produce half of
the possible VCF file, since the other half are mirror images (e.g. `0101` and
`1010`).

## Usage
```bash
haploblock-shuffler test.vcf output
```

To generate consensus fasta files from the output vcf files, bgzip and index
the output vcf files
```bash
cd output
for i in out_*.vcf; do
    bgzip $i
    tabix ${i}.gz
done
```
Then, generate the consensus using
```bash
samtools faidx $REFERENCE $REGION | bcftools consensus -H 1 out_0.vcf.gz > out_0_1.fa
samtools faidx $REFERENCE $REGION | bcftools consensus -H 2 out_0.vcf.gz > out_0_2.fa
```


