Module: Genfrag
- Defined in:
- lib/genfrag.rb,
lib/genfrag/app.rb,
lib/genfrag/app/command.rb,
lib/genfrag/app/index_command.rb,
lib/genfrag/app/search_command.rb,
lib/genfrag/app/index_command/db.rb,
lib/genfrag/app/search_command/trim.rb,
lib/genfrag/app/search_command/match.rb,
lib/genfrag/app/search_command/process_file.rb
Defined Under Namespace
Classes: App
Constant Summary collapse
- VERSION =
:stopdoc:
'0.0.0.4'
- LIBPATH =
::File.(::File.dirname(__FILE__)) + ::File::SEPARATOR
- PATH =
::File.dirname(LIBPATH) + ::File::SEPARATOR
Class Method Summary collapse
-
.libpath(*args) ⇒ Object
Returns the library path for the module.
-
.name_adapters(fileadapters = nil) ⇒ Object
Return the name of the adapters file without its extension.
-
.name_freq_lookup(input_filenames = [], filefasta = nil, filelookup = nil, re5 = nil, re3 = nil) ⇒ Object
Create a unique filename for the frequency file out of a combination of filenames.
-
.name_normalized_fasta(input_filenames = [], filefasta = nil) ⇒ Object
Create a unique filename out of a combination of filenames.
-
.path(*args) ⇒ Object
Returns the lpath for the module.
-
.require_all_libs_relative_to(fname, dir = nil) ⇒ Object
Utility method used to require all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in.
- .tracktime(verbose = true, f = nil) ⇒ Object
-
.version ⇒ Object
Returns the version string for the library.
Class Method Details
.libpath(*args) ⇒ Object
Returns the library path for the module. If any arguments are given, they will be joined to the end of the libray path using File.join
.
20 21 22 |
# File 'lib/genfrag.rb', line 20 def self.libpath( *args ) args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten) end |
.name_adapters(fileadapters = nil) ⇒ Object
Return the name of the adapters file without its extension
120 121 122 123 |
# File 'lib/genfrag.rb', line 120 def self.name_adapters(fileadapters=nil) return nil if !fileadapters return fileadapters.gsub(/\.(db|tdf)$/, '') end |
.name_freq_lookup(input_filenames = [], filefasta = nil, filelookup = nil, re5 = nil, re3 = nil) ⇒ Object
Create a unique filename for the frequency file out of a combination of filenames
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/genfrag.rb', line 82 def self.name_freq_lookup(input_filenames=[],filefasta=nil,filelookup=nil,re5=nil,re3=nil) input_filenames = [] if input_filenames.nil? if filelookup # FIXME used to be gsub! - make sure it still works in code return filelookup.gsub(/\.(db|tdf)$/, '') elsif !input_filenames.empty? if re5 and re3 [input_filenames.sort,re5.downcase,re3.downcase,'index'].join('_').gsub(/\//,'x') else raise "re5 or re3 is undefined" end elsif filefasta # construct default name if re5 and re3 [name_normalized_fasta(nil,filefasta),re5.downcase,re3.downcase,'index'].join('_').gsub(/\//,'x') else raise "re5 or re3 is undefined" end else raise "--lookup undefined and no default filenames passed" end end |
.name_normalized_fasta(input_filenames = [], filefasta = nil) ⇒ Object
Create a unique filename out of a combination of filenames
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/genfrag.rb', line 107 def self.name_normalized_fasta(input_filenames=[],filefasta=nil) if filefasta # FIXME used to be gsub! - make sure it still works in code return filefasta.gsub(/\.(db|tdf)$/, '') elsif !input_filenames.empty? return [input_filenames.sort, 'normalized'].join('_').gsub(/\//,'x') else raise "--fasta undefined and no default filenames passed" end end |
.path(*args) ⇒ Object
Returns the lpath for the module. If any arguments are given, they will be joined to the end of the path using File.join
.
28 29 30 |
# File 'lib/genfrag.rb', line 28 def self.path( *args ) args.empty? ? PATH : ::File.join(PATH, args.flatten) end |
.require_all_libs_relative_to(fname, dir = nil) ⇒ Object
Utility method used to require all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in. Optionally, a specific directory name can be passed in such that the filename does not have to be equivalent to the directory.
37 38 39 40 41 42 43 |
# File 'lib/genfrag.rb', line 37 def self.require_all_libs_relative_to( fname, dir = nil ) dir ||= ::File.basename(fname, '.*') search_me = ::File.( ::File.join(::File.dirname(fname), dir, '**', '*.rb')) Dir.glob(search_me).sort.each {|rb| require rb} end |
.tracktime(verbose = true, f = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/genfrag.rb', line 45 def self.tracktime verbose=true, f=nil # Info:: Pjotr's shared Ruby modules # Author:: Pjotr Prins # mail:: [email protected] # Copyright:: July 2007 # License:: Ruby License begin t1 = Time.now yield ensure t2 = Time.now dt = t2 - t1 if verbose if f == nil f = $stdout end f.print "\nElapsed time " hours = dt.to_i/3600 dt -= hours*3600 mins = dt.to_i/60 dt -= mins*60 secs = dt secs = secs.to_i if secs > 25 if hours > 0 f.print hours.to_i," hours " end if mins > 0 f.print mins.to_i," minutes " end f.print secs," seconds\n" end end end |
.version ⇒ Object
Returns the version string for the library.
12 13 14 |
# File 'lib/genfrag.rb', line 12 def self.version VERSION end |