bio 1.4.3.0001 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.travis.yml +39 -33
- data/BSDL +22 -0
- data/COPYING +2 -2
- data/COPYING.ja +36 -36
- data/ChangeLog +2404 -1025
- data/KNOWN_ISSUES.rdoc +15 -55
- data/README.rdoc +17 -23
- data/RELEASE_NOTES.rdoc +246 -183
- data/Rakefile +3 -2
- data/bin/br_biofetch.rb +29 -5
- data/bioruby.gemspec +15 -32
- data/bioruby.gemspec.erb +10 -20
- data/doc/ChangeLog-1.4.3 +1478 -0
- data/doc/RELEASE_NOTES-1.4.3.rdoc +204 -0
- data/doc/Tutorial.rd +0 -6
- data/doc/Tutorial.rd.html +7 -12
- data/doc/Tutorial.rd.ja +960 -1064
- data/doc/Tutorial.rd.ja.html +977 -1067
- data/gemfiles/Gemfile.travis-jruby1.8 +2 -1
- data/gemfiles/Gemfile.travis-jruby1.9 +2 -4
- data/gemfiles/Gemfile.travis-rbx +13 -0
- data/gemfiles/Gemfile.travis-ruby1.8 +2 -1
- data/gemfiles/Gemfile.travis-ruby1.9 +2 -4
- data/gemfiles/Gemfile.travis-ruby2.2 +9 -0
- data/lib/bio.rb +10 -43
- data/lib/bio/alignment.rb +8 -14
- data/lib/bio/appl/blast.rb +1 -2
- data/lib/bio/appl/blast/format0.rb +18 -7
- data/lib/bio/appl/blast/remote.rb +0 -9
- data/lib/bio/appl/blast/report.rb +1 -1
- data/lib/bio/appl/clustalw/report.rb +3 -1
- data/lib/bio/appl/genscan/report.rb +1 -2
- data/lib/bio/appl/iprscan/report.rb +1 -2
- data/lib/bio/appl/meme/mast.rb +4 -4
- data/lib/bio/appl/meme/mast/report.rb +1 -1
- data/lib/bio/appl/paml/codeml.rb +2 -2
- data/lib/bio/appl/paml/codeml/report.rb +1 -0
- data/lib/bio/appl/paml/common.rb +1 -1
- data/lib/bio/appl/sosui/report.rb +1 -2
- data/lib/bio/command.rb +62 -2
- data/lib/bio/data/aa.rb +13 -31
- data/lib/bio/data/codontable.rb +1 -2
- data/lib/bio/db/biosql/biosql_to_biosequence.rb +1 -0
- data/lib/bio/db/biosql/sequence.rb +1 -1
- data/lib/bio/db/embl/common.rb +1 -1
- data/lib/bio/db/embl/embl.rb +5 -4
- data/lib/bio/db/embl/format_embl.rb +3 -3
- data/lib/bio/db/embl/sptr.rb +9 -1444
- data/lib/bio/db/embl/swissprot.rb +12 -29
- data/lib/bio/db/embl/trembl.rb +13 -30
- data/lib/bio/db/embl/uniprot.rb +12 -29
- data/lib/bio/db/embl/uniprotkb.rb +1455 -0
- data/lib/bio/db/fasta.rb +17 -0
- data/lib/bio/db/fasta/defline.rb +1 -3
- data/lib/bio/db/fastq.rb +1 -1
- data/lib/bio/db/genbank/ddbj.rb +9 -5
- data/lib/bio/db/genbank/refseq.rb +11 -3
- data/lib/bio/db/gff.rb +3 -4
- data/lib/bio/db/go.rb +5 -6
- data/lib/bio/db/kegg/module.rb +4 -5
- data/lib/bio/db/kegg/pathway.rb +4 -5
- data/lib/bio/db/kegg/reaction.rb +1 -1
- data/lib/bio/db/nexus.rb +3 -2
- data/lib/bio/db/pdb/pdb.rb +2 -2
- data/lib/bio/db/phyloxml/phyloxml_elements.rb +82 -59
- data/lib/bio/db/phyloxml/phyloxml_parser.rb +2 -2
- data/lib/bio/db/phyloxml/phyloxml_writer.rb +1 -2
- data/lib/bio/db/sanger_chromatogram/chromatogram.rb +1 -2
- data/lib/bio/db/transfac.rb +1 -1
- data/lib/bio/io/das.rb +40 -41
- data/lib/bio/io/fastacmd.rb +0 -16
- data/lib/bio/io/fetch.rb +111 -55
- data/lib/bio/io/flatfile/buffer.rb +4 -5
- data/lib/bio/io/hinv.rb +2 -3
- data/lib/bio/io/ncbirest.rb +43 -6
- data/lib/bio/io/pubmed.rb +76 -81
- data/lib/bio/io/togows.rb +33 -10
- data/lib/bio/map.rb +1 -1
- data/lib/bio/pathway.rb +1 -1
- data/lib/bio/sequence/compat.rb +1 -1
- data/lib/bio/sequence/na.rb +63 -12
- data/lib/bio/shell.rb +0 -2
- data/lib/bio/shell/core.rb +5 -6
- data/lib/bio/shell/interface.rb +3 -4
- data/lib/bio/shell/irb.rb +1 -2
- data/lib/bio/shell/plugin/entry.rb +2 -3
- data/lib/bio/shell/plugin/seq.rb +7 -6
- data/lib/bio/shell/setup.rb +1 -2
- data/lib/bio/tree.rb +2 -2
- data/lib/bio/util/contingency_table.rb +0 -2
- data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +2 -2
- data/lib/bio/util/sirna.rb +76 -16
- data/lib/bio/version.rb +8 -9
- data/sample/benchmark_clustalw_report.rb +47 -0
- data/sample/biofetch.rb +248 -151
- data/setup.rb +6 -7
- data/test/data/clustalw/example1-seqnos.aln +58 -0
- data/test/network/bio/appl/blast/test_remote.rb +1 -15
- data/test/network/bio/appl/test_blast.rb +0 -12
- data/test/network/bio/io/test_pubmed.rb +49 -0
- data/test/network/bio/io/test_togows.rb +0 -1
- data/test/network/bio/test_command.rb +65 -2
- data/test/unit/bio/appl/bl2seq/test_report.rb +0 -1
- data/test/unit/bio/appl/blast/test_report.rb +110 -48
- data/test/unit/bio/appl/clustalw/test_report.rb +67 -51
- data/test/unit/bio/appl/sim4/test_report.rb +46 -17
- data/test/unit/bio/appl/test_blast.rb +2 -2
- data/test/unit/bio/db/embl/test_embl.rb +0 -1
- data/test/unit/bio/db/embl/test_embl_rel89.rb +0 -1
- data/test/unit/bio/db/embl/{test_sptr.rb → test_uniprotkb.rb} +111 -115
- data/test/unit/bio/db/embl/{test_uniprot_new_part.rb → test_uniprotkb_new_part.rb} +11 -11
- data/test/unit/bio/db/genbank/test_genbank.rb +10 -4
- data/test/unit/bio/db/pdb/test_pdb.rb +14 -8
- data/test/unit/bio/db/test_fasta.rb +41 -1
- data/test/unit/bio/db/test_fastq.rb +14 -4
- data/test/unit/bio/db/test_gff.rb +2 -2
- data/test/unit/bio/db/test_phyloxml.rb +30 -30
- data/test/unit/bio/db/test_phyloxml_writer.rb +2 -2
- data/test/unit/bio/io/flatfile/test_autodetection.rb +1 -2
- data/test/unit/bio/io/flatfile/test_buffer.rb +7 -1
- data/test/unit/bio/io/flatfile/test_splitter.rb +1 -1
- data/test/unit/bio/io/test_togows.rb +3 -2
- data/test/unit/bio/sequence/test_dblink.rb +1 -1
- data/test/unit/bio/sequence/test_na.rb +3 -1
- data/test/unit/bio/test_alignment.rb +1 -2
- data/test/unit/bio/test_command.rb +5 -4
- data/test/unit/bio/test_db.rb +4 -2
- data/test/unit/bio/test_pathway.rb +25 -10
- data/test/unit/bio/util/test_sirna.rb +22 -22
- metadata +656 -1430
- data/doc/KEGG_API.rd +0 -1843
- data/doc/KEGG_API.rd.ja +0 -1834
- data/extconf.rb +0 -2
- data/lib/bio/appl/blast/ddbj.rb +0 -131
- data/lib/bio/db/kegg/taxonomy.rb +0 -280
- data/lib/bio/io/dbget.rb +0 -194
- data/lib/bio/io/ddbjrest.rb +0 -344
- data/lib/bio/io/ddbjxml.rb +0 -458
- data/lib/bio/io/ebisoap.rb +0 -158
- data/lib/bio/io/ensembl.rb +0 -229
- data/lib/bio/io/higet.rb +0 -73
- data/lib/bio/io/keggapi.rb +0 -363
- data/lib/bio/io/ncbisoap.rb +0 -156
- data/lib/bio/io/soapwsdl.rb +0 -119
- data/lib/bio/shell/plugin/keggapi.rb +0 -181
- data/lib/bio/shell/plugin/soap.rb +0 -87
- data/sample/dbget +0 -37
- data/sample/demo_ddbjxml.rb +0 -212
- data/sample/demo_kegg_taxonomy.rb +0 -92
- data/sample/demo_keggapi.rb +0 -502
- data/sample/psortplot_html.rb +0 -214
- data/test/network/bio/io/test_ddbjrest.rb +0 -47
- data/test/network/bio/io/test_ensembl.rb +0 -230
- data/test/network/bio/io/test_soapwsdl.rb +0 -53
- data/test/unit/bio/io/test_ddbjxml.rb +0 -81
- data/test/unit/bio/io/test_ensembl.rb +0 -111
- data/test/unit/bio/io/test_soapwsdl.rb +0 -33
@@ -5,7 +5,6 @@
|
|
5
5
|
#
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id:$
|
9
8
|
#
|
10
9
|
#
|
11
10
|
# See documents for Bio::FlatFile::BufferedInputStream and Bio::FlatFile.
|
@@ -151,8 +150,8 @@ module Bio
|
|
151
150
|
yield self.new(fobj, uri.to_s)
|
152
151
|
end
|
153
152
|
else
|
154
|
-
|
155
|
-
self.new(
|
153
|
+
fobj0 = uri.open(*arg)
|
154
|
+
self.new(fobj0, uri.to_s)
|
156
155
|
end
|
157
156
|
else
|
158
157
|
if block_given?
|
@@ -160,8 +159,8 @@ module Bio
|
|
160
159
|
yield self.new(fobj, uri)
|
161
160
|
end
|
162
161
|
else
|
163
|
-
|
164
|
-
self.new(
|
162
|
+
fobj0 = OpenURI.open_uri(uri, *arg)
|
163
|
+
self.new(fobj0, uri)
|
165
164
|
end
|
166
165
|
end
|
167
166
|
end
|
data/lib/bio/io/hinv.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
# Copyright:: Copyright (C) 2008 Toshiaki Katayama <k@bioruby.org>
|
5
5
|
# License:: The Ruby License
|
6
6
|
#
|
7
|
-
# $Id:$
|
8
7
|
#
|
9
8
|
|
10
9
|
require 'bio/command'
|
@@ -17,11 +16,11 @@ module Bio
|
|
17
16
|
# Accessing the H-invDB web services.
|
18
17
|
#
|
19
18
|
# * http://www.h-invitational.jp/
|
20
|
-
# * http://
|
19
|
+
# * http://h-invitational.jp/hinv/hws/doc/index.html
|
21
20
|
#
|
22
21
|
class Hinv
|
23
22
|
|
24
|
-
BASE_URI = "http://
|
23
|
+
BASE_URI = "http://h-invitational.jp/hinv/hws/"
|
25
24
|
|
26
25
|
module Common
|
27
26
|
def query(options = nil)
|
data/lib/bio/io/ncbirest.rb
CHANGED
@@ -15,13 +15,21 @@ module Bio
|
|
15
15
|
|
16
16
|
class NCBI
|
17
17
|
|
18
|
-
autoload :SOAP, 'bio/io/ncbisoap'
|
19
18
|
|
20
19
|
# (Hash) Default parameters for Entrez (eUtils).
|
21
20
|
# They may also be used for other NCBI services.
|
22
21
|
ENTREZ_DEFAULT_PARAMETERS = {
|
23
|
-
|
24
|
-
|
22
|
+
# Cited from
|
23
|
+
# http://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.Release_Notes
|
24
|
+
# tool:
|
25
|
+
# Name of application making the E-utility call.
|
26
|
+
# Value must be a string with no internal spaces.
|
27
|
+
'tool' => "bioruby",
|
28
|
+
# Cited from
|
29
|
+
# http://www.ncbi.nlm.nih.gov/books/NBK25497/
|
30
|
+
# The value of email should be a complete and valid e-mail address
|
31
|
+
# of the software developer and not that of a third-party end user.
|
32
|
+
'email' => 'staff@bioruby.org',
|
25
33
|
}
|
26
34
|
|
27
35
|
# Resets Entrez (eUtils) default parameters.
|
@@ -29,8 +37,8 @@ class NCBI
|
|
29
37
|
# *Returns*:: (Hash) default parameters
|
30
38
|
def self.reset_entrez_default_parameters
|
31
39
|
h = {
|
32
|
-
'tool'
|
33
|
-
'email' =>
|
40
|
+
'tool' => "bioruby",
|
41
|
+
'email' => 'staff@bioruby.org',
|
34
42
|
}
|
35
43
|
ENTREZ_DEFAULT_PARAMETERS.clear
|
36
44
|
ENTREZ_DEFAULT_PARAMETERS.update(h)
|
@@ -45,6 +53,24 @@ class NCBI
|
|
45
53
|
|
46
54
|
# Sets default email address used for Entrez (eUtils).
|
47
55
|
# It may also be used for other NCBI services.
|
56
|
+
#
|
57
|
+
# In http://www.ncbi.nlm.nih.gov/books/NBK25497/
|
58
|
+
# NCBI says:
|
59
|
+
# "The value of email should be a complete and valid e-mail address of
|
60
|
+
# the software developer and not that of a third-party end user."
|
61
|
+
#
|
62
|
+
# By default, email address of BioRuby staffs is set.
|
63
|
+
#
|
64
|
+
# From the above NCBI documentation, the tool and email value is used
|
65
|
+
# only for unblocking IP addresses blocked by NCBI due to excess requests.
|
66
|
+
# For the purpose, NCBI says:
|
67
|
+
# "Please be aware that merely providing values for tool and email
|
68
|
+
# in requests is not sufficient to comply with this policy;
|
69
|
+
# these values must be registered with NCBI."
|
70
|
+
#
|
71
|
+
# Please use your own email address and tool name when registering
|
72
|
+
# tool and email values to NCBI.
|
73
|
+
#
|
48
74
|
# ---
|
49
75
|
# *Arguments*:
|
50
76
|
# * (required) _str_: (String) email address
|
@@ -62,6 +88,17 @@ class NCBI
|
|
62
88
|
|
63
89
|
# Sets default tool name for Entrez (eUtils).
|
64
90
|
# It may also be used for other NCBI services.
|
91
|
+
#
|
92
|
+
# In http://www.ncbi.nlm.nih.gov/books/NBK25497/
|
93
|
+
# NCBI says:
|
94
|
+
# "The value of tool should be a string with no internal spaces that
|
95
|
+
# uniquely identifies the software producing the request."
|
96
|
+
#
|
97
|
+
# "bioruby" is set by default.
|
98
|
+
# Please use your own tool name when registering to NCBI.
|
99
|
+
#
|
100
|
+
# See the document of default_email= for more information.
|
101
|
+
#
|
65
102
|
# ---
|
66
103
|
# *Arguments*:
|
67
104
|
# * (required) _str_: (String) tool name
|
@@ -148,7 +185,7 @@ class REST
|
|
148
185
|
def ncbi_check_parameters(opts)
|
149
186
|
#return if Time.now < Time.gm(2010,5,31)
|
150
187
|
if opts['email'].to_s.empty? then
|
151
|
-
raise 'Set email parameter for the query, or set Bio::NCBI.default_email = "(
|
188
|
+
raise 'Set email parameter for the query, or set Bio::NCBI.default_email = "(email address of the author of this software)"'
|
152
189
|
end
|
153
190
|
if opts['tool'].to_s.empty? then
|
154
191
|
raise 'Set tool parameter for the query, or set Bio::NCBI.default_tool = "(your tool name)"'
|
data/lib/bio/io/pubmed.rb
CHANGED
@@ -5,47 +5,42 @@
|
|
5
5
|
# Copyright:: Copyright (C) 2006 Jan Aerts <jan.aerts@bbsrc.ac.uk>
|
6
6
|
# License:: The Ruby License
|
7
7
|
#
|
8
|
-
# $Id:$
|
9
|
-
#
|
10
8
|
|
11
9
|
require 'bio/io/ncbirest'
|
12
|
-
require 'bio/command'
|
13
|
-
require 'cgi'
|
14
10
|
|
15
11
|
module Bio
|
16
12
|
|
17
13
|
# == Description
|
18
14
|
#
|
19
15
|
# The Bio::PubMed class provides several ways to retrieve bibliographic
|
20
|
-
# information from the PubMed database at
|
21
|
-
# http://www.ncbi.nlm.nih.gov/sites/entrez?db=PubMed
|
16
|
+
# information from the PubMed database at NCBI.
|
22
17
|
#
|
23
18
|
# Basically, two types of queries are possible:
|
24
19
|
#
|
25
20
|
# * searching for PubMed IDs given a query string:
|
26
21
|
# * Bio::PubMed#esearch (recommended)
|
27
|
-
# * Bio::PubMed#search (only retrieves top 20 hits)
|
22
|
+
# * Bio::PubMed#search (only retrieves top 20 hits; will be deprecated)
|
28
23
|
#
|
29
24
|
# * retrieving the MEDLINE text (i.e. authors, journal, abstract, ...)
|
30
25
|
# given a PubMed ID
|
31
26
|
# * Bio::PubMed#efetch (recommended)
|
32
|
-
# * Bio::PubMed#query (
|
33
|
-
# * Bio::PubMed#pmfetch (
|
27
|
+
# * Bio::PubMed#query (will be deprecated)
|
28
|
+
# * Bio::PubMed#pmfetch (will be deprecated)
|
34
29
|
#
|
35
|
-
#
|
36
|
-
#
|
30
|
+
# Since BioRuby 1.5, all implementations uses NCBI E-Utilities services.
|
31
|
+
# The different methods within the same group still remain because
|
32
|
+
# specifications of arguments and/or return values are different.
|
33
|
+
# The search, query, and pmfetch will be obsoleted in the future.
|
37
34
|
#
|
38
35
|
# Additional information about the MEDLINE format and PubMed programmable
|
39
36
|
# APIs can be found on the following websites:
|
40
37
|
#
|
41
|
-
# * PubMed
|
42
|
-
#
|
43
|
-
# *
|
44
|
-
#
|
45
|
-
# *
|
46
|
-
#
|
47
|
-
# * How to link:
|
48
|
-
# http://www.ncbi.nlm.nih.gov/books/bv.fcgi?rid=helplinks.chapter.linkshelp
|
38
|
+
# * PubMed Tutorial:
|
39
|
+
# http://www.nlm.nih.gov/bsd/disted/pubmedtutorial/index.html
|
40
|
+
# * E-utilities Quick Start:
|
41
|
+
# http://www.ncbi.nlm.nih.gov/books/NBK25500/
|
42
|
+
# * Creating a Web Link to PubMed:
|
43
|
+
# http://www.ncbi.nlm.nih.gov/books/NBK3862/
|
49
44
|
#
|
50
45
|
# == Usage
|
51
46
|
#
|
@@ -61,10 +56,14 @@ module Bio
|
|
61
56
|
# end
|
62
57
|
#
|
63
58
|
# # To retrieve the MEDLINE entry for a given PubMed ID:
|
64
|
-
#
|
59
|
+
# Bio::PubMed.efetch("10592173").each { |x| puts x }
|
65
60
|
# puts Bio::PubMed.query("10592173")
|
66
61
|
# puts Bio::PubMed.pmfetch("10592173")
|
67
62
|
#
|
63
|
+
# # To retrieve MEDLINE entries for given PubMed IDs:
|
64
|
+
# Bio::PubMed.efetch([ "10592173", "14693808" ]).each { |x| puts x }
|
65
|
+
# puts Bio::PubMed.query("10592173", "14693808") # returns a String
|
66
|
+
#
|
68
67
|
# # This can be converted into a Bio::MEDLINE object:
|
69
68
|
# manuscript = Bio::PubMed.query("10592173")
|
70
69
|
# medline = Bio::MEDLINE.new(manuscript)
|
@@ -80,15 +79,15 @@ class PubMed < Bio::NCBI::REST
|
|
80
79
|
# *Arguments*:
|
81
80
|
# * _str_: query string (required)
|
82
81
|
# * _hash_: hash of E-Utils options
|
83
|
-
# *
|
84
|
-
# *
|
85
|
-
# *
|
86
|
-
# *
|
87
|
-
# *
|
88
|
-
# *
|
89
|
-
# *
|
90
|
-
# *
|
91
|
-
# *
|
82
|
+
# * _"retmode"_: "xml", "html", ...
|
83
|
+
# * _"rettype"_: "medline", ...
|
84
|
+
# * _"retmax"_: integer (default 100)
|
85
|
+
# * _"retstart"_: integer
|
86
|
+
# * _"field"_
|
87
|
+
# * _"reldate"_
|
88
|
+
# * _"mindate"_
|
89
|
+
# * _"maxdate"_
|
90
|
+
# * _"datetype"_
|
92
91
|
# *Returns*:: array of PubMed IDs or a number of results
|
93
92
|
def esearch(str, hash = {})
|
94
93
|
opts = { "db" => "pubmed" }
|
@@ -104,15 +103,15 @@ class PubMed < Bio::NCBI::REST
|
|
104
103
|
# *Arguments*:
|
105
104
|
# * _ids_: list of PubMed IDs (required)
|
106
105
|
# * _hash_: hash of E-Utils options
|
107
|
-
# *
|
108
|
-
# *
|
109
|
-
# *
|
110
|
-
# *
|
111
|
-
# *
|
112
|
-
# *
|
113
|
-
# *
|
114
|
-
# *
|
115
|
-
# *
|
106
|
+
# * _"retmode"_: "xml", "html", ...
|
107
|
+
# * _"rettype"_: "medline", ...
|
108
|
+
# * _"retmax"_: integer (default 100)
|
109
|
+
# * _"retstart"_: integer
|
110
|
+
# * _"field"_
|
111
|
+
# * _"reldate"_
|
112
|
+
# * _"mindate"_
|
113
|
+
# * _"maxdate"_
|
114
|
+
# * _"datetype"_
|
116
115
|
# *Returns*:: Array of MEDLINE formatted String
|
117
116
|
def efetch(ids, hash = {})
|
118
117
|
opts = { "db" => "pubmed", "rettype" => "medline" }
|
@@ -124,26 +123,29 @@ class PubMed < Bio::NCBI::REST
|
|
124
123
|
result
|
125
124
|
end
|
126
125
|
|
126
|
+
# This method will be DEPRECATED in the future.
|
127
|
+
#
|
127
128
|
# Search the PubMed database by given keywords using entrez query and returns
|
128
|
-
# an array of PubMed IDs.
|
129
|
+
# an array of PubMed IDs.
|
130
|
+
#
|
131
|
+
# Caution: this method returns the first 20 hits only,
|
132
|
+
#
|
129
133
|
# Instead, use of the 'esearch' method is strongly recomended.
|
134
|
+
#
|
135
|
+
# Implementation details: Since BioRuby 1.5, this method internally uses
|
136
|
+
# NCBI EUtils with retmax=20 by using Bio::PubMed#efetch method.
|
137
|
+
#
|
130
138
|
# ---
|
131
139
|
# *Arguments*:
|
132
140
|
# * _id_: query string (required)
|
133
141
|
# *Returns*:: array of PubMed IDs
|
134
142
|
def search(str)
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
ncbi_access_wait
|
139
|
-
|
140
|
-
http = Bio::Command.new_http(host)
|
141
|
-
response = http.get(path + CGI.escape(str))
|
142
|
-
result = response.body
|
143
|
-
result = result.scan(/value="(\d+)" id="UidCheckBox"/m).flatten
|
144
|
-
return result
|
143
|
+
warn "Bio::PubMed#search is now a subset of Bio::PubMed#esearch. Using Bio::PubMed#esearch is recommended." if $VERBOSE
|
144
|
+
esearch(str, { "retmax" => 20 })
|
145
145
|
end
|
146
146
|
|
147
|
+
# This method will be DEPRECATED in the future.
|
148
|
+
#
|
147
149
|
# Retrieve PubMed entry by PMID and returns MEDLINE formatted string using
|
148
150
|
# entrez query.
|
149
151
|
# ---
|
@@ -151,68 +153,61 @@ class PubMed < Bio::NCBI::REST
|
|
151
153
|
# * _id_: PubMed ID (required)
|
152
154
|
# *Returns*:: MEDLINE formatted String
|
153
155
|
def query(*ids)
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
ncbi_access_wait
|
159
|
-
|
160
|
-
http = Bio::Command.new_http(host)
|
161
|
-
response = http.get(path + list)
|
162
|
-
result = response.body
|
163
|
-
result = result.scan(/<pre>\s*(.*?)<\/pre>/m).flatten
|
164
|
-
|
165
|
-
if result =~ /id:.*Error occurred/
|
166
|
-
# id: xxxxx Error occurred: Article does not exist
|
167
|
-
raise( result )
|
156
|
+
warn "Bio::PubMed#query internally uses Bio::PubMed#efetch. Using Bio::PubMed#efetch is recommended." if $VERBOSE
|
157
|
+
ret = efetch(ids)
|
158
|
+
if ret && ret.size > 0 then
|
159
|
+
ret.join("\n\n") + "\n"
|
168
160
|
else
|
169
|
-
|
170
|
-
return result
|
171
|
-
else
|
172
|
-
return result.first
|
173
|
-
end
|
161
|
+
""
|
174
162
|
end
|
175
163
|
end
|
176
164
|
|
177
|
-
#
|
178
|
-
#
|
165
|
+
# This method will be DEPRECATED in the future.
|
166
|
+
#
|
167
|
+
# Retrieve PubMed entry by PMID and returns MEDLINE formatted string.
|
168
|
+
#
|
179
169
|
# ---
|
180
170
|
# *Arguments*:
|
181
171
|
# * _id_: PubMed ID (required)
|
182
172
|
# *Returns*:: MEDLINE formatted String
|
183
173
|
def pmfetch(id)
|
184
|
-
|
185
|
-
path = "/entrez/utils/pmfetch.fcgi?tool=bioruby&mode=text&report=medline&db=PubMed&id="
|
186
|
-
|
187
|
-
ncbi_access_wait
|
174
|
+
warn "Bio::PubMed#pmfetch internally use Bio::PubMed#efetch. Using Bio::PubMed#efetch is recommended." if $VERBOSE
|
188
175
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
if result =~ /#{id}\s+Error/
|
193
|
-
raise( result )
|
176
|
+
ret = efetch(id)
|
177
|
+
if ret && ret.size > 0 then
|
178
|
+
ret.join("\n\n") + "\n"
|
194
179
|
else
|
195
|
-
|
196
|
-
return result
|
180
|
+
""
|
197
181
|
end
|
198
182
|
end
|
199
183
|
|
184
|
+
# The same as Bio::PubMed.new.esearch(*args).
|
200
185
|
def self.esearch(*args)
|
201
186
|
self.new.esearch(*args)
|
202
187
|
end
|
203
188
|
|
189
|
+
# The same as Bio::PubMed.new.efetch(*args).
|
204
190
|
def self.efetch(*args)
|
205
191
|
self.new.efetch(*args)
|
206
192
|
end
|
207
193
|
|
194
|
+
# This method will be DEPRECATED. Use esearch method.
|
195
|
+
#
|
196
|
+
# The same as Bio::PubMed.new.search(*args).
|
208
197
|
def self.search(*args)
|
209
198
|
self.new.search(*args)
|
210
199
|
end
|
211
200
|
|
201
|
+
# This method will be DEPRECATED. Use efetch method.
|
202
|
+
#
|
203
|
+
# The same as Bio::PubMed.new.query(*args).
|
212
204
|
def self.query(*args)
|
213
205
|
self.new.query(*args)
|
214
206
|
end
|
215
207
|
|
208
|
+
# This method will be DEPRECATED. Use efetch method.
|
209
|
+
#
|
210
|
+
# The same as Bio::PubMed.new.pmfetch(*args).
|
216
211
|
def self.pmfetch(*args)
|
217
212
|
self.new.pmfetch(*args)
|
218
213
|
end
|
data/lib/bio/io/togows.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
# Copyright:: Copyright (C) 2009 Naohisa Goto <ng@bioruby.org>
|
5
5
|
# License:: The Ruby License
|
6
6
|
#
|
7
|
-
# $Id:$
|
8
7
|
#
|
9
8
|
# Bio::TogoWS is a set of clients for the TogoWS web services
|
10
9
|
# (http://togows.dbcls.jp/).
|
@@ -245,9 +244,16 @@ module Bio
|
|
245
244
|
rescue NoMethodError
|
246
245
|
ids = ids.to_s
|
247
246
|
end
|
248
|
-
ids = a.join(',') if a
|
249
247
|
|
250
|
-
arg = [ 'entry', database
|
248
|
+
arg = [ 'entry', database ]
|
249
|
+
if a then
|
250
|
+
b = a.dup
|
251
|
+
(a.size - 1).downto(1) { |i| b.insert(i, :",") }
|
252
|
+
arg.concat b
|
253
|
+
else
|
254
|
+
arg.push ids
|
255
|
+
end
|
256
|
+
|
251
257
|
arg.push field if field
|
252
258
|
arg[-1] = "#{arg[-1]}.#{format}" if format
|
253
259
|
response = get(*arg)
|
@@ -280,7 +286,7 @@ module Bio
|
|
280
286
|
arg = [ 'search', database, query ]
|
281
287
|
if offset then
|
282
288
|
limit ||= 1
|
283
|
-
arg.
|
289
|
+
arg.concat [ "#{offset}", :",", "#{limit}" ]
|
284
290
|
end
|
285
291
|
arg[-1] = "#{arg[-1]}.#{format}" if format
|
286
292
|
response = get(*arg)
|
@@ -398,8 +404,7 @@ module Bio
|
|
398
404
|
end
|
399
405
|
|
400
406
|
# Access to the TogoWS by using POST method.
|
401
|
-
#
|
402
|
-
# Mime type is 'application/x-www-form-urlencoded'.
|
407
|
+
# Mime type is 'application/octet-stream'.
|
403
408
|
# ---
|
404
409
|
# *Arguments*:
|
405
410
|
# * (required) _data_: String
|
@@ -408,19 +413,37 @@ module Bio
|
|
408
413
|
def post_data(data, *paths)
|
409
414
|
path = make_path(paths)
|
410
415
|
if @debug then
|
411
|
-
$stderr.puts "TogoWS: Bio::Command.
|
416
|
+
$stderr.puts "TogoWS: Bio::Command.http_post(#{path.inspect}, data(#{data.size} bytes), #{@header.inspect})"
|
412
417
|
end
|
413
418
|
togows_access_wait
|
414
|
-
Bio::Command.
|
419
|
+
Bio::Command.http_post(@http, path, data, @header)
|
415
420
|
end
|
416
421
|
|
417
422
|
# Generates path string from the given paths.
|
423
|
+
# Symbol objects are not URL-escaped.
|
424
|
+
# String objects are joined with '/'.
|
425
|
+
# Symbol objects are joined directly without '/'.
|
426
|
+
#
|
418
427
|
# ---
|
419
428
|
# *Arguments*:
|
420
|
-
# * (required) _paths_: Array containing String objects
|
429
|
+
# * (required) _paths_: Array containing String or Symbol objects
|
421
430
|
# *Returns*:: String
|
422
431
|
def make_path(paths)
|
423
|
-
|
432
|
+
flag_sep = false
|
433
|
+
a = paths.collect do |x|
|
434
|
+
case x
|
435
|
+
when Symbol
|
436
|
+
# without URL escape
|
437
|
+
flag_sep = false
|
438
|
+
str = x.to_s
|
439
|
+
else
|
440
|
+
str = CGI.escape(x.to_s)
|
441
|
+
str = '/' + str if flag_sep
|
442
|
+
flag_sep = true
|
443
|
+
end
|
444
|
+
str
|
445
|
+
end
|
446
|
+
@pathbase + a.join('')
|
424
447
|
end
|
425
448
|
|
426
449
|
# If response.code == "200", returns body as a String.
|