def create_classifier_with_two_entries(cls: Type) -> Type[Classifier]: flag = 0 cigar = "56M" nm = "NM:i:0" md = "MD:Z:56" mapq = 60 pos = 1 query_header = ProbeHeader(interval=ProbeInterval(12, 17)) sequence = "AAAAAAAAAAACGGCTCGCATAGACACGACGACGACACGTACGATCGATCAGTCAT" ref_header = ProbeHeader( chrom="GC00000422_2", sample="CFT073", pos=603, interval=ProbeInterval(25, 32), svtype="PH_SNPs", gt_conf=89.5987, ) header = create_sam_header(str(ref_header), 64) contents = str(header) + "\n" record1 = pysam.AlignedSegment.fromstring( f"{query_header}\t{flag}\t{ref_header}\t{pos}\t{mapq}\t{cigar}\t*\t0\t0\t{sequence}\t*\t{nm}\t{md}\tAS:i:43\tXS:i:32", header, ) contents += record1.to_string() + "\n" flag = 2048 cigar = "43M" nm = "NM:i:1" md = "MD:Z:21T21" mapq = 0 pos = 5 query_header = ProbeHeader(chrom="3", pos=14788, interval=ProbeInterval(21, 22)) sequence = "CGCGAAAGCCCTGACCATCTGCACCGTGTCTGACCACATCCGC" header = create_sam_header(str(ref_header), 57) record2 = pysam.AlignedSegment.fromstring( f"{query_header}\t{flag}\t{ref_header}\t{pos}\t{mapq}\t{cigar}\t*\t0\t0\t{sequence}\t*\t{nm}\t{md}\tAS:i:43\tXS:i:32", header, ) contents += record2.to_string() + "\n" sam = create_tmp_sam(contents) return cls(sam)
class TestRecallMasker: @patch.object( Probe, "get_interval", return_value=ProbeInterval(3, 4) ) @patch.object(Probe, "chrom", return_value="chrom1", new_callable=PropertyMock) @patch.object(Probe, "pos", return_value=45, new_callable=PropertyMock) def test_getIntervalWhereProbeAlignsToTruth_probeOfLengthOneReturnsIntervalOfLengthOne( self, *mock ): actual = RecallMasker.get_interval_where_probe_aligns_to_truth(Classification()) expected = Interval(45, 46, "chrom1") assert actual == expected @patch.object( Probe, "get_interval", return_value=ProbeInterval(3, 5) ) @patch.object(Probe, "chrom", return_value="chrom1", new_callable=PropertyMock) @patch.object(Probe, "pos", return_value=45, new_callable=PropertyMock) def test_getIntervalWhereProbeAlignsToTruth_probeOfLengthTwoReturnsIntervalOfLengthTwo( self, *mock ): actual = RecallMasker.get_interval_where_probe_aligns_to_truth(Classification()) expected = Interval(45, 47, "chrom1") assert actual == expected @patch.object( Probe, "get_interval", return_value=ProbeInterval(3, 3) ) @patch.object(Probe, "chrom", return_value="chrom1", new_callable=PropertyMock) @patch.object(Probe, "pos", return_value=45, new_callable=PropertyMock) def test_getIntervalWhereProbeAlignsToTruth_probeOfLengthZeroReturnsNullInterval( self, *mock ): actual = RecallMasker.get_interval_where_probe_aligns_to_truth(Classification()) expected = Interval(45, 45, "chrom1") assert actual == expected
def create_incorrect_primary_sam_record() -> pysam.AlignedSegment: flag = 0 cigar = "56M" nm = "NM:i:1" md = "MD:Z:12T43" mapq = 60 pos = 1 query_header = ProbeHeader(interval=ProbeInterval(12, 13)) ref_header = ProbeHeader( chrom="GC00000422_2", sample="CFT073", pos=603, interval=ProbeInterval(25, 32), svtype="PH_SNPs", gt_conf=89.5987, ) sequence = "AAAAAAAAAAACGGCTCGCATAGACACGACGACGACACGTACGATCGATCAGTCAT" header = create_sam_header(str(ref_header), 64) record = pysam.AlignedSegment.fromstring( f"{query_header}\t{flag}\t{ref_header}\t{pos}\t{mapq}\t{cigar}\t*\t0\t0\t{sequence}\t*\t{nm}\t{md}\tAS:i:43\tXS:i:32", header, ) return record
def create_correct_supplementary_sam_record() -> pysam.AlignedSegment: flag = 2048 cigar = "43M" nm = "NM:i:1" md = "MD:Z:19T23" mapq = 0 pos = 5 query_header = ProbeHeader(chrom="3", pos=14788, interval=ProbeInterval(21, 22)) ref_header = ProbeHeader( chrom="GC00000422_2", sample="CFT073", pos=603, interval=ProbeInterval(25, 32), svtype="PH_SNPs", gt_conf=89.5987, ) sequence = "CGCGAAAGCCCTGACCATCTGCACCGTGTCTGACCACATCCGC" header = create_sam_header(str(ref_header), 57) record = pysam.AlignedSegment.fromstring( f"{query_header}\t{flag}\t{ref_header}\t{pos}\t{mapq}\t{cigar}\t*\t0\t0\t{sequence}\t*\t{nm}\t{md}\tAS:i:43\tXS:i:32", header, ) return record