Ejemplo n.º 1
0
    def _set_flags(self, rec: pysam.AlignedSegment, is_r1: bool,
                   strand: str) -> None:
        """Appropriately sets most flag fields on the given read.

        Args:
            rec: the read to set the flags on
            is_r1: True if the read is a R1, False if it is an R2
            strand: Either "+" or "-" to indicate strand of the read
        """
        rec.is_paired = True
        rec.is_read1 = is_r1
        rec.is_read2 = not is_r1
        rec.is_qcfail = False
        rec.is_duplicate = False
        rec.is_secondary = False
        rec.is_supplementary = False
        if not rec.is_unmapped:
            rec.is_reverse = strand != "+"
Ejemplo n.º 2
0
def _make_read_unmapped(rec: AlignedSegment) -> None:
    """Removes mapping information from a read."""
    if rec.is_reverse:
        quals = rec.query_qualities
        quals.reverse()
        rec.query_sequence = dnautils.reverse_complement(rec.query_sequence)
        rec.query_qualities = quals
        rec.is_reverse = False

    rec.reference_id = sam.NO_REF_INDEX
    rec.reference_start = sam.NO_REF_POS
    rec.cigar = None
    rec.mapping_quality = 0
    rec.template_length = 0
    rec.is_duplicate = False
    rec.is_secondary = False
    rec.is_supplementary = False
    rec.is_proper_pair = False
    rec.is_unmapped = True