class Bio::SQL
Constants
- VERSION
Public Class Methods
delete_entry_accession(accession)
click to toggle source
# File lib/bio/io/sql.rb 73 def self.delete_entry_accession(accession) 74 Bio::SQL::Bioentry.find_by_accession(accession.upcase).destroy! 75 end
delete_entry_id(id)
click to toggle source
# File lib/bio/io/sql.rb 69 def self.delete_entry_id(id) 70 Bio::SQL::Bioentry.delete(id) 71 end
establish_connection(configurations, env)
click to toggle source
no check is made
# File lib/bio/io/biosql/biosql.rb 23 def self.establish_connection(configurations, env) 24 # #configurations is an hash similar what YAML returns. 25 26 #configurations.assert_valid_keys('development', 'production','test') 27 #configurations[env].assert_valid_keys('hostname','database','adapter','username','password') 28 DummyBase.configurations = configurations 29 connection = DummyBase.establish_connection "#{env}" 30 #Init of basis terms and ontologies 31 Ontology.first(:conditions => ["name = ?", 'Annotation Tags']) || Ontology.create({:name => 'Annotation Tags'}) 32 Ontology.first(:conditions => ["name = ?", 'SeqFeature Keys']) || Ontology.create({:name => 'SeqFeature Keys'}) 33 Ontology.first(:conditions => ["name = ?", 'SeqFeature Sources']) ||Ontology.create({:name => 'SeqFeature Sources'}) 34 Term.first(:conditions => ["name = ?", 'EMBLGenBankSwit']) || Term.create({:name => 'EMBLGenBankSwit', :ontology => Ontology.first(:conditions => ["name = ?", 'SeqFeature Sources'])}) 35 connection 36 end
exists_accession(accession)
click to toggle source
# File lib/bio/io/sql.rb 47 def self.exists_accession(accession) 48 # Bio::SQL::Bioentry.find_by_accession(accession.upcase).nil? ? false : true 49 !Bio::SQL::Bioentry.find_by_accession(accession.upcase).nil? 50 end
exists_database(name)
click to toggle source
# File lib/bio/io/sql.rb 52 def self.exists_database(name) 53 # Bio::SQL::Biodatabase.find_by_name(name).nil? ? false : true 54 !Bio::SQL::Biodatabase.first(:name=>name).nil? 55 end
fetch_accession(accession)
click to toggle source
# File lib/bio/io/sql.rb 42 def self.fetch_accession(accession) 43 # Bio::SQL::Bioentry.exists?(:accession => accession) ? Bio::SQL::Sequence.new(:entry=>Bio::SQL::Bioentry.find_by_accession(accession)) : nil 44 Bio::SQL::Sequence.new(:entry=>Bio::SQL::Bioentry.find_by_accession(accession.upcase)) 45 end
fetch_id(id)
click to toggle source
# File lib/bio/io/sql.rb 38 def self.fetch_id(id) 39 Bio::SQL::Bioentry.find(id) 40 end
list_databases()
click to toggle source
# File lib/bio/io/sql.rb 63 def self.list_databases 64 Bio::SQL::Biodatabase.all.collect do|entry| 65 {:id=>entry.biodatabase_id, :name => entry.name} 66 end 67 end
list_entries()
click to toggle source
# File lib/bio/io/sql.rb 57 def self.list_entries 58 Bio::SQL::Bioentry.all.collect do|entry| 59 {:id=>entry.bioentry_id, :accession=>entry.accession} 60 end 61 end