Esempio n. 1
0
 def test_cg_from_sg_invalid_subgraph_breaking_m(self):
     cg = ftmc.CoarseGrainRNA('test/forgi/threedee/data/3D0U_A.cg')
     """
          /s3 --h1
        m1  |
       /    |
     s0     m2
       \    |
        m0  |
          \s1--i0--s2--h0
     """
     split_ml = ["s0", "m0", "s1"]
     with self.assertRaises(Exception):
         ftmc.cg_from_sg(cg, split_ml)
Esempio n. 2
0
 def test_cg_from_sg_invalid_subgraph_breaking_m(self):
     cg = ftmc.CoarseGrainRNA.from_bg_file(
         'test/forgi/threedee/data/3D0U_A.cg')
     """
          /s3 --h1
        m1  |
       /    |
     s0     m2
       \    |
        m0  |
          \s1--i0--s2--h0
     """
     split_ml = ["s0", "m0", "s1"]
     with self.assertRaises(Exception):
         ftmc.cg_from_sg(cg, split_ml)
Esempio n. 3
0
def cg_from_sg(cg, sg):
    '''
    Create a coarse-grain structure from a subgraph.

    @param cg: The original structure
    @param sg: The list of elements that are in the subgraph
    '''
    new_cg = ftmc.cg_from_sg(cg, sg)
    return new_cg

    for d in sg:
        new_cg.defines[d] = cg.defines[d]

        if d in cg.coords.keys():
            new_cg.coords[d] = cg.coords[d]
        if d in cg.twists.keys():
            new_cg.twists[d] = cg.twists[d]
        if d in cg.longrange.keys():
            new_cg.longrange[d] = cg.longrange[d]

        for x in cg.edges[d]:
            if x in new_cg.defines.keys():
                new_cg.edges[d].add(x)
                new_cg.edges[x].add(d)

    return new_cg
def main():
    usage = """
    python create_colinearity_measures.py temp.cg
    """
    num_args= 1
    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')
    parser.add_option('-i', '--iterations', dest='iterations', default=1, help="The number of iterations to perform", type='int')

    (options, args) = parser.parse_args()

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

    for arg in args:
        cg = ftmc.CoarseGrainRNA(arg)
        cie = fbe.CylinderIntersectionEnergy()

        for i in range(options.iterations):
            sg = cg.random_subgraph()                                                                                        
            csg = ftmc.cg_from_sg(cg, sg)

            total_length = sum([len(list(cg.define_residue_num_iterator(d))) for d in sg])                                   
            cylinder_intersections = cie.calculate_intersection_coverages(csg)

            print total_length, " ".join(map("{:.2f}".format, cylinder_intersections.values()))
Esempio n. 5
0
def cg_from_sg(cg, sg):
    '''
    Create a coarse-grain structure from a subgraph.

    @param cg: The original structure
    @param sg: The list of elements that are in the subgraph
    '''
    new_cg = ftmc.cg_from_sg(cg, sg)
    return new_cg

    for d in sg:
        new_cg.defines[d] = cg.defines[d]

        if d in cg.coords.keys():
            new_cg.coords[d] = cg.coords[d]
        if d in cg.twists.keys():
            new_cg.twists[d] = cg.twists[d]
        if d in cg.longrange.keys():
            new_cg.longrange[d] = cg.longrange[d]

        for x in cg.edges[d]:
            if x in new_cg.defines.keys():
                new_cg.edges[d].add(x)
                new_cg.edges[x].add(d)

    return new_cg
Esempio n. 6
0
    def test_cg_from_sg_breaking_after_s(self):
        cg = ftmc.CoarseGrainRNA('test/forgi/threedee/data/3D0U_A.cg')
        """
             /s3 --h1
           m1  |
          /    |
        s0     m2
          \    |
           m0  |
             \s1--i0--s2--h0
        """
        split_ml = ["s0", "m0", "s1", "m2", "s3", "m1", "h1"]

        sg = ftmc.cg_from_sg(cg, split_ml)
        self.check_graph_integrity(sg)
Esempio n. 7
0
    def test_cg_from_sg_breaking_after_s(self):
        cg = ftmc.CoarseGrainRNA.from_bg_file(
            'test/forgi/threedee/data/3D0U_A.cg')
        """
             /s3 --h1
           m1  |
          /    |
        s0     m2
          \    |
           m0  |
             \s1--i0--s2--h0
        """
        split_ml = ["s0", "m0", "s1", "m2", "s3", "m1", "h1"]

        sg = ftmc.cg_from_sg(cg, split_ml)
        self.check_graph_integrity(sg)
def main():
    usage = """
    python create_colinearity_measures.py temp.cg
    """
    num_args = 1
    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')
    parser.add_option('-i',
                      '--iterations',
                      dest='iterations',
                      default=1,
                      help="The number of iterations to perform",
                      type='int')

    (options, args) = parser.parse_args()

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

    for arg in args:
        cg = ftmc.CoarseGrainRNA(arg)
        cie = fbe.CylinderIntersectionEnergy()

        for i in range(options.iterations):
            sg = cg.random_subgraph()
            csg = ftmc.cg_from_sg(cg, sg)

            total_length = sum(
                [len(list(cg.define_residue_num_iterator(d))) for d in sg])
            cylinder_intersections = cie.calculate_intersection_coverages(csg)

            print total_length, " ".join(
                map("{:.2f}".format, cylinder_intersections.values()))