Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:wwood/bbbin
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'optparse' | ||
require 'bio-logger' | ||
require 'bio/kseq' | ||
|
||
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} <arguments> | ||
Converts a FASTA file into the same file except in FASTQ format with dummy quality scores.\n\n" | ||
|
||
# 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! | ||
# 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); log.outputters[0].formatter = Log4r::PatternFormatter.new(:pattern => "%5l %c %d: %m", :date_pattern => '%d/%m %T') | ||
|
||
|
||
# Convert FASTQ to FASTA | ||
kseq = Bio::Kseq.new(ARGV[0]) | ||
while kseq.read! # returns truthy values when there is an entry | ||
puts "@" + kseq.name | ||
puts kseq.seq | ||
puts '+' | ||
puts 'A'*kseq.seq.length | ||
end | ||
|