Class: Chem::NCBI::EFetch

Inherits:
Object
  • Object
show all
Includes:
Chem::NetUtils
Defined in:
lib/chem/utils/net.rb

Overview

obsolete

Constant Summary collapse

EFetchURI =
EUtilsURI + 'efetch.fcgi' + '?'

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Chem::NetUtils

#http_get

Constructor Details

#initialize(query_key, web_env) ⇒ EFetch

Returns a new instance of EFetch.


190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/chem/utils/net.rb', line 190

def initialize(query_key, web_env)
  uri = [PCFetchURI]
  uri << 'db=pccompound'
  uri << '&WebEnv=' + web_env
  uri << '&query_key=' + query_key
  uri << '&retmode=sdf'
  uri << '&compression=none'
  #"retmode=xml&"
  #uri = EFetchURI + "&db=pccompound&retmode=xml&WebEnv=" + web_env + "&query_key=" + query_key + "&tool=oscar3&email=nobuya.tanaka%40gmail.com"
  p uri.join
  doc = http_get(uri.join)
  if m = /bookmarking this page or by going to<\/p><p><a href=\"([^"]+)/.match(doc)
    sleep 1
    p m[1]
    d = http_get(m[1])
    m = /"ftp:\/\/([^"]+)/.match(d)
    p m[1]
    require 'net/ftp'
    begin
      sleep 0.5
      ftp = Net::FTP.open("ftp.ncbi.nih.gov")
      ftp.
      ftp.gettextfile("pubchem/.fetch/606874731181068179.sdf")
    rescue Net::FTPPermError
      sleep 1
      puts 'OK'
    end
      
  end
end

Class Method Details

.fetch_all(query_key, web_env) ⇒ Object


221
222
223
# File 'lib/chem/utils/net.rb', line 221

def self.fetch_all(query_key, web_env)
  new(query_key, web_env)
end