Skip to Content
Python APIHicHiCSamProcessor

HiCSamProcessor

class chr3d.HiCSamProcessor( threads: int = 1, min_mapq: int = 30, )

SAM/BAM processing for Hi-C data using samtools.

Converts SAM to BAM and sorts by read name (required for pairtools).

Parameters

ParameterTypeDescription
threadsintNumber of threads for samtools (default: 1)
min_mapqintMinimum mapping quality score (default: 30)

Methods

process

def process( self, input_sam: str, output_bam: str, stats_file: Optional[str] = None, keep_unsorted: bool = False, ) -> Dict[str, Any]

Convert SAM to sorted BAM.

Parameters:

ParameterTypeDescription
input_samstrPath to input SAM file
output_bamstrPath to output sorted BAM file
stats_fileOptional[str]Optional path to save BAM stats
keep_unsortedboolKeep unsorted BAM file (default: False)

Returns:

Dict[str, Any] with keys:

  • 'output_bam': Path to output BAM file
  • 'stats_file': Path to stats file
  • 'bam_size_bytes': Size of BAM file in bytes

Example:

import chr3d as c3d processor = c3d.HiCSamProcessor(threads=24, min_mapq=30) stats = processor.process( input_sam="aligned.sam", output_bam="sorted.bam" )
Last updated on