Skip to content

CanonicalNucleotideAtoms

Module documentation for CanonicalNucleotideAtoms.

API Reference

Nucleotide

Bases: Group

Source code in mrdna/model/CanonicalNucleotideAtoms.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class Nucleotide(Group):
    def __init__(self, children, orientation, sequence, resname, factory):
        Group.__init__(self, children=children, orientation = orientation)
        self.atoms_by_name = {a.name:a for a in self.children}
        self._factory = factory
        self.sequence = sequence
        self.resname = resname
        self._first_atomic_index = 0

    def _get_atomic_index(self, name):
        return self._factory._name_to_idx[name] + self._first_atomic_index

    def get_intrahelical_above(self):
        """ Returns next nucleotide along 5'-to-3' in same strand-side of helix """
        return self.get_intrahelical_nucleotide(1)

    def get_intrahelical_below(self):
        """ Returns last nucleotide along 5'-to-3' in same strand-side of helix """
        return self.get_intrahelical_nucleotide(-1)

    def get_intrahelical_nucleotide(self,offset=1):
        """ Returns nucleotide in same strand-side of helix with some offset along 5'-to-3' """
        from ..segmentmodel import SingleStrandedSegment

        strand_piece = self.parent
        is_fwd = strand_piece.is_fwd
        lo,hi = sorted([strand_piece.start,strand_piece.end])

        if is_fwd:
            nt_idx = strand_piece.children.index(self)+lo + offset
        else:
            nt_idx = hi-strand_piece.children.index(self) - offset


        seg = strand_piece.segment
        if nt_idx < 0 or nt_idx >= seg.num_nt:
            """ Cross intrahelical connections if possible """
            ret = seg._ntpos_to_seg_and_ntpos(nt_idx, is_fwd)
            if ret is None:
                ret = seg._ntpos_to_seg_and_ntpos(nt_idx, is_fwd)
                return None
            else:
                seg, nt_idx, is_fwd = ret
                if isinstance(seg, SingleStrandedSegment):
                    return None
                else:
                    return seg._get_atomic_nucleotide(nt_idx, is_fwd)
        else:
            return seg._get_atomic_nucleotide(nt_idx, is_fwd)

get_intrahelical_above()

Returns next nucleotide along 5'-to-3' in same strand-side of helix

Source code in mrdna/model/CanonicalNucleotideAtoms.py
33
34
35
def get_intrahelical_above(self):
    """ Returns next nucleotide along 5'-to-3' in same strand-side of helix """
    return self.get_intrahelical_nucleotide(1)

get_intrahelical_below()

Returns last nucleotide along 5'-to-3' in same strand-side of helix

Source code in mrdna/model/CanonicalNucleotideAtoms.py
37
38
39
def get_intrahelical_below(self):
    """ Returns last nucleotide along 5'-to-3' in same strand-side of helix """
    return self.get_intrahelical_nucleotide(-1)

get_intrahelical_nucleotide(offset=1)

Returns nucleotide in same strand-side of helix with some offset along 5'-to-3'

Source code in mrdna/model/CanonicalNucleotideAtoms.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def get_intrahelical_nucleotide(self,offset=1):
    """ Returns nucleotide in same strand-side of helix with some offset along 5'-to-3' """
    from ..segmentmodel import SingleStrandedSegment

    strand_piece = self.parent
    is_fwd = strand_piece.is_fwd
    lo,hi = sorted([strand_piece.start,strand_piece.end])

    if is_fwd:
        nt_idx = strand_piece.children.index(self)+lo + offset
    else:
        nt_idx = hi-strand_piece.children.index(self) - offset


    seg = strand_piece.segment
    if nt_idx < 0 or nt_idx >= seg.num_nt:
        """ Cross intrahelical connections if possible """
        ret = seg._ntpos_to_seg_and_ntpos(nt_idx, is_fwd)
        if ret is None:
            ret = seg._ntpos_to_seg_and_ntpos(nt_idx, is_fwd)
            return None
        else:
            seg, nt_idx, is_fwd = ret
            if isinstance(seg, SingleStrandedSegment):
                return None
            else:
                return seg._get_atomic_nucleotide(nt_idx, is_fwd)
    else:
        return seg._get_atomic_nucleotide(nt_idx, is_fwd)