wwood-bioruby 1.2.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +205 -0
- data/README_DEV.rdoc +285 -0
- data/VERSION.yml +4 -0
- data/bin/bioruby +44 -0
- data/bin/br_biofetch.rb +47 -0
- data/bin/br_bioflat.rb +293 -0
- data/bin/br_biogetseq.rb +45 -0
- data/bin/br_pmfetch.rb +421 -0
- data/lib/bio.rb +306 -0
- data/lib/bio/alignment.rb +2518 -0
- data/lib/bio/appl/bl2seq/report.rb +334 -0
- data/lib/bio/appl/blast.rb +505 -0
- data/lib/bio/appl/blast/ddbj.rb +142 -0
- data/lib/bio/appl/blast/format0.rb +1438 -0
- data/lib/bio/appl/blast/format8.rb +83 -0
- data/lib/bio/appl/blast/genomenet.rb +263 -0
- data/lib/bio/appl/blast/ncbioptions.rb +220 -0
- data/lib/bio/appl/blast/remote.rb +105 -0
- data/lib/bio/appl/blast/report.rb +767 -0
- data/lib/bio/appl/blast/rexml.rb +144 -0
- data/lib/bio/appl/blast/rpsblast.rb +277 -0
- data/lib/bio/appl/blast/wublast.rb +635 -0
- data/lib/bio/appl/blast/xmlparser.rb +236 -0
- data/lib/bio/appl/blat/report.rb +530 -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 +235 -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/paml/baseml.rb +95 -0
- data/lib/bio/appl/paml/baseml/report.rb +32 -0
- data/lib/bio/appl/paml/codeml.rb +242 -0
- data/lib/bio/appl/paml/codeml/rates.rb +67 -0
- data/lib/bio/appl/paml/codeml/report.rb +67 -0
- data/lib/bio/appl/paml/common.rb +348 -0
- data/lib/bio/appl/paml/common_report.rb +38 -0
- data/lib/bio/appl/paml/yn00.rb +103 -0
- data/lib/bio/appl/paml/yn00/report.rb +32 -0
- data/lib/bio/appl/phylip/alignment.rb +133 -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 +542 -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 +231 -0
- data/lib/bio/command.rb +593 -0
- data/lib/bio/compat/features.rb +157 -0
- data/lib/bio/compat/references.rb +128 -0
- data/lib/bio/data/aa.rb +353 -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/biosql/biosql_to_biosequence.rb +67 -0
- data/lib/bio/db/biosql/sequence.rb +508 -0
- data/lib/bio/db/embl/common.rb +352 -0
- data/lib/bio/db/embl/embl.rb +500 -0
- data/lib/bio/db/embl/embl_to_biosequence.rb +85 -0
- data/lib/bio/db/embl/format_embl.rb +190 -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 +597 -0
- data/lib/bio/db/fasta.rb +410 -0
- data/lib/bio/db/fasta/defline.rb +532 -0
- data/lib/bio/db/fasta/fasta_to_biosequence.rb +63 -0
- data/lib/bio/db/fasta/format_fasta.rb +97 -0
- data/lib/bio/db/genbank/common.rb +307 -0
- data/lib/bio/db/genbank/ddbj.rb +22 -0
- data/lib/bio/db/genbank/format_genbank.rb +187 -0
- data/lib/bio/db/genbank/genbank.rb +250 -0
- data/lib/bio/db/genbank/genbank_to_biosequence.rb +86 -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 +1846 -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 +166 -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 +326 -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 +456 -0
- data/lib/bio/db/soft.rb +404 -0
- data/lib/bio/db/transfac.rb +375 -0
- data/lib/bio/db/url.rb +42 -0
- data/lib/bio/feature.rb +139 -0
- data/lib/bio/io/biosql/biodatabase.rb +64 -0
- data/lib/bio/io/biosql/bioentry.rb +29 -0
- data/lib/bio/io/biosql/bioentry_dbxref.rb +11 -0
- data/lib/bio/io/biosql/bioentry_path.rb +12 -0
- data/lib/bio/io/biosql/bioentry_qualifier_value.rb +10 -0
- data/lib/bio/io/biosql/bioentry_reference.rb +10 -0
- data/lib/bio/io/biosql/bioentry_relationship.rb +10 -0
- data/lib/bio/io/biosql/biosequence.rb +11 -0
- data/lib/bio/io/biosql/comment.rb +7 -0
- data/lib/bio/io/biosql/config/database.yml +20 -0
- data/lib/bio/io/biosql/dbxref.rb +13 -0
- data/lib/bio/io/biosql/dbxref_qualifier_value.rb +12 -0
- data/lib/bio/io/biosql/location.rb +32 -0
- data/lib/bio/io/biosql/location_qualifier_value.rb +11 -0
- data/lib/bio/io/biosql/ontology.rb +10 -0
- data/lib/bio/io/biosql/reference.rb +9 -0
- data/lib/bio/io/biosql/seqfeature.rb +32 -0
- data/lib/bio/io/biosql/seqfeature_dbxref.rb +11 -0
- data/lib/bio/io/biosql/seqfeature_path.rb +11 -0
- data/lib/bio/io/biosql/seqfeature_qualifier_value.rb +20 -0
- data/lib/bio/io/biosql/seqfeature_relationship.rb +11 -0
- data/lib/bio/io/biosql/taxon.rb +12 -0
- data/lib/bio/io/biosql/taxon_name.rb +9 -0
- data/lib/bio/io/biosql/term.rb +27 -0
- data/lib/bio/io/biosql/term_dbxref.rb +11 -0
- data/lib/bio/io/biosql/term_path.rb +12 -0
- data/lib/bio/io/biosql/term_relationship.rb +13 -0
- data/lib/bio/io/biosql/term_relationship_term.rb +11 -0
- data/lib/bio/io/biosql/term_synonym.rb +10 -0
- data/lib/bio/io/das.rb +461 -0
- data/lib/bio/io/dbget.rb +194 -0
- data/lib/bio/io/ddbjxml.rb +638 -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 +195 -0
- data/lib/bio/io/flatfile.rb +482 -0
- data/lib/bio/io/flatfile/autodetection.rb +545 -0
- data/lib/bio/io/flatfile/bdb.rb +253 -0
- data/lib/bio/io/flatfile/buffer.rb +237 -0
- data/lib/bio/io/flatfile/index.rb +1381 -0
- data/lib/bio/io/flatfile/indexer.rb +805 -0
- data/lib/bio/io/flatfile/splitter.rb +297 -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 +733 -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 +186 -0
- data/lib/bio/location.rb +867 -0
- data/lib/bio/map.rb +410 -0
- data/lib/bio/pathway.rb +960 -0
- data/lib/bio/reference.rb +602 -0
- data/lib/bio/sequence.rb +456 -0
- data/lib/bio/sequence/aa.rb +152 -0
- data/lib/bio/sequence/adapter.rb +108 -0
- data/lib/bio/sequence/common.rb +310 -0
- data/lib/bio/sequence/compat.rb +123 -0
- data/lib/bio/sequence/dblink.rb +54 -0
- data/lib/bio/sequence/format.rb +358 -0
- data/lib/bio/sequence/format_raw.rb +23 -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 +852 -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 +200 -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/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/blast/blastp-multi.m7 +188 -0
- data/test/data/command/echoarg2.bat +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/paml/codeml/control_file.txt +30 -0
- data/test/data/paml/codeml/output.txt +78 -0
- data/test/data/paml/codeml/rates +217 -0
- data/test/data/prosite/prosite.dat +2233 -0
- data/test/data/refseq/nm_126355.entret +64 -0
- data/test/data/rpsblast/misc.rpsblast +193 -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/appl/test_pts1.rb +115 -0
- data/test/functional/bio/io/test_ensembl.rb +229 -0
- data/test/functional/bio/io/test_soapwsdl.rb +52 -0
- data/test/functional/bio/sequence/test_output_embl.rb +51 -0
- data/test/functional/bio/test_command.rb +301 -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_ncbioptions.rb +112 -0
- data/test/unit/bio/appl/blast/test_report.rb +1135 -0
- data/test/unit/bio/appl/blast/test_rpsblast.rb +398 -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/paml/codeml/test_rates.rb +45 -0
- data/test/unit/bio/appl/paml/codeml/test_report.rb +45 -0
- data/test/unit/bio/appl/paml/test_codeml.rb +174 -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 +277 -0
- data/test/unit/bio/appl/test_fasta.rb +130 -0
- data/test/unit/bio/appl/test_psort.rb +57 -0
- data/test/unit/bio/appl/test_pts1.rb +77 -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_embl_to_bioseq.rb +203 -0
- data/test/unit/bio/db/embl/test_sptr.rb +1812 -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 +1190 -0
- data/test/unit/bio/db/test_lasergene.rb +95 -0
- data/test/unit/bio/db/test_medline.rb +127 -0
- data/test/unit/bio/db/test_newick.rb +293 -0
- data/test/unit/bio/db/test_nexus.rb +364 -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/db/test_url.rb +36 -0
- data/test/unit/bio/io/flatfile/test_autodetection.rb +375 -0
- data/test/unit/bio/io/flatfile/test_buffer.rb +251 -0
- data/test/unit/bio/io/flatfile/test_splitter.rb +369 -0
- data/test/unit/bio/io/test_ddbjxml.rb +80 -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 +505 -0
- data/test/unit/bio/io/test_soapwsdl.rb +32 -0
- data/test/unit/bio/sequence/test_aa.rb +115 -0
- data/test/unit/bio/sequence/test_common.rb +373 -0
- data/test/unit/bio/sequence/test_compat.rb +69 -0
- data/test/unit/bio/sequence/test_dblink.rb +58 -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 +349 -0
- data/test/unit/bio/test_db.rb +96 -0
- data/test/unit/bio/test_feature.rb +144 -0
- data/test/unit/bio/test_location.rb +599 -0
- data/test/unit/bio/test_map.rb +230 -0
- data/test/unit/bio/test_pathway.rb +499 -0
- data/test/unit/bio/test_reference.rb +252 -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 +543 -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,505 @@
|
|
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
|
+
# Copyright:: Copyright (C) 2008 Naohisa Goto <ng@bioruby.org>
|
8
|
+
# License:: The Ruby License
|
9
|
+
#
|
10
|
+
# $Id:$
|
11
|
+
#
|
12
|
+
|
13
|
+
require 'bio/command'
|
14
|
+
require 'shellwords'
|
15
|
+
require 'stringio'
|
16
|
+
require 'bio/io/flatfile'
|
17
|
+
|
18
|
+
module Bio
|
19
|
+
|
20
|
+
# == Description
|
21
|
+
#
|
22
|
+
# The Bio::Blast class contains methods for running local or remote BLAST
|
23
|
+
# searches, as well as for parsing of the output of such BLASTs (i.e. the
|
24
|
+
# BLAST reports). For more information on similarity searches and the BLAST
|
25
|
+
# program, see http://www.ncbi.nlm.nih.gov/Education/BLASTinfo/similarity.html.
|
26
|
+
#
|
27
|
+
# == Usage
|
28
|
+
#
|
29
|
+
# require 'bio'
|
30
|
+
#
|
31
|
+
# # To run an actual BLAST analysis:
|
32
|
+
# # 1. create a BLAST factory
|
33
|
+
# remote_blast_factory = Bio::Blast.remote('blastp', 'SWISS',
|
34
|
+
# '-e 0.0001', 'genomenet')
|
35
|
+
# #or:
|
36
|
+
# local_blast_factory = Bio::Blast.local('blastn','/path/to/db')
|
37
|
+
#
|
38
|
+
# # 2. run the actual BLAST by querying the factory
|
39
|
+
# report = remote_blast_factory.query(sequence_text)
|
40
|
+
#
|
41
|
+
# # Then, to parse the report, see Bio::Blast::Report
|
42
|
+
#
|
43
|
+
# == See also
|
44
|
+
#
|
45
|
+
# * Bio::Blast::Report
|
46
|
+
# * Bio::Blast::Report::Hit
|
47
|
+
# * Bio::Blast::Report::Hsp
|
48
|
+
#
|
49
|
+
# == References
|
50
|
+
#
|
51
|
+
# * http://www.ncbi.nlm.nih.gov/blast/
|
52
|
+
# * http://www.ncbi.nlm.nih.gov/Education/BLASTinfo/similarity.html
|
53
|
+
# * http://blast.genome.jp/ideas/ideas.html#blast
|
54
|
+
#
|
55
|
+
class Blast
|
56
|
+
|
57
|
+
autoload :Fastacmd, 'bio/io/fastacmd'
|
58
|
+
autoload :Report, 'bio/appl/blast/report'
|
59
|
+
autoload :Report_tab, 'bio/appl/blast/report'
|
60
|
+
autoload :Default, 'bio/appl/blast/format0'
|
61
|
+
autoload :WU, 'bio/appl/blast/wublast'
|
62
|
+
autoload :Bl2seq, 'bio/appl/bl2seq/report'
|
63
|
+
autoload :RPSBlast, 'bio/appl/blast/rpsblast'
|
64
|
+
autoload :NCBIOptions, 'bio/appl/blast/ncbioptions'
|
65
|
+
autoload :Remote, 'bio/appl/blast/remote'
|
66
|
+
|
67
|
+
# This is a shortcut for Bio::Blast.new:
|
68
|
+
# Bio::Blast.local(program, database, options)
|
69
|
+
# is equivalent to
|
70
|
+
# Bio::Blast.new(program, database, options, 'local')
|
71
|
+
# ---
|
72
|
+
# *Arguments*:
|
73
|
+
# * _program_ (required): 'blastn', 'blastp', 'blastx', 'tblastn' or 'tblastx'
|
74
|
+
# * _db_ (required): name of the local database
|
75
|
+
# * _options_: blastall options \
|
76
|
+
# (see http://www.genome.jp/dbget-bin/show_man?blast2)
|
77
|
+
# * _blastall_: full path to blastall program (e.g. "/opt/bin/blastall"; DEFAULT: "blastall")
|
78
|
+
# *Returns*:: Bio::Blast factory object
|
79
|
+
def self.local(program, db, options = '', blastall = nil)
|
80
|
+
f = self.new(program, db, options, 'local')
|
81
|
+
if blastall then
|
82
|
+
f.blastall = blastall
|
83
|
+
end
|
84
|
+
f
|
85
|
+
end
|
86
|
+
|
87
|
+
# Bio::Blast.remote does exactly the same as Bio::Blast.new, but sets
|
88
|
+
# the remote server 'genomenet' as its default.
|
89
|
+
# ---
|
90
|
+
# *Arguments*:
|
91
|
+
# * _program_ (required): 'blastn', 'blastp', 'blastx', 'tblastn' or 'tblastx'
|
92
|
+
# * _db_ (required): name of the remote database
|
93
|
+
# * _options_: blastall options \
|
94
|
+
# (see http://www.genome.jp/dbget-bin/show_man?blast2)
|
95
|
+
# * _server_: server to use (DEFAULT = 'genomenet')
|
96
|
+
# *Returns*:: Bio::Blast factory object
|
97
|
+
def self.remote(program, db, option = '', server = 'genomenet')
|
98
|
+
self.new(program, db, option, server)
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
# Bio::Blast.report parses given data,
|
103
|
+
# and returns an array of report
|
104
|
+
# (Bio::Blast::Report or Bio::Blast::Default::Report) objects,
|
105
|
+
# or yields each report object when a block is given.
|
106
|
+
#
|
107
|
+
# Supported formats: NCBI default (-m 0), XML (-m 7), tabular (-m 8).
|
108
|
+
#
|
109
|
+
# ---
|
110
|
+
# *Arguments*:
|
111
|
+
# * _input_ (required): input data
|
112
|
+
# * _parser_: type of parser. see Bio::Blast::Report.new
|
113
|
+
# *Returns*:: Undefiend when a block is given. Otherwise, an Array containing report (Bio::Blast::Report or Bio::Blast::Default::Report) objects.
|
114
|
+
def self.reports(input, parser = nil)
|
115
|
+
begin
|
116
|
+
istr = input.to_str
|
117
|
+
rescue NoMethodError
|
118
|
+
istr = nil
|
119
|
+
end
|
120
|
+
if istr then
|
121
|
+
input = StringIO.new(istr)
|
122
|
+
end
|
123
|
+
raise 'unsupported input data type' unless input.respond_to?(:gets)
|
124
|
+
|
125
|
+
# if proper parser is given, emulates old behavior.
|
126
|
+
case parser
|
127
|
+
when :xmlparser, :rexml
|
128
|
+
ff = Bio::FlatFile.new(Bio::Blast::Report, input)
|
129
|
+
if block_given? then
|
130
|
+
ff.each do |e|
|
131
|
+
yield e
|
132
|
+
end
|
133
|
+
return []
|
134
|
+
else
|
135
|
+
return ff.to_a
|
136
|
+
end
|
137
|
+
when :tab
|
138
|
+
istr = input.read unless istr
|
139
|
+
rep = Report.new(istr, parser)
|
140
|
+
if block_given? then
|
141
|
+
yield rep
|
142
|
+
return []
|
143
|
+
else
|
144
|
+
return [ rep ]
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# preparation of the new format autodetection rule if needed
|
149
|
+
if !defined?(@@reports_format_autodetection_rule) or
|
150
|
+
!@@reports_format_autodetection_rule then
|
151
|
+
regrule = Bio::FlatFile::AutoDetect::RuleRegexp
|
152
|
+
blastxml = regrule[ 'Bio::Blast::Report',
|
153
|
+
/\<\!DOCTYPE BlastOutput PUBLIC / ]
|
154
|
+
blast = regrule[ 'Bio::Blast::Default::Report',
|
155
|
+
/^BLAST.? +[\-\.\w]+ +\[[\-\.\w ]+\]/ ]
|
156
|
+
tblast = regrule[ 'Bio::Blast::Default::Report_TBlast',
|
157
|
+
/^TBLAST.? +[\-\.\w]+ +\[[\-\.\w ]+\]/ ]
|
158
|
+
tab = regrule[ 'Bio::Blast::Report_tab',
|
159
|
+
/^([^\t]*\t){11}[^\t]*$/ ]
|
160
|
+
auto = Bio::FlatFile::AutoDetect[ blastxml,
|
161
|
+
blast,
|
162
|
+
tblast,
|
163
|
+
tab
|
164
|
+
]
|
165
|
+
# sets priorities
|
166
|
+
blastxml.is_prior_to blast
|
167
|
+
blast.is_prior_to tblast
|
168
|
+
tblast.is_prior_to tab
|
169
|
+
# rehash
|
170
|
+
auto.rehash
|
171
|
+
@@report_format_autodetection_rule = auto
|
172
|
+
end
|
173
|
+
|
174
|
+
# Creates a FlatFile object with dummy class
|
175
|
+
ff = Bio::FlatFile.new(Object, input)
|
176
|
+
ff.dbclass = nil
|
177
|
+
|
178
|
+
# file format autodetection
|
179
|
+
3.times do
|
180
|
+
break if ff.eof? or
|
181
|
+
ff.autodetect(31, @@report_format_autodetection_rule)
|
182
|
+
end
|
183
|
+
# If format detection failed, assumed to be tabular (-m 8)
|
184
|
+
ff.dbclass = Bio::Blast::Report_tab unless ff.dbclass
|
185
|
+
|
186
|
+
if block_given? then
|
187
|
+
ff.each do |entry|
|
188
|
+
yield entry
|
189
|
+
end
|
190
|
+
ret = []
|
191
|
+
else
|
192
|
+
ret = ff.to_a
|
193
|
+
end
|
194
|
+
ret
|
195
|
+
end
|
196
|
+
|
197
|
+
#--
|
198
|
+
# the method Bio::Blast.reports is moved from bio/appl/blast/report.rb.
|
199
|
+
#++
|
200
|
+
|
201
|
+
# Note that this is the old implementation of Bio::Blast.reports.
|
202
|
+
# The aim of this method is keeping compatibility for older BLAST
|
203
|
+
# XML documents which might not be parsed by the new
|
204
|
+
# Bio::Blast.reports nor Bio::FlatFile.
|
205
|
+
# (Though we are not sure whether such documents exist or not.)
|
206
|
+
#
|
207
|
+
# Bio::Blast.reports_xml parses given data,
|
208
|
+
# and returns an array of Bio::Blast::Report objects, or
|
209
|
+
# yields each Bio::Blast::Report object when a block is given.
|
210
|
+
#
|
211
|
+
# It can be used only for XML format.
|
212
|
+
# For default (-m 0) format, consider using Bio::FlatFile, or
|
213
|
+
# Bio::Blast.reports.
|
214
|
+
#
|
215
|
+
# ---
|
216
|
+
# *Arguments*:
|
217
|
+
# * _input_ (required): input data
|
218
|
+
# * _parser_: type of parser. see Bio::Blast::Report.new
|
219
|
+
# *Returns*:: Undefiend when a block is given. Otherwise, an Array containing Bio::Blast::Report objects.
|
220
|
+
def self.reports_xml(input, parser = nil)
|
221
|
+
ary = []
|
222
|
+
input.each_line("</BlastOutput>\n") do |xml|
|
223
|
+
xml.sub!(/[^<]*(<?)/, '\1') # skip before <?xml> tag
|
224
|
+
next if xml.empty? # skip trailing no hits
|
225
|
+
rep = Report.new(xml, parser)
|
226
|
+
if rep.reports then
|
227
|
+
if block_given?
|
228
|
+
rep.reports.each { |r| yield r }
|
229
|
+
else
|
230
|
+
ary.concat rep.reports
|
231
|
+
end
|
232
|
+
else
|
233
|
+
if block_given?
|
234
|
+
yield rep
|
235
|
+
else
|
236
|
+
ary.push rep
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
return ary
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
# Program name (_-p_ option for blastall): blastp, blastn, blastx, tblastn
|
245
|
+
# or tblastx
|
246
|
+
attr_accessor :program
|
247
|
+
|
248
|
+
# Database name (_-d_ option for blastall)
|
249
|
+
attr_accessor :db
|
250
|
+
|
251
|
+
# Options for blastall
|
252
|
+
attr_reader :options
|
253
|
+
|
254
|
+
# Sets options for blastall
|
255
|
+
def options=(ary)
|
256
|
+
@options = set_options(ary)
|
257
|
+
end
|
258
|
+
|
259
|
+
# Server to submit the BLASTs to
|
260
|
+
attr_accessor :server
|
261
|
+
|
262
|
+
# Sets server to submit the BLASTs to.
|
263
|
+
# The exec_xxxx method should be defined in Bio::Blast or
|
264
|
+
# Bio::Blast::Remote::Xxxx class.
|
265
|
+
def server=(str)
|
266
|
+
@server = str
|
267
|
+
begin
|
268
|
+
m = Bio::Blast::Remote.const_get(@server.capitalize)
|
269
|
+
rescue NameError
|
270
|
+
m = nil
|
271
|
+
end
|
272
|
+
if m and !(self.is_a?(m)) then
|
273
|
+
# lazy include Bio::Blast::Remote::XXX module
|
274
|
+
self.class.class_eval { include m }
|
275
|
+
end
|
276
|
+
return @server
|
277
|
+
end
|
278
|
+
|
279
|
+
# Full path for blastall. (default: 'blastall').
|
280
|
+
attr_accessor :blastall
|
281
|
+
|
282
|
+
# Substitution matrix for blastall -M
|
283
|
+
attr_accessor :matrix
|
284
|
+
|
285
|
+
# Filter option for blastall -F (T or F).
|
286
|
+
attr_accessor :filter
|
287
|
+
|
288
|
+
# Returns a String containing blast execution output in as is the Bio::Blast#format.
|
289
|
+
attr_reader :output
|
290
|
+
|
291
|
+
# Output report format for blastall -m
|
292
|
+
#
|
293
|
+
# 0, pairwise; 1; 2; 3; 4; 5; 6; 7, XML Blast outpu;, 8, tabular;
|
294
|
+
# 9, tabular with comment lines; 10, ASN text; 11, ASN binery [intege].
|
295
|
+
attr_accessor :format
|
296
|
+
|
297
|
+
#
|
298
|
+
attr_writer :parser # to change :xmlparser, :rexml, :tab
|
299
|
+
|
300
|
+
|
301
|
+
# Creates a Bio::Blast factory object.
|
302
|
+
#
|
303
|
+
# To run any BLAST searches, a factory has to be created that describes a
|
304
|
+
# certain BLAST pipeline: the program to use, the database to search, any
|
305
|
+
# options and the server to use. E.g.
|
306
|
+
#
|
307
|
+
# blast_factory = Bio::Blast.new('blastn','dbsts', '-e 0.0001 -r 4', 'genomenet')
|
308
|
+
#
|
309
|
+
# ---
|
310
|
+
# *Arguments*:
|
311
|
+
# * _program_ (required): 'blastn', 'blastp', 'blastx', 'tblastn' or 'tblastx'
|
312
|
+
# * _db_ (required): name of the (local or remote) database
|
313
|
+
# * _options_: blastall options \
|
314
|
+
# (see http://www.genome.jp/dbget-bin/show_man?blast2)
|
315
|
+
# * _server_: server to use (e.g. 'genomenet'; DEFAULT = 'local')
|
316
|
+
# *Returns*:: Bio::Blast factory object
|
317
|
+
def initialize(program, db, opt = [], server = 'local')
|
318
|
+
@program = program
|
319
|
+
@db = db
|
320
|
+
|
321
|
+
@blastall = 'blastall'
|
322
|
+
@matrix = nil
|
323
|
+
@filter = nil
|
324
|
+
|
325
|
+
@output = ''
|
326
|
+
@parser = nil
|
327
|
+
@format = nil
|
328
|
+
|
329
|
+
@options = set_options(opt, program, db)
|
330
|
+
self.server = server
|
331
|
+
end
|
332
|
+
|
333
|
+
|
334
|
+
# This method submits a sequence to a BLAST factory, which performs the
|
335
|
+
# actual BLAST.
|
336
|
+
#
|
337
|
+
# # example 1
|
338
|
+
# seq = Bio::Sequence::NA.new('agggcattgccccggaagatcaagtcgtgctcctg')
|
339
|
+
# report = blast_factory.query(seq)
|
340
|
+
#
|
341
|
+
# # example 2
|
342
|
+
# str <<END_OF_FASTA
|
343
|
+
# >lcl|MySequence
|
344
|
+
# MPPSAISKISNSTTPQVQSSSAPNLTMLEGKGISVEKSFRVYSEEENQNQHKAKDSLGF
|
345
|
+
# KELEKDAIKNSKQDKKDHKNWLETLYDQAEQKWLQEPKKKLQDLIKNSGDNSRVILKDS
|
346
|
+
# END_OF_FASTA
|
347
|
+
# report = blast_factory.query(str)
|
348
|
+
#
|
349
|
+
# Bug note: When multi-FASTA is given and the format is 7 (XML) or 8 (tab),
|
350
|
+
# it should return an array of Bio::Blast::Report objects,
|
351
|
+
# but it returns a single Bio::Blast::Report object.
|
352
|
+
# This is a known bug and should be fixed in the future.
|
353
|
+
#
|
354
|
+
# ---
|
355
|
+
# *Arguments*:
|
356
|
+
# * _query_ (required): single- or multiple-FASTA formatted sequence(s)
|
357
|
+
# *Returns*:: a Bio::Blast::Report (or Bio::Blast::Default::Report) object when single query is given. When multiple sequences are given as the query, it returns an array of Bio::Blast::Report (or Bio::Blast::Default::Report) objects. If it can not parse result, nil will be returnd.
|
358
|
+
def query(query)
|
359
|
+
case query
|
360
|
+
when Bio::Sequence
|
361
|
+
query = query.output(:fasta)
|
362
|
+
when Bio::Sequence::NA, Bio::Sequence::AA, Bio::Sequence::Generic
|
363
|
+
query = query.to_fasta('query', 70)
|
364
|
+
else
|
365
|
+
query = query.to_s
|
366
|
+
end
|
367
|
+
|
368
|
+
@output = self.__send__("exec_#{@server}", query)
|
369
|
+
report = parse_result(@output)
|
370
|
+
return report
|
371
|
+
end
|
372
|
+
|
373
|
+
# Returns options of blastall
|
374
|
+
def option
|
375
|
+
# backward compatibility
|
376
|
+
Bio::Command.make_command_line(options)
|
377
|
+
end
|
378
|
+
|
379
|
+
# Set options for blastall
|
380
|
+
def option=(str)
|
381
|
+
# backward compatibility
|
382
|
+
self.options = Shellwords.shellwords(str)
|
383
|
+
end
|
384
|
+
|
385
|
+
private
|
386
|
+
|
387
|
+
def set_options(opt = nil, program = nil, db = nil)
|
388
|
+
opt = @options unless opt
|
389
|
+
|
390
|
+
# when opt is a String, splits to an array
|
391
|
+
begin
|
392
|
+
a = opt.to_ary
|
393
|
+
rescue NameError #NoMethodError
|
394
|
+
# backward compatibility
|
395
|
+
a = Shellwords.shellwords(opt)
|
396
|
+
end
|
397
|
+
ncbiopt = NCBIOptions.new(a)
|
398
|
+
|
399
|
+
if fmt = ncbiopt.get('-m') then
|
400
|
+
@format = fmt.to_i
|
401
|
+
else
|
402
|
+
Bio::Blast::Report #dummy to load XMLParser or REXML
|
403
|
+
if defined?(XMLParser) or defined?(REXML)
|
404
|
+
@format ||= 7
|
405
|
+
else
|
406
|
+
@format ||= 8
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
mtrx = ncbiopt.get('-M')
|
411
|
+
@matrix = mtrx if mtrx
|
412
|
+
fltr = ncbiopt.get('-F')
|
413
|
+
@filter = fltr if fltr
|
414
|
+
|
415
|
+
# special treatment for '-p'
|
416
|
+
if program then
|
417
|
+
@program = program
|
418
|
+
ncbiopt.delete('-p')
|
419
|
+
else
|
420
|
+
program = ncbiopt.get('-p')
|
421
|
+
@program = program if program
|
422
|
+
end
|
423
|
+
|
424
|
+
# special treatment for '-d'
|
425
|
+
if db then
|
426
|
+
@db = db
|
427
|
+
ncbiopt.delete('-d')
|
428
|
+
else
|
429
|
+
db = ncbiopt.get('-d')
|
430
|
+
@db = db if db
|
431
|
+
end
|
432
|
+
|
433
|
+
# returns an array of string containing options
|
434
|
+
return ncbiopt.options
|
435
|
+
end
|
436
|
+
|
437
|
+
# parses result
|
438
|
+
def parse_result(str)
|
439
|
+
if @format.to_i == 0 then
|
440
|
+
ary = Bio::FlatFile.open(Bio::Blast::Default::Report,
|
441
|
+
StringIO.new(str)) { |ff| ff.to_a }
|
442
|
+
case ary.size
|
443
|
+
when 0
|
444
|
+
return nil
|
445
|
+
when 1
|
446
|
+
return ary[0]
|
447
|
+
else
|
448
|
+
return ary
|
449
|
+
end
|
450
|
+
else
|
451
|
+
Report.new(str, @parser)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
# returns an array containing NCBI BLAST options
|
456
|
+
def make_command_line_options
|
457
|
+
set_options
|
458
|
+
cmd = []
|
459
|
+
if @program
|
460
|
+
cmd.concat([ '-p', @program ])
|
461
|
+
end
|
462
|
+
if @db
|
463
|
+
cmd.concat([ '-d', @db ])
|
464
|
+
end
|
465
|
+
if @format
|
466
|
+
cmd.concat([ '-m', @format.to_s ])
|
467
|
+
end
|
468
|
+
if @matrix
|
469
|
+
cmd.concat([ '-M', @matrix ])
|
470
|
+
end
|
471
|
+
if @filter
|
472
|
+
cmd.concat([ '-F', @filter ])
|
473
|
+
end
|
474
|
+
ncbiopts = NCBIOptions.new(@options)
|
475
|
+
ncbiopts.make_command_line_options(cmd)
|
476
|
+
end
|
477
|
+
|
478
|
+
# makes command line.
|
479
|
+
def make_command_line
|
480
|
+
cmd = make_command_line_options
|
481
|
+
cmd.unshift @blastall
|
482
|
+
cmd
|
483
|
+
end
|
484
|
+
|
485
|
+
# Local execution of blastall
|
486
|
+
def exec_local(query)
|
487
|
+
cmd = make_command_line
|
488
|
+
@output = Bio::Command.query_command(cmd, query)
|
489
|
+
return @output
|
490
|
+
end
|
491
|
+
|
492
|
+
# This method is obsolete.
|
493
|
+
#
|
494
|
+
# Runs genomenet with '-m 8' option.
|
495
|
+
# Note that the format option is overwritten.
|
496
|
+
def exec_genomenet_tab(query)
|
497
|
+
warn "Bio::Blast#server=\"genomenet_tab\" is deprecated."
|
498
|
+
@format = 8
|
499
|
+
exec_genomenet(query)
|
500
|
+
end
|
501
|
+
|
502
|
+
end # class Blast
|
503
|
+
|
504
|
+
end # module Bio
|
505
|
+
|