bio 0.7.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.
- 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/bioruby
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# = BioRuby shell - command line interface for the BioRuby library
|
|
4
|
+
#
|
|
5
|
+
# Copyright:: Copyright (C) 2005
|
|
6
|
+
# Toshiaki Katayama <k@bioruby.org>
|
|
7
|
+
# License:: LGPL
|
|
8
|
+
#
|
|
9
|
+
# $Id: bioruby,v 1.10 2005/12/07 05:12:06 k Exp $
|
|
10
|
+
#
|
|
11
|
+
#--
|
|
12
|
+
#
|
|
13
|
+
# This library is free software; you can redistribute it and/or
|
|
14
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
15
|
+
# License as published by the Free Software Foundation; either
|
|
16
|
+
# version 2 of the License, or (at your option) any later version.
|
|
17
|
+
#
|
|
18
|
+
# This library is distributed in the hope that it will be useful,
|
|
19
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21
|
+
# Lesser General Public License for more details.
|
|
22
|
+
#
|
|
23
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
24
|
+
# License along with this library; if not, write to the Free Software
|
|
25
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
26
|
+
#
|
|
27
|
+
#++
|
|
28
|
+
#
|
|
29
|
+
|
|
30
|
+
# $: << File.dirname(__FILE__)+'/../lib'
|
|
31
|
+
|
|
32
|
+
begin
|
|
33
|
+
require 'rubygems'
|
|
34
|
+
require_gem 'bio', '~> 0.7'
|
|
35
|
+
rescue LoadError
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
require 'bio/shell'
|
|
39
|
+
|
|
40
|
+
include Bio::Shell
|
|
41
|
+
|
|
42
|
+
# loading configuration and plugins
|
|
43
|
+
Bio::Shell.setup
|
|
44
|
+
|
|
45
|
+
### IRB setup
|
|
46
|
+
|
|
47
|
+
require 'irb'
|
|
48
|
+
begin
|
|
49
|
+
require 'irb/completion'
|
|
50
|
+
Bio::Shell.cache[:readline] = true
|
|
51
|
+
rescue LoadError
|
|
52
|
+
Bio::Shell.cache[:readline] = false
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
IRB.setup(nil)
|
|
56
|
+
|
|
57
|
+
# set application name
|
|
58
|
+
IRB.conf[:AP_NAME] = 'bioruby'
|
|
59
|
+
|
|
60
|
+
# change prompt for bioruby
|
|
61
|
+
$_ = Bio::Shell.esc_seq
|
|
62
|
+
IRB.conf[:PROMPT][:BIORUBY_COLOR] = {
|
|
63
|
+
:PROMPT_I => "bio#{$_[:ruby]}ruby#{$_[:none]}> ",
|
|
64
|
+
:PROMPT_S => "bio#{$_[:ruby]}ruby#{$_[:none]}%l ",
|
|
65
|
+
:PROMPT_C => "bio#{$_[:ruby]}ruby#{$_[:none]}+ ",
|
|
66
|
+
:RETURN => " ==> %s\n"
|
|
67
|
+
}
|
|
68
|
+
IRB.conf[:PROMPT][:BIORUBY] = {
|
|
69
|
+
:PROMPT_I => "bioruby> ",
|
|
70
|
+
:PROMPT_S => "bioruby%l ",
|
|
71
|
+
:PROMPT_C => "bioruby+ ",
|
|
72
|
+
:RETURN => " ==> %s\n"
|
|
73
|
+
}
|
|
74
|
+
if Bio::Shell.config[:color]
|
|
75
|
+
IRB.conf[:PROMPT_MODE] = :BIORUBY_COLOR
|
|
76
|
+
else
|
|
77
|
+
IRB.conf[:PROMPT_MODE] = :BIORUBY
|
|
78
|
+
end
|
|
79
|
+
IRB.conf[:ECHO] = Bio::Shell.config[:echo] || false
|
|
80
|
+
|
|
81
|
+
# irb/input-method.rb >= v1.5 (not in 1.8.2)
|
|
82
|
+
#IRB.conf[:SAVE_HISTORY] = 100000
|
|
83
|
+
|
|
84
|
+
# not beautifully works
|
|
85
|
+
#IRB.conf[:AUTO_INDENT] = true
|
|
86
|
+
|
|
87
|
+
### IRB main loop
|
|
88
|
+
|
|
89
|
+
irb = IRB::Irb.new
|
|
90
|
+
|
|
91
|
+
# needed for method completion
|
|
92
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
|
93
|
+
|
|
94
|
+
# loading workspace and command history
|
|
95
|
+
Bio::Shell.load
|
|
96
|
+
|
|
97
|
+
Signal.trap("SIGINT") do
|
|
98
|
+
irb.signal_handle
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
catch(:IRB_EXIT) do
|
|
102
|
+
irb.eval_input
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# saving workspace, command history and configuration before exit
|
|
106
|
+
Bio::Shell.save
|
|
107
|
+
|
data/bin/br_biofetch.rb
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# biofetch - BioFetch client
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2002 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_biofetch.rb,v 1.2 2002/12/03 18:54:43 k Exp $
|
|
22
|
+
#
|
|
23
|
+
|
|
24
|
+
require 'bio/io/fetch'
|
|
25
|
+
|
|
26
|
+
def usage
|
|
27
|
+
default_url = 'http://bioruby.org/cgi-bin/biofetch.rb'
|
|
28
|
+
another_url = 'http://www.ebi.ac.uk/cgi-bin/dbfetch'
|
|
29
|
+
puts "#{$0} [-s[erver] #{another_url}] db id [style] [format]"
|
|
30
|
+
puts " server : URL of the BioFetch CGI (default is #{default_url})"
|
|
31
|
+
puts " db : database name (embl, genbank, etc.)"
|
|
32
|
+
puts " id : entry id"
|
|
33
|
+
puts " style : 'raw' or 'html' (default is 'raw')"
|
|
34
|
+
puts " format : change the output format ('default', 'fasta', etc.)"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
if ARGV.empty? or ARGV[0] =~ /^--?h/
|
|
38
|
+
usage
|
|
39
|
+
exit 1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
case ARGV[0]
|
|
43
|
+
when /^--?s/ # User specified server
|
|
44
|
+
ARGV.shift
|
|
45
|
+
serv = Bio::Fetch.new(ARGV.shift)
|
|
46
|
+
puts serv.fetch(*ARGV)
|
|
47
|
+
when /^--?e/ # EBI server
|
|
48
|
+
ARGV.shift
|
|
49
|
+
serv = Bio::Fetch.new('http://www.ebi.ac.uk/cgi-bin/dbfetch')
|
|
50
|
+
puts serv.fetch(*ARGV)
|
|
51
|
+
when /^--?r/ # BioRuby server
|
|
52
|
+
ARGV.shift
|
|
53
|
+
serv = Bio::Fetch.new('http://bioruby.org/cgi-bin/biofetch.rb')
|
|
54
|
+
puts serv.fetch(*ARGV)
|
|
55
|
+
else # Default server
|
|
56
|
+
puts Bio::Fetch.query(*ARGV)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
data/bin/br_bioflat.rb
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# bioflat - OBDA flat file indexer (executable)
|
|
4
|
+
#
|
|
5
|
+
# Copyright (C) 2002 GOTO Naohisa <ngoto@gen-info.osaka-u.ac.jp>
|
|
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_bioflat.rb,v 1.14 2003/08/27 17:28:30 ng Exp $
|
|
22
|
+
#
|
|
23
|
+
|
|
24
|
+
require 'bio'
|
|
25
|
+
|
|
26
|
+
def usage
|
|
27
|
+
print <<EOM
|
|
28
|
+
Search:
|
|
29
|
+
#{$0} [--search] [options...] [DIR/]DBNAME KEYWORDS
|
|
30
|
+
or
|
|
31
|
+
#{$0} [--search] --location DIR --dbname DBNAME [options...] KEYWORDS
|
|
32
|
+
|
|
33
|
+
Search options:
|
|
34
|
+
--namespace NAME set serch namespace to NAME
|
|
35
|
+
(or --name NAME) You can set this option many times to specify
|
|
36
|
+
more than one namespace.
|
|
37
|
+
|
|
38
|
+
Create index:
|
|
39
|
+
#{$0} --create --location DIR --dbname DBNAME [--format <genbank|embl|fasta>] [options...] [--files] FILES
|
|
40
|
+
Update index:
|
|
41
|
+
#{$0} --update --location DIR --dbname DBNAME [options...] [--files] FILES
|
|
42
|
+
|
|
43
|
+
Create index options:
|
|
44
|
+
--primary=UNIQUE set primary namespece to UNIQUE
|
|
45
|
+
Default primary/secondary namespaces depend on
|
|
46
|
+
each format of flatfiles.
|
|
47
|
+
--secondary=KEY set secondary namespaces.
|
|
48
|
+
You may use this option many times to specify
|
|
49
|
+
more than one namespace.
|
|
50
|
+
--add-secondary=KEY add secondary namespaces to default specification.
|
|
51
|
+
You can use this option many times.
|
|
52
|
+
|
|
53
|
+
Options only valid for --create (or --update) --type flat:
|
|
54
|
+
--sort=/path/to/sort use external sort program (e.g. /usr/bin/sort)
|
|
55
|
+
--sort=BUILTIN use builtin sort routine
|
|
56
|
+
|
|
57
|
+
Options only valid for --update:
|
|
58
|
+
--renew re-read all flatfiles and update whole index
|
|
59
|
+
|
|
60
|
+
Backward compatibility:
|
|
61
|
+
--makeindex DIR/DBNAME
|
|
62
|
+
same as --create --type flat --location DIR --dbname DBNAME
|
|
63
|
+
--makeindexBDB DIR/DBNAME
|
|
64
|
+
same as --create --type bdb --location DIR --dbname DBNAME
|
|
65
|
+
--format=CLASS
|
|
66
|
+
instead of genbank|embl|fasta, specifing a class name is allowed
|
|
67
|
+
|
|
68
|
+
Show namespaces:
|
|
69
|
+
#{$0} --show-namespaces [--location DIR --dbname DBNAME] [DIR/DBNAME]
|
|
70
|
+
or
|
|
71
|
+
#{$0} --show-namespaces [--format=CLASS]
|
|
72
|
+
or
|
|
73
|
+
#{$0} --show-namespaces --files file
|
|
74
|
+
|
|
75
|
+
EOM
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def do_index(mode = :create)
|
|
81
|
+
case ARGV[0]
|
|
82
|
+
when /^\-\-?make/
|
|
83
|
+
dbpath = ARGV[1]
|
|
84
|
+
args = ARGV[2..-1]
|
|
85
|
+
is_bdb = nil
|
|
86
|
+
when /^\-\-?make.*bdb/i
|
|
87
|
+
dbname = ARGV[1]
|
|
88
|
+
args = ARGV[2..-1]
|
|
89
|
+
is_bdb = Bio::FlatFileIndex::MAGIC_BDB
|
|
90
|
+
when /^\-\-create/, /^\-\-update/
|
|
91
|
+
args = ARGV[1..-1]
|
|
92
|
+
else
|
|
93
|
+
usage
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
options = {}
|
|
97
|
+
|
|
98
|
+
while args.first =~ /^\-/
|
|
99
|
+
case x = args.shift
|
|
100
|
+
|
|
101
|
+
# OBDA stuff
|
|
102
|
+
|
|
103
|
+
when /^\-\-?format/
|
|
104
|
+
args.shift
|
|
105
|
+
format = nil # throw this f*ckin' mess for auto detect :)
|
|
106
|
+
when /^\-\-?location/
|
|
107
|
+
location = args.shift.chomp('/')
|
|
108
|
+
when /^\-\-?dbname/
|
|
109
|
+
dbname = args.shift
|
|
110
|
+
when /^\-\-?(index)?type/
|
|
111
|
+
indextype = args.shift
|
|
112
|
+
case indextype
|
|
113
|
+
when /bdb/
|
|
114
|
+
is_bdb = Bio::FlatFileIndex::MAGIC_BDB
|
|
115
|
+
when /flat/
|
|
116
|
+
is_bdb = nil
|
|
117
|
+
else
|
|
118
|
+
usage
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# BioRuby extension
|
|
122
|
+
|
|
123
|
+
when /^\-\-?files/i
|
|
124
|
+
break
|
|
125
|
+
|
|
126
|
+
when /^\-\-?format\=(.*)/i
|
|
127
|
+
format = $1
|
|
128
|
+
|
|
129
|
+
when /^\-\-?sort\=(.*)/i
|
|
130
|
+
options['sort_program'] = $1
|
|
131
|
+
options['onmemory'] = nil
|
|
132
|
+
when /^\-\-?no\-?te?mp/i
|
|
133
|
+
options['onmemory'] = true
|
|
134
|
+
|
|
135
|
+
when /^\-\-?primary.*\=(.*)/i
|
|
136
|
+
options['primary_namespace'] = $1
|
|
137
|
+
|
|
138
|
+
when /^\-\-?add-secondary.*\=(.*)/i
|
|
139
|
+
unless options['additional_secondary_namespaces'] then
|
|
140
|
+
options['additional_secondary_namespaces'] = []
|
|
141
|
+
end
|
|
142
|
+
options['additional_secondary_namespaces'] << $1 if $1.length > 0
|
|
143
|
+
|
|
144
|
+
when /^\-\-?secondary.*\=(.*)/i
|
|
145
|
+
unless options['secondary_namespaces'] then
|
|
146
|
+
options['secondary_namespaces'] = []
|
|
147
|
+
end
|
|
148
|
+
options['secondary_namespaces'] << $1 if $1.length > 0
|
|
149
|
+
|
|
150
|
+
when /^\-\-?renew/
|
|
151
|
+
options['renew'] = true
|
|
152
|
+
|
|
153
|
+
else
|
|
154
|
+
STDERR.print "Warning: ignoring invalid option #{x.inspect}\n"
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
dbpath = File.join(location, dbname) unless dbpath
|
|
159
|
+
if mode == :update then
|
|
160
|
+
Bio::FlatFileIndex::update_index(dbpath, format, options, *args)
|
|
161
|
+
else
|
|
162
|
+
Bio::FlatFileIndex::makeindex(is_bdb, dbpath, format, options, *args)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def do_search
|
|
168
|
+
dbname = nil
|
|
169
|
+
location = nil
|
|
170
|
+
names = []
|
|
171
|
+
while x = ARGV.shift
|
|
172
|
+
case x
|
|
173
|
+
when /\A\-\-?search/i
|
|
174
|
+
#do nothing
|
|
175
|
+
when /\A\-\-?location/i
|
|
176
|
+
location = ARGV.shift.to_s.chomp('/')
|
|
177
|
+
when /\A\-\-?dbname/i
|
|
178
|
+
dbname = ARGV.shift
|
|
179
|
+
when /\A\-\-?name(?:space)?(?:\=(.+))?/i
|
|
180
|
+
if $1 then
|
|
181
|
+
names << $1
|
|
182
|
+
elsif x = ARGV.shift
|
|
183
|
+
names << x
|
|
184
|
+
end
|
|
185
|
+
else
|
|
186
|
+
ARGV.unshift x
|
|
187
|
+
break
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
dbname = ARGV.shift unless dbname
|
|
191
|
+
dbname = File.join(location, dbname) unless location.to_s.empty?
|
|
192
|
+
db = Bio::FlatFileIndex.open(dbname)
|
|
193
|
+
ARGV.each do |key|
|
|
194
|
+
STDERR.print "Searching for \'#{key}\'...\n"
|
|
195
|
+
#r = db.search(key)
|
|
196
|
+
#STDERR.print "OK, #{r.size} entry found\n"
|
|
197
|
+
#if r.size > 0 then
|
|
198
|
+
# print r
|
|
199
|
+
#end
|
|
200
|
+
begin
|
|
201
|
+
if names.empty? then
|
|
202
|
+
r = db.include?(key)
|
|
203
|
+
else
|
|
204
|
+
r = db.include_in_namespaces?(key, *names)
|
|
205
|
+
end
|
|
206
|
+
rescue RuntimeError
|
|
207
|
+
STDERR.print "ERROR: #{$!}\n"
|
|
208
|
+
next
|
|
209
|
+
end
|
|
210
|
+
r = [] unless r
|
|
211
|
+
STDERR.print "OK, #{r.size} entry found\n"
|
|
212
|
+
r.each do |i|
|
|
213
|
+
print db.search_primary(i)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
db.close
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def do_show_namespaces
|
|
221
|
+
dbname = nil
|
|
222
|
+
location = nil
|
|
223
|
+
files = nil
|
|
224
|
+
format = nil
|
|
225
|
+
names = []
|
|
226
|
+
while x = ARGV.shift
|
|
227
|
+
case x
|
|
228
|
+
when /\A\-\-?(show\-)?name(space)?s/i
|
|
229
|
+
#do nothing
|
|
230
|
+
when /\A\-\-?location/i
|
|
231
|
+
location = ARGV.shift.to_s.chomp('/')
|
|
232
|
+
when /\A\-\-?dbname/i
|
|
233
|
+
dbname = ARGV.shift
|
|
234
|
+
when /\A\-\-?format(?:\=(.+))?/i
|
|
235
|
+
if $1 then
|
|
236
|
+
format = $1
|
|
237
|
+
elsif x = ARGV.shift
|
|
238
|
+
format = x
|
|
239
|
+
end
|
|
240
|
+
when /\A\-\-?files/i
|
|
241
|
+
files = ARGV
|
|
242
|
+
break
|
|
243
|
+
else
|
|
244
|
+
ARGV.unshift x
|
|
245
|
+
break
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
if files then
|
|
249
|
+
k = nil
|
|
250
|
+
files.each do |x|
|
|
251
|
+
k = Bio::FlatFile.autodetect_file(x)
|
|
252
|
+
break if k
|
|
253
|
+
end
|
|
254
|
+
if k then
|
|
255
|
+
STDERR.print "Format: #{k.to_s}\n"
|
|
256
|
+
format = k
|
|
257
|
+
else
|
|
258
|
+
STDERR.print "ERROR: couldn't determine file format\n"
|
|
259
|
+
return
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
STDERR.print "Namespaces: (first line: primary namespace)\n"
|
|
263
|
+
if format then
|
|
264
|
+
parser = Bio::FlatFileIndex::Indexer::Parser.new(format)
|
|
265
|
+
print parser.primary.name, "\n"
|
|
266
|
+
puts parser.secondary.keys
|
|
267
|
+
else
|
|
268
|
+
dbname = ARGV.shift unless dbname
|
|
269
|
+
dbname = File.join(location, dbname) unless location.to_s.empty?
|
|
270
|
+
db = Bio::FlatFileIndex.open(dbname)
|
|
271
|
+
puts db.namespaces
|
|
272
|
+
db.close
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
if ARGV.size > 1
|
|
277
|
+
case ARGV[0]
|
|
278
|
+
when /--make/, /--create/
|
|
279
|
+
Bio::FlatFileIndex::DEBUG.out = true
|
|
280
|
+
do_index
|
|
281
|
+
when /--update/
|
|
282
|
+
Bio::FlatFileIndex::DEBUG.out = true
|
|
283
|
+
do_index(:update)
|
|
284
|
+
when /\A\-\-?(show\-)?name(space)?s/i
|
|
285
|
+
do_show_namespaces
|
|
286
|
+
when /--search/
|
|
287
|
+
do_search
|
|
288
|
+
else #default is search
|
|
289
|
+
do_search
|
|
290
|
+
end
|
|
291
|
+
else
|
|
292
|
+
usage
|
|
293
|
+
end
|
|
294
|
+
|