11import Base.==
2+ import Base. isequal
23
34type Laboratory
45 pi :: AbstractString
@@ -139,6 +140,7 @@ function convert_for_json(m :: MetaData)
139140 if length (m. media) > 0 d[" media" ] = m. media end
140141 if length (m. sex) > 0 d[" sex" ] = m. sex end
141142 if length (m. stage) > 0 d[" stage" ] = m. stage end
143+ if ! isnan (m. age) d[" age" ] = m. age end
142144 if length (m. protocol) > 0 d[" protocol" ] = m. protocol end
143145 nzsw = filter (x -> length (x) > 0 , map (x -> convert_for_json (x), m. software))
144146 if length (nzsw) > 0
@@ -161,12 +163,12 @@ end
161163
162164function error_if_not_string (a :: Any , err :: AbstractString , msg :: AbstractString )
163165 result :: AbstractString = err
164- if ! ( typeof (a) <: AbstractString ) result = error_accum (err, msg) end
166+ if ! isa (a, AbstractString) result = error_accum (err, msg) end
165167 return result
166168end
167169
168170function empty_if_not_string (a :: Any )
169- if typeof (a) <: AbstractString convert (AbstractString, a) else " " end
171+ if isa (a, AbstractString) convert (AbstractString, a) else " " end
170172end
171173
172174function parsed_json_to_laboratory (m :: Dict{AbstractString, Any} )
@@ -196,9 +198,9 @@ function parsed_json_to_arena(m :: Dict{AbstractString, Any})
196198 err = error_if_not_string (kind, err, string (" Arena " , keys[1 ], " should be a string" ))
197199 diam = make_dbl_array (get (m, keys[2 ], Array {Float64,1} ()))
198200 if length (diam) == 1
199- if ! ( typeof ( diam[1 ]) <: Number ) err = error_accum (err, string (" Arena " , keys[2 ], " should be numeric" )) end
201+ if ! isa ( diam[1 ], Number) err = error_accum (err, string (" Arena " , keys[2 ], " should be numeric" )) end
200202 elseif length (diam) == 2
201- if ( ! diam[1 ] <: Number && diam[2 ] <: Number ) err = error_accum (err, string (" Arena " , keys[2 ], " should have only numeric entries" )) end
203+ if ! ( isa ( diam[1 ], Number) && isa ( diam[2 ], Number) ) err = error_accum (err, string (" Arena " , keys[2 ], " should have only numeric entries" )) end
202204 elseif length (diam) > 2
203205 err = error_accum (err, string (" Arena " , keys[2 ], " size should have at most two dimensions" ))
204206 end
@@ -227,14 +229,14 @@ function parsed_json_to_software(m :: Dict{AbstractString, Any})
227229 err = error_if_not_string (name, err, string (" Software " , keys[2 ], " should be a string" ))
228230 fid = get (m, " featureID" , " " )
229231 featureID :: Set{AbstractString} = Set {AbstractString} ()
230- if ( typeof ( fid) <: AbstractString )
232+ if isa ( fid, AbstractString)
231233 str = convert (AbstractString, fid)
232234 if length (str) > 0 featureID = Set (str) end
233- elseif typeof (fid) <: Array
235+ elseif isa (fid, Array)
234236 sid = convert (Array, fid)
235237 allstring = true
236238 for s in sid
237- if ! ( typeof (s) <: AbstractString ) allstring = false end
239+ if ! isa (s, AbstractString) allstring = false end
238240 end
239241 if ! allstring err = error_accum (err, " Software featureIDs should all be strings" )
240242 else
@@ -283,7 +285,7 @@ function parsed_json_to_metadata(d :: Dict{AbstractString, Any})
283285 if onestring[i]
284286 s = get (d, keys[i], " " )
285287 strings[i] = empty_if_not_string (s)
286- if ! ( typeof (s) <: AbstractString )
288+ if ! isa (s, AbstractString)
287289 err = error_accum (err, string (" MetaData " , keys[i], " should be a string" ))
288290 end
289291 end
@@ -292,9 +294,9 @@ function parsed_json_to_metadata(d :: Dict{AbstractString, Any})
292294 for i in 1 : length (keys)
293295 if vecstring[i]
294296 s = get (d, keys[i], Array {AbstractString,1} ())
295- if typeof (s) <: AbstractString
297+ if isa (s, AbstractString)
296298 vstrings[i] = Array (convert (AbstractString, s))
297- elseif typeof (s) <: Array{AbstractString,1}
299+ elseif isa (s, Array{AbstractString,1 })
298300 vstrings[i] = convert (Array{AbstractString,1 }, s)
299301 else
300302 err = error_accum (err, string (" MetaData " , keys[i], " should be a string or array of strings" ))
@@ -305,7 +307,7 @@ function parsed_json_to_metadata(d :: Dict{AbstractString, Any})
305307 for i in 1 : length (keys)
306308 if onenumber[i]
307309 n = get (d, keys[i], NaN )
308- if typeof (n) <: Number
310+ if isa (n, Number)
309311 numbers[i] = convert (Float64, n)
310312 else
311313 err = error_accum (err, string (" MetaData" , keys[i], " should be a numeric value" ))
@@ -315,10 +317,10 @@ function parsed_json_to_metadata(d :: Dict{AbstractString, Any})
315317 laboratory =
316318 if haskey (d, " lab" )
317319 l = d[" lab" ]
318- if typeof (l) <: Dict{AbstractString, Any}
320+ if isa (l, Dict{AbstractString, Any})
319321 ld = convert (Dict{AbstractString, Any}, l)
320322 lab = parsed_json_to_laboratory (ld)
321- if typeof (lab) <: AbstractString
323+ if isa (lab, AbstractString)
322324 err = error_accum (err, convert (AbstractString, lab))
323325 Nullable {Laboratory} ()
324326 else
@@ -333,10 +335,10 @@ function parsed_json_to_metadata(d :: Dict{AbstractString, Any})
333335 arena =
334336 if haskey (d, " arena" )
335337 a = d[" arena" ]
336- if typeof (a) <: Dict{AbstractString, Any}
338+ if isa (a, Dict{AbstractString, Any})
337339 ad = convert (Dict{AbstractString, Any}, a)
338340 arn = parsed_json_to_arena (ad)
339- if typeof (arn) <: AbstractString
341+ if isa (arn, AbstractString)
340342 err = error_accum (err, convert (AbstractString, arn))
341343 Nullable {Arena} ()
342344 else
@@ -350,18 +352,18 @@ function parsed_json_to_metadata(d :: Dict{AbstractString, Any})
350352 softwares =
351353 if haskey (d, " software" )
352354 s = d[" software" ]
353- if typeof (s) <: Dict{AbstractString, Any}
355+ if isa (s, Dict{AbstractString, Any})
354356 s = Array (s)
355357 end
356- if typeof (s) <: Array
358+ if isa (s, Array)
357359 sa = convert (Array, s)
358360 softs = fill (empty_software (), length (sa))
359361 for i in 1 : length (sa)
360362 si = sa[i]
361- if typeof (si) <: Dict{AbstractString, Any}
363+ if isa (si, Dict{AbstractString, Any})
362364 sid = convert (Dict{AbstractString, Any}, si)
363365 soft = parsed_json_to_software (sid)
364- if typeof (soft) <: AbstractString
366+ if isa (soft, AbstractString)
365367 err = error_accum (err, convert (AbstractString, soft))
366368 else
367369 softs[i] = convert (Software, soft)
0 commit comments