Class: Bio::SQL

Inherits:
Object show all
Defined in:
lib/bio/io/sql.rb,
lib/bio/io/biosql/biosql.rb,
lib/bio/db/biosql/sequence.rb,
lib/bio/io/biosql/ar-biosql.rb

Defined Under Namespace

Classes: Biodatabase, Bioentry, BioentryDbxref, BioentryPath, BioentryQualifierValue, BioentryReference, BioentryRelationship, Biosequence, Comment, Dbxref, DbxrefQualifierValue, DummyBase, Location, LocationQualifierValue, Ontology, Reference, Seqfeature, SeqfeatureDbxref, SeqfeaturePath, SeqfeatureQualifierValue, SeqfeatureRelationship, Sequence, Taxon, TaxonName, Term, TermDbxref, TermPath, TermRelationship, TermRelationshipTerm, TermSynonym

Class Method Summary (collapse)

Class Method Details

+ (Object) delete_entry_accession(accession)



73
74
75
# File 'lib/bio/io/sql.rb', line 73

def self.delete_entry_accession(accession)
  Bio::SQL::Bioentry.find_by_accession(accession.upcase).destroy!
end

+ (Object) delete_entry_id(id)



69
70
71
# File 'lib/bio/io/sql.rb', line 69

def self.delete_entry_id(id)
  Bio::SQL::Bioentry.delete(id)
end

+ (Object) establish_connection(configurations, env)

#no check is made



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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

+ (Object) exists_accession(accession)



47
48
49
50
# 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

+ (Object) exists_database(name)



52
53
54
55
# 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

+ (Object) fetch_accession(accession)



42
43
44
45
# 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

+ (Object) fetch_id(id)



38
39
40
# File 'lib/bio/io/sql.rb', line 38

def self.fetch_id(id)
  Bio::SQL::Bioentry.find(id)
end

+ (Object) list_databases



63
64
65
66
67
# 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

+ (Object) list_entries



57
58
59
60
61
# 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