Read Counting¶
Counts properly paired reads within the KIV-2 VNTR region for each sample, filtered by mapping quality and SAM flag as specified in the config.
- grid.utils.count_reads.count_reads(config, console=None)¶
- grid.utils.count_reads.count_reads_in_region(cram_file, ref_fasta, chrom, start, end, proper_flags, min_mapq=1)¶
Count properly paired reads in a genomic region using pysam.
- Parameters:
cram_file (str)
ref_fasta (str)
chrom (str)
start (int)
end (int)
proper_flags (set[int])
min_mapq (int)
- Return type:
int
- grid.utils.count_reads.process_single_cram(path, ref_fasta, chrom, start, end, proper_flags, min_mapq=1, console=None)¶
Process a single sequence alignment file and count reads in region.
- Parameters:
path (str) – Path to sequence alignment file
ref_fasta (str) – Path to reference genome FASTA
chrom (str) – Chromosome name
start (int) – Start position
end (int) – End position
proper_flags (set[int]) – Set of SAM flags to count
min_mapq (int)
- Returns:
Read count or “Error”
- Return type:
int or str
- grid.utils.count_reads.write_read_results(output_file, basename, count, write_lock)¶
Write a single result to the output file in a thread-safe manner.
- Parameters:
output_file (Path) – Path to output file
basename (str) – Sample basename
count (int | str) – Read count or “Error”
write_lock (allocate_lock) – Threading lock for safe file writing
- Return type:
None