Module: Chem::KEGG

Defined in:
lib/chem/db/kcf.rb,
lib/chem/db/kegg.rb,
lib/chem/db/kcf_glycan.rb

Defined Under Namespace

Modules: Atom, Bond, KeggFormat, ReactionList Classes: ANumber, Compound, EC, KCF, KCFAtom, KCFBond, KCFCorrespondence, KCFGlycan, KCFMolecule, KCFRXN, KCFReader, KEGGReaction, KeggCompound, KeggDirectory, KeggEc, KeggGlycan, KeggGlycanParser, KeggReaction, KeggReactionLstParser, KeggReactionMapParser, KeggReactionParser, Reaction

Constant Summary collapse

CNUMREG =
/C(\d\d\d\d\d)/
ECREG =
/EC([^.]+)\.([^.]+)\.([^.]+)\.([^.]+)/
@@kegg =
{}
@@kegg_compound_folder =

obsolete

nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](kegg_id) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/chem/db/kegg.rb', line 21

def self.[](kegg_id)
  @@kegg[kegg_id] ||= case kegg_id
                     when CNUMREG
                     when ECREG
                       EC.new($1, $2, $3, $4)
                     else
                       raise KEGGException, "Unknown KEGG ID '#{kegg_id}'"
                     end
end

.kegg_compound_folderObject



206
207
208
# File 'lib/chem/db/kegg.rb', line 206

def self.kegg_compound_folder
  @@kegg_compound_folder
end

.kegg_compound_folder=(folder) ⇒ Object



202
203
204
# File 'lib/chem/db/kegg.rb', line 202

def self.kegg_compound_folder= (folder)
  @@kegg_compound_folder = folder
end

.parse_compound_fileObject



501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/chem/db/kegg.rb', line 501

def self.parse_compound_file
  compound = nil
  parse($home + "compound") do |str, state|
    case state
    when "ENTRY"
      compound = Compound.find(:first, :conditions => ["entry = ?", str.split[0]])
      if compound == nil
        compound = Compound.new
        compound.entry = str.split[0]
      end
    when "NAME"
      compound.name = str.split("\n").join if str
    when "DBLINKS"
      str.split("\n").each do |line|
        if m = /ChEBI: (\d+)/.match(line)
          compound.chebi = m[1].to_i
        elsif m = /PubChem: (\d+)/.match(line)
          compound.pubchem = m[1].to_i
        end
      end
    when "GLYCAN"
      compound.glycan_entry = str
    when "///"
      #compound.save
    end
  end
end

Instance Method Details

#set_compoundsObject



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/chem/db/kegg.rb', line 529

def set_compounds
  require 'util'
  Dir.glob($home + "/mol/*.mol").each do |mol|
    entry = /(.\d+).mol/.match(mol)[1]
#        comp = KeggCompound.find(:first, :conditions => ["entry = ?", entry])
    mol = Chem.open_mol(mol)
    if comp == nil
      puts mol
      next
    end
    if comp.ctab == nil
      comp.ctab = Marshal.dump(mol)
      comp.save
    end
    #p comp
  end
end