bio 1.5.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +35 -36
- data/ChangeLog +911 -2554
- data/{gemfiles/Gemfile.travis-ruby2.2 → Gemfile} +0 -3
- data/KNOWN_ISSUES.rdoc +10 -13
- data/LEGAL +0 -10
- data/README.rdoc +40 -96
- data/README_DEV.rdoc +5 -5
- data/RELEASE_NOTES.rdoc +118 -234
- data/Rakefile +13 -43
- data/appveyor.yml +29 -0
- data/bioruby.gemspec +18 -81
- data/bioruby.gemspec.erb +8 -28
- data/doc/ChangeLog-1.5.0 +2919 -0
- data/doc/RELEASE_NOTES-1.5.0.rdoc +285 -0
- data/doc/Tutorial.rd +6 -108
- data/doc/Tutorial.rd.html +19 -98
- data/gemfiles/Gemfile.travis-jruby1.8 +3 -5
- data/gemfiles/Gemfile.travis-jruby1.9 +0 -3
- data/gemfiles/Gemfile.travis-rbx +0 -3
- data/gemfiles/Gemfile.travis-ruby1.8 +3 -5
- data/gemfiles/Gemfile.travis-ruby1.9 +0 -3
- data/gemfiles/Gemfile.windows +6 -0
- data/gemfiles/prepare-gemspec.rb +4 -0
- data/lib/bio.rb +0 -10
- data/lib/bio/appl/blast/genomenet.rb +4 -4
- data/lib/bio/appl/blast/report.rb +40 -8
- data/lib/bio/appl/fasta/format10.rb +2 -1
- data/lib/bio/command.rb +10 -0
- data/lib/bio/data/codontable.rb +99 -3
- data/lib/bio/db/aaindex.rb +74 -5
- data/lib/bio/db/gff.rb +3 -1
- data/lib/bio/db/kegg/common.rb +14 -0
- data/lib/bio/db/kegg/genes.rb +26 -0
- data/lib/bio/db/kegg/pathway.rb +5 -11
- data/lib/bio/db/soft.rb +2 -2
- data/lib/bio/io/flatfile/autodetection.rb +5 -0
- data/lib/bio/io/togows.rb +5 -5
- data/lib/bio/map.rb +4 -4
- data/lib/bio/sequence/format.rb +1 -0
- data/lib/bio/util/restriction_enzyme/range/sequence_range/calculated_cuts.rb +1 -1
- data/lib/bio/util/sirna.rb +2 -0
- data/lib/bio/version.rb +6 -8
- data/sample/color_scheme_aa.rb +82 -0
- data/sample/color_scheme_na.rb +5 -6
- data/sample/fastq2html.cwl +23 -0
- data/sample/fastq2html.rb +94 -0
- data/sample/fastq2html.testdata.yaml +5 -0
- data/sample/na2aa.cwl +23 -0
- data/sample/na2aa.rb +11 -25
- data/sample/na2aa.testdata.yaml +7 -0
- data/sample/rev_comp.cwl +23 -0
- data/sample/rev_comp.rb +20 -0
- data/sample/rev_comp.testdata.yaml +7 -0
- data/sample/test_restriction_enzyme_long.rb +1 -1
- data/test/network/bio/db/kegg/test_genes_hsa7422.rb +91 -0
- data/test/unit/bio/appl/blast/test_report.rb +4 -4
- data/test/unit/bio/data/test_codontable.rb +3 -0
- data/test/unit/bio/db/test_gff.rb +5 -0
- data/test/unit/bio/test_alignment.rb +2 -2
- metadata +20 -77
- data/bin/bioruby +0 -47
- data/bin/br_biofetch.rb +0 -71
- data/bin/br_bioflat.rb +0 -293
- data/bin/br_biogetseq.rb +0 -45
- data/bin/br_pmfetch.rb +0 -422
- data/lib/bio/appl/blast/xmlparser.rb +0 -236
- data/lib/bio/db/biosql/biosql_to_biosequence.rb +0 -78
- data/lib/bio/db/biosql/sequence.rb +0 -444
- data/lib/bio/db/phyloxml/phyloxml.xsd +0 -582
- data/lib/bio/db/phyloxml/phyloxml_elements.rb +0 -1197
- data/lib/bio/db/phyloxml/phyloxml_parser.rb +0 -1001
- data/lib/bio/db/phyloxml/phyloxml_writer.rb +0 -227
- data/lib/bio/io/biosql/ar-biosql.rb +0 -257
- data/lib/bio/io/biosql/biosql.rb +0 -39
- data/lib/bio/io/biosql/config/database.yml +0 -21
- data/lib/bio/io/sql.rb +0 -79
- data/lib/bio/shell.rb +0 -44
- data/lib/bio/shell/core.rb +0 -578
- data/lib/bio/shell/demo.rb +0 -146
- data/lib/bio/shell/interface.rb +0 -217
- data/lib/bio/shell/irb.rb +0 -94
- data/lib/bio/shell/object.rb +0 -71
- data/lib/bio/shell/plugin/blast.rb +0 -42
- data/lib/bio/shell/plugin/codon.rb +0 -218
- data/lib/bio/shell/plugin/das.rb +0 -58
- data/lib/bio/shell/plugin/emboss.rb +0 -23
- data/lib/bio/shell/plugin/entry.rb +0 -137
- data/lib/bio/shell/plugin/flatfile.rb +0 -101
- data/lib/bio/shell/plugin/midi.rb +0 -430
- data/lib/bio/shell/plugin/ncbirest.rb +0 -68
- data/lib/bio/shell/plugin/obda.rb +0 -45
- data/lib/bio/shell/plugin/psort.rb +0 -56
- data/lib/bio/shell/plugin/seq.rb +0 -248
- data/lib/bio/shell/plugin/togows.rb +0 -40
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/bioruby_generator.rb +0 -29
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_classes.rhtml +0 -4
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_log.rhtml +0 -27
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_methods.rhtml +0 -11
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_modules.rhtml +0 -4
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/_variables.rhtml +0 -7
- 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 +0 -368
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby.rhtml +0 -47
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb +0 -144
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_helper.rb +0 -47
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/commands.rhtml +0 -8
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/history.rhtml +0 -10
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/index.rhtml +0 -26
- data/lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/spinner.gif +0 -0
- data/lib/bio/shell/script.rb +0 -25
- data/lib/bio/shell/setup.rb +0 -108
- data/lib/bio/shell/web.rb +0 -102
- data/sample/test_phyloxml_big.rb +0 -205
- data/setup.rb +0 -1600
- data/test/data/phyloxml/apaf.xml +0 -666
- data/test/data/phyloxml/bcl_2.xml +0 -2097
- data/test/data/phyloxml/made_up.xml +0 -144
- data/test/data/phyloxml/ncbi_taxonomy_mollusca_short.xml +0 -65
- data/test/data/phyloxml/phyloxml_examples.xml +0 -415
- data/test/unit/bio/db/biosql/tc_biosql.rb +0 -114
- data/test/unit/bio/db/biosql/ts_suite_biosql.rb +0 -8
- data/test/unit/bio/db/test_phyloxml.rb +0 -821
- data/test/unit/bio/db/test_phyloxml_writer.rb +0 -334
- data/test/unit/bio/shell/plugin/test_seq.rb +0 -187
- data/test/unit/bio/test_shell.rb +0 -20
data/lib/bio/db/gff.rb
CHANGED
|
@@ -359,7 +359,9 @@ module Bio
|
|
|
359
359
|
# Parses a GFF2-formatted line and returns a new
|
|
360
360
|
# Bio::GFF::GFF2::Record object.
|
|
361
361
|
def self.parse(str)
|
|
362
|
-
self.new
|
|
362
|
+
ret = self.new
|
|
363
|
+
ret.parse(str)
|
|
364
|
+
ret
|
|
363
365
|
end
|
|
364
366
|
|
|
365
367
|
# Creates a Bio::GFF::GFF2::Record object.
|
data/lib/bio/db/kegg/common.rb
CHANGED
|
@@ -210,6 +210,20 @@ class KEGG
|
|
|
210
210
|
private :strings_as_hash
|
|
211
211
|
end #module StringsAsHash
|
|
212
212
|
|
|
213
|
+
# This module provides diseases_as_hash method.
|
|
214
|
+
#
|
|
215
|
+
# Bio::KEGG::* internal use only.
|
|
216
|
+
module DiseasesAsHash
|
|
217
|
+
include StringsAsHash
|
|
218
|
+
# Returns a Hash of the disease ID and its definition
|
|
219
|
+
def diseases_as_hash
|
|
220
|
+
unless (defined? @diseases_as_hash) && @diseases_as_hash
|
|
221
|
+
@diseases_as_hash = strings_as_hash(diseases_as_strings)
|
|
222
|
+
end
|
|
223
|
+
@diseases_as_hash
|
|
224
|
+
end
|
|
225
|
+
end #module DiseasesAsHash
|
|
226
|
+
|
|
213
227
|
end #module Common
|
|
214
228
|
end #class KEGG
|
|
215
229
|
end #module Bio
|
data/lib/bio/db/kegg/genes.rb
CHANGED
|
@@ -107,6 +107,11 @@ class GENES < KEGGDB
|
|
|
107
107
|
def orthologs_as_hash; super; end if false #dummy for RDoc
|
|
108
108
|
alias orthologs orthologs_as_hash
|
|
109
109
|
|
|
110
|
+
include Common::DiseasesAsHash
|
|
111
|
+
# Returns a Hash of the disease ID and its definition
|
|
112
|
+
def diseases_as_hash; super; end if false #dummy for RDoc
|
|
113
|
+
alias diseases diseases_as_hash
|
|
114
|
+
|
|
110
115
|
# Creates a new Bio::KEGG::GENES object.
|
|
111
116
|
# ---
|
|
112
117
|
# *Arguments*:
|
|
@@ -238,6 +243,27 @@ class GENES < KEGGDB
|
|
|
238
243
|
lines_fetch('PATHWAY')
|
|
239
244
|
end
|
|
240
245
|
|
|
246
|
+
# Networks described in the NETWORK lines.
|
|
247
|
+
# ---
|
|
248
|
+
# *Returns*:: Array containing String
|
|
249
|
+
def networks_as_strings
|
|
250
|
+
lines_fetch('NETWORK')
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Diseases described in the DISEASE lines.
|
|
254
|
+
# ---
|
|
255
|
+
# *Returns*:: Array containing String
|
|
256
|
+
def diseases_as_strings
|
|
257
|
+
lines_fetch('DISEASE')
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# Drug targets described in the DRUG_TARGET lines.
|
|
261
|
+
# ---
|
|
262
|
+
# *Returns*:: Array containing String
|
|
263
|
+
def drug_targets_as_strings
|
|
264
|
+
lines_fetch('DRUG_TARGET')
|
|
265
|
+
end
|
|
266
|
+
|
|
241
267
|
# Returns CLASS field of the entry.
|
|
242
268
|
def keggclass
|
|
243
269
|
field_fetch('CLASS')
|
data/lib/bio/db/kegg/pathway.rb
CHANGED
|
@@ -42,6 +42,11 @@ class PATHWAY < KEGGDB
|
|
|
42
42
|
def orthologs_as_hash; super; end if false #dummy for RDoc
|
|
43
43
|
alias orthologs orthologs_as_hash
|
|
44
44
|
|
|
45
|
+
include Common::DiseasesAsHash
|
|
46
|
+
# Returns a Hash of the disease ID and its definition
|
|
47
|
+
def diseases_as_hash; super; end if false #dummy for RDoc
|
|
48
|
+
alias diseases diseases_as_hash
|
|
49
|
+
|
|
45
50
|
include Common::References
|
|
46
51
|
# REFERENCE -- Returns contents of the REFERENCE records as an Array of
|
|
47
52
|
# Bio::Reference objects.
|
|
@@ -122,17 +127,6 @@ class PATHWAY < KEGGDB
|
|
|
122
127
|
lines_fetch('DISEASE')
|
|
123
128
|
end
|
|
124
129
|
|
|
125
|
-
# Diseases described in the DISEASE lines.
|
|
126
|
-
# ---
|
|
127
|
-
# *Returns*:: Hash of disease ID and its definition
|
|
128
|
-
def diseases_as_hash
|
|
129
|
-
unless (defined? @diseases_as_hash) && @diseases_as_hash
|
|
130
|
-
@diseases_as_hash = strings_as_hash(diseases_as_strings)
|
|
131
|
-
end
|
|
132
|
-
@diseases_as_hash
|
|
133
|
-
end
|
|
134
|
-
alias diseases diseases_as_hash
|
|
135
|
-
|
|
136
130
|
# Returns an Array of a database name and entry IDs in DBLINKS field.
|
|
137
131
|
# ---
|
|
138
132
|
# *Returns*:: Array containing String
|
data/lib/bio/db/soft.rb
CHANGED
|
@@ -217,13 +217,13 @@ class SOFT
|
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
def [](x)
|
|
220
|
-
if x.kind_of?(
|
|
220
|
+
if x.kind_of?( Integer )
|
|
221
221
|
super(x)
|
|
222
222
|
else
|
|
223
223
|
begin
|
|
224
224
|
x = x.to_s.downcase.to_sym
|
|
225
225
|
z = @header_object.column_index[x]
|
|
226
|
-
unless z.kind_of?(
|
|
226
|
+
unless z.kind_of?( Integer )
|
|
227
227
|
raise IndexError, "#{x.inspect} is not a valid index. Contents of @header_object.column_index: #{@header_object.column_index.inspect}"
|
|
228
228
|
end
|
|
229
229
|
self[ z ]
|
|
@@ -547,6 +547,11 @@ module Bio
|
|
|
547
547
|
#BottomRule.is_prior_to(debug_last)
|
|
548
548
|
#fastaformat.is_prior_to(debug_last)
|
|
549
549
|
|
|
550
|
+
## for suppressing warnings
|
|
551
|
+
p medline, aaindex, litdb, fantom, clustal,
|
|
552
|
+
gcg_msf, gcg_seq, blastxml, rpsblast, blat,
|
|
553
|
+
spidey, hmmer, sim4 if false
|
|
554
|
+
|
|
550
555
|
a.rehash
|
|
551
556
|
return a
|
|
552
557
|
end
|
data/lib/bio/io/togows.rb
CHANGED
|
@@ -107,14 +107,14 @@ module Bio
|
|
|
107
107
|
#
|
|
108
108
|
# For light users, class methods can be used.
|
|
109
109
|
#
|
|
110
|
-
# print Bio::TogoWS::REST.entry('
|
|
110
|
+
# print Bio::TogoWS::REST.entry('ncbi-nucleotide', 'AF237819')
|
|
111
111
|
# print Bio::TogoWS::REST.search('uniprot', 'lung cancer')
|
|
112
112
|
#
|
|
113
113
|
# For heavy users, an instance of the REST class can be created, and
|
|
114
114
|
# using the instance is more efficient than using class methods.
|
|
115
115
|
#
|
|
116
116
|
# t = Bio::TogoWS::REST.new
|
|
117
|
-
# print t.entry('
|
|
117
|
+
# print t.entry('ncbi-nucleotide', 'AF237819')
|
|
118
118
|
# print t.search('uniprot', 'lung cancer')
|
|
119
119
|
#
|
|
120
120
|
# == References
|
|
@@ -222,9 +222,9 @@ module Bio
|
|
|
222
222
|
#
|
|
223
223
|
# Example:
|
|
224
224
|
# t = Bio::TogoWS::REST.new
|
|
225
|
-
# kuma = t.entry('
|
|
225
|
+
# kuma = t.entry('ncbi-nucleotide', 'AF237819')
|
|
226
226
|
# # multiple IDs at a time
|
|
227
|
-
# misc = t.entry('
|
|
227
|
+
# misc = t.entry('ncbi-nucleotide', [ 'AF237819', 'AF237820' ])
|
|
228
228
|
# # with format change
|
|
229
229
|
# p53 = t.entry('uniprot', 'P53_HUMAN', 'fasta')
|
|
230
230
|
#
|
|
@@ -366,7 +366,7 @@ module Bio
|
|
|
366
366
|
# Access to the TogoWS by using GET method.
|
|
367
367
|
#
|
|
368
368
|
# Example 1:
|
|
369
|
-
# get('entry', '
|
|
369
|
+
# get('entry', 'ncbi-nucleotide', AF209156')
|
|
370
370
|
# Example 2:
|
|
371
371
|
# get('search', 'uniprot', 'lung cancer')
|
|
372
372
|
#
|
data/lib/bio/map.rb
CHANGED
|
@@ -90,7 +90,7 @@ module Bio
|
|
|
90
90
|
# class MyMapThing
|
|
91
91
|
# include Bio::Map::ActsLikeMap
|
|
92
92
|
#
|
|
93
|
-
# def initialize
|
|
93
|
+
# def initialize(name)
|
|
94
94
|
# @name = name
|
|
95
95
|
# @mappings_as_maps = Array.new
|
|
96
96
|
# end
|
|
@@ -177,7 +177,7 @@ module Bio
|
|
|
177
177
|
# class MyMarkerThing
|
|
178
178
|
# include Bio::Map::ActsLikeMarker
|
|
179
179
|
#
|
|
180
|
-
# def initialize
|
|
180
|
+
# def initialize(name)
|
|
181
181
|
# @name = name
|
|
182
182
|
# @mappings_as_marker = Array.new
|
|
183
183
|
# end
|
|
@@ -301,7 +301,7 @@ module Bio
|
|
|
301
301
|
# * _map_: a Bio::Map::SimpleMap object
|
|
302
302
|
# * _marker_: a Bio::Map::Marker object
|
|
303
303
|
# * _location_: a Bio::Locations object
|
|
304
|
-
def initialize
|
|
304
|
+
def initialize(map, marker, location = nil)
|
|
305
305
|
@map, @marker, @location = map, marker, location
|
|
306
306
|
end
|
|
307
307
|
attr_accessor :map, :marker, :location
|
|
@@ -350,7 +350,7 @@ module Bio
|
|
|
350
350
|
# * type: type of the map (e.g. linkage, radiation_hybrid, cytogenetic, ...)
|
|
351
351
|
# * units: unit of the map (e.g. cM, cR, ...)
|
|
352
352
|
# *Returns*:: new Bio::Map::SimpleMap object
|
|
353
|
-
def initialize
|
|
353
|
+
def initialize(name = nil, type = nil, length = nil, units = nil)
|
|
354
354
|
@name, @type, @length, @units = name, type, length, units
|
|
355
355
|
@mappings_as_map = Array.new
|
|
356
356
|
end
|
data/lib/bio/sequence/format.rb
CHANGED
|
@@ -151,7 +151,7 @@ class CalculatedCuts
|
|
|
151
151
|
def remove_incomplete_cuts(size=nil)
|
|
152
152
|
@strands_for_display_current = false
|
|
153
153
|
@size = size if size
|
|
154
|
-
raise IndexError, "Size of the strand must be provided here or during initalization." if !@size.kind_of?(
|
|
154
|
+
raise IndexError, "Size of the strand must be provided here or during initalization." if !@size.kind_of?(Integer) and not @circular
|
|
155
155
|
|
|
156
156
|
vcuts = @vc_primary + @vc_complement
|
|
157
157
|
hcuts = @hc_between_strands
|
data/lib/bio/util/sirna.rb
CHANGED
|
@@ -278,6 +278,8 @@ module Bio
|
|
|
278
278
|
|
|
279
279
|
# human readable report
|
|
280
280
|
def report
|
|
281
|
+
# raise NomethodError for compatibility
|
|
282
|
+
raise NoMethodError if !defined?(@top_strand) || !@top_strand
|
|
281
283
|
report = "### shRNA\n"
|
|
282
284
|
report << "Top strand shRNA (#{@top_strand.length} nt):\n"
|
|
283
285
|
report << " 5'-#{@top_strand.upcase}-3'\n"
|
data/lib/bio/version.rb
CHANGED
|
@@ -10,19 +10,17 @@
|
|
|
10
10
|
module Bio
|
|
11
11
|
|
|
12
12
|
# BioRuby version (Array containing Integer)
|
|
13
|
-
BIORUBY_VERSION = [
|
|
13
|
+
BIORUBY_VERSION = [2, 0, 2].extend(Comparable).freeze
|
|
14
14
|
|
|
15
15
|
# Extra version specifier (String or nil).
|
|
16
16
|
# Existance of the value indicates development version.
|
|
17
17
|
#
|
|
18
|
-
# nil
|
|
19
|
-
# "
|
|
20
|
-
# ".20150630" :: Development version (specify the date digits).
|
|
18
|
+
# nil :: Release version.
|
|
19
|
+
# ".pre :: Pre-release version.
|
|
21
20
|
#
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
nil #"-dev" #(BIORUBY_VERSION[2] == 0) ? "-dev" : nil
|
|
21
|
+
# References: https://guides.rubygems.org/patterns/#prerelease-gems
|
|
22
|
+
BIORUBY_EXTRA_VERSION = nil
|
|
23
|
+
#".pre"
|
|
26
24
|
|
|
27
25
|
# Version identifier, including extra version string (String)
|
|
28
26
|
# Unlike BIORUBY_VERSION, it is not comparable.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# color_scheme_aa.rb - A Bio::ColorScheme demo script for Amino Acid sequences.
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
#
|
|
7
|
+
# % ruby color_scheme_aa.rb > cs-seq-faa.html
|
|
8
|
+
#
|
|
9
|
+
# % cat seq.faa
|
|
10
|
+
# >AA_sequence
|
|
11
|
+
# MKRISTTITTTITITTGNGAG
|
|
12
|
+
# % ruby color_scheme_aa.rb seq.faa > colored-seq-faa.html
|
|
13
|
+
#
|
|
14
|
+
#
|
|
15
|
+
# Copyright:: Copyright (C) 2005
|
|
16
|
+
# Mitsuteru C. Nakao <n@bioruby.org>
|
|
17
|
+
# License:: The Ruby License
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
require 'bio'
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# returns folded sequence with <br>.
|
|
24
|
+
def br(i, width = 80)
|
|
25
|
+
return "<br\n>" if i % width == 0
|
|
26
|
+
""
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# returns sequence html doc
|
|
31
|
+
def display(seq, cs)
|
|
32
|
+
html = '<p style="font-family: monospace">'
|
|
33
|
+
postfix = '</span>'
|
|
34
|
+
i = 0
|
|
35
|
+
seq.each_char do |c|
|
|
36
|
+
color = cs[c]
|
|
37
|
+
prefix = %Q(<span style="background:\##{color};">)
|
|
38
|
+
html += prefix + c + postfix
|
|
39
|
+
html += br(i += 1)
|
|
40
|
+
end
|
|
41
|
+
html + '</p>'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# returns scheme wise html doc
|
|
46
|
+
def display_scheme(scheme, aaseq)
|
|
47
|
+
html = ''
|
|
48
|
+
cs = Bio::ColorScheme.const_get(scheme.intern)
|
|
49
|
+
[aaseq].each do |seq|
|
|
50
|
+
html += display(seq, cs)
|
|
51
|
+
end
|
|
52
|
+
return ['<div>', "<h3>#{cs}</h3>", html, '</div>']
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if fna = ARGV.shift
|
|
58
|
+
aaseq = Bio::FlatFile.open(fna) { |ff| ff.next_entry.aaseq }
|
|
59
|
+
else
|
|
60
|
+
aaseq = Bio::Sequence::AA.new('ARNDCQEGHILKMFPSTWYV' * 20).randomize
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
title = 'Bio::ColorScheme for amino acid sequences'
|
|
64
|
+
doc = ['<html>',
|
|
65
|
+
'<header>', '<title>', title, '</title>', '</header>',
|
|
66
|
+
'<body>', '<h1>', title, '</h1>']
|
|
67
|
+
|
|
68
|
+
doc << ['<div>', '<h2>', 'Simple colors', '</h2>']
|
|
69
|
+
|
|
70
|
+
['Zappo', 'Taylor' ].each do |scheme|
|
|
71
|
+
doc << display_scheme(scheme, aaseq)
|
|
72
|
+
end
|
|
73
|
+
doc << ['</div>']
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
doc << ['<div>', '<h2>', 'Score colors', '</h2>']
|
|
77
|
+
['Buried', 'Helix', 'Hydropathy', 'Strand', 'Turn'].each do |score|
|
|
78
|
+
doc << display_scheme(score, aaseq)
|
|
79
|
+
end
|
|
80
|
+
doc << ['</div>']
|
|
81
|
+
|
|
82
|
+
puts doc + ['</body>','</html>']
|
data/sample/color_scheme_na.rb
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
# Mitsuteru C. Nakao <n@bioruby.org>
|
|
18
18
|
# License:: The Ruby License
|
|
19
19
|
#
|
|
20
|
-
# $Id: color_scheme_na.rb,v 1.3 2007/04/05 23:35:42 trevor Exp $
|
|
21
20
|
#
|
|
22
21
|
|
|
23
22
|
require 'bio'
|
|
@@ -35,10 +34,10 @@ def display(seq, cs)
|
|
|
35
34
|
html = '<p style="font-family: monospace">'
|
|
36
35
|
postfix = '</span>'
|
|
37
36
|
i = 0
|
|
38
|
-
seq.
|
|
39
|
-
color = cs[c
|
|
37
|
+
seq.each_char do |c|
|
|
38
|
+
color = cs[c]
|
|
40
39
|
prefix = %Q(<span style="background:\##{color};">)
|
|
41
|
-
html += prefix + c
|
|
40
|
+
html += prefix + c + postfix
|
|
42
41
|
html += br(i += 1)
|
|
43
42
|
end
|
|
44
43
|
html + '</p>'
|
|
@@ -48,7 +47,7 @@ end
|
|
|
48
47
|
# returns scheme wise html doc
|
|
49
48
|
def display_scheme(scheme, naseq, aaseq)
|
|
50
49
|
html = ''
|
|
51
|
-
cs =
|
|
50
|
+
cs = Bio::ColorScheme.const_get(scheme.intern)
|
|
52
51
|
[naseq, aaseq].each do |seq|
|
|
53
52
|
html += display(seq, cs)
|
|
54
53
|
end
|
|
@@ -58,7 +57,7 @@ end
|
|
|
58
57
|
|
|
59
58
|
|
|
60
59
|
if fna = ARGV.shift
|
|
61
|
-
naseq = Bio::
|
|
60
|
+
naseq = Bio::FlatFile.open(fna) { |ff| ff.next_entry.naseq }
|
|
62
61
|
aaseq = naseq.translate
|
|
63
62
|
else
|
|
64
63
|
naseq = Bio::Sequence::NA.new('acgtu' * 20).randomize
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env cwl-runner
|
|
2
|
+
|
|
3
|
+
cwlVersion: v1.0
|
|
4
|
+
class: CommandLineTool
|
|
5
|
+
baseCommand: [ruby]
|
|
6
|
+
|
|
7
|
+
inputs:
|
|
8
|
+
- id: script
|
|
9
|
+
type: File
|
|
10
|
+
default:
|
|
11
|
+
class: File
|
|
12
|
+
location: fastq2html.rb
|
|
13
|
+
inputBinding:
|
|
14
|
+
position: -1
|
|
15
|
+
- id: fastq
|
|
16
|
+
type: File[]
|
|
17
|
+
inputBinding:
|
|
18
|
+
position: 1
|
|
19
|
+
|
|
20
|
+
outputs:
|
|
21
|
+
- id: out
|
|
22
|
+
type: stdout
|
|
23
|
+
stdout: $(inputs.script.nameroot)-$(inputs.fastq[0].nameroot).html
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# fastq2html.rb - HTML visualization of FASTQ sequences
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
#
|
|
7
|
+
# % ruby fastq2html.rb seq00.fastq > seq00.html
|
|
8
|
+
#
|
|
9
|
+
#
|
|
10
|
+
# Copyright:: Copyright (C) 2019 BioRuby Project
|
|
11
|
+
# Copyright (C) 2005 Mitsuteru C. Nakao <n@bioruby.org>
|
|
12
|
+
# License:: The Ruby License
|
|
13
|
+
#
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
require 'bio'
|
|
17
|
+
|
|
18
|
+
# thickness to color
|
|
19
|
+
def thickness2color(t)
|
|
20
|
+
c = "%02X" % ((t * 255.0).to_i)
|
|
21
|
+
c * 3
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Creates
|
|
25
|
+
def create_score2color_hashes
|
|
26
|
+
h_bg = {}
|
|
27
|
+
h_char = {}
|
|
28
|
+
cutoff_low = 0
|
|
29
|
+
cutoff_high = 50
|
|
30
|
+
range = cutoff_high - cutoff_low
|
|
31
|
+
sc_min = -5
|
|
32
|
+
sc_max = 100
|
|
33
|
+
(sc_min..sc_max).each do |i|
|
|
34
|
+
t = if i <= cutoff_low then
|
|
35
|
+
0.0
|
|
36
|
+
elsif i >= cutoff_high then
|
|
37
|
+
1.0
|
|
38
|
+
else
|
|
39
|
+
(i - cutoff_low).to_f / range
|
|
40
|
+
end
|
|
41
|
+
h_bg[i] = thickness2color(t)
|
|
42
|
+
h_char[i] = thickness2color((t > 0.3) ? 0.0 : 0.55)
|
|
43
|
+
end
|
|
44
|
+
h_bg.default = h_bg[cutoff_low]
|
|
45
|
+
h_char.default = h_char[cutoff_low]
|
|
46
|
+
[h_bg, h_char]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Color code from quality score
|
|
50
|
+
SCORE2COLOR_BG, SCORE2COLOR_CHAR = create_score2color_hashes
|
|
51
|
+
|
|
52
|
+
# returns folded sequence with <br>.
|
|
53
|
+
def br(i, width = 80)
|
|
54
|
+
return "<br\n>" if i % width == 0
|
|
55
|
+
""
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# returns sequence html doc
|
|
59
|
+
def display(naseq, scores)
|
|
60
|
+
html = '<p style="font-family: monospace">'
|
|
61
|
+
postfix = '</span>'
|
|
62
|
+
i = 0
|
|
63
|
+
naseq.each_char.with_index do |c, i|
|
|
64
|
+
sc = scores[i]
|
|
65
|
+
bgcol = SCORE2COLOR_BG[sc]
|
|
66
|
+
col = SCORE2COLOR_CHAR[sc]
|
|
67
|
+
prefix = %Q(<span style="color:\##{col}; background:\##{bgcol};">)
|
|
68
|
+
html += prefix + c + postfix
|
|
69
|
+
html += br(i += 1)
|
|
70
|
+
end
|
|
71
|
+
html + '</p>'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# returns colorized html doc
|
|
75
|
+
def fastq2html(definition, naseq, scores)
|
|
76
|
+
html = display(naseq, scores)
|
|
77
|
+
return ['<div>', "<div>>#{CGI.escapeHTML(definition)}</div>", html, '</div>']
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
title = 'Sequences with quality scores'
|
|
81
|
+
puts ['<html>',
|
|
82
|
+
'<header>', '<title>', title, '</title>', '</header>',
|
|
83
|
+
'<body>', '<h1>', title, '</h1>']
|
|
84
|
+
|
|
85
|
+
#main loop
|
|
86
|
+
ARGV.each do |filename|
|
|
87
|
+
Bio::FlatFile.open(filename) do |ff|
|
|
88
|
+
ff.each do |e|
|
|
89
|
+
puts fastq2html(e.definition, e.naseq, e.quality_scores)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
puts ['</body>','</html>']
|