sequenceserver-beta 0.8.7.beta1
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/Gemfile +3 -0
- data/LICENSE.Apache.txt +176 -0
- data/LICENSE.txt +69 -0
- data/README.txt +5 -0
- data/bin/sequenceserver +82 -0
- data/config.ru +6 -0
- data/example.config.yml +39 -0
- data/lib/profile_code.rb +217 -0
- data/lib/sequenceserver.rb +527 -0
- data/lib/sequenceserver/blast.rb +92 -0
- data/lib/sequenceserver/customisation.rb +60 -0
- data/lib/sequenceserver/database.rb +29 -0
- data/lib/sequenceserver/database_formatter.rb +190 -0
- data/lib/sequenceserver/helpers.rb +136 -0
- data/lib/sequenceserver/sequencehelpers.rb +93 -0
- data/lib/sequenceserver/sinatralikeloggerformatter.rb +12 -0
- data/lib/sequenceserver/version.rb +9 -0
- data/public/css/beige.css.css +254 -0
- data/public/css/bootstrap.dropdown.css +29 -0
- data/public/css/bootstrap.icons.css +155 -0
- data/public/css/bootstrap.min.css +415 -0
- data/public/css/bootstrap.modal.css +28 -0
- data/public/css/custom.css +232 -0
- data/public/img/glyphicons-halflings-white.png +0 -0
- data/public/img/glyphicons-halflings.png +0 -0
- data/public/js/bootstrap.dropdown.js +92 -0
- data/public/js/bootstrap.modal.js +7 -0
- data/public/js/bootstrap.transition.js +7 -0
- data/public/js/jquery-scrollspy.js +98 -0
- data/public/js/jquery-ui.js +14987 -0
- data/public/js/jquery.activity.js +10 -0
- data/public/js/jquery.enablePlaceholder.min.js +10 -0
- data/public/js/jquery.js +5 -0
- data/public/js/sequenceserver.blast.js +208 -0
- data/public/js/sequenceserver.js +304 -0
- data/public/js/store.min.js +2 -0
- data/sequenceserver.gemspec +49 -0
- data/tests/database/nucleotide/Sinvicta2-2-3.cdna.subset.fasta +5486 -0
- data/tests/database/nucleotide/Sinvicta2-2-3.cdna.subset.fasta.nhr +0 -0
- data/tests/database/nucleotide/Sinvicta2-2-3.cdna.subset.fasta.nin +0 -0
- data/tests/database/nucleotide/Sinvicta2-2-3.cdna.subset.fasta.nsq +0 -0
- data/tests/database/protein/Sinvicta2-2-3.prot.subset.fasta +6449 -0
- data/tests/database/protein/Sinvicta2-2-3.prot.subset.fasta.phr +0 -0
- data/tests/database/protein/Sinvicta2-2-3.prot.subset.fasta.pin +0 -0
- data/tests/database/protein/Sinvicta2-2-3.prot.subset.fasta.psq +0 -0
- data/tests/run +26 -0
- data/tests/test_sequencehelpers.rb +77 -0
- data/tests/test_sequenceserver_blast.rb +60 -0
- data/tests/test_ui.rb +104 -0
- data/tests/test_ui.rb~ +104 -0
- data/tests/ui.specs.todo +10 -0
- data/views/500.erb +22 -0
- data/views/_options.erb +144 -0
- data/views/search.erb +220 -0
- metadata +226 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 83b35f8dfca75fbce7007e69f85f0ce8ca20a535
|
4
|
+
data.tar.gz: 0a0d7f13d30df5bbf6cb40f5a5c7b508fb7f8976
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 287254a9e93241d43ab7719c5c11bb7eb246814ffaed0dba21a275c45813b436a15eef03fc6a766670ed15d9b5aab2d6b2e6bc3d82da8c3436cba7aa6ad2e2e3
|
7
|
+
data.tar.gz: ce04e4b60e6bb5400ba15ca811cca5e97a0447524b76b9e5dbd772212cd059d93e2e6447f0d12d4592b422dce4ae19af709c52d5d7df44a2dd5ca6b0019eea89
|
data/Gemfile
ADDED
data/LICENSE.Apache.txt
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
SequenceServer (http://sequenceserver.com)
|
2
|
+
Copyright (c) 2010-2011 Yannick Wurm, Benjamin J. Woodcroft, Anurag Priyam.
|
3
|
+
|
4
|
+
|
5
|
+
1. Definitions
|
6
|
+
|
7
|
+
The software: the SequenceServer software and associated documentation. The
|
8
|
+
term does not extend to unmodified open source software components used within
|
9
|
+
SequenceServer which are governed by their own license agreements. However,
|
10
|
+
modfications to such components shall be deemed a part of the SequenceServer
|
11
|
+
software.
|
12
|
+
|
13
|
+
The authors: Yannick Wurm, Anurag Priyam, Benjamin J. Woodcroft.
|
14
|
+
|
15
|
+
|
16
|
+
2. Fair usage
|
17
|
+
|
18
|
+
Within not-for-profit and educational organizations the software can
|
19
|
+
be freely used by individuals and on internal and public websites.
|
20
|
+
|
21
|
+
Installation of the software or use of the software by for-profit
|
22
|
+
organizations (including but not limited to companies, service providers
|
23
|
+
and consultancies) requires purchase of a usage license or other specific
|
24
|
+
arrangements with the authors.
|
25
|
+
|
26
|
+
|
27
|
+
3. Modifications
|
28
|
+
|
29
|
+
Modifications can be made by not-for-profit and educational organizations.
|
30
|
+
However, citation requests and links to sequenceserver.com must remain
|
31
|
+
visible and unaltered.
|
32
|
+
|
33
|
+
|
34
|
+
4. Redistribution of the software
|
35
|
+
|
36
|
+
Redistribution without modification is permitted unless associated to
|
37
|
+
a financial transaction. In particular, the software may not be
|
38
|
+
distributed with nor installed via a commercial software package, nor
|
39
|
+
be made available by commercial service providers.
|
40
|
+
|
41
|
+
Redistribution with modification is permitted only if ALL of the
|
42
|
+
following conditions are respected:
|
43
|
+
|
44
|
+
a. no financial transaction is associated (see above).
|
45
|
+
b. This license and copyright notices are included and remain
|
46
|
+
unchanged; citation requests and links to sequenceserver.com
|
47
|
+
remain visible and unaltered.
|
48
|
+
c. Modifications are made freely available on github.com (or an
|
49
|
+
equivalent medium) and the authors are allowed to freely
|
50
|
+
incorporate modifications into the software.
|
51
|
+
|
52
|
+
|
53
|
+
5. Specific needs
|
54
|
+
|
55
|
+
The authors reserve the right to make specific licensing, modification
|
56
|
+
and distribution arrangements with interested parties.
|
57
|
+
|
58
|
+
|
59
|
+
6. Disclaimer
|
60
|
+
|
61
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
62
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
63
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
64
|
+
PURPOSE. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
65
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
66
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
67
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
68
|
+
SOFTWARE.
|
69
|
+
|
data/README.txt
ADDED
data/bin/sequenceserver
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'optparse'
|
6
|
+
require 'sequenceserver'
|
7
|
+
|
8
|
+
# e.g:
|
9
|
+
# sequenceserver --config .sequenceserver.conf format_database
|
10
|
+
begin
|
11
|
+
# parse command line till first non-option, removing parsed options from ARGV
|
12
|
+
OptionParser.new do |opts|
|
13
|
+
opts.banner =<<BANNER
|
14
|
+
|
15
|
+
SUMMARY
|
16
|
+
|
17
|
+
custom, local, BLAST server
|
18
|
+
|
19
|
+
USAGE
|
20
|
+
|
21
|
+
sequenceserver [options] [subcommand] [subcommand's options]
|
22
|
+
|
23
|
+
Example:
|
24
|
+
|
25
|
+
# launch SequenceServer with the given config file
|
26
|
+
$ sequenceserver --config ~/.sequenceserver.ants.conf
|
27
|
+
|
28
|
+
# use the bundled database formatter utility to prepare databases for use
|
29
|
+
# with SequenceServer
|
30
|
+
$ sequenceserver format-databases
|
31
|
+
|
32
|
+
DESCRIPTION
|
33
|
+
|
34
|
+
SequenceServer lets you rapidly set up a BLAST+ server with an intuitive user
|
35
|
+
interface for use locally or over the web.
|
36
|
+
|
37
|
+
SUB-COMMANDS
|
38
|
+
|
39
|
+
format-databases:
|
40
|
+
prepare BLAST databases for use with SequenceServer
|
41
|
+
|
42
|
+
Run '#{$0} format-databases -h' for help.
|
43
|
+
|
44
|
+
OPTIONS
|
45
|
+
|
46
|
+
BANNER
|
47
|
+
opts.on('-c', '--config CONFIG_FILE', 'Use the given configuration file') do |config_file|
|
48
|
+
SequenceServer::App.config_file = File.expand_path(config_file)
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on('-v', '--version', 'Print version number of SequenceServer that will be loaded.' ) do |config_file|
|
52
|
+
puts SequenceServer.version
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
end.order!
|
56
|
+
|
57
|
+
# of the remaining items in ARGV, the first one must be a subcommand
|
58
|
+
subcommand = ARGV.shift
|
59
|
+
|
60
|
+
if subcommand
|
61
|
+
# process subcommands now
|
62
|
+
|
63
|
+
case subcommand
|
64
|
+
when 'format-databases'
|
65
|
+
require 'sequenceserver/database_formatter'
|
66
|
+
exit
|
67
|
+
else
|
68
|
+
puts "invalid subcommand: #{subcommand}"
|
69
|
+
puts "Run '#{$0} -h' for help with command line options."
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
end
|
73
|
+
rescue OptionParser::InvalidOption =>e
|
74
|
+
puts e
|
75
|
+
puts "Run '#{$0} -h' for help with command line options."
|
76
|
+
exit
|
77
|
+
end
|
78
|
+
|
79
|
+
# display name for tools like `ps`
|
80
|
+
$PROGRAM_NAME = 'sequenceserver'
|
81
|
+
|
82
|
+
SequenceServer::App.run!
|
data/config.ru
ADDED
data/example.config.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Path to the blast executables.
|
2
|
+
#
|
3
|
+
# Sequence Server scans the given directory for blast binaries. Ideally it
|
4
|
+
# should point the `bin` of your BLAST+ installation. Not setting this
|
5
|
+
# value, or setting it to `nil` will default to searching the system `PATH`.
|
6
|
+
#
|
7
|
+
# Uncomment the following line, and change to appropriate value to use.
|
8
|
+
#
|
9
|
+
# bin: ~/ncbi-blast-2.2.25+/bin/
|
10
|
+
|
11
|
+
# Path to blast database.
|
12
|
+
#
|
13
|
+
# Sequence Server scans the given directory (including the sub-directories)
|
14
|
+
# for blast database. You can not specify more than one top-level directory.
|
15
|
+
# Not setting this value, will default to searching `database` directory
|
16
|
+
# relative to the current working directory.
|
17
|
+
#
|
18
|
+
# Uncomment the following line, and change to appropriate value to use.
|
19
|
+
#
|
20
|
+
# database: ~/blast_databases/
|
21
|
+
|
22
|
+
# Port to run Sequence Server on.
|
23
|
+
#
|
24
|
+
# The app will then be accessible at http://your-ip:port. Defaults to 4567.
|
25
|
+
# http://localhost:port is also valid for local access.
|
26
|
+
#
|
27
|
+
# Uncomment the following line, and change to appropriate value to use.
|
28
|
+
#
|
29
|
+
# port: 4567
|
30
|
+
|
31
|
+
# number of threads to be use when blasting
|
32
|
+
#
|
33
|
+
# This option is passed directly to BLAST+. Setting this option to more
|
34
|
+
# than 1 may crash BLAST+ if it was not compiled with threading support.
|
35
|
+
# Default is to use the safe value of 1.
|
36
|
+
#
|
37
|
+
# Uncomment the following line, and change to appropriate value to use.
|
38
|
+
#
|
39
|
+
# num_threads: 1
|
data/lib/profile_code.rb
ADDED
@@ -0,0 +1,217 @@
|
|
1
|
+
require 'ruby-prof'
|
2
|
+
|
3
|
+
$:.unshift '.'
|
4
|
+
|
5
|
+
#require 'sinatra/base'
|
6
|
+
require 'yaml'
|
7
|
+
require 'logger'
|
8
|
+
require 'fileutils'
|
9
|
+
require 'sequenceserver/helpers'
|
10
|
+
require 'sequenceserver/blast'
|
11
|
+
require 'sequenceserver/sequencehelpers'
|
12
|
+
require 'sequenceserver/sinatralikeloggerformatter'
|
13
|
+
require 'sequenceserver/customisation'
|
14
|
+
require 'sequenceserver/version'
|
15
|
+
|
16
|
+
require 'sequenceserver'
|
17
|
+
|
18
|
+
|
19
|
+
query = '>1111883
|
20
|
+
GCTGGCGGCGTGCCTAACACATGTAAGTCGAACGGGACTGGGGGCAACTCCAGTTCAGTG
|
21
|
+
GCAGACGGGTGCGTAACACGTGAGCAACTTGTCCGACGGCGGGGGATAGCCGGCCCAACG
|
22
|
+
GCCGGGTAATACCGCGTACGCTCGTTTAGGGACATCCCTGAATGAGGAAAGCCGTAAGGC
|
23
|
+
ACCGACGGAGAGGCTCGCGGCCTATCAGCTAGTTGGCGGGGTAACGGCCCACCAAGGCGA
|
24
|
+
CGACGGGTAGCTGGTCTGAGAGGATGGCCAGCCACATTGGGACTGAGACACGGCCCAGAC
|
25
|
+
TCCTACGGGAGGCAGCAGTGGGGAATCTTGCGCAATGGCCGCAAGGCTGACGCAGCGACG
|
26
|
+
CCGCGTGTGGGATGACGGCCTTCGGGTTGTAAACCACTGTCGGGAGGAACGAATACTCGG
|
27
|
+
CTAGTCCGAGGGTGACGGTACCTCCAAAGGAAGCACCGGCTAACTCCGTGCCAGCAGCCG
|
28
|
+
CGGTAATACGGAGGGTGCGAGCGTTGTCCGGAATCACTGGGCGTAAAGGGCGCGTAGGTG
|
29
|
+
GCCCGTTAAGTGGCTGGTGAAATCCCGGGGCTCAACTCCGGGGCTGCCGGTCAGACTGGC
|
30
|
+
GAGCTAGAGCACGGTAGGGGCAGATGGAATTCCCGGTGTAGCGGTGGAATGCGTAGATAT
|
31
|
+
CGGGAAGAATACCAGTGGCGAAGGCGTTCTGCTGGGCCGTTGCTGACACTGAGGCGCGAC
|
32
|
+
AGCGTGGGGAGCAAACAGGATTAGATACCCTGGTAGTCCACGCCGTAAACGATGGACACT
|
33
|
+
AGACGTCGGGGGGAGCGACCCTCCCGGTGTCGTCGCTAACGCAGTAAGTGTCCCGCCTGG
|
34
|
+
GGAGTACGGCCGCAAGGCTGAAACTCAAAGGAATTGACGGGGGCCCGCACAAGCGGTGGA
|
35
|
+
GCATGTGGTTTAATTCGAAGCAACGCGAAGAACCTTACCTGGGCTTGACATGCTGGTGCA
|
36
|
+
AGCCGGTGGAAACATCGGCCCCTCTTCGGAGCGCCAGCACAGGTGCTGCATGGCTGTCGT
|
37
|
+
CAGCTCGTGTCGTGAGATGTTGGGTTAAGTCCCGCAACGAGCGCAACTCTCGCTCCCAGT
|
38
|
+
TGCCAGCGGTTCGGCCGGGGACTCTGGGGGGACTGCCGGCGTTAAGCCGGAGGAAGGTGG
|
39
|
+
GGACGACGTCAAGTCATCATGGCCCTTACGTCCAGGGCGACACACGTGCTACAATGCCTG
|
40
|
+
GTACAGCGCGTCGCGAACTCGCAAGAGGGAGCCAATCGCCAAAAGCCGGGCTAAGTTCGG
|
41
|
+
ATTGTCGTCTGCAACTCGACGGCATGAAGCCGGAATCGCTAGTAATCGCGGATCAGCCAC
|
42
|
+
GCCGCGGTGAATACGTTCCCGGGCCTTGTACACACCGCCCGTCACGCCATGGAAGCCGGA
|
43
|
+
GGGACCCGAAACCGGTGGGCCAACCGCAAGGGGGCAGCCGTCTAAGGT'
|
44
|
+
|
45
|
+
#blastn -db '/home/ben/git/sequenceserver/db/97_otus.fasta' -query '/tmp/sequenceserver_query20140119-10926-qt2ecp' -task blastn -num_threads 1 -html
|
46
|
+
method = 'blastn'#params['method']
|
47
|
+
databases = ['/home/ben/git/sequenceserver/db/97_otus.fasta']#params[:databases]
|
48
|
+
sequence = query #params[:sequence]
|
49
|
+
advanced_opts = '-max_target_seqs 1'#params['advanced']
|
50
|
+
|
51
|
+
# evaluate empty sequence as nil, otherwise as fasta
|
52
|
+
# sequence = sequence.empty? ? nil : to_fasta(sequence)
|
53
|
+
|
54
|
+
# blastn implies blastn, not megablast; but let's not interfere if a user
|
55
|
+
# specifies `task` herself
|
56
|
+
if method == 'blastn' and not advanced_opts =~ /task/
|
57
|
+
#advanced_opts << ' -task blastn '
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# run blast and log
|
62
|
+
blast = SequenceServer::Blast.new(method, sequence, databases.join(' '), advanced_opts)
|
63
|
+
blast.run!
|
64
|
+
puts('Ran: ' + blast.command)
|
65
|
+
|
66
|
+
|
67
|
+
def format_blast_results(result, databases)
|
68
|
+
formatted_result = ''
|
69
|
+
@all_retrievable_ids = []
|
70
|
+
string_of_used_databases = databases.join(' ')
|
71
|
+
blast_database_number = 0
|
72
|
+
line_number = 0
|
73
|
+
started_query = false
|
74
|
+
finished_database_summary = false
|
75
|
+
finished_alignments = false
|
76
|
+
reference_string = ''
|
77
|
+
database_summary_string = ''
|
78
|
+
result.each do |line|
|
79
|
+
line_number += 1
|
80
|
+
next if line_number <= 5 #skip the first 5 lines
|
81
|
+
|
82
|
+
# Add the reference to the end, not the start, of the blast result
|
83
|
+
if line_number >= 7 and line_number <= 15
|
84
|
+
reference_string += line
|
85
|
+
next
|
86
|
+
end
|
87
|
+
|
88
|
+
if !finished_database_summary and line_number > 15
|
89
|
+
database_summary_string += line
|
90
|
+
finished_database_summary = true if line.match(/total letters/)
|
91
|
+
next
|
92
|
+
end
|
93
|
+
|
94
|
+
# Remove certain lines from the output
|
95
|
+
skipped_lines = [/^<\/BODY>/,/^<\/HTML>/,/^<\/PRE>/]
|
96
|
+
skip = false
|
97
|
+
skipped_lines.each do |skippy|
|
98
|
+
# $stderr.puts "`#{line}' matches #{skippy}?"
|
99
|
+
if skippy.match(line)
|
100
|
+
skip = true
|
101
|
+
# $stderr.puts 'yes'
|
102
|
+
else
|
103
|
+
# $stderr.puts 'no'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
next if skip
|
107
|
+
|
108
|
+
# Remove the javascript inclusion
|
109
|
+
line.gsub!(/^<script src=\"blastResult.js\"><\/script>/, '')
|
110
|
+
|
111
|
+
if line.match(/^>/) # If line to possibly replace
|
112
|
+
# Reposition the anchor to the end of the line, so that it both still works and
|
113
|
+
# doesn't interfere with the diagnostic space at the beginning of the line.
|
114
|
+
#
|
115
|
+
# There are two cases:
|
116
|
+
#
|
117
|
+
# database formatted _with_ -parse_seqids
|
118
|
+
line.gsub!(/^>(.+)(<a.*><\/a>)(.*)/, '>\1\3\2')
|
119
|
+
#
|
120
|
+
# database formatted _without_ -parse_seqids
|
121
|
+
line.gsub!(/^>(<a.*><\/a>)(.*)/, '>\2\1')
|
122
|
+
|
123
|
+
# get hit coordinates -- useful for linking to genome browsers
|
124
|
+
hit_length = result[line_number..-1].index{|l| l =~ />lcl|Lambda/}
|
125
|
+
hit_coordinates = result[line_number, hit_length].grep(/Sbjct/).
|
126
|
+
map(&:split).map{|l| [l[1], l[-1]]}.flatten.map(&:to_i).minmax
|
127
|
+
|
128
|
+
# Create the hyperlink (if required)
|
129
|
+
formatted_result += construct_sequence_hyperlink_line(line, databases, hit_coordinates)
|
130
|
+
else
|
131
|
+
# Surround each query's result in <div> tags so they can be coloured by CSS
|
132
|
+
if matches = line.match(/^<b>Query=<\/b> (.*)/) # If starting a new query, then surround in new <div> tag, and finish the last one off
|
133
|
+
line = "<div class=\"resultn\" id=\"#{matches[1]}\">\n<h3>Query= #{matches[1]}</h3><pre>"
|
134
|
+
unless blast_database_number == 0
|
135
|
+
line = "</pre></div>\n#{line}"
|
136
|
+
end
|
137
|
+
blast_database_number += 1
|
138
|
+
elsif line.match(/^ Database: /) and !finished_alignments
|
139
|
+
formatted_result += "</div>\n<pre>#{database_summary_string}\n\n"
|
140
|
+
finished_alignments = true
|
141
|
+
end
|
142
|
+
formatted_result += line
|
143
|
+
end
|
144
|
+
end
|
145
|
+
formatted_result << "</pre>"
|
146
|
+
|
147
|
+
link_to_fasta_of_all = "/get_sequence/?id=#{@all_retrievable_ids.join(' ')}&db=#{string_of_used_databases}"
|
148
|
+
# #dbs must be sep by ' '
|
149
|
+
retrieval_text = @all_retrievable_ids.empty? ? '' : "<a href='#{url(link_to_fasta_of_all)}'>FASTA of #{@all_retrievable_ids.length} retrievable hit(s)</a>"
|
150
|
+
|
151
|
+
"<h2>Results</h2>"+
|
152
|
+
retrieval_text +
|
153
|
+
"<br/><br/>" +
|
154
|
+
formatted_result +
|
155
|
+
"<br/>" +
|
156
|
+
"<pre>#{reference_string.strip}</pre>"
|
157
|
+
end
|
158
|
+
|
159
|
+
def construct_sequence_hyperlink_line(line, databases, hit_coordinates)
|
160
|
+
matches = line.match(/^>(.+)/)
|
161
|
+
sequence_id = matches[1]
|
162
|
+
|
163
|
+
link = nil
|
164
|
+
|
165
|
+
# If a custom sequence hyperlink method has been defined,
|
166
|
+
# use that.
|
167
|
+
options = {
|
168
|
+
:sequence_id => sequence_id,
|
169
|
+
:databases => databases,
|
170
|
+
:hit_coordinates => hit_coordinates
|
171
|
+
}
|
172
|
+
|
173
|
+
# First precedence: construct the whole line to be customised
|
174
|
+
if self.respond_to?(:construct_custom_sequence_hyperlinking_line)
|
175
|
+
settings.log.debug("Using custom hyperlinking line creator with sequence #{options.inspect}")
|
176
|
+
link_line = construct_custom_sequence_hyperlinking_line(options)
|
177
|
+
unless link_line.nil?
|
178
|
+
return link_line
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# If we have reached here, custom construction of the
|
183
|
+
# whole line either wasn't defined, or returned nil
|
184
|
+
# (indicating failure)
|
185
|
+
if self.respond_to?(:construct_custom_sequence_hyperlink)
|
186
|
+
# settings.log.debug("Using custom hyperlink creator with sequence #{options.inspect}")
|
187
|
+
link = construct_custom_sequence_hyperlink(options)
|
188
|
+
else
|
189
|
+
# settings.log.debug("Using standard hyperlink creator with sequence `#{options.inspect}'")
|
190
|
+
link = construct_standard_sequence_hyperlink(options)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Return the BLAST output line with the link in it
|
194
|
+
if link.nil?
|
195
|
+
# settings.log.debug('No link added link for: `'+ sequence_id +'\'')
|
196
|
+
return line
|
197
|
+
else
|
198
|
+
settings.log.debug('Added link for: `'+ sequence_id +'\''+ link)
|
199
|
+
return "><a href='#{url(link)}' target='_blank'>#{sequence_id}</a> \n"
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
# Advanced options are specified by the user. Here they are checked for interference with SequenceServer operations.
|
205
|
+
# raise ArgumentError if an error has occurred, otherwise return without value
|
206
|
+
def validate_advanced_parameters(advanced_options)
|
207
|
+
raise ArgumentError, "Invalid characters detected in the advanced options" unless advanced_options =~ /\A[a-z0-9\-_\. ']*\Z/i
|
208
|
+
disallowed_options = %w(-out -html -outfmt -db -query)
|
209
|
+
disallowed_options.each do |o|
|
210
|
+
raise ArgumentError, "The advanced BLAST option \"#{o}\" is used internally by SequenceServer and so cannot be specified by the you" if advanced_options =~ /#{o}/i
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
puts format_blast_results(blast.result, databases)
|
215
|
+
|
216
|
+
|
217
|
+
|