예제 #1
0
    def __call__(self, snv):
        self._clean_filter(snv)
        seq_name = snv.chrom
        seq_ref = self.ref_index[seq_name]
        aminos = None
        try:
            seq_estscan = self.orf_seq_index[seq_name + self.orf_suffix]
        except KeyError:
            return
        try:
            aminos = get_amino_change(seq_ref, seq_estscan, snv)
        except IsIndelError:
            snv.add_filter(self.name)
            snv.add_info(info=self.info_id, value='INDEL')
        except BetweenSegments:
            pass
        except OutsideAlignment:
            pass
        if aminos is None:
            return

        if set(aminos['ref_amino']) != set(aminos['alt_amino']):
            snv.add_filter(self.name)
            info_val = '{}->{}'.format(aminos['ref_amino'],
                                       ','.join(aminos['alt_amino']))
            snv.add_info(info=self.info_id, value=info_val)
예제 #2
0
    def __call__(self, snv):
        self._clean_filter(snv)
        seq_name = snv.chrom
        seq_ref = self.ref_index[seq_name]
        aminos = None
        try:
            seq_estscan = self.orf_seq_index[seq_name + self.orf_suffix]
        except KeyError:
            return
        try:
            aminos = get_amino_change(seq_ref, seq_estscan, snv)
        except IsIndelError:
            snv.add_filter(self.name)
        except BetweenSegments:
            pass
        except OutsideAlignment:
            pass

        if aminos is None:
            return

        ref_aa = aminos['ref_amino']
        alt_aas = aminos['alt_amino']
        if set(ref_aa) == set(alt_aas):
            return snv
        if any([self._is_severe(ref_aa, alt_aa) for alt_aa in alt_aas]):
            snv.add_filter(self.name)
예제 #3
0
    def test_get_aminos(self):
        # test using
        seq_ref = """>SEUC00016_TC01
    CACGCTAAACAACGATCATTGTCATCGGTACCGATTGTTACAAGTTGTGTGCAGTGTCGT
    GCTATTTGTGTGTACATTCCTTCTAAGATGTCGTCAACAAAGTGGTTGGTGTGTGCGCTA
    GTGGTGGTGTGCGTGAGCGTAAGGCAAGCAACATCTGCGCCGGCGCCGCAGGAACAAGAA
    TACCCGCCTATGCCCTACGAGTACAAATATGACGTTGAAGATCAAGAGCTTGAAGAGAAA
    GCTCTCTACTTCGGAGCCAACGAAGCAGGAGATGCCCAGGGCAAGGTCATCGGAGGATAC
    CGAGTTCTCCTCCCCGATGGTCGTCTTATGACCGTCGAGTACAGTGTGGAGGGAGAAAGC
    GGTTTCGTTCCCAAAATCACCTTCGAAGACAACGCCAGCCCCTTCGGCAAAGGAAAGTAG
    ACCTTATAACGACGCCTACAAGACTGGTACCGCGATCAATTGATACTAGTTCAATTTGAT
    TTCTGAATTCTATGCCGTAAAACATTTTCTTTTATTAATTATACCGATTTCGATAAATAG
    ACATCTTTACCTACTTAACGAATTTCTCATAGGATTCAGAAGTCGAAACCGAAAAAAGTT
    ACTTCAGTTTTCATTAGATTGTAAATGTGTGTAAATTATTATTATTATTATATCAGGGAT
    CCTTAAGTTGATATTAGTGGTGATATAAACGATATTTATGAACGACAATCAGGTATCGTC
    ACTGGCTTGAGTAATGTTAGAAAAAATATAATTTTACCGAAAGCATTAGTAACTTTTTTC
    ACGATTATAATCTCCCATACATACTGTATACTTACGTTACGTATAATAATTTTGATTGTC
    TTCATAGTGTACTCTATAATATATGTAGGTGTAGGCAAAACTCATTCGCCAATAAGATAA
    TATGTACAGTCAGCGATTTCTAAGATAAATTTGTACCGCAAATATCGAGTTACCGATACT
    GTGATCAATTAGAACG"""
        orf_seq = """>SEUC00016_TC01_orf_seq start=89 end=421 strand=forward
    ATGTCGTCAACAAAGTGGTTGGTGTGTGCGCTAGTGGTGGTGTGCGTGAGCGTAAGGCAAGCAACATCTGCGCC
    GGCGCCGCAGGAACAAGAATACCCGCCTATGCCCTACGAGTACAAATATGACGTTGAAGATCAAGAGCTTGAAG
    AGAAAGCTCTCTACTTCGGAGCCAACGAAGCAGGAGATGCCCAGGGCAAGGTCATCGGAGGATACCGAGTTCTC
    CTCCCCGATGGTCGTCTTATGACCGTCGAGTACAGTGTGGAGGGAGAAAGCGGTTTCGTTCCCAAAATCACCTT
    CGAAGACAACGCCAGCCCCTTCGGCAAAGGAAAGTAG"""
        seq_ref = StringIO(seq_ref)
        orf_seq = StringIO(orf_seq)
        seq_ref = SeqIO.read(seq_ref, "fasta")
        orf_seq = SeqIO.read(orf_seq, "fasta")

        record = FakeClass()
        record.is_indel = False
        record.pos = 111
        record.alleles = ["T", "C"]
        aminos = get_amino_change(seq_ref, orf_seq, record)
        assert aminos == {"ref_amino": "C", "alt_amino": ["R"]}

        record = FakeClass()
        record.is_indel = True
        record.pos = 110
        try:
            aminos = get_amino_change(seq_ref, orf_seq, record)
            raise RuntimeError("We should not reach here")
        except IsIndelError:
            pass

        record = FakeClass()
        record.is_indel = False
        record.pos = 111
        record.alleles = ["T", "C", "A"]
        aminos = get_amino_change(seq_ref, orf_seq, record)
        assert aminos == {"ref_amino": "C", "alt_amino": ["R", "S"]}

        # Outside orf
        seq_ref = "ATCTAGGCTGCTACGATTAGCTGACGATGTTATCGTAGATCTAGCTGATCATCTAGCT"
        seq_ref += "GATCG"
        orf_seq = "AGGCTCTACGATTAGCTGATCGATGTTATC"
        seq_ref = SeqRecord(seq=Seq(seq_ref), id="ref")
        orf_seq = SeqRecord(seq=Seq(orf_seq), id="orf")
        record = FakeClass()
        record.is_indel = False
        record.pos = 34
        record.alleles = ["G", "C"]

        try:
            aminos = get_amino_change(seq_ref, orf_seq, record)
            self.fail()
        except OutsideAlignment:
            pass

        # frameshift
        record = FakeClass()
        record.is_indel = False
        record.pos = 9
        record.alleles = ["G", "C"]
        try:
            aminos = get_amino_change(seq_ref, orf_seq, record)
            self.fail()
        except BetweenSegments:
            pass