Exemplo n.º 1
0
 def align_pose_at_position1_sheffler(self, pose_move, pose_ref,
                                      position_move, position_ref):
     stubs_ref = rcl.bbstubs(
         pose_ref, [position_ref])['raw']  # gets 'stub' for reslist
     stubs_move = rcl.bbstubs(
         pose_move, [position_move])['raw']  # raw field is position matrix
     # PRINTDBG(stubs_ref.shape)  # h**o coords numpy array n x 4 x 4
     # PRINTDBG(stubs_move.shape)
     # a @ b is np.matmul(a, b)
     xalign = stubs_ref @ np.linalg.inv(stubs_move)
     # PRINTDBG(xalign.shape)
     rcl.xform_pose(xalign[0], pose_move)
Exemplo n.º 2
0
def main():
    pose1 = poselib.c1
    pose2 = poselib.c2

    stubs1 = rcl.bbstubs(pose1, [len(pose1)])['raw']  # gets 'stub' for reslist
    stubs2 = rcl.bbstubs(pose2, [1])['raw']  # raw field is position matrix
    print(stubs1.shape)  # h**o coords numpy array n x 4 x 4
    print(stubs2.shape)
    xalign = stubs1 @ np.linalg.inv(stubs2)  # a @ b is np.matmul(a, b)
    print(xalign.shape)
    rcl.xform_pose(xalign[0], pose2)

    # append residues 2-7 of pose2 to pose1
    # note: O and H positions may be f****d up...
    # not sure easiest way to fix... cart min?
    rosetta.core.pose.remove_upper_terminus_type_from_pose_residue(
        pose1, len(pose1))
    rosetta.core.pose.append_subpose_to_pose(pose1, pose2, 2, 7)
Exemplo n.º 3
0
Arquivo: worm.py Projeto: uw-ipd/rif
def _cyclic_permute_chains(chainslist, polarity, spliceres):
    rm_lower_t = ros.core.pose.remove_lower_terminus_type_from_pose_residue
    rm_upper_t = ros.core.pose.remove_upper_terminus_type_from_pose_residue
    beg, end = chainslist[0], chainslist[-1]
    n2c = polarity == 'N'
    if n2c:
        stub1 = rcl.bbstubs(beg[0], [spliceres])
        stub2 = rcl.bbstubs(end[-1], [len(end[-1])])
        beg[0] = rcl.subpose(beg[0], spliceres + 1, len(beg[0]))
        rm_lower_t(beg[0], 1)
        rm_upper_t(end[-1], len(end[-1]))
    else:
        stub1 = rcl.bbstubs(beg[-1], [spliceres])
        stub2 = rcl.bbstubs(end[0], [1])
        beg[-1] = rcl.subpose(beg[-1], 1, spliceres - 1)
        rm_lower_t(beg[-1], len(beg[-1]))
        rm_upper_t(end[0], 1)
    xalign = stub1['raw'][0] @ np.linalg.inv(stub2['raw'][0])
    for p in end: rcl.xform_pose(xalign, p)
    if n2c: chainslist[0] = end + beg
    else: chainslist[0] = beg + end
    chainslist = chainslist[:-1]
Exemplo n.º 4
0
Arquivo: worm.py Projeto: uw-ipd/rif
 def pose(self, which, *, align=True, end=None, join=True,
          only_connected=None, cyclic_permute=False, provenance=False,
          **kw):
     "makes a pose for the ith worm"
     if isinstance(which, Iterable): return (
         self.pose(w, align=align, end=end, join=join,
                   only_connected=only_connected, **kw)
         for w in which)
     # print("Will needs to fix bb O/H position!")
     rm_lower_t = ros.core.pose.remove_lower_terminus_type_from_pose_residue
     rm_upper_t = ros.core.pose.remove_upper_terminus_type_from_pose_residue
     if end is None:
         end = not self.criteria.is_cyclic
     if only_connected is None:
         only_connected = not self.criteria.is_cyclic
     if cyclic_permute is None:
         cyclic_permute = self.criteria.is_cyclic
     elif cyclic_permute and not self.criteria.is_cyclic:
         raise ValueError('cyclic_permute should only be used for Cyclic')
     iend = None if end else -1
     entryexits = [seg.make_pose_chains(self.indices[which][iseg],
                                        self.positions[which][iseg])
                   for iseg, seg in enumerate(self.segments[:iend])]
     entryexits, rest = zip(*entryexits)
     chainslist = reorder_spliced_as_N_to_C(
         entryexits, [s.entrypol for s in self.segments[1:iend]])
     if align:
         x = self.criteria.alignment(segpos=self.positions[which], **kw)
         for p in it.chain(*chainslist, *rest): rcl.xform_pose(x, p[0])
     if cyclic_permute and len(chainslist) > 1:
         # todo: this is only correct if 1st seg is one chain
         spliceres = self.segments[-1].entryresid[self.indices[which, -1]]
         bodyid = self.segments[0].bodyid[self.indices[which, 0]]
         origlen = len(self.segments[0].spliceables[bodyid].body)
         i = -1 if self.segments[-1].entrypol == 'C' else 0
         spliceres -= origlen - len(chainslist[0][0][i])
         _cyclic_permute_chains(chainslist, self.segments[-1].entrypol,
                                spliceres + 1)
     sourcelist = [[x[1] for x in c] for c in chainslist]
     chainslist = [[x[0] for x in c] for c in chainslist]
     pose = ros.core.pose.Pose()
     prov0 = []
     splicepoints = []
     for chains, sources in zip(chainslist, sourcelist):
         if only_connected and len(chains) is 1: continue
         ros.core.pose.append_pose_to_pose(pose, chains[0], True)
         prov0.append(sources[0])
         for chain, source in zip(chains[1:], sources[1:]):
             assert isinstance(chain, ros.core.pose.Pose)
             rm_upper_t(pose, len(pose))
             rm_lower_t(chain, 1)
             splicepoints.append(len(pose))
             ros.core.pose.append_pose_to_pose(pose, chain, not join)
             prov0.append(source)
     self.splicepoint_cache[which] = splicepoints
     if not only_connected:
         for chain, source in it.chain(*rest):
             assert isinstance(chain, ros.core.pose.Pose)
             ros.core.pose.append_pose_to_pose(pose, chain, True)
             prov0.append(source)
     assert rcl.worst_CN_connect(pose) < 0.5
     if not provenance: return pose
     prov = []
     for i, pr in enumerate(prov0):
         psrc, lb0, ub0 = pr
         lb1 = sum(ub - lb + 1 for _, lb, ub in prov0[:i]) + 1
         ub1 = lb1 + ub0 - lb0
         assert ub0 - lb0 == ub1 - lb1
         assert 0 < lb0 <= len(psrc) and 0 < ub0 <= len(psrc)
         assert 0 < lb1 <= len(pose) and 0 < ub1 <= len(pose)
         assert psrc.sequence()[lb0 - 1:ub0] == pose.sequence()[lb1 - 1:ub1]
         prov.append((lb1, ub1, psrc, lb0, ub0))
     return pose, prov