class Bio::SQL

Public Class Methods

delete_entry_accession(accession) click to toggle source
# File lib/bio/io/sql.rb, line 73
def self.delete_entry_accession(accession)
  Bio::SQL::Bioentry.find_by_accession(accession.upcase).destroy!
end
delete_entry_id(id) click to toggle source
# File lib/bio/io/sql.rb, line 69
def self.delete_entry_id(id)
  Bio::SQL::Bioentry.delete(id)
end
establish_connection(configurations, env) click to toggle source

no check is made

# File lib/bio/io/biosql/biosql.rb, line 23
def self.establish_connection(configurations, env)
  #  #configurations is an hash similar what YAML returns.

   #configurations.assert_valid_keys('development', 'production','test')
   #configurations[env].assert_valid_keys('hostname','database','adapter','username','password')
   DummyBase.configurations = configurations
  connection = DummyBase.establish_connection "#{env}"
  #Init of basis terms and ontologies
  Ontology.first(:conditions => ["name = ?", 'Annotation Tags']) || Ontology.create({:name => 'Annotation Tags'})
  Ontology.first(:conditions => ["name = ?", 'SeqFeature Keys']) || Ontology.create({:name => 'SeqFeature Keys'})
  Ontology.first(:conditions => ["name = ?", 'SeqFeature Sources']) ||Ontology.create({:name => 'SeqFeature Sources'})
  Term.first(:conditions => ["name = ?", 'EMBLGenBankSwit']) || Term.create({:name => 'EMBLGenBankSwit', :ontology => Ontology.first(:conditions => ["name = ?", 'SeqFeature Sources'])})
  connection 
end
exists_accession(accession) click to toggle source
# File lib/bio/io/sql.rb, line 47
    def self.exists_accession(accession)
#      Bio::SQL::Bioentry.find_by_accession(accession.upcase).nil? ? false : true
      !Bio::SQL::Bioentry.find_by_accession(accession.upcase).nil?
    end
exists_database(name) click to toggle source
# File lib/bio/io/sql.rb, line 52
    def self.exists_database(name)
#      Bio::SQL::Biodatabase.find_by_name(name).nil? ? false : true
      !Bio::SQL::Biodatabase.first(:name=>name).nil?
    end
fetch_accession(accession) click to toggle source
# File lib/bio/io/sql.rb, line 42
    def self.fetch_accession(accession)
#     Bio::SQL::Bioentry.exists?(:accession => accession) ? Bio::SQL::Sequence.new(:entry=>Bio::SQL::Bioentry.find_by_accession(accession)) : nil
      Bio::SQL::Sequence.new(:entry=>Bio::SQL::Bioentry.find_by_accession(accession.upcase))
    end
fetch_id(id) click to toggle source
# File lib/bio/io/sql.rb, line 38
def self.fetch_id(id)
  Bio::SQL::Bioentry.find(id)
end
list_databases() click to toggle source
# File lib/bio/io/sql.rb, line 63
def self.list_databases
  Bio::SQL::Biodatabase.all.collect do|entry|
    {:id=>entry.biodatabase_id, :name => entry.name}
  end
end
list_entries() click to toggle source
# File lib/bio/io/sql.rb, line 57
def self.list_entries
  Bio::SQL::Bioentry.all.collect do|entry|
    {:id=>entry.bioentry_id, :accession=>entry.accession}
  end
end