@@ -22,7 +22,7 @@ def initialize(data = {})
2222
2323 return unless @upgraded
2424
25- logger . info 'You are using old configuration syntax. ' \
25+ logger . warn 'You are using old configuration syntax. ' \
2626 'Run `sequenceserver -s` to update your config file syntax.'
2727 end
2828
@@ -69,20 +69,7 @@ def normalize(data)
6969 @upgrade = true
7070 end
7171
72- # Old config files may have an options hash with array values. We turn the
73- # array values into a hash. The logic is simple: If the array value is the
74- # same as default, we give it the key 'default', otherwise we give it the
75- # key 'custom'
76- data [ :options ] &.each do |key , val |
77- next if val . is_a? Hash
78-
79- data [ :options ] [ key ] = if val == defaults [ :options ] [ key ] [ :default ]
80- { default : val }
81- else
82- { custom : val }
83- end
84- @upgraded = true
85- end
72+ data [ :options ] = convert_deprecated_options ( data [ :options ] ) if data [ :options ]
8673
8774 data
8875 end
@@ -112,19 +99,34 @@ def defaults
11299 databases_widget : 'classic' ,
113100 options : {
114101 blastn : {
115- default : [ '-task blastn' , '-evalue 1e-5' ]
102+ default : {
103+ description : nil ,
104+ attributes : [ '-task blastn' , '-evalue 1e-5' ]
105+ }
116106 } ,
117107 blastp : {
118- default : [ '-evalue 1e-5' ]
108+ default : {
109+ description : nil ,
110+ attributes : [ '-evalue 1e-5' ]
111+ }
119112 } ,
120113 blastx : {
121- default : [ '-evalue 1e-5' ]
114+ default : {
115+ description : nil ,
116+ attributes : [ '-evalue 1e-5' ]
117+ }
122118 } ,
123119 tblastx : {
124- default : [ '-evalue 1e-5' ]
120+ default : {
121+ description : nil ,
122+ attributes : [ '-evalue 1e-5' ]
123+ }
125124 } ,
126125 tblastn : {
127- default : [ '-evalue 1e-5' ]
126+ default : {
127+ description : nil ,
128+ attributes : [ '-evalue 1e-5' ]
129+ }
128130 }
129131 } ,
130132 num_threads : 1 ,
@@ -137,5 +139,37 @@ def defaults
137139 optimistic : false # Faster, but does not perform DB compatibility checks
138140 }
139141 end
142+
143+ def convert_deprecated_options ( options )
144+ options . each do |blast_algo , algo_config |
145+ if algo_config . is_a? ( Array )
146+ # Very old config files may have a single array with CLI args.
147+ # e.g. { blastn: ['-task blastn', '-evalue 1e-5'] }
148+ # Convert the array values into a single hash naming it 'default' if
149+ # the values match SequenceServer defaults.
150+ options [ blast_algo ] = if algo_config == defaults . dig ( :options , blast_algo , :default , :attributes )
151+ { default : { attributes : algo_config } }
152+ else
153+ { custom : { attributes : algo_config } }
154+ end
155+ @upgraded = true
156+ elsif algo_config . is_a? ( Hash )
157+ # v3.0.1 and older config files contain a flatter structure
158+ # with an array instead of 'description' and 'attributes' keys.
159+ # e.g. { blastn: { default: ['-task blastn', '-evalue 1e-5'] }
160+ algo_config . each do |config_name , config |
161+ next unless config . is_a? ( Array )
162+
163+ options [ blast_algo ] [ config_name ] = {
164+ description : nil ,
165+ attributes : config
166+ }
167+ @upgraded = true
168+ end
169+ end
170+ end
171+
172+ options
173+ end
140174 end
141175end
0 commit comments