Skip to content

Instantly share code, notes, and snippets.

View florianzwagemaker's full-sized avatar
🧬

Florian Zwagemaker florianzwagemaker

🧬
View GitHub Profile
@florianzwagemaker
florianzwagemaker / filter_reference_from_alignment.py
Created July 4, 2024 13:56
A quick script to filter references based on amount of mapped reads in a bamfile. Includes only references that have more than 20 mapped reads.
import sys
# please install the following requirements: pandas, pysam, biopython
import pandas as pd
import pysam
from Bio import SeqIO
# python filter_reference_from_alignment.py input.bam references.fasta mapping_statistics.csv filtered_references.fasta
inputbam, inputref, outputcsv, outputfasta = sys.argv[1:]