#!/usr/bin/env ruby require 'optparse' require 'bio-logger' SCRIPT_NAME = File.basename(__FILE__); LOG_NAME = SCRIPT_NAME.gsub('.rb','') # Parse command line options into the options hash options = { :logger => 'stderr', :log_level => 'info', } o = OptionParser.new do |opts| opts.banner = " Usage: #{SCRIPT_NAME} Description of what this program does...\n\n" opts.on("--velvet-pregraph GRAPH_FILE", "PreGraph file output from velveth [required]") do |arg| options[:velvet_pregraph_file] = arg end # logger options opts.separator "\nVerbosity:\n\n" opts.on("-q", "--quiet", "Run quietly, set logging to ERROR level [default INFO]") {options[:log_level] = 'error'} opts.on("--logger filename",String,"Log to file [default #{options[:logger]}]") { |name| options[:logger] = name} opts.on("--trace options",String,"Set log level [default INFO]. e.g. '--trace debug' to set logging level to DEBUG"){|s| options[:log_level] = s} end; o.parse! if ARGV.length != 0 or options[:velvet_pregraph_file].nil? $stderr.puts o exit 1 end # Setup logging Bio::Log::CLI.logger(options[:logger]); Bio::Log::CLI.trace(options[:log_level]); log = Bio::Log::LoggerPlus.new(LOG_NAME); Bio::Log::CLI.configure(LOG_NAME) # Read in the velvet graph log.info "Parsing graph from #{options[:velvet_pregraph_file]}" graph = Bio::Velvet::Graph.parse_from_file(options[:velvet_pregraph_file]) log.info "Finished parsing graph, found #{graph.number_of_nodes} nodes" # Log the number of nodes and arcs in the current graph # Read in the fasta file of immutable nodes, and extract the two most immutable # Log that they are found # Determine that the graph is connected or not between the two most immutable nodes, using some graph theoretic algorithm # If the graph is not connected, then there is no hope, exit # Go through the graph to get a list of the cap nodes # Log the number of cap nodes found # Trim off all the cap nodes back to cross nodes, keeping track of the lengths # Print the graph in graphviz dot format