jandot-bio 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/bioruby +44 -0
- data/bin/br_biofetch.rb +47 -0
- data/bin/br_bioflat.rb +282 -0
- data/bin/br_biogetseq.rb +45 -0
- data/bin/br_pmfetch.rb +421 -0
- data/doc/Changes-0.7.rd +369 -0
- data/doc/KEGG_API.rd +1843 -0
- data/doc/KEGG_API.rd.ja +1834 -0
- data/doc/Tutorial.rd +1296 -0
- data/doc/Tutorial.rd.ja +2640 -0
- data/etc/bioinformatics/seqdatabase.ini +210 -0
- data/lib/bio.rb +279 -0
- data/lib/bio/alignment.rb +2518 -0
- data/lib/bio/appl/bl2seq/report.rb +334 -0
- data/lib/bio/appl/blast.rb +351 -0
- data/lib/bio/appl/blast/format0.rb +1438 -0
- data/lib/bio/appl/blast/format8.rb +83 -0
- data/lib/bio/appl/blast/report.rb +516 -0
- data/lib/bio/appl/blast/rexml.rb +135 -0
- data/lib/bio/appl/blast/rpsblast.rb +176 -0
- data/lib/bio/appl/blast/wublast.rb +550 -0
- data/lib/bio/appl/blast/xmlparser.rb +228 -0
- data/lib/bio/appl/blat/report.rb +489 -0
- data/lib/bio/appl/clustalw.rb +219 -0
- data/lib/bio/appl/clustalw/report.rb +152 -0
- data/lib/bio/appl/emboss.rb +203 -0
- data/lib/bio/appl/fasta.rb +237 -0
- data/lib/bio/appl/fasta/format10.rb +325 -0
- data/lib/bio/appl/gcg/msf.rb +212 -0
- data/lib/bio/appl/gcg/seq.rb +195 -0
- data/lib/bio/appl/genscan/report.rb +552 -0
- data/lib/bio/appl/hmmer.rb +126 -0
- data/lib/bio/appl/hmmer/report.rb +683 -0
- data/lib/bio/appl/iprscan/report.rb +374 -0
- data/lib/bio/appl/mafft.rb +259 -0
- data/lib/bio/appl/mafft/report.rb +226 -0
- data/lib/bio/appl/muscle.rb +52 -0
- data/lib/bio/appl/phylip/alignment.rb +129 -0
- data/lib/bio/appl/phylip/distance_matrix.rb +96 -0
- data/lib/bio/appl/probcons.rb +41 -0
- data/lib/bio/appl/psort.rb +548 -0
- data/lib/bio/appl/psort/report.rb +457 -0
- data/lib/bio/appl/pts1.rb +263 -0
- data/lib/bio/appl/sim4.rb +124 -0
- data/lib/bio/appl/sim4/report.rb +485 -0
- data/lib/bio/appl/sosui/report.rb +151 -0
- data/lib/bio/appl/spidey/report.rb +593 -0
- data/lib/bio/appl/targetp/report.rb +267 -0
- data/lib/bio/appl/tcoffee.rb +55 -0
- data/lib/bio/appl/tmhmm/report.rb +222 -0
- data/lib/bio/command.rb +337 -0
- data/lib/bio/data/aa.rb +349 -0
- data/lib/bio/data/codontable.rb +722 -0
- data/lib/bio/data/na.rb +223 -0
- data/lib/bio/db.rb +329 -0
- data/lib/bio/db/aaindex.rb +357 -0
- data/lib/bio/db/embl/common.rb +336 -0
- data/lib/bio/db/embl/embl.rb +402 -0
- data/lib/bio/db/embl/sptr.rb +1283 -0
- data/lib/bio/db/embl/swissprot.rb +42 -0
- data/lib/bio/db/embl/trembl.rb +41 -0
- data/lib/bio/db/embl/uniprot.rb +42 -0
- data/lib/bio/db/fantom.rb +599 -0
- data/lib/bio/db/fasta.rb +907 -0
- data/lib/bio/db/genbank/common.rb +290 -0
- data/lib/bio/db/genbank/ddbj.rb +22 -0
- data/lib/bio/db/genbank/genbank.rb +215 -0
- data/lib/bio/db/genbank/genpept.rb +60 -0
- data/lib/bio/db/genbank/refseq.rb +18 -0
- data/lib/bio/db/gff.rb +174 -0
- data/lib/bio/db/go.rb +481 -0
- data/lib/bio/db/kegg/brite.rb +41 -0
- data/lib/bio/db/kegg/compound.rb +131 -0
- data/lib/bio/db/kegg/drug.rb +98 -0
- data/lib/bio/db/kegg/enzyme.rb +148 -0
- data/lib/bio/db/kegg/expression.rb +155 -0
- data/lib/bio/db/kegg/genes.rb +263 -0
- data/lib/bio/db/kegg/genome.rb +241 -0
- data/lib/bio/db/kegg/glycan.rb +170 -0
- data/lib/bio/db/kegg/keggtab.rb +357 -0
- data/lib/bio/db/kegg/kgml.rb +256 -0
- data/lib/bio/db/kegg/orthology.rb +136 -0
- data/lib/bio/db/kegg/reaction.rb +82 -0
- data/lib/bio/db/kegg/taxonomy.rb +331 -0
- data/lib/bio/db/lasergene.rb +209 -0
- data/lib/bio/db/litdb.rb +107 -0
- data/lib/bio/db/medline.rb +323 -0
- data/lib/bio/db/nbrf.rb +191 -0
- data/lib/bio/db/newick.rb +658 -0
- data/lib/bio/db/nexus.rb +1854 -0
- data/lib/bio/db/pdb.rb +29 -0
- data/lib/bio/db/pdb/atom.rb +77 -0
- data/lib/bio/db/pdb/chain.rb +210 -0
- data/lib/bio/db/pdb/chemicalcomponent.rb +224 -0
- data/lib/bio/db/pdb/model.rb +148 -0
- data/lib/bio/db/pdb/pdb.rb +1911 -0
- data/lib/bio/db/pdb/residue.rb +176 -0
- data/lib/bio/db/pdb/utils.rb +399 -0
- data/lib/bio/db/prosite.rb +597 -0
- data/lib/bio/db/rebase.rb +457 -0
- data/lib/bio/db/soft.rb +404 -0
- data/lib/bio/db/transfac.rb +375 -0
- data/lib/bio/feature.rb +226 -0
- data/lib/bio/io/das.rb +461 -0
- data/lib/bio/io/dbget.rb +194 -0
- data/lib/bio/io/ddbjxml.rb +581 -0
- data/lib/bio/io/ebisoap.rb +158 -0
- data/lib/bio/io/ensembl.rb +229 -0
- data/lib/bio/io/fastacmd.rb +163 -0
- data/lib/bio/io/fetch.rb +181 -0
- data/lib/bio/io/flatfile.rb +1309 -0
- data/lib/bio/io/flatfile/bdb.rb +253 -0
- data/lib/bio/io/flatfile/index.rb +1371 -0
- data/lib/bio/io/flatfile/indexer.rb +787 -0
- data/lib/bio/io/higet.rb +73 -0
- data/lib/bio/io/hinv.rb +442 -0
- data/lib/bio/io/keggapi.rb +805 -0
- data/lib/bio/io/ncbirest.rb +256 -0
- data/lib/bio/io/ncbisoap.rb +155 -0
- data/lib/bio/io/pubmed.rb +307 -0
- data/lib/bio/io/registry.rb +292 -0
- data/lib/bio/io/soapwsdl.rb +119 -0
- data/lib/bio/io/sql.rb +365 -0
- data/lib/bio/location.rb +772 -0
- data/lib/bio/map.rb +410 -0
- data/lib/bio/pathway.rb +854 -0
- data/lib/bio/reference.rb +623 -0
- data/lib/bio/sequence.rb +475 -0
- data/lib/bio/sequence/aa.rb +125 -0
- data/lib/bio/sequence/common.rb +333 -0
- data/lib/bio/sequence/compat.rb +123 -0
- data/lib/bio/sequence/format.rb +181 -0
- data/lib/bio/sequence/generic.rb +24 -0
- data/lib/bio/sequence/na.rb +491 -0
- data/lib/bio/shell.rb +44 -0
- data/lib/bio/shell/core.rb +578 -0
- data/lib/bio/shell/demo.rb +146 -0
- data/lib/bio/shell/interface.rb +218 -0
- data/lib/bio/shell/irb.rb +95 -0
- data/lib/bio/shell/object.rb +71 -0
- data/lib/bio/shell/plugin/blast.rb +42 -0
- data/lib/bio/shell/plugin/codon.rb +218 -0
- data/lib/bio/shell/plugin/das.rb +58 -0
- data/lib/bio/shell/plugin/emboss.rb +23 -0
- data/lib/bio/shell/plugin/entry.rb +105 -0
- data/lib/bio/shell/plugin/flatfile.rb +101 -0
- data/lib/bio/shell/plugin/keggapi.rb +181 -0
- data/lib/bio/shell/plugin/midi.rb +430 -0
- data/lib/bio/shell/plugin/obda.rb +45 -0
- data/lib/bio/shell/plugin/psort.rb +56 -0
- data/lib/bio/shell/plugin/seq.rb +247 -0
- data/lib/bio/shell/plugin/soap.rb +87 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +29 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +4 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +27 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +11 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +4 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +7 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-bg.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-gem.png +0 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby-link.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.css +368 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +47 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +144 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +47 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +8 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +10 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +26 -0
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
- data/lib/bio/shell/script.rb +25 -0
- data/lib/bio/shell/setup.rb +109 -0
- data/lib/bio/shell/web.rb +102 -0
- data/lib/bio/tree.rb +850 -0
- data/lib/bio/util/color_scheme.rb +191 -0
- data/lib/bio/util/color_scheme/buried.rb +59 -0
- data/lib/bio/util/color_scheme/helix.rb +59 -0
- data/lib/bio/util/color_scheme/hydropathy.rb +64 -0
- data/lib/bio/util/color_scheme/nucleotide.rb +31 -0
- data/lib/bio/util/color_scheme/strand.rb +59 -0
- data/lib/bio/util/color_scheme/taylor.rb +50 -0
- data/lib/bio/util/color_scheme/turn.rb +59 -0
- data/lib/bio/util/color_scheme/zappo.rb +50 -0
- data/lib/bio/util/contingency_table.rb +370 -0
- data/lib/bio/util/restriction_enzyme.rb +228 -0
- data/lib/bio/util/restriction_enzyme/analysis.rb +249 -0
- data/lib/bio/util/restriction_enzyme/analysis_basic.rb +217 -0
- data/lib/bio/util/restriction_enzyme/cut_symbol.rb +107 -0
- data/lib/bio/util/restriction_enzyme/double_stranded.rb +321 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/aligned_strands.rb +130 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair.rb +103 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_location_pair_in_enzyme_notation.rb +38 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations.rb +76 -0
- data/lib/bio/util/restriction_enzyme/double_stranded/cut_locations_in_enzyme_notation.rb +107 -0
- data/lib/bio/util/restriction_enzyme/enzymes.yaml +7061 -0
- data/lib/bio/util/restriction_enzyme/range/cut_range.rb +24 -0
- data/lib/bio/util/restriction_enzyme/range/cut_ranges.rb +47 -0
- data/lib/bio/util/restriction_enzyme/range/horizontal_cut_range.rb +67 -0
- data/lib/bio/util/restriction_enzyme/range/sequence_range.rb +257 -0
- data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +242 -0
- data/lib/bio/util/restriction_enzyme/range/sequence_range/fragment.rb +51 -0
- data/lib/bio/util/restriction_enzyme/range/sequence_range/fragments.rb +41 -0
- data/lib/bio/util/restriction_enzyme/range/vertical_cut_range.rb +77 -0
- data/lib/bio/util/restriction_enzyme/single_strand.rb +199 -0
- data/lib/bio/util/restriction_enzyme/single_strand/cut_locations_in_enzyme_notation.rb +135 -0
- data/lib/bio/util/restriction_enzyme/single_strand_complement.rb +23 -0
- data/lib/bio/util/restriction_enzyme/string_formatting.rb +111 -0
- data/lib/bio/util/sirna.rb +288 -0
- data/sample/any2fasta.rb +59 -0
- data/sample/biofetch.rb +475 -0
- data/sample/color_scheme_na.rb +91 -0
- data/sample/dbget +37 -0
- data/sample/enzymes.rb +78 -0
- data/sample/fasta2tab.rb +99 -0
- data/sample/fastagrep.rb +72 -0
- data/sample/fastasort.rb +54 -0
- data/sample/fsplit.rb +51 -0
- data/sample/gb2fasta.rb +30 -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 +303 -0
- data/sample/gt2fasta.rb +47 -0
- data/sample/na2aa.rb +34 -0
- data/sample/pmfetch.rb +42 -0
- data/sample/pmsearch.rb +42 -0
- data/sample/psortplot_html.rb +214 -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/HMMER/hmmpfam.out +64 -0
- data/test/data/HMMER/hmmsearch.out +88 -0
- data/test/data/SOSUI/sample.report +11 -0
- data/test/data/TMHMM/sample.report +21 -0
- data/test/data/aaindex/DAYM780301 +30 -0
- data/test/data/aaindex/PRAM900102 +20 -0
- data/test/data/bl2seq/cd8a_cd8b_blastp.bl2seq +53 -0
- data/test/data/bl2seq/cd8a_p53_e-5blastp.bl2seq +37 -0
- data/test/data/blast/2.2.15.blastp.m7 +876 -0
- data/test/data/blast/b0002.faa +15 -0
- data/test/data/blast/b0002.faa.m0 +128 -0
- data/test/data/blast/b0002.faa.m7 +65 -0
- data/test/data/blast/b0002.faa.m8 +1 -0
- data/test/data/embl/AB090716.embl +65 -0
- data/test/data/embl/AB090716.embl.rel89 +63 -0
- data/test/data/fasta/example1.txt +75 -0
- data/test/data/fasta/example2.txt +21 -0
- data/test/data/genscan/sample.report +63 -0
- data/test/data/iprscan/merged.raw +32 -0
- data/test/data/iprscan/merged.txt +74 -0
- data/test/data/prosite/prosite.dat +2233 -0
- data/test/data/refseq/nm_126355.entret +64 -0
- data/test/data/soft/GDS100_partial.soft +92 -0
- data/test/data/soft/GSE3457_family_partial.soft +874 -0
- data/test/data/uniprot/p53_human.uniprot +1456 -0
- data/test/functional/bio/io/test_ensembl.rb +186 -0
- data/test/functional/bio/io/test_soapwsdl.rb +52 -0
- data/test/runner.rb +14 -0
- data/test/unit/bio/appl/bl2seq/test_report.rb +134 -0
- data/test/unit/bio/appl/blast/test_report.rb +417 -0
- data/test/unit/bio/appl/blast/test_xmlparser.rb +388 -0
- data/test/unit/bio/appl/genscan/test_report.rb +182 -0
- data/test/unit/bio/appl/hmmer/test_report.rb +342 -0
- data/test/unit/bio/appl/iprscan/test_report.rb +338 -0
- data/test/unit/bio/appl/mafft/test_report.rb +63 -0
- data/test/unit/bio/appl/sosui/test_report.rb +81 -0
- data/test/unit/bio/appl/targetp/test_report.rb +146 -0
- data/test/unit/bio/appl/test_blast.rb +163 -0
- data/test/unit/bio/appl/test_fasta.rb +130 -0
- data/test/unit/bio/appl/test_pts1.rb +140 -0
- data/test/unit/bio/appl/tmhmm/test_report.rb +126 -0
- data/test/unit/bio/data/test_aa.rb +90 -0
- data/test/unit/bio/data/test_codontable.rb +107 -0
- data/test/unit/bio/data/test_na.rb +80 -0
- data/test/unit/bio/db/embl/test_common.rb +117 -0
- data/test/unit/bio/db/embl/test_embl.rb +214 -0
- data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
- data/test/unit/bio/db/embl/test_sptr.rb +1775 -0
- data/test/unit/bio/db/embl/test_uniprot.rb +31 -0
- data/test/unit/bio/db/kegg/test_genes.rb +45 -0
- data/test/unit/bio/db/pdb/test_pdb.rb +152 -0
- data/test/unit/bio/db/test_aaindex.rb +197 -0
- data/test/unit/bio/db/test_fasta.rb +250 -0
- data/test/unit/bio/db/test_gff.rb +127 -0
- data/test/unit/bio/db/test_lasergene.rb +95 -0
- data/test/unit/bio/db/test_newick.rb +293 -0
- data/test/unit/bio/db/test_nexus.rb +360 -0
- data/test/unit/bio/db/test_prosite.rb +1437 -0
- data/test/unit/bio/db/test_rebase.rb +101 -0
- data/test/unit/bio/db/test_soft.rb +138 -0
- data/test/unit/bio/io/test_ddbjxml.rb +75 -0
- data/test/unit/bio/io/test_ensembl.rb +109 -0
- data/test/unit/bio/io/test_fastacmd.rb +42 -0
- data/test/unit/bio/io/test_flatfile.rb +237 -0
- data/test/unit/bio/io/test_soapwsdl.rb +32 -0
- data/test/unit/bio/sequence/test_aa.rb +103 -0
- data/test/unit/bio/sequence/test_common.rb +174 -0
- data/test/unit/bio/sequence/test_compat.rb +69 -0
- data/test/unit/bio/sequence/test_na.rb +330 -0
- data/test/unit/bio/shell/plugin/test_seq.rb +185 -0
- data/test/unit/bio/test_alignment.rb +1025 -0
- data/test/unit/bio/test_command.rb +288 -0
- data/test/unit/bio/test_db.rb +96 -0
- data/test/unit/bio/test_feature.rb +116 -0
- data/test/unit/bio/test_location.rb +39 -0
- data/test/unit/bio/test_map.rb +230 -0
- data/test/unit/bio/test_pathway.rb +473 -0
- data/test/unit/bio/test_reference.rb +224 -0
- data/test/unit/bio/test_sequence.rb +329 -0
- data/test/unit/bio/test_shell.rb +18 -0
- data/test/unit/bio/test_tree.rb +593 -0
- data/test/unit/bio/util/restriction_enzyme/analysis/test_calculated_cuts.rb +299 -0
- data/test/unit/bio/util/restriction_enzyme/analysis/test_cut_ranges.rb +103 -0
- data/test/unit/bio/util/restriction_enzyme/analysis/test_sequence_range.rb +240 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_aligned_strands.rb +101 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair.rb +75 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_location_pair_in_enzyme_notation.rb +73 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations.rb +53 -0
- data/test/unit/bio/util/restriction_enzyme/double_stranded/test_cut_locations_in_enzyme_notation.rb +104 -0
- data/test/unit/bio/util/restriction_enzyme/single_strand/test_cut_locations_in_enzyme_notation.rb +83 -0
- data/test/unit/bio/util/restriction_enzyme/test_analysis.rb +246 -0
- data/test/unit/bio/util/restriction_enzyme/test_cut_symbol.rb +44 -0
- data/test/unit/bio/util/restriction_enzyme/test_double_stranded.rb +115 -0
- data/test/unit/bio/util/restriction_enzyme/test_single_strand.rb +147 -0
- data/test/unit/bio/util/restriction_enzyme/test_single_strand_complement.rb +147 -0
- data/test/unit/bio/util/restriction_enzyme/test_string_formatting.rb +60 -0
- data/test/unit/bio/util/test_color_scheme.rb +33 -0
- data/test/unit/bio/util/test_contingency_table.rb +94 -0
- data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
- data/test/unit/bio/util/test_sirna.rb +245 -0
- metadata +479 -0
@@ -0,0 +1,334 @@
|
|
1
|
+
#
|
2
|
+
# = bio/appl/bl2seq/report.rb - bl2seq (BLAST 2 sequences) parser
|
3
|
+
#
|
4
|
+
# Copyright:: Copyright (C) 2005 GOTO Naohisa <ng@bioruby.org>
|
5
|
+
# License:: The Ruby License
|
6
|
+
#
|
7
|
+
# $Id: report.rb,v 1.8 2007/04/05 23:35:39 trevor Exp $
|
8
|
+
#
|
9
|
+
# Bio::Bl2seq::Report is a NCBI bl2seq (BLAST 2 sequences) output parser.
|
10
|
+
#
|
11
|
+
# = Acknowledgements
|
12
|
+
#
|
13
|
+
# Thanks to Tomoaki NISHIYAMA <tomoakin __at__ kenroku.kanazawa-u.ac.jp>
|
14
|
+
# for providing bl2seq parser patches based on
|
15
|
+
# lib/bio/appl/blast/format0.rb.
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'bio/appl/blast/format0'
|
19
|
+
|
20
|
+
module Bio
|
21
|
+
class Blast
|
22
|
+
|
23
|
+
class Bl2seq
|
24
|
+
|
25
|
+
# Bio::Bl2seq::Report is a NCBI bl2seq (BLAST 2 sequences) output parser.
|
26
|
+
# It inherits Bio::Blast::Default::Report.
|
27
|
+
# Most of its methods are the same as Bio::Blast::Default::Report,
|
28
|
+
# but it lacks many methods.
|
29
|
+
class Report < Bio::Blast::Default::Report
|
30
|
+
|
31
|
+
# Delimiter of each entry. Bio::FlatFile uses it.
|
32
|
+
# In Bio::Bl2seq::Report, it it nil (1 entry 1 file).
|
33
|
+
DELIMITER = RS = nil
|
34
|
+
|
35
|
+
undef format0_parse_header
|
36
|
+
undef program, version, version_number, version_date,
|
37
|
+
message, converged?, reference, db
|
38
|
+
|
39
|
+
# Splits headers.
|
40
|
+
def format0_split_headers(data)
|
41
|
+
@f0query = data.shift
|
42
|
+
end
|
43
|
+
private :format0_split_headers
|
44
|
+
|
45
|
+
# Splits the search results.
|
46
|
+
def format0_split_search(data)
|
47
|
+
iterations = []
|
48
|
+
while r = data[0] and /^\>/ =~ r
|
49
|
+
iterations << Iteration.new(data)
|
50
|
+
end
|
51
|
+
if iterations.size <= 0 then
|
52
|
+
iterations << Iteration.new(data)
|
53
|
+
end
|
54
|
+
iterations
|
55
|
+
end
|
56
|
+
private :format0_split_search
|
57
|
+
|
58
|
+
# Stores format0 database statistics.
|
59
|
+
# Internal use only. Users must not use the class.
|
60
|
+
class F0dbstat < Bio::Blast::Default::Report::F0dbstat #:nodoc:
|
61
|
+
# Returns number of sequences in database.
|
62
|
+
def db_num
|
63
|
+
unless defined?(@db_num)
|
64
|
+
parse_params
|
65
|
+
@db_num = @hash['Number of Sequences'].to_i
|
66
|
+
end
|
67
|
+
@db_num
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns number of letters in database.
|
71
|
+
def db_len
|
72
|
+
unless defined?(@db_len)
|
73
|
+
parse_params
|
74
|
+
@db_len = @hash['length of database'].to_i
|
75
|
+
end
|
76
|
+
@db_len
|
77
|
+
end
|
78
|
+
end #class F0dbstat
|
79
|
+
|
80
|
+
# Bio::Bl2seq::Report::Iteration stores information about
|
81
|
+
# a iteration.
|
82
|
+
# Normally, it may contain some Bio::Bl2seq::Report::Hit objects.
|
83
|
+
#
|
84
|
+
# Note that its main existance reason is to keep complatibility
|
85
|
+
# between Bio::Blast::Default::Report::* classes.
|
86
|
+
class Iteration < Bio::Blast::Default::Report::Iteration
|
87
|
+
# Creates a new Iteration object.
|
88
|
+
# It is designed to be called only internally from
|
89
|
+
# the Bio::Blast::Default::Report class.
|
90
|
+
# Users shall not use the method directly.
|
91
|
+
def initialize(data)
|
92
|
+
@f0stat = []
|
93
|
+
@f0dbstat = Bio::Blast::Default::Report::AlwaysNil.instance
|
94
|
+
@hits = []
|
95
|
+
@num = 1
|
96
|
+
while r = data[0] and /^\>/ =~ r
|
97
|
+
@hits << Hit.new(data)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Returns the hits of the iteration.
|
102
|
+
# It returns an array of Bio::Bl2seq::Report::Hit objects.
|
103
|
+
def hits; @hits; end
|
104
|
+
|
105
|
+
undef message, pattern_in_database,
|
106
|
+
pattern, pattern_positions, hits_found_again,
|
107
|
+
hits_newly_found, hits_for_pattern, parse_hitlist,
|
108
|
+
converged?
|
109
|
+
end #class Iteration
|
110
|
+
|
111
|
+
# Bio::Bl2seq::Report::Hit contains information about a hit.
|
112
|
+
# It may contain some Bio::Blast::Default::Report::HSP objects.
|
113
|
+
# All methods are the same as Bio::Blast::Default::Report::Hit class.
|
114
|
+
# Please refer to Bio::Blast::Default::Report::Hit.
|
115
|
+
class Hit < Bio::Blast::Default::Report::Hit
|
116
|
+
end #class Hit
|
117
|
+
|
118
|
+
# Bio::Bl2seq::Report::HSP holds information about the hsp
|
119
|
+
# (high-scoring segment pair).
|
120
|
+
# NOTE that the HSP class below is NOT used because
|
121
|
+
# Ruby's constants namespace are normally statically determined
|
122
|
+
# and HSP object is created in Bio::Blast::Default::Report::Hit class.
|
123
|
+
# Please refer to Bio::Blast::Default::Report::HSP.
|
124
|
+
class HSP < Bio::Blast::Default::Report::HSP
|
125
|
+
end #class HSP
|
126
|
+
|
127
|
+
end #class Report
|
128
|
+
end #class Bl2seq
|
129
|
+
|
130
|
+
end #class Blast
|
131
|
+
end #module Bio
|
132
|
+
|
133
|
+
######################################################################
|
134
|
+
|
135
|
+
if __FILE__ == $0
|
136
|
+
|
137
|
+
Bio::FlatFile.open(Bio::Blast::Bl2seq::Report, ARGF) do |ff|
|
138
|
+
ff.each do |rep|
|
139
|
+
|
140
|
+
print "# === Bio::Blast::Bl2seq::Report\n"
|
141
|
+
puts
|
142
|
+
#@#print " rep.program #=> "; p rep.program
|
143
|
+
#@#print " rep.version #=> "; p rep.version
|
144
|
+
#@#print " rep.reference #=> "; p rep.reference
|
145
|
+
#@#print " rep.db #=> "; p rep.db
|
146
|
+
#print " rep.query_id #=> "; p rep.query_id
|
147
|
+
print " rep.query_def #=> "; p rep.query_def
|
148
|
+
print " rep.query_len #=> "; p rep.query_len
|
149
|
+
#puts
|
150
|
+
#@#print " rep.version_number #=> "; p rep.version_number
|
151
|
+
#@#print " rep.version_date #=> "; p rep.version_date
|
152
|
+
puts
|
153
|
+
|
154
|
+
print "# === Parameters\n"
|
155
|
+
#puts
|
156
|
+
#print " rep.parameters #=> "; p rep.parameters
|
157
|
+
puts
|
158
|
+
print " rep.matrix #=> "; p rep.matrix
|
159
|
+
print " rep.expect #=> "; p rep.expect
|
160
|
+
#print " rep.inclusion #=> "; p rep.inclusion
|
161
|
+
print " rep.sc_match #=> "; p rep.sc_match
|
162
|
+
print " rep.sc_mismatch #=> "; p rep.sc_mismatch
|
163
|
+
print " rep.gap_open #=> "; p rep.gap_open
|
164
|
+
print " rep.gap_extend #=> "; p rep.gap_extend
|
165
|
+
#print " rep.filter #=> "; p rep.filter
|
166
|
+
#@#print " rep.pattern #=> "; p rep.pattern
|
167
|
+
#print " rep.entrez_query #=> "; p rep.entrez_query
|
168
|
+
#puts
|
169
|
+
#@#print " rep.pattern_positions #=> "; p rep.pattern_positions
|
170
|
+
puts
|
171
|
+
|
172
|
+
print "# === Statistics (last iteration's)\n"
|
173
|
+
#puts
|
174
|
+
#print " rep.statistics #=> "; p rep.statistics
|
175
|
+
puts
|
176
|
+
print " rep.db_num #=> "; p rep.db_num
|
177
|
+
print " rep.db_len #=> "; p rep.db_len
|
178
|
+
#print " rep.hsp_len #=> "; p rep.hsp_len
|
179
|
+
print " rep.eff_space #=> "; p rep.eff_space
|
180
|
+
print " rep.kappa #=> "; p rep.kappa
|
181
|
+
print " rep.lambda #=> "; p rep.lambda
|
182
|
+
print " rep.entropy #=> "; p rep.entropy
|
183
|
+
puts
|
184
|
+
print " rep.num_hits #=> "; p rep.num_hits
|
185
|
+
print " rep.gapped_kappa #=> "; p rep.gapped_kappa
|
186
|
+
print " rep.gapped_lambda #=> "; p rep.gapped_lambda
|
187
|
+
print " rep.gapped_entropy #=> "; p rep.gapped_entropy
|
188
|
+
print " rep.posted_date #=> "; p rep.posted_date
|
189
|
+
puts
|
190
|
+
|
191
|
+
#@#print "# === Message (last iteration's)\n"
|
192
|
+
#@#puts
|
193
|
+
#@#print " rep.message #=> "; p rep.message
|
194
|
+
#puts
|
195
|
+
#@#print " rep.converged? #=> "; p rep.converged?
|
196
|
+
#@#puts
|
197
|
+
|
198
|
+
print "# === Iterations\n"
|
199
|
+
puts
|
200
|
+
print " rep.itrerations.each do |itr|\n"
|
201
|
+
puts
|
202
|
+
|
203
|
+
rep.iterations.each do |itr|
|
204
|
+
|
205
|
+
print "# --- Bio::Blast::Bl2seq::Report::Iteration\n"
|
206
|
+
puts
|
207
|
+
|
208
|
+
print " itr.num #=> "; p itr.num
|
209
|
+
#print " itr.statistics #=> "; p itr.statistics
|
210
|
+
#@#print " itr.message #=> "; p itr.message
|
211
|
+
print " itr.hits.size #=> "; p itr.hits.size
|
212
|
+
#puts
|
213
|
+
#@#print " itr.hits_newly_found.size #=> "; p itr.hits_newly_found.size;
|
214
|
+
#@#print " itr.hits_found_again.size #=> "; p itr.hits_found_again.size;
|
215
|
+
#@#if itr.hits_for_pattern then
|
216
|
+
#@#itr.hits_for_pattern.each_with_index do |hp, hpi|
|
217
|
+
#@#print " itr.hits_for_pattern[#{hpi}].size #=> "; p hp.size;
|
218
|
+
#@#end
|
219
|
+
#@#end
|
220
|
+
#@#print " itr.converged? #=> "; p itr.converged?
|
221
|
+
puts
|
222
|
+
|
223
|
+
print " itr.hits.each do |hit|\n"
|
224
|
+
puts
|
225
|
+
|
226
|
+
itr.hits.each_with_index do |hit, i|
|
227
|
+
|
228
|
+
print "# --- Bio::Blast::Bl2seq::Default::Report::Hit"
|
229
|
+
print " ([#{i}])\n"
|
230
|
+
puts
|
231
|
+
|
232
|
+
#print " hit.num #=> "; p hit.num
|
233
|
+
#print " hit.hit_id #=> "; p hit.hit_id
|
234
|
+
print " hit.len #=> "; p hit.len
|
235
|
+
print " hit.definition #=> "; p hit.definition
|
236
|
+
#print " hit.accession #=> "; p hit.accession
|
237
|
+
#puts
|
238
|
+
print " hit.found_again? #=> "; p hit.found_again?
|
239
|
+
|
240
|
+
print " --- compatible/shortcut ---\n"
|
241
|
+
#print " hit.query_id #=> "; p hit.query_id
|
242
|
+
#print " hit.query_def #=> "; p hit.query_def
|
243
|
+
#print " hit.query_len #=> "; p hit.query_len
|
244
|
+
#print " hit.target_id #=> "; p hit.target_id
|
245
|
+
print " hit.target_def #=> "; p hit.target_def
|
246
|
+
print " hit.target_len #=> "; p hit.target_len
|
247
|
+
|
248
|
+
print " --- first HSP's values (shortcut) ---\n"
|
249
|
+
print " hit.evalue #=> "; p hit.evalue
|
250
|
+
print " hit.bit_score #=> "; p hit.bit_score
|
251
|
+
print " hit.identity #=> "; p hit.identity
|
252
|
+
#print " hit.overlap #=> "; p hit.overlap
|
253
|
+
|
254
|
+
print " hit.query_seq #=> "; p hit.query_seq
|
255
|
+
print " hit.midline #=> "; p hit.midline
|
256
|
+
print " hit.target_seq #=> "; p hit.target_seq
|
257
|
+
|
258
|
+
print " hit.query_start #=> "; p hit.query_start
|
259
|
+
print " hit.query_end #=> "; p hit.query_end
|
260
|
+
print " hit.target_start #=> "; p hit.target_start
|
261
|
+
print " hit.target_end #=> "; p hit.target_end
|
262
|
+
print " hit.lap_at #=> "; p hit.lap_at
|
263
|
+
print " --- first HSP's vaules (shortcut) ---\n"
|
264
|
+
print " --- compatible/shortcut ---\n"
|
265
|
+
|
266
|
+
puts
|
267
|
+
print " hit.hsps.size #=> "; p hit.hsps.size
|
268
|
+
if hit.hsps.size == 0 then
|
269
|
+
puts " (HSP not found: please see blastall's -b and -v options)"
|
270
|
+
puts
|
271
|
+
else
|
272
|
+
|
273
|
+
puts
|
274
|
+
print " hit.hsps.each do |hsp|\n"
|
275
|
+
puts
|
276
|
+
|
277
|
+
hit.hsps.each_with_index do |hsp, j|
|
278
|
+
|
279
|
+
print "# --- Bio::Blast::Default::Report::HSP (Bio::Blast::Bl2seq::Report::HSP)"
|
280
|
+
print " ([#{j}])\n"
|
281
|
+
puts
|
282
|
+
#print " hsp.num #=> "; p hsp.num
|
283
|
+
print " hsp.bit_score #=> "; p hsp.bit_score
|
284
|
+
print " hsp.score #=> "; p hsp.score
|
285
|
+
print " hsp.evalue #=> "; p hsp.evalue
|
286
|
+
print " hsp.identity #=> "; p hsp.identity
|
287
|
+
print " hsp.gaps #=> "; p hsp.gaps
|
288
|
+
print " hsp.positive #=> "; p hsp.positive
|
289
|
+
print " hsp.align_len #=> "; p hsp.align_len
|
290
|
+
#print " hsp.density #=> "; p hsp.density
|
291
|
+
|
292
|
+
print " hsp.query_frame #=> "; p hsp.query_frame
|
293
|
+
print " hsp.query_from #=> "; p hsp.query_from
|
294
|
+
print " hsp.query_to #=> "; p hsp.query_to
|
295
|
+
|
296
|
+
print " hsp.hit_frame #=> "; p hsp.hit_frame
|
297
|
+
print " hsp.hit_from #=> "; p hsp.hit_from
|
298
|
+
print " hsp.hit_to #=> "; p hsp.hit_to
|
299
|
+
|
300
|
+
#print " hsp.pattern_from#=> "; p hsp.pattern_from
|
301
|
+
#print " hsp.pattern_to #=> "; p hsp.pattern_to
|
302
|
+
|
303
|
+
print " hsp.qseq #=> "; p hsp.qseq
|
304
|
+
print " hsp.midline #=> "; p hsp.midline
|
305
|
+
print " hsp.hseq #=> "; p hsp.hseq
|
306
|
+
puts
|
307
|
+
print " hsp.percent_identity #=> "; p hsp.percent_identity
|
308
|
+
#print " hsp.mismatch_count #=> "; p hsp.mismatch_count
|
309
|
+
#
|
310
|
+
print " hsp.query_strand #=> "; p hsp.query_strand
|
311
|
+
print " hsp.hit_strand #=> "; p hsp.hit_strand
|
312
|
+
print " hsp.percent_positive #=> "; p hsp.percent_positive
|
313
|
+
print " hsp.percent_gaps #=> "; p hsp.percent_gaps
|
314
|
+
puts
|
315
|
+
|
316
|
+
end #each
|
317
|
+
end #if hit.hsps.size == 0
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end #ff.each
|
321
|
+
end #FlatFile.open
|
322
|
+
|
323
|
+
end #if __FILE__ == $0
|
324
|
+
|
325
|
+
######################################################################
|
326
|
+
|
327
|
+
=begin
|
328
|
+
|
329
|
+
= Bio::Blast::Bl2seq::Report
|
330
|
+
|
331
|
+
NCBI bl2seq (BLAST 2 sequences) output parser
|
332
|
+
|
333
|
+
=end
|
334
|
+
|
@@ -0,0 +1,351 @@
|
|
1
|
+
#
|
2
|
+
# = bio/appl/blast.rb - BLAST wrapper
|
3
|
+
#
|
4
|
+
# Copyright:: Copyright (C) 2001,2008 Mitsuteru C. Nakao <n@bioruby.org>
|
5
|
+
# Copyright:: Copyright (C) 2002,2003 Toshiaki Katayama <k@bioruby.org>
|
6
|
+
# Copyright:: Copyright (C) 2006 Jan Aerts <jan.aerts@bbsrc.ac.uk>
|
7
|
+
# License:: The Ruby License
|
8
|
+
#
|
9
|
+
# $Id: blast.rb,v 1.35 2008/04/15 13:54:39 ngoto Exp $
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'net/http'
|
13
|
+
require 'cgi' unless defined?(CGI)
|
14
|
+
require 'bio/command'
|
15
|
+
require 'shellwords'
|
16
|
+
|
17
|
+
module Bio
|
18
|
+
|
19
|
+
# == Description
|
20
|
+
#
|
21
|
+
# The Bio::Blast class contains methods for running local or remote BLAST
|
22
|
+
# searches, as well as for parsing of the output of such BLASTs (i.e. the
|
23
|
+
# BLAST reports). For more information on similarity searches and the BLAST
|
24
|
+
# program, see http://www.ncbi.nlm.nih.gov/Education/BLASTinfo/similarity.html.
|
25
|
+
#
|
26
|
+
# == Usage
|
27
|
+
#
|
28
|
+
# require 'bio'
|
29
|
+
#
|
30
|
+
# # To run an actual BLAST analysis:
|
31
|
+
# # 1. create a BLAST factory
|
32
|
+
# remote_blast_factory = Bio::Blast.remote('blastp', 'SWISS',
|
33
|
+
# '-e 0.0001', 'genomenet')
|
34
|
+
# #or:
|
35
|
+
# local_blast_factory = Bio::Blast.local('blastn','/path/to/db')
|
36
|
+
#
|
37
|
+
# # 2. run the actual BLAST by querying the factory
|
38
|
+
# report = remote_blast_factory.query(sequence_text)
|
39
|
+
#
|
40
|
+
# # Then, to parse the report, see Bio::Blast::Report
|
41
|
+
#
|
42
|
+
# === Available databases for Bio::Blast.remote
|
43
|
+
#
|
44
|
+
# ----------+-------+---------------------------------------------------
|
45
|
+
# program | query | db (supported in GenomeNet)
|
46
|
+
# ----------+-------+---------------------------------------------------
|
47
|
+
# blastp | AA | nr-aa, genes, vgenes.pep, swissprot, swissprot-upd,
|
48
|
+
# ----------+-------+ pir, prf, pdbstr
|
49
|
+
# blastx | NA |
|
50
|
+
# ----------+-------+---------------------------------------------------
|
51
|
+
# blastn | NA | nr-nt, genbank-nonst, gbnonst-upd, dbest, dbgss,
|
52
|
+
# ----------+-------+ htgs, dbsts, embl-nonst, embnonst-upd, epd,
|
53
|
+
# tblastn | AA | genes-nt, genome, vgenes.nuc
|
54
|
+
# ----------+-------+---------------------------------------------------
|
55
|
+
#
|
56
|
+
# == See also
|
57
|
+
#
|
58
|
+
# * Bio::Blast::Report
|
59
|
+
# * Bio::Blast::Report::Hit
|
60
|
+
# * Bio::Blast::Report::Hsp
|
61
|
+
#
|
62
|
+
# == References
|
63
|
+
#
|
64
|
+
# * http://www.ncbi.nlm.nih.gov/blast/
|
65
|
+
# * http://www.ncbi.nlm.nih.gov/Education/BLASTinfo/similarity.html
|
66
|
+
# * http://blast.genome.jp/ideas/ideas.html#blast
|
67
|
+
#
|
68
|
+
class Blast
|
69
|
+
|
70
|
+
autoload :Fastacmd, 'bio/io/fastacmd'
|
71
|
+
autoload :Report, 'bio/appl/blast/report'
|
72
|
+
autoload :Default, 'bio/appl/blast/format0'
|
73
|
+
autoload :WU, 'bio/appl/blast/wublast'
|
74
|
+
autoload :Bl2seq, 'bio/appl/bl2seq/report'
|
75
|
+
autoload :RPSBlast, 'bio/appl/blast/rpsblast'
|
76
|
+
|
77
|
+
# This is a shortcut for Bio::Blast.new:
|
78
|
+
# Bio::Blast.local(program, database, options)
|
79
|
+
# is equivalent to
|
80
|
+
# Bio::Blast.new(program, database, options, 'local')
|
81
|
+
# ---
|
82
|
+
# *Arguments*:
|
83
|
+
# * _program_ (required): 'blastn', 'blastp', 'blastx', 'tblastn' or 'tblastx'
|
84
|
+
# * _db_ (required): name of the local database
|
85
|
+
# * _options_: blastall options \
|
86
|
+
# (see http://www.genome.jp/dbget-bin/show_man?blast2)
|
87
|
+
# *Returns*:: Bio::Blast factory object
|
88
|
+
def self.local(program, db, option = '')
|
89
|
+
self.new(program, db, option, 'local')
|
90
|
+
end
|
91
|
+
|
92
|
+
# Bio::Blast.remote does exactly the same as Bio::Blast.new, but sets
|
93
|
+
# the remote server 'genomenet' as its default.
|
94
|
+
# ---
|
95
|
+
# *Arguments*:
|
96
|
+
# * _program_ (required): 'blastn', 'blastp', 'blastx', 'tblastn' or 'tblastx'
|
97
|
+
# * _db_ (required): name of the remote database
|
98
|
+
# * _options_: blastall options \
|
99
|
+
# (see http://www.genome.jp/dbget-bin/show_man?blast2)
|
100
|
+
# * _server_: server to use (DEFAULT = 'genomenet')
|
101
|
+
# *Returns*:: Bio::Blast factory object
|
102
|
+
def self.remote(program, db, option = '', server = 'genomenet')
|
103
|
+
self.new(program, db, option, server)
|
104
|
+
end
|
105
|
+
|
106
|
+
# the method Bio::Blast.report is moved from bio/appl/blast/report.rb.
|
107
|
+
# only for xml format
|
108
|
+
def self.reports(input, parser = nil)
|
109
|
+
ary = []
|
110
|
+
input.each("</BlastOutput>\n") do |xml|
|
111
|
+
xml.sub!(/[^<]*(<?)/, '\1') # skip before <?xml> tag
|
112
|
+
next if xml.empty? # skip trailing no hits
|
113
|
+
if block_given?
|
114
|
+
yield Report.new(xml, parser)
|
115
|
+
else
|
116
|
+
ary << Report.new(xml, parser)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
return ary
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
# Program name (_-p_ option for blastall): blastp, blastn, blastx, tblastn
|
124
|
+
# or tblastx
|
125
|
+
attr_accessor :program
|
126
|
+
|
127
|
+
# Database name (_-d_ option for blastall)
|
128
|
+
attr_accessor :db
|
129
|
+
|
130
|
+
# Options for blastall
|
131
|
+
attr_accessor :options
|
132
|
+
|
133
|
+
# Server to submit the BLASTs to
|
134
|
+
attr_accessor :server
|
135
|
+
|
136
|
+
# Full path for blastall. (default: 'blastall').
|
137
|
+
attr_accessor :blastall
|
138
|
+
|
139
|
+
# Substitution matrix for blastall -M
|
140
|
+
attr_accessor :matrix
|
141
|
+
|
142
|
+
# Filter option for blastall -F (T or F).
|
143
|
+
attr_accessor :filter
|
144
|
+
|
145
|
+
# Returns a String containing blast execution output in as is the Bio::Blast#format.
|
146
|
+
attr_reader :output
|
147
|
+
|
148
|
+
# Output report format for blastall -m
|
149
|
+
#
|
150
|
+
# 0, pairwise; 1; 2; 3; 4; 5; 6; 7, XML Blast outpu;, 8, tabular;
|
151
|
+
# 9, tabular with comment lines; 10, ASN text; 11, ASN binery [intege].
|
152
|
+
attr_reader :format
|
153
|
+
|
154
|
+
#
|
155
|
+
attr_writer :parser # to change :xmlparser, :rexml, :tab
|
156
|
+
|
157
|
+
|
158
|
+
# Creates a Bio::Blast factory object.
|
159
|
+
#
|
160
|
+
# To run any BLAST searches, a factory has to be created that describes a
|
161
|
+
# certain BLAST pipeline: the program to use, the database to search, any
|
162
|
+
# options and the server to use. E.g.
|
163
|
+
#
|
164
|
+
# blast_factory = Bio::Blast.new('blastn','dbsts', '-e 0.0001 -r 4', 'genomenet')
|
165
|
+
#
|
166
|
+
# ---
|
167
|
+
# *Arguments*:
|
168
|
+
# * _program_ (required): 'blastn', 'blastp', 'blastx', 'tblastn' or 'tblastx'
|
169
|
+
# * _db_ (required): name of the (local or remote) database
|
170
|
+
# * _options_: blastall options \
|
171
|
+
# (see http://www.genome.jp/dbget-bin/show_man?blast2)
|
172
|
+
# * _server_: server to use (e.g. 'genomenet'; DEFAULT = 'local')
|
173
|
+
# *Returns*:: Bio::Blast factory object
|
174
|
+
def initialize(program, db, opt = [], server = 'local')
|
175
|
+
@program = program
|
176
|
+
@db = db
|
177
|
+
@server = server
|
178
|
+
|
179
|
+
@blastall = 'blastall'
|
180
|
+
@matrix = nil
|
181
|
+
@filter = nil
|
182
|
+
|
183
|
+
@output = ''
|
184
|
+
@parser = nil
|
185
|
+
@format = 0
|
186
|
+
|
187
|
+
set_options(opt)
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
# This method submits a sequence to a BLAST factory, which performs the
|
192
|
+
# actual BLAST.
|
193
|
+
#
|
194
|
+
# fasta_sequences = Bio::FlatFile.open(Bio::FastaFormat, 'my_sequences.fa')
|
195
|
+
# report = blast_factory.query(fasta_sequences)
|
196
|
+
#
|
197
|
+
# ---
|
198
|
+
# *Arguments*:
|
199
|
+
# * _query_ (required): single- or multiple-FASTA formatted sequence(s)
|
200
|
+
# *Returns*:: a Bio::Blast::Report object
|
201
|
+
def query(query)
|
202
|
+
return self.send("exec_#{@server}", query.to_s)
|
203
|
+
end
|
204
|
+
|
205
|
+
# Returns options of blastall
|
206
|
+
def option
|
207
|
+
# backward compatibility
|
208
|
+
Bio::Command.make_command_line(@options)
|
209
|
+
end
|
210
|
+
|
211
|
+
# Set options for blastall
|
212
|
+
def option=(str)
|
213
|
+
# backward compatibility
|
214
|
+
@options = Shellwords.shellwords(str)
|
215
|
+
end
|
216
|
+
|
217
|
+
private
|
218
|
+
|
219
|
+
def set_options(opt = nil)
|
220
|
+
opt = @options unless opt
|
221
|
+
begin
|
222
|
+
a = opt.to_ary
|
223
|
+
rescue NameError #NoMethodError
|
224
|
+
# backward compatibility
|
225
|
+
a = Shellwords.shellwords(opt)
|
226
|
+
end
|
227
|
+
unless a.find { |x| /\A\-m/ =~ x.to_s } then
|
228
|
+
if defined?(XMLParser) or defined?(REXML)
|
229
|
+
@format = 7
|
230
|
+
else
|
231
|
+
@format = 8
|
232
|
+
end
|
233
|
+
else
|
234
|
+
@format = a[a.index('-m') + 1].to_i
|
235
|
+
end
|
236
|
+
@options = [ *a ]
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
def parse_result(data)
|
241
|
+
Report.new(data, @parser)
|
242
|
+
end
|
243
|
+
|
244
|
+
|
245
|
+
def make_command_line
|
246
|
+
set_options
|
247
|
+
cmd = [ @blastall, '-p', @program, '-d', @db ]
|
248
|
+
if @matrix
|
249
|
+
cmd.concat([ '-M', @matrix ])
|
250
|
+
i = @options.index('-M')
|
251
|
+
@options.delete_at(i)
|
252
|
+
@options.delete_at(i)
|
253
|
+
end
|
254
|
+
if @filter
|
255
|
+
cmd.concat([ '-F', @filter ])
|
256
|
+
i = @options.index('-F')
|
257
|
+
@options.delete_at(i)
|
258
|
+
@options.delete_at(i)
|
259
|
+
end
|
260
|
+
if @format
|
261
|
+
cmd.concat([ '-m', @format.to_s ])
|
262
|
+
i = @options.index('-m')
|
263
|
+
@options.delete_at(i)
|
264
|
+
@options.delete_at(i)
|
265
|
+
end
|
266
|
+
cmd.concat(@options) if @options
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
def exec_local(query)
|
271
|
+
cmd = make_command_line
|
272
|
+
report = nil
|
273
|
+
|
274
|
+
@output = Bio::Command.query_command(cmd, query)
|
275
|
+
report = parse_result(@output)
|
276
|
+
|
277
|
+
return report
|
278
|
+
end
|
279
|
+
|
280
|
+
|
281
|
+
def exec_genomenet_tab(query)
|
282
|
+
@format = 8
|
283
|
+
exec_genomenet(query)
|
284
|
+
end
|
285
|
+
|
286
|
+
|
287
|
+
def exec_genomenet(query)
|
288
|
+
host = "blast.genome.jp"
|
289
|
+
#path = "/sit-bin/nph-blast"
|
290
|
+
path = "/sit-bin/blast" #2005.08.12
|
291
|
+
|
292
|
+
matrix = @matrix ? @matrix : 'blosum62'
|
293
|
+
filter = @filter ? @filter : 'T'
|
294
|
+
|
295
|
+
opt = []
|
296
|
+
opt.concat([ '-m', @format.to_s ]) if @format
|
297
|
+
opt.concat(@options) if @options
|
298
|
+
|
299
|
+
form = {
|
300
|
+
'style' => 'raw',
|
301
|
+
'prog' => @program,
|
302
|
+
'dbname' => @db,
|
303
|
+
'sequence' => CGI.escape(query),
|
304
|
+
'other_param' => CGI.escape(Bio::Command.make_command_line_unix(opt)),
|
305
|
+
'matrix' => matrix,
|
306
|
+
'filter' => filter,
|
307
|
+
'V_value' => 500, # default value for GenomeNet
|
308
|
+
'B_value' => 250, # default value for GenomeNet
|
309
|
+
'alignment_view' => 0,
|
310
|
+
}
|
311
|
+
|
312
|
+
data = []
|
313
|
+
|
314
|
+
form.each do |k, v|
|
315
|
+
data.push("#{k}=#{v}") if v
|
316
|
+
end
|
317
|
+
|
318
|
+
report = nil
|
319
|
+
|
320
|
+
begin
|
321
|
+
http = Bio::Command.new_http(host)
|
322
|
+
http.open_timeout = 300
|
323
|
+
http.read_timeout = 600
|
324
|
+
result, = http.post(path, data.join('&'))
|
325
|
+
@output = result.body
|
326
|
+
# workaround 2005.08.12
|
327
|
+
if /\<A +HREF=\"(http\:\/\/blast\.genome\.jp(\/tmp\/[^\"]+))\"\>Show all result\<\/A\>/i =~ @output.to_s then
|
328
|
+
result, = http.get($2)
|
329
|
+
@output = result.body
|
330
|
+
txt = @output.to_s.split(/\<pre\>/)[1]
|
331
|
+
raise 'cannot understand response' unless txt
|
332
|
+
txt.sub!(/\<\/pre\>.*\z/m, '')
|
333
|
+
txt.sub!(/.*^ \-{20,}\s*/m, '')
|
334
|
+
@output = txt.gsub(/\<\;/, '<')
|
335
|
+
report = parse_result(@output)
|
336
|
+
else
|
337
|
+
raise 'cannot understand response'
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
return report
|
342
|
+
end
|
343
|
+
|
344
|
+
def exec_ncbi(query)
|
345
|
+
raise NotImplementedError
|
346
|
+
end
|
347
|
+
|
348
|
+
end # class Blast
|
349
|
+
|
350
|
+
end # module Bio
|
351
|
+
|