Module: Cath

Extended by:
Resource
Defined in:
lib/rbbt/sources/cath.rb

Class Method Summary collapse

Class Method Details

.align(domain, sequence) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/rbbt/sources/cath.rb', line 123

def self.align(domain, sequence)
  require 'bio'

  return nil if not domain_sequences.include? domain

  TmpFile.with_file(">target\n" << sequence) do |target|
    TmpFile.with_file(">domain\n" << domain_sequences[domain]) do |domain|

      result = CMD.cmd("fasta35 #{ target } #{ domain }").read

      if result.match(/([\d\.]+)% identity.*overlap \((\d+)-(\d+):/s)
        {:identity => $1.to_f, :range => ($2.to_i..$3.to_i)}
      else
        false
      end
    end
  end
end

.cath_indexObject



78
79
80
# File 'lib/rbbt/sources/cath.rb', line 78

def self.cath_index
  @@cath ||= Rbbt.share.databases.CATH.CathNames.tsv :persist => true, :case_insensitive => true
end

.domain_sequencesObject



105
106
107
# File 'lib/rbbt/sources/cath.rb', line 105

def self.domain_sequences
  @@domain_sequences ||= Rbbt.share.databases.CATH.CathDomainSeqs.tsv(:persist => true)
end

.domains_for_pdb(pdb) ⇒ Object



118
119
120
121
# File 'lib/rbbt/sources/cath.rb', line 118

def self.domains_for_pdb(pdb)
  pdb2cath = pdb_index
  (pdb2cath[pdb] || []) + (unclassified[pdb] || [])
end

.pdb_indexObject



82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rbbt/sources/cath.rb', line 82

def self.pdb_index
  if not defined? @@pdb or @@pdb.nil?
    @@pdb = {}
    Rbbt.share.databases.CATH.CathDomainSeqs.read.split("\n").each do |line|
      domain = line.split(/\t/).first
      pdb = domain[0..3]
      @@pdb[pdb] ||= []
      @@pdb[pdb] << domain
    end
  end
  @@pdb
end

.pdbs(cath_code) ⇒ Object



109
110
111
112
113
114
115
116
# File 'lib/rbbt/sources/cath.rb', line 109

def self.pdbs(cath_code)
  cath = cath_index
  if cath.include? cath_code
    cath[cath_code]["PDB ID"]
  else
    nil
  end
end

.unclassifiedObject



95
96
97
98
99
100
101
102
103
# File 'lib/rbbt/sources/cath.rb', line 95

def self.unclassified
  @@unclassified = {}
  Rbbt.share.databases.CATH.CathUnclassifiedList.read.split("\n").each do |domain|
    pdb = domain[0..3]
    @@unclassified[pdb] ||= []
    @@unclassified[pdb] << domain
  end
  @@unclassified
end