Class: SequenceServer::MAKEBLASTDB
- Inherits:
-
Object
- Object
- SequenceServer::MAKEBLASTDB
- Extended by:
- Forwardable
- Defined in:
- lib/sequenceserver/makeblastdb.rb
Overview
Smart ‘makeblastdb` wrapper: recursively scans database directory determining which files need to be formatted or re-formatted.
Example usage:
makeblastdb = MAKEBLASTDB.new(database_dir)
makeblastdb.run # formats and re-formats databases in database_dir
makeblastdb.formatted_fastas # lists formatted databases
Instance Attribute Summary collapse
-
#database_dir ⇒ Object
readonly
Returns the value of attribute database_dir.
Instance Method Summary collapse
- #any_formatted? ⇒ Boolean
- #any_to_format? ⇒ Boolean
- #any_to_format_or_reformat? ⇒ Boolean
-
#format ⇒ Object
Format any unformatted FASTA files in database directory.
-
#formatted_fastas ⇒ Object
Determines which FASTA files in the database directory are already formatted.
-
#initialize(database_dir) ⇒ MAKEBLASTDB
constructor
A new instance of MAKEBLASTDB.
- #no_fastas? ⇒ Boolean
-
#reformat ⇒ Object
Re-format databases that require reformatting.
-
#run ⇒ Object
Runs makeblastdb on each file in ‘fastas_to_format` and `fastas_to_reformat`.
Constructor Details
#initialize(database_dir) ⇒ MAKEBLASTDB
Returns a new instance of MAKEBLASTDB.
19 20 21 |
# File 'lib/sequenceserver/makeblastdb.rb', line 19 def initialize(database_dir) @database_dir = database_dir end |
Instance Attribute Details
#database_dir ⇒ Object (readonly)
Returns the value of attribute database_dir.
23 24 25 |
# File 'lib/sequenceserver/makeblastdb.rb', line 23 def database_dir @database_dir end |
Instance Method Details
#any_formatted? ⇒ Boolean
25 26 27 |
# File 'lib/sequenceserver/makeblastdb.rb', line 25 def any_formatted? formatted_fastas.any? end |
#any_to_format? ⇒ Boolean
86 87 88 |
# File 'lib/sequenceserver/makeblastdb.rb', line 86 def any_to_format? fastas_to_format.any? end |
#any_to_format_or_reformat? ⇒ Boolean
29 30 31 |
# File 'lib/sequenceserver/makeblastdb.rb', line 29 def any_to_format_or_reformat? any_to_format? || any_to_reformat? end |
#format ⇒ Object
Format any unformatted FASTA files in database directory. Returns Array of files that were formatted.
46 47 48 49 50 51 52 53 54 |
# File 'lib/sequenceserver/makeblastdb.rb', line 46 def format # Make the intent clear as well as ensure the program won't crash if we # accidentally call format before calling scan. return unless any_to_format? fastas_to_format.select do |path, title, type| make_blast_database('format', path, title, type) end end |
#formatted_fastas ⇒ Object
Determines which FASTA files in the database directory are already formatted.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/sequenceserver/makeblastdb.rb', line 70 def formatted_fastas return @formatted_fastas if defined?(@formatted_fastas) @formatted_fastas = [] blastdbcmd.each_line do |line| path, *rest = line.chomp.split("\t") next if multipart_database_name?(path) rest << get_categories(path) @formatted_fastas << Database.new(path, *rest) end @formatted_fastas end |
#no_fastas? ⇒ Boolean
33 34 35 |
# File 'lib/sequenceserver/makeblastdb.rb', line 33 def no_fastas? probably_fastas.empty? end |
#reformat ⇒ Object
Re-format databases that require reformatting. Returns Array of files that were reformatted.
58 59 60 61 62 63 64 65 66 |
# File 'lib/sequenceserver/makeblastdb.rb', line 58 def reformat # Make the intent clear as well as ensure the program won't crash if # we accidentally call reformat before calling scan. return unless any_to_reformat? fastas_to_reformat.select do |path, title, type, non_parse_seqids| make_blast_database('reformat', path, title, type, non_parse_seqids) end end |
#run ⇒ Object
Runs makeblastdb on each file in ‘fastas_to_format` and `fastas_to_reformat`.
39 40 41 42 |
# File 'lib/sequenceserver/makeblastdb.rb', line 39 def run format reformat end |