def main(): usage = """ ./longest_stem.py dotbracket_file """ num_args = 1 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) < num_args: parser.print_help() sys.exit(1) if args[0] == '-': f = sys.stdin else: f = open(args[0]) brackets = "".join(f.readlines()).replace('\n', '') bg = cgb.BulgeGraph() bg.from_dotbracket(brackets) biggest_stem = (-1, 'x') for s in bg.stem_iterator(): if bg.stem_length(s) > biggest_stem[0]: biggest_stem = (bg.stem_length(s), s) print biggest_stem[0]
def main(): usage = """ Usage: ./dotbracket_to_element_string.py file.dotbracket" Convert a dotbracket notation to an element-type notation where the type of each element is shown. For example, the string '..((..))..' will be converted to 'ffsshhsstt' to indicate the presence of a fiveprime, stem, hairpin, and threeprime section. """ parser = OptionParser(usage=usage) parser.add_option( '-s', '--secondary-structure', dest='sec_struct', default=False, help= "Display the dotbracket represenation of the secondary structure along with the element string.", action='store_true') (options, args) = parser.parse_args() if len(args) < 1: parser.print_help() sys.exit(1) if args[0] == '-': f = sys.stdin else: f = open(args[0]) brackets = "".join(f.readlines()).replace('\n', '') bg = cgb.BulgeGraph() bg.from_dotbracket(brackets) if options.sec_struct: print bg.dotbracket_str print bg.to_element_string()
def test_from_dotplot2(self): bg = cgb.BulgeGraph() # secondary structure taken from 1y26 bg.from_dotbracket('((..))') elem_str = bg.to_element_string() self.assertEquals(elem_str, "sshhss") dotbracket = '..((..))..' bg.from_dotbracket(dotbracket) elem_str = bg.to_element_string() self.assertEquals(elem_str, "ffsshhsstt") dotbracket = '..((..))..((..))..' bg.from_dotbracket(dotbracket) elem_str = bg.to_element_string() self.assertEquals(elem_str, "ffsshhssmmsshhsstt")
def main(): usage = """ Usage: ./graph_to_neato.py struct.graph Convert a BulgeGraph structure to a representation readable by the 'neato' program. """ parser = OptionParser(usage=usage) (options, args) = parser.parse_args() if len(args) < 1: parser.print_help() sys.exit(1) if args[0] == '-': f = sys.stdin else: f = open(args[0]) brackets = "".join(f.readlines()).replace('\n', '') bg = cgb.BulgeGraph() bg.from_dotbracket(brackets) print_neato(bg)
def main(): usage = """ Usage: ./dotbracket_to_rosetta_constraints.py Convert a dotbracket file to a set of constraints for the Rosetta rna_denovo program. These constraints will describe the stems within the structure by showing which necleotides need to pair with which other nucleotides. """ parser = OptionParser(usage=usage) (options, args) = parser.parse_args() if len(args) < 1: parser.print_help() sys.exit(1) if args[0] == '-': f = sys.stdin else: f = open(args[0]) brackets = "".join(f.readlines()).replace('\n', '') bg = cgb.BulgeGraph() bg.from_dotbracket(brackets) print_rosetta_constraints(bg)
def test_from_dotplot(self): bg = cgb.BulgeGraph() bg.from_dotbracket(self.dotbracket) print bg.to_bg_string()
def main(): usage = """ Usage: ./create_bulge_graph.py file.dotbracket [name]" Creates a graph of the paired and unpaired regions within a dotplot. Paired regions are called stems while unpaired regions are called bulges. The file created contains four sections: 1. Name (optional): The name of this graph. This can be used, for example, to specify which PDB file the dotplot was inferred from. The name should not contain any spaces. 2. Length (optional): The length of the dotplot that was used to create this graph. 3. Definitions: Each line in the definitions sections begins with the keyword 'define' It is followed by the name of the region and the numbers of the nucleotides which define that region. The numbers of the nucleotides always come in sets of two for bulges and sets of four for stems (which can be interpreted as two sets of two). Each set of two numbers indicates the starting and ending nucleotide for that region. All numbers are 1-based. 4. Connections: This section shows how the different regions are connected to each other. The term connected means that they share a common nucleotide. Each line begins with the keyword 'connect'. It is followed by the name of the region for which the connections are being described. The name is followed by a number of different names. Each of these regions is connected to the first. One region may be defined by more than one connect statement. This section of the file is simpy an adjacency list. The results are printed to standard out. """ parser = OptionParser(usage=usage) (options, args) = parser.parse_args() if len(args) < 1: parser.print_help() sys.exit(1) if args[0] == '-': f = sys.stdin else: f = open(args[0]) brackets = "".join(f.readlines()).replace('\n', '') bg = cgb.BulgeGraph() bg.from_dotbracket(brackets) if len(args) == 2: bg.name = args[1] print bg.to_bg_string()