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 Classes: ANumber, KCF, KCFAtom, KCFBond, KCFCorrespondence, KCFGlycan, KCFMolecule, KCFRXN, KCFReader, KEGGReaction, KeggCompound, KeggDirectory, KeggEc, KeggGlycan, KeggGlycanParser, KeggReaction, KeggReactionLstParser, KeggReactionMapParser, KeggReactionParser

Constant Summary collapse

@@kegg_compound_folder =

obsolete

nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.kegg_compound_folderObject



172
173
174
# File 'lib/chem/db/kegg.rb', line 172

def self.kegg_compound_folder
  @@kegg_compound_folder
end

.kegg_compound_folder=(folder) ⇒ Object



168
169
170
# File 'lib/chem/db/kegg.rb', line 168

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

.parse_compound_fileObject



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/chem/db/kegg.rb', line 467

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



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/chem/db/kegg.rb', line 495

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