bio 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/bioruby +14 -122
- data/bin/br_biofetch.rb +2 -2
- data/bin/br_bioflat.rb +2 -2
- data/bin/br_biogetseq.rb +2 -2
- data/bin/br_pmfetch.rb +3 -3
- data/doc/Changes-0.7.rd +77 -0
- data/doc/KEGG_API.rd +523 -232
- data/doc/KEGG_API.rd.ja +529 -207
- data/doc/Tutorial.rd +48 -11
- data/lib/bio.rb +59 -6
- data/lib/bio/alignment.rb +713 -103
- data/lib/bio/appl/bl2seq/report.rb +2 -18
- data/lib/bio/appl/blast.rb +108 -91
- data/lib/bio/appl/blast/format0.rb +33 -18
- data/lib/bio/appl/blast/format8.rb +6 -20
- data/lib/bio/appl/blast/report.rb +293 -429
- data/lib/bio/appl/blast/rexml.rb +8 -22
- data/lib/bio/appl/blast/wublast.rb +21 -12
- data/lib/bio/appl/blast/xmlparser.rb +180 -183
- data/lib/bio/appl/blat/report.rb +127 -30
- data/lib/bio/appl/clustalw.rb +87 -59
- data/lib/bio/appl/clustalw/report.rb +20 -22
- data/lib/bio/appl/emboss.rb +113 -20
- data/lib/bio/appl/fasta.rb +173 -198
- data/lib/bio/appl/fasta/format10.rb +244 -347
- 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 +5 -23
- data/lib/bio/appl/hmmer.rb +8 -45
- data/lib/bio/appl/hmmer/report.rb +2 -20
- data/lib/bio/appl/iprscan/report.rb +374 -0
- data/lib/bio/appl/mafft.rb +87 -50
- data/lib/bio/appl/mafft/report.rb +151 -44
- 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 +89 -96
- data/lib/bio/appl/psort/report.rb +6 -22
- data/lib/bio/appl/pts1.rb +263 -0
- data/lib/bio/appl/sim4.rb +26 -36
- data/lib/bio/appl/sim4/report.rb +2 -18
- data/lib/bio/appl/sosui/report.rb +5 -20
- data/lib/bio/appl/spidey/report.rb +2 -2
- data/lib/bio/appl/targetp/report.rb +4 -20
- data/lib/bio/appl/tcoffee.rb +55 -0
- data/lib/bio/appl/tmhmm/report.rb +4 -20
- data/lib/bio/command.rb +235 -64
- data/lib/bio/data/aa.rb +21 -26
- data/lib/bio/data/codontable.rb +2 -20
- data/lib/bio/data/na.rb +19 -4
- data/lib/bio/db.rb +27 -12
- data/lib/bio/db/aaindex.rb +2 -20
- data/lib/bio/db/embl/common.rb +4 -21
- data/lib/bio/db/embl/embl.rb +33 -85
- data/lib/bio/db/embl/sptr.rb +612 -302
- data/lib/bio/db/embl/swissprot.rb +10 -29
- data/lib/bio/db/embl/trembl.rb +10 -29
- data/lib/bio/db/embl/uniprot.rb +10 -29
- data/lib/bio/db/fantom.rb +15 -20
- data/lib/bio/db/fasta.rb +3 -3
- data/lib/bio/db/genbank/common.rb +37 -46
- data/lib/bio/db/genbank/ddbj.rb +6 -18
- data/lib/bio/db/genbank/genbank.rb +47 -186
- data/lib/bio/db/genbank/genpept.rb +4 -17
- data/lib/bio/db/genbank/refseq.rb +4 -17
- data/lib/bio/db/gff.rb +103 -35
- data/lib/bio/db/go.rb +4 -20
- data/lib/bio/db/kegg/brite.rb +26 -36
- data/lib/bio/db/kegg/compound.rb +81 -85
- data/lib/bio/db/kegg/drug.rb +98 -0
- data/lib/bio/db/kegg/enzyme.rb +133 -110
- data/lib/bio/db/kegg/expression.rb +2 -20
- data/lib/bio/db/kegg/genes.rb +208 -238
- data/lib/bio/db/kegg/genome.rb +164 -285
- data/lib/bio/db/kegg/glycan.rb +114 -157
- data/lib/bio/db/kegg/keggtab.rb +242 -303
- data/lib/bio/db/kegg/kgml.rb +117 -160
- data/lib/bio/db/kegg/orthology.rb +112 -0
- data/lib/bio/db/kegg/reaction.rb +54 -69
- data/lib/bio/db/kegg/taxonomy.rb +331 -0
- data/lib/bio/db/lasergene.rb +209 -0
- data/lib/bio/db/litdb.rb +3 -27
- data/lib/bio/db/medline.rb +228 -249
- data/lib/bio/db/nbrf.rb +3 -3
- data/lib/bio/db/newick.rb +510 -0
- data/lib/bio/db/nexus.rb +1854 -0
- data/lib/bio/db/pdb.rb +5 -17
- data/lib/bio/db/pdb/atom.rb +2 -18
- data/lib/bio/db/pdb/chain.rb +2 -18
- data/lib/bio/db/pdb/chemicalcomponent.rb +2 -18
- data/lib/bio/db/pdb/model.rb +2 -18
- data/lib/bio/db/pdb/pdb.rb +73 -34
- data/lib/bio/db/pdb/residue.rb +4 -20
- data/lib/bio/db/pdb/utils.rb +2 -18
- data/lib/bio/db/prosite.rb +403 -422
- data/lib/bio/db/rebase.rb +84 -40
- data/lib/bio/db/soft.rb +404 -0
- data/lib/bio/db/transfac.rb +5 -17
- data/lib/bio/feature.rb +106 -52
- data/lib/bio/io/das.rb +32 -42
- data/lib/bio/io/dbget.rb +2 -20
- data/lib/bio/io/ddbjxml.rb +77 -138
- data/lib/bio/io/ebisoap.rb +158 -0
- data/lib/bio/io/ensembl.rb +229 -0
- data/lib/bio/io/fastacmd.rb +89 -82
- data/lib/bio/io/fetch.rb +163 -96
- data/lib/bio/io/flatfile.rb +170 -73
- data/lib/bio/io/flatfile/bdb.rb +3 -16
- data/lib/bio/io/flatfile/index.rb +2 -2
- data/lib/bio/io/flatfile/indexer.rb +3 -2
- data/lib/bio/io/higet.rb +12 -31
- data/lib/bio/io/keggapi.rb +210 -269
- data/lib/bio/io/ncbisoap.rb +155 -0
- data/lib/bio/io/pubmed.rb +169 -147
- data/lib/bio/io/registry.rb +4 -20
- data/lib/bio/io/soapwsdl.rb +43 -38
- data/lib/bio/io/sql.rb +242 -305
- data/lib/bio/location.rb +407 -285
- data/lib/bio/map.rb +410 -0
- data/lib/bio/pathway.rb +558 -695
- data/lib/bio/reference.rb +272 -75
- data/lib/bio/sequence.rb +255 -13
- data/lib/bio/sequence/aa.rb +71 -10
- data/lib/bio/sequence/common.rb +187 -33
- data/lib/bio/sequence/compat.rb +59 -4
- data/lib/bio/sequence/format.rb +54 -7
- data/lib/bio/sequence/generic.rb +3 -3
- data/lib/bio/sequence/na.rb +328 -26
- data/lib/bio/shell.rb +11 -4
- data/lib/bio/shell/core.rb +221 -160
- data/lib/bio/shell/demo.rb +18 -15
- data/lib/bio/shell/interface.rb +14 -12
- data/lib/bio/shell/irb.rb +95 -0
- data/lib/bio/shell/object.rb +45 -26
- data/lib/bio/shell/plugin/blast.rb +42 -0
- data/lib/bio/shell/plugin/codon.rb +22 -14
- data/lib/bio/shell/plugin/das.rb +58 -0
- data/lib/bio/shell/plugin/emboss.rb +2 -2
- data/lib/bio/shell/plugin/entry.rb +22 -11
- data/lib/bio/shell/plugin/flatfile.rb +2 -2
- data/lib/bio/shell/plugin/keggapi.rb +13 -6
- data/lib/bio/shell/plugin/midi.rb +4 -4
- data/lib/bio/shell/plugin/obda.rb +2 -2
- data/lib/bio/shell/plugin/psort.rb +56 -0
- data/lib/bio/shell/plugin/seq.rb +35 -8
- data/lib/bio/shell/plugin/soap.rb +87 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/bioruby_generator.rb +29 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_classes.rhtml +4 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_log.rhtml +27 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_methods.rhtml +11 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_modules.rhtml +4 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/_variables.rhtml +7 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-bg.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-console.png +0 -0
- data/lib/bio/shell/rails/{public/images/icon.png → vendor/plugins/generators/bioruby/templates/bioruby-gem.png} +0 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby-link.gif +0 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.css +369 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby.rhtml +47 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_controller.rb +144 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/bioruby_helper.rb +47 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/commands.rhtml +8 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/history.rhtml +10 -0
- data/lib/bio/shell/rails/vendor/plugins/generators/bioruby/templates/index.rhtml +22 -0
- data/lib/bio/shell/script.rb +25 -0
- data/lib/bio/shell/setup.rb +109 -0
- data/lib/bio/shell/web.rb +70 -58
- data/lib/bio/tree.rb +850 -0
- data/lib/bio/util/color_scheme.rb +84 -107
- data/lib/bio/util/color_scheme/buried.rb +5 -24
- data/lib/bio/util/color_scheme/helix.rb +5 -24
- data/lib/bio/util/color_scheme/hydropathy.rb +5 -24
- data/lib/bio/util/color_scheme/nucleotide.rb +5 -24
- data/lib/bio/util/color_scheme/strand.rb +5 -24
- data/lib/bio/util/color_scheme/taylor.rb +5 -24
- data/lib/bio/util/color_scheme/turn.rb +5 -24
- data/lib/bio/util/color_scheme/zappo.rb +5 -24
- data/lib/bio/util/contingency_table.rb +70 -43
- 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 +4 -22
- data/sample/color_scheme_na.rb +4 -12
- data/sample/enzymes.rb +78 -0
- data/sample/goslim.rb +5 -13
- data/sample/psortplot_html.rb +4 -12
- data/test/data/blast/2.2.15.blastp.m7 +876 -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/iprscan/merged.raw +32 -0
- data/test/data/iprscan/merged.txt +74 -0
- data/test/data/soft/GDS100_partial.soft +92 -0
- data/test/data/soft/GSE3457_family_partial.soft +874 -0
- data/test/functional/bio/io/test_ensembl.rb +103 -0
- data/test/functional/bio/io/test_soapwsdl.rb +5 -17
- data/test/unit/bio/appl/bl2seq/test_report.rb +2 -2
- data/test/unit/bio/appl/blast/test_report.rb +3 -16
- data/test/unit/bio/appl/blast/test_xmlparser.rb +4 -16
- data/test/unit/bio/appl/genscan/test_report.rb +3 -16
- data/test/unit/bio/appl/hmmer/test_report.rb +3 -16
- 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 +3 -16
- data/test/unit/bio/appl/targetp/test_report.rb +3 -16
- data/test/unit/bio/appl/test_blast.rb +3 -16
- data/test/unit/bio/appl/test_fasta.rb +4 -16
- data/test/unit/bio/appl/test_pts1.rb +140 -0
- data/test/unit/bio/appl/tmhmm/test_report.rb +3 -16
- data/test/unit/bio/data/test_aa.rb +4 -17
- data/test/unit/bio/data/test_codontable.rb +3 -16
- data/test/unit/bio/data/test_na.rb +3 -3
- data/test/unit/bio/db/embl/test_common.rb +3 -16
- data/test/unit/bio/db/embl/test_embl.rb +3 -16
- data/test/unit/bio/db/embl/test_embl_rel89.rb +219 -0
- data/test/unit/bio/db/embl/test_sptr.rb +1548 -41
- data/test/unit/bio/db/embl/test_uniprot.rb +3 -16
- data/test/unit/bio/db/kegg/test_genes.rb +3 -16
- data/test/unit/bio/db/pdb/test_pdb.rb +7 -24
- data/test/unit/bio/db/test_aaindex.rb +2 -2
- data/test/unit/bio/db/test_fasta.rb +3 -16
- data/test/unit/bio/db/test_gff.rb +3 -16
- data/test/unit/bio/db/test_lasergene.rb +95 -0
- data/test/unit/bio/db/test_newick.rb +56 -0
- data/test/unit/bio/db/test_nexus.rb +360 -0
- data/test/unit/bio/db/test_prosite.rb +5 -18
- data/test/unit/bio/db/test_rebase.rb +11 -25
- data/test/unit/bio/db/test_soft.rb +138 -0
- data/test/unit/bio/io/test_ddbjxml.rb +5 -17
- data/test/unit/bio/io/test_ensembl.rb +109 -0
- data/test/unit/bio/io/test_fastacmd.rb +3 -16
- data/test/unit/bio/io/test_flatfile.rb +237 -0
- data/test/unit/bio/io/test_soapwsdl.rb +4 -17
- data/test/unit/bio/sequence/test_aa.rb +3 -3
- data/test/unit/bio/sequence/test_common.rb +3 -16
- data/test/unit/bio/sequence/test_compat.rb +3 -16
- data/test/unit/bio/sequence/test_na.rb +29 -3
- data/test/unit/bio/shell/plugin/test_seq.rb +8 -8
- data/test/unit/bio/test_alignment.rb +16 -27
- data/test/unit/bio/test_command.rb +242 -25
- data/test/unit/bio/test_db.rb +3 -16
- data/test/unit/bio/test_feature.rb +4 -16
- data/test/unit/bio/test_location.rb +4 -16
- data/test/unit/bio/test_map.rb +230 -0
- data/test/unit/bio/test_pathway.rb +4 -16
- data/test/unit/bio/test_reference.rb +2 -2
- data/test/unit/bio/test_sequence.rb +7 -19
- data/test/unit/bio/test_shell.rb +3 -16
- 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 +100 -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 +6 -18
- data/test/unit/bio/util/test_contingency_table.rb +6 -18
- data/test/unit/bio/util/test_restriction_enzyme.rb +42 -0
- data/test/unit/bio/util/test_sirna.rb +3 -16
- metadata +228 -169
- data/doc/BioRuby.rd.ja +0 -225
- data/doc/Design.rd.ja +0 -341
- data/doc/TODO.rd.ja +0 -138
- data/lib/bio/appl/fasta/format6.rb +0 -37
- data/lib/bio/db/kegg/cell.rb +0 -88
- data/lib/bio/db/kegg/ko.rb +0 -178
- data/lib/bio/shell/rails/Rakefile +0 -10
- data/lib/bio/shell/rails/app/controllers/application.rb +0 -4
- data/lib/bio/shell/rails/app/controllers/shell_controller.rb +0 -94
- data/lib/bio/shell/rails/app/helpers/application_helper.rb +0 -3
- data/lib/bio/shell/rails/app/models/shell_connection.rb +0 -30
- data/lib/bio/shell/rails/app/views/layouts/shell.rhtml +0 -37
- data/lib/bio/shell/rails/app/views/shell/history.rhtml +0 -5
- data/lib/bio/shell/rails/app/views/shell/index.rhtml +0 -2
- data/lib/bio/shell/rails/app/views/shell/show.rhtml +0 -13
- data/lib/bio/shell/rails/config/boot.rb +0 -19
- data/lib/bio/shell/rails/config/database.yml +0 -85
- data/lib/bio/shell/rails/config/environment.rb +0 -53
- data/lib/bio/shell/rails/config/environments/development.rb +0 -19
- data/lib/bio/shell/rails/config/environments/production.rb +0 -19
- data/lib/bio/shell/rails/config/environments/test.rb +0 -19
- data/lib/bio/shell/rails/config/routes.rb +0 -19
- data/lib/bio/shell/rails/doc/README_FOR_APP +0 -2
- data/lib/bio/shell/rails/public/404.html +0 -8
- data/lib/bio/shell/rails/public/500.html +0 -8
- data/lib/bio/shell/rails/public/dispatch.cgi +0 -10
- data/lib/bio/shell/rails/public/dispatch.fcgi +0 -24
- data/lib/bio/shell/rails/public/dispatch.rb +0 -10
- data/lib/bio/shell/rails/public/favicon.ico +0 -0
- data/lib/bio/shell/rails/public/images/rails.png +0 -0
- data/lib/bio/shell/rails/public/index.html +0 -277
- data/lib/bio/shell/rails/public/javascripts/controls.js +0 -750
- data/lib/bio/shell/rails/public/javascripts/dragdrop.js +0 -584
- data/lib/bio/shell/rails/public/javascripts/effects.js +0 -854
- data/lib/bio/shell/rails/public/javascripts/prototype.js +0 -1785
- data/lib/bio/shell/rails/public/robots.txt +0 -1
- data/lib/bio/shell/rails/public/stylesheets/main.css +0 -187
- data/lib/bio/shell/rails/script/about +0 -3
- data/lib/bio/shell/rails/script/breakpointer +0 -3
- data/lib/bio/shell/rails/script/console +0 -3
- data/lib/bio/shell/rails/script/destroy +0 -3
- data/lib/bio/shell/rails/script/generate +0 -3
- data/lib/bio/shell/rails/script/performance/benchmarker +0 -3
- data/lib/bio/shell/rails/script/performance/profiler +0 -3
- data/lib/bio/shell/rails/script/plugin +0 -3
- data/lib/bio/shell/rails/script/process/reaper +0 -3
- data/lib/bio/shell/rails/script/process/spawner +0 -3
- data/lib/bio/shell/rails/script/process/spinner +0 -3
- data/lib/bio/shell/rails/script/runner +0 -3
- data/lib/bio/shell/rails/script/server +0 -42
- data/lib/bio/shell/rails/test/test_helper.rb +0 -28
data/lib/bio/shell.rb
CHANGED
|
@@ -3,22 +3,26 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Copyright:: Copyright (C) 2005, 2006
|
|
5
5
|
# Toshiaki Katayama <k@bioruby.org>
|
|
6
|
-
# License
|
|
6
|
+
# License:: The Ruby License
|
|
7
7
|
#
|
|
8
|
-
# $Id: shell.rb,v 1.
|
|
8
|
+
# $Id: shell.rb,v 1.20 2007/07/09 11:17:09 k Exp $
|
|
9
9
|
#
|
|
10
10
|
|
|
11
11
|
require 'bio'
|
|
12
12
|
require 'yaml'
|
|
13
13
|
require 'open-uri'
|
|
14
|
+
require 'fileutils'
|
|
14
15
|
require 'pp'
|
|
15
16
|
|
|
16
17
|
module Bio::Shell
|
|
17
18
|
|
|
19
|
+
require 'bio/shell/setup'
|
|
20
|
+
require 'bio/shell/irb'
|
|
21
|
+
require 'bio/shell/web'
|
|
22
|
+
require 'bio/shell/script'
|
|
18
23
|
require 'bio/shell/core'
|
|
19
24
|
require 'bio/shell/interface'
|
|
20
25
|
require 'bio/shell/object'
|
|
21
|
-
require 'bio/shell/web'
|
|
22
26
|
require 'bio/shell/demo'
|
|
23
27
|
require 'bio/shell/plugin/entry'
|
|
24
28
|
require 'bio/shell/plugin/seq'
|
|
@@ -26,11 +30,14 @@ module Bio::Shell
|
|
|
26
30
|
require 'bio/shell/plugin/codon'
|
|
27
31
|
require 'bio/shell/plugin/flatfile'
|
|
28
32
|
require 'bio/shell/plugin/obda'
|
|
33
|
+
require 'bio/shell/plugin/das'
|
|
29
34
|
require 'bio/shell/plugin/keggapi'
|
|
35
|
+
require 'bio/shell/plugin/soap'
|
|
30
36
|
require 'bio/shell/plugin/emboss'
|
|
37
|
+
require 'bio/shell/plugin/blast'
|
|
38
|
+
require 'bio/shell/plugin/psort'
|
|
31
39
|
|
|
32
40
|
extend Ghost
|
|
33
|
-
extend Private
|
|
34
41
|
|
|
35
42
|
end
|
|
36
43
|
|
data/lib/bio/shell/core.rb
CHANGED
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Copyright:: Copyright (C) 2005, 2006
|
|
5
5
|
# Toshiaki Katayama <k@bioruby.org>
|
|
6
|
-
# License:: Ruby
|
|
6
|
+
# License:: The Ruby License
|
|
7
7
|
#
|
|
8
|
-
# $Id: core.rb,v 1.
|
|
8
|
+
# $Id: core.rb,v 1.27 2007/06/28 11:21:40 k Exp $
|
|
9
9
|
#
|
|
10
10
|
|
|
11
|
+
module Bio::Shell::Core
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
DATADIR
|
|
21
|
-
BIOFLAT = "bioflat/"
|
|
13
|
+
SHELLDIR = "shell"
|
|
14
|
+
DATADIR = "data"
|
|
15
|
+
SESSION = File.join(SHELLDIR, "session")
|
|
16
|
+
PLUGIN = File.join(SHELLDIR, "plugin")
|
|
17
|
+
SCRIPT = File.join(SHELLDIR, "script.rb")
|
|
18
|
+
CONFIG = File.join(SESSION, "config")
|
|
19
|
+
OBJECT = File.join(SESSION, "object")
|
|
20
|
+
HISTORY = File.join(SESSION, "history")
|
|
21
|
+
BIOFLAT = File.join(DATADIR, "bioflat")
|
|
22
22
|
|
|
23
23
|
MARSHAL = [ Marshal::MAJOR_VERSION, Marshal::MINOR_VERSION ]
|
|
24
24
|
|
|
@@ -36,80 +36,133 @@ module Bio::Shell::Ghost
|
|
|
36
36
|
:n => "\e[00m", :none => "\e[00m", :reset => "\e[00m",
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
def
|
|
40
|
-
|
|
39
|
+
def colors
|
|
40
|
+
ESC_SEQ
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
def
|
|
44
|
-
|
|
43
|
+
def shell_dir
|
|
44
|
+
File.join(@cache[:savedir], SHELLDIR)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
def
|
|
48
|
-
|
|
47
|
+
def data_dir
|
|
48
|
+
File.join(@cache[:savedir], DATADIR)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
def session_dir
|
|
52
|
+
File.join(@cache[:savedir], SESSION)
|
|
53
|
+
end
|
|
52
54
|
|
|
53
|
-
def
|
|
54
|
-
@
|
|
55
|
-
@cache = {}
|
|
56
|
-
check_version
|
|
57
|
-
check_marshal
|
|
58
|
-
load_config
|
|
59
|
-
load_plugin
|
|
55
|
+
def plugin_dir
|
|
56
|
+
File.join(@cache[:savedir], PLUGIN)
|
|
60
57
|
end
|
|
61
|
-
|
|
58
|
+
|
|
59
|
+
def script_file
|
|
60
|
+
File.join(@cache[:savedir], SCRIPT)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def script_dir
|
|
64
|
+
File.dirname(script_file)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def config_file
|
|
68
|
+
File.join(@cache[:savedir], CONFIG)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def object_file
|
|
72
|
+
File.join(@cache[:savedir], OBJECT)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def history_file
|
|
76
|
+
File.join(@cache[:savedir], HISTORY)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def bioflat_dir
|
|
80
|
+
File.join(@cache[:savedir], BIOFLAT)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def ask_yes_or_no(message)
|
|
84
|
+
loop do
|
|
85
|
+
STDERR.print "#{message}"
|
|
86
|
+
answer = gets
|
|
87
|
+
if answer.nil?
|
|
88
|
+
# readline support might be broken
|
|
89
|
+
return false
|
|
90
|
+
elsif /^\s*[Nn]/.match(answer)
|
|
91
|
+
return false
|
|
92
|
+
elsif /^\s*[Yy]/.match(answer)
|
|
93
|
+
return true
|
|
94
|
+
else
|
|
95
|
+
# loop
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
module Bio::Shell::Ghost
|
|
104
|
+
|
|
105
|
+
include Bio::Shell::Core
|
|
106
|
+
|
|
62
107
|
# A hash to store persistent configurations
|
|
63
108
|
attr_accessor :config
|
|
64
109
|
|
|
65
110
|
# A hash to store temporal (per session) configurations
|
|
66
111
|
attr_accessor :cache
|
|
67
112
|
|
|
113
|
+
### save/restore the environment
|
|
114
|
+
|
|
115
|
+
def configure(savedir)
|
|
116
|
+
@config = {}
|
|
117
|
+
@cache = {
|
|
118
|
+
:savedir => savedir,
|
|
119
|
+
:workdir => Dir.pwd,
|
|
120
|
+
}
|
|
121
|
+
create_save_dir
|
|
122
|
+
load_config
|
|
123
|
+
load_plugin
|
|
124
|
+
end
|
|
125
|
+
|
|
68
126
|
def load_session
|
|
69
127
|
load_object
|
|
70
|
-
|
|
71
|
-
|
|
128
|
+
unless @cache[:mode] == :script
|
|
129
|
+
load_history
|
|
130
|
+
opening_splash
|
|
131
|
+
open_history
|
|
132
|
+
end
|
|
72
133
|
end
|
|
73
134
|
|
|
74
135
|
def save_session
|
|
75
|
-
|
|
136
|
+
unless @cache[:mode] == :script
|
|
137
|
+
closing_splash
|
|
138
|
+
end
|
|
76
139
|
if create_save_dir_ask
|
|
77
140
|
#save_history # changed to use our own...
|
|
141
|
+
close_history
|
|
78
142
|
save_object
|
|
79
143
|
save_config
|
|
80
144
|
end
|
|
145
|
+
#STDERR.puts "Leaving directory '#{@cache[:workdir]}'"
|
|
81
146
|
end
|
|
82
147
|
|
|
83
|
-
###
|
|
84
|
-
|
|
85
|
-
def check_version
|
|
86
|
-
if RUBY_VERSION < "1.8.2"
|
|
87
|
-
raise "BioRuby shell runs on Ruby version >= 1.8.2"
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def check_marshal
|
|
92
|
-
if @config[:marshal] and @config[:marshal] != MARSHAL
|
|
93
|
-
raise "Marshal version mismatch"
|
|
94
|
-
end
|
|
95
|
-
end
|
|
148
|
+
### directories
|
|
96
149
|
|
|
97
150
|
def create_save_dir
|
|
98
|
-
create_real_dir(
|
|
99
|
-
create_real_dir(
|
|
100
|
-
create_real_dir(
|
|
151
|
+
create_real_dir(session_dir)
|
|
152
|
+
create_real_dir(plugin_dir)
|
|
153
|
+
create_real_dir(data_dir)
|
|
101
154
|
end
|
|
102
155
|
|
|
103
156
|
def create_save_dir_ask
|
|
104
|
-
if File.directory?(
|
|
157
|
+
if File.directory?(session_dir)
|
|
105
158
|
@cache[:save] = true
|
|
106
159
|
end
|
|
107
|
-
|
|
108
|
-
if ask_yes_or_no("Save session in '#{
|
|
109
|
-
create_real_dir(
|
|
110
|
-
create_real_dir(
|
|
111
|
-
create_real_dir(
|
|
112
|
-
|
|
160
|
+
unless @cache[:save]
|
|
161
|
+
if ask_yes_or_no("Save session in '#{@cache[:workdir]}' directory? [y/n] ")
|
|
162
|
+
create_real_dir(session_dir)
|
|
163
|
+
create_real_dir(plugin_dir)
|
|
164
|
+
create_real_dir(data_dir)
|
|
165
|
+
create_real_dir(bioflat_dir)
|
|
113
166
|
@cache[:save] = true
|
|
114
167
|
else
|
|
115
168
|
@cache[:save] = false
|
|
@@ -118,29 +171,12 @@ module Bio::Shell::Ghost
|
|
|
118
171
|
return @cache[:save]
|
|
119
172
|
end
|
|
120
173
|
|
|
121
|
-
def ask_yes_or_no(message)
|
|
122
|
-
loop do
|
|
123
|
-
print "#{message}"
|
|
124
|
-
answer = gets
|
|
125
|
-
if answer.nil?
|
|
126
|
-
# readline support might be broken
|
|
127
|
-
return false
|
|
128
|
-
elsif /^\s*[Nn]/.match(answer)
|
|
129
|
-
return false
|
|
130
|
-
elsif /^\s*[Yy]/.match(answer)
|
|
131
|
-
return true
|
|
132
|
-
else
|
|
133
|
-
# loop
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
174
|
def create_real_dir(dir)
|
|
139
175
|
unless File.directory?(dir)
|
|
140
176
|
begin
|
|
141
|
-
print "Creating directory (#{dir}) ... "
|
|
142
|
-
|
|
143
|
-
puts "done"
|
|
177
|
+
STDERR.print "Creating directory (#{dir}) ... "
|
|
178
|
+
FileUtils.makedirs(dir)
|
|
179
|
+
STDERR.puts "done"
|
|
144
180
|
rescue
|
|
145
181
|
warn "Error: Failed to create directory (#{dir}) : #{$!}"
|
|
146
182
|
end
|
|
@@ -150,18 +186,15 @@ module Bio::Shell::Ghost
|
|
|
150
186
|
### bioflat
|
|
151
187
|
|
|
152
188
|
def create_flat_dir(dbname)
|
|
153
|
-
dir =
|
|
154
|
-
unless File.directory?(BIOFLAT)
|
|
155
|
-
Dir.mkdir(BIOFLAT)
|
|
156
|
-
end
|
|
189
|
+
dir = File.join(bioflat_dir, dbname.to_s.strip)
|
|
157
190
|
unless File.directory?(dir)
|
|
158
|
-
|
|
191
|
+
FileUtils.makedirs(dir)
|
|
159
192
|
end
|
|
160
193
|
return dir
|
|
161
194
|
end
|
|
162
195
|
|
|
163
196
|
def find_flat_dir(dbname)
|
|
164
|
-
dir =
|
|
197
|
+
dir = File.join(bioflat_dir, dbname.to_s.strip)
|
|
165
198
|
if File.exists?(dir)
|
|
166
199
|
return dir
|
|
167
200
|
else
|
|
@@ -172,30 +205,30 @@ module Bio::Shell::Ghost
|
|
|
172
205
|
### config
|
|
173
206
|
|
|
174
207
|
def load_config
|
|
175
|
-
load_config_file(
|
|
208
|
+
load_config_file(config_file)
|
|
176
209
|
end
|
|
177
210
|
|
|
178
211
|
def load_config_file(file)
|
|
179
212
|
if File.exists?(file)
|
|
180
|
-
print "Loading config (#{file}) ... "
|
|
213
|
+
STDERR.print "Loading config (#{file}) ... "
|
|
181
214
|
if hash = YAML.load(File.read(file))
|
|
182
215
|
@config.update(hash)
|
|
183
216
|
end
|
|
184
|
-
puts "done"
|
|
217
|
+
STDERR.puts "done"
|
|
185
218
|
end
|
|
186
219
|
end
|
|
187
220
|
|
|
188
221
|
def save_config
|
|
189
|
-
save_config_file(
|
|
222
|
+
save_config_file(config_file)
|
|
190
223
|
end
|
|
191
224
|
|
|
192
225
|
def save_config_file(file)
|
|
193
226
|
begin
|
|
194
|
-
print "Saving config (#{file}) ... "
|
|
227
|
+
STDERR.print "Saving config (#{file}) ... "
|
|
195
228
|
File.open(file, "w") do |f|
|
|
196
229
|
f.puts @config.to_yaml
|
|
197
230
|
end
|
|
198
|
-
puts "done"
|
|
231
|
+
STDERR.puts "done"
|
|
199
232
|
rescue
|
|
200
233
|
warn "Error: Failed to save (#{file}) : #{$!}"
|
|
201
234
|
end
|
|
@@ -203,20 +236,20 @@ module Bio::Shell::Ghost
|
|
|
203
236
|
|
|
204
237
|
def config_show
|
|
205
238
|
@config.each do |k, v|
|
|
206
|
-
puts "#{k}\t= #{v.inspect}"
|
|
239
|
+
STDERR.puts "#{k}\t= #{v.inspect}"
|
|
207
240
|
end
|
|
208
241
|
end
|
|
209
242
|
|
|
210
243
|
def config_echo
|
|
211
|
-
bind =
|
|
244
|
+
bind = Bio::Shell.cache[:binding]
|
|
212
245
|
flag = ! @config[:echo]
|
|
213
246
|
@config[:echo] = IRB.conf[:ECHO] = flag
|
|
214
247
|
eval("conf.echo = #{flag}", bind)
|
|
215
|
-
puts "Echo #{flag ? 'on' : 'off'}"
|
|
248
|
+
STDERR.puts "Echo #{flag ? 'on' : 'off'}"
|
|
216
249
|
end
|
|
217
250
|
|
|
218
251
|
def config_color
|
|
219
|
-
bind =
|
|
252
|
+
bind = Bio::Shell.cache[:binding]
|
|
220
253
|
flag = ! @config[:color]
|
|
221
254
|
@config[:color] = flag
|
|
222
255
|
if flag
|
|
@@ -235,7 +268,7 @@ module Bio::Shell::Ghost
|
|
|
235
268
|
def config_splash
|
|
236
269
|
flag = ! @config[:splash]
|
|
237
270
|
@config[:splash] = flag
|
|
238
|
-
puts "Splash #{flag ? 'on' : 'off'}"
|
|
271
|
+
STDERR.puts "Splash #{flag ? 'on' : 'off'}"
|
|
239
272
|
opening_splash
|
|
240
273
|
end
|
|
241
274
|
|
|
@@ -248,115 +281,143 @@ module Bio::Shell::Ghost
|
|
|
248
281
|
### plugin
|
|
249
282
|
|
|
250
283
|
def load_plugin
|
|
251
|
-
load_plugin_dir(
|
|
284
|
+
load_plugin_dir(plugin_dir)
|
|
252
285
|
end
|
|
253
286
|
|
|
254
287
|
def load_plugin_dir(dir)
|
|
255
288
|
if File.directory?(dir)
|
|
256
289
|
Dir.glob("#{dir}/*.rb").sort.each do |file|
|
|
257
|
-
print "Loading plugin (#{file}) ... "
|
|
290
|
+
STDERR.print "Loading plugin (#{file}) ... "
|
|
258
291
|
load file
|
|
259
|
-
puts "done"
|
|
292
|
+
STDERR.puts "done"
|
|
260
293
|
end
|
|
261
294
|
end
|
|
262
295
|
end
|
|
263
296
|
|
|
264
297
|
### object
|
|
265
298
|
|
|
299
|
+
def check_marshal
|
|
300
|
+
if @config[:marshal] and @config[:marshal] != MARSHAL
|
|
301
|
+
raise "Marshal version mismatch"
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
266
305
|
def load_object
|
|
267
|
-
|
|
306
|
+
begin
|
|
307
|
+
check_marshal
|
|
308
|
+
load_object_file(object_file)
|
|
309
|
+
rescue
|
|
310
|
+
warn "Error: Load aborted : #{$!}"
|
|
311
|
+
end
|
|
268
312
|
end
|
|
269
313
|
|
|
270
314
|
def load_object_file(file)
|
|
271
315
|
if File.exists?(file)
|
|
272
|
-
print "Loading object (#{file}) ... "
|
|
316
|
+
STDERR.print "Loading object (#{file}) ... "
|
|
273
317
|
begin
|
|
274
|
-
bind =
|
|
318
|
+
bind = Bio::Shell.cache[:binding]
|
|
275
319
|
hash = Marshal.load(File.read(file))
|
|
276
320
|
hash.each do |k, v|
|
|
277
321
|
begin
|
|
278
322
|
Thread.current[:restore_value] = v
|
|
279
323
|
eval("#{k} = Thread.current[:restore_value]", bind)
|
|
280
324
|
rescue
|
|
281
|
-
puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
|
|
325
|
+
STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
|
|
282
326
|
end
|
|
283
327
|
end
|
|
284
328
|
rescue
|
|
285
329
|
warn "Error: Failed to load (#{file}) : #{$!}"
|
|
286
330
|
end
|
|
287
|
-
puts "done"
|
|
331
|
+
STDERR.puts "done"
|
|
288
332
|
end
|
|
289
333
|
end
|
|
290
|
-
|
|
334
|
+
|
|
291
335
|
def save_object
|
|
292
|
-
save_object_file(
|
|
336
|
+
save_object_file(object_file)
|
|
293
337
|
end
|
|
294
338
|
|
|
295
339
|
def save_object_file(file)
|
|
296
340
|
begin
|
|
297
|
-
print "Saving object (#{file}) ... "
|
|
341
|
+
STDERR.print "Saving object (#{file}) ... "
|
|
342
|
+
File.rename(file, "#{file}.old") if File.exist?(file)
|
|
298
343
|
File.open(file, "w") do |f|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
# value could not be dumped.
|
|
312
|
-
end
|
|
344
|
+
bind = Bio::Shell.cache[:binding]
|
|
345
|
+
list = eval("local_variables", bind)
|
|
346
|
+
list -= ["_"]
|
|
347
|
+
hash = {}
|
|
348
|
+
list.each do |elem|
|
|
349
|
+
value = eval(elem, bind)
|
|
350
|
+
if value
|
|
351
|
+
begin
|
|
352
|
+
Marshal.dump(value)
|
|
353
|
+
hash[elem] = value
|
|
354
|
+
rescue
|
|
355
|
+
# value could not be dumped.
|
|
313
356
|
end
|
|
314
357
|
end
|
|
315
|
-
Marshal.dump(hash, f)
|
|
316
|
-
@config[:marshal] = MARSHAL
|
|
317
|
-
rescue
|
|
318
|
-
warn "Error: Failed to dump (#{file}) : #{$!}"
|
|
319
358
|
end
|
|
359
|
+
Marshal.dump(hash, f)
|
|
360
|
+
@config[:marshal] = MARSHAL
|
|
320
361
|
end
|
|
321
|
-
puts "done"
|
|
362
|
+
STDERR.puts "done"
|
|
322
363
|
rescue
|
|
364
|
+
File.rename("#{file}.old", file) if File.exist?("#{file}.old")
|
|
323
365
|
warn "Error: Failed to save (#{file}) : #{$!}"
|
|
324
366
|
end
|
|
325
367
|
end
|
|
326
368
|
|
|
327
369
|
### history
|
|
328
370
|
|
|
371
|
+
def open_history
|
|
372
|
+
@cache[:histfile] = File.open(history_file, "a")
|
|
373
|
+
@cache[:histfile].sync = true
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def store_history(line)
|
|
377
|
+
Bio::Shell.cache[:histfile].puts "# #{Time.now}"
|
|
378
|
+
Bio::Shell.cache[:histfile].puts line
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def close_history
|
|
382
|
+
if @cache[:histfile]
|
|
383
|
+
STDERR.print "Saving history (#{history_file}) ... "
|
|
384
|
+
@cache[:histfile].close
|
|
385
|
+
STDERR.puts "done"
|
|
386
|
+
end
|
|
387
|
+
end
|
|
388
|
+
|
|
329
389
|
def load_history
|
|
330
390
|
if @cache[:readline]
|
|
331
|
-
load_history_file(
|
|
391
|
+
load_history_file(history_file)
|
|
332
392
|
end
|
|
333
393
|
end
|
|
334
394
|
|
|
335
395
|
def load_history_file(file)
|
|
336
396
|
if File.exists?(file)
|
|
337
|
-
print "Loading history (#{file}) ... "
|
|
397
|
+
STDERR.print "Loading history (#{file}) ... "
|
|
338
398
|
File.open(file).each do |line|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
399
|
+
unless line[/^# /]
|
|
400
|
+
Readline::HISTORY.push line.chomp
|
|
401
|
+
end
|
|
342
402
|
end
|
|
343
|
-
puts "done"
|
|
403
|
+
STDERR.puts "done"
|
|
344
404
|
end
|
|
345
405
|
end
|
|
346
406
|
|
|
407
|
+
# not used (use open_history/close_history instead)
|
|
347
408
|
def save_history
|
|
348
409
|
if @cache[:readline]
|
|
349
|
-
save_history_file(
|
|
410
|
+
save_history_file(history_file)
|
|
350
411
|
end
|
|
351
412
|
end
|
|
352
413
|
|
|
353
414
|
def save_history_file(file)
|
|
354
415
|
begin
|
|
355
|
-
print "Saving history (#{file}) ... "
|
|
416
|
+
STDERR.print "Saving history (#{file}) ... "
|
|
356
417
|
File.open(file, "w") do |f|
|
|
357
418
|
f.puts Readline::HISTORY.to_a
|
|
358
419
|
end
|
|
359
|
-
puts "done"
|
|
420
|
+
STDERR.puts "done"
|
|
360
421
|
rescue
|
|
361
422
|
warn "Error: Failed to save (#{file}) : #{$!}"
|
|
362
423
|
end
|
|
@@ -386,44 +447,44 @@ module Bio::Shell::Ghost
|
|
|
386
447
|
end
|
|
387
448
|
|
|
388
449
|
def script_begin
|
|
389
|
-
puts "-- 8< -- 8< -- 8< -- Script -- 8< -- 8< -- 8< --"
|
|
450
|
+
STDERR.puts "-- 8< -- 8< -- 8< -- Script -- 8< -- 8< -- 8< --"
|
|
390
451
|
@script_begin = Readline::HISTORY.size
|
|
391
452
|
end
|
|
392
453
|
|
|
393
454
|
def script_end
|
|
394
|
-
puts "-- >8 -- >8 -- >8 -- Script -- >8 -- >8 -- >8 --"
|
|
455
|
+
STDERR.puts "-- >8 -- >8 -- >8 -- Script -- >8 -- >8 -- >8 --"
|
|
395
456
|
@script_end = Readline::HISTORY.size - 2
|
|
396
457
|
end
|
|
397
458
|
|
|
398
459
|
def save_script
|
|
399
460
|
if @script_begin and @script_end and @script_begin <= @script_end
|
|
400
|
-
if File.exists?(
|
|
401
|
-
message = "Overwrite script file (#{
|
|
461
|
+
if File.exists?(script_file)
|
|
462
|
+
message = "Overwrite script file (#{script_file})? [y/n] "
|
|
402
463
|
else
|
|
403
|
-
message = "Save script file (#{
|
|
464
|
+
message = "Save script file (#{script_file})? [y/n] "
|
|
404
465
|
end
|
|
405
466
|
if ask_yes_or_no(message)
|
|
406
|
-
save_script_file(
|
|
467
|
+
save_script_file(script_file)
|
|
407
468
|
else
|
|
408
|
-
puts " ... save aborted."
|
|
409
|
-
end
|
|
469
|
+
STDERR.puts " ... save aborted."
|
|
470
|
+
end
|
|
410
471
|
elsif @script_begin and @script_end and @script_begin - @script_end == 1
|
|
411
|
-
puts " ... script aborted."
|
|
472
|
+
STDERR.puts " ... script aborted."
|
|
412
473
|
else
|
|
413
|
-
puts "Error: Script range #{@script_begin}..#{@script_end} is invalid"
|
|
474
|
+
STDERR.puts "Error: Script range #{@script_begin}..#{@script_end} is invalid"
|
|
414
475
|
end
|
|
415
476
|
end
|
|
416
477
|
|
|
417
478
|
def save_script_file(file)
|
|
418
479
|
begin
|
|
419
|
-
print "Saving script (#{file}) ... "
|
|
420
|
-
|
|
480
|
+
STDERR.print "Saving script (#{file}) ... "
|
|
481
|
+
File.open(file, "w") do |f|
|
|
421
482
|
f.puts "#!/usr/bin/env bioruby"
|
|
422
483
|
f.puts
|
|
423
484
|
f.puts Readline::HISTORY.to_a[@script_begin..@script_end]
|
|
424
485
|
f.puts
|
|
425
486
|
end
|
|
426
|
-
puts "done"
|
|
487
|
+
STDERR.puts "done"
|
|
427
488
|
rescue
|
|
428
489
|
@script_begin = nil
|
|
429
490
|
warn "Error: Failed to save (#{file}) : #{$!}"
|
|
@@ -439,8 +500,8 @@ module Bio::Shell::Ghost
|
|
|
439
500
|
|
|
440
501
|
def splash_message_color
|
|
441
502
|
str = splash_message
|
|
442
|
-
ruby =
|
|
443
|
-
none =
|
|
503
|
+
ruby = colors[:ruby]
|
|
504
|
+
none = colors[:none]
|
|
444
505
|
return str.sub(/R u b y/) { "#{ruby}R u b y#{none}" }
|
|
445
506
|
end
|
|
446
507
|
|
|
@@ -464,7 +525,7 @@ module Bio::Shell::Ghost
|
|
|
464
525
|
def splash_message_action_color(message = nil)
|
|
465
526
|
s = message || splash_message
|
|
466
527
|
l = s.length
|
|
467
|
-
c =
|
|
528
|
+
c = colors
|
|
468
529
|
x = " "
|
|
469
530
|
0.step(l,2) do |i|
|
|
470
531
|
l1 = l-i; l2 = l1/2; l4 = l2/2
|
|
@@ -480,7 +541,7 @@ module Bio::Shell::Ghost
|
|
|
480
541
|
end
|
|
481
542
|
|
|
482
543
|
def opening_splash
|
|
483
|
-
puts
|
|
544
|
+
STDERR.puts
|
|
484
545
|
if @config[:splash]
|
|
485
546
|
if @config[:color]
|
|
486
547
|
splash_message_action_color
|
|
@@ -489,28 +550,28 @@ module Bio::Shell::Ghost
|
|
|
489
550
|
end
|
|
490
551
|
end
|
|
491
552
|
if @config[:color]
|
|
492
|
-
print splash_message_color
|
|
553
|
+
STDERR.print splash_message_color
|
|
493
554
|
else
|
|
494
|
-
print splash_message
|
|
555
|
+
STDERR.print splash_message
|
|
495
556
|
end
|
|
496
|
-
puts
|
|
497
|
-
puts
|
|
498
|
-
print " Version : BioRuby #{Bio::BIORUBY_VERSION.join(".")}"
|
|
499
|
-
print " / Ruby #{RUBY_VERSION}"
|
|
500
|
-
puts
|
|
501
|
-
puts
|
|
557
|
+
STDERR.puts
|
|
558
|
+
STDERR.puts
|
|
559
|
+
STDERR.print " Version : BioRuby #{Bio::BIORUBY_VERSION.join(".")}"
|
|
560
|
+
STDERR.print " / Ruby #{RUBY_VERSION}"
|
|
561
|
+
STDERR.puts
|
|
562
|
+
STDERR.puts
|
|
502
563
|
end
|
|
503
564
|
|
|
504
565
|
def closing_splash
|
|
505
|
-
puts
|
|
506
|
-
puts
|
|
566
|
+
STDERR.puts
|
|
567
|
+
STDERR.puts
|
|
507
568
|
if @config[:color]
|
|
508
|
-
print splash_message_color
|
|
569
|
+
STDERR.print splash_message_color
|
|
509
570
|
else
|
|
510
|
-
print splash_message
|
|
571
|
+
STDERR.print splash_message
|
|
511
572
|
end
|
|
512
|
-
puts
|
|
513
|
-
puts
|
|
573
|
+
STDERR.puts
|
|
574
|
+
STDERR.puts
|
|
514
575
|
end
|
|
515
576
|
|
|
516
577
|
end
|