btbtbtqqq / Split_bam_into_HP

Split Bam file in to three isolated bam by using Haplotype tags (HP:i:1 or HP:i:2)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Split haplotype BAM by haplotag

Split Bam file in to three isolated bam by using Haplotype tags (HP:i:1 or HP:i:2)

There are two step:
(1) Divide Input-Bam into 3 files:
'Haplotype 1 Bam'--'1.0.bam'
'Haplotype 2 Bam'--'2.0.bam'
'Unphased Bam' --'0.0.bam'
(2) Index and Sort 3 new Bam files (Require samtools env)


Proactive

Example:

conda create -n py39 -c bioconda python=3.9.13 pysam==0.19.1
conda activate py39

Usage

This generator requires pysam, samtools when use it in HPC.

You can simply run it by using this script:

python3 Split_bam_into_HP.py -b my.bam -hp HP

You can Specify the output file name and output folder:

python3 Split_bam_into_HP.py -b my.bam -hp HP -o1 new_HP_1.bam -o2 new_HP_2.bam  -o3 new_noHP.bam -d /outputdirection/

Note

This small tool adapts to duel with bam file which added 'HP:i' tags by longshot, longphase, etc..

About

Split Bam file in to three isolated bam by using Haplotype tags (HP:i:1 or HP:i:2)

License:MIT License


Languages

Language:Python 100.0%