class FastaDB
Warning: Uses Bio::Command which is a private API of the Bio
package
Public Class Methods
create(blast_database_file_path,input_fasta_filepath,type='nucl')
click to toggle source
# File lib/protk/fastadb.rb, line 17 def self.create(blast_database_file_path,input_fasta_filepath,type='nucl') db = FastaDB.new(blast_database_file_path) db.make_index(input_fasta_filepath,type) db end
new(blast_database_file_path)
click to toggle source
# File lib/protk/fastadb.rb, line 10 def initialize(blast_database_file_path) env = Constants.instance @database = blast_database_file_path @makedbcmd = env.makeblastdb @searchdbcmd = env.blastdbcmd end
Public Instance Methods
fetch(list)
click to toggle source
# File lib/protk/fastadb.rb, line 34 def fetch(list) if list.respond_to?(:join) entry_id = list.join(",") else entry_id = list end cmd = [ @searchdbcmd, '-db', @database, '-entry', entry_id ] Bio::Command.call_command(cmd) do |io| io.close_write Bio::FlatFile.new(Bio::FastaFormat, io).to_a end end
get_by_id(entry_id)
click to toggle source
# File lib/protk/fastadb.rb, line 23 def get_by_id(entry_id) fetch(entry_id).shift end
make_index(input_fasta,dbtype)
click to toggle source
# File lib/protk/fastadb.rb, line 27 def make_index(input_fasta,dbtype) cmd = [ @makedbcmd, '-in', input_fasta, '-parse_seqids','-out',@database,'-dbtype',dbtype] res = Bio::Command.call_command(cmd) do |io| puts io.read end end