call module

class mavis.validate.call.EventCall(b1, b2, source_evidence, event_type, call_method, contig=None, contig_alignment=None, untemplated_seq=None)[source]

Bases: mavis.breakpoint.BreakpointPair

class for holding evidence and the related calls since we can’t freeze the evidence object directly without a lot of copying. Instead we use call objects which are basically just a reference to the evidence object and decisions on class, exact breakpoints, etc

Parameters:
  • evidence (Evidence) – the evidence object we are calling based on
  • event_type (SVTYPE) – the type of structural variant
  • breakpoint_pair (BreakpointPair) – the breakpoint pair representing the exact breakpoints
  • call_method (CALL_METHOD) – the way the breakpoints were called
  • contig (Contig) – the contig used to call the breakpoints (if applicable)
add_break1_split_read(read)[source]
Parameters:read (pysam.AlignedSegment) – putative split read supporting the first breakpoint
add_break2_split_read(read)[source]
Parameters:read (pysam.AlignedSegment) – putative split read supporting the second breakpoint
add_flanking_support(flanking_pairs, is_compatible=False)[source]

counts the flanking read-pair support for the event called. The original source evidence may have contained evidence for multiple events and uses a larger range so flanking pairs here are checked specifically against the current breakpoint call

Returns:
  • set of str - set of the read query_names
  • int - the median insert size
  • int - the standard deviation (from the median) of the insert size
Return type:tuple

see theory - determining flanking support

add_spanning_read(read)[source]
Parameters:read (pysam.AlignedSegment) – putative spanning read
break1_split_read_names(tgt=False, both=False)[source]
Parameters:
  • tgt (bool) – return only target re-aligned read names
  • both (bool) – return both original alignments and target-realigned
break2_split_read_names(tgt=False, both=False)[source]
Parameters:
  • tgt (bool) – return only target re-aligned read names
  • both (bool) – return both original alignments and target-realigned
static characterize_repeat_region(event, reference_genome)[source]

For a given event, determines the number of repeats the insertion/duplication/deletion is following. This is most useful in flagging homopolymer regions. Will raise a ValueError if the current event is not an expected type or is non-specific.

Returns:int - the number of repeats str - the repeat sequence
Return type:tuple
complexity()[source]

The sequence complexity for the call. If called by contig then the complexity of the contig sequence, otherwise an average of the sequence complexity of the support based on the call method

flanking_metrics()[source]

computes the median and standard deviation of the flanking pairs. Note that standard deviation is calculated wrt the median and not the average. Also that the fragment size is calculated as a range so the start and end of the range are used in computing these metrics

Returns:
  • float - the median fragment size
  • float - the fragment size standard deviation wrt the median
Return type:tuple
flatten()[source]

converts the current call to a dictionary for a row in a tabbed file

get_bed_repesentation()[source]
has_compatible
is_supplementary()[source]

check if the current event call was the target event given the source evidence object or an off-target call, i.e. something that was called as part of the original target. This is important b/c if the current event was not one of the original target it may not be fully investigated in other libraries

linking_split_read_names()[source]
support()[source]

return a set of all reads which support the call

mavis.validate.call.call_events(source_evidence)[source]

generates a set of event calls based on the evidence associated with the source_evidence object will also narrow down the event type

Parameters:
  • source_evidence (Evidence) – the input evidence
  • event_type (SVTYPE) – the type of event we are collecting evidence for
Returns:

list of calls

Return type:

list of EventCall

mavis.validate.call.filter_consumed_pairs(pairs, consumed_reads)[source]

given a set of read tuples, returns all tuples where neither read in the tuple is in the consumed set

Parameters:
Returns:

set of filtered tuples

Return type:

set of tuples of pysam.AlignedSegment and pysam.AlignedSegment

Note

this will work with any hash-able object

Example

>>> pairs = {(1, 2), (3, 4), (5, 6)}
>>> consumed_reads = {1, 2, 4}
>>> filter_consumed_pairs(pairs, consumed_reads)
{(5, 6)}