Exemplo n.º 1
0
def main():
    usage = './stem_distances.py temp.comp'
    usage += """
    List the distances between stems.
    """

    parser = OptionParser(usage=usage)

    #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str')
    #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option')

    (options, args) = parser.parse_args()

    if len(args) < 1:
        parser.print_help()
        sys.exit(1)

    bg = ttmc.CoarseGrainRNA(args[0])

    for (s1, s2) in it.combinations(bg.stems(), 2):

        adjacent = 0
        if bg.are_any_adjacent_stems(s1, s2):
            adjacent = 1

        closest_points = cuv.line_segment_distance(bg.coords[s1][0],
                                                   bg.coords[s1][1],
                                                   bg.coords[s2][0],
                                                   bg.coords[s2][1])

        closest_distance = cuv.magnitude(closest_points[1] - closest_points[0])
        print "stem", closest_distance, adjacent, s1, s2
Exemplo n.º 2
0
def main():
    parser = OptionParser()

    #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str')
    #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option')

    (options, args) = parser.parse_args()

    if len(args) < 1:
        print >> sys.stderr, "Usage: ./stem_angles.py temp.comp"
        print >> sys.stderr, "Print the angles between the stems in temp.comp"
        sys.exit(1)

    bg = ttmc.CoarseGrainRNA(args[0])

    stems = [d for d in bg.defines.keys() if d[0] == 's']

    for i in xrange(len(stems)):
        for j in xrange(i + 1, len(stems)):
            #p1 = bg.get_point[stems[i]]
            #p2 = bg.get_point[stems[j]]

            if len(bg.edges[stems[i]].intersection(bg.edges[stems[j]])) > 0:
                print bg.name, stems[i], stems[j], bg.get_stem_angle(
                    stems[i], stems[j])
Exemplo n.º 3
0
def main():
    usage = './bg_rmsd.py s1.coord s2.coord'
    parser = OptionParser()

    #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str')
    #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option')

    (options, args) = parser.parse_args()

    if len(args) < 2:
        parser.print_help()
        sys.exit(1)

    bg1 = ttmc.CoarseGrainRNA(args[0])
    bg2 = ttmc.CoarseGrainRNA(args[1])

    r1 = cgg.bg_virtual_residues(bg1)
    r2 = cgg.bg_virtual_residues(bg2)

    print cbr.centered_rmsd(r1, r2)
Exemplo n.º 4
0
def main():
    parser = OptionParser()

    #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str')
    #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option')

    (options, args) = parser.parse_args()

    if len(args) < 1:
        print >> sys.stderr, "./graph_to_json temp.graph"
        sys.exit(1)

    bg = ttmc.CoarseGrainRNA(args[0])
    json_str = cvf.convert_graph_to_fancy_json(bg)
    print json_str
Exemplo n.º 5
0
def main():
    if len(sys.argv) < 3:
        print "Usage: ./graph_to_simplified_pymol.py struct.graph pdb_file"
        sys.exit(1)

    pdb_name = sys.argv[2]
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        s = PDBParser().get_structure('temp', pdb_name)
        chain = list(s.get_chains())[0]

    bg = ttmc.CoarseGrainRNA(sys.argv[1])

    cgg.add_stem_information_from_pdb_chain(bg, chain)
    bg.add_bulge_coords_from_stems()
    cgg.add_loop_information_from_pdb_chain(bg, chain)

    bg.dump()
Exemplo n.º 6
0
def main():
    if len(sys.argv) < 3:
        print "Usage: ./graph_to_pymol.py struct.graph coarse_grain.py"
        print
        print "Traverse a structure and color the stems that are connected by a bulge"
        sys.exit(1)

    print "hide all"
    print "show sticks, all"
    print "show cartoon, all"
    print "set cartoon_ring_mode"
    print "set cartoon_tube_radius, .3"

    bg = ttmc.CoarseGrainRNA(sys.argv[1])
    print "hide all"
    color_stems(bg)
    hide_stems(bg)
    print "run %s" % (sys.argv[2])
    print "show cartoon, temp"
    print "orient"
Exemplo n.º 7
0
def main():
    usage = './bounding_box_coords.py temp.comp temp.pdb'
    usage += "Print out the coordinates of two diagonal corners of the"
    usage += 'bounding box of each stem nucleotide in the pdb file.'
    parser = OptionParser()

    #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str')
    parser.add_option('-e',
                      '--edge',
                      dest='edge',
                      default=False,
                      action='store_true',
                      help='Include the edge nucleotides in the statistics.')
    parser.add_option('-p',
                      '--pymol',
                      dest='pymol',
                      default=False,
                      action='store_true',
                      help='Output in pymol cgo format.')
    parser.add_option(
        '-a',
        '--averages',
        dest='averages',
        default=False,
        action='store_true',
        help='Output the average coordinates of the bounding boxes')

    (options, args) = parser.parse_args()

    if len(args) < 2:
        parser.print_help()
        sys.exit(1)

    chain = list(bp.PDBParser().get_structure('temp', args[1]).get_chains())[0]
    bg = ttmc.CoarseGrainRNA(args[0])

    pp = cvp.PymolPrinter()
    pp.draw_axes = True
    all_corners = []

    for s in bg.stems():
        for i in range(bg.stem_length(s)):
            if i == 0 or i == bg.stem_length(s) - 1:
                if options.edge:
                    pass
                else:
                    continue

            (origin, basis, corners) = cgg.bounding_boxes(bg, chain, s, i)
            all_corners += [corners]

            if options.pymol:
                pp.add_sphere(corners[0][0], 'yellow', 0.1, '',
                              [238 / 255., 221 / 255., 130 / 255.])
                pp.add_sphere(corners[0][1], 'yellow', 0.1, '',
                              [184 / 255., 134 / 255., 11 / 255.])

                pp.add_sphere(corners[1][0], 'purple', 0.1, '',
                              [238 / 255., 130 / 255., 238 / 255.])
                pp.add_sphere(corners[1][1], 'purple', 0.1, '',
                              [208 / 255., 32 / 255., 144 / 255.])
            else:
                print '0', '0', " ".join(map(str, corners[0][0]))
                print '0', '1', " ".join(map(str, corners[0][1]))
                print '1', '0', " ".join(map(str, corners[1][0]))
                print '1', '1', " ".join(map(str, corners[1][1]))

    if options.averages:
        all_corners = np.array(all_corners)
        print '--averages--'
        print '0', '0', " ".join(
            map(str, np.mean(np.array([c[0][0] for c in all_corners]),
                             axis=0)))
        print '0', '1', " ".join(
            map(str, np.mean(np.array([c[0][1] for c in all_corners]),
                             axis=0)))
        print '1', '0', " ".join(
            map(str, np.mean(np.array([c[1][0] for c in all_corners]),
                             axis=0)))
        print '1', '1', " ".join(
            map(str, np.mean(np.array([c[1][1] for c in all_corners]),
                             axis=0)))

    if options.pymol:
        pp.output_pymol_file()
Exemplo n.º 8
0
def main():
    usage = './virtual_res_distances temp.comp'
    usage += """
    List the distances between each virtual residue in the structure.
    """

    parser = OptionParser(usage=usage)

    #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str')
    #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option')

    (options, args) = parser.parse_args()

    if len(args) < 1:
        parser.print_help()
        sys.exit(1)

    bg = ttmc.CoarseGrainRNA(args[0])
    bg.calc_bp_distances()
    stems = bg.stems()
    adjacent = 0

    mult = 7.

    for (s1, s2) in it.combinations(bg.stems(), 2):
        s1_len = bg.stem_length(s1)
        s2_len = bg.stem_length(s2)

        adjacent = 0

        if bg.are_any_adjacent_stems(s1, s2):
            adjacent = 1

        for k in range(s1_len):
            for l in range(s2_len):
                (v1_p, v1_v, v1_l, v1_r) = cgg.virtual_res_3d_pos(bg, s1, k)
                (v2_p, v2_v, v2_l, v2_r) = cgg.virtual_res_3d_pos(bg, s2, l)

                closest_points = cuv.line_segment_distance(
                    v1_p, v1_p + mult * v1_v, v2_p, v2_p + mult * v2_v)

                closest_distance = cuv.magnitude(closest_points[1] -
                                                 closest_points[0])
                vres_distance = bg.calc_vres_distance(s1, k, s2, l)

                print "dist:", cuv.magnitude(
                    (v2_p + mult * v2_v) - (v1_p + mult * v1_v)
                ), closest_distance, adjacent, s1, k, s2, l, vres_distance

            for l in range(k + 1, s1_len):
                (v1_p, v1_v, v1_l, v1_r) = cgg.virtual_res_3d_pos(bg, s1, k)
                (v2_p, v2_v, v2_l, v2_r) = cgg.virtual_res_3d_pos(bg, s2, l)

                closest_points = cuv.line_segment_distance(
                    v1_p, v1_p + mult * v1_v, v2_p, v2_p + mult * v2_v)

                closest_distance = cuv.magnitude(closest_points[1] -
                                                 closest_points[0])
                vres_distance = bg.calc_vres_distance(s1, k, s2, l)

                print "internal_dist:", cuv.magnitude(
                    (v2_p + mult * v2_v) - (v1_p + mult * v1_v)
                ), closest_distance, 1, s1, k, s1, l, vres_distance
Exemplo n.º 9
0
def main():
    usage = """
Collect the information about how stems are surrounded by nucleotides.

For each nucleotide in each stem, the position 
(relative to that nucleotide) of each surrounding
nucleotide (which is also part of a stem) will be recorded. 

The information will be classified according to the type
of residue that the base is.

usage: %prog [options] temp.comp
"""
    parser = OptionParser(usage=usage)

    #parser.add_option('-o', '--options', dest='some_option', default='yo', help="Place holder for a real option", type='str')
    #parser.add_option('-u', '--useless', dest='uselesss', default=False, action='store_true', help='Another useless option')

    (options, args) = parser.parse_args()

    if len(args) < 1:
        print >> sys.stderr, "Missing graph file."
        parser.print_help()
        sys.exit(1)

    bg = ttmc.CoarseGrainRNA(args[0])

    stems = [d for d in bg.defines.keys() if d[0] == 's']
    #stems = [d for d in bg.defines.keys() if (bg.weights[d] == 2 or bg.weights[d] == 0)]

    for i in range(len(stems)):
        '''
        if stems[i][0] != 's':
            # the end nucleotides of bulges overlap those of stems
            # so their length needs to be one less than that of stems
            s1_len = bg.defines[stems[i]][1] - bg.defines[stems[i]][0]
            k_start = 1
        else:
        '''
        #s1_len = bg.defines[stems[i]][1] - bg.defines[stems[i]][0] + 1
        s1_len = bg.stem_length(stems[i])
        k_start = 0

        for j in range(len(stems)):
            if i == j:
                continue

            # ignore connected stems... that should be taken care of in the sampling
            # potential
            if bg.are_adjacent_stems(stems[i], stems[j]):
                continue
            if stems[i] in bg.edges[stems[j]]:
                continue

            #if connected_stems(bg, stems[i], stems[j]):
            #    continue
            '''
            if stems[j][0] != 's':
                # see comment for s1_len above
                s2_len = bg.defines[stems[j]][1] - bg.defines[stems[j]][0]
                l_start = 1
            else:
            '''
            #s2_len = bg.defines[stems[j]][1] - bg.defines[stems[j]][0] + 1
            s2_len = bg.stem_length(stems[i])
            l_start = 0

            for k in range(k_start, s1_len):
                s1_start = cgg.pos_to_spos(bg, stems[i], k, stems[i], 0)
                s1_end = cgg.pos_to_spos(bg, stems[i], k, stems[i], s1_len - 1)
                '''
                print >>sys.stderr, stems[i], k, s1_start, s1_end
                print >>sys.stderr, s1_len
                '''

                #print "s1_start:", s1_start, "s1_end:", s1_end
                for l in range(l_start, s2_len):
                    r1_type = cgg.get_residue_type(k, s1_len)
                    r2_spos = cgg.pos_to_spos(bg, stems[i], k, stems[j], l)

                    #if cuv.magnitude(r2_spos) < 400. and r2_spos[0] > s1_start[0] and r2_spos[0] < s1_end[0]:
                    #if cuv.magnitude(r2_spos) < 400. and r2_spos[0] > -3. and r2_spos[0] < 3.:
                    if True:
                        print r1_type, cuv.magnitude(r2_spos), " ".join(
                            map(str,
                                r2_spos)), bg.name, stems[i], k, stems[j], l