예제 #1
0
def make_paired_bnd_records(record, ref_fasta):
    chr2 = record.info['CHR2']
    if 'END2' in record.info.keys():
        end2 = record.info['END2']
    elif record.contig == record.info['CHR2']:
        end2 = record.pos + record.info['SVLEN']

    orig_id = record.id
    new_id = orig_id + "_M1"
    mate_id = orig_id + "_M2"
    strands = record.info['STRANDS']

    alt1 = svu.make_bnd_alt(chr2, end2, strands, ref_base=record.ref)
    record.alts = (alt1, )
    record.id = new_id
    record.info['MATEID'] = mate_id
    record.info.pop('CHR2')
    if 'END2' in record.info.keys():
        record.info.pop('END2')
    record.info.pop('SVLEN')

    mate_record = record.copy()
    mate_record.id = mate_id
    mate_record.contig = chr2
    mate_record.pos = int(end2)
    mate_record.ref = get_ref_base(chr2, int(end2), ref_fasta)
    mate_record.info['MATEID'] = new_id
    # strands are reversed for the mate BND
    mate_strands = strands[::-1]
    mate_alt = svu.make_bnd_alt(record.contig, record.pos, mate_strands, ref_base=mate_record.ref)
    mate_record.alts = (mate_alt, )
    return record, mate_record
예제 #2
0
    def standardize_alts(self, std_rec, raw_rec):
        """
        Standardize ALT field.

        Default behavior is to standardize BND alt to VCF spec and leave
        other SVTYPE alts untouched.
        """

        # Standardize tloc ALT after SVTYPE and CHR2/END are standardized
        if std_rec.info['SVTYPE'] == 'BND':
            alt = make_bnd_alt(std_rec.info['CHR2'], std_rec.stop,
                               std_rec.info['STRANDS'])
            stop = std_rec.stop
            std_rec.alts = (alt, )
            std_rec.stop = stop

        return std_rec
예제 #3
0
def make_reciprocal_translocation_bnds(record, ref_fasta):
    chr1 = record.contig
    chr1_pos1 = record.pos
    chr1_pos1_ref = get_ref_base(chr1, chr1_pos1, ref_fasta)
    chr1_pos2 = chr1_pos1 + 1
    chr1_pos2_ref = get_ref_base(chr1, chr1_pos2, ref_fasta)
    chr2 = record.info['CHR2']
    if 'END2' in record.info.keys():
        chr2_pos1 = int(record.info['END2'])
    else:
        chr2_pos1 = record.stop
    chr2_pos1_ref = get_ref_base(chr2, chr2_pos1, ref_fasta)
    chr2_pos2 = chr2_pos1 + 1
    chr2_pos2_ref = get_ref_base(chr2, chr2_pos2, ref_fasta)

    orig_id = record.id
    m1_id = orig_id + "_M1" # M1: chr1P->chr2 on chr1
    m2_id = orig_id + "_M2" # M2: chr1P->chr2 on chr2
    m3_id = orig_id + "_M3" # M3: chr1Q->chr2 on chr1
    m4_id = orig_id + "_M4" # M3: chr1Q->chr2 on chr2

    event_id = orig_id

    if record.info['CPX_TYPE'] == "CTX_PQ/QP":
        strands_m1 = '+-'
        strands_m2 = '-+'
        strands_m3 = '-+'
        strands_m4 = '+-'
        m1_pos1 = chr1_pos1
        m1_ref = chr1_pos1_ref
        m1_pos2 = chr2_pos2
        m2_pos1 = chr2_pos2
        m2_ref = chr2_pos2_ref
        m2_pos2 = chr1_pos1
        m3_pos1 = chr1_pos2
        m3_ref = chr1_pos2_ref
        m3_pos2 = chr2_pos2
        m4_pos1 = chr2_pos1
        m4_ref = chr1_pos1_ref
        m4_pos2 = chr1_pos1
    elif record.info['CPX_TYPE'] == "CTX_PP/QQ":
        strands_m1 = '++'
        strands_m2 = '++'
        strands_m3 = '--'
        strands_m4 = '--'
        m1_pos1 = chr1_pos1
        m1_ref = chr1_pos1_ref
        m1_pos2 = chr2_pos1
        m2_pos1 = chr2_pos1
        m2_ref = chr2_pos1_ref
        m2_pos2 = chr1_pos1
        m3_pos1 = chr1_pos2
        m3_ref = chr1_pos2_ref
        m3_pos2 = chr2_pos2
        m4_pos1 = chr2_pos2
        m4_ref = chr2_pos2_ref
        m4_pos2 = chr1_pos2

    record.info['EVENT'] = event_id
    record.info['SVTYPE'] = 'BND'
    record.info.pop('CHR2')
    record.info.pop('SVLEN')

    m1 = record.copy()
    m1.id = m1_id
    m1.contig = chr1
    m1.pos = m1_pos1
    m1.stop = m1_pos1 + 1
    m1.ref = m1_ref
    m1.alts = (svu.make_bnd_alt(chr2, m1_pos2, strands_m1, ref_base=m1.ref), )
    m1.info['MATEID'] = m2_id

    m2 = record.copy()
    m2.id = m2_id
    m2.contig = chr2
    m2.pos = m2_pos1
    m2.stop = m2_pos1 + 1
    m2.ref = m2_ref
    m2.alts = (svu.make_bnd_alt(chr1, m2_pos2, strands_m2, ref_base=m2.ref), )
    m2.info['MATEID'] = m2_id

    m3 = record.copy()
    m3.id = m3_id
    m3.contig = chr1
    m3.pos = m3_pos1
    m3.stop = m3_pos1 + 1
    m3.ref = m3_ref
    m3.alts = (svu.make_bnd_alt(chr2, m3_pos2, strands_m3, ref_base=m3.ref), )
    m3.info['MATEID'] = m4_id

    m4 = record.copy()
    m4.id = m4_id
    m4.contig = chr2
    m4.pos = m4_pos1
    m4.stop = m4_pos1 + 1
    m4.ref = m4_ref
    m4.alts = (svu.make_bnd_alt(chr1, m4_pos2, strands_m4, ref_base=m4.ref), )
    m4.info['MATEID'] = m3_id

    return m1, m2, m3, m4