Class: SwissprotDatabase
- Inherits:
-
Object
- Object
- SwissprotDatabase
- Defined in:
- lib/protk/swissprot_database.rb
Overview
Provides fast indexed access to a swissprot database in a flat .dat file
Instance Method Summary collapse
- #get_entry_for_name(name) ⇒ Object
-
#initialize(env = nil, database = "swissprot") ⇒ SwissprotDatabase
constructor
A new instance of SwissprotDatabase.
Constructor Details
#initialize(env = nil, database = "swissprot") ⇒ SwissprotDatabase
Returns a new instance of SwissprotDatabase.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/protk/swissprot_database.rb', line 10 def initialize(env=nil,database="swissprot") if ( env!=nil) @genv=env else @genv=Constants.new end dbpath=Pathname.new(database) if ( dbpath.exist? ) # require 'debugger';debugger dbclass=Bio::SPTR parser = Bio::FlatFileIndex::Indexer::Parser.new(dbclass, nil, nil) Bio::FlatFileIndex::Indexer::makeindexFlat(dbpath.realpath.dirname.to_s, parser, {}, dbpath.realpath.to_s) @db_object=Bio::FlatFileIndex.new("#{dbpath.realpath.dirname.to_s}") elsif ( database=="swissprot") @db_object=Bio::FlatFileIndex.new("#{@genv.protein_database_root}/#{@genv.uniprot_sprot_annotation_database}") else @db_object=Bio::FlatFileIndex.new("#{@genv.protein_database_root}/#{@genv.uniprot_trembl_annotation_database}") end @db_object.always_check_consistency=false end |
Instance Method Details
#get_entry_for_name(name) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/protk/swissprot_database.rb', line 36 def get_entry_for_name(name) result=@db_object.get_by_id(name) if result=="" if ( @genv!=nil) @genv.log("Failed to find UniProt entry for protein named #{name} in database",:warn) end return nil else Bio::SPTR.new(result) end end |