seismicrna.core.rel package

Subpackages

Submodules

class seismicrna.core.rel.pattern.HalfRelPattern(*codes: str)

Bases: object

a
classmethod allc()

Fits every relationship except for no coverage.

classmethod as_fancy(code: str)

Convert a ref-read code into fancy format, as follows:

  • 6-character uppercase string

  • 1st character is reference base

  • 6th character is read base, ‘D’ (deletion), or ‘I’ (insertion)

  • 2nd to 5th characters form an arrow: ‘ -> ‘

Examples:

  • ‘A -> G’ means an A in the reference is a G in the read

  • ‘C -> D’ means a C in the reference is deleted in the read

classmethod as_match(code: str) Match[str]

Return a re.Match object if the code matches either the plain or the fancy format. Otherwise, raise ValueError.

classmethod as_plain(code: str)

Convert a ref-read code into plain format, as follows:

  • 2-character lowercase string

  • 1st character is reference base

  • 2nd character is read base, ‘d’ (deletion), or ‘i’ (insertion)

Examples:

  • ‘ag’ means an A in the reference is a G in the read

  • ‘cd’ means a C in the reference is deleted in the read

c
property codes

Return the codes of the relationships counted.

classmethod compile(codes: Iterable[str])

Given one or more codes in plain or fancy format, return a dict that maps each reference base to a pattern that will match all and only the codes given for that reference base.

This function is the inverse of cls.decompile.

classmethod decompile(patterns: dict[str, int])

For each reference base and its one-byte pattern, yield all codes that the pattern will count.

This function is the inverse of cls.compile.

fits(base: str, rel: int)

Test whether a relationship code fits the pattern.

fmt_fancy = '{} -> {}'
fmt_plain = '{}{}'
classmethod from_counts(*, count_ref: bool = False, count_sub: bool = False, count_del: bool = False, count_ins: bool = False, discount: Iterable[str] = ())

Return a new SemiBitCaller by specifying which general types of relationships are to be counted.

Parameters:
  • count_ref (bool = False) – Whether to call True all matches between the read and ref.

  • count_sub (bool = False) – Whether to call True all substitutions in the read.

  • count_del (bool = False) – Whether to call True all deletions in the read.

  • count_ins (bool = False) – Whether to call True all insertions in the read.

  • discount (Iterable[str] = ()) – Do not count any of these relationships between the read and the reference, even if they would be counted according to any of the other parameters. Should be an iterable of str in either plain or fancy format (except case-insensitive).

Returns:

New HalfRefPattern instance that counts the specified bytes.

Return type:

HalfRelPattern

classmethod from_report_format(mut_codes: Iterable[str])
g
intersect(other: HalfRelPattern)

Intersect the HalfRelPattern with another.

mut_bits = b'\x10 @\x80\x02\x0c'
classmethod muts()

Fits every mutation.

classmethod none()

Fits nothing.

property patterns
ptrn_fancy = re.compile('([ACGT]) -> ([ACGTDI])')
ptrn_plain = re.compile('([acgt])([acgtdi])')
read_bases = 'ACGTDI'
ref_bases = 'ACGT'
classmethod refs()

Fits every match.

t
to_report_format()

Return the types of counted relationships as a list.

class seismicrna.core.rel.pattern.RelPattern(yes: HalfRelPattern, nos: HalfRelPattern)

Bases: object

classmethod allc()

Fits every relationship except for no coverage.

fits(base: str, rel: int)

Check whether the base and relationship give a definitive result and whether they fit the pattern.

classmethod from_counts(count_del: bool = False, count_ins: bool = False, discount: Iterable[str] = ())

Return a new RelPattern by specifying which general types of mutations are to be counted, with optional ones to discount.

intersect(other: RelPattern | None)

Intersect the pattern with another.

invert()

Swap the yes and nos patterns.

classmethod matches()

Fits every match.

classmethod muts()

Fits every mutation.

nos
yes