Ejemplo n.º 1
0
    def calc_superposition(self, tls):
        plist = []
        msd = 0.0
        segment = tls.segment

        for frag1 in segment.iter_fragments():
            try:
                frag2 = self.srctgt_equiv[frag1]
            except KeyError:
                continue
            for name in const.SUPER_ATOMS:
                atm1 = frag1.get_atom(name)
                atm2 = frag2.get_atom(name)
                if atm1 == None or atm2 == None:
                    console.stdoutln("EEK! No Equivalent Atom %s" % (atm1))
                    continue
                plist.append((atm1.position, atm2.align_position))
                d = atm1.position - atm2.align_position
                msd += numpy.dot(d, d)

        rmsd_pre_alignment = math.sqrt(msd / len(plist))
        tls.rmsd_pre_alignment = rmsd_pre_alignment

        sresult = Superposition.SuperimposePositions(plist)
        tls.sresult = sresult

        rotation = math.degrees(2.0 * math.acos(sresult.Q[0]))
        if rotation > 180.0:
            rotation = 360.0 - rotation

        fragstr = "%s:%s-%s" % (self.chain.chain_id, tls.frag_id1,
                                tls.frag_id2)
        console.stdoutln(
            "TLS Group::%20s  Num Atoms::%4d  RMSD PRE ALIGN::%6.2f  RMSD::%6.2f  TRANSORM ROTATION::%6.2f"
            %
            (fragstr, len(plist), rmsd_pre_alignment, sresult.rmsd, rotation))

        ## screw displacement vector
        vscrew = AtomMath.normalize(
            numpy.array([sresult.Q[1], sresult.Q[2], sresult.Q[3]], float))
        console.stdoutln("superposition rotation vector: %s" % (vscrew))
        tls.superposition_vscrew = vscrew * rotation

        ## fit the isotropic TLS model to the group
        evals, evecs = numpy.linalg.eig(tls.tls_group.itls_L)

        for i in (0, 1, 2):
            eval = evals[i]
            evec = evecs[i]

            lname = "L%d_eigen_val" % (i)

            if (eval * Constants.RAD2DEG2) < 1.0:
                continue

            ang = min(calc_angle(evec, vscrew), calc_angle(-evec, vscrew))

            console.stdoutln("%s  magnitude::%6.2f  vector angle::%6.2f" %
                             (lname, eval * Constants.RAD2DEG2, ang))
Ejemplo n.º 2
0
    def calc_superposition(self, tls):
        plist = []
        msd = 0.0
        segment = tls.segment

        for frag1 in segment.iter_fragments():
            try:
                frag2 = self.srctgt_equiv[frag1]
            except KeyError:
                continue
            for name in SUPER_ATOMS:
                atm1 = frag1.get_atom(name)
                atm2 = frag2.get_atom(name)
                if atm1 == None or atm2 == None:
                    console.stdoutln("EEK! No Equivalent Atom %s" % (atm1))
                    continue
                plist.append((atm1.position, atm2.align_position))
                d = atm1.position - atm2.align_position
                msd += numpy.dot(d,d)
                    
        rmsd_pre_alignment = math.sqrt(msd / len(plist))
        tls.rmsd_pre_alignment = rmsd_pre_alignment

        sresult = Superposition.SuperimposePositions(plist)
        tls.sresult = sresult

        rotation = math.degrees(2.0 * math.acos(sresult.Q[0]))
        if rotation > 180.0:
            rotation = 360.0 - rotation

        fragstr = "%s:%s-%s" % (self.chain.chain_id, tls.frag_id1, tls.frag_id2)
        console.stdoutln(
            "TLS Group::%20s  Num Atoms::%4d  RMSD PRE ALIGN::%6.2f  RMSD::%6.2f  TRANSORM ROTATION::%6.2f" % (
            fragstr, len(plist), rmsd_pre_alignment, sresult.rmsd, rotation))

        ## screw displacement vector
        vscrew = AtomMath.normalize(numpy.array([sresult.Q[1],sresult.Q[2],sresult.Q[3]], float))
        console.stdoutln("superposition rotation vector: %s" % (vscrew))
        tls.superposition_vscrew = vscrew * rotation

        ## fit the isotropic TLS model to the group
        evals, evecs = numpy.linalg.eig(tls.tls_group.itls_L)

        for i in (0,1,2):
            eval = evals[i]
            evec = evecs[i]
            
            lname = "L%d_eigen_val" % (i)

            if (eval * Constants.RAD2DEG2) < 1.0:
                continue

            ang = min(calc_angle(evec, vscrew), calc_angle(-evec, vscrew))

            console.stdoutln("%s  magnitude::%6.2f  vector angle::%6.2f" % (
                lname, eval*Constants.RAD2DEG2, ang))
Ejemplo n.º 3
0
def random_vec():
    rcoord = lambda: random.random() - 0.5
    return AtomMath.normalize(numpy.array([rcoord(), rcoord(), rcoord()], float))