bio 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/bioruby +107 -0
- data/bin/br_biofetch.rb +59 -0
- data/bin/br_bioflat.rb +294 -0
- data/bin/br_biogetseq.rb +57 -0
- data/bin/br_pmfetch.rb +431 -0
- data/doc/BioRuby.rd.ja +225 -0
- data/doc/Changes-0.7.rd +236 -0
- data/doc/Design.rd.ja +341 -0
- data/doc/KEGG_API.rd +1437 -0
- data/doc/KEGG_API.rd.ja +1399 -0
- data/doc/TODO.rd.ja +138 -0
- data/doc/Tutorial.rd +1138 -0
- data/doc/Tutorial.rd.ja +2110 -0
- data/etc/bioinformatics/seqdatabase.ini +210 -0
- data/lib/bio.rb +256 -0
- data/lib/bio/alignment.rb +1906 -0
- data/lib/bio/appl/bl2seq/report.rb +350 -0
- data/lib/bio/appl/blast.rb +269 -0
- data/lib/bio/appl/blast/format0.rb +1402 -0
- data/lib/bio/appl/blast/format8.rb +95 -0
- data/lib/bio/appl/blast/report.rb +652 -0
- data/lib/bio/appl/blast/rexml.rb +151 -0
- data/lib/bio/appl/blast/wublast.rb +553 -0
- data/lib/bio/appl/blast/xmlparser.rb +222 -0
- data/lib/bio/appl/blat/report.rb +392 -0
- data/lib/bio/appl/clustalw.rb +191 -0
- data/lib/bio/appl/clustalw/report.rb +154 -0
- data/lib/bio/appl/emboss.rb +68 -0
- data/lib/bio/appl/fasta.rb +262 -0
- data/lib/bio/appl/fasta/format10.rb +428 -0
- data/lib/bio/appl/fasta/format6.rb +37 -0
- data/lib/bio/appl/genscan/report.rb +570 -0
- data/lib/bio/appl/hmmer.rb +129 -0
- data/lib/bio/appl/hmmer/report.rb +556 -0
- data/lib/bio/appl/mafft.rb +222 -0
- data/lib/bio/appl/mafft/report.rb +119 -0
- data/lib/bio/appl/psort.rb +555 -0
- data/lib/bio/appl/psort/report.rb +473 -0
- data/lib/bio/appl/sim4.rb +134 -0
- data/lib/bio/appl/sim4/report.rb +501 -0
- data/lib/bio/appl/sosui/report.rb +166 -0
- data/lib/bio/appl/spidey/report.rb +604 -0
- data/lib/bio/appl/targetp/report.rb +283 -0
- data/lib/bio/appl/tmhmm/report.rb +238 -0
- data/lib/bio/command.rb +166 -0
- data/lib/bio/data/aa.rb +354 -0
- data/lib/bio/data/codontable.rb +740 -0
- data/lib/bio/data/na.rb +226 -0
- data/lib/bio/db.rb +340 -0
- data/lib/bio/db/aaindex.rb +280 -0
- data/lib/bio/db/embl/common.rb +332 -0
- data/lib/bio/db/embl/embl.rb +446 -0
- data/lib/bio/db/embl/sptr.rb +954 -0
- data/lib/bio/db/embl/swissprot.rb +32 -0
- data/lib/bio/db/embl/trembl.rb +31 -0
- data/lib/bio/db/embl/uniprot.rb +32 -0
- data/lib/bio/db/fantom.rb +604 -0
- data/lib/bio/db/fasta.rb +869 -0
- data/lib/bio/db/genbank/common.rb +299 -0
- data/lib/bio/db/genbank/ddbj.rb +34 -0
- data/lib/bio/db/genbank/genbank.rb +354 -0
- data/lib/bio/db/genbank/genpept.rb +73 -0
- data/lib/bio/db/genbank/refseq.rb +31 -0
- data/lib/bio/db/gff.rb +106 -0
- data/lib/bio/db/go.rb +497 -0
- data/lib/bio/db/kegg/brite.rb +51 -0
- data/lib/bio/db/kegg/cell.rb +88 -0
- data/lib/bio/db/kegg/compound.rb +130 -0
- data/lib/bio/db/kegg/enzyme.rb +125 -0
- data/lib/bio/db/kegg/expression.rb +173 -0
- data/lib/bio/db/kegg/genes.rb +293 -0
- data/lib/bio/db/kegg/genome.rb +362 -0
- data/lib/bio/db/kegg/glycan.rb +213 -0
- data/lib/bio/db/kegg/keggtab.rb +418 -0
- data/lib/bio/db/kegg/kgml.rb +299 -0
- data/lib/bio/db/kegg/ko.rb +178 -0
- data/lib/bio/db/kegg/reaction.rb +97 -0
- data/lib/bio/db/litdb.rb +131 -0
- data/lib/bio/db/medline.rb +317 -0
- data/lib/bio/db/nbrf.rb +199 -0
- data/lib/bio/db/pdb.rb +38 -0
- data/lib/bio/db/pdb/atom.rb +60 -0
- data/lib/bio/db/pdb/chain.rb +117 -0
- data/lib/bio/db/pdb/model.rb +106 -0
- data/lib/bio/db/pdb/pdb.rb +1682 -0
- data/lib/bio/db/pdb/residue.rb +122 -0
- data/lib/bio/db/pdb/utils.rb +234 -0
- data/lib/bio/db/prosite.rb +616 -0
- data/lib/bio/db/rebase.rb +417 -0
- data/lib/bio/db/transfac.rb +387 -0
- data/lib/bio/feature.rb +201 -0
- data/lib/bio/io/brdb.rb +103 -0
- data/lib/bio/io/das.rb +471 -0
- data/lib/bio/io/dbget.rb +212 -0
- data/lib/bio/io/ddbjxml.rb +614 -0
- data/lib/bio/io/fastacmd.rb +123 -0
- data/lib/bio/io/fetch.rb +114 -0
- data/lib/bio/io/flatfile.rb +496 -0
- data/lib/bio/io/flatfile/bdb.rb +266 -0
- data/lib/bio/io/flatfile/index.rb +1308 -0
- data/lib/bio/io/flatfile/indexer.rb +778 -0
- data/lib/bio/io/higet.rb +92 -0
- data/lib/bio/io/keggapi.rb +863 -0
- data/lib/bio/io/pubmed.rb +189 -0
- data/lib/bio/io/registry.rb +308 -0
- data/lib/bio/io/soapwsdl.rb +114 -0
- data/lib/bio/io/sql.rb +428 -0
- data/lib/bio/location.rb +650 -0
- data/lib/bio/pathway.rb +991 -0
- data/lib/bio/reference.rb +308 -0
- data/lib/bio/sequence.rb +593 -0
- data/lib/bio/shell.rb +51 -0
- data/lib/bio/shell/core.rb +512 -0
- data/lib/bio/shell/plugin/codon.rb +228 -0
- data/lib/bio/shell/plugin/entry.rb +85 -0
- data/lib/bio/shell/plugin/flatfile.rb +119 -0
- data/lib/bio/shell/plugin/keggapi.rb +187 -0
- data/lib/bio/shell/plugin/midi.rb +448 -0
- data/lib/bio/shell/plugin/obda.rb +63 -0
- data/lib/bio/shell/plugin/seq.rb +238 -0
- data/lib/bio/shell/session.rb +214 -0
- data/lib/bio/util/color_scheme.rb +214 -0
- data/lib/bio/util/color_scheme/buried.rb +78 -0
- data/lib/bio/util/color_scheme/helix.rb +78 -0
- data/lib/bio/util/color_scheme/hydropathy.rb +83 -0
- data/lib/bio/util/color_scheme/nucleotide.rb +50 -0
- data/lib/bio/util/color_scheme/strand.rb +78 -0
- data/lib/bio/util/color_scheme/taylor.rb +69 -0
- data/lib/bio/util/color_scheme/turn.rb +78 -0
- data/lib/bio/util/color_scheme/zappo.rb +69 -0
- data/lib/bio/util/contingency_table.rb +337 -0
- data/lib/bio/util/sirna.rb +306 -0
- data/lib/bioruby.rb +34 -0
- data/sample/biofetch.rb +475 -0
- data/sample/color_scheme_na.rb +99 -0
- data/sample/dbget +37 -0
- data/sample/fasta2tab.rb +99 -0
- data/sample/fsplit.rb +51 -0
- data/sample/gb2fasta.rb +31 -0
- data/sample/gb2tab.rb +325 -0
- data/sample/gbtab2mysql.rb +161 -0
- data/sample/genes2nuc.rb +33 -0
- data/sample/genes2pep.rb +33 -0
- data/sample/genes2tab.rb +81 -0
- data/sample/genome2rb.rb +29 -0
- data/sample/genome2tab.rb +76 -0
- data/sample/goslim.rb +311 -0
- data/sample/gt2fasta.rb +47 -0
- data/sample/pmfetch.rb +42 -0
- data/sample/pmsearch.rb +42 -0
- data/sample/psortplot_html.rb +222 -0
- data/sample/ssearch2tab.rb +96 -0
- data/sample/tdiary.rb +158 -0
- data/sample/tfastx2tab.rb +100 -0
- data/sample/vs-genes.rb +212 -0
- data/test/data/SOSUI/sample.report +11 -0
- data/test/data/TMHMM/sample.report +21 -0
- data/test/data/blast/eco:b0002.faa +15 -0
- data/test/data/blast/eco:b0002.faa.m0 +128 -0
- data/test/data/blast/eco:b0002.faa.m7 +65 -0
- data/test/data/blast/eco:b0002.faa.m8 +1 -0
- data/test/data/embl/AB090716.embl +65 -0
- data/test/data/genscan/sample.report +63 -0
- data/test/data/prosite/prosite.dat +2233 -0
- data/test/data/refseq/nm_126355.entret +64 -0
- data/test/data/uniprot/p53_human.uniprot +1456 -0
- data/test/runner.rb +10 -0
- data/test/unit/bio/appl/blast/test_report.rb +427 -0
- data/test/unit/bio/appl/blast/test_xmlparser.rb +400 -0
- data/test/unit/bio/appl/genscan/test_report.rb +195 -0
- data/test/unit/bio/appl/sosui/test_report.rb +94 -0
- data/test/unit/bio/appl/targetp/test_report.rb +159 -0
- data/test/unit/bio/appl/test_blast.rb +159 -0
- data/test/unit/bio/appl/test_fasta.rb +142 -0
- data/test/unit/bio/appl/tmhmm/test_report.rb +139 -0
- data/test/unit/bio/data/test_aa.rb +103 -0
- data/test/unit/bio/data/test_codontable.rb +120 -0
- data/test/unit/bio/data/test_na.rb +89 -0
- data/test/unit/bio/db/embl/test_common.rb +130 -0
- data/test/unit/bio/db/embl/test_embl.rb +227 -0
- data/test/unit/bio/db/embl/test_sptr.rb +268 -0
- data/test/unit/bio/db/embl/test_uniprot.rb +44 -0
- data/test/unit/bio/db/kegg/test_genes.rb +58 -0
- data/test/unit/bio/db/test_fasta.rb +263 -0
- data/test/unit/bio/db/test_gff.rb +140 -0
- data/test/unit/bio/db/test_prosite.rb +1450 -0
- data/test/unit/bio/io/test_ddbjxml.rb +87 -0
- data/test/unit/bio/io/test_soapwsdl.rb +45 -0
- data/test/unit/bio/shell/plugin/test_seq.rb +175 -0
- data/test/unit/bio/test_alignment.rb +1028 -0
- data/test/unit/bio/test_command.rb +71 -0
- data/test/unit/bio/test_db.rb +109 -0
- data/test/unit/bio/test_feature.rb +128 -0
- data/test/unit/bio/test_location.rb +51 -0
- data/test/unit/bio/test_pathway.rb +485 -0
- data/test/unit/bio/test_sequence.rb +386 -0
- data/test/unit/bio/test_shell.rb +31 -0
- data/test/unit/bio/util/test_color_scheme.rb +45 -0
- data/test/unit/bio/util/test_contingency_table.rb +106 -0
- data/test/unit/bio/util/test_sirna.rb +258 -0
- metadata +295 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
#
|
|
2
|
+
# = bio/shell/plugin/midi.rb - Sequence to MIDI converter
|
|
3
|
+
#
|
|
4
|
+
# Copyright:: Copyright (C) 2003, 2005
|
|
5
|
+
# Natsuhiro Ichinose <ichinose@genome.ist.i.kyoto-u.ac.jp>,
|
|
6
|
+
# Toshiaki Katayama <k@bioruby.org>
|
|
7
|
+
# License:: LGPL
|
|
8
|
+
#
|
|
9
|
+
# $Id: midi.rb,v 1.6 2005/11/28 12:06:18 k Exp $
|
|
10
|
+
#
|
|
11
|
+
#--
|
|
12
|
+
#
|
|
13
|
+
# This library is free software; you can redistribute it and/or
|
|
14
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
15
|
+
# License as published by the Free Software Foundation; either
|
|
16
|
+
# version 2 of the License, or (at your option) any later version.
|
|
17
|
+
#
|
|
18
|
+
# This library is distributed in the hope that it will be useful,
|
|
19
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21
|
+
# Lesser General Public License for more details.
|
|
22
|
+
#
|
|
23
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
24
|
+
# License along with this library; if not, write to the Free Software
|
|
25
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
26
|
+
#
|
|
27
|
+
#++
|
|
28
|
+
#
|
|
29
|
+
|
|
30
|
+
#--
|
|
31
|
+
# *TODO*
|
|
32
|
+
# - add "Ohno" style
|
|
33
|
+
# - add a accessor to drum pattern
|
|
34
|
+
# - add a new feature to select music style (pop, trans, ryukyu, ...)
|
|
35
|
+
# - what is the base?
|
|
36
|
+
#++
|
|
37
|
+
|
|
38
|
+
class Bio::Sequence::NA
|
|
39
|
+
|
|
40
|
+
class MidiTrack
|
|
41
|
+
|
|
42
|
+
MidiProg = [
|
|
43
|
+
"Acoustic Grand Piano",
|
|
44
|
+
"Bright Acoustic Piano",
|
|
45
|
+
"Electric grand Piano",
|
|
46
|
+
"Honky Tonk Piano",
|
|
47
|
+
"Eiectric Piano 1",
|
|
48
|
+
"Electric Piano 2",
|
|
49
|
+
"Harpsichord",
|
|
50
|
+
"Clavinet",
|
|
51
|
+
"Celesra",
|
|
52
|
+
"Glockenspiel",
|
|
53
|
+
"Music Box",
|
|
54
|
+
"Vibraphone",
|
|
55
|
+
"Marimba",
|
|
56
|
+
"Xylophone",
|
|
57
|
+
"Tubular bells",
|
|
58
|
+
"Dulcimer",
|
|
59
|
+
"Drawbar Organ",
|
|
60
|
+
"Percussive Organ",
|
|
61
|
+
"Rock Organ",
|
|
62
|
+
"Church Organ",
|
|
63
|
+
"Reed Organ",
|
|
64
|
+
"Accordion",
|
|
65
|
+
"Harmonica",
|
|
66
|
+
"Tango Accordion",
|
|
67
|
+
"Nylon Accustic Guitar",
|
|
68
|
+
"Steel Acoustic Guitar",
|
|
69
|
+
"Jazz Electric Guitar",
|
|
70
|
+
"Ciean Electric Guitar",
|
|
71
|
+
"Muted Electric Guitar",
|
|
72
|
+
"Overdrive Guitar",
|
|
73
|
+
"Distorted Guitar",
|
|
74
|
+
"Guitar Harmonics",
|
|
75
|
+
"Acoustic Bass",
|
|
76
|
+
"Electric Fingered Bass",
|
|
77
|
+
"Electric Picked Bass",
|
|
78
|
+
"Fretless Bass",
|
|
79
|
+
"Slap Bass 1",
|
|
80
|
+
"Slap Bass 2",
|
|
81
|
+
"Syn Bass 1",
|
|
82
|
+
"Syn Bass 2",
|
|
83
|
+
"Violin",
|
|
84
|
+
"Viola",
|
|
85
|
+
"Cello",
|
|
86
|
+
"Contrabass",
|
|
87
|
+
"Tremolo Strings",
|
|
88
|
+
"Pizzicato Strings",
|
|
89
|
+
"Orchestral Harp",
|
|
90
|
+
"Timpani",
|
|
91
|
+
"String Ensemble 1",
|
|
92
|
+
"String Ensemble 2 (Slow)",
|
|
93
|
+
"Syn Strings 1",
|
|
94
|
+
"Syn Strings 2",
|
|
95
|
+
"Choir Aahs",
|
|
96
|
+
"Voice Oohs",
|
|
97
|
+
"Syn Choir",
|
|
98
|
+
"Orchestral Hit",
|
|
99
|
+
"Trumpet",
|
|
100
|
+
"Trombone",
|
|
101
|
+
"Tuba",
|
|
102
|
+
"Muted Trumpet",
|
|
103
|
+
"French Horn",
|
|
104
|
+
"Brass Section",
|
|
105
|
+
"Syn Brass 1",
|
|
106
|
+
"Syn Brass 2",
|
|
107
|
+
"Soprano Sax",
|
|
108
|
+
"Alto Sax",
|
|
109
|
+
"Tenor Sax",
|
|
110
|
+
"Baritone Sax",
|
|
111
|
+
"Oboe",
|
|
112
|
+
"English Horn",
|
|
113
|
+
"Bassoon",
|
|
114
|
+
"Clarinet",
|
|
115
|
+
"Piccolo",
|
|
116
|
+
"Flute",
|
|
117
|
+
"Recorder",
|
|
118
|
+
"Pan Flute",
|
|
119
|
+
"Bottle Blow",
|
|
120
|
+
"Shakuhachi",
|
|
121
|
+
"Whistle",
|
|
122
|
+
"Ocarina",
|
|
123
|
+
"Syn Square Wave",
|
|
124
|
+
"Syn Sawtooth Wave",
|
|
125
|
+
"Syn Calliope",
|
|
126
|
+
"Syn Chiff",
|
|
127
|
+
"Syn Charang",
|
|
128
|
+
"Syn Voice",
|
|
129
|
+
"Syn Fifths Sawtooth Wave",
|
|
130
|
+
"Syn Brass & Lead",
|
|
131
|
+
"New Age Syn Pad",
|
|
132
|
+
"Warm Syn Pad",
|
|
133
|
+
"Polysynth Syn Pad",
|
|
134
|
+
"Choir Syn Pad",
|
|
135
|
+
"Bowed Syn Pad",
|
|
136
|
+
"Metal Syn Pad",
|
|
137
|
+
"Halo Syn Pad",
|
|
138
|
+
"Sweep Syn Pad",
|
|
139
|
+
"SFX Rain",
|
|
140
|
+
"SFX Soundtrack",
|
|
141
|
+
"SFX Crystal",
|
|
142
|
+
"SFX Atmosphere",
|
|
143
|
+
"SFX Brightness",
|
|
144
|
+
"SFX Goblins",
|
|
145
|
+
"SFX Echoes",
|
|
146
|
+
"SFX Sci-fi",
|
|
147
|
+
"Sitar",
|
|
148
|
+
"Banjo",
|
|
149
|
+
"Shamisen",
|
|
150
|
+
"Koto",
|
|
151
|
+
"Kalimba",
|
|
152
|
+
"Bag Pipe",
|
|
153
|
+
"Fiddle",
|
|
154
|
+
"Shanai",
|
|
155
|
+
"Tinkle Bell",
|
|
156
|
+
"Agogo",
|
|
157
|
+
"Steel Drums",
|
|
158
|
+
"Woodblock",
|
|
159
|
+
"Taiko Drum",
|
|
160
|
+
"Melodic Tom",
|
|
161
|
+
"Syn Drum",
|
|
162
|
+
"Reverse Cymbal",
|
|
163
|
+
"Guitar Fret Noise",
|
|
164
|
+
"Breath Noise",
|
|
165
|
+
"Seashore",
|
|
166
|
+
"Bird Tweet",
|
|
167
|
+
"Telephone Ring",
|
|
168
|
+
"Helicopter",
|
|
169
|
+
"Applause",
|
|
170
|
+
"Gun Shot"
|
|
171
|
+
]
|
|
172
|
+
|
|
173
|
+
Styles = {
|
|
174
|
+
# "Ohno" => {
|
|
175
|
+
# # http://home.hiroshima-u.ac.jp/cato/bunkakoryuron.html
|
|
176
|
+
# },
|
|
177
|
+
"Ichinose" => {
|
|
178
|
+
:tempo => 120,
|
|
179
|
+
:scale => [0, 2, 4, 5, 7, 9, 11],
|
|
180
|
+
:tones => [
|
|
181
|
+
{:prog => 9, :base => 60, :range => 2},
|
|
182
|
+
{:prog => 13, :base => 48, :range => 2},
|
|
183
|
+
{:prog => 41, :base => 48, :range => 2},
|
|
184
|
+
{:prog => 44, :base => 36, :range => 2},
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
"Okinawan" => {
|
|
188
|
+
:tempo => 180,
|
|
189
|
+
:scale => [0,4,5,7,11],
|
|
190
|
+
:tones => [
|
|
191
|
+
{:prog => MidiProg.index("Harpsichord"), :base => 60, :range => 2},
|
|
192
|
+
{:prog => MidiProg.index("Dulcimer"), :base => 48, :range => 2},
|
|
193
|
+
{:prog => MidiProg.index("Fretless Base"), :base => 36, :range => 1},
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
"Major" => {
|
|
197
|
+
:scale => [0,2,4,5,7,9,11],
|
|
198
|
+
},
|
|
199
|
+
"Minor" => {
|
|
200
|
+
:scale => [0,2,3,5,7,9,10],
|
|
201
|
+
},
|
|
202
|
+
"Harmonic minor" => {
|
|
203
|
+
:scale => [0,2,3,5,7,9,11],
|
|
204
|
+
},
|
|
205
|
+
"Whole tone" => {
|
|
206
|
+
:scale => [0,2,4,6,8,10],
|
|
207
|
+
},
|
|
208
|
+
"Half tone" => {
|
|
209
|
+
:scale => [0,1,2,3,4,5,6,7,8,9,10,11],
|
|
210
|
+
},
|
|
211
|
+
"Indian" => {
|
|
212
|
+
:scale => [0,1,4,5,7,8,11],
|
|
213
|
+
},
|
|
214
|
+
"Arabic" => {
|
|
215
|
+
:scale => [0,2,3,6,7,8,11],
|
|
216
|
+
},
|
|
217
|
+
"Spanish" => {
|
|
218
|
+
:scale => [0,1,3,4,5,7,8,10],
|
|
219
|
+
},
|
|
220
|
+
"Japanese" => {
|
|
221
|
+
:scale => [0,2,5,7,9],
|
|
222
|
+
},
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
def initialize(channel = 0, program = nil, base = nil, range = nil, scale = nil)
|
|
226
|
+
@channel = channel & 0xff
|
|
227
|
+
@program = program || 0
|
|
228
|
+
@base = base || 60
|
|
229
|
+
@range = range || 2
|
|
230
|
+
@scale = scale || [0, 2, 4, 5, 7, 9, 11]
|
|
231
|
+
|
|
232
|
+
@tunes = []
|
|
233
|
+
@tune = 0
|
|
234
|
+
@code = []
|
|
235
|
+
@time = 0
|
|
236
|
+
|
|
237
|
+
@range.times do |i|
|
|
238
|
+
@scale.each do |c|
|
|
239
|
+
@tunes.push c + i * 12
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
@ttype = {
|
|
244
|
+
'aa' => 1, 'at' => 0, 'ac' => 3, 'ag' => -1,
|
|
245
|
+
'ta' => 0, 'tt' => -1, 'tc' => 1, 'tg' => -2,
|
|
246
|
+
'ca' => 2, 'ct' => 1, 'cc' => 2, 'cg' => 6,
|
|
247
|
+
'ga' => -1, 'gt' => -3, 'gc' => 0, 'gg' => -2,
|
|
248
|
+
}
|
|
249
|
+
@dtype = [
|
|
250
|
+
{ 'aa' => 2, 'at' => 4, 'ac' => 4, 'ag' => 2,
|
|
251
|
+
'ta' => 2, 'tt' => 4, 'tc' => 4, 'tg' => 2,
|
|
252
|
+
'ca' => 2, 'ct' => 3, 'cc' => 1, 'cg' => 2,
|
|
253
|
+
'ga' => 1, 'gt' => 2, 'gc' => 2, 'gg' => 3,
|
|
254
|
+
},
|
|
255
|
+
{ 'aa' => 3, 'at' => 3, 'ac' => 2, 'ag' => 3,
|
|
256
|
+
'ta' => 3, 'tt' => 3, 'tc' => 2, 'tg' => 2,
|
|
257
|
+
'ca' => 3, 'ct' => 2, 'cc' => 1, 'cg' => 1,
|
|
258
|
+
'ga' => 1, 'gt' => 1, 'gc' => 1, 'gg' => 1,
|
|
259
|
+
},
|
|
260
|
+
{ 'aa' => 2, 'at' => 2, 'ac' => 2, 'ag' => 2,
|
|
261
|
+
'ta' => 1, 'tt' => 1, 'tc' => 2, 'tg' => 2,
|
|
262
|
+
'ca' => 2, 'ct' => 2, 'cc' => 2, 'cg' => 3,
|
|
263
|
+
'ga' => 2, 'gt' => 2, 'gc' => 3, 'gg' => 1,
|
|
264
|
+
},
|
|
265
|
+
{ 'aa' => 1, 'at' => 1, 'ac' => 1, 'ag' => 1,
|
|
266
|
+
'ta' => 1, 'tt' => 1, 'tc' => 1, 'tg' => 1,
|
|
267
|
+
'ca' => 1, 'ct' => 1, 'cc' => 1, 'cg' => 3,
|
|
268
|
+
'ga' => 1, 'gt' => 1, 'gc' => 1, 'gg' => 1,
|
|
269
|
+
},
|
|
270
|
+
]
|
|
271
|
+
|
|
272
|
+
@code.concat [0x00, 0xc0 | (@channel & 0xff)]
|
|
273
|
+
@code.concat icode(@program & 0xff, 1)
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def icode(num, n)
|
|
277
|
+
code = []
|
|
278
|
+
n.times do |i|
|
|
279
|
+
code.push num & 0xff
|
|
280
|
+
num >>= 8
|
|
281
|
+
end
|
|
282
|
+
code.reverse
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def rcode(num)
|
|
286
|
+
code = []
|
|
287
|
+
code.push num & 0x7f
|
|
288
|
+
while num > 0x7f
|
|
289
|
+
num >>= 7
|
|
290
|
+
code.push num & 0x7f | 0x80
|
|
291
|
+
end
|
|
292
|
+
code.reverse
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def c2s(code)
|
|
296
|
+
ans = ""
|
|
297
|
+
code.each do |c|
|
|
298
|
+
ans += c.chr
|
|
299
|
+
end
|
|
300
|
+
ans
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
def push(s)
|
|
304
|
+
tt = @time % 4
|
|
305
|
+
t = @ttype[s[0, 2]]
|
|
306
|
+
d = @dtype[tt][s[2, 2]]
|
|
307
|
+
if !t.nil? && !d.nil?
|
|
308
|
+
@tune += t
|
|
309
|
+
@tune %= @tunes.length
|
|
310
|
+
if tt == 0
|
|
311
|
+
vel = 90
|
|
312
|
+
elsif tt == 1 && d > 1
|
|
313
|
+
vel = 100
|
|
314
|
+
elsif tt == 2
|
|
315
|
+
vel = 60
|
|
316
|
+
else
|
|
317
|
+
vel = 50
|
|
318
|
+
end
|
|
319
|
+
@code.concat rcode(1)
|
|
320
|
+
@code.concat [0x90 | @channel, @tunes[@tune] + @base, vel]
|
|
321
|
+
@code.concat rcode(240 * d)
|
|
322
|
+
@code.concat [0x80 | @channel, @tunes[@tune] + @base, 0]
|
|
323
|
+
@time += d
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def push_silent(d)
|
|
328
|
+
@code.concat rcode(1)
|
|
329
|
+
@code.concat [0x90 | @channel, 0, 0]
|
|
330
|
+
@code.concat rcode(240 * d)
|
|
331
|
+
@code.concat [0x80 | @channel, 0, 0]
|
|
332
|
+
@time += d;
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def encode
|
|
336
|
+
ans ="MTrk"
|
|
337
|
+
ans += c2s(icode(@code.length + 4, 4))
|
|
338
|
+
ans += c2s(@code)
|
|
339
|
+
ans += c2s([0x00, 0xff, 0x2f, 0x00])
|
|
340
|
+
ans
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def header(num, tempo = 120)
|
|
344
|
+
ans = "MThd"
|
|
345
|
+
ans += c2s(icode(6, 4))
|
|
346
|
+
ans += c2s(icode(1, 2))
|
|
347
|
+
ans += c2s(icode(num + 1, 2))
|
|
348
|
+
ans += c2s(icode(480, 2))
|
|
349
|
+
ans += "MTrk"
|
|
350
|
+
ans += c2s(icode(11, 4))
|
|
351
|
+
ans += c2s([0x00, 0xff, 0x51, 0x03])
|
|
352
|
+
ans += c2s(icode(60000000 / tempo, 3))
|
|
353
|
+
ans += c2s([0x00, 0xff, 0x2f, 0x00])
|
|
354
|
+
ans
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
end # MidiTrack
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
# style:
|
|
361
|
+
# Hash of :tempo, :scale, :tones
|
|
362
|
+
# scale:
|
|
363
|
+
# C C# D D# E F F# G G# A A# B
|
|
364
|
+
# 0 1 2 3 4 5 6 7 8 9 10 11
|
|
365
|
+
# tones:
|
|
366
|
+
# Hash of :prog, :base, :range -- tone, vol? or len?, octaves
|
|
367
|
+
# drum:
|
|
368
|
+
# true (with rhythm part), false (without rhythm part)
|
|
369
|
+
def to_midi(style = {}, drum = true)
|
|
370
|
+
default = MidiTrack::Styles["Ichinose"]
|
|
371
|
+
if style.is_a?(String)
|
|
372
|
+
style = MidiTrack::Styles[style] || default
|
|
373
|
+
end
|
|
374
|
+
tempo = style[:tempo] || default[:tempo]
|
|
375
|
+
scale = style[:scale] || default[:scale]
|
|
376
|
+
tones = style[:tones] || default[:tones]
|
|
377
|
+
|
|
378
|
+
track = []
|
|
379
|
+
|
|
380
|
+
tones.each_with_index do |tone, i|
|
|
381
|
+
ch = i
|
|
382
|
+
ch += 1 if i >= 9 # skip rythm track
|
|
383
|
+
track.push MidiTrack.new(ch, tone[:prog], tone[:base], tone[:range], scale)
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
if drum
|
|
387
|
+
rhythm = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
|
388
|
+
track.push(MidiTrack.new(9, 0, 35, 2, rhythm))
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
cur = 0
|
|
392
|
+
window_search(4) do |s|
|
|
393
|
+
track[cur % track.length].push(s)
|
|
394
|
+
cur += 1
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
track.each do |t|
|
|
398
|
+
t.push_silent(12)
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
ans = track[0].header(track.length, tempo)
|
|
402
|
+
track.each do |t|
|
|
403
|
+
ans += t.encode
|
|
404
|
+
end
|
|
405
|
+
return ans
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
module Bio::Shell
|
|
412
|
+
|
|
413
|
+
private
|
|
414
|
+
|
|
415
|
+
def midifile(filename, seq, *args)
|
|
416
|
+
begin
|
|
417
|
+
print "Saving MIDI file (#{filename}) ... "
|
|
418
|
+
File.open(filename, "w") do |file|
|
|
419
|
+
file.puts seq.to_midi(*args)
|
|
420
|
+
end
|
|
421
|
+
puts "done"
|
|
422
|
+
rescue
|
|
423
|
+
warn "Error: Failed to save (#{filename}) : #{$!}"
|
|
424
|
+
end
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
if $0 == __FILE__
|
|
431
|
+
|
|
432
|
+
# % for i in file*
|
|
433
|
+
# do
|
|
434
|
+
# ruby -r bio bio/shell/plugin/midi.rb $i ${i}.mid
|
|
435
|
+
# done
|
|
436
|
+
|
|
437
|
+
include Bio::Shell
|
|
438
|
+
|
|
439
|
+
seq_file = ARGV.shift
|
|
440
|
+
mid_file = ARGV.shift
|
|
441
|
+
style = ARGV.shift
|
|
442
|
+
|
|
443
|
+
Bio::FlatFile.auto(seq_file) do |ff|
|
|
444
|
+
ff.each do |f|
|
|
445
|
+
midi(f.naseq[0..1000], mid_file, style)
|
|
446
|
+
end
|
|
447
|
+
end
|
|
448
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#
|
|
2
|
+
# = bio/shell/plugin/obda.rb - plugin for OBDA
|
|
3
|
+
#
|
|
4
|
+
# Copyright:: Copyright (C) 2005
|
|
5
|
+
# Toshiaki Katayama <k@bioruby.org>
|
|
6
|
+
# License:: LGPL
|
|
7
|
+
#
|
|
8
|
+
# $Id: obda.rb,v 1.8 2005/11/30 02:01:04 k Exp $
|
|
9
|
+
#
|
|
10
|
+
#--
|
|
11
|
+
#
|
|
12
|
+
# This library is free software; you can redistribute it and/or
|
|
13
|
+
# modify it under the terms of the GNU Lesser General Public
|
|
14
|
+
# License as published by the Free Software Foundation; either
|
|
15
|
+
# version 2 of the License, or (at your option) any later version.
|
|
16
|
+
#
|
|
17
|
+
# This library is distributed in the hope that it will be useful,
|
|
18
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20
|
+
# Lesser General Public License for more details.
|
|
21
|
+
#
|
|
22
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
23
|
+
# License along with this library; if not, write to the Free Software
|
|
24
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
25
|
+
#
|
|
26
|
+
#++
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
module Bio::Shell
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def obda
|
|
34
|
+
@obda ||= Bio::Registry.new
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def obdaentry(dbname, entry_id)
|
|
38
|
+
db = obda.get_database(dbname)
|
|
39
|
+
unless db
|
|
40
|
+
warn "Error: No such database (#{dbname})"
|
|
41
|
+
return
|
|
42
|
+
end
|
|
43
|
+
entry = db.get_by_id(entry_id)
|
|
44
|
+
if block_given?
|
|
45
|
+
yield entry
|
|
46
|
+
else
|
|
47
|
+
return entry
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def obdadbs
|
|
52
|
+
result = obda.databases.map {|db| db.database}
|
|
53
|
+
return result
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def biofetch(db, id, style = 'raw', format = 'default')
|
|
57
|
+
serv = Bio::Fetch.new("http://www.ebi.ac.uk/cgi-bin/dbfetch")
|
|
58
|
+
result = serv.fetch(db, id, style, format)
|
|
59
|
+
return result
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|