Module: UniProt
- Extended by:
- Resource
- Defined in:
- lib/rbbt/sources/uniprot.rb
Constant Summary collapse
- UNIPROT_TEXT =
"http://www.uniprot.org/uniprot/[PROTEIN].txt"
- UNIPROT_FASTA =
"http://www.uniprot.org/uniprot/[PROTEIN].fasta"
Class Method Summary collapse
- .cath(protein) ⇒ Object
- .cath_domains(protein) ⇒ Object
- .features(protein) ⇒ Object
- .pdbs(protein) ⇒ Object
- .pdbs_covering_aa_position(protein, aa_position) ⇒ Object
- .sequence(protein) ⇒ Object
- .variants(protein) ⇒ Object
Class Method Details
.cath(protein) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/rbbt/sources/uniprot.rb', line 159 def self.cath(protein) url = UNIPROT_TEXT.sub "[PROTEIN]", protein text = Open.read(url) cath = {} text.split(/\n/).each{|l| next unless l =~ /^DR\s+Gene3D; G3DSA:(.*)\./ id, description, cuantity = $1.split(";").collect{|v| v.strip} cath[id] = {:description => description, :cuantity => cuantity} } cath end |
.cath_domains(protein) ⇒ Object
172 173 174 175 176 177 |
# File 'lib/rbbt/sources/uniprot.rb', line 172 def self.cath_domains(protein) pdbs = pdbs(protein).keys.uniq pdbs.collect do |pdb| Cath.domains_for_pdb(pdb) end.flatten.compact end |
.features(protein) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/rbbt/sources/uniprot.rb', line 68 def self.features(protein) url = UNIPROT_TEXT.sub "[PROTEIN]", protein text = Open.read(url) text = text.split(/\n/).select{|line| line =~ /^FT/} * "\n" parts = text.split(/^(FT \w+)/) parts.shift features = [] type = nil parts.each do |part| parts if part[0..1] == "FT" type = part.gsub(/FT\s+/,'') next end value = part.gsub("\nFT", '').gsub(/\s+/, ' ') case when value.match(/(\d+) (\d+) (.*)/) start, eend, description = $1, $2, $3 description.gsub(/^FT\s+/m, '') when value.match(/(\d+) (\d+)/) start, eend = $1, $2 description = nil else Log.debug "Value not understood: #{ value }" end feature = { :type => type, :start => start.to_i, :end => eend.to_i, :description => description, } features << feature end features end |
.pdbs(protein) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rbbt/sources/uniprot.rb', line 38 def self.pdbs(protein) url = UNIPROT_TEXT.sub "[PROTEIN]", protein text = Open.read(url) pdb = {} text.split(/\n/).each{|l| next unless l =~ /^DR\s+PDB; (.*)\./ id, method, resolution, region = $1.split(";").collect{|v| v.strip} begin chains, start, eend = region.match(/(\w+)=(\d+)-(\d+)/).values_at(1,2,3) start = start.to_i eend = eend.to_i start, eend = eend, start if start > eend rescue Log.warn("Error process Uniprot PDB line: #{line}") next end pdb[id.downcase] = {:method => method, :resolution => resolution, :region => (start..eend), :chains => chains} } pdb end |
.pdbs_covering_aa_position(protein, aa_position) ⇒ Object
179 180 181 182 183 |
# File 'lib/rbbt/sources/uniprot.rb', line 179 def self.pdbs_covering_aa_position(protein, aa_position) UniProt.pdbs(protein).select do |pdb, info| info[:region].include? aa_position end end |
.sequence(protein) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/rbbt/sources/uniprot.rb', line 61 def self.sequence(protein) url = UNIPROT_FASTA.sub "[PROTEIN]", protein text = Open.read(url) text.split(/\n/).select{|line| line !~ /^>/} * "" end |
.variants(protein) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/rbbt/sources/uniprot.rb', line 113 def self.variants(protein) url = UNIPROT_TEXT.sub "[PROTEIN]", protein text = Open.read(url) text = text.split(/\n/).select{|line| line =~ /^FT/} * "\n" parts = text.split(/^(FT \w+)/) parts.shift variants = [] type = nil parts.each do |part| if type.nil? type = part else if type !~ /VARIANT/ type = nil next end type = nil value = part.gsub("\nFT", '').gsub(/\s+/, ' ') # 291 291 K -> E (in sporadic cancers; somatic mutation). /FTId=VAR_045413. case when value.match(/(\d+) (\d+) ([A-Z])\s*\-\>\s*([A-Z]) (.*)\. \/FTId=(.*)/) start, eend, ref, mut, desc, id = $1, $2, $3, $4, $5, $6 when value.match(/(\d+) (\d+) (.*)\. \/FTId=(.*)/) start, eend, ref, mut, desc, id = $1, $2, nil, nil, $3, $4 else Log.debug "Value not understood: #{ value }" end variants << { :start => start, :end => eend, :ref => ref, :mut => mut, :desc => desc, :id => id, } end end variants end |