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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
#
|
|
2
|
+
# = bio/io/soapwsdl.rb - SOAP/WSDL interface class
|
|
3
|
+
#
|
|
4
|
+
# Copyright:: Copyright (C) 2004
|
|
5
|
+
# KATAYAMA Toshiaki <k@bioruby.org>
|
|
6
|
+
# License:: LGPL
|
|
7
|
+
#
|
|
8
|
+
# $Id: soapwsdl.rb,v 1.3 2005/12/18 16:51:18 nakao Exp $
|
|
9
|
+
#
|
|
10
|
+
# SOAP/WSDL
|
|
11
|
+
#
|
|
12
|
+
#
|
|
13
|
+
# == Examples
|
|
14
|
+
#
|
|
15
|
+
# class API < Bio::SOAPWSDL
|
|
16
|
+
# def initialize
|
|
17
|
+
# @wsdl = 'http://example.com/example.wsdl'
|
|
18
|
+
# @log = File.new("soap_log", 'w')
|
|
19
|
+
# create_driver
|
|
20
|
+
# end
|
|
21
|
+
# end
|
|
22
|
+
#
|
|
23
|
+
# == Use HTTP proxy
|
|
24
|
+
#
|
|
25
|
+
# You need to set following two environmental variables
|
|
26
|
+
# (case might be insensitive) as required by SOAP4R.
|
|
27
|
+
#
|
|
28
|
+
# --- soap_use_proxy
|
|
29
|
+
# Set the value of this variable to 'on'.
|
|
30
|
+
#
|
|
31
|
+
# --- http_proxy
|
|
32
|
+
# Set the URL of your proxy server (http://myproxy.com:8080 etc.).
|
|
33
|
+
#
|
|
34
|
+
# === Example
|
|
35
|
+
#
|
|
36
|
+
# % export soap_use_proxy=on
|
|
37
|
+
# % export http_proxy=http://localhost:8080
|
|
38
|
+
#
|
|
39
|
+
#--
|
|
40
|
+
#
|
|
41
|
+
# This library is free software; you can redistribute it and/or
|
|
42
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
43
|
+
# License as published by the Free Software Foundation; either
|
|
44
|
+
# version 2 of the License, or (at your option) any later version.
|
|
45
|
+
#
|
|
46
|
+
# This library is distributed in the hope that it will be useful,
|
|
47
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
48
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
49
|
+
# Lesser General Public License for more details.
|
|
50
|
+
#
|
|
51
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
52
|
+
# License along with this library; if not, write to the Free Software
|
|
53
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
54
|
+
#
|
|
55
|
+
#++
|
|
56
|
+
#
|
|
57
|
+
|
|
58
|
+
begin
|
|
59
|
+
require 'soap/wsdlDriver'
|
|
60
|
+
rescue LoadError
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
module Bio
|
|
64
|
+
|
|
65
|
+
class SOAPWSDL
|
|
66
|
+
|
|
67
|
+
# WSDL URL
|
|
68
|
+
attr_reader :wsdl
|
|
69
|
+
|
|
70
|
+
# log IO
|
|
71
|
+
attr_reader :log
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def initialize(wsdl = nil)
|
|
75
|
+
@wsdl = wsdl
|
|
76
|
+
@log = nil
|
|
77
|
+
create_driver
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def create_driver
|
|
82
|
+
if RUBY_VERSION > "1.8.2"
|
|
83
|
+
@driver = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
|
|
84
|
+
else
|
|
85
|
+
@driver = SOAP::WSDLDriverFactory.new(@wsdl).create_driver
|
|
86
|
+
end
|
|
87
|
+
@driver.generate_explicit_type = true # Ruby obj <-> SOAP obj
|
|
88
|
+
end
|
|
89
|
+
private :create_driver
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# Set a WSDL URL.
|
|
93
|
+
def wsdl=(url)
|
|
94
|
+
@wsdl = url
|
|
95
|
+
create_driver
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# Set log IO
|
|
100
|
+
def log=(io)
|
|
101
|
+
@log = io
|
|
102
|
+
@driver.wiredump_dev = @log
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def method_missing(*arg)
|
|
107
|
+
@driver.send(*arg)
|
|
108
|
+
end
|
|
109
|
+
private :method_missing
|
|
110
|
+
|
|
111
|
+
end # SOAP
|
|
112
|
+
|
|
113
|
+
end # Bio
|
|
114
|
+
|
data/lib/bio/io/sql.rb
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
#
|
|
2
|
+
# bio/io/sql.rb - BioSQL access module
|
|
3
|
+
#
|
|
4
|
+
# Copyright (C) 2002 KATAYAMA Toshiaki <k@bioruby.org>
|
|
5
|
+
#
|
|
6
|
+
# This library is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
8
|
+
# License as published by the Free Software Foundation; either
|
|
9
|
+
# version 2 of the License, or (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14
|
+
# Lesser General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
17
|
+
# License along with this library; if not, write to the Free Software
|
|
18
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19
|
+
#
|
|
20
|
+
# $Id: sql.rb,v 1.4 2005/09/26 13:04:28 k Exp $
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
begin
|
|
24
|
+
require 'dbi'
|
|
25
|
+
rescue LoadError
|
|
26
|
+
end
|
|
27
|
+
require 'bio/sequence'
|
|
28
|
+
require 'bio/feature'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
module Bio
|
|
32
|
+
|
|
33
|
+
class SQL
|
|
34
|
+
|
|
35
|
+
def initialize(db = 'dbi:Mysql:biosql', user = nil, pass = nil)
|
|
36
|
+
@dbh = DBI.connect(db, user, pass)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def close
|
|
40
|
+
@dbh.disconnect
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def fetch(accession) # or display_id for fall back
|
|
44
|
+
query = "select * from bioentry where accession = ?"
|
|
45
|
+
entry = @dbh.execute(query, accession).fetch
|
|
46
|
+
return Sequence.new(@dbh, entry) if entry
|
|
47
|
+
|
|
48
|
+
query = "select * from bioentry where display_id = ?"
|
|
49
|
+
entry = @dbh.execute(query, accession).fetch
|
|
50
|
+
return Sequence.new(@dbh, entry) if entry
|
|
51
|
+
end
|
|
52
|
+
alias get_by_id fetch
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# for lazy fetching
|
|
56
|
+
|
|
57
|
+
class Sequence
|
|
58
|
+
|
|
59
|
+
def initialize(dbh, entry)
|
|
60
|
+
@dbh = dbh
|
|
61
|
+
@bioentry_id = entry['bioentry_id']
|
|
62
|
+
@database_id = entry['biodatabase_id']
|
|
63
|
+
@entry_id = entry['display_id']
|
|
64
|
+
@accession = entry['accession']
|
|
65
|
+
@version = entry['entry_version']
|
|
66
|
+
@division = entry['division']
|
|
67
|
+
end
|
|
68
|
+
attr_reader :accession, :division, :entry_id, :version
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def to_fasta
|
|
72
|
+
if seq = seq
|
|
73
|
+
return seq.to_fasta(@accession)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def seq
|
|
78
|
+
query = "select * from biosequence where bioentry_id = ?"
|
|
79
|
+
row = @dbh.execute(query, @bioentry_id).fetch
|
|
80
|
+
return unless row
|
|
81
|
+
|
|
82
|
+
mol = row['molecule']
|
|
83
|
+
seq = row['biosequence_str']
|
|
84
|
+
|
|
85
|
+
case mol
|
|
86
|
+
when /.na/i # 'dna' or 'rna'
|
|
87
|
+
Bio::Sequence::NA.new(seq)
|
|
88
|
+
else # 'protein'
|
|
89
|
+
Bio::Sequence::AA.new(seq)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def subseq(from, to)
|
|
94
|
+
length = to - from + 1
|
|
95
|
+
query = "select molecule, substring(biosequence_str, ?, ?) as subseq" +
|
|
96
|
+
" from biosequence where bioentry_id = ?"
|
|
97
|
+
row = @dbh.execute(query, from, length, @bioentry_id).fetch
|
|
98
|
+
return unless row
|
|
99
|
+
|
|
100
|
+
mol = row['molecule']
|
|
101
|
+
seq = row['subseq']
|
|
102
|
+
|
|
103
|
+
case mol
|
|
104
|
+
when /.na/i # 'dna' or 'rna'
|
|
105
|
+
Bio::Sequence::NA.new(seq)
|
|
106
|
+
else # 'protein'
|
|
107
|
+
Bio::Sequence::AA.new(seq)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def features
|
|
113
|
+
array = []
|
|
114
|
+
query = "select * from seqfeature where bioentry_id = ?"
|
|
115
|
+
@dbh.execute(query, @bioentry_id).fetch_all.each do |row|
|
|
116
|
+
next unless row
|
|
117
|
+
|
|
118
|
+
f_id = row['seqfeature_id']
|
|
119
|
+
k_id = row['seqfeature_key_id']
|
|
120
|
+
s_id = row['seqfeature_source_id']
|
|
121
|
+
rank = row['seqfeature_rank'].to_i - 1
|
|
122
|
+
|
|
123
|
+
# key : type (gene, CDS, ...)
|
|
124
|
+
type = feature_key(k_id)
|
|
125
|
+
|
|
126
|
+
# source : database (EMBL/GenBank/SwissProt)
|
|
127
|
+
database = feature_source(s_id)
|
|
128
|
+
|
|
129
|
+
# location : position
|
|
130
|
+
locations = feature_locations(f_id)
|
|
131
|
+
|
|
132
|
+
# qualifier
|
|
133
|
+
qualifiers = feature_qualifiers(f_id)
|
|
134
|
+
|
|
135
|
+
# rank
|
|
136
|
+
array[rank] = Bio::Feature.new(type, locations, qualifiers)
|
|
137
|
+
end
|
|
138
|
+
return Bio::Features.new(array)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def references
|
|
143
|
+
array = []
|
|
144
|
+
query = <<-END
|
|
145
|
+
select * from bioentry_reference, reference
|
|
146
|
+
where bioentry_id = ? and
|
|
147
|
+
bioentry_reference.reference_id = reference.reference_id
|
|
148
|
+
END
|
|
149
|
+
@dbh.execute(query, @bioentry_id).fetch_all.each do |row|
|
|
150
|
+
next unless row
|
|
151
|
+
|
|
152
|
+
hash = {
|
|
153
|
+
'start' => row['reference_start'],
|
|
154
|
+
'end' => row['reference_end'],
|
|
155
|
+
'journal' => row['reference_location'],
|
|
156
|
+
'title' => row['reference_title'],
|
|
157
|
+
'authors' => row['reference_authors'],
|
|
158
|
+
'medline' => row['reference_medline']
|
|
159
|
+
}
|
|
160
|
+
hash.default = ''
|
|
161
|
+
|
|
162
|
+
rank = row['reference_rank'].to_i - 1
|
|
163
|
+
array[rank] = hash
|
|
164
|
+
end
|
|
165
|
+
return array
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def comment
|
|
170
|
+
query = "select * from comment where bioentry_id = ?"
|
|
171
|
+
row = @dbh.execute(query, @bioentry_id).fetch
|
|
172
|
+
row ? row['comment_text'] : ''
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def comments
|
|
176
|
+
array = []
|
|
177
|
+
query = "select * from comment where bioentry_id = ?"
|
|
178
|
+
@dbh.execute(query, @bioentry_id).fetch_all.each do |row|
|
|
179
|
+
next unless row
|
|
180
|
+
rank = row['comment_rank'].to_i - 1
|
|
181
|
+
array[rank] = row['comment_text']
|
|
182
|
+
end
|
|
183
|
+
return array
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def database
|
|
187
|
+
query = "select * from biodatabase where biodatabase_id = ?"
|
|
188
|
+
row = @dbh.execute(query, @database_id).fetch
|
|
189
|
+
row ? row['name'] : ''
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def date
|
|
193
|
+
query = "select * from bioentry_date where bioentry_id = ?"
|
|
194
|
+
row = @dbh.execute(query, @bioentry_id).fetch
|
|
195
|
+
row ? row['date'] : ''
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def dblink
|
|
199
|
+
query = "select * from bioentry_direct_links where source_bioentry_id = ?"
|
|
200
|
+
row = @dbh.execute(query, @bioentry_id).fetch
|
|
201
|
+
row ? [row['dbname'], row['accession']] : []
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def definition
|
|
205
|
+
query = "select * from bioentry_description where bioentry_id = ?"
|
|
206
|
+
row = @dbh.execute(query, @bioentry_id).fetch
|
|
207
|
+
row ? row['description'] : ''
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def keyword
|
|
211
|
+
query = "select * from bioentry_keywords where bioentry_id = ?"
|
|
212
|
+
row = @dbh.execute(query, @bioentry_id).fetch
|
|
213
|
+
row ? row['keywords'] : ''
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def taxonomy
|
|
217
|
+
query = <<-END
|
|
218
|
+
select full_lineage, common_name, ncbi_taxa_id
|
|
219
|
+
from bioentry_taxa, taxa
|
|
220
|
+
where bioentry_id = ? and bioentry_taxa.taxa_id = taxa.taxa_id
|
|
221
|
+
END
|
|
222
|
+
row = @dbh.execute(query, @bioentry_id).fetch
|
|
223
|
+
@lineage = row ? row['full_lineage'] : ''
|
|
224
|
+
@common_name = row ? row['common_name'] : ''
|
|
225
|
+
@ncbi_taxa_id = row ? row['ncbi_taxa_id'] : ''
|
|
226
|
+
row ? [@lineage, @common_name, @ncbi_taxa_id] : []
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def lineage
|
|
230
|
+
taxonomy unless @lineage
|
|
231
|
+
return @lineage
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def common_name
|
|
235
|
+
taxonomy unless @common_name
|
|
236
|
+
return @common_name
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
def ncbi_taxa_id
|
|
240
|
+
taxonomy unless @ncbi_taxa_id
|
|
241
|
+
return @ncbi_taxa_id
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
private
|
|
246
|
+
|
|
247
|
+
def feature_key(k_id)
|
|
248
|
+
query = "select * from seqfeature_key where seqfeature_key_id = ?"
|
|
249
|
+
row = @dbh.execute(query, k_id).fetch
|
|
250
|
+
row ? row['key_name'] : ''
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def feature_source(s_id)
|
|
254
|
+
query = "select * from seqfeature_source where seqfeature_source_id = ?"
|
|
255
|
+
row = @dbh.execute(query, s_id).fetch
|
|
256
|
+
row ? row['source_name'] : ''
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def feature_locations(f_id)
|
|
260
|
+
locations = []
|
|
261
|
+
query = "select * from seqfeature_location where seqfeature_id = ?"
|
|
262
|
+
@dbh.execute(query, f_id).fetch_all.each do |row|
|
|
263
|
+
next unless row
|
|
264
|
+
|
|
265
|
+
location = Bio::Location.new
|
|
266
|
+
location.strand = row['seq_strand']
|
|
267
|
+
location.from = row['seq_start']
|
|
268
|
+
location.to = row['seq_end']
|
|
269
|
+
|
|
270
|
+
xref = feature_locations_remote(row['seqfeature_location_id'])
|
|
271
|
+
location.xref_id = xref.shift unless xref.empty?
|
|
272
|
+
|
|
273
|
+
# just omit fuzzy location for now...
|
|
274
|
+
#feature_locations_qv(row['seqfeature_location_id'])
|
|
275
|
+
|
|
276
|
+
rank = row['location_rank'].to_i - 1
|
|
277
|
+
locations[rank] = location
|
|
278
|
+
end
|
|
279
|
+
return Bio::Locations.new(locations)
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def feature_locations_remote(l_id)
|
|
283
|
+
query = "select * from remote_seqfeature_name where seqfeature_location_id = ?"
|
|
284
|
+
row = @dbh.execute(query, l_id).fetch
|
|
285
|
+
row ? [row['accession'], row['version']] : []
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
def feature_locations_qv(l_id)
|
|
289
|
+
query = "select * from location_qualifier_value where seqfeature_location_id = ?"
|
|
290
|
+
row = @dbh.execute(query, l_id).fetch
|
|
291
|
+
row ? [row['qualifier_value'], row['slot_value']] : []
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def feature_qualifiers(f_id)
|
|
295
|
+
qualifiers = []
|
|
296
|
+
query = "select * from seqfeature_qualifier_value where seqfeature_id = ?"
|
|
297
|
+
@dbh.execute(query, f_id).fetch_all.each do |row|
|
|
298
|
+
next unless row
|
|
299
|
+
|
|
300
|
+
key = feature_qualifiers_key(row['seqfeature_qualifier_id'])
|
|
301
|
+
value = row['qualifier_value']
|
|
302
|
+
qualifier = Bio::Feature::Qualifier.new(key, value)
|
|
303
|
+
|
|
304
|
+
rank = row['seqfeature_qualifier_rank'].to_i - 1
|
|
305
|
+
qualifiers[rank] = qualifier
|
|
306
|
+
end
|
|
307
|
+
return qualifiers.compact # .compact is nasty hack for a while
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def feature_qualifiers_key(q_id)
|
|
311
|
+
query = "select * from seqfeature_qualifier where seqfeature_qualifier_id = ?"
|
|
312
|
+
row = @dbh.execute(query, q_id).fetch
|
|
313
|
+
row ? row['qualifier_name'] : ''
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
if __FILE__ == $0
|
|
323
|
+
begin
|
|
324
|
+
require 'pp'
|
|
325
|
+
alias p pp
|
|
326
|
+
rescue LoadError
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
db = ARGV.empty? ? 'dbi:Mysql:database=biosql;host=localhost' : ARGV.shift
|
|
330
|
+
serv = Bio::SQL.new(db, 'root')
|
|
331
|
+
|
|
332
|
+
ent0 = serv.fetch('X76706')
|
|
333
|
+
ent0 = serv.fetch('A15H9FIB')
|
|
334
|
+
ent1 = serv.fetch('J01902')
|
|
335
|
+
ent2 = serv.fetch('X04311')
|
|
336
|
+
|
|
337
|
+
pp ent0.features
|
|
338
|
+
pp ent0.references
|
|
339
|
+
|
|
340
|
+
pp ent1.seq
|
|
341
|
+
pp ent1.seq.translate
|
|
342
|
+
pp ent1.seq.gc
|
|
343
|
+
pp ent1.subseq(1,20)
|
|
344
|
+
|
|
345
|
+
pp ent2.accession
|
|
346
|
+
pp ent2.comment
|
|
347
|
+
pp ent2.comments
|
|
348
|
+
pp ent2.common_name
|
|
349
|
+
pp ent2.database
|
|
350
|
+
pp ent2.date
|
|
351
|
+
pp ent2.dblink
|
|
352
|
+
pp ent2.definition
|
|
353
|
+
pp ent2.division
|
|
354
|
+
pp ent2.entry_id
|
|
355
|
+
pp ent2.features
|
|
356
|
+
pp ent2.keyword
|
|
357
|
+
pp ent2.lineage
|
|
358
|
+
pp ent2.ncbi_taxa_id
|
|
359
|
+
pp ent2.references
|
|
360
|
+
pp ent2.seq
|
|
361
|
+
pp ent2.subseq(1,10)
|
|
362
|
+
pp ent2.taxonomy
|
|
363
|
+
pp ent2.version
|
|
364
|
+
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
=begin
|
|
369
|
+
|
|
370
|
+
= Bio::SQL
|
|
371
|
+
|
|
372
|
+
--- Bio::SQL.new(db = 'dbi:Mysql:biosql', user = nil, pass = nil)
|
|
373
|
+
|
|
374
|
+
--- Bio::SQL.close
|
|
375
|
+
|
|
376
|
+
--- Bio::SQL#fetch(accession)
|
|
377
|
+
|
|
378
|
+
Returns Bio::SQL::Sequence object.
|
|
379
|
+
|
|
380
|
+
== Bio::SQL::Sequence
|
|
381
|
+
|
|
382
|
+
--- Bio::SQL::Sequence.new(dbh, entry)
|
|
383
|
+
|
|
384
|
+
--- Bio::SQL::Sequence#accession -> String
|
|
385
|
+
--- Bio::SQL::Sequence#comment -> String
|
|
386
|
+
|
|
387
|
+
Returns the first comment. For complete comments, use comments method.
|
|
388
|
+
|
|
389
|
+
--- Bio::SQL::Sequence#comments -> Array
|
|
390
|
+
|
|
391
|
+
Returns comments in an Array of Strings.
|
|
392
|
+
|
|
393
|
+
--- Bio::SQL::Sequence#common_name -> String
|
|
394
|
+
--- Bio::SQL::Sequence#database -> String
|
|
395
|
+
--- Bio::SQL::Sequence#date -> String
|
|
396
|
+
--- Bio::SQL::Sequence#dblink -> Array
|
|
397
|
+
--- Bio::SQL::Sequence#definition -> String
|
|
398
|
+
--- Bio::SQL::Sequence#division -> String
|
|
399
|
+
--- Bio::SQL::Sequence#entry_id -> String
|
|
400
|
+
|
|
401
|
+
--- Bio::SQL::Sequence#features
|
|
402
|
+
|
|
403
|
+
Returns Bio::Features object.
|
|
404
|
+
|
|
405
|
+
--- Bio::SQL::Sequence#keyword -> String
|
|
406
|
+
--- Bio::SQL::Sequence#lineage -> String
|
|
407
|
+
--- Bio::SQL::Sequence#ncbi_taxa_id -> String
|
|
408
|
+
|
|
409
|
+
--- Bio::SQL::Sequence#references -> Array
|
|
410
|
+
|
|
411
|
+
Returns reference informations in Array of Hash (not Bio::Reference).
|
|
412
|
+
|
|
413
|
+
--- Bio::SQL::Sequence#seq
|
|
414
|
+
|
|
415
|
+
Returns Bio::Sequence::NA or AA object.
|
|
416
|
+
|
|
417
|
+
--- Bio::SQL::Sequence#subseq(from, to)
|
|
418
|
+
|
|
419
|
+
Returns Bio::Sequence::NA or AA object (by lazy fetching).
|
|
420
|
+
|
|
421
|
+
--- Bio::SQL::Sequence#taxonomy -> DBI::Row
|
|
422
|
+
|
|
423
|
+
Use lineage, common_name, ncbi_taxa_id methods to extract in detail.
|
|
424
|
+
|
|
425
|
+
--- Bio::SQL::Sequence#version -> String
|
|
426
|
+
|
|
427
|
+
=end
|
|
428
|
+
|