seismicrna.relate.tests package

Submodules

class seismicrna.relate.tests.main_test.TestRelate(*args, **kwargs)

Bases: TestCase, ABC

batches(min_reads: int = 0, min_mapq: int = 0, min_phred: int = 0, clip_end5: int = 0, clip_end3: int = 0, **kwargs)
abstract classmethod get_sam_data() list

Data for the SAM file.

setUp()

Hook method for setting up the test fixture before exercising it.

tearDown()

Hook method for deconstructing the test fixture after testing it.

class seismicrna.relate.tests.main_test.TestRelateEmpty(*args, **kwargs)

Bases: TestRelate

classmethod get_sam_data()

Data for the SAM file.

test_min_reads()
test_noargs()
class seismicrna.relate.tests.main_test.TestRelatePaired(*args, **kwargs)

Bases: TestRelate

classmethod get_sam_data()

Data for the SAM file.

test_batch_size_1()
test_batch_size_4()
test_batch_size_5()
test_batch_size_6()
test_clip()
test_min_phred()
test_min_reads()
test_noargs()
class seismicrna.relate.tests.main_test.TestRelateSingle(*args, **kwargs)

Bases: TestRelate

classmethod get_sam_data()

Data for the SAM file.

test_batch_size_1()
test_batch_size_3()
test_clip()
test_min_phred()
test_min_reads()
test_noargs()
seismicrna.relate.tests.main_test.extract_batches(batches: Iterable[RegionMutsBatch])
seismicrna.relate.tests.main_test.load_refseq(out_dir: Path)
seismicrna.relate.tests.main_test.write_fasta_file(out_dir: Path)
seismicrna.relate.tests.main_test.write_sam_file(out_dir: Path, data: list[list])
class seismicrna.relate.tests.relate_test.TestCalcRelsLinesPaired(methodName='runTest')

Bases: TestCase

evaluate(expect_ends1: tuple[int, int], expect_ends2: tuple[int, int], expect_rels: dict[int, int], ref: str, refseq: DNA, read1: DNA, qual1: str, cigar1: str, end51: int, read2: DNA, qual2: str, cigar2: str, end52: int)
relate(ref: str, refseq: DNA, read1: DNA, qual1: str, cigar1: str, end51: int, read2: DNA, qual2: str, cigar2: str, end52: int, ambindel: bool = True, insert3: bool = True, clip_end5: int = 0, clip_end3: int = 0, read1rev: bool = False)

Generate a SAM line from the given information, and use it to compute the relationships.

relate_error(error_msg: str, ref: str = 'ref', refseq: DNA = DNA('ACGT'), name1: str = 'read', ref1: str = 'ref', cigar1: str = '4M', flag1: int = 83, end51: int = 1, read1: DNA = DNA('ACGT'), qual1: str = 'FFFF', name2: str = 'read', ref2: str = 'ref', flag2: int = 163, end52: int = 1, cigar2: str = '4M', read2: DNA = DNA('ACGT'), qual2: str = 'FFFF', insert3: bool = True, ambindel: bool = True, clip_end5: int = 0, clip_end3: int = 0)
test_abut()

Reads abut.

R1 GTGC R2 TCGT Ref AGTCAACGT Pos 123456789

test_contain()

One read contains the other, with neither end flush.

R1 TgcAT R2 gtaAACG Ref AGTCAACGT Pos 123456789

test_contain_flush3()

One read contains the other, with 3’ ends flush.

R1 TAtCa R2 CggAtCc Ref AGTCAACGT Pos 123456789

test_contain_flush5()

One read contains the other, with 5’ ends flush.

R1 ATcAggG R2 gTcaT Ref AGTCAACGT Pos 123456789

test_contain_flush53()

Both reads start and end at the same positions.

R1 tc-ACG R2 gGATCG Ref AGTCAACGT Pos 123456789

test_diff_names()
test_gap()

Reads are separated by a gap.

R1 AGTG R2 TCGT Ref AGTCAACGT Pos 123456789

test_improper()
test_read_marks()
test_read_orientation()
test_staggered()

Reads overlap in a staggered manner.

R1 aGTGgtA R2 AGATGc Ref AGTCAACGT Pos 123456789

test_unpaired()
class seismicrna.relate.tests.relate_test.TestCalcRelsLinesSingle(methodName='runTest')

Bases: TestCase

iter_cases(refseq: DNA, max_ins: int, paired: bool = False)
iter_cases_insert3(refseq: DNA, max_ins: int, insert3: bool, paired: bool)

Iterate through every test case.

relate(ref: str, refseq: DNA, read: DNA, qual: str, cigar: str, end5: int, insert3: bool, ambindel: bool, clip_end5: int, clip_end3: int, paired: bool = False)

Generate a SAM line from the given information, and use it to compute the relationships.

relate_error(error_msg: str, error_msg_py: str = '', ref: str = 'ref', refseq: DNA = DNA('ACGT'), read: DNA = DNA('ACGT'), qual: str = 'FFFF', cigar: str = '4M', end5: Any = 1, sam_ref: str = '', mapq: Any = None, flag: Any = None, ambindel: bool = True, insert3: bool = True, clip_end5: int = 0, clip_end3: int = 0, paired: bool = False)
relate_truncated(num_fields: int, error_msg: str, ref: str = 'ref', refseq: DNA = DNA('ACGT'), read: DNA = DNA('ACGT'), qual: str = 'FFFF', cigar: str = '4M', end5: Any = 1, ambindel: bool = True, insert3: bool = True, clip_end5: int = 0, clip_end3: int = 0, paired: bool = False)

Test errors caused by lines that are too short.

test_4nt_2ins()
test_4nt_2ins_paired()
test_5nt_2ins()
test_6nt_2ins()
test_7nt_0ins()
test_8nt_0ins()
test_all_matches()
test_ambig_delet_low_qual()

Test ambiguous deletions with all low-quality positions.

test_error_cigar_adj_ins_del()
test_error_cigar_consecutive()
test_error_cigar_del_first_rel()
test_error_cigar_del_last_rel()
test_error_cigar_empty()
test_error_cigar_ins_first_rel()
test_error_cigar_ins_last_rel()
test_error_cigar_missing()
test_error_cigar_op_read_diff()
test_error_cigar_op_ref_long()
test_error_cigar_op_ref_zero()
test_error_cigar_parse()
test_error_cigar_soft_clips()
test_error_flag_large()
test_error_flag_missing()
test_error_flag_parse()
test_error_line_improper_flag_proper()
test_error_line_paired_flag_unpaired()
test_error_line_unpaired_flag_paired()
test_error_mapq()
test_error_mapq_insufficient()
test_error_mapq_missing()
test_error_name_missing()
test_error_pos_large()
test_error_pos_missing()
test_error_pos_parse()
test_error_pos_zero()
test_error_qual_missing()
test_error_read_missing()
test_error_read_qual_diff()
test_error_ref_mismatch()
test_error_ref_missing()
test_example_1()

Soft clips in CIGAR plus clip_end5 and clip_end3.

Seq GGTATAG Qul FFFFFFF CGR SS====S Ref CAATATATC Pos 123456789

test_example_2()

Deletions cannot move out of soft-clipped regions.

Seq TATA–TAT Qul FFFF–FFF CGR SS==DD==S Ref ATATATATATA Pos 123456789ab

test_example_3()

Insertions cannot move out of soft-clipped regions.

Seq TATATATAT Qul FFFFFFFFF CGR SS==II==S Ref ATATA–TATA Pos 12345–6789

test_long_ambindels()
test_n_read()

Read contains a non-ACGT base and reference is ACGT.

test_n_ref()

Reference contains a non-ACGT base.

test_soft_clips()
class seismicrna.relate.tests.relate_test.TestMergeMates(methodName='runTest')

Bases: TestCase

test_both_blank()
test_both_reads()
test_empty()
test_overhangs()
test_read1()
test_read2()
seismicrna.relate.tests.relate_test.as_sam(name: str, flag: int, ref: str, end5: int, mapq: int, cigar: str, rnext: str, pnext: int, tlen: int, read: DNA, qual: str, validate: bool = True)

Return a line in SAM format from the given fields.

Parameters:
  • name (str) – Name of the read.

  • flag (int) – SAM flag. Must be in [0, MAX_FLAG].

  • ref (str) – Name of the reference.

  • end5 (int) – Most 5’ position to which the read mapped (1-indexed).

  • mapq (int) – Mapping quality score.

  • cigar (str) – CIGAR string. Not checked for compatibility with the read.

  • rnext (str) – Name of the mate’s reference (if paired-end).

  • pnext (int) – Most 5’ position of the mate (if paired-end).

  • tlen (int) – Length of the template.

  • read (DNA) – Base calls in the read. Must be equal in length to read.

  • qual (str) – Phred quality score string of the base calls. Must be equal in length to read.

  • validate (bool) – Check that the fields are valid before assembling the line.

Returns:

A line in SAM format containing the given fields.

Return type:

str

class seismicrna.relate.tests.sam_test.TestIterRecordsPaired(methodName='runTest')

Bases: TestCase

run_test_invalid(lines: list[str], expect: str)
run_test_valid(lines: list[str], expect: list[tuple[str, str, str]])
test_blank()
test_one_improper()
test_one_proper()
test_one_single()
test_two_mated_improper()
test_two_mated_improper_1()
test_two_mated_improper_2()
test_two_mated_proper()
test_two_unmated_improper()
test_two_unmated_proper()
class seismicrna.relate.tests.sam_test.TestLineAttrs(methodName='runTest')

Bases: TestCase

test_paired_improper()
test_paired_proper()
test_single()
seismicrna.relate.tests.sam_test.delete_sam(sam_file: Path)
seismicrna.relate.tests.sam_test.write_sam(text: str)