Пример #1
0
    def _postProcess(self, baseList):
        """
        Final tweaks on the DNA chunk, including:

          - Transmute Ax3 atoms on each end into Ae3.
          - Adjust open bond singlets.

        @param baseList: List of basepair chunks that make up the duplex.
        @type  baseList: list

        @note: baseList must contain at least two base-pair chunks.
        """

        if len(baseList) < 1:
            print_compact_stack("bug? (ignoring) DnaDuplex._postProcess called but "\
                                "baseList is empty. Maybe dna_updater was "\
                                "run?: ")
            return

        start_basepair_atoms = baseList[0].atoms.values()
        end_basepair_atoms = baseList[-1].atoms.values()

        Ax_caps = filter( lambda atom: atom.element.symbol in ('Ax3'), 
                          start_basepair_atoms)
        Ax_caps += filter( lambda atom: atom.element.symbol in ('Ax3'), 
                           end_basepair_atoms)

        # Transmute Ax3 caps to Ae3 atoms. 
        # Note: this leaves two "killed singlets" hanging around,  
        #       one from each Ax3 cap.
        #
        # REVIEW: is it safe to simply not do this when dna_updater_is_enabled()?
        # [bruce 080320 question]
        for atom in Ax_caps:
            atom.Transmute(Element_Ae3)

        # X_List will contain 6 singlets, 2 of which are killed (non-bonded).
        # The other 4 are the 2 pair of strand open bond singlets.
        X_List = filter( lambda atom: atom.element.symbol in ('X'), 
                         start_basepair_atoms)
        X_List += filter( lambda atom: atom.element.symbol in ('X'), 
                          end_basepair_atoms)

        # Adjust the 4 open bond singlets.
        for singlet in X_List:
            if singlet.killed():
                # Skip the 2 killed singlets.
                continue
            adjustSinglet(singlet)


        return
Пример #2
0
    def _postProcess(self, baseList):
        """
        Final tweaks on the DNA chunk, including:

          - Transmute Ax3 atoms on each end into Ae3.
          - Adjust open bond singlets.

        @param baseList: List of basepair chunks that make up the duplex.
        @type  baseList: list

        @note: baseList must contain at least two base-pair chunks.
        """

        if len(baseList) < 1:
            print_compact_stack("bug? (ignoring) DnaDuplex._postProcess called but "\
                                "baseList is empty. Maybe dna_updater was "\
                                "run?: ")
            return

        start_basepair_atoms = baseList[0].atoms.values()
        end_basepair_atoms = baseList[-1].atoms.values()

        Ax_caps = filter(lambda atom: atom.element.symbol in ('Ax3'),
                         start_basepair_atoms)
        Ax_caps += filter(lambda atom: atom.element.symbol in ('Ax3'),
                          end_basepair_atoms)

        # Transmute Ax3 caps to Ae3 atoms.
        # Note: this leaves two "killed singlets" hanging around,
        #       one from each Ax3 cap.
        #
        # REVIEW: is it safe to simply not do this when dna_updater_is_enabled()?
        # [bruce 080320 question]
        for atom in Ax_caps:
            atom.Transmute(Element_Ae3)

        # X_List will contain 6 singlets, 2 of which are killed (non-bonded).
        # The other 4 are the 2 pair of strand open bond singlets.
        X_List = filter(lambda atom: atom.element.symbol in ('X'),
                        start_basepair_atoms)
        X_List += filter(lambda atom: atom.element.symbol in ('X'),
                         end_basepair_atoms)

        # Adjust the 4 open bond singlets.
        for singlet in X_List:
            if singlet.killed():
                # Skip the 2 killed singlets.
                continue
            adjustSinglet(singlet)

        return
Пример #3
0
    def makeStrandChunkFromBrokenStrand(self, x1, x2): # by Mark
        """
        Makes a new strand chunk using the two singlets just created by
        busting the original strand, which is now broken. If the original
        strand was a ring, no new chunk is created.

        The new strand chunk, which includes the atoms between the 3' end of
        the original strand and the new 5' end (i.e. the break point), is
        added to the same DNA group as the original strand and assigned a
        different color.

        @param x1: The first of two singlets created by busting a strand
                   backbone bond. It is either the 3' or 5' open bond singlet,
                   but we don't know yet.
        @type  x1: L{Atom}

        @param x2: The second of two singlets created by busting a backbone
                   backbone bond. It is either the 3' or 5' open bond singlet,
                   but we don't know yet.
        @type  x2: L{Atom}

        @return: The new strand chunk. Returns B{None} if no new strand chunk
                 is created, as is the case of a ring.
        @rtype:  L{Chunk}
        """
        minimize = debug_pref("Adjust broken strand bondpoints using minimizer?",
                          #bruce 080415 revised text (to not use the developer-
                          # jargon-only term "singlet"), changed prefs_key,
                          # and removed non_debug = True, for .rc2 release,
                          # since the repositioning bug this worked around
                          # is now fixed.
                         Choice_boolean_False,
                         prefs_key = True,
                    )

        _five_prime_atom = None
        _three_prime_atom = None

        for singlet in (x1, x2):
            adjustSinglet(singlet, minimize = minimize)
            open_bond = singlet.bonds[0]
            if open_bond.isFivePrimeOpenBond():
                _five_prime_atom = open_bond.other(singlet)
            else:
                _three_prime_atom = open_bond.other(singlet)

        # Make sure we have exactly one 3' and one 5' singlet.
        # If not, there is probably a direction error on the open bond(s)
        # that x1 and/or x2 are members of.
        if not _five_prime_atom:
            print_compact_stack("No 5' bondpoint.")
            return None
        if not _three_prime_atom:
            print_compact_stack("No 3' bondpoint.")
            return None

        atomList = self.o.assy.getConnectedAtoms([_five_prime_atom])

        if _three_prime_atom in atomList:
            # The strand was a closed loop strand, so we're done.
            return None # Since no new chunk was created.

        # See self.ensure_toplevel_group() docstring for explanation.
        self.ensure_toplevel_group()
        _group_five_prime_was_in = _five_prime_atom.molecule.dad
        if env.prefs[assignColorToBrokenDnaStrands_prefs_key]:
            _new_strand_color = getNextStrandColor(_five_prime_atom.molecule.color)
        else:
            _new_strand_color = _five_prime_atom.molecule.color
        return self.makeChunkFromAtomList(atomList,
                                          group = _group_five_prime_was_in,
                                          name = gensym("Strand"),
                                              # doesn't need "DnaStrand" or self.assy,
                                              # since not normally seen by users
                                              # [bruce 080407 comment]
                                          color = _new_strand_color)
Пример #4
0
    def makeStrandChunkFromBrokenStrand(self, x1, x2):  # by Mark
        """
        Makes a new strand chunk using the two singlets just created by
        busting the original strand, which is now broken. If the original
        strand was a ring, no new chunk is created.
        
        The new strand chunk, which includes the atoms between the 3' end of
        the original strand and the new 5' end (i.e. the break point), is 
        added to the same DNA group as the original strand and assigned a 
        different color.
        
        @param x1: The first of two singlets created by busting a strand
                   backbone bond. It is either the 3' or 5' open bond singlet,
                   but we don't know yet.
        @type  x1: L{Atom}
        
        @param x2: The second of two singlets created by busting a backbone
                   backbone bond. It is either the 3' or 5' open bond singlet,
                   but we don't know yet.
        @type  x2: L{Atom}
        
        @return: The new strand chunk. Returns B{None} if no new strand chunk
                 is created, as is the case of a ring.
        @rtype:  L{Chunk}
        """
        minimize = debug_pref(
            "Adjust broken strand bondpoints using minimizer?",
            #bruce 080415 revised text (to not use the developer-
            # jargon-only term "singlet"), changed prefs_key,
            # and removed non_debug = True, for .rc2 release,
            # since the repositioning bug this worked around
            # is now fixed.
            Choice_boolean_False,
            prefs_key=True,
        )

        _five_prime_atom = None
        _three_prime_atom = None

        for singlet in (x1, x2):
            adjustSinglet(singlet, minimize=minimize)
            open_bond = singlet.bonds[0]
            if open_bond.isFivePrimeOpenBond():
                _five_prime_atom = open_bond.other(singlet)
            else:
                _three_prime_atom = open_bond.other(singlet)

        # Make sure we have exactly one 3' and one 5' singlet.
        # If not, there is probably a direction error on the open bond(s)
        # that x1 and/or x2 are members of.
        if not _five_prime_atom:
            print_compact_stack("No 5' bondpoint.")
            return None
        if not _three_prime_atom:
            print_compact_stack("No 3' bondpoint.")
            return None

        atomList = self.o.assy.getConnectedAtoms([_five_prime_atom])

        if _three_prime_atom in atomList:
            # The strand was a closed loop strand, so we're done.
            return None  # Since no new chunk was created.

        # See self.ensure_toplevel_group() docstring for explanation.
        self.ensure_toplevel_group()
        _group_five_prime_was_in = _five_prime_atom.molecule.dad
        if env.prefs[assignColorToBrokenDnaStrands_prefs_key]:
            _new_strand_color = getNextStrandColor(
                _five_prime_atom.molecule.color)
        else:
            _new_strand_color = _five_prime_atom.molecule.color
        return self.makeChunkFromAtomList(
            atomList,
            group=_group_five_prime_was_in,
            name=gensym("Strand"),
            # doesn't need "DnaStrand" or self.assy,
            # since not normally seen by users
            # [bruce 080407 comment]
            color=_new_strand_color)