bio 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/bioruby +107 -0
- data/bin/br_biofetch.rb +59 -0
- data/bin/br_bioflat.rb +294 -0
- data/bin/br_biogetseq.rb +57 -0
- data/bin/br_pmfetch.rb +431 -0
- data/doc/BioRuby.rd.ja +225 -0
- data/doc/Changes-0.7.rd +236 -0
- data/doc/Design.rd.ja +341 -0
- data/doc/KEGG_API.rd +1437 -0
- data/doc/KEGG_API.rd.ja +1399 -0
- data/doc/TODO.rd.ja +138 -0
- data/doc/Tutorial.rd +1138 -0
- data/doc/Tutorial.rd.ja +2110 -0
- data/etc/bioinformatics/seqdatabase.ini +210 -0
- data/lib/bio.rb +256 -0
- data/lib/bio/alignment.rb +1906 -0
- data/lib/bio/appl/bl2seq/report.rb +350 -0
- data/lib/bio/appl/blast.rb +269 -0
- data/lib/bio/appl/blast/format0.rb +1402 -0
- data/lib/bio/appl/blast/format8.rb +95 -0
- data/lib/bio/appl/blast/report.rb +652 -0
- data/lib/bio/appl/blast/rexml.rb +151 -0
- data/lib/bio/appl/blast/wublast.rb +553 -0
- data/lib/bio/appl/blast/xmlparser.rb +222 -0
- data/lib/bio/appl/blat/report.rb +392 -0
- data/lib/bio/appl/clustalw.rb +191 -0
- data/lib/bio/appl/clustalw/report.rb +154 -0
- data/lib/bio/appl/emboss.rb +68 -0
- data/lib/bio/appl/fasta.rb +262 -0
- data/lib/bio/appl/fasta/format10.rb +428 -0
- data/lib/bio/appl/fasta/format6.rb +37 -0
- data/lib/bio/appl/genscan/report.rb +570 -0
- data/lib/bio/appl/hmmer.rb +129 -0
- data/lib/bio/appl/hmmer/report.rb +556 -0
- data/lib/bio/appl/mafft.rb +222 -0
- data/lib/bio/appl/mafft/report.rb +119 -0
- data/lib/bio/appl/psort.rb +555 -0
- data/lib/bio/appl/psort/report.rb +473 -0
- data/lib/bio/appl/sim4.rb +134 -0
- data/lib/bio/appl/sim4/report.rb +501 -0
- data/lib/bio/appl/sosui/report.rb +166 -0
- data/lib/bio/appl/spidey/report.rb +604 -0
- data/lib/bio/appl/targetp/report.rb +283 -0
- data/lib/bio/appl/tmhmm/report.rb +238 -0
- data/lib/bio/command.rb +166 -0
- data/lib/bio/data/aa.rb +354 -0
- data/lib/bio/data/codontable.rb +740 -0
- data/lib/bio/data/na.rb +226 -0
- data/lib/bio/db.rb +340 -0
- data/lib/bio/db/aaindex.rb +280 -0
- data/lib/bio/db/embl/common.rb +332 -0
- data/lib/bio/db/embl/embl.rb +446 -0
- data/lib/bio/db/embl/sptr.rb +954 -0
- data/lib/bio/db/embl/swissprot.rb +32 -0
- data/lib/bio/db/embl/trembl.rb +31 -0
- data/lib/bio/db/embl/uniprot.rb +32 -0
- data/lib/bio/db/fantom.rb +604 -0
- data/lib/bio/db/fasta.rb +869 -0
- data/lib/bio/db/genbank/common.rb +299 -0
- data/lib/bio/db/genbank/ddbj.rb +34 -0
- data/lib/bio/db/genbank/genbank.rb +354 -0
- data/lib/bio/db/genbank/genpept.rb +73 -0
- data/lib/bio/db/genbank/refseq.rb +31 -0
- data/lib/bio/db/gff.rb +106 -0
- data/lib/bio/db/go.rb +497 -0
- data/lib/bio/db/kegg/brite.rb +51 -0
- data/lib/bio/db/kegg/cell.rb +88 -0
- data/lib/bio/db/kegg/compound.rb +130 -0
- data/lib/bio/db/kegg/enzyme.rb +125 -0
- data/lib/bio/db/kegg/expression.rb +173 -0
- data/lib/bio/db/kegg/genes.rb +293 -0
- data/lib/bio/db/kegg/genome.rb +362 -0
- data/lib/bio/db/kegg/glycan.rb +213 -0
- data/lib/bio/db/kegg/keggtab.rb +418 -0
- data/lib/bio/db/kegg/kgml.rb +299 -0
- data/lib/bio/db/kegg/ko.rb +178 -0
- data/lib/bio/db/kegg/reaction.rb +97 -0
- data/lib/bio/db/litdb.rb +131 -0
- data/lib/bio/db/medline.rb +317 -0
- data/lib/bio/db/nbrf.rb +199 -0
- data/lib/bio/db/pdb.rb +38 -0
- data/lib/bio/db/pdb/atom.rb +60 -0
- data/lib/bio/db/pdb/chain.rb +117 -0
- data/lib/bio/db/pdb/model.rb +106 -0
- data/lib/bio/db/pdb/pdb.rb +1682 -0
- data/lib/bio/db/pdb/residue.rb +122 -0
- data/lib/bio/db/pdb/utils.rb +234 -0
- data/lib/bio/db/prosite.rb +616 -0
- data/lib/bio/db/rebase.rb +417 -0
- data/lib/bio/db/transfac.rb +387 -0
- data/lib/bio/feature.rb +201 -0
- data/lib/bio/io/brdb.rb +103 -0
- data/lib/bio/io/das.rb +471 -0
- data/lib/bio/io/dbget.rb +212 -0
- data/lib/bio/io/ddbjxml.rb +614 -0
- data/lib/bio/io/fastacmd.rb +123 -0
- data/lib/bio/io/fetch.rb +114 -0
- data/lib/bio/io/flatfile.rb +496 -0
- data/lib/bio/io/flatfile/bdb.rb +266 -0
- data/lib/bio/io/flatfile/index.rb +1308 -0
- data/lib/bio/io/flatfile/indexer.rb +778 -0
- data/lib/bio/io/higet.rb +92 -0
- data/lib/bio/io/keggapi.rb +863 -0
- data/lib/bio/io/pubmed.rb +189 -0
- data/lib/bio/io/registry.rb +308 -0
- data/lib/bio/io/soapwsdl.rb +114 -0
- data/lib/bio/io/sql.rb +428 -0
- data/lib/bio/location.rb +650 -0
- data/lib/bio/pathway.rb +991 -0
- data/lib/bio/reference.rb +308 -0
- data/lib/bio/sequence.rb +593 -0
- data/lib/bio/shell.rb +51 -0
- data/lib/bio/shell/core.rb +512 -0
- data/lib/bio/shell/plugin/codon.rb +228 -0
- data/lib/bio/shell/plugin/entry.rb +85 -0
- data/lib/bio/shell/plugin/flatfile.rb +119 -0
- data/lib/bio/shell/plugin/keggapi.rb +187 -0
- data/lib/bio/shell/plugin/midi.rb +448 -0
- data/lib/bio/shell/plugin/obda.rb +63 -0
- data/lib/bio/shell/plugin/seq.rb +238 -0
- data/lib/bio/shell/session.rb +214 -0
- data/lib/bio/util/color_scheme.rb +214 -0
- data/lib/bio/util/color_scheme/buried.rb +78 -0
- data/lib/bio/util/color_scheme/helix.rb +78 -0
- data/lib/bio/util/color_scheme/hydropathy.rb +83 -0
- data/lib/bio/util/color_scheme/nucleotide.rb +50 -0
- data/lib/bio/util/color_scheme/strand.rb +78 -0
- data/lib/bio/util/color_scheme/taylor.rb +69 -0
- data/lib/bio/util/color_scheme/turn.rb +78 -0
- data/lib/bio/util/color_scheme/zappo.rb +69 -0
- data/lib/bio/util/contingency_table.rb +337 -0
- data/lib/bio/util/sirna.rb +306 -0
- data/lib/bioruby.rb +34 -0
- data/sample/biofetch.rb +475 -0
- data/sample/color_scheme_na.rb +99 -0
- data/sample/dbget +37 -0
- data/sample/fasta2tab.rb +99 -0
- data/sample/fsplit.rb +51 -0
- data/sample/gb2fasta.rb +31 -0
- data/sample/gb2tab.rb +325 -0
- data/sample/gbtab2mysql.rb +161 -0
- data/sample/genes2nuc.rb +33 -0
- data/sample/genes2pep.rb +33 -0
- data/sample/genes2tab.rb +81 -0
- data/sample/genome2rb.rb +29 -0
- data/sample/genome2tab.rb +76 -0
- data/sample/goslim.rb +311 -0
- data/sample/gt2fasta.rb +47 -0
- data/sample/pmfetch.rb +42 -0
- data/sample/pmsearch.rb +42 -0
- data/sample/psortplot_html.rb +222 -0
- data/sample/ssearch2tab.rb +96 -0
- data/sample/tdiary.rb +158 -0
- data/sample/tfastx2tab.rb +100 -0
- data/sample/vs-genes.rb +212 -0
- data/test/data/SOSUI/sample.report +11 -0
- data/test/data/TMHMM/sample.report +21 -0
- data/test/data/blast/eco:b0002.faa +15 -0
- data/test/data/blast/eco:b0002.faa.m0 +128 -0
- data/test/data/blast/eco:b0002.faa.m7 +65 -0
- data/test/data/blast/eco:b0002.faa.m8 +1 -0
- data/test/data/embl/AB090716.embl +65 -0
- data/test/data/genscan/sample.report +63 -0
- data/test/data/prosite/prosite.dat +2233 -0
- data/test/data/refseq/nm_126355.entret +64 -0
- data/test/data/uniprot/p53_human.uniprot +1456 -0
- data/test/runner.rb +10 -0
- data/test/unit/bio/appl/blast/test_report.rb +427 -0
- data/test/unit/bio/appl/blast/test_xmlparser.rb +400 -0
- data/test/unit/bio/appl/genscan/test_report.rb +195 -0
- data/test/unit/bio/appl/sosui/test_report.rb +94 -0
- data/test/unit/bio/appl/targetp/test_report.rb +159 -0
- data/test/unit/bio/appl/test_blast.rb +159 -0
- data/test/unit/bio/appl/test_fasta.rb +142 -0
- data/test/unit/bio/appl/tmhmm/test_report.rb +139 -0
- data/test/unit/bio/data/test_aa.rb +103 -0
- data/test/unit/bio/data/test_codontable.rb +120 -0
- data/test/unit/bio/data/test_na.rb +89 -0
- data/test/unit/bio/db/embl/test_common.rb +130 -0
- data/test/unit/bio/db/embl/test_embl.rb +227 -0
- data/test/unit/bio/db/embl/test_sptr.rb +268 -0
- data/test/unit/bio/db/embl/test_uniprot.rb +44 -0
- data/test/unit/bio/db/kegg/test_genes.rb +58 -0
- data/test/unit/bio/db/test_fasta.rb +263 -0
- data/test/unit/bio/db/test_gff.rb +140 -0
- data/test/unit/bio/db/test_prosite.rb +1450 -0
- data/test/unit/bio/io/test_ddbjxml.rb +87 -0
- data/test/unit/bio/io/test_soapwsdl.rb +45 -0
- data/test/unit/bio/shell/plugin/test_seq.rb +175 -0
- data/test/unit/bio/test_alignment.rb +1028 -0
- data/test/unit/bio/test_command.rb +71 -0
- data/test/unit/bio/test_db.rb +109 -0
- data/test/unit/bio/test_feature.rb +128 -0
- data/test/unit/bio/test_location.rb +51 -0
- data/test/unit/bio/test_pathway.rb +485 -0
- data/test/unit/bio/test_sequence.rb +386 -0
- data/test/unit/bio/test_shell.rb +31 -0
- data/test/unit/bio/util/test_color_scheme.rb +45 -0
- data/test/unit/bio/util/test_contingency_table.rb +106 -0
- data/test/unit/bio/util/test_sirna.rb +258 -0
- metadata +295 -0
data/bin/br_biogetseq.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# biogetseq - OBDA sequence data retrieval (executable)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2003 KATAYAMA Toshiaki <k@bioruby.org>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20
|
+
#
|
21
|
+
# $Id: br_biogetseq.rb,v 1.2 2003/02/21 02:44:22 k Exp $
|
22
|
+
#
|
23
|
+
|
24
|
+
require 'bio'
|
25
|
+
|
26
|
+
def usage
|
27
|
+
print <<END
|
28
|
+
#{$0} --dbname <dbname> [--namespace <namespace>] entry_id [entry_id]
|
29
|
+
END
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
|
33
|
+
if ARGV.size < 3
|
34
|
+
usage
|
35
|
+
end
|
36
|
+
|
37
|
+
while ARGV.first =~ /^-/
|
38
|
+
case ARGV.shift
|
39
|
+
when /^\-\-format/
|
40
|
+
ARGV.shift
|
41
|
+
raise NotImplementedError
|
42
|
+
when /^\-\-dbname/
|
43
|
+
dbname = ARGV.shift
|
44
|
+
when /^\-\-namespace/
|
45
|
+
namespace = ARGV.shift
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
reg = Bio::Registry.new
|
50
|
+
db = reg.get_database(dbname)
|
51
|
+
if namespace
|
52
|
+
db['namespace'] = namespace
|
53
|
+
end
|
54
|
+
ARGV.each do |entry|
|
55
|
+
puts db.get_by_id(entry)
|
56
|
+
end
|
57
|
+
|
data/bin/br_pmfetch.rb
ADDED
@@ -0,0 +1,431 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# pmfetch - PubMed client
|
4
|
+
#
|
5
|
+
# Copyright (C) 2004, 2005 Toshiaki Katayama <k@bioruby.org>
|
6
|
+
#
|
7
|
+
# This program is free software; you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation; either version 2 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program; if not, write to the Free Software
|
19
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20
|
+
#
|
21
|
+
|
22
|
+
PROG_VER = '$Id: br_pmfetch.rb,v 1.5 2005/07/11 09:31:32 k Exp $'
|
23
|
+
PROG_NAME = File.basename($0)
|
24
|
+
|
25
|
+
|
26
|
+
require 'getoptlong'
|
27
|
+
require 'bio'
|
28
|
+
|
29
|
+
|
30
|
+
### formatting
|
31
|
+
|
32
|
+
class String
|
33
|
+
def fill(fill_column = 80, prefix = '', separater = ' ')
|
34
|
+
prefix = ' ' * prefix if prefix.is_a?(Integer)
|
35
|
+
maxlen = fill_column - prefix.length
|
36
|
+
raise "prefix is longer than fill_column" if maxlen <= 0
|
37
|
+
|
38
|
+
cursor = pos = 0
|
39
|
+
lines = []
|
40
|
+
while cursor < self.length
|
41
|
+
line = self[cursor, maxlen]
|
42
|
+
pos = line.rindex(separater)
|
43
|
+
pos = nil if line.length < maxlen
|
44
|
+
if pos
|
45
|
+
len = pos + separater.length
|
46
|
+
lines << self[cursor, len]
|
47
|
+
cursor += len
|
48
|
+
else
|
49
|
+
lines << self[cursor, maxlen]
|
50
|
+
cursor += maxlen
|
51
|
+
end
|
52
|
+
end
|
53
|
+
return lines.join("\n#{prefix}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
module Bio
|
59
|
+
class Reference
|
60
|
+
def report
|
61
|
+
if (num = @authors.size) > 10
|
62
|
+
authors = "#{@authors[0]} et al. (#{num} authors)"
|
63
|
+
elsif num > 4
|
64
|
+
sep = ',' * (num - 1)
|
65
|
+
authors = "#{@authors[0]}#{sep} #{@authors[-1]}"
|
66
|
+
else
|
67
|
+
authors = authors_join(' & ')
|
68
|
+
end
|
69
|
+
journal = "#{@journal} #{@year} #{@volume}(#{@issue}):#{@pages}"
|
70
|
+
|
71
|
+
indent = 8
|
72
|
+
prefix = ' ' * indent
|
73
|
+
[
|
74
|
+
"#{@pages[/\d+/]}".ljust(indent) + "#{@title}".fill(78, indent),
|
75
|
+
authors,
|
76
|
+
"#{journal} [PMID:#{@pubmed}]",
|
77
|
+
].join("\n#{prefix}")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
class PMFetch
|
84
|
+
|
85
|
+
class Examples < StandardError; end
|
86
|
+
class Version < StandardError; end
|
87
|
+
class Usage < StandardError; end
|
88
|
+
|
89
|
+
### default options
|
90
|
+
|
91
|
+
def initialize
|
92
|
+
@format = 'rd'
|
93
|
+
@search_opts = {
|
94
|
+
'retmax' => 20,
|
95
|
+
}
|
96
|
+
@query = nil
|
97
|
+
@query_opts = []
|
98
|
+
@pmid_list_only = false
|
99
|
+
|
100
|
+
pmfetch
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
### main
|
105
|
+
|
106
|
+
def pmfetch
|
107
|
+
begin
|
108
|
+
set_options
|
109
|
+
parse_options
|
110
|
+
check_query
|
111
|
+
rescue PMFetch::Examples
|
112
|
+
puts examples
|
113
|
+
exit
|
114
|
+
rescue PMFetch::Version
|
115
|
+
puts version
|
116
|
+
exit
|
117
|
+
rescue PMFetch::Usage
|
118
|
+
puts usage
|
119
|
+
exit
|
120
|
+
rescue GetoptLong::MissingArgument, GetoptLong::InvalidOption
|
121
|
+
puts usage
|
122
|
+
exit
|
123
|
+
end
|
124
|
+
|
125
|
+
list = pm_esearch
|
126
|
+
|
127
|
+
if list.empty?
|
128
|
+
;
|
129
|
+
elsif @pmid_list_only
|
130
|
+
puts list
|
131
|
+
else
|
132
|
+
pm_efetch(list)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
### help
|
138
|
+
|
139
|
+
def usage
|
140
|
+
%Q[
|
141
|
+
Usage: #{PROG_NAME} [options...] "query string"
|
142
|
+
or #{PROG_NAME} --query "query string" [other options...]
|
143
|
+
|
144
|
+
Options:
|
145
|
+
-q --query "genome AND virus" Query string for PubMed search
|
146
|
+
-t --title "mobile elements" Title of the article to search
|
147
|
+
-j --journal "genome res" Journal title to search
|
148
|
+
-v --volume # Journal volume to search
|
149
|
+
-i --issue # Journal issue to search
|
150
|
+
-p --page # First page number of the article to search
|
151
|
+
-a --author "Altschul SF" Author name to search
|
152
|
+
-m --mesh "SARS virus" MeSH term to search
|
153
|
+
-f --format bibtex Summary output format
|
154
|
+
--pmidlist Output only a list of PubMed IDs
|
155
|
+
-n --retmax # Number of articles to retrieve at the maximum
|
156
|
+
-N --retstart # Starting number of the articles to retrieve
|
157
|
+
-s --sort pub+date Sort method for the summary output
|
158
|
+
--reldate # Search articles published within recent # days
|
159
|
+
--mindate YYYY/MM/DD Search articles published after the date
|
160
|
+
--maxdate YYYY/MM/DD Search articles published before the date
|
161
|
+
--help Output this help, then exit
|
162
|
+
--examples Output examples, then exit
|
163
|
+
--version Output version number, then exit
|
164
|
+
|
165
|
+
Formats:
|
166
|
+
endnote, medline, bibitem, bibtex, report, rd,
|
167
|
+
nature, science, genome_res, genome_biol, nar, current, trends, cell
|
168
|
+
|
169
|
+
Sort:
|
170
|
+
author, journal, pub+date, page
|
171
|
+
|
172
|
+
See the following pages for the PubMed search options:
|
173
|
+
http://www.ncbi.nlm.nih.gov/entrez/query/static/help/pmhelp.html
|
174
|
+
http://www.ncbi.nlm.nih.gov/entrez/query/static/esearch_help.html
|
175
|
+
|
176
|
+
#{version}
|
177
|
+
|
178
|
+
]
|
179
|
+
end
|
180
|
+
|
181
|
+
def version
|
182
|
+
PROG_VER
|
183
|
+
end
|
184
|
+
|
185
|
+
def examples
|
186
|
+
DATA.read.gsub('PMFetch', PROG_NAME)
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
private
|
191
|
+
|
192
|
+
|
193
|
+
### options
|
194
|
+
|
195
|
+
def set_options
|
196
|
+
@parser = GetoptLong.new
|
197
|
+
|
198
|
+
@parser.set_options(
|
199
|
+
[ '--query', '-q', GetoptLong::REQUIRED_ARGUMENT ],
|
200
|
+
[ '--title', '-t', GetoptLong::REQUIRED_ARGUMENT ],
|
201
|
+
[ '--journal', '-j', GetoptLong::REQUIRED_ARGUMENT ],
|
202
|
+
[ '--volume', '-v', GetoptLong::REQUIRED_ARGUMENT ],
|
203
|
+
[ '--issue', '-i', GetoptLong::REQUIRED_ARGUMENT ],
|
204
|
+
[ '--page', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
205
|
+
[ '--author', '-a', GetoptLong::REQUIRED_ARGUMENT ],
|
206
|
+
[ '--mesh', '-m', GetoptLong::REQUIRED_ARGUMENT ],
|
207
|
+
[ '--format', '-f', GetoptLong::REQUIRED_ARGUMENT ],
|
208
|
+
[ '--pmidlist', GetoptLong::NO_ARGUMENT ],
|
209
|
+
[ '--retmax', '-n', GetoptLong::REQUIRED_ARGUMENT ],
|
210
|
+
[ '--retstart', '-N', GetoptLong::REQUIRED_ARGUMENT ],
|
211
|
+
[ '--sort', '-s', GetoptLong::REQUIRED_ARGUMENT ],
|
212
|
+
[ '--reldate', GetoptLong::REQUIRED_ARGUMENT ],
|
213
|
+
[ '--mindate', GetoptLong::REQUIRED_ARGUMENT ],
|
214
|
+
[ '--maxdate', GetoptLong::REQUIRED_ARGUMENT ],
|
215
|
+
[ '--examples', GetoptLong::NO_ARGUMENT ],
|
216
|
+
[ '--help', GetoptLong::NO_ARGUMENT ],
|
217
|
+
[ '--version', GetoptLong::NO_ARGUMENT ]
|
218
|
+
)
|
219
|
+
end
|
220
|
+
|
221
|
+
def parse_options
|
222
|
+
@parser.each_option do |optname, optarg|
|
223
|
+
case optname
|
224
|
+
when /--query/
|
225
|
+
@query = optarg
|
226
|
+
when /--title/
|
227
|
+
@query_opts << "#{optarg}[ti]"
|
228
|
+
when /--journal/
|
229
|
+
@query_opts << "#{optarg}[ta]"
|
230
|
+
when /--volume/
|
231
|
+
@query_opts << "#{optarg}[vi]"
|
232
|
+
when /--issue/
|
233
|
+
@query_opts << "#{optarg}[ip]"
|
234
|
+
when /--page/
|
235
|
+
@query_opts << "#{optarg}[pg]"
|
236
|
+
when /--author/
|
237
|
+
@query_opts << "#{optarg}[au]"
|
238
|
+
when /--mesh/
|
239
|
+
@query_opts << "#{optarg}[mh]"
|
240
|
+
when /--format/
|
241
|
+
@format = optarg
|
242
|
+
when /--pmidlist/
|
243
|
+
@pmid_list_only = true
|
244
|
+
when /--examples/
|
245
|
+
raise PMFetch::Examples
|
246
|
+
when /--help/
|
247
|
+
raise PMFetch::Usage
|
248
|
+
when /--version/
|
249
|
+
raise PMFetch::Version
|
250
|
+
when /--sort/
|
251
|
+
@sort = optarg
|
252
|
+
@search_opts["sort"] = @sort unless @sort == "page"
|
253
|
+
else
|
254
|
+
optname.delete!('-')
|
255
|
+
@search_opts[optname] = optarg
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
|
261
|
+
### check query
|
262
|
+
|
263
|
+
def check_query
|
264
|
+
p @query if $DEBUG
|
265
|
+
@query ||= ARGV.join(" ") unless ARGV.empty?
|
266
|
+
|
267
|
+
p @query if $DEBUG
|
268
|
+
@query_str = [ @query, @query_opts ].flatten.compact.join(" AND ")
|
269
|
+
|
270
|
+
p @query_str if $DEBUG
|
271
|
+
if @query_str.empty?
|
272
|
+
raise PMFetch::Usage
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
|
277
|
+
### search
|
278
|
+
|
279
|
+
def pm_esearch
|
280
|
+
return Bio::PubMed.esearch(@query_str, @search_opts)
|
281
|
+
end
|
282
|
+
|
283
|
+
def pm_efetch(list)
|
284
|
+
entries = Bio::PubMed.efetch(list)
|
285
|
+
|
286
|
+
if @format == 'medline'
|
287
|
+
medline_format(entries)
|
288
|
+
else
|
289
|
+
entries = parse_entries(entries)
|
290
|
+
if @sort == 'page'
|
291
|
+
entries = sort_entries(entries)
|
292
|
+
end
|
293
|
+
if @format == 'report'
|
294
|
+
report_format(entries)
|
295
|
+
else
|
296
|
+
other_format(entries)
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
|
302
|
+
### output
|
303
|
+
|
304
|
+
def medline_format(entries)
|
305
|
+
entries.each do |entry|
|
306
|
+
puts entry
|
307
|
+
puts '//'
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def parse_entries(entries)
|
312
|
+
entries.map { |entry| Bio::MEDLINE.new(entry) }
|
313
|
+
end
|
314
|
+
|
315
|
+
def sort_entries(entries)
|
316
|
+
if RUBY_VERSION > "1.8.0"
|
317
|
+
entries.sort_by { |x|
|
318
|
+
[ x.journal, x.volume.to_i, x.issue.to_i, x.pages.to_i ]
|
319
|
+
}
|
320
|
+
else
|
321
|
+
entries.map { |x|
|
322
|
+
[ x.journal, x.volume.to_i, x.issue.to_i, x.pages.to_i, x ]
|
323
|
+
}.sort { |a, b|
|
324
|
+
a[0..3] <=> b[0..3]
|
325
|
+
}.map { |y|
|
326
|
+
y.pop
|
327
|
+
}
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
def report_format(entries)
|
332
|
+
entries.each do |entry|
|
333
|
+
puts entry.reference.report
|
334
|
+
puts
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
def other_format(entries)
|
339
|
+
entries.each do |entry|
|
340
|
+
puts entry.reference.format(@format)
|
341
|
+
puts
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
|
348
|
+
PMFetch.new
|
349
|
+
|
350
|
+
|
351
|
+
__END__
|
352
|
+
|
353
|
+
= Examples : PubMed search
|
354
|
+
|
355
|
+
These four lines will do the same job.
|
356
|
+
|
357
|
+
% PMFetch transcription factor
|
358
|
+
% PMFetch "transcription factor"
|
359
|
+
% PMFetch --query "transcription factor"
|
360
|
+
% PMFetch -q "transcription factor"
|
361
|
+
|
362
|
+
|
363
|
+
Retrieve max 100 artiecles (20 is a NCBI's default) at a time, use --retmax as
|
364
|
+
|
365
|
+
% PMFetch -q "transcription factor" --retmax 100
|
366
|
+
|
367
|
+
and, to retrieve next 100 articles, use --retstart as
|
368
|
+
|
369
|
+
% PMFetch -q "transcription factor" --retmax 100 --retstart 100
|
370
|
+
|
371
|
+
|
372
|
+
You can narrow the search target for an issue of the journal.
|
373
|
+
|
374
|
+
% PMFetch --journal development --volume 131 --issue 3 transcription factor
|
375
|
+
|
376
|
+
|
377
|
+
Short options are also available.
|
378
|
+
|
379
|
+
% PMFetch -j development -v 131 -i 3 transcription factor
|
380
|
+
|
381
|
+
|
382
|
+
Search articles indexed in PubMed within these 90 days.
|
383
|
+
|
384
|
+
% PMFetch -q "transcription factor" --reldate 90
|
385
|
+
|
386
|
+
|
387
|
+
Search articles indexed in PubMed during the period of 2001/04/01 to 2001/08/31
|
388
|
+
|
389
|
+
% PMFetch -q "transcription factor" --mindate 2001/04/01 --maxdate 2001/08/31
|
390
|
+
|
391
|
+
|
392
|
+
Output format can be changed by --format option.
|
393
|
+
|
394
|
+
% PMFetch -q "transcription factor" -j development -v 131 -i 3 -f report
|
395
|
+
% PMFetch -q "transcription factor" -j development -v 131 -i 3 -f rd
|
396
|
+
% PMFetch -q "transcription factor" -j development -v 131 -i 3 -f endnote
|
397
|
+
% PMFetch -q "transcription factor" -j development -v 131 -i 3 -f medline
|
398
|
+
% PMFetch -q "transcription factor" -j development -v 131 -i 3 -f bibitem
|
399
|
+
% PMFetch -q "transcription factor" -j development -v 131 -i 3 -f bibtex
|
400
|
+
% PMFetch -q "transcription factor" -j development -v 131 -i 3 -f nature
|
401
|
+
% PMFetch -q "transcription factor" -j development -v 131 -i 3 -f science
|
402
|
+
|
403
|
+
|
404
|
+
Generate title listings for the journal report meeting (don't forget
|
405
|
+
to inclease the number of --retmax for fetching all titles).
|
406
|
+
|
407
|
+
% PMFetch -f report -j development -v 131 -i 3 -n 100
|
408
|
+
|
409
|
+
|
410
|
+
Search by author name.
|
411
|
+
|
412
|
+
% PMFetch -a "Karlin S"
|
413
|
+
% PMFetch -a "Koonin EV"
|
414
|
+
|
415
|
+
|
416
|
+
Search by MeSH term.
|
417
|
+
|
418
|
+
% PMFetch -m "computational biology"
|
419
|
+
% PMFetch -m "SARS virus"
|
420
|
+
|
421
|
+
|
422
|
+
Search by PubMed ID (PMID).
|
423
|
+
|
424
|
+
% PMFetch 12345
|
425
|
+
|
426
|
+
|
427
|
+
Output PMID only.
|
428
|
+
|
429
|
+
% PMFetch --pmidlist tardigrada
|
430
|
+
|
431
|
+
|